Repository navigation
[PR] fix(#2638): stop preflight re-nominating structurally-dead spans every turn - #2660
Conversation
…y turn The kernel's range selector keeps advertising spans whose messages are all already covered by active blocks or locked as live checkpoint carriers; the apply side rejects them with the structural 'no new compressible messages' verdict. Preflight's skipSet was per-invocation only, so every request re-derived the same candidates, re-previewed the same dead span, and re-rejected it forever -- wasting per-request work, spamming logs, pinning the auto-fold target above its floor, and (during the 10-minute backoff) resurrecting classic nudges that pushed the model into compress calls which were atomically refused. Remember structural preview verdicts per session (session.metadata, persisted) keyed by startRef:endRef; while the recorded active-block snapshot is unchanged the span can never fold through plain refs, so it is filtered out of candidate lists (preflight walk + relaxed probe) and of the nudge-advertised ranges on all four protocol surfaces. Any block lifecycle change wakes the entries for one re-preview. Structural verdicts are also added to the invocation skipSet (no intra-invocation re-preview), and the auto-fold no-progress backoff only arms when foldable candidates actually existed -- a lean steady state now forwards without backoff instead of cycling backoff -> classic nudge -> refused compress.
…gression Unit suite covers verdict parsing (both wordings, multi-id, truncation, negatives), record/cap/evict, snapshot-subsumption invalidation, exact-key filtering, and metadata persistence round-trip. The integration test builds the minimal production geometry (checkpoint carriers adjacent in the pruned view but separated by covered raws in the full-log history) and asserts: invocation 1 previews+rejects+remembers the dead span exactly once while the foldable tail still folds; later invocations never re-nominate it; an all-dead candidate set reports hadFoldableCandidates=false.
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2876-pr.2660.c75d458This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2660.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…ate) CI's unused-exports gate (#1440 P6) flagged buildDeadSpanFixture as INTERNAL_ONLY — it is exported but every reference sits inside its own file. Drop the stray `export`; the fixture is consumed only by this file.
[bot] 🏷 PR #2660 reviewed — approve (human merge). Root cause verified against kernel source; one CI blocker found & fixed+pushed. Pulled Verified (evidence, not assertion):
Regression audit — existing behaviors touched, each conclusion:
One CI blocker — fixed & pushed. The Behavior change (flagged per Deliverables #4):
Both deliverables present: host-side defense = this PR; the kernel-side root (recommend not mirroring 结构化八问:
判定:可合(人工合并)。 触碰 |
Closes #2638
What & why
The kernel's range selector keeps advertising spans whose messages are all already covered by active blocks or locked as live checkpoint carriers (
summaryOfBlockId); the apply side rejects such spans with the structural "no new compressible messages" verdict (livelock guard). Preflight'sskipSetwas per-invocation only, so every request re-derived the same candidates from the same kernel recommendation, re-previewed the same dead span, and re-rejected it forever:outcome=refused) — the nudge churn in [Bug][preflight] range selector re-nominates a fully-folded span every turn — permanent "no new compressible messages" rejection loop + nudge churn #2638;Fix (host-side defense)
src/dead-ranges.ts: per-session memory of structural preview verdicts insession.metadata.preflightDeadRanges(persisted, restart-safe). An entry recordsstartRef:endRef, the block ids named by the verdict, and a snapshot of ALL active block ids at record time. While the snapshot is unchanged the span can never fold through plain refs; any block lifecycle change wakes the entries for exactly one re-preview. Cap 64, FIFO-evict.emergencyNudgestops firing on ranges that can never fold (压缩出现bug #2104-class loop).PreflightResult.hadFoldableCandidates); a lean steady state forwards without backoff instead of cycling backoff → classic nudge → refused compress.Behavior changes (old → new)
acp_statuspanel still shows the raw kernel list until the kernel-side fix lands.Config surface
None added. The memory lives in internal session state (
session.metadata, persisted like every other session field); no config field, env var, or CLI flag.Root cause stays upstream — kernel follow-up filed separately
The advertise/validate disagreement itself (kernel recommend lacks live-carrier screening while apply carves carriers out of plain-ref spans) is fixed properly in acp-kernel; a kernel issue with the minimal repro geometry (now in
tests/preflight-dead-ranges.test.ts) is filed separately with the source marker. This PR makes the host stop paying the cost regardless.Tests
tests/dead-ranges.test.ts: verdict parsing (both wordings, multi-id, truncation, negatives), record/cap/evict, snapshot-subsumption invalidation, exact-key filtering, metadata persistence round-trip.tests/preflight-dead-ranges.test.ts: builds the minimal production geometry (checkpoint carriers adjacent in the pruned view but separated by covered raws in the full-log history) through realpreflightCompress: invocation 1 previews+rejects+remembers the dead span exactly once while the foldable tail still folds; later invocations never re-nominate it; carrier text never reaches the summarizer; an all-dead candidate set reportshadFoldableCandidates=false.Verified on the rebased head: typecheck clean, targeted suites green (16/16), build OK. Full regression left to CI.