Skip to content

docs(architecture): document how the six packages connect - #72

Merged
myselfsiddharth merged 2 commits into
mainfrom
wave0/b0-architecture-doc
Jul 25, 2026
Merged

docs(architecture): document how the six packages connect#72
myselfsiddharth merged 2 commits into
mainfrom
wave0/b0-architecture-doc

Conversation

@OM152002

Copy link
Copy Markdown
Collaborator

Closes #55.

Adds docs/architecture.md — the document that owns the chain between the six src/ packages. The docs/gate/*.md specs each describe one hop; this one describes what hands what to whom, under which contract, and where the chain is not connected yet.

Derived from the code at 6ad7151, not from sibling docs.

What's in it

  1. The loop, in one mermaid flowchart LR — testbed → recorder → trajectory.json → compiler → bundle → cache write (pool/tenant split) → runner replay → repair → metrics NDJSON → gate report, with the governing contract on every edge.
  2. Package table — responsibility, public entry point, contract read, contract written, spec doc, one row per package (plus experiments/gate-v1/).
  3. Artifact table — every file the pipeline produces, where it lands, committed vs gitignored.
  4. What is real vs stubbed today — eight rows, each with the file:line proving it and a live issue that fixes it.
  5. Invariants that must not break — frozen assertions, fail-closed pool writes, no typed values in a trajectory, no_data over invented rates, and the harness staying throwaway.
  6. Open questions / what I could not verify — including the doc-vs-code disagreements below.

⚠️ Two hops in the pipeline do not exist

The diagram draws these as dashed red edges rather than pretending the chain is whole:

  1. The bundle never reaches the cache. Nothing outside src/cache/ and tests/ imports the cache package — so writeCacheRow, the authoritative write-time privacy boundary, is never called by the pipeline. The pool_eligible flag on a bundle row comes from the compiler's own pre-check (src/compiler/pool.ts). Both fail closed and the compiler's doc honestly calls itself a pre-check — but today nothing calls the authority.
  2. The bundle never reaches the runner. The runner consumes CompiledProgram (src/runner/types.ts), a different shape from CompiledTrajectoryBundle, and no adapter exists. npm run gate:matrix loads a hand-written experiments/gate-v1/fixtures/compiled-program.json instead.

Both close with #52. Every hop is unit-tested; the seams between them are not.

Per the issue's constraint, I recorded rather than resolved the resulting doc conflicts — no sibling doc was edited:

  • DEVELOPMENT.md "The data flow" shows cache write (fail-closed) as a step in the chain, and its layout table says cache-row.schema.json — compiler + cache write, runner reads.
  • contracts/README.md lists cache-row.schema.json as read by "B4" (the runner) — true by shape, false by wiring.

Whether those are describing intent or are stale is the owners' call, so both are in Open questions.

Stub → issue mapping

Every stub links a live issue: StubRepairModelClient#27 · cost_fresh zeros → #39 · run-matrix.ts exit-2 → #62 · placeholder versions.json#26 · cache read path/persistence → #63 · confidence updates → #64 · both unwired hops → #52 · missing cache hit-rate metric → #67.

How this was verified

npm run lint:docs does not exist yet — it is #53, already flagged in DEVELOPMENT.md's own open questions. The issue's stated test could not be run, so I substituted stronger checks and noted this in the doc:

Check Result
npm run ci green (secret-scan, contracts, lint, typecheck, 35 unit tests)
npm run test:canary green (6 tests)
Every repo path named in the doc exists at HEAD scripted sweep — all resolve; the only misses are experiments/gate-v1/out/*, which are gitignored generated output and correctly described as such
Every file:line reference spot-checked each one against sed -n output
Every relative doc link scripted — all 12 resolve
Mermaid renders rendered with real mermaid 11 in headless Chromium: RENDER_OK, 14 nodes / 14 edges, zero console errors, and linkStyle 4/7 confirmed to land on the two dashed edges
Artifact table accuracy ran gate:matrix -- --dry-run + gate:report and diffed the produced file list against the table; also confirmed npm run compile leaves the committed bundle byte-identical
Aggregate claims ran the report: 7 sections, no_data on exactly the four with no denominator

Frontmatter matches the CONTRIBUTING standard (doc_type: spec) and the doc ends with ## Open questions / what I could not verify. docs/README.md index row added under Start here.

The test the doc exists for

open it against a fresh checkout and confirm you can answer, without opening a source file, "where does a trajectory come from, and what reads it?"

There is a Reading the diagram subsection directly under the mermaid block that answers exactly that question in one paragraph, naming the CLI that writes it, the default output path, and the single reader.

Follow-up (not in this PR)

🤖 Generated with Claude Code

Each src/ package had a spec doc under docs/gate/ describing one hop; nobody
owned the chain. docs/architecture.md now does: a mermaid flowchart LR with
the governing contract on every edge, a package table (responsibility, entry
point, contracts read/written, spec doc), an artifact table marking each
produced file committed or gitignored, a real-vs-stubbed section linking a
live issue per stub, and the invariants with the code that enforces them.

Derived from the code at 6ad7151, not from sibling docs. Two findings the
existing prose does not reflect, recorded as the diagram's dashed edges:

- Nothing outside src/cache/ and tests/ imports the cache package, so the
  authoritative write-time boundary (writeCacheRow) is never called by the
  pipeline. The pool_eligible flag on a bundle row comes from the compiler's
  own pre-check instead.
- The runner consumes CompiledProgram, a different shape from the compiler's
  CompiledTrajectoryBundle, and no adapter exists; gate:matrix loads a
  hand-written fixture.

Both are issue #52. Where DEVELOPMENT.md and contracts/README.md disagree with
the code on these two hops, the disagreement is recorded in Open questions
rather than silently resolved or edited away.

npm run lint:docs does not exist yet (#53), so the doc was checked with
npm run ci, npm run test:canary, a path-existence sweep over every repo path
it names, and a real mermaid 11 render of the diagram.

Closes #55
@OM152002
OM152002 requested review from a team and myselfsiddharth as code owners July 25, 2026 09:43
@github-actions github-actions Bot added the size/L <= 600 changed lines label Jul 25, 2026
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 25, 2026

@myselfsiddharth myselfsiddharth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@myselfsiddharth
myselfsiddharth merged commit 605c384 into main Jul 25, 2026
12 checks passed
@myselfsiddharth
myselfsiddharth deleted the wave0/b0-architecture-doc branch July 25, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L <= 600 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write docs/architecture.md — how the six packages actually connect

2 participants