Repository navigation
[PR] fix: enforce turn-aligned fold coverage after re-anchor (#4348) - #4353
ranxianglei wants to merge 1 commit into
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.5166-pr.4353.34b7848This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr4353.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 — 本 PR 是 #4348 的修复 PR(正文 标签: bug + scope/kernel + p1(缺陷类;src 侧压缩决策面 fold-reconcile;p1 = 核心承诺失灵——被弃半对永久不可折叠、每轮逐字重发,属缓存/上下文失控类,按 owner 修订 2026-10-19 不降 p2。宿主客户端从 issue 无法判定,不打客户端标签。) 开始 review:拉取 PR head、核对代码与 CI 状态,稍后按八问给结论。 |
Re-anchoring coverage after an identity-churn incident splices claimed ids in place and leaves unmatched old ids as dead refs, so a block can end up covering only one half of a tool-call / tool-result pair while the other half is stranded as debris. The kernel turn-integrity INV2 guard then correctly refuses to fold that orphan half, leaving the debris permanently unrecoverable and resent verbatim on every turn. Add enforceTurnAlignedCoverage: after rewriteBlocks, for any tool pair whose exactly one half is covered by an active block, drop the covered half so the pair becomes fully uncovered and foldable again. Runs in proxy mode, repair mode, on every pass — heals already-stranded sessions without fresh churn and prevents future mid-turn islands. Conservative: it only removes coverage, never claims churned bytes. Regression pins: tests/issue4348-turn-aligned-coverage.test.ts (pure function + proxy/plugin/warn wiring). Closes #4348
2caca60 to
b405f62
Compare
(ai: vllm-qwen/qwen3.8-27b) Review 结论(结构化八问)1. 是什么问题:身份抖动(churn)触发的 re-anchor 之后,一个 fold 块可能只盖住工具调用/结果对的一半,另一半被甩在覆盖之外;kernel 的 turn-integrity INV2 守卫正确地拒绝任何会拆散该对的折叠( 2. 什么原因导致的: 3. 影响范围与严重程度:proxy 模式 + 经历过身份抖动 re-anchor 的会话(p1):受影响半对永久不可折叠、每轮逐字重发,属上下文只增不减的失控类(owner 修订 2026-10-19 不降 p2)。触发条件明确(需先有 churn re-anchor),非全量用户。 4. 怎么修复的:新增 5. 是否有回归问题(逐项审过既有行为):
6. 是否破坏缓存:不破坏缓存键/ref/去重策略(零改动)。临时重新暴露会改变一次出站字节(到整对被下一次折叠吸收为止)——这是修复意图本身,已在 PR 正文按旧值→新值+原因披露,且只缩小永久残骸类。 7. 是否改了设计方向:否。host 侧记账修复,kernel 守卫保持严格,架构/数据流未转向。 8. 是否引入了新的配置:无。 验证证据(本地定向,非全量)
判定可合(等 rebase 后的新矩阵跑绿)。按 §7.4 属人工合并档:压缩决策面的覆盖语义变化 + 已披露行为变更 = 产品决策,不走 auto-merge。测试有效性合格(正/负双向断言齐备,符合 #3617 门规);唯一缺口是无真实 #4348 会话级 e2e A/B,但机制级单测复现充分,可接受。 |
|
(ai: vllm-qwen/qwen3.8-27b) Closing this — superseded by #4354. My root-cause read here was off. I attributed the incident debris to a re-anchor bookkeeping edge (a block covering exactly one half of a call/result pair, so the turn-split guard pins the orphan forever). @ranxianglei measured the actual session and the real cause is different: successful This PR fixes the mid-turn-island edge, not the cause, so it does not resolve #4348. On re-examination that edge also looks far less reachable than I assumed: protection/exemption changes are applied atomically per If a genuine mid-turn coverage island is ever observed with evidence, it merits its own issue with a repro — not a blind defensive fix. Closing per one-issue-one-PR; #4354 is the fix for #4348. Reopen if you want the turn-alignment invariant enforced separately. |
What
After an identity-churn incident re-anchors fold coverage (
re-anchored N/M), a block can end up covering only one half of a tool-call / tool-result pair while the other half is stranded as uncovered debris. The kernel turn-integrity INV2 guard then correctly refuses to fold that orphan half, so the debris is permanently unrecoverable and resent verbatim on every turn (~170K chars across 11 clusters in session 01a11bc7 after the #4323 incident; manual fold attempts all hitRange would split N turns).Root cause
rewriteBlockssplices claimed ids in place and leaves unmatched old ids as dead refs. It does not re-check the turn-pair invariant that the original fold's turn-split guard guaranteed at creation time — so re-anchoring can produce a mid-turn coverage island that no subsequent fold can repair. The guard is correct and must not be loosened (strict providers reject rebuilt requests missing a call or result); the defect is on the bookkeeping side that feeds it.Fix (host-side)
New
enforceTurnAlignedCoverageinsrc/fold-reconcile.ts, run afterrewriteBlocksfor proxy mode / repair mode on every pass: for any tool pair whose exactly one half is covered by an active block, drop the covered half so the pair becomes fully uncovered and foldable again. Conservative — it only removes coverage, never claims churned bytes (honors the exact-match doctrine). Idempotent. Makes already-stranded debris foldable again and prevents future mid-turn islands.Behavior change (flagged): previously a mid-turn covered half stayed covered and its partner was permanently un-foldable; now the covered half is dropped from coverage so the whole pair folds together. Net effect: transiently re-exposes that half verbatim until the next fold absorbs the complete pair — strictly shrinks the permanent-debris class and adds no new bytes to any request.
Scope / gates
Single module (
src/fold-reconcile.ts) + one new test file. No kernel change, no config surface, no wire/message-shape change, no cache-key change, no persistence change. Proxy-mode only — plugin-mode blocks mirror the agent's private compression state and are left untouched (matches the existing zombie-reap gate).Tests
tests/issue4348-turn-aligned-coverage.test.ts: 8 pure-function pins (drop covered call / drop covered result / aligned pair same-block untouched / both-halves-in-different-blocks untouched / lone-half untouched / keeps unrelated coverage / cleans directMessageIds / non-tool no-op) + 3 wiring tests (proxy heals an existing island on a later pass with no fresh churn / plugin leaves it untouched / warn observes without rewriting). Targeted local on the rebased head: typecheck clean, build ok, 105/105 across the full fold-reconcile family. Full-suite verdict = CI.Closes #4348