Skip to content

test(gateway): end-to-end accept trace over real SQLite rows and the real routes (composition) - #433

Draft
LamaSu wants to merge 1 commit into
feat/mc9-child-reservationsfrom
test/composition-real-state-trace
Draft

LamaSu wants to merge 1 commit into
feat/mc9-child-reservationsfrom
test/composition-real-state-trace

Conversation

@LamaSu

@LamaSu LamaSu commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Draft, test-only, stacked on #415. The composition path end to end over REAL SQLite rows, through the REAL HTTP routes. The product pack's return asks for "one end-to-end trace proving the lane's contribution against real state, not fixtures". Until now the traces held live rows as in-memory arrays.

What is real

  • The store: the gateway's own store (initStore, getRepos, getStore), a real SQLite database migrated by the real createStore.
  • Rows: capability and kernel rows are inserted, and later price-updated, through the real repositories.
  • Re-read: productionAgentPlanDeps().revalidation runs unchanged, both for /api/agent-plans/validate and inside the accept seam. It is the real mapping from DB rows to live terms, over the real CSD registry (getCsdRegistry()).
  • Routes and pipeline: the real agentPlanRoutes and reservationRoutes, the accept seam, the deal binding and presentPlan. Layer B and sealed come from the code; nothing is asserted by hand.
  • Reservations: the durable BudgetReservationStore over the SAME SQLite handle, with the real consume protocol, sealedDealPreimage and parseSealedDeal.

The trace (one test, 6 steps; the artifact is written when PCC_REAL_TRACE_OUT is set)

  1. validate: every node current, and the live terms equal the DB rows;
  2. the payer issues a reservation;
  3. accept: 200, layer B, sealed; the read-back is consumed with the same digest;
  4. the stored sealed deal hashes to the digest and parses;
  5. a real provider price change in the DB: the same old claim is now stale, with a price diff and the new live price;
  6. MC 9: the print operator carves a child reservation from the sealed unit, with its own wallet.

The artifact is /mnt/sparkbulk/pcc-reconciliation/returns/pcc-composition-real-state-trace.json.

What is still a labelled stand-in, and why

⚠ Gap found: the reference vertical's CSD is not registered in production

loadBuiltinCsds() (packages/spec/src/csd/registry.ts) never registers document-print-and-mail.csd.json, a workflow-kind CSD. So in production, getCsdRegistry().findUrlByType("document-print-and-mail") is undefined: the print leg of the reference vertical cannot resolve its CSD, and validate or accept would answer incompatible.

  • The test PROVES the gap first.
  • It then registers the unmodified JSON through the registry's own register(), the same call POST /api/csd makes.
  • The fix belongs in the builtins list. It has been raised with the steward to route to its owner.

Tests

  • This file: 1 test, 6 steps.
  • With reservations-route and agent-plans-route in the same run: 28/28. No singleton leaks between files.
  • tsc: no errors in this file.

Written by a sonnet subagent (implementer-delta) to the lane's spec, and reviewed and re-run by the lane.

pcc-composition 8a0f4de0, goal pcc-reconciliation.

🤖 Generated with Claude Code

…REAL HTTP routes

Proves composition R10 (validate -> issue -> accept -> sealed read-back ->
real price change -> MC 9 child) against the real gateway store (initStore/
getRepos), real kernel/capability rows, the real CsdRegistry, and the real
agentPlanRoutes/reservationRoutes + accept seam/deal-binding/PlanPresentation,
over one durable BudgetReservationStore sharing getStore()'s sqlite handle.

Found and closed a real gap: loadBuiltinCsds() (packages/spec/src/csd/
registry.ts:397-406) omits document-print-and-mail.csd.json, so the shared
getCsdRegistry() singleton can't map a capability type to it today. Proven
with an `undefined` assertion, then closed the same way POST /api/csd would:
registering the real CSD JSON via the real .register() method.

Also deviates from the literal evidenceFor spec: keying evidenceTypeId on
primitive.id alone collides for document-print-and-mail's tier1-3 (two
primitives share id "machine.execution_log", differing only by `bind`), and
the real compiler's uniqueness-per-(evidenceTypeId,tier) check (composition-
commitment.ts:220) refuses the plan. Keyed on primitive.bind ?? primitive.id
instead, matching how this codebase's own existing stand-in EVIDENCE maps
already do it.

implementer-delta

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant