Skip to content

[PR] kernel: let BLOCKED partners stop vetoing block merges (#6709) - #6719

Closed
sx4im wants to merge 3 commits into
ranxianglei:masterfrom
sx4im:fix-6709-blocked-merge-partners
Closed

sx4im wants to merge 3 commits into
ranxianglei:masterfrom
sx4im:fix-6709-blocked-merge-partners

Conversation

@sx4im

@sx4im sx4im commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

kernel-change: BLOCKED stranded partners no longer veto block merges — the #5919 no-op is a permanent deadlock for content-free partners, and the fix is a one-predicate change in the kernel merge ladder with a regression test.

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 for good), so the merge can never proceed and the session stays stuck at its context ceiling. Same reporter and session as #5919 (session-ad47cd30, 6,115 BLOCKED messages, 533K/792K on 0.1.214).

What changed

How verified

  • The new tests failed before the fix (merge no-opped) and pass after; the protected-tool case still no-ops.
  • Kernel suite 1639/1639 green locally, typecheck clean. The bili suite verdict is CI on this head (could not run it locally: the root install hits the sandbox disk quota).

Fixes #6709

)

A merge whose stranded turn partner is BLOCKED could never proceed: ranxianglei#5919
made it an idempotent no-op, but a BLOCKED partner can never age into
foldability — its body is gone for good — so the no-op was a permanent
deadlock and old blocks could never consolidate (session-ad47cd30, 6,115
BLOCKED messages, context stuck at 533K/792K). BLOCKED partners carry no
content turn-integrity protects, so they no longer doom a merge; the ladder
extends the fold to them (rung 2) and the turn closes under the merged
block. Protected-tool / recent-zone / unrecoverable-media partners still
doom a merge, exactly as before.

Tests: new kernel/tests/issue6709-blocked-merge-partners.test.ts (BLOCKED
only, BLOCKED + foldable, BLOCKED + protected-tool); ranxianglei#5919 test 5919-2
updated to the new BLOCKED behavior. Kernel suite 1639/1639 green,
typecheck clean. Bumps acp-kernel 0.0.197 -> 0.0.198.
@ranxianglei ranxianglei changed the title kernel: let BLOCKED partners stop vetoing block merges (#6709) [PR] kernel: let BLOCKED partners stop vetoing block merges (#6709) Nov 14, 2026
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

查重:不重复——#6719 是唯一修 #6709「BLOCKED 伙伴死锁块合并」的 PR;#6305 虽也提 BLOCKED,但机制不同(改 acp_status 不再推荐 BLOCKED 端点,不碰合并梯子),不重复。

已独立审完(kernel 改动,高敏感域)。结论:方向正确、修法干净、测试有牙、无回归,建议合入(待 CI 全绿 + 人工 review——kernel 改动按 Kernel Boundary 规则 3 必须人工把关)。

我做了什么(独立审核,非复读 issue):

  • 拉 PR 分支(基于当前 master 3858b695,仅 1 个 commit 3662c5d9),逐行读 kernel/src/unit-projection.ts 合并梯子(rung 1 排除 / rung 2 扩展)与 isNeverFoldable5919/refOf5919 全貌;确认改动只动 doomedStranded 过滤那一行,谓词内部一字未改;
  • 本地装 kernel devDeps,跑定向测试:6709-1/2/3 + 5919-1/2/3/4 + 5789 全套 + 4484/684/recommend-merge 共 48 个 merge/turn-integrity 测试全绿;
  • 复现验证:把源文件临时回退到 master(修复前),新增 6709-1/2 如期失败(复现死锁),6709-3(protected-tool)如期通过;恢复后全绿;
  • kernel typecheck 干净;golden pin(tests/golden/wire-contract/kernel.json)未被触碰;
  • 核对 computeProtectedRefs:recent-zone(last-N 消息/ token)确实进 protectedMessageIds,故 PR 注释「recent-zone 仍挡合并」准确;
  • CI 在跑(19 项 pending、0 failed;kernel-guard/version-guard 排队中)。

结构化八问

  1. 是什么问题:合并旧块时,只要回合里有一个 ref=BLOCKED 的伙伴,整批合并就被 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 永久挡住——BLOCKED 伙伴正文已被原生压缩删掉、seq 冻结,永远等不到可折,合并永远推进不了,会话卡在上下文上限(session-ad47cd30:6,115 条 BLOCKED、533K/792K 压不下去)。
  2. 什么原因导致的:根因是 isNeverFoldable5919 把「这条折不了」和「这条挡着别人折」混为一谈——它同时用于单条可折判定和合并挡路判定。对 BLOCKED 这种「正文已永久消失」的伙伴,「折不了」是对的,但拿它去「挡合并」就把 no-op 变成了死锁。修法正是把这两个判断拆开(与 reporter 在 Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709 给的最小补丁同向)。
  3. 影响范围与严重程度:所有带 BLOCKED 消息的会话里,覆盖 BLOCKED 回合的块合并全部 no-op,旧块无法合并、上下文只增不减。属 p1(会话压不下去、上下文只增不减)。
  4. 怎么修复的:只改合并挡路判定这一处谓词——doomedStranded 过滤时排除 ref==="BLOCKED",让 BLOCKED 伙伴像普通 stranded 伙伴一样流到 rung 2 被折进合并块、闭合回合;单条可折判定 isNeverFoldable5919 一字未动,protected-tool / unrecoverable-media / recent-zone / 缺消息 仍照旧挡合并。
  5. 是否有回归问题:逐项过既有行为——①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 对 BLOCKED 的 no-op:被 Version 0.214: compression issues still persist. The problem of old blocks failing to compress remains unresolved. | 0.214版本,压缩依旧存在问题,旧块无法压缩问题依旧存在 #6709 有意取代(PR 已披露旧→新);②protected-tool 挡合并:不变(5919-3 / 6709-3 钉死);③recent-zone / 缺消息 / unrecoverable-media 挡合并:不变;④Reaching out to the author — a plugin bug is throwing errors and causing the context to balloon rapidly. | 求助作者,插件bug报错导致上下文急速增加 #5789 中性继承 / 毒块排除:不变(全套绿);⑤[Bug] Merging stale compressed blocks retracts existing coverage, causing repeated coverage-regression rejections | [Bug] 合并旧压缩块时撤回既有覆盖,导致 coverage-regression 反复拒绝 #4484「合并不丢已有覆盖」:成立(BLOCKED 伙伴无正文,折进去不丢内容)。一个边界变化:若 BLOCKED 伙伴折进去会切开另一回合、或 stranded>16,rung 2 失败时合并从「no-op」变「fatal split error」——这是更有信息量的失败(提示模型对齐整回合),非回归,但属行为变更,在此点出。
  6. 是否破坏缓存:不涉及。改动在块合并/整合层,不碰前缀缓存、cache ref、去重键;把一个无正文的 BLOCKED 伙伴折进合并块不改变前缀字节。
  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 的 rung 1/rung 2 梯子结构,只在挡路判定里放行 BLOCKED,不转向架构/数据流。
  8. 是否引入了新的配置:不涉及。无新 env/config/CLI/默认值。

判定

方向对、修法对、测试有牙、无回归;kernel 边界规则齐(声明✓ / 版本 0.0.197→0.0.198✓ / 两层测试✓ / golden pin 未动✓ / 结构不变量✓);owner 已在 #6709 拍板(「会在 214 基础上追加 215 解决」)。建议合入,待 CI 全绿 + 人工 review。

ranxianglei pushed a commit that referenced this pull request Nov 14, 2026
…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
lock-sync regenerates the lockfile and diffs it; the kernel
version bump left the lockfile recording acp-kernel 0.0.197.
Update the one version line so lock-sync passes.
ranxianglei added a commit that referenced this pull request Nov 14, 2026
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
ranxianglei added a commit that referenced this pull request Nov 14, 2026
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
ranxianglei added a commit that referenced this pull request Nov 14, 2026
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
lock-sync also regenerates the kernel lockfile; the version bump
left it recording acp-kernel 0.0.197 in two places.
Update both version lines so lock-sync passes.
ranxianglei added a commit that referenced this pull request Nov 15, 2026
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
@ranxianglei

Copy link
Copy Markdown
Owner

#6754

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

Labels

None yet

Projects

None yet

2 participants