Repository navigation
[PR] storage: shadow DIGEST DRIFT now names the diverged dimension and slot; prefix rewrites fail soft at the delta boundary - #3948
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4750-pr.3948.a37159cThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3948.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本 PR 是 #3919 的修复交付物(Related: #3919),与 #3919 线程里声明的两项工作(对账点取证 + delta 路径廉价前缀探针)一一对应;按失败签名(DIGEST DRIFT 日志行、delta head probe、issue3919-shadow-drift-forensics 测试名)检索 open+closed issue/PR 无其他在途条目。同家族条目 #3407/#3285/#3288/#3559/#3841 已在 #3919 triage 中逐一排除(机制不同)。 标签: bug / codex / scope/storage / p2(修复 #3919 缺陷;受影响客户端为 Codex Desktop;统一存储对账路径;严重程度随 #3919——shadow 模式自愈合、不影响会话可用性,代价是 CPU 与日志噪音)。 审核进行中:分支与 master 同步(落后 0 commit),diff 为 4 文件 +419/-6(src/storage/{shadow,store,ingest}.ts + 新测试)。已核对 fail-soft 语义、位置假设、CAS 持久化机制;定向测试与 CI 状态确认后补完整八问结论。 |
(ai: vllm-qwen/qwen3.8-27b) Review 完成(head 查重:不重复(首条已述)。本 PR 是 #3919 floor 6 承诺的两项交付物本身,无并列在途项。 结构化八问
回归审计(触碰路径的既有行为清点)
高危模式逐项过:无 fail-fast 变吞错(try/catch 只包诊断格式化,不包 heal 逻辑);无阈值/时序漂移( 测试有效性三个新测试都有牙,非摆设:
全部 hermetic/tmpdir/env 钉死,确定性成立。本地定向跑(5 个相关文件):37 tests,36 pass,0 fail,1 skip(skip 为 better-sqlite3 可选原生依赖本机未装,环境性,node:sqlite 变体通过)。typecheck 干净。 CI 状态与唯一的红head
处置建议:re-run 该 job 即可;若再次复发则是另一个症状/机制,届时单独处理,不应绑在本 PR 上。 两个非阻塞发现(记录在案,不拦合并)
代码整洁硬标准逐项过:命名达意、无死代码、无重复、错误处理带上下文、注释讲为什么、风格与文件既有代码一致、无新依赖、函数规模合理——全过。 收工判定可合入:方向正确(#3919 验收标准逐项兑现)、无回归、测试有牙、行为变更全部披露且我逐一核实。待办:re-run |
…x rewrites at the delta boundary (#3919) The sampled verify backstop fired 28 times across four Codex Desktop sessions in v0.1.201 but only said 'views differ' — nothing about WHERE they differ, so interior-history mutation vs comparison asymmetry vs non-convergence could not be told apart, and v0.1.201's in-memory-only counters made even consecutive-failure detection impossible from logs. - shadow.ts: on detected drift, log which top-level view dimensions diverge and, for lastMessages, the first divergent slot with both sides' id/role/serialized-length/sha8 fingerprint (never body text); a session still drifting on the NEXT sample is flagged '(repeat: ...)' so non-convergence is visible in the log itself. Heal path, digest contract, and counters unchanged. - ingest.ts + store.ts: planIngestDelta takes an optional head-slot identity; when trustedLen > 1 the delta path probes message seq 0's stored msg_id (PK point read) and refuses the delta if it changed, failing soft to the full path on the same save instead of riding the delta until the next sampled verify. Same-id byte drift below the boundary stays the backstop's job.
…exports gate) DriftSlotFingerprint/DriftDiagnostics are referenced only inside shadow.ts — consumers use the functions structurally. Drop the leading export per the gate's own fix guidance instead of waiving.
|
Rebased onto current master (step-3 had renamed the store calls to the sync fast lane inside |
0dd6f22 to
52961ef
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.680-master.74090ac # this exact build
npm install -g billion-context@master # always the newest merged build
|
Related: #3919
Background
In #3919 the shadow-mode sampled-verify backstop fired 28 times across four Codex Desktop sessions on v0.1.201. Its log line said "views differ" but not WHERE they differ, so real interior-history rewrite vs comparison asymmetry vs non-convergence could not be told apart; v0.1.201's verifyOk/verifyDrift counters are also in-memory-only, so even consecutive-failure detection was impossible from logs. This PR adds the forensics and closes one concrete drift window.
Changes
src/storage/shadow.ts): on detected drift the log now appends which top-level view dimensions diverge and, forlastMessages, the first divergent slot with both sides'id/role/serialized-length/sha8fingerprints — never body text. A session still drifting on the NEXT sample is flagged(repeat: consecutive sampled drift — the views are not converging). Diagnostics run in a try/catch so they can never break the heal path.src/storage/store.ts+src/storage/ingest.ts):planIngestDeltatakes an optional head-slot identity; whentrustedLen > 1the delta path reads the storedmsg_idof message seq 0 (PK point read, zero serialization cost) and refuses the delta if it changed, failing soft to the full path on the same save. Previously such a rewrite rode the delta until the next sampled verify (window <= 20 saves). Same-id byte drift below the boundary stays the sampled backstop's job (documented trade-off).Behavior changes (disclosed)
[storage] unified shadow DIGEST DRIFT ...line gains an additive forensic suffix (e.g.[diverged: lastMessages; tail slot 0: expect h_msg0/user len=67 sha=e24a6f57, got tampered/user len=70 sha=c18830b2]) plus the optional(repeat: ...)marker. The prefix stays byte-identical, so existing greps keep matching.Tests
New
tests/issue3919-shadow-drift-forensics.test.ts(3 tests): head probe end-to-end + planner level + negative control (metadata-only raw-tail saves still delta); CAS-tamper scenario -> diagnosis names exactlylastMessages/ slot 0 with differing fingerprints and no body text in any output; repeat-marker lifecycle (flagged while consecutive samples drift, cleared after a clean sample). Pre-existingtests/storage-ingest-watermark.test.ts(16 tests incl. the original CAS-tamper scenario) passes unchanged — the head probe does not interfere with it (its row columns stay intact).No config surface change. No kernel change. No version bump.