Repository navigation
[PR] storage: CI gate — jsonWriter=off may only write whitelisted .json in the sessions dir (#2960) - #5992
Merged
Conversation
Contributor
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8833-pr.5992.4017916This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5992.tgz
npm install -g packageInstall instructions are refreshed on each push. |
This was referenced Nov 9, 2026
added 2 commits
November 9, 2026 23:28
Phase 3 said the off switch covers the session envelope; the per-session CCR content-store sidecar kept being written either way. In effective-full mode that file is never read (contentStoreOf is unified-first) and the same save already ingests the store into the index (sessions.ccr_json), so the sidecar write was dead weight contradicting the switch's contract: the SQLite index is the ONLY persistent copy. - saveContentStore: writerOffActive() gate after the emptied-store rm branch — off skips the file write; the builder's ccr ingest (same save cycle) is the durable copy. - The gate clears contentStoreDirty: the off save drops the resident store right after the ingest (dropResidentContentStore), and a stale dirty=true with contentStore=null would make a later writer-resume save hit the emptied-store branch and DELETE the sidecar file. Convergence after a writer-resume comes from the kernel re-adopting its in-memory store on the next turn. - Fork/restore one-shot materialization (writeContentStoreSidecar) stays unconditional: the index does not carry forked CCR stores, so skipping there would strand forked payloads. - Tests: new suite proves the sidecar bytes are untouched under off, the index mirror resolves the originals, and an on-control leg still writes the file. Docs: config docblock + process.yaml (EN/ZH) + regenerated configuration.md.
… the sessions dir (#2960) #5988 stopped the CCR content-store sidecar write under the off switch, but the contract "the SQLite index is the ONLY persistent copy" had no mechanical guard: any future save path that starts writing JSON there would silently regress it (the sidecar itself is exactly that shape of violation). This adds the gate. tests/storage-json-writer-off-json-writes.test.ts: - snapshot-diff design: every *.json file in the store dir is hashed before/after each phase; added/modified entries are checked against the whitelist. No fs interception — whatever API a write path uses shows up in the diff, so a new writer cannot hide behind an un-intercepted call. - Phases: A first save (ZERO .json writes), B restart adopt + save (ZERO), C replica + restore (the restored id's own materialized files ONLY — envelope + CCR sidecar, named via relPathFor/ contentStoreRelPathFor; session files are hash-named, so the concrete per-run set is derived from the restored id, not a regex), plus an on-control leg proving the snapshot mechanism actually sees writes. - JSON_WRITE_WHITELIST documents the allowed category (restore materialization: the index is not a restore source and does not carry forked CCR stores); extending it requires the code path and the reason the index cannot carry the bytes. - Mutation-verified: disabling the #5988 sidecar gate makes phase A fail with the offender file listed — the gate catches exactly the regression #5988 fixed. Scope: the sessions directory (persistence layer). CLI-level state files under stateDir() are handled separately by #5757 (kv_store migration). Verification: typecheck ✓, gate suite 2/2 ✓, sibling off suites + issue5805 9/9 ✓, storage regression battery 110/110 ✓, check:unused-exports ✓, check:test-import-graph ✓, gen-config-docs check-coverage ✓, check-architecture-docs ✓
ranxianglei
force-pushed
the
2026-11-09_jsonwriter-off-json-write-gate
branch
from
November 9, 2026 15:29
e45be45 to
2f89ca0
Compare
Contributor
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1130-master.9bbc2a4 # this exact build
npm install -g billion-context@master # always the newest merged build
|
This was referenced Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A CI gate for the
storage.jsonWriter: "off"contract (#2960 Phase 3, hardened by #5988): while the switch is off, the sessions directory may gain a.jsonfile only through the whitelisted materialization paths — anything else fails CI.The off switch promises "the SQLite index is the ONLY persistent copy." Nothing enforced that: #5988's CCR sidecar write was exactly a silent violation of the promise, found by audit, not by CI. This PR adds the mechanical guard so the next such writer is caught in CI, not in a review.
How
tests/storage-json-writer-off-json-writes.test.ts— snapshot diff, not fs interception:*.jsonfile in the store dir is hashed before and after each phase; added/modified entries are checked against the whitelist. Whatever API a write path uses (writeFileSync, rename, fd) shows up in the diff — a new writer cannot hide behind an un-intercepted syscall..jsonwrites.relPathFor), never by the id itself, so the allowed set is derived per-run from the restored id viarelPathFor/contentStoreRelPathFor— a regex over names cannot anchor a restore.JSON_WRITE_WHITELISTdocuments the allowed category (restore materialization: the index is not a restore source, and it does not carry forked CCR stores —buildRecorddropsforkContentStoreon the next live save). Extending it requires naming the code path and why the index cannot carry the bytes — callout in the assertion message.Scope
Sessions directory (persistence layer) only. CLI-level state files under
stateDir()are handled separately by #5757 (kv_store migration).Stacking note
This branch is stacked on #5988 (
3554fe3fdis included) — the gate's phase A requires the sidecar fix to pass, by design. Merge #5988 first; this PR then reduces to the single gate commit.Verification
npm run typecheck✓check:unused-exports✓ ·check:test-import-graph✓ ·gen-config-docs check-coverage✓ ·check-architecture-docs✓