Repository navigation
fix: body-stability classifier gains a tail class for post-array divergences (#2982) - #2983
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3387-pr.2983.a906e0aThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2983.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2983 审查完成(独立验证:代码逐行审 + 定向测试 + master 红复现)。 八问结论:
测试有效性:8 个回归用例断言有牙(非恒真)——我在未改动的 origin/master 上跑同一套,6/8 red(三个 tail 家族 actual='mid' 复现 bug;另有 Responses diff 整洁度:单 commit、4 文件、每行都与本 PR 目的相关;无 version bump、无 lockfile churn、无空白噪音;与 #2929 的类型 union 冲突合并正确(seam/prov 字段保留)。 CI:所有门禁 job 绿(static-gates ×3 / build-artifact / version-guard / lock-sync / kernel-guard / lane-guard / pi-subagents-guard / config-surface-guard / unused-exports / docs-coverage / docs-sync / image-billing e2e);test matrix ×4 审查时仍在跑,完成后即齐。 一处核验过的非问题(不立项):扫描器取「文本序中第一个匹配数组 key」,而 判定:可合入(等 CI test matrix 收尾;合并由人执行)。 |
The new tail divergence class reclassifies 11 of 14 persisted cacheLedger bs values mid->tail in the golden conversations (divergence sits at the message-array closing bracket: trailing params / ephemeral notes), changing session.metadata digests. Regenerated via scripts/update-storage-render-goldens.ts; diff is digests-only (stateDigest + sectionDigests.metadata) for chat/anthropic/google. responses wire unaffected (its ledgers keep their classes). Closes nothing; completes PR #2983's required golden refresh.
[bot] 🏷 更正上一条 review 结论(重要):我此前说「CI red 是 master 既有问题、与本 PR 无关」——这个判断错了,在此撤回。真正原因已查明并已在 PR 分支上修复。 排查过程与自我纠错我最初的「master 也红」证据来自一组 worktree bisect 运行,但那些命令忘了 真正根因
验证闭环:在 PR head 本地驱动同一 golden 会话,重生成后的 chat metadata digest = 已做修复(提交到 PR 分支)
结构化八问(更正版)
另:排查中观察到 master push 事件下 判定:代码本体 review 结论维持上一轮(实现正确、diff 干净、测试有牙);补上 golden 重生成后,待新 head CI 全绿即可由人合并。 |
a191244 to
233d9a7
Compare
The new tail divergence class reclassifies 11 of 14 persisted cacheLedger bs values mid->tail in the golden conversations (divergence sits at the message-array closing bracket: trailing params / ephemeral notes), changing session.metadata digests. Regenerated via scripts/update-storage-render-goldens.ts; diff is digests-only (stateDigest + sectionDigests.metadata) for chat/anthropic/google. responses wire unaffected (its ledgers keep their classes). Closes nothing; completes PR #2983's required golden refresh.
[bot] 🏷 冲突已解决并推送 — 新 head 发生了什么:master 从本 PR 原 base( 结构化八问:
行为变更披露:无新增——仍为此前两轮回复已披露的内容( 收工判定:冲突解除、rebase 后 head CI 全绿、无回归,可合入(合并操作留给人)。 |
…rgences (#2982) The per-call BODY STABILITY divergence classes only looked at the first diverging byte offset (LCP) plus a 64-byte append tolerance — never at where the messages array ENDS. Two harmless families were labelled mid ("mid-history rewrite"): trailing top-level param jitter (host-computed max_tokens/…) and ephemeral tail notes (nudge/imgNote/retrNote) that appear/vanish between adjacent requests, even though every shared history byte was untouched and hit rates stayed 90–95%+ (#2980 log: 181/182 pairs flagged mid, zero seam evidence). New fourth class tail: in the would-be-mid branch only (hot path pays nothing extra), scan the SHORTER full body for the top-level messages/input/contents array closing bracket (string-aware depth scan, same key set as seamLcp); lcp >= that offset ⇒ tail, else mid as before. Unparseable bodies keep the conservative pre-fix class. Report aggregate, acp-cache text and web UI legend (en+zh) surface the new class.
The new tail divergence class reclassifies 11 of 14 persisted cacheLedger bs values mid->tail in the golden conversations (divergence sits at the message-array closing bracket: trailing params / ephemeral notes), changing session.metadata digests. Regenerated via scripts/update-storage-render-goldens.ts; diff is digests-only (stateDigest + sectionDigests.metadata) for chat/anthropic/google. responses wire unaffected (its ledgers keep their classes). Closes nothing; completes PR #2983's required golden refresh.
233d9a7 to
8d66ca2
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.366-master.676f7fd # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2982
Problem
The BODY STABILITY per-pair divergence classifier (
src/cache-ledger.ts) only looked at the FIRST diverging byte offset (LCP) plus a 64-byte append tolerance — never at where the messages array ENDS. Two harmless divergence families were therefore labelledmid(=「历史中段重写」):Both leave every shared history byte untouched and the prefix cache intact, yet the label masqueraded harmless jitter as a high-severity symptom (#2980 log: 181/182 adjacent pairs flagged mid while hit rates stayed 90–95%+ and seam forensics found no rebuild seam).
Fix
A fourth class
tail: in the would-be-mid branch ONLY (the hot path pays nothing extra), scan the SHORTER full body for the top-levelmessages/input/contentsarray's closing bracket (string-aware depth scan over the raw text; same key set asseamLcp's msgsOf).lcp >= arrClose⇒tail, elsemidexactly as before. No array locatable (unparseable body) keeps the conservative pre-fix class.Refinement vs the issue proposal: the scan must run on the shorter body. When one side grew the array, the LCP stops at ITS closing bracket (
]vs,), which lies inside the longer side's array — parsing the longer side would misread the pair as mid again.Behavior changes (disclosure, mandatory)
bs: pairs whose first divergence sits at/past the message-array end are now"tail"instead of"mid"(additive enum value; already-persisted lines keep their historical values).stability: newtailcounter — the five classes partitiondiverged; sessions with dynamic trailing params see theirmidcount drop intotail.acp-cachetext: the divergence-class line gains atail(params/notes) Ncolumn; when N>0 an explanatory line prints WITHOUT ⚠ (benign class, no action needed).tail (params / ephemeral notes)/尾部参数/尾注; i18n tips updated en+zh in sync.midstill fires when the break lands INSIDE the array, including a rewrite of the latest element (boundary case pinned by test).Verification
tests/issue2982-body-stability-tail-class.test.ts(8 cases): trailing-param jitter → tail; ephemeral note APPEARS → tail; ephemeral note VANISHES → tail; Responses-wireinputkey → tail; last-element rewrite → still mid; mid-history rewrite → still mid; unparseable bodies → fall back to mid without crashing; report + acp-cache text surface the class. On unmodified master (c60c2d1) the three tail families failed withactual: 'mid'— bug reproduced before fixing.BiliCacheReport.linestype (upstream codex 命中率问题分析 #2929 addedseam/provfields on the same line — both kept).