Skip to content

kernel: empty view no longer marks requested refs DEAD (#3137) - #3141

Open
ranxianglei wants to merge 1 commit into
masterfrom
2026-10-14_kernel-empty-view-no-dead-refs
Open

ranxianglei wants to merge 1 commit into
masterfrom
2026-10-14_kernel-empty-view-no-dead-refs

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

kernel-change: #3137 — applyCompression marked every requested ref DEAD under an empty message view (input.messages=[]), poisoning intact refs tables until the next model request restored the view. An empty view carries no visibility evidence and must not create tombstones. Owner-approved via dedicated issue #3137 (the host-side gate in #3136 protects only bili; mixed requests it deliberately lets through, and every other acp-kernel consumer, still hit this path).

Closes #3137

Problem

applyCompression computes the "visible" baseline as new Set(input.messages.map(m => m.id)). With input.messages=[] that set is empty, so danglingMessageRefs judges every requested ref that is known to the session but not covered by an active block as dangling and writes it into state.deadRefs — even though nothing disappeared; the call simply carried no messages (proxy resident-pool eviction between model requests, process restarts, or any consumer calling with []). Because the host commits the kernel state clone even on a total failure, those tombstones persist: receipts blame "the client rewrote or dropped those messages" and forbid retry forever ("can NEVER compress"), and three such calls arm the loop breaker with a false cause (#3126).

Fix

Skip the dead-ref recording block entirely when input.messages.length === 0. Everything else is unchanged:

  • existing tombstones are neither lifted nor extended by an empty view (an empty view proves nothing in either direction) and clear on reappearance through the existing tombstone-with-clear branches (the applyCompression filter + the processTurn lift);
  • non-empty-view behavior is byte-identical — genuinely vanished refs still record DEAD exactly as before;
  • range classification, refold decisions, and gate structure are untouched; only the empty-view receipt wording changes (it now falls through to the honest "already compressed / stale block ref(s)" phrasing instead of claiming refs are DEAD).

Behavior change disclosure (old → new)

Case Old New
messages=[], requested refs known but uncovered by any block every such ref written to state.deadRefs; receipt says "recorded as DEAD … Do not retry this range in any form"; acp_status shows "can NEVER compress" no tombstones written (deadRefs unchanged); receipt uses the non-DEAD gate wording; acp_status unaffected
messages=[], pre-existing tombstones kept, plus new ones added kept, none added
messages=[], refs covered by active blocks (refold path) no-op (covered refs were never dangling) identical
messages != [] (all cases) — identical

Reason: deadRefs express "the message really is gone", not "this call did not carry messages". This is defense-in-depth at the kernel contract layer — bili's main path gets the up-front gate:no-visible-context refusal from #3136 (merged to master), but mixed requests (a range over an active block plus a range that is not, which that gate deliberately lets through) and every other acp-kernel consumer remain protected here.

Tests (two layers, both green on the rebased head d171c65)

  • kernel suite: 1279 pass / 0 fail (npm --prefix kernel test). New pins in kernel/tests/dead-refs.test.ts:
    • empty view + mapped refs + uncovered range ⇒ state.deadRefs stays undefined, no "DEAD" wording in the receipt;
    • pre-existing tombstones survive an empty-view call unlifted and unchanged;
    • mixed request (range over active block b1 + uncovered range, empty view) ⇒ no new tombstone, no "DEAD" wording.
  • bili layer: targeted suites green locally incl. the merged fix(#3126): refuse empty-view compress up front instead of poisoning refs #3136 gate suite — pins-storage-refactor, storage-corpus, compress-span-hint, issue2360-compress-receipt, wire-contract, issue3126-no-visible-context: 50/50; the full bili suite/e2e verdict comes from remote CI on this branch.
  • typecheck clean; wire-contract goldens untouched (no schema/prompt/config surface change).

Kernel version bumped 0.0.126 → 0.0.127 (CI-enforced discipline; master consumed 0.0.123–0.0.126 via other kernel changes while this PR was in review — the rebase resolved the version-line collision at the next free number each time). package-lock.json records the file: link version accordingly — verified npm install --package-lock-only --ignore-scripts --no-fund --no-audit produces zero further lock drift (lock-sync job).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到。这是已提交的 PR(分支 2026-10-14_kernel-empty-view-no-dead-refs,head bae518d),我不重做,按流程审核:拉分支核对 diff(kernel 改动属人工评审层)、确认 CI 状态,随后给结构化八问结论。预计几分钟内回复。

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-14_kernel-empty-view-no-dead-refs (d171c65)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3921-pr.3141.3516452

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-pr3141.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

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

PR #3141 审核结论(八问)

1. 是什么问题:会话视图为空(input.messages=[])时调 compress,内核把请求里每个「refs 表里有、但没有活动压缩块覆盖」的 ref 判成悬空并写进 state.deadRefs——实际上没有任何消息消失,只是这次调用没带消息。

2. 什么原因导致的:可见性基准是 new Set(input.messages.map(m => m.id)),空视图下即空集;danglingMessageRefs 按「已知 ref + 不可见 + 无块覆盖」判悬空,于是把「这次看不见」当成了「已消失」。我在 kernel/src/boundaries.ts 的 resolveAnchorIndex 确认了分类路径:空视图下已知但未覆盖的 ref 确实落入 BoundaryNotFoundError("consumed"),所以这不是理论缺口而是真实可达路径。修在内核契约层的判定源头(疏),不是下游过滤症状(堵)。

3. 影响范围与严重程度:触发条件是空视图调用——大会话上下文丢失后的重试、宿主侧异常。后果链:假 DEAD 墓碑让后续重试被 receipt 明确禁止("Do not retry this range in any form")、acp_status 误报 ref 永久不可压缩、#3126 熔断器可被误武装。宿主侧主修复 #3136(gate:no-visible-context)已挡住纯空视图请求,但混合请求和 acp-kernel 其他消费方仍会走到这条内核路径,故本条是契约层纵深加固。严重度:特定条件下的真实缺陷(非完全不可用),#3126 的用户可见症状已由宿主侧修复覆盖。

4. 怎么修复的:给 dead-ref 记录循环加 input.messages.length > 0 守卫——空视图不产生任何关于「消息消失」的断言,因此不写墓碑。既有墓碑在空视图调用下保持不动(不被误清、也不被新增),仍按原语义在消息重现时由 processTurn / applyCompression 过滤器解除。receipt 措辞从 DEAD 措辞降级为诚实的「already compressed / stale block ref(s)」。非空视图代码路径字节等价(循环体未动)。

5. 是否有回归问题:逐项审过触碰路径的既有行为——非空视图死 ref 记录(不变,字节等价)✓;墓碑解除双路径(applyCompression 过滤 + processTurn 清除,均未触碰)✓;refold 决策(evaluateRefold/refoldDecisions 不读 danglingBySpec,不受影响)✓;持久化格式(deadRefs 字段 schema 不变)✓;acp_status 渲染逻辑不变(只是不再被假阳性武装)✓;wire-contract golden 零触碰 ✓。有意行为变更(PR 正文已披露旧值→新值+原因):空视图调用——旧:写入墓碑 + DEAD 措辞 → 新:不写墓碑 + 非 DEAD 措辞;非空视图全部不变。未发现无意回归。

6. 是否破坏缓存:不涉及。deadRefs 只影响 receipt 措辞、重试建议与 acp_status 展示,不碰 prefix cache、增量游标、去重键或重试策略。

7. 是否改了设计方向:不涉及。内核契约层单点加固,与内核既有的「可见性是逐次调用的证据」纪律对称(解除逻辑本就只认非空视图的重现证据)。

8. 是否引入了新的配置:不涉及。

测试有效性(§④ 独立验证)

3 个新测试钉住披露表的三行语义(空视图不写墓碑且无 DEAD 措辞 / 既有墓碑空视图下原样存活 / 混合请求不加墓碑)。本地 A/B 实证:PR head 上 tests/dead-refs.test.ts 9/9 通过;把 compress.ts 回退到修复前版本重跑,恰好 3 个新测试失败、原有 6 个通过——测试有牙,且原有 6 个双侧同绿同时证明了非空视图行为未变。

Kernel Boundary 合规

kernel-change: 声明 ✓;owner 经专门 issue #3137 批准(含「为何宿主侧解决不了」论证:混合请求被 #3136 有意放行 + 其他 acp-kernel 消费方)✓;版本纪律 0.0.122→0.0.123 + lockfile 同步 ✓;两层测试——kernel 套件本地绿 + bili 全量 CI 绿 ✓。

CI 终局状态(head bae518d22)

33/33 check runs 全绿,含 4 条全量 test lane(ubuntu/windows × node 22/24)、kernel-guard/version-guard/lock-sync/config-surface-guard、e2e 与 hermetic registry 各 lane。分支落后 master(#3139/#3134 persona-google-v2,改 src/server/handle.ts + bili 测试文件)与本 PR 的 kernel/** diff 零文件交集,mergeable=True,无语义交互。

判定

可合。方向对、修在根因层、披露完整、测试有牙、CI 全绿、Kernel Boundary 全合规。合并为人工操作,请 owner 自行合并:#3141

An empty input.messages carries no visibility evidence: it means this call
carried no messages at all, not that the requested messages disappeared.
applyCompression previously judged every requested known-but-uncovered ref
dangling under [] and wrote it to state.deadRefs, poisoning the intact refs
table until the next model request restored the view (tombstone-with-clear)
and lying in every receipt in between ('can NEVER compress').

With an empty view, create no new tombstones and lift none; existing
tombstone-with-clear branches are untouched, and non-empty-view behavior is
unchanged.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant