Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions CLAUDE.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<!-- After twin: Critter Stack 2026 line (Wolverine 6 / Marten 9) -->
<ItemGroup>
<PackageVersion Include="WolverineFx.Http" Version="6.30.0" />
<!-- Added 2026-09-09 (Erik's call): the core after twin moved from Marten
to EF Core so both twins share the ORM and only the architecture
changes between them. The one exception to the version freeze; both
packages track the existing Wolverine pin, and the EF Core / Npgsql
pins are the before twin's, reused as-is. WolverineFx.Marten stays
below for the Marten twin, now experiments/after-marten/. -->
<PackageVersion Include="WolverineFx.EntityFrameworkCore" Version="6.30.0" />
<PackageVersion Include="WolverineFx.Postgresql" Version="6.30.0" />
<PackageVersion Include="WolverineFx.Marten" Version="6.30.0" />
<!-- Wolverine 6 no longer ships the Roslyn runtime compiler in core;
Dynamic codegen (the dev/demo default) throws at startup without this.
Expand Down
52 changes: 32 additions & 20 deletions README.md

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions docs/build-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,18 @@ Running record of decisions made during build sessions: anything a later session
- **Live run, same day (Erik asked for it)**: the template host was run with `dotnet run` against a throwaway `postgres:17` container (port 55432, removed afterwards; the compose database was never touched), bound to its own port 5113 and to the before twin's 42010. Every route answered as the suite says: ping, browse (three seeds, ordered by name), 201 with `Location` and body, get by id, 404, two 400s, 409, `/openapi/v1.json` listing `/cakes`, `/cakes/{id}`, `/ping`, and the untouched sample `/api/TodoLists` still 401 without a token. Scalar renders the Cakes group. The repo's demo page in Before mode, driven with Playwright, listed the template's catalog, published a cake through its form, and showed the 409 detail and the 400 title. Two things seen and left alone: the page reports `Location: null` because the template's CORS policy does not expose that header to browsers (the raw response carries it; the twins add `WithExposedHeaders`), and the baker's board shows HTTP 404 because the template has no such endpoint.
- **2026-09-06** Doc-only, counts unchanged: `README.md` and `CLAUDE.md` now acknowledge the template experiment (where it lives, why its test project is separate, the explicit `dotnet test` command, 6/10 as shipped, the 9 / 8 number) and link to the inventory's experiment section and the entry above instead of restating them. `CLAUDE.md` also gains the experiments paragraph (outside the slnx, the scorecard, the version freeze, and the OpenSpec loop), the name-after-the-artifact rule, the experiment variant of workflow step 3, and the three open calls from PR #15. No code, no `openspec/` change, no count moved.
- **2026-09-07** Duplicate-name backstop, third look. The mock audience synthesis (2026-09-07) restated the skeptic review's 2026-09-04 finding that the after twin lacked a unique index on `Cake.Name` and asked for one so both twins back the 409 guard at the database. The gap had already been closed twice over: the index shipped in Audit Tier 2 (`b24a723`, PR #5, 2026-09-04) as `opts.Schema.For<Cake>().UniqueIndex(UniqueIndexType.Computed, x => x.Name)` in `src/after/LayerCake.Slices/Program.cs`, and the 2026-09-05 hardening added the shared `database_refuses_duplicate_cake_name_behind_the_api` scenario that turns red when either twin's index is removed. Adding the statement again would have registered the same index twice, so no code changed this session. Re-verified instead: `SeedData` seeds three distinct cake names; the fixture's `ApplyAllConfiguredChangesToDatabaseAsync` builds the index on every fresh Testcontainers database; the pre-existing compose volume already carries `after.mt_doc_cake_uidx_name` (`CREATE UNIQUE INDEX ... USING btree ((data ->> 'name'))`, Marten's default `AutoCreate.CreateOrUpdate` patched the table on 2026-09-05, so no `down -v` is needed for the live demo); suite 54/54 (27 scenarios x 2) and 15/15. Whole-twin counts recounted by the inventory's rule and unchanged: before 2,140 raw / 1,775 non-blank, after 703 / 581; the index and its comment have been inside the after twin's number since 2026-09-04. Nothing for the deck's scorecard to propagate.
- **2026-09-09** **The core after twin moved from Marten to EF Core; the Marten twin became an experiment.** Erik's call, the day before the talk, and the reason is the argument, not the stack: the talk is about architecture (A-Frame, Railway Oriented Programming, pure functions, distance), and a room that sees Marten on the after side asks "you changed your ORM, is this a Critter Stack talk?" and stops listening. With EF Core on both sides the confounded variable in slide 2.5 shrinks to the one the talk is actually about. Tagged `kcdc-marten-baseline` at `70a2b13` first, so the Marten deck and twin are one checkout away.
- **The move.** `src/after/LayerCake.Slices` became `experiments/after-marten/LayerCake.Slices.Marten` (project and assembly renamed; namespaces deliberately left as `LayerCake.Slices`, so the diff is a rename and nothing else). Its unit tests moved with it as `tests/LayerCake.Slices.Marten.Tests`. A new `tests/LayerCake.ContractTests.Marten` binds the unchanged shared scenario classes to it, exactly as `tests/LayerCake.ContractTests.CleanTemplate` does for the template experiment. Both are outside `LayerCake.slnx`, so root `dotnet test` is still two hosts. The Marten twin's assembly is aliased (`Aliases="marten"`) in that test project: because its namespaces stayed, every shared type name (`AfterTwin`, `SeedData`, `Cakes.Cake`) would otherwise be ambiguous against the EF Core twin that arrives through the scenario project reference. Same trick, same reason, as the template host's `cleantemplate` alias.
- **The new twin, same shape.** Same folders, same file names, same endpoint methods, same guard order, same `Decide` with the same `MidpointRounding.ToEven` arithmetic (`PlaceOrderTests` and `CouponValidationTests` are byte-identical to the Marten twin's). `[Entity(Required = true, OnMissing = OnMissing.ProblemDetailsWith404)]` still loads `GetCake` and `GetOrder`, now against the DbContext. `PlaceOrder.Post` still returns `(PlacedOrder, NotifyBaker)`. No `SaveChanges` in any endpoint.
- **The DbContext is never edited per feature, and that is the point.** `LayerCakeDbContext` has no `DbSet` properties and no per-entity mapping: `HasDefaultSchema("after")` plus `ApplyConfigurationsFromAssembly`. Each table configures itself in its own feature file beside the type it maps (`Cakes/Cake.cs` carries `Cake` and `CakeTable`, `Orders/Order.cs` carries `Order`, `OrderLine` and `OrderTable`), and endpoints reach for `db.Set<T>()`. So the scorecard line "on the order slice the after twin edited zero existing files" survives the ORM change, which is the whole reason for the shape. The before twin's DbContext is edited by three of the four slices.
- **Order lines stay one column.** `OwnsMany(o => o.Lines, lines => lines.ToJson())`, so `after.orders` has a jsonb `Lines` column and no child table and no foreign key, matching what the document store did by default and keeping the wire shape identical. Money columns are `HasPrecision(10, 2)` on both twins.
- **No migrations folder in the after twin.** `opts.UseEntityFrameworkCoreWolverineManagedMigrations()` plus `builder.Services.AddResourceSetupOnStartup()`: Weasel builds the tables this DbContext describes, and Wolverine's own envelope tables, when the host starts. `EnsureCreatedAsync` was rejected on purpose, and this is worth remembering: it does nothing at all when the database already exists, and both twins share one database, so it would have been a silent no-op under Testcontainers and live. Seeding therefore moved into a `SeedOnStartup` hosted service registered after Wolverine (Development only), because the schema does not exist until the host starts. The contract fixture seeds itself as it always did.
- **`Storage.Store<T>` is not portable, and that cost the afternoon's one real debugging hour.** `NotifyBakerHandler` returning `Store<BakerTask>` compiled, ran, logged nothing, and produced no row. The generated code says why: `// No explicit update necessary with EF Core without a Version property`. Wolverine's EF Core storage-action applier treats `Store` as update-of-a-tracked-entity, not upsert, so for a new row it is a no-op. (`codegen preview` found this in one command; the debug logs alone only showed the message arriving at the durable inbox and nothing after.) Two further facts fell out of the same hour: a handler returning an `ISideEffect` does NOT get `AutoApplyTransactions` (it has no DbContext dependency for the policy to notice), so nothing calls `SaveChangesAsync` and the write vanishes just as silently; and both symptoms look identical from the outside.
- **So the baker notification is now a side effect plus one attribute.** `Orders/NotifyBaker.cs` holds `AddBakerTask : ISideEffect` with `ExecuteAsync(LayerCakeDbContext db, CancellationToken ct)`, and `NotifyBakerHandler.Handle` stays a pure function returning it, marked `[Transactional]`. The side effect checks for an existing task by order id before adding, because the broker delivers at least once and EF Core inserts where Marten upserted on the identity. That check is the honest cost of the move and belongs on a slide if the outbox slide has room: the document store made redelivery harmless for free; the relational store makes it three lines. `NotifyBakerHandlerTests` now asserts on the returned side effect's fields, still with no context real or faked.
- **Reads say they are reads.** `BrowseCakes`, `ValidateCoupon` and `GetBakerTasks` are `[NonTransactional]` with `AsNoTracking()`, which is the EF Core way of saying what `IQuerySession` said on the Marten side. Without it `AutoApplyTransactions` opens a transaction around every GET.
- **Messaging unchanged.** Same queue name, same `PublishMessage<NotifyBaker>().ToRabbitQueue(...).UseDurableOutbox()`, same `ListenToRabbitQueue`, same `AutoProvision()`. Verified rather than assumed: the generated `PlaceOrder` endpoint writes `INSERT INTO after.orders` and `INSERT INTO after.wolverine_outgoing_envelopes` in one command batch, one transaction, and the sender opens its channel after the commit.
- **Packages.** `WolverineFx.EntityFrameworkCore` and `WolverineFx.Postgresql` added at 6.30.0, tracking the existing Wolverine pin; EF Core 10.0.4 and Npgsql 10.0.3 reused from the before twin's pins. This is the one exception to the version freeze (plan.md decision 26 on the talk side). `WolverineFx.Marten` and `Marten` stay pinned for the experiment.
- **Results.** Root `dotnet test` on `LayerCake.slnx`: 54/54 contract scenarios (27 x 2 hosts) and 15/15 after-twin unit facts, 0 warnings. 16.9 s warm, 22.1 s cold after `dotnet clean`, both well inside the thirty seconds the live moment needs. Marten experiment: `tests/LayerCake.ContractTests.Marten` 27/27, `tests/LayerCake.Slices.Marten.Tests` 15/15. Template experiment re-run and undisturbed at 6/10, exactly as committed. Live run against `docker compose up -d`: schema built and seeded on startup, `/ping`, `/cakes`, `/cakes/{id}`, `/coupons/bday10` (valid, 10% off), `POST /orders` with `BDAY10` returning subtotal 68.00, discount 6.80, total 61.20, the baker task appearing on `/baker/tasks?orderId=...` after the message crossed RabbitMQ, and Swagger UI 200.
- **Counts.** Before twin untouched at 2,140 raw / 1,775 non-blank. After twin 844 / 707, up from the Marten twin's 703 / 581. Per-slice file counts for the after twin are unchanged, path for path. Full breakdown, including the file-by-file delta and the DbContext-caller list slide 4.2 needs, in `docs/file-inventory.md` (2026-09-09 section).
- **Two shared test files were edited, both twin bindings and no scenario.** `tests/LayerCake.ContractTests/TwinHosts.cs` (the after fixture wipes tables and re-seeds through the DbContext instead of `CleanAllMartenDataAsync`) and `CakeScenarios.cs` (`AfterTwinCakes.InsertCakeDirectlyAsync` inserts through the DbContext instead of a Marten session). Both files also gained `AfterDb` / `BeforeDb` using-aliases, because both twins now have a type called `LayerCakeDbContext`. No assertion, no scenario name and no abstract member changed; the 27 scenarios are the same 27.
- **For Erik**: (a) the scorecard ratio moves from about 3.0x to about 2.5x and slide 4.4 has to say the new number; (b) slide 4.2's DbContext-caller count is 9 methods in 7 files, or 8 in 6 if seeding is excluded as non-feature code, and the inventory lists both; (c) the `[Transactional]` attribute and the three-line redelivery check on `AddBakerTask` are new honest costs that the Marten version did not pay, and the outbox slide can either own them in a sentence or not mention them; (d) `openspec/specs/` was not touched: no built behaviour changed, the HTTP contract is byte-identical and all 54 scenarios are unchanged, so the archived specs still describe what ships.
Loading