Repository navigation
fix: shadow parity digest compares blockContents by content, not Map insertion order - #3423
Conversation
…rder (#3407) The unified shadow parity digest rendered blockContents as a Map in insertion order. The two verify legs legitimately populate it differently — the expect leg keeps the live Map's order (completeBlockContents appends synthesized entries at the end) while the got leg lays blocks out in state.blocks array order — so long dsh persona-fork sessions whose orphan-GC'd or reordered blockContents diverge in order false-alarmed DIGEST DRIFT on every sampled save (telemetry-only in shadow mode, but a real read-path divergence in full mode). Key-sort both legs' blockContents before hashing so only genuine content forks trip the digest. Regression test drives the real UnifiedShadow.record() path for both the orphan-GC partial shape and the reordered shape; both fail pre-fix and pass post-fix.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4020-pr.3423.9807dfcThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3423.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重:不重复——#3423 是缺陷 #3407 的唯一修复 PR;检索 open+closed 无并列的同类「unified shadow digest 顺序漂移」PR/issue(#3407 自身已带 PR #3423 独立审核结论先排除一个易误判点:此 PR 真实改动只有 2 个文件( 结构化八问
验证
合并判定可合——机械上满足 auto-merge 全部 8 条(单模块、回归测试复现+通过、无 config/persistence/wire/kernel 改动、纯 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.506-master.53ebe00 # this exact build
npm install -g billion-context@master # always the newest merged build
|
What & why
Long dsh persona-fork sessions repeatedly logged:
Root cause: the unified-shadow parity digest renders
session.blockContentsas a Map in insertion order, but the two legs it compares legitimately populate that map in different orders:completeBlockContentsappends synthesized entries at the end whenever a block has no slot;loadLegacyView) lays blocks out instate.blocksarray order via the blocks table.A long-lived session hits this every time orphan GC deactivates a non-terminal block (it stays in
state.blocksbut its content is deleted fromblockContents,src/orphan-gc.ts) or fork-adoption sets contents out of array order. Each such save then false-alarms DIGEST DRIFT on the sampled verify (everyVERIFY_EVERY_INGESTS=20ingests). In shadow mode this is telemetry-only (read path stays legacy); in full mode the read follows the unified view, so the drift would mask a real read-path divergence.Fix
Key-sort both legs'
blockContentsby blockId before hashing (orderedBlockContents), so the digest compares block contents, not insertion order. Sorting changes neither keys nor values, so a genuine fork (different blockIds or different text) still trips it — only pure ordering differences are neutralized.Scope:
src/storage/shadow.tsverify path only. No wire/message-shape, config-schema, or persistence-format change. Not underkernel/.Behavior change (flagged)
blockContentsMap insertion order → false DIGEST DRIFT on any partial/reorderedblockContents(e.g. an orphan-GC'd non-terminal block).blockContentson both legs → order differences no longer trip it; real content forks still do.Verification
tests/issue3407-shadow-blockcontents-order.test.tsdrives the realUnifiedShadow.record()sampled-verify for both production shapes (orphan-GC partial, reordered-complete): both fail pre-fix (verifyDrift=1) and pass post-fix (verifyDrift=0) — verified locally by reverting the fix, observing the failures, restoring it, and re-running.Config surface
None — no env/config/CLI/default added or re-semantics'd.
Closes #3407