Repository navigation
[PR] kernel: let BLOCKED partners stop vetoing block merges via integrity gate (#6709) - #6731
ranxianglei wants to merge 4 commits into
Conversation
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10007-pr.6731.e11159eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6731.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…gate (#6709) kernel-change: BLOCKED (never-foldable) messages no longer block the merge integrity gate. The #5919 fix turned the fatal into a no-op, but a BLOCKED partner can never age into foldability (its body is gone permanently), so the no-op is a permanent deadlock: every merge touching that turn re-fails identically. The fix adds a neverFoldableIds parameter to computeIntegrityWithdrawals so the merge can proceed without the BLOCKED partner blocking the turn-integrity check. The BLOCKED message itself is never included in the merge (it is never foldable), but its turn-mates can now be folded. This is a different approach from PR #6719 (which includes BLOCKED messages in the merge coverage). This approach keeps BLOCKED messages out of the block's coverage, which is safer for the compressedTokens accounting. Fixes #6709
cb4b980 to
805909e
Compare
The #5919 merge no-op treats every ref='BLOCKED' partner as "cannot be closed now", but that conflates two very different cases. A content-free BLOCKED partner (body removed by native compression) carries no live wire content and can never age into foldability, so letting it doom the merge turns the no-op into a permanent deadlock: every merge covering its turn re-hits the same skip and the session stays stuck at its context ceiling (#6709, session-ad47cd30, 6,115 BLOCKED). A LIVE protected tool / unrecoverable media is pinned to ref 'BLOCKED' by assignRefs too, with its full body still in the wire — folding it in drops protected content and leaving it split emits an orphaned tool_call/tool_result. Exempt only content-free BLOCKED partners (ref BLOCKED AND not live-protected-tool AND not host-protected AND not unrecoverable-media) from the merge-deadlock; they flow to the #5919 rung-2 fallback and are folded into the merged block, closing the turn. Live protected tools / media still doom the merge into the honest no-op. This is the correct superset of the two related PRs (#6719: flow-all- BLOCKED-to-rung2; #6731: key-on-ref-BLOCKED, keep-split) — both keyed on ref==='BLOCKED' alone, and both masked the live-protected case by giving the protected partner a numeric ref in their regression tests. 5919-5 adds that guard (live protected tool stored as ref BLOCKED still no-ops). Refs: #6709, #6719, #6731
The #5919 merge no-op treats every ref='BLOCKED' partner as "cannot be closed now", but that conflates two very different cases. A content-free BLOCKED partner (body removed by native compression) carries no live wire content and can never age into foldability, so letting it doom the merge turns the no-op into a permanent deadlock: every merge covering its turn re-hits the same skip and the session stays stuck at its context ceiling (#6709, session-ad47cd30, 6,115 BLOCKED). A LIVE protected tool / unrecoverable media is pinned to ref 'BLOCKED' by assignRefs too, with its full body still in the wire — folding it in drops protected content and leaving it split emits an orphaned tool_call/tool_result. Exempt only content-free BLOCKED partners (ref BLOCKED AND not live-protected-tool AND not host-protected AND not unrecoverable-media) from the merge-deadlock; they flow to the #5919 rung-2 fallback and are folded into the merged block, closing the turn. Live protected tools / media still doom the merge into the honest no-op. This is the correct superset of the two related PRs (#6719: flow-all- BLOCKED-to-rung2; #6731: key-on-ref-BLOCKED, keep-split) — both keyed on ref==='BLOCKED' alone, and both masked the live-protected case by giving the protected partner a numeric ref in their regression tests. 5919-5 adds that guard (live protected tool stored as ref BLOCKED still no-ops). Refs: #6709, #6719, #6731
[bot] 🏷 Duplicate screening: 查重: 同 issue (#6709) 存在平行 PR #6719,两者方案不同——#6719 把 BLOCKED 伙伴折进合并块(纳入 coverage),#6731 让 BLOCKED 伙伴不挡完整性门(排除 coverage)。两者互斥,需 owner 拍板选哪个。本 PR (#6731) 的 PR #6731 review (kernel change, closes #6709) Kernel Boundary compliance:
Fix logic (verified by reading code + running targeted tests):
Tests (verified locally):
Concerns:
8问(中文):
Verdict: Technically sound, tests pass, kernel boundary satisfied. Main concerns: (1) parallel PR #6719 — owner must pick one; (2) edge-case wire validity for TOOL-RESULT BLOCKED messages — the PR's "model's view unchanged" rationale holds for the common case (user image) but not for the edge case (tool-result). Recommend owner decision on which PR to merge + address the edge case. |
[bot] 🏷 CI update: All 30 checks now complete — 16 success, 14 skipped, 0 failed. The full test suite (including the 1636 kernel tests) passes on the pushed head. The PR's test claim is verified. This updates my earlier note "CI: 0 failed, 12 pending" — the test lanes have finished and are green. The review verdict stands: technically sound, tests pass, kernel boundary satisfied. The two concerns remain for owner decision: (1) parallel PR #6719 (same issue #6709, different approach); (2) edge-case wire validity for TOOL-RESULT BLOCKED messages. |
[bot] 🏷 Summary (in response to system nudge): The review is complete and was posted in two comments above (floors 5 & 6). Key findings:
Awaiting owner decision on:
|
The #5919 merge no-op treats every ref='BLOCKED' partner as "cannot be closed now", but that conflates two very different cases. A content-free BLOCKED partner (body removed by native compression) carries no live wire content and can never age into foldability, so letting it doom the merge turns the no-op into a permanent deadlock: every merge covering its turn re-hits the same skip and the session stays stuck at its context ceiling (#6709, session-ad47cd30, 6,115 BLOCKED). A LIVE protected tool / unrecoverable media is pinned to ref 'BLOCKED' by assignRefs too, with its full body still in the wire — folding it in drops protected content and leaving it split emits an orphaned tool_call/tool_result. Exempt only content-free BLOCKED partners (ref BLOCKED AND not live-protected-tool AND not host-protected AND not unrecoverable-media) from the merge-deadlock; they flow to the #5919 rung-2 fallback and are folded into the merged block, closing the turn. Live protected tools / media still doom the merge into the honest no-op. This is the correct superset of the two related PRs (#6719: flow-all- BLOCKED-to-rung2; #6731: key-on-ref-BLOCKED, keep-split) — both keyed on ref==='BLOCKED' alone, and both masked the live-protected case by giving the protected partner a numeric ref in their regression tests. 5919-5 adds that guard (live protected tool stored as ref BLOCKED still no-ops). Refs: #6709, #6719, #6731
The #5919 merge no-op treats every ref='BLOCKED' partner as "cannot be closed now", but that conflates two very different cases. A content-free BLOCKED partner (body removed by native compression) carries no live wire content and can never age into foldability, so letting it doom the merge turns the no-op into a permanent deadlock: every merge covering its turn re-hits the same skip and the session stays stuck at its context ceiling (#6709, session-ad47cd30, 6,115 BLOCKED). A LIVE protected tool / unrecoverable media is pinned to ref 'BLOCKED' by assignRefs too, with its full body still in the wire — folding it in drops protected content and leaving it split emits an orphaned tool_call/tool_result. Exempt only content-free BLOCKED partners (ref BLOCKED AND not live-protected-tool AND not host-protected AND not unrecoverable-media) from the merge-deadlock; they flow to the #5919 rung-2 fallback and are folded into the merged block, closing the turn. Live protected tools / media still doom the merge into the honest no-op. This is the correct superset of the two related PRs (#6719: flow-all- BLOCKED-to-rung2; #6731: key-on-ref-BLOCKED, keep-split) — both keyed on ref==='BLOCKED' alone, and both masked the live-protected case by giving the protected partner a numeric ref in their regression tests. 5919-5 adds that guard (live protected tool stored as ref BLOCKED still no-ops). Refs: #6709, #6719, #6731
kernel-change: BLOCKED (never-foldable) messages no longer block the merge integrity gate.
What broke
Merging old blocks (b312..b315, b312..b313) always skips when a turn partner has ref BLOCKED: #5919 made that an idempotent no-op, but a BLOCKED partner can never age into foldability (its body is gone permanently), so the no-op is a permanent deadlock: every merge touching that turn re-fails identically. The reporter's session (session-ad47cd30, 0.1.214) carries 6,115 BLOCKED messages (13.7% of 44,623); merges of old blocks all skip, and the context stays stuck at 533K/792K.
Root cause
computeIntegrityWithdrawals(kernel/src/turn-integrity.ts) treats a BLOCKED message as a regular "kept visible" message. When a merge covers the BLOCKED message's turn-mates, the integrity gate sees a split turn (reasoning folded + BLOCKED call visible) and withdraws the entire group. The #5919 fix caught this and turned it into a no-op, but the no-op is permanent because the BLOCKED message can never become foldable.Fix
Add a
neverFoldableIdsparameter tocomputeIntegrityWithdrawals. When set, messages in this set are excluded from the "kept visible" check (INV1) and from the split-pair withdrawal (INV2). The merge can now proceed without the BLOCKED partner blocking the turn-integrity check.The BLOCKED message itself is never included in the merge (it is never foldable), but its turn-mates can now be folded. This is different from PR #6719 (which includes BLOCKED messages in the merge coverage) — this approach keeps BLOCKED messages out of the block's coverage, which is safer for the
compressedTokensaccounting.Changes
kernel/src/turn-integrity.ts: addedneverFoldableIdsparameter tocomputeIntegrityWithdrawals; INV1 skips BLOCKED calls in the "kept" check; INV2 skips withdrawal for BLOCKED pairs.kernel/src/unit-projection.ts: computeneverFoldableIdsfromstate.messageRefs.byRaw(ref==="BLOCKED") whenisMerge; pass to all 3 merge call sites.kernel/tests/issue5919-shredded-merge.test.ts: updated 5919-2 test to reflect new behavior (merge succeeds instead of no-op).kernel/tests/issue4484-merge-coverage.test.ts: updated tests to passneverFoldableIdstocomputeIntegrityWithdrawals.Tests
Closes #6709