Repository navigation
[PR] fix: post-compress tail — subtract folded spans, backfill plugin offer, honest no-offer clause - #6815
[PR] fix: post-compress tail — subtract folded spans, backfill plugin offer, honest no-offer clause#6815ranxianglei wants to merge 1 commit into
Conversation
…r, honest no-offer clause The compress success receipt's "remaining ranges" logic had three defects in the post-compress tail (postCompressTail, src/stream.ts): A. The plugin lane never passed lastNudge to the tool ctx (LoopCtx had no such field), so postCompressTail fell back to a post-fold live recompute. After a successful fold the recompute returns shouldInject=false → base=[] → the receipt falsely claimed every offered range was folded. rememberPluginMessages already stores the prepare-time nudge in transient.pluginMessages; the wire and preflight lanes pass it, the plugin lane did not. LoopCtx now carries lastNudge and the plugin lane passes mem?.nudge. B. spansOverlap was a boolean intersection: ANY overlap between a submitted span and an offered range dropped the ENTIRE offered range, so folding the head of a range silently hid its tail. Replaced with span subtraction (subtractSpans + makeResidual): the folded span is cut out and the residual sub-ranges are advertised, re-gated by the viability floor + submit gate. Only message-ref submitted spans (refToIndex !== null) count as cuts, so block refs (bN) never conflate with message indices. C. The uncovered-history branch said "all offered ranges are folded" even when no offer existed (ctx.lastNudge undefined). That clause is now conditional: a no-offer lane says "no ranges were offered in this call". Tests: two cases added to tests/compress-success-tail.test.ts — (a) folding only the head of an offered range advertises the residual tail; (b) a no-offer (plugin-style) ctx never claims the offer was exhausted. Fixes #6809
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.10157-pr.6815.487f56dThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6815.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: opencode/qwen3.8-27b) Dedupe check: no duplicate. No other open issue or PR targets the post-compress tail remaining-ranges logic or #6809 — this is the only fix in flight for that thread (checked open [PR] rows; nearest neighbors #6812 / #6807 are different receipts/paths). Labels: Review in progress: pulled the branch ( |
(ai: opencode/qwen3.8-27b) Review complete — verdict: mergeable, pending CI green. I pulled the branch ( ① Direction (source issue): the PR implements #6809's proposed fix 1:1 — (1) ② Regression review (existing behavior walked):
④ Test validity: both new tests have teeth — I ran the PR's test file against base: 10/12 pass, and the two #6809 cases fail with exactly the bug symptoms (B: stop signal fires instead of advertising the residual tail; C: receipt literally says "all offered ranges are folded, but 16 msg(s) … ~20K tok" on a no-offer lane). Test (b)'s conditional assertion is not vacuous — the uncovered branch demonstrably fires in that construction (16 msgs ≈ 20K tok ≥ the 10K floor). ⑤/⑤b Diff & code cleanliness: 4 files, every line related to the fix; Local evidence: typecheck green, build green, One hygiene note (not a blocker): the head is 92 commits behind current master (tip 26d9bcc). I checked master-side churn on the three touched files — all in disjoint regions ( 八问(中文结论)
判定:可合(等 CI 绿;合并前建议先 rebase 到当前 master——机械操作,无重叠区域)。PR 标签 |
What
The compress success receipt's remaining-ranges logic had three defects in the post-compress tail (
postCompressTail,src/stream.ts), all in the post-fold path:A. Plugin lane never backfilled the prepare-time offer.
LoopCtxhad nolastNudgefield, so the plugin lane's tool call fell back to a post-fold live recompute inpostCompressTail. After a successful fold that recompute returnsshouldInject=false→base=[]→ the receipt falsely claimed every offered range was folded while ~42K tokens stayed compressible.rememberPluginMessagesalready stores the prepare-time nudge intransient.pluginMessages; the wire lane (src/server/relay.ts) and preflight lanes pass it, the plugin lane did not.LoopCtxnow carrieslastNudgeand the plugin lane passesmem?.nudge.B. Boolean overlap dropped the whole range.
spansOverlapwas a boolean intersection: any overlap between a submitted span and an offered range dropped the entire offered range, so folding the head of a range silently hid its tail. Replaced with span subtraction (subtractSpans+makeResidual): the folded span is cut out and the residual sub-ranges are advertised, re-gated by the viability floor + submit gate. Only message-ref submitted spans (refToIndex !== null) count as cuts, so block refs (bN) never conflate with message indices.C. False offer-exhaustion clause. The uncovered-history branch said "all offered ranges are folded" even when no offer existed (
ctx.lastNudge === undefined). That clause is now conditional: a no-offer lane says "no ranges were offered in this call".Behavior change (old → new)
"Uncovered history remains — all offered ranges are folded, but …"→"Uncovered history remains — no ranges were offered in this call, but …"(the old wording was a false statement when no offer existed).Folding itself is unchanged; only the receipt's remaining-ranges computation and wording are corrected.
Tests
Two cases added to
tests/compress-success-tail.test.ts:All 12 tests in the file pass. Typecheck + build green. (4 pre-existing
loop-compress.test.tsfailures are unrelated — identical on base.)Scope
Host-side only (
src/stream.ts,src/loop/core.ts,src/plugin.ts,tests/). Nokernel/change, no config schema change, no wire-protocol change.Fixes #6809