Skip to content

kernel: split compressible ranges around recorded-dead refs so receipts never bracket them (#3192 #3205) - #3230

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-15_fix-3192-dead-ref-kernel-split
Oct 17, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-15_fix-3192-dead-ref-kernel-split

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

kernel-change: owner-directed root fix for #3192 — treat recorded-dead refs as segmentation gaps so range emitters stop producing spans that bracket a dead ref. The host-side whole-span-drop (#3195/#3204) cannot express the surviving sub-spans because it sees only aggregated {startRef,endRef}spans without per-message token accounting; onlybuildCompressibleRanges (which has per-message stats in hand) can split correctly. Human-only review required.

What

Follow-up to the merged host-side fix (#3195) and its sibling surface fix (#3204). Per owner direction, this folds #3205 into #3192 and fixes the bug at the source instead of masking it at the host.

The user-visible self-contradiction (a receipt declaring a ref DEAD while listing a range containing it) is already gone on master via excludeDeadRefRanges. What remains — and what the owner asked ("为什么不默认覆盖区间?") — is that the host filter drops the entire span bracketing a dead ref, silently withholding the perfectly-live messages on both sides of the dropped message.

Mechanism

A client-dropped message leaves no array slot, so its neighbours become array-adjacent. Three independent range layers each bridge across array-contiguous neighbours:

  1. buildCompressibleRanges segmentation (array adjacency),
  2. mergeRangesToThreshold (index-gap check),
  3. formatRanges display merge (position adjacency).

Covered/pruned gaps don't have this problem because a folded message is replaced by a summary node occupying an array slot (a real index gap); a dead hole has no such slot.

Fix: break the group at a recorded-dead hole in buildCompressibleRanges, then tag the following range noMergeBefore so neither merger re-bridges across it. Same level as the existing covered/pruned/carrier skip criteria. Strict no-op when state.deadRefs is empty.

Behavior change (old → new)

The host excludeDeadRefRanges filter is kept (it is load-bearing for #3204's plugin.ts/prepare-* surfaces) and now acts as a no-op safety net.

Tests (both layers green on rebased head)

  • Kernel: dead-ref-split.test.ts (new, 5 cases: interior split + flag, non-dead control stays bridged, multiple holes, trailing dead, no-rebridge through mergeRangesToThreshold) + full recommend/merge/nudge/formatRanges/consistency matrix = 167 pass.
  • Bili: updated compress-recovery-ranges.test.ts#3192 (now asserts the two surviving sub-spans, none crossing the dead ref) + issue3204-dead-ref-nudge-panel + success-tail/acp-status/span-hint/plugin-nudge = 54 pass. Every test file that assigns state.deadRefs is covered.

No config/env/CLI surface added. Kernel acp-kernel 0.0.124 → 0.0.125.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_fix-3192-dead-ref-kernel-split (acdd814)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4136-pr.3230.c7afad8

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-pr3230.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 本 PR 是 #3192 的 owner 定向根治实现(#3205 已由你关闭并入 #3192,见 #3205 floor 4)。检索 open+closed(dead ref / compressible range / kernel split / buildCompressibleRanges):无其他在途 issue/PR 覆盖「内核分段围绕 DEAD ref 切分」这一改动;#3195(已合入的宿主侧止血)与 #3204(宿主侧姊妹面)与本 PR 分工明确、互不重叠。本条为 [PR] 跟踪 issue,我按 PR review 处理,不重做。

这是 kernel 变更(Kernel Boundary):human-only review,不自动合并。我按八问体例做完整审核——方向关(#3192/#3205)、回归关(recommend/nudge-text/types 既有行为逐项清点)、代码关、测试有效性关、diff 整洁度关,本地只跑定向套件,全量以 CI 为准。结论稍后。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #3230 审核结论(kernel 变更,human-only tier)

审核证据(全部独立执行,非转述)

方向关(①原 issue):#3192 的自相矛盾(回执宣告 DEAD 的 ref 同时出现在可压 span 里)已由 #3195 宿主侧止血消除;本 PR 按你在 #3205 floor 4 的定向(「为什么不默认覆盖区间」→ DEAD ref 当分段间隙、断组后另起新组)修在源头。我逐层核对了所有 span 出口:可操作面只有三条产线——buildCompressibleRanges(分段)→ mergeRangesToThreshold(批合并)→ formatRanges(展示合并),宿主各面(acp-status/plugin/prepare-*/stream success-tail)全部消费这条链的产物并保留 excludeDeadRefRanges 作安全网。三层全覆盖,无遗漏的可操作出口。

代码关(③):逐行读过 recommend.ts / nudge-text.ts / types.ts 改动。关键正确性点我都验证过:

测试有效性关(④):测试有牙,我在 master(未修复基线 effd544)上叠了新测试实测:kernel 5 例中 3 例红(internal split / multiple holes / no-rebridge 正是钉修复的三例;control 与 trailing-dead 双基线绿,符合预期)、bili #3192 例红。修复头本地定向跑:kernel 全套件 1302 pass / 0 fail(PR 正文说的 167 是子集数)、bili 四个 deadRefs 相关文件 27 pass / 0 fail。展示层(formatRanges 不重桥)虽无独立 kernel 单测,但被 bili 回执端到端测试钉住(回执文本走 formatRanges,若重桥会解析出罩洞 span 而断言失败)。

回归关(②):逐项清点既有行为——covered/pruned/carrier/unrecoverable-media 四类既有 gap 判据未动;merge/format 两条合并路径对无 flag 输入行为不变(1302 例含既有 recommend/merge/nudge/formatRanges/consistency 矩阵全绿);types.ts 纯加性可选字段;golden wire-contract 无需变更(config/prompt/tool schema 零触碰,CI golden 门绿);持久化格式不动;bili 根 package.json 版本未碰。

diff 整洁度(⑤):6 文件全部与本 PR 目的相关,无私货、无空行洪水。Kernel Boundary 合规:kernel-change: 声明 ✓、acp-kernel 0.0.124→0.0.125 ✓、kernel: commit 前缀 ✓、双层测试 ✓。

我顺手修掉的一个 CI 红(已推独立标注 commit)

原 head 1399716cd 上 lock-sync 失败:kernel bump 改了 kernel/package.json 却没同步根 package-lock.json 里的 file:-link 版本记录(0.0.124),导致 lock-sync 红、整个分片 test 矩阵被 needs 跳过(全量套件根本没跑)。我用门禁自己的命令(npm install --package-lock-only)重新生成,单行 diff,推为独立 commit 77fbc6e05(非 kernel/** 变更,属该内核 bump 的锁文件同步机制部分)。新 head 41/41 check runs 全绿:lock-sync ✓、12 条分片 test(ubuntu/windows × node 22/24 × 3 shard)✓、static-gates(typecheck+kernel 套件)✓、kernel-guard/lane-guard/version-guard/docs/unused-exports/config-surface ✓、全部 e2e 道(registry/image-billing/codex/pi/opencode/dsh/OpenCode-V2-WS)✓。

结构化八问

  1. 是什么问题:客户端改写历史丢掉某条消息(ref 记为 DEAD)后,内核宣告可压区间仍罩住这个洞,宿主只能整段丢弃,把洞两侧完活的子 span 一起扣下,模型收到「无可压范围」而实际有活内容可压。
  2. 什么原因导致的:被丢的消息不留数组槽位,洞两侧变成数组相邻;三个独立的区间层(分段、批合并、展示合并)都以数组位置连续为桥接条件,对洞完全失明——根因在内核分段机制不感知 deadRefs,宿主侧整段丢弃是治标。
  3. 影响范围与严重程度:仅触发过客户端改写/丢消息且产生 DEAD ref 的会话(The compress failure receipt is self-contradictory: the same message first declares the ref permanently DEAD, then lists the range containing that DEAD ref as the "current compressible range." | compress 失败回执自相矛盾:同一条消息先宣告 ref 永久 DEAD,再把含该 DEAD ref 的区间列为「当前可压缩范围」 #3192 报告者即此形状);严重度=特定条件下系统性少报可压量(体验+效率损失,非数据损坏、非会话损坏)——洞两侧活内容被整段扣到「continue without compressing」。
  4. 怎么修复的:把 recorded-dead ref 当作与 covered/pruned/carrier 同级的分段间隙——分段时遇洞断组,并给洞后 range 打 noMergeBefore 标记贯穿批合并与展示合并两层,使任何下游位置合并都无法重桥回罩洞 span;宿主过滤保留为 no-op 安全网。
  5. 是否有回归问题:无。deadRefs 为空字节级不变(控制测试钉住);既有四类 gap 判据、合并语义、闸门、持久化、wire 契约均未动;双层 1302+27 本地绿 + CI 41/41 绿。一个有意行为变更(PR 正文已披露):拆出后被洞界定且低于 minChars 的碎片不再提供——与既有 gap 语义(出现持续压缩失败,无法自动恢复 #847/高 usage 下的非 400 失败(流截断/超时)无任何 overflow 兜底 —— 会话直接死 #498)一致,不再跨 gap 拉伸凑阈值。
  6. 是否破坏缓存:不涉及。不触碰 prefix-cache 敏感路径(head system 消息、块序、ref 编号空间均不变);ref 不复用契约不受影响。
  7. 是否改了设计方向:不涉及架构转向;是把既有「gap 判据家族」扩展一个新成员(DEAD),同一设计哲学([kernel][recommend] selector advertises spans the apply side structurally rejects — live-carrier screening missing (permanent advertise/validate disagreement) #2663/kernel: selector screens live carriers; withdrawal judged on original array class (#2663) #2669 先例)。一处与 kernel: buildCompressibleRanges 应围绕 DEAD ref 切分区间,而不是让 DEAD ref 落进已宣告 span 的内部 #3205 floor 2 建议的偏差需向你明示:当时建议同步第四处 report.ts 的 acp_status uncompressed 视图,本 PR 未改——我的独立判断是该视图纯信息展示(列出未压消息,不构成压缩指令),且其中罩洞 span 端点皆活、照做也能压成功,不会再生成自相矛盾,故判定可接受;若你要求 status 展示也绕洞分行,另开小 follow-up 即可。
  8. 是否引入了新的配置:不涉及。无新 env/config/CLI 面(CI config-surface-guard 绿)。

残留观察(均非阻塞,留你拍板):① 上述 report.ts 展示面;② 回执错误文案 “no range that includes them can compress now or later” 对「手搓的内部罩洞 span」技术上不准确(这类 span 其实能压成功)——#3205 floor 2 第 6 点已列过,属 owner 决策项,本 PR 范围外。

判定:审核通过,可合(kernel 变更按 Kernel Boundary 由你人工合并;我不代合)。分支当前 head 77fbc6e05,基于最新 master(effd5442c,base 新鲜无冲突),CI 全绿。

@ranxianglei
ranxianglei force-pushed the 2026-10-15_fix-3192-dead-ref-kernel-split branch from 77fbc6e to bf574ce Compare October 16, 2026 02:27
@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突 ci失败

@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突 ci失败

…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
ranxianglei force-pushed the 2026-10-15_fix-3192-dead-ref-kernel-split branch from bf574ce to acdd814 Compare October 17, 2026 06:14
@ranxianglei
ranxianglei merged commit 94e0fe0 into master Oct 17, 2026
43 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.526-master.94e0fe0 (rolling master tag).

npm install -g billion-context@0.0.526-master.94e0fe0  # 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant