Repository navigation
fix: dead-ref tombstones — stop the self-amplifying compress failure loop (#2362) - #2370
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2645-pr.2370.f5f8297This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2370.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 已完成对 PR #2370(dead-ref tombstones,#2362)的审查。这是 kernel 变更(v0.0.105→0.0.106),按 Kernel Boundary 属人工门禁、禁止自动合并。 结论:暂不可合并 —— 1 个机械性阻塞(需 rebase + 重定版本)+ 1 个真实回归 bug + 1 处披露不实。以下按七问作答。 ① 是什么问题 ② 什么原因导致的 ③ 怎么修复的 ④ 是否有回归问题 —— 有,三处(按严重度):
确认无回归的项:acp-status.ts 纯增量、deadRefs 为空时 byte-identical;covered-not-dangling 保持「already compressed」原话(有负向测试钉住); ⑤ 是否破坏缓存:否。 ⑥ 是否改了设计方向:无架构转向。加一个加法式可选 state 字段 + 复用既有 receipt/acp_status 引导面。kernel-boundary 声明到位且理由成立(按-ref 可达性是 kernel 自有状态,host 侧表达不了)。与 #2360(初始触发)解耦得当。 ⑦ 是否引入新配置:无。不加 env/config key/CLI flag(符合 config-surface 纪律)。 补充:
合并判定:不可合并(人工门禁)。 合并前必需:
之后重跑 CI 至绿。 我可以在你确认后:(a) 立即推 (1)——纯机械、我已在临时 rebase 里备好;(b) 起草 (2)(3) 补丁供你审。(2)(3) 都动到 kernel-gated 代码 / 引导面行为决策,故等你拍板再动手。 |
|
Reproduced the reviewer's regression (2) from a second environment and it is not an edge case on this box — it is the common path. Cleaning that up first because it changes the priority of the fix. Environment
MeasurementScanned all 587 sessions, reading
Two things follow. 1. The "all DEAD" branch is reached on ordinary healthy sessions, not on poisoned ones. 2. Therefore the PR's own regression promise does not hold here. "No-dead output is byte-identical to before" is true only if Victim ranking, which is the part I would weight: the two affected states are "clean session that never needed to fold" and "healthy session that just folded successfully". Both are good states. The failure direction is falsely reporting poisoning, which is worse than staying silent, and it lands on the users whose compression is working — the ones who would have no reason to distrust the message. That is the §7.3 Honest output concern the review already raised, but the blast radius is the whole box rather than a corner. A regression case that would pin itThe review noted
I can supply the fixtures if useful. On the two other release blockers(1) version bump — no objection to rebasing and re-cutting kernel at (3) Thanks for catching (2) before merge — on this box it would have been the noisiest possible way to ship a correct fix. |
[bot] 🏷 Correction — I was wrong on item (2); withdrawing it. Re-reading the actual diff (not just the receipt wording) overturns my earlier read. The "all-DEAD false positive" I reported does not exist:
So the escalation in the previous comment rests on the same misread: it assumes Net effect on the "byte-identical otherwise" promise: it holds, with one exception — when exactly one ref sits above the boundary ( Corrected pre-merge list (item 2 withdrawn):
Verdict unchanged in kind: human-gated kernel PR, not mergeable until (1) lands; (3) is a one-line text fix. I hold for owner (@ranxianglei) sign-off before pushing anything. Two notes for the record: (a) @loalissm-cell is flagged unverified/outside by the platform, so I re-derived every claim from source rather than taking either account's word; (b) thanks for pushing on this — it caught a real error in my first pass. |
8c3250f to
acee3c3
Compare
acee3c3 to
17e5a45
Compare
[bot] 🏷 上游冲突已解决并 push(rebase 到当前 master;未合并,内核改动 human-gated) 系统转发「merge state: dirty」。核对后确认是真实冲突:master 在本 PR base 之后又合入了 6 个提交——全部是 pi-subagents 入仓(#2384/#2386/#2380)+ 文档/CI。按「上游 PR 冲突唤醒」流程 rebase → 解冲突 → push。 结构化回答
版本披露(按行为变更披露要求): 当前状态:head 已更新到 结论:冲突解决完毕,可进入 CI + 人工评审/合并流程。 |
|
冲突 ci失败 |
[bot] 🏷 CI 已定位:4 个 先排除嫌疑:我上次 rebase 只动了 逐条根因 ①②
③ 结构化八问
建议与分工:这是 human-gated 内核 PR,且 ③ 动的是你内核里的真回归,我不擅自改方向。①②我可以立刻补两条断言(独立标注 commit);③想请你先定修法方向——我倾向「失败路径不落任何喂给 observation.generation 的 state mutation」,定位到具体行再动手。你点头我就把三条一起修好推上去;或你说「直接修」我就照此执行。 当前状态:head |
|
你找到ci红色根本原因并修复,rebase master最后报告状态 |
17e5a45 to
14dd146
Compare
…-amplification loop (#2362) A compress request whose endpoint ref is known to the session but backs no visible or folded message (client history rewrite / host-native compaction) used to fail with 'cannot be anchored ... leaving your old refs dangling. Run acp_status and call again' — inviting a retry that can never succeed while every failed attempt added more hidden orphan refs. Now such refs are recorded as DEAD (state.deadRefs, tombstone-with-clear: marked by applyCompression on a dangling endpoint, cleared per-ref by processTurn once the message reappears inbound, never removed from messageRefs so ref numbers stay un-reissuable). Failure receipts name the dead refs and forbid retrying the range; mixed-batch skip warnings say DEAD instead of 'already compressed'; rejected batches return the cloned state so the marking survives; cloneState carries deadRefs.
…pan hint (#2362) Failure receipts point the model at acp_status, so the dead set must be visible on every surface that steers the next compress: compressibleSpanHint subtracts state.deadRefs from the advertised live span (multi-span output, all-dead branch drops the retry push), and handleAcpStatus appends a DEAD REFS section when non-empty. No-dead output is byte-identical to before.
…s in cloneState applyCompression bumped nextRunId unconditionally and cloneState dropped lastPassIds, so a failed (zero-block) manual compress returned a state that differed only in internal bookkeeping. The host adopts res.state and markDirty()s after every tool, so forkSnapshot's parentRevision re-hashed and contextGeneration churned on every failed tool call (tests/plugin-status-provenance #3). Allocate the run id only when a block is actually created, and make cloneState faithfully preserve lastPassIds.
…receipt tests #2362 renamed the cannot-anchor gate sentence but the armed-breaker scrub list kept only the old wording, so an armed receipt carried BOTH 'run acp_status and target only the live refs' and 'do not poll acp_status' - reintroducing the contradiction #2146/#2360 removed. Add the new sentence to KERNEL_RETRY_GUIDANCE and update the two stale assertions to match the new kernel wording.
master independently consumed 0.0.108 (#2378); recut so the branch's kernel/src changes carry a version delta vs master (Kernel Boundary rule 2).
14dd146 to
d9ce7ad
Compare
#2370 已修复并 rebase 到最新 master —— 结构化八问 冲突已解、CI 红色的根因已定位并修复,分支已 rebase 到当前 master tip(
收工判定:本地 typecheck 干净、承重测试 26/26(provenance/receipt/span-hint/acp-status)+ 内核定向 38/38 + 181/181 全绿;全量回归 + e2e 交给 CI(按本地测试纪律未在本地跑全量)。这是 kernel 变更(Kernel Boundary:永不自动合并)——我不合并,请 review 后自行合并:#2370 。仓库合并节奏很快(本会话内 master 动了三次),若合入前 master 又前进,可能还需再一次机械 rebase,需要的话我来做。第 5 条的两个残留项若要立项跟进,我可以补带「来源」标记的 issue,等你点头。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.165-master.293c32d # this exact build
npm install -g billion-context@master # always the newest merged build
|
…drator CompressionState clone/hydrate points rebuild via explicit field lists, so each new optional field silently drops wherever the list lagged (deadRefs hit three such points in #2362/#2370). Make that drift loud instead of silent: Guard (two layers): a compile-time field inventory mapped over keyof CompressionState with optionality stripped (-?), so adding a field without listing it is a TYPE error, plus a runtime EXACT match between each point's actually-carried keys and its documented expected-missing set. Covers syncBlocks, cloneState, mergeCompressionState (kernel) and mergeState (host). The subagent fork is targeted inheritance, documented rather than asserted (needs the session harness). Fix: mergeCompressionState (the standalone acp-kernel hydrator) carried neither hiddenOrphanRefs nor lastPassIds, so a real consumer lost them on restart. deadRefs (#2362) hit the same gap when it landed — the host mergeState carries all three, so the hydrator matches it. Bare passthrough like terminalStreak (none of them is seeded by createInitialState). syncBlocks keeps its two documented gaps (hiddenOrphanRefs self-heals post-pipeline; lastPassIds is inert — consumed before it runs, re-stamped after); cloneState and both hydrators carry every field, pinned against regression. Rebased onto master: #3266 removed imageFullRestored/imageShrinks from CompressionState, so inventories and gap sets track the post-removal field set; cloneState's original gaps were closed upstream by the #2362 work. Bumps acp-kernel 0.0.126 -> 0.0.127 (kernel/src changed).
…drator CompressionState clone/hydrate points rebuild via explicit field lists, so each new optional field silently drops wherever the list lagged (deadRefs hit three such points in #2362/#2370). Make that drift loud instead of silent: Guard (two layers): a compile-time field inventory mapped over keyof CompressionState with optionality stripped (-?), so adding a field without listing it is a TYPE error, plus a runtime EXACT match between each point's actually-carried keys and its documented expected-missing set. Covers syncBlocks, cloneState, mergeCompressionState (kernel) and mergeState (host). The subagent fork is targeted inheritance, documented rather than asserted (needs the session harness). Fix: mergeCompressionState (the standalone acp-kernel hydrator) carried neither hiddenOrphanRefs nor lastPassIds, so a real consumer lost them on restart. Bare passthrough like terminalStreak (neither is seeded by createInitialState). No runtime behavior change: the syncBlocks/cloneState gaps are left as-is; their safety proofs (self-heal / inert / deferred-eval) are documented in the guard. Carrying image*/lastPassIds there is deliberately deferred per the issue. Bumps acp-kernel 0.0.108 -> 0.0.109 (kernel/src changed).
…drator CompressionState clone/hydrate points rebuild via explicit field lists, so each new optional field silently drops wherever the list lagged (deadRefs hit three such points in #2362/#2370). Make that drift loud instead of silent: Guard (two layers): a compile-time field inventory mapped over keyof CompressionState with optionality stripped (-?), so adding a field without listing it is a TYPE error, plus a runtime EXACT match between each point's actually-carried keys and its documented expected-missing set. Covers syncBlocks, cloneState, mergeCompressionState (kernel) and mergeState (host). The subagent fork is targeted inheritance, documented rather than asserted (needs the session harness). Fix: mergeCompressionState (the standalone acp-kernel hydrator) carried neither hiddenOrphanRefs nor lastPassIds, so a real consumer lost them on restart. deadRefs (#2362) hit the same gap when it landed — the host mergeState carries all three, so the hydrator matches it. Bare passthrough like terminalStreak (none of them is seeded by createInitialState). syncBlocks keeps its two documented gaps (hiddenOrphanRefs self-heals post-pipeline; lastPassIds is inert — consumed before it runs, re-stamped after); cloneState and both hydrators carry every field, pinned against regression. Rebased onto master: #3266 removed imageFullRestored/imageShrinks from CompressionState, so inventories and gap sets track the post-removal field set (and pick up deadRefs); cloneState's original gaps were closed upstream by the #2362 work. Bumps acp-kernel 0.0.126 -> 0.0.127 (kernel/src changed).
…drator CompressionState clone/hydrate points rebuild via explicit field lists, so each new optional field silently drops wherever the list lagged (deadRefs hit three such points in #2362/#2370). Make that drift loud instead of silent: Guard (two layers): a compile-time field inventory mapped over keyof CompressionState with optionality stripped (-?), so adding a field without listing it is a TYPE error, plus a runtime EXACT match between each point's actually-carried keys and its documented expected-missing set. Covers syncBlocks, cloneState, mergeCompressionState (kernel) and mergeState (host). The subagent fork is targeted inheritance, documented rather than asserted (needs the session harness). Fix: mergeCompressionState (the standalone acp-kernel hydrator) carried neither hiddenOrphanRefs nor lastPassIds, so a real consumer lost them on restart. Bare passthrough like terminalStreak (neither is seeded by createInitialState). No runtime behavior change: the syncBlocks/cloneState gaps are left as-is; their safety proofs (self-heal / inert / deferred-eval) are documented in the guard. Carrying image*/lastPassIds there is deliberately deferred per the issue. Bumps acp-kernel 0.0.108 -> 0.0.109 (kernel/src changed).
kernel-change: dangling-endpoint detection, gate receipts and the reachability tombstone live inside the kernel compression pipeline (boundaries + applyCompression); per-ref reachability is kernel-owned state and cannot be expressed from the host side.
Closes #2362
What this fixes
A compress request whose endpoint ref is known to the session but backs no visible or folded message (client history rewrite, host-native compaction) failed with "…leaving your old refs dangling. Run acp_status, then call the compress tool again using only the refs it reports." — inviting a retry that can never succeed, while every failed attempt added more hidden orphan refs (
hiddenOrphanRefs). Net effect: the same range stayed permanently un-compressible and the diagnostics self-contradicted ("unknown ranges in request=0/1" while telling the model to retry).Mechanism
Kernel (v0.0.108) — master had already advanced the kernel to 0.0.107 via other merged PRs; this branch bumps to 0.0.108.
deadRefs?: string[]— tombstone-with-clear: marked byapplyCompressionwhen a requested endpoint dangles (ref known, no visible message, no active block covers it); cleared per-ref byprocessTurnonce the backing message reappears inbound; refs are NEVER removed frommessageRefs(kernel contract: numbers never re-issue).cloneStatecarriesdeadRefsthrough.syncBlocks(kernel/src/sync.ts — runs every request as pipeline node Use kernel renderTags:"text-only" + forbid tag echoing in prompt #3) now carriesdeadRefs; without it the tombstone died at the next request boundary and the model re-learned each dead ref by failing again.Host
compressibleSpanHint(src/stream.ts) subtractsstate.deadRefsfrom the advertised live span (multi-span output; all-dead branch drops the "Retry NOW" push). No-dead output is byte-identical to before.handleAcpStatus(src/acp-status.ts) appends aDEAD REFS — …section when non-empty — receipts point the model at acp_status, so the dead set is visible on the canonical steering surface.mergeState(src/persist.ts, restart hydration) mergesdeadRefs; the subagent fork (src/plugin.ts) inherits it with inverse-prefix semantics (a dead ref whose message IS in the forked prefix revives; refs outside it stay dead).ProxyToolResult.reasonset at every compress refusal site (parse:{kind}/gate:{cannot-anchor|already-compressed|none-resolved|too-small|other}/exception) and carried onto the[plugin] … executed via plugin (… outcome=…, reason=…)execution log line — previouslyoutcome=refusednever said why on the anchor line (compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362 log-sweep finding F2).Behavior changes (old → new)
deadRefs(additive; old sessions load fine; auto-clears when the messages reappear; now also survives restart hydration and subagent forks).acp_statusgains a DEAD REFS section only when non-empty; receipt live-span hints subtract dead sub-spans (byte-identical otherwise).[plugin]execution log line gains, reason=<class>on refused compress calls (log-only; applied/partial outcomes unchanged; all e2e assertions use prefix regexes — verified compatible).No config-surface change, no env vars, no wire-format change, KEEP_LAST_ORPHANED unchanged.
Commits (rebased onto master@625989406, which includes merged #2364)
2881083e8kernel: record dead refs for unreachable endpoints and stop the retry-amplification loop (compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362) — types/compress/tests, kernel 0.0.107 → 0.0.108f777b5a5afix: surface dead refs in acp_status and carve them out of the live-span hint (compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362)bf978cb97fix: carry a machine-readable refusal reason onto the [plugin] execution line (compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362)acee3c3f8fix: carry deadRefs through syncBlocks, restart hydration and subagent forks (compress failure is self-amplifying: failed calls are hidden as orphan refs, making the same range permanently un-compressible #2362) — found when CI's targeted suite caught the per-request dropConflict resolution during rebase was textual union of intent (no semantic overlap with #2364's guard/receipt changes).
Tests
kernel/tests/dead-refs.test.ts(6 tests): marking + receipt wording; retry stability (dead set does not grow); tombstone lift on full/partial revival; mixed batch (live half folds, dead half warns DEAD); covered-not-dangling guard keeps "already compressed".kernel/tests/compress.test.tsto assert the new receipt wording +deadRefs.tests/compress-span-hint.test.ts: dead-carved multi-span, all-dead branch, receipt embedding.Relation to #2360 / #2388
mergeCompressionStatestill lacksdeadRefs/hiddenOrphanRefs/lastPassIds). Deliberately NOT bundled here: different failure domain, kernel-gated, and carrying the remaining fields would be unquantified behavior drift.