Repository navigation
[PR] feat: one-time ledger restamp of legacy refs + fork row cloning (#4316 layer 3 PR3/3) - #4575
Conversation
…ng (#4316 layer 3 PR3/3) Kernel: restampRefsToLedger re-homes the citation space onto the unified ledger (ref = store row seq + 1) exactly once per state — BLOCKED stays unnumbered, dead refs survive, displaced no-row ids re-home to fresh high numbers (no-reuse contract), multi-generation ids excluded by seqByRaw. CompressionState.refLedgerAligned rides the single-source-of-truth merge. Host: the restamp fires at cold load only (loadSync afterLoad) — the restart boundary is the one moment no in-flight compress call can observe a half-renumbered map; mid-conversation alignment would break the D-suite byte-stability contract. Post-load arrivals keep counter minting (fresh numbers, no collision). Superseded old refs are refused by the compress funnel with guidance (never silently fold the wrong span); the map rides the Session for this process only. fork endpoints clone parent rows to the child session preserving seqs (store+mysql), lineage columns get real values, content/media refcounts bump, replay is idempotent. Parity: storage-unified now pins 'full serve = legacy serve + the same deterministic alignment' via an aligned-legacy oracle digest; the corpus manifest keeps pinning the pure view. kernel 0.0.163.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5521-pr.4575.28b89d5This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4575.tgz
npm install -g packageInstall instructions are refreshed on each push. |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.824-master.8ad3aed # this exact build
npm install -g billion-context@master # always the newest merged build
|
#4316 PR3/3 makes the restart wire-visible — the 6 storage-engine proofs are the detector, not born-redMaster
Evidence (job 121293… ubuntu-latest 22,3, same on 24,3)Refs are text: Two side effects that are also by construction:
Options (owner call)
Note the family-B/C failures are deterministic, not born-red-flaky: I reproduced C locally (Node 24 + Fix for C is small and does not need mode gating (it fails on every host with a working engine): assert the round trip instead of the pre-alignment literal — #4652 will clear A only; B and C stay red behind it. 中文摘要本条提交把「冷加载时一次性把旧 counter ref 重编号到 ledger seq+1」落了地,而 ref 是写进 wire 文本的( 可选出路:(a) 让 proofs 只比较已对齐状态、并让采样器豁免这一次对齐(最省的 CI 解);(b) 冷加载时同时重写信封,让下一次 legacy 重启看到同一组编号;(c) 只对「ref 从未被渲染过」的会话做重编号,新消息交给 assignRefs 的 ledgerSeq 路径(唯一不产生一次性 wire 变更的方案,我认为是 #4316 layer 3 应有的形状)。plugin-fork 那条属另一族(该测试的 store 本来就走 legacy-only),#4652 可清;但它清不掉 B/C。 |
Follow-up: byte-level proof that the restamp is what changes the wireI drove the same golden script twice locally (master tree, Node 24 + Same message, same scripted turn, different ref — the one-time restamp renumbered it All four wires, deterministically, on a host where the engine works — same signature as CI's ubuntu 22,3 / 24,3 shards. So the proofs are not born-red and not flaky: they are pinning the contract the restamp breaks. (I also reproduced Nothing here changes the options in my first comment; it just moves the question from "is the CI flaky?" to "does #4316 layer 3 accept one wire-visible renumber per pre-alignment session?" — and if the answer is yes, the goldens and the #3135 sampler have to be taught about it in the same PR, otherwise the detector keeps reverting the aligned view ( |
Closes #4316 (layer 3, final PR of the series).
What this does
Closes the loop opened by #4346 (ledgerSeq stamping) and #4552 (interval coverage): legacy sessions still carry counter-minted refs that drift from store row seqs (BLOCKED messages take no number, edits/churn widen the gap). This PR re-homes the citation space onto the ledger exactly once, and makes fork preserve numbering by cloning rows.
Kernel
restampRefsToLedger(state, seqByRawId): atomic one-shot restamp (draft maps, swap at end).highestUsedIndex+1walk — no-reuse contract intact), recorded insuperseded.CompressionState.refLedgerAlignedmarks done (rides thestate-hydrationsingle-source-of-truth merge → auto-persisted).kernel/tests/seq-restamp.test.ts4/4: BLOCKED offset, swap atomicity, no-row keep + displaced re-home + dead-ref survival, aligned-idempotent.Host
loadSyncafterLoad). Mid-conversation alignment was tried (getSession hook) and rejected: it breaks the D-suite byte-stability contract when rows materialize after serving started (snapshot-render flip m00024→m00027 in testing). A restart boundary has no in-flight compress call, so nothing can observe a half-renumbered map. Post-load arrivals keep counter minting — fresh numbers, no collision.Sessionobject for this process only. Refusal is safe (no wrong fold), the cost is one re-read of acp_status.cloneSessionRows(parent, child, throughSeq)(sqlite + mysql) — rows copied preserving(session, seq),parentSessionId/forkPointSeqlineage get real values, content/media CAS refcounts bump, replay idempotent; child appends continue from parent maxSeq+1 naturally. Storage unavailable → kernel-only clone (previous behavior).seqByRawonly maps single-row msg_ids — multi-generation (edited) ids are excluded, their legacy refs stay put (honest gap).Parity contract
storage-unifiednow pins "full serve = legacy serve + the same deterministic alignment" via analignedLegacyDigestoracle (legacy view +restampRefsToLedgerwith the sameseqByRaw), instead of comparing against the pre-After model switch / client-side history rewrite, all message identities (content hashes) are replaced: ACP numbers re-m | 切模型/客户端重写历史后,消息身份(内容哈希)全部更换:acp 编号重铸、折叠覆盖大规模重挂、死 ref、churn 区临时膨胀重折 #4316 corpus digest.update-storage-corpus.tsstrips the alignment marker.kernel-change
kernel-change: refs.ts restampRefsToLedger + types.ts refLedgerAligned + index.ts exports; version 0.0.162 → 0.0.163 (lock regen).Verification
seq-restamp4/4; hostseq-ledger-pr34/4 (clone full/partial + superseded refusal + cold-load restamp once/idempotent).tsc 0, unused-exports clean, lifecycle OK,npm run buildOK.