Examples

Board

Board, columns and cards, with rank ordering from a per-parent string sequence.

Card ordering belongs to a column. Adding more cards later should continue that column's ranks without changing another column's sequence. This example uses string ranks to show that sequences are useful beyond integer IDs.

A kanban board: Board → Column → Card. Cards are ordered by a string rank ("a", "aa", "aaa"…, in the spirit of LexoRank) that restarts for every column. Source: tests/Zeeq.Biome.Tests/Board.

Every scenario exists twice in one BoardTests partial class: BoardTests.WithBiome.cs uses Biome, and BoardTests.Typical.cs sets up the same entities by hand with identical assertions. Read them side by side to see what Biome removes.

The blueprints

Board/Domain.cs
// Give each column its own rank progression so sibling columns can start at "a".
internal static readonly Sequence<string> Ranks = Sequence
    .Of("a", rank => rank + "a")
    .PerParent();

internal static readonly Blueprint<BoardSeed, Board> Board = Blueprint.For<BoardSeed, Board>(
    _ => new()
);

internal static readonly ChildBlueprint<BoardSeed, Board, Column> Column = Blueprint.ChildOf<
    BoardSeed,
    Board,
    Column
>((board, _) => new() { Board = board });

internal static readonly ChildBlueprint<BoardSeed, Column, Card> Card = Blueprint
    .ChildOf<BoardSeed, Column, Card>((column, _) => new() { Column = column })
    // Fill the null rank after customizers have had a chance to set it.
    .Derive(c => c.Rank, Ranks);
Rank is declared string Rank { get; set; } = null!; and is null until the Derive runs. A default of "" would count as explicitly set, and the sequence would never fill it.

Ranks resume per column, and .Under revisits

await TestBiome
    .Start(out _)
    .AddBoard(out var board)
    .AddColumns(out var columns, 2)
    .AddCards(out var cards, 2)
    // Revisit the first column to continue its ranks at "aaa".
    .Under(columns[0])
    .AddCard(out var next)
    // Return to the board to create a sibling column with a fresh rank sequence.
    .Under(board)
    .AddColumn(out var sibling)
    .AddCard(out var siblingCard)
    .BuildAsync();

Assertions in the real test: cards[0].Rank == "a", cards[1].Rank == "aa", cards[2].Rank == "a", next.Rank == "aaa", siblingCard.Rank == "a".

Scope is declared on the sequence, not chosen by .Under or a customizer. PerParent keys state by the column's reference identity, so two columns never share a counter, and .Under(columns[0]) always resumes the right one.

An explicit rank is reserved only in its own column

BoardTests.WithBiome.cs
await TestBiome
    .Start(out _)
    .AddBoard(out _)
    .AddColumns(out var columns, 2)
    // Reserve "a" in the first column so its generated rank skips to "aa".
    .Under(columns[0])
    .AddCards(out var first, _ => { }, c => c.Rank = "a")
    // The first column's reservation leaves "a" available here.
    .Under(columns[1])
    .AddCard(out var other)
    .BuildAsync();

// first[0].Rank == "aa"; other.Rank == "a"