Skip to content

[PR] kernel: let content-free BLOCKED partners close their turn (#6709) - #6754

Merged
ranxianglei merged 2 commits into
masterfrom
2026-11-14_6709-content-free-blocked-merge
Nov 15, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-11-14_6709-content-free-blocked-merge

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

kernel-change: #6709 — the #5919 merge no-op conflates content-free BLOCKED partners with LIVE protected tools, so a turn that has a content-free partner dead-locks every merge covering it (session pins at ~67% of context).

What

A content-free BLOCKED partner (body removed by native compression) can never fold. Under the current #5919 classification it therefore dooms every merge covering its turn forever → the session stays stuck at its context ceiling (#6709, session-ad47cd30, 6,115 BLOCKED = 13.7%).

But ref==='BLOCKED' ALSO covers LIVE protected tools / unrecoverable media — assignRefs pins those to ref 'BLOCKED' too, with their full bodies still in the wire. Those MUST still no-op the merge: folding them in drops protected content, and leaving them split emits an orphaned tool_call/tool_result the provider rejects.

The two related PRs both keyed on ref==='BLOCKED' alone, and both masked the live-protected case (their regression tests gave the protected partner a numeric ref):

This PR is the correct superset: exempt ONLY content-free BLOCKED partners (ref BLOCKED AND not live-protected-tool AND not host-protected AND not unrecoverable-media). They flow to the #5919 rung-2 fallback and close the turn; live protected tools/media still no-op.

Changes

  • kernel/src/unit-projection.ts — add isContentFreeBlocked5919; filter it out of doomedStranded.
  • kernel/tests/issue5919-shredded-merge.test.ts — 5919-2 updated (content-free BLOCKED now merges); new 5919-5 (live protected tool stored as ref BLOCKED still no-ops — the guard both prior PRs missed).
  • kernel/package.json — 0.0.197 → 0.0.198.

Pre-flight (local, rebased on 58741e4)

  • tsc --noEmit: clean
  • kernel suite: 1637 pass / 0 fail
  • build: success
  • Full-suite verdict: remote CI (this PR is labeled ci:full).

Closes #6709
Related: #6719, #6731 — both superseded by this one (please close once this lands).

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-14_6709-content-free-blocked-merge (10b12e5)

Latest build — install this exact version

npm install -g billion-context@0.0.10078-pr.6754.581e685

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
10b12e5 billion-context@0.0.10078-pr.6754.581e685 build
acbaf91 billion-context@0.0.10015-pr.6754.034c53f build
0110a84 billion-context@0.0.10014-pr.6754.7e3fdc6 build
3c2f1db billion-context@0.0.10010-pr.6754.b30967f build
de50219 billion-context@0.0.10006-pr.6754.080646a build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6754.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title kernel: let content-free BLOCKED partners close their turn (#6709) [PR] kernel: let content-free BLOCKED partners close their turn (#6709) Nov 14, 2026
@ranxianglei
ranxianglei force-pushed the 2026-11-14_6709-content-free-blocked-merge branch 3 times, most recently from 0110a84 to acbaf91 Compare November 14, 2026 15:31
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Reviewed the diff against origin/master (merge base 58741e46b), traced the projectUnit #5919 path end-to-end, and ran the targeted + related regression suites locally.

What the change does

kernel/src/unit-projection.ts adds isContentFreeBlocked5919(id) and filters it out of doomedStranded:

const doomedStranded = visibleStranded.filter(
  (id) => isNeverFoldable5919(id) && !isContentFreeBlocked5919(id),
);

The predicate returns true only when ALL hold: ref === "BLOCKED" AND not in input.protectedMessageIds (host-level protection) AND filterProtectedToolMessages([id]).length > 0 (the fold-path filter does NOT remove it → it's foldable) AND not hasUnrecoverableMediaPayload. So a BLOCKED ref that is actually foldable (an aged compress receipt per #4348, or a non-protected tool whose body was stripped by native compression) no longer dooms the merge — it flows to rung 2 and gets folded into the merged block, closing the turn. A BLOCKED ref that is live-protected (newest compress receipt / protected tool) or unrecoverable media stays in doomedStranded → idempotent no-op.

Why this is the right split

ref === "BLOCKED" is stamped by assignRefs whenever protectedFn fires (unrecoverable media OR protected tool OR latest-protected). But the actual arbiter of foldability is the fold-path filter filterProtectedToolMessages, which carries the #4348 aged-receipt exemption (isExemptFold). So a BLOCKED ref can be foldable (aged compress receipt) or not (newest compress receipt / live protected tool). Keying the #5919 no-op on ref === "BLOCKED" alone conflated the two — exactly the #6709 deadlock (the 6,115 stale BLOCKED pins were aged compress receipts, each dooming every merge of its turn).

The safety net is intact: rung 2 (tryExtend5919) re-runs computeIntegrityWithdrawals on the extended set and only commits when there's no fold-side withdrawal, so the extension can't drop coverage (#4484) or split a call/result pair into a wire-invalid orphan. Live-protected partners never reach rung 2 because they remain in doomedStranded.

Tests — both directions pinned (gate-test discipline):

Local verification (targeted only, per local-testing discipline):

  • tests/issue5919-shredded-merge.test.ts: 7/7 pass.
  • Related regression suites (issue5789-tier2-merge-ladder, issue4484-merge-coverage, issue684-turn-integrity, issue3236-recommend-apply-consistency): 20/20 pass.
  • Recommend + media suites (recommend-merge, recommend-range-integrity, recommend, issue5620-ref-recoverable-media, prune-recommend-scale): 56/56 pass.
  • tsc --noEmit (kernel): clean.
  • Version bump 0.0.197 → 0.0.198 is clean and consistent across kernel/package.json, kernel/package-lock.json, and the root package-lock.json.
  • Full-suite verdict: remote CI (PR is labeled ci:full).

One minor test-coverage note (non-blocking): in every new test the stranded partner is a tool-RESULT (l); the symmetric case — a content-free BLOCKED tool-CALL as the stranded partner — isn't explicitly pinned. The logic is symmetric (the integrity check treats call/result pairs uniformly) and rung 2's withdrawal re-check is the safety net, so I don't consider this merge-blocking, but a one-line 5919-8 with k as the BLOCKED call would make the symmetry explicit.

Verdict: Correct, well-reasoned, well-tested. This is the right superset of #6719/#6731 — it folds exactly the BLOCKED refs that are actually foldable and keeps the live-protected/media no-op. Kernel change → human-only review tier, so I'm not merging; flagging for your sign-off. #6719 and #6731 can be closed once this lands (I won't close them — that's your call).


结构化八问

  1. 是什么问题:New error in v0.213, following up on the previous bug where old blocks can't be compressed and tokens double. | 0.213版本新报错,接着上次的旧块无法压缩token翻倍bug #5919 的 merge no-op 把「无内容的 BLOCKED 搭档」(body 被原生压缩删掉、永远无法 fold)和「活着的受保护工具/不可恢复媒体」混为一谈,导致覆盖其 turn 的每个 merge 永久死锁,会话钉在上下文上限(Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709,session-ad47cd30,6,115 个 BLOCKED = 13.7%)。
  2. 什么原因导致的:ref === "BLOCKED" 是 assignRefs 在 protectedFn 命中时(媒体/受保护工具/latest-protected)统一打的章,但真正的可折叠性由 fold 路径的 filterProtectedToolMessages 裁决(它带 Accident re-anchor debris is unrecoverable: the overlay island lands mid-turn, and the turn-split guard means the orphan | 事故重锚碎屑无法回收:覆盖岛落在 turn 中段,turn-split 守卫让孤另一半永远折不了 #4348 的 aged-receipt 豁免 isExemptFold)。New error in v0.213, following up on the previous bug where old blocks can't be compressed and tokens double. | 0.213版本新报错,接着上次的旧块无法压缩token翻倍bug #5919 只按 ref === "BLOCKED" 判 no-op,把实际可折叠的 aged compress receipt 也判成「永不折叠」→ 每次 merge 重撞同一个 skip。
  3. 影响范围与严重程度:特定条件下有问题——会话里存在「ref BLOCKED 但实际可折叠」的搭档(典型是 aged compress receipt)时,覆盖其 turn 的 merge 全部 no-op,上下文压不下去、只增不减地顶到 ~67% 上限。严重度:能用但上下文失控(成本随上下文单调上涨),属上下文/存储只增不减类;本 PR 是修复,不是引入。
  4. 怎么修复的:新增 isContentFreeBlocked5919,只豁免「ref BLOCKED 且非 host-protected 且 fold 过滤器不删它(即可折叠)且非不可恢复媒体」的搭档,把它们从 doomedStranded 滤掉、走 New error in v0.213, following up on the previous bug where old blocks can't be compressed and tokens double. | 0.213版本新报错,接着上次的旧块无法压缩token翻倍bug #5919 rung-2 折进合并块闭合 turn;活着的受保护工具/媒体仍留在 doomedStranded 里 no-op。
  5. 是否有回归问题:审过的既有行为——[Bug] Merging stale compressed blocks retracts existing coverage, causing repeated coverage-regression rejections | [Bug] 合并旧压缩块时撤回既有覆盖,导致 coverage-regression 反复拒绝 #4484 覆盖不丢(rung-2 提交前重跑 computeIntegrityWithdrawals,有 fold 侧 withdrawal 即拒绝)、Reaching out to the author — a plugin bug is throwing errors and causing the context to balloon rapidly. | 求助作者,插件bug报错导致上下文急速增加 #5789 阶梯/毒块排除、turn-integrity 的 INV1/INV2、recommend 共享投影(KDD refactor: reapOrphanBlocks should live in acp-kernel, not the proxy #12)、媒体 ref——全部定向跑绿(7+20+56);live-protected 仍 no-op(5919-5/7 钉死)。无回归。
  6. 是否破坏缓存:不涉及。改动只在 merge 决策的 doomedStranded 分类,不动 ref 空间、不动 prefix-cache 字节、不动重试/去重键。
  7. 是否改了设计方向:不涉及。仍是 New error in v0.213, following up on the previous bug where old blocks can't be compressed and tokens double. | 0.213版本新报错,接着上次的旧块无法压缩token翻倍bug #5919 的「no-op vs rung-2 扩展」两档,只是把「可折叠的 BLOCKED」从 no-op 档挪到 rung-2 档;单一投影(KDD refactor: reapOrphanBlocks should live in acp-kernel, not the proxy #12)不变。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:可合(kernel 属 human-only review,我不合,等你拍板)。#6719/#6731 待本 PR 落地后由你关闭。

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
…RL.pathname)

new URL(import.meta.url).pathname yields "/D:/..." on Windows (leading slash),
which path.resolve mangles into "D:\D:\a\..." and makes the package.json read
throw ENOENT — a deterministic red on the windows hermetic-registry e2e leg for
every PR. fileURLToPath (node:url) is the cross-platform idiom the repo already
uses (src/index.ts:12, src/update.ts, ...). Landed here because it was blocking
PR #6709's windows leg; path.dirname is preserved so REPO_ROOT still resolves to
the repo root on both platforms.

Refs: #6709
@ranxianglei
ranxianglei force-pushed the 2026-11-14_6709-content-free-blocked-merge branch from acbaf91 to 10b12e5 Compare November 15, 2026 03:52
@ranxianglei
ranxianglei merged commit 6468299 into master Nov 15, 2026
60 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1201-master.6468299 (rolling master tag).

npm install -g billion-context@0.0.1201-master.6468299  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the FULL CI matrix (all e2e lanes + 12-leg test matrix) on this PR

Projects

None yet

1 participant