Repository navigation
fix(#3126): refuse empty-view compress up front instead of poisoning refs - #3136
Conversation
…refs When the proxy holds no live message view of a session (in-memory copy dropped between model requests by resident-pool eviction or restart) but the refs table is intact, applyRanges fed an empty message list into the kernel: every requested ref was judged dangling, marked DEAD in deadRefs (committed + persisted even on total failure), and receipts blamed content-changed / substrate-destruction while the breaker armed with a false cause. The refs were never actually changed — the next model request restores the view and clears the tombstones anyway. - new gate in applyRanges (+ external-summary lane): refuse with reason gate:no-visible-context and an honest receipt (refs intact, nothing recorded as dead, do-not-retry-until-next-model-request); writes no deadRefs; feeds the loop breaker the true cause - the gate YIELDS when any requested range overlaps an active compression block (#398/#403 refold works from state alone under a proxy-shaped empty view) and for fresh ref-less sessions (unchanged kernel diagnostics) - noteCompressLoopFailure gains forcedCause so the breaker records the honest cause without re-running failure-cause inference - resident-pool evictions are now logged (session id, weight, budget) so the empty-view window is observable instead of silent
850ff3d to
3b5d606
Compare
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3578-pr.3136.ed11918This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3136.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qween/qwen3.8-27b) Review 完成。结论先行:可合并 —— 方向正确、打在了根因上、未发现回归、CI 全绿(head 审核过程(独立重做,非复读 issue 结论):
结构化八问:
额外发现(独立探针): 空视图下的 bN..bM tier-distillation 请求: 收工判定:可合并。 完整 CI 绿、typecheck/build 干净、diff 收敛为单 commit 且每行都与 issue 目的相关。PR 合并是 human-only,请自行合并:#3136 |
(ai: vllm-qwen/qwen3.8-27b) 上一条首行的模型自报打错了一个字母,更正: |
(ai: vllm-qwen/qwen3.8-27b) 收到「上游 PR 冲突」转发——核实后:没有真实冲突,未做任何操作。按「不重复 rebase、不硬救」原则处理。 核实依据(实时 GitHub API,非缓存):
CI 现状(同一 head): 30 个检查中 26 个 success;4 个 八问(本次为误报核实,多数不涉及):
收工判定:维持原结论——可合并(待 4 个重跑检查回绿后即可);合并是 human-only,请自行操作:#3136 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.426-master.1d5a420 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3126
Problem
Large-session compress calls fail repeatedly with
ctx has 0 message(s)while the refs table stays intact (state has N ref(s) mapped). With an empty message list, the kernel judges every requested ref dangling and marks them DEAD indeadRefs— and becauseapplyRangescommits the kernel state clone even on total failure, those tombstones get persisted. Receipts blamecontent-changed("the messages behind those refs changed"), acp_status shows "N ref(s) can NEVER compress", and three such calls arm the loop breaker with a false cause. None of it is true: nothing changed — the proxy simply held no live message view at that moment (the in-memory copy is dropped between model requests by resident-pool eviction or restart), and the next model request restores the view and clears the tombstones anyway.Fix (host-side only; no kernel changes)
applyRanges(plus the external-summary lane): when the view is empty AND refs are mapped AND no requested range overlaps an active compression block → refuse up front with machine reasongate:no-visible-contextand an honest receipt: refs intact, nothing recorded as dead, do-not-retry-until-the-next-model-request. No deadRefs written; the breaker is fed the true cause.noteCompressLoopFailuregains aforcedCauseparameter so the breaker records the honest cause without re-running failure-cause inference (behavior-equivalent for all existing callers).[session] evicted <id> … weight … budget) — previously silent, which made the empty-view window invisible in triage.Behavior-change disclosure (required)
reason=gate:no-visible-context; zero deadRefs written; receipt states what actually happened and when retrying becomes possibleNo change to successful folds, refold (#398/#403), fresh-session diagnostics, breaker thresholds/timing, the config surface, the persistence format, or any wire shape. Already-polluted sessions need no migration: the kernel's tombstone-with-clear lifts DEAD refs automatically once their raw ids return in a resent view.
In-passing fix (already landed on master)
Found while verifying: two PRE-EXISTING failures on master —
tests/compress-success-tail.test.ts#1387 fixtures assume the old kernel defaultpreserveRecentMessages: 5; kernel commit ca93ef4 (#3058) moved it to 3 without updating them, leaving master's full suite red (masked by recently skipped test lanes). That fix landed on master independently (bd5e1ec66, #3061 fallout), so this PR's duplicate pin commit was dropped when rebasing onto current master. The new default stays pinned bytests/golden/wire-contract/kernel.json.Deferred (tracked separately)
input.messages.length === 0) — filed as a follow-up issue; defense-in-depth, since the host gate makes this path unreachable from bili today.Verification
npm run typecheckclean on the rebased head.tests/issue3126-no-visible-context.test.ts: gate fires / fresh-session passthrough / normal fold unaffected / breaker + repeat-guard honesty / block-overlap yield (refold intact) / external lane refuses before any network call.