Skip to content

fix: stop advertising DEAD refs as compressible in receipts and acp_status - #3195

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-14_fix-3192-dead-ref-hint
Oct 15, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-14_fix-3192-dead-ref-hint

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

A single compress failure receipt could be self-contradictory: it declared a ref recorded as DEAD ... no range that includes them can compress now or later, then listed Current compressible ranges = the very span containing that dead ref. The model had to burn a round-trip on acp_status to discover the two statements disagreed.

Root cause

Two independent computations:

  • Gate (kernel/src/compress.ts) reads state.deadRefs, rejects any range citing a dead ref, and records the tombstone.
  • Eligibility view (buildCompressibleRanges, kernel/src/recommend.ts) never reads state.deadRefs. Because it segments positionally (a dropped middle message leaves a numeric hole bracketed by one span), a dead ref ends up inside an advertised [startRef..endRef] even though no message backs it.

This is a regression from #2800 (the #2778 shared-eligibility refactor): the pre-#2800 hint excluded dead refs; the shared-source rewrite kept only the protected/covered carve-outs.

Fix (host-side)

Add excludeDeadRefRanges() in src/acp-status.ts and apply it at every host surface that advertises ranges derived from nudge.compressibleRanges:

A range whose [startRef..endRef] brackets a dead ref is dropped. When nothing remains, the receipt falls through to the existing No eligible message ranges are available now; continue the task without compressing. stop instruction instead of listing a doomed span. No-op when state.deadRefs is empty.

Behavior change (disclosed)

Old → New: failure receipts / acp_status / nudge tail could advertise a range containing a dead ref → they now drop any such range (and emit the stop instruction when that empties the list). This only removes ranges the submit gate would reject anyway; it never adds or reorders live ranges.

Scope / gates

  • Host-side only — kernel/ untouched (no kernel-change declaration needed). The kernel-level hardening (splitting around a dead ref instead of dropping the whole span) is the more fundamental home but is owner-gated per the Kernel Boundary; filed as a follow-up note rather than bundled here.
  • No new config / env / CLI surface.
  • Regression test reproduces the contradiction (dropped middle message → positional span brackets the dead ref) and fails on unfixed code via the behavioral assertion, not an import error. Targeted suites green locally; full-suite verdict deferred to CI on this head.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-14_fix-3192-dead-ref-hint (63a89bf)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3710-pr.3195.91b2482

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

…tatus (#3192)

The submit gate records refs as DEAD when the client rewrites/drops their
messages and rejects any range citing them, but the eligibility view
(buildCompressibleRanges) never reads state.deadRefs — so a failure receipt
(and acp_status) could list exactly the doomed span it had just declared
"cannot compress now or later", one self-contradictory message.

Add excludeDeadRefRanges() and apply it at every host advertising surface that
derives from nudge.compressibleRanges: liveCompressionRanges (feeds both the
failure-receipt hint and acp_status) and the post-compress tail offer. A range
whose [startRef..endRef] brackets a dead ref is dropped; when nothing remains
the receipt falls through to the existing "continue the task without
compressing" stop instruction instead of a doomed retry span. No-op when
state.deadRefs is empty.

Regression test reproduces the contradiction (a dropped middle message leaves a
positional span that brackets the dead ref) and fails on unfixed code via the
behavioral assertion, not an import error.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。本条是 [PR] 审核任务而非新 bug 报告;关联项核对:#3192(源 issue,本 PR 的 Fixes 对象)、#3137/#3141(空视图误判 DEAD——不同症状不同机制,#3192 楼层已有判定)、#2638/#2660(preflight 产线,用户自划分的同类独立产线)。#3192 楼里「本 PR 需以 #3141 合并后的 master 为 base、文件有重叠」的担忧经实测不成立:rebase 到当前 master 零冲突。

审核方式: 独立重做——自己读了 gate/recommend/boundaries 源码判定过滤语义,试 rebase、本地定向验证、拉 CI 日志逐 shard 看了失败用例;未沿用 #3192 楼里作者 agent 的八问结论。

八问

  1. 是什么问题:一条 compress 失败回执可以自相矛盾——同一段话先宣告某 ref「已记为 DEAD,任何包含它的区间现在和将来都压不了」,又把「当前可压缩范围」列成恰好罩住这个 DEAD ref 的 span(实测案例 m11615–m11620 罩 m11620),模型被迫多跑一轮 acp_status 才发现两处对不上。
  2. 什么原因导致的:两段计算没对齐——提交闸门认 state.deadRefs(danglingMessageRefs),资格视图 buildCompressibleRanges() 从不读它(recommend.ts 全文件 0 次出现 dead),且按数组位置分段:被客户端丢掉的消息留下 ref 数字洞,被同一个 [startRef..endRef] 罩住。这是 Use live compression eligibility for recovery advice #2800(Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 共享来源重构)静默丢掉的排除项:重构前 hint 有显式 "Excluded as DEAD" 行,重构后只剩 protected/covered 两类。
  3. 影响范围与严重程度:所有 ACP compress 会话中「客户端改写/删除过消息(产生 DEAD ref)且该 ref 落在某 span 数字区间内」的场景;后果是注定失败的区间再喂给模型一次(浪费一轮往返 + 困惑),非数据损坏。严重度:中(特定条件触发)。触发前提不低(tombstone 由一次锚定失败创建),但长会话里客户端改写并不罕见。
  4. 怎么修复的:宿主侧加纯函数 excludeDeadRefRanges()(数字区间罩住任一 DEAD ref 的 span 整体剔除;deadRefs 为空时恒等返回,连数组引用都不换),应用在三个对外宣称面:liveCompressionRanges()(同时喂失败回执与 acp_status,两构造性一致,保住 Compression failure recovery hints advertise protected or already covered refs as immediately compressible #2778 承诺)+ post-compress tail 两条分支。滤空后落到既有停手指令。
  5. 是否有回归问题:我审过的既有行为——protected tail / already-covered / sub-minCompressRange / 正常可压区间:deadRefs 为空时 helper 是 identity no-op,四类不受影响;有 DEAD ref 时只删 span、不新增不重排。但 PR 描述里一句披露措辞不准确(见附加发现 1):「只移除闸门本就会拒绝的区间」对『内部罩洞』型 span 不成立——闸门只查两端点,内部有洞的 span 其实能压成功,本 PR 把它们也删了(少报,保守方向,符合验收标准;根治在内核侧)。
  6. 是否破坏缓存:不涉及(只改对外展示哪些区间;不碰 prefix cache、快照游标、去重键、持久化格式)。
  7. 是否改了设计方向:不改架构/边界/数据流,是把 Use live compression eligibility for recovery advice #2800 弄丢的一处排除补回宿主侧。更根本的家在 kernel(分段绕洞切分)——受 Kernel Boundary 约束,PR 不捆绑是对的;但正文说 "filed as a follow-up note" 实际没有 issue 号,我已按 Kernel Boundary 第 1 条正式立项 kernel: buildCompressibleRanges 应围绕 DEAD ref 切分区间,而不是让 DEAD ref 落进已宣告 span 的内部 #3205。
  8. 是否引入新的配置:不涉及。无新 env/config/CLI 字段。

验证证据(我本地跑的,rebase 后的头 ead8640 = 本 PR 提交 + 当前 master b2868ca)

附加发现(已立项,不塞进本 PR)

  1. 披露措辞建议改准(非阻塞):PR 描述 "This only removes ranges the submit gate would reject anyway" 对内部罩洞型 span 不成立——danglingMessageRefs 只遍历两端点(compress.ts:170-190),resolveBoundaries 收集两端点之间的可见消息、内部洞透明(boundaries.ts:126-138);回归夹具本身就演示了这一点(base 上宣告 m00001–m00007,dead m00005 在内部,该 span 提交其实会放行)。建议改为:移除的是「数字区间罩住 DEAD ref」的 span——端点罩洞的闸门必拒,内部罩洞的闸门会放行(压掉可见子集),故此处是刻意的保守少报,直到内核学会绕洞切分(kernel: buildCompressibleRanges 应围绕 DEAD ref 切分区间,而不是让 DEAD ref 落进已宣告 span 的内部 #3205)。
  2. 另有两条产线还在宣称未过滤的 span(同根机制、不同表面,按 [Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638/[PR] fix(#2638): stop preflight re-nominating structurally-dead spans every turn #2660 的产线划分惯例单独立项 nudge 决策指令与 /acp 面板仍会列出含 DEAD ref 的压缩区间(#3192 同根机制的另外两条产线) #3204):① nudge 模型决策面(nudgeModelDecided=true 时)——决策提示词列 span、yes 后注入命令式指令「compress exactly this span」,span 端点罩 DEAD ref 时模型照做必拒 + 累加 breaker 计数;② /acp 面板 JSON 的 compressibleRanges 字段(plugin.ts:1556,live 重算、无过滤)——本 PR 合并后会与 acp_status 输出重新分裂。
  3. 内核侧根治立项 kernel: buildCompressibleRanges 应围绕 DEAD ref 切分区间,而不是让 DEAD ref 落进已宣告 span 的内部 #3205:buildCompressibleRanges 绕 DEAD ref 切分(输出存活子 span 而非整段丢弃),owner-gated,待批准。

合并判定

代码本身我这边验证通过(rebase 后头全绿 + 红测属实 + 既有行为无回归)。pushed head 的 CI 红已由我 rebase 消除根因(stale base),等 ead8640 上的 CI 转绿即可合;若仍红我再定向排查。无需改代码;建议顺手把 PR 描述第 1 条披露措辞改准(非阻塞)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 结论(rebase 后 head ead8640,parent = 当前 master b2868ca):

判定:PR 相关信号全绿;剩余红灯是 master 级环境问题,与本 PR 无关。

附加动作:这 4 类失败已有跟踪单 #3206(伞)+ #3207(端口冲突机制),修复 PR #3197 在途。按查重规则未另开单,已在 #3206 补充本次排查证据(精确错误签名 EADDRINUSE 127.0.0.1:18787 / "hook attached to the user's daemon" / 0.8s 就绪超时 / 事件循环挂起 + rerun 系统复现 + master 连续红事实),并在 #3207 留了佐证。

最终判定(不变,证据链补全):代码本身无阻塞问题,可合并;合并时机受 master 级 CI 红灯风暴约束——等 #3197 修好红灯后 CI 自然转绿,或 owner 依据上述证据直接合并、环境问题留给 #3206/#3207 继续收敛。

@ranxianglei
ranxianglei merged commit afed2aa into master Oct 15, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.437-master.afed2aa (rolling master tag).

npm install -g billion-context@0.0.437-master.afed2aa  # 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.

@ranxianglei
ranxianglei deleted the 2026-10-14_fix-3192-dead-ref-hint branch October 15, 2026 05:33
ranxianglei pushed a commit that referenced this pull request Oct 16, 2026
…ub-spans (#3192 #3205)

A client-dropped message leaves NO array slot, so array-adjacency segmentation plus both position-based mergers (mergeRangesToThreshold, formatRanges) each bridge across it and re-emit one span bracketing the recorded-dead ref — the self-contradictory receipt from #3192. Treat the dead ref as a segmentation gap (same level as covered/pruned/carrier): break the group at the hole in buildCompressibleRanges, then tag the following range noMergeBefore so neither merger can re-bridge across it.

Supersedes the host whole-span-drop from #3195/#3204 at the source: the surviving sub-spans are now advertised instead of the whole doomed span being dropped. The host excludeDeadRefRanges filter stays as a no-op safety net. Strict no-op when state.deadRefs is empty.

kernel package.json 0.0.124 -> 0.0.125; new kernel/tests/dead-ref-split.test.ts; updated tests/compress-recovery-ranges.test.ts #3192 to assert the split sub-spans.
ranxianglei pushed a commit that referenced this pull request Oct 17, 2026
…ub-spans (#3192 #3205)

A client-dropped message leaves NO array slot, so array-adjacency segmentation plus both position-based mergers (mergeRangesToThreshold, formatRanges) each bridge across it and re-emit one span bracketing the recorded-dead ref — the self-contradictory receipt from #3192. Treat the dead ref as a segmentation gap (same level as covered/pruned/carrier): break the group at the hole in buildCompressibleRanges, then tag the following range noMergeBefore so neither merger can re-bridge across it.

Supersedes the host whole-span-drop from #3195/#3204 at the source: the surviving sub-spans are now advertised instead of the whole doomed span being dropped. The host excludeDeadRefRanges filter stays as a no-op safety net. Strict no-op when state.deadRefs is empty.

kernel package.json 0.0.124 -> 0.0.125; new kernel/tests/dead-ref-split.test.ts; updated tests/compress-recovery-ranges.test.ts #3192 to assert the split sub-spans.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant