Skip to content

wiki: describe the Brain snapshot echo as what releases actually carry - #62

Merged
Deicyde merged 5 commits into
mainfrom
claude/worker-snapshot-contract
Oct 14, 2026
Merged

Deicyde merged 5 commits into
mainfrom
claude/worker-snapshot-contract

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Problem

Every Brain API and MCP response echoes snapshot:{generated_at, pin} from the release's cells/manifest.json. The MCP initialize instructions describe those fields as "the brain build time and the Mathlib rev the decls were built against" (wiki/src/mcp.ts:84-85 at 37b7036). Since the offline-replay release went live on 2026-10-04, neither description holds. A live GET /api/brain/search?q=group returns:

  • generated_at: sha256:b3016dec…, which is the release's replay.generation_id;
  • pin: sha256:9dbb5d68…, which is prov row 0 (source: mathlib, method: agent+oracle). That is the concept-graph family's dataset revision, a digest over the Mathlib tree and WikiLean annotations, Wikidata, TheoremGraph and curated grounding.

Agents told to read these as a build time and a Mathlib revision get neither. docs/BRAIN-API.md and the brain-query skill made the same claim.

Could the Worker expose the real values instead? No:

  • release.json has no created_at.
  • authority.git_commit and reducer.git_commit are WikiLean commits.
  • The selector's audited_at is a promotion time outside release identity.
  • sources.json and the cells manifest carry no mathlib4 commit.
  • The only 40-hex prov pin is TheoremGraph's dataset revision.
  • The real mathlib4 commit exists only in private pack evidence.

So this PR changes the description, not the values.

Change

  • These places now say the same thing:
    • the MCP initialize instructions;
    • the /brain/api reference;
    • docs/BRAIN-API.md ("Release and snapshot echo");
    • both brain-query skill copies (.claude/skills/ and .agents/skills/);
    • the snapshot-echo section header in wiki/src/brain-api.ts.
  • What they say:
    • release_id identifies the whole release.
    • generated_at and pin are opaque provenance values of the release's inputs.
    • Compare them for equality, never parse them, and do not read them as a build time or a Mathlib revision.
  • The public text names no selection rule, row order or per-profile pin shape. Those hold only because of the builder's current prov row order, which is how the old text went wrong.
  • docs/BRAIN-API.md no longer says a held-out evaluation is dishonest without the snapshot. It asks evaluations to record release_id, which identifies the release that answered.
  • The mathlibPin/Snapshot code comments describe what the code does:
    • it returns the first git-commit-shaped pin on a mathlib/kerodon/stacks row, else the first such row's pin;
    • the only git-shaped value ever seen there is a 16-hex truncation of TheoremGraph's statement_formal.csv digest (bf3266149cda603f), never a Mathlib commit;
    • with the current row order, offline-replay releases return the concept-graph family's sha256: digest, and brain-current-v1 releases return a date.
  • Values are unchanged.
  • /brain/api and /mcp HTML are not KV-cached; they only carry Cache-Control: max-age=3600. No render-cache key is involved.

How tested

  • npx vitest run test/brain-api.test.ts: 150 pass.
    • A new case pins the fallback rules: a kerodon row interned first wins, TheoremGraph's hex pin is skipped, and a git-shaped pin (the old 16-hex truncation) beats an earlier non-shaped mathlib row.
    • Mutation check: deleting the shape branch in mathlibPin fails that case. The previous version of the case passed under the same mutation.
    • A new case builds a real brain-offline-replay-v1 release (no created_at) whose prov rows follow the live order: the concept-graph row, then attribute rows with a different digest, then TheoremGraph's 40-hex revision. It asserts the echo is {generated_at: <generation id>, pin: <first mathlib-row digest>}.
    • The API reference test asserts the new wording.
  • npx vitest run test/mcp.test.ts: 26 pass. The initialize instructions no longer contain the old build-time/Mathlib-rev phrase and do contain the new wording.
  • Full worker suite (npx vitest run): 919 pass in 38 files.
  • npx tsc --noEmit -p . passes.

Risks

Copy only. One other place still describes these fields: the /brain page status label (data ${generated_at.slice(0,10)}, which now renders "data sha256:b301"). It lives in site/build_brain_page.py and ships inside a frozen release.

A true Mathlib commit in the echo would need the builder to emit it as a prov row, which requires a new release.

Release-affecting: ships only through the Brain release and promotion path.

What Jack must do

Nothing to configure. Decide whether to have the builder publish the mathlib4 commit, which would need a new release.

🤖 Generated with Claude Code

snapshot.generated_at and snapshot.pin are copied from cells/manifest.json.
In offline-replay releases (production since 2026-10-04) generated_at is the
sha256: replay generation id and every Mathlib-family prov pin is a sha256:
digest of the sealed source input, so pin falls back to that digest. The
release carries no build timestamp and no mathlib4 commit to expose instead.

The MCP initialize instructions said 'the brain build time and the Mathlib
rev'; they, the /brain/api reference and the code comments now describe
both fields as opaque identifiers (ISO timestamp / git commit only in older
releases). Values are unchanged. A replay-shaped fixture pins the echo.
The live pin is the concept-graph family's sha256 dataset revision, whose
inputs include WikiLean annotations, Wikidata, TheoremGraph and curated
grounding alongside the Mathlib tree, so it changes when Mathlib does not;
current-profile releases can still report a date. The MCP instructions,
the /brain/api reference and the code comments now say so, without
calling it a Mathlib source digest or contradicting themselves. The replay
test now uses a real offline-replay release (no created_at) with the live
prov row order.
- Equal pins do not mean equal build inputs, and pin is not a mathlib4
  commit: the only git-shaped value ever seen (bf3266149cda603f) is a
  16-hex truncation of TheoremGraph's statement_formal.csv sha256. Say so,
  and tell agents to compare the fields verbatim, never parse them.
- pin is described as what the code returns (the first git-shaped, else
  the first mathlib/kerodon/stacks row's pin), with the concept-graph
  digest as the current row order, not a definition.
- brain-current-v1 generated_at is an ISO 8601 UTC build timestamp, and
  that profile is still built, not 'older'.
- Tests pin the row-order fallback and the shape preference.
@Deicyde

Deicyde commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner Author

Review status: merged in 7dee06f2; required fixes verified

Update 2026-10-14 (re-checked at 2c6196a1):

  • Landed in c7ce3d1 (checked at 7dee06f): docs/BRAIN-API.md (Release and snapshot echo), both brain-query/SKILL.md copies, the wiki/src/brain-api.ts:343 header, the MCP SNAPSHOT ECHO block (wiki/src/mcp.ts:84-87) and the /brain/api paragraph now use one wording: generated_at and pin are opaque provenance values, compared for equality and never read as a build time or a Mathlib revision. Held-out evaluations are asked to record release_id.
  • Tests: one positive wording check per surface, and the MCP check that the old phrase is gone is kept. The row-order case now puts a non-shaped mathlib row ahead of the 16-hex pin, so the git-shape preference is covered.
  • Departure (reasonable): the mathlibPin/Snapshot code comments keep row-order and per-profile detail. They are internal comments, so the cost is a possibly stale comment, not wrong public copy.
  • Still open: the /brain "data sha256:b30" label, brain/SCHEMA.md:563, dating Docs: record the Brain activation and correct project status #53's activation sentence, and the decision on publishing the real mathlib4 commit.
Original review (2026-10-14)

Independent adversarial review of 831f7022: a defect reviewer with skeptics, a design reviewer with a devil's advocate, and an arbiter.

Verdict: keep the values and call generated_at and pin opaque provenance; correct the other copies of the contract and shorten the new text.

Required before merge

  • Make the same correction in docs/BRAIN-API.md ("Release and snapshot echo", lines 569-573, including the held-out-evaluation sentence), in both brain-query/SKILL.md copies (lines 151-152), and in the header at wiki/src/brain-api.ts:343. Docs ship with the code they describe, /brain/api links to that reference, and the .agents copy can only change in a release-affecting PR like this one.
  • Replace the SNAPSHOT ECHO block (wiki/src/mcp.ts:84-94) and the /brain/api paragraph (wiki/src/brain-api.ts:2688-2696) with wording that names no selection rule, row order or per-profile pin shape. The new text describes a rule mathlibPin doesn't implement, and its per-profile claims hold only because of prov row order. That is how the old text went wrong.
  • Align the tests: keep the check that the old phrase is gone and add one positive check per surface; drop negative assertions on phrases that never reached main. For the row-order test at wiki/test/brain-api.test.ts:1539, add a case with a non-shaped mathlib row before a 16-hex one, or delete the test. Today, removing the shape branch leaves CI green.

Decisions for the maintainer

  • Publish the real mathlib4 commit in snapshot.pin? It can come from sealed inputs, but that means reducer, SCHEMA, Worker and test changes. Recommended: not on release B, because nothing reads the field today.
  • Bundle the /brain "data sha256:b30" label fix (site/build_brain_page.py:4027, :5879)? Recommended: yes. It adds no release cost.

Merge order: release-affecting; batch with #46, #47, #50, #52, #54, #55, #58 and the replacement for #63 before release B is built, never between build and promotion.

Fixes are in progress; this comment will be updated.

Posted by the WikiLean PR swarm (lead); updated 2026-10-14.

@Deicyde

Deicyde commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

Status review (2026-10-14): ✅ Ready

This changes copy and comments only, and every claim checks out against the live release and the builder code. The tests pin the echo values, including the live prov row order, and the new wording.

Nits

  • Claude Code won't see this fix. The corrected SNAPSHOT ECHO text sits at roughly chars 2907-3757 of the 4000-char MCP INSTRUCTIONS, and Claude Code truncates server instructions at 2048 chars, so it sees neither the old text nor the new.
    • The copy Claude Code agents do load, .claude/skills/brain-query/SKILL.md:151, still has the old claim ("the Mathlib rev the decls were built against"). So does the .agents/ copy at the same line, and docs/BRAIN-API.md ~567-575 still calls it "the Mathlib pin".
    • The .claude/ skill and docs/BRAIN-API.md are release-neutral and could be fixed now. The .agents/ copy is release-affecting under site/ops/brain_release_authority.py. Also consider moving the echo note before the 2048 mark.
  • The public copy doesn't match the code. It says pin "is the first mathlib/kerodon/stacks provenance pin…", but mathlibPin() returns a git-shaped (7-40 hex) pin from any mathlib/kerodon/stacks row first, regardless of row order. The new test already asserts that preference; align the copy with it.

Cross-PR: once this merges, the mcp.ts half of #53's sentence in docs/BRAIN-ACTIVATION-2026-10-04.md (~L45-46) is stale. That sentence says the echo carries digests, "not the build time and Mathlib revision that the MCP instructions (wiki/src/mcp.ts) and docs/BRAIN-API.md describe". Whichever lands second should update it.

To ship: Worker change, so it needs the next Brain release and promotion.


🤖 Automated status pass by Claude Code over all 18 open PRs (#46–#63), posted for the repo owner. An independent verifier re-checked each finding. All 18 heads were also merged and tested together in a scratch tree; the only test failure that comes from combining them is #47 × #55 (three other pairs had mechanical text conflicts). Reviewed head: 831f7022.

…here

- The MCP instructions and the /brain/api reference no longer describe a
  selection rule, row order or per-profile pin shape. They say what holds
  for every release: generated_at and pin are opaque provenance values of
  the release's inputs; compare them for equality, never parse them, and
  do not read them as a build time or a Mathlib revision.
- docs/BRAIN-API.md, both brain-query SKILL.md copies and the snapshot
  echo section header say the same. The held-out-evaluation sentence now
  asks for release_id, which identifies the release that answered.
- Tests keep the check that the old phrase is gone, assert the new wording
  once per surface, and drop negative checks on phrases that never reached
  main. The row-order case now puts a non-shaped mathlib row before the
  16-hex one, so dropping mathlibPin's shape branch fails it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Deicyde

Deicyde commented Oct 14, 2026

Copy link
Copy Markdown
Owner Author

Fixes pushed (2026-10-14)

This addresses the two earlier reviews on this PR: all three "Required before merge" items in the PR swarm's review, plus the stale-copy and copy-vs-code nits in the "Status review (2026-10-14)" comment.

What changed (all in c7ce3d11)

  • docs/BRAIN-API.md, both brain-query/SKILL.md copies and the snapshot-echo header in brain-api.ts now use the opaque-provenance wording. The "Mathlib rev" / "Mathlib pin" descriptions are gone, and the held-out-evaluation sentence asks for release_id. (Swarm item 1; the stale-copy part of status nit 1.)
  • The MCP SNAPSHOT ECHO block and the /brain/api paragraph now name no selection rule, row order or pin shape. This drops the "first mathlib/kerodon/stacks provenance pin" claim that didn't match mathlibPin(). (Swarm item 2; status nit 2.)
  • Tests: one positive wording check per Worker surface, the MCP old-phrase check kept, negatives on never-merged phrases dropped. The row-order case now puts a non-shaped mathlib row before the 16-hex one, so it pins the git-shape preference; contrary to the status review, the old case did not. (Swarm item 3.)

Verification

  • tsc clean; worker suite 919/919 in 38 files; brain-api + mcp tests 176 pass. The verifier re-ran all three.
  • Mutation: deleting mathlibPin's shape branch fails the new case; the old row-order case passed under the same mutation.
  • Merges cleanly with main; no other open PR touches these files.
  • CI on c7ce3d11: all checks green (worker, python, browser, required).

Not changed / still open

Merge notes

  • Release-affecting: merge before release B is built, never between build and promotion.

🤖 Posted by Claude Code for the repo owner. Each fix was checked by an independent verifier before it was pushed. Head: c7ce3d11.

@Deicyde
Deicyde merged commit 7dee06f into main Oct 14, 2026
4 checks passed
@Deicyde
Deicyde deleted the claude/worker-snapshot-contract branch October 14, 2026 21:14
Deicyde added a commit that referenced this pull request Oct 17, 2026
wiki: describe the Brain snapshot echo as what releases actually carry
Deicyde added a commit that referenced this pull request Oct 17, 2026
…ord, README facts and the 2026-10-13 ROADMAP entry

The five deploy notes no longer say a hotfix path would be a journaled promoter mode: no hotfix path exists, rollback is the only lever, and ROADMAP Waiting item 8 stays open. The activation record's operator table drops an unsourced release ID and three claims that the promoter journal records host, receipt-root and backup details (it records none), and gains a host-context row. Its snapshot sentence follows #62. README's facts table no longer says wiki/src is unchanged on main. The 2026-10-13 ROADMAP entry gets the /stats review figures and the diagnosis pointer.
Deicyde added a commit that referenced this pull request Oct 18, 2026
…uestion by title

Production's MCP instructions (built from 2eb31ba) still call generated_at and pin the build time and the Mathlib revision; the activation record now says so, and that main's opaque wording (#62) reaches production with the next release. The five hotfix-path pointers cite 'Worker-only hotfix path' in the ROADMAP's Waiting on Jack list by title, since the list renumbers. The operator table restores bfcfc912 with its likely source (added in 85c974a with the journal's final_state values) and keeps only '(the promoter journal does not record it)' in the host and backup rows. The host-context row covers both P1B boxes. The ROADMAP entry says no review tokens were recorded, not spent.
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