Repository navigation
[PR] kernel: re-inject T1 after a partial fold to kill the compression ratchet (#6720) - #6760
ranxianglei wants to merge 5 commits into
Conversation
…chet (#6720) A partial tier-1 fold (harvest < STALL_HARVEST_RATIO of the offered pending) arms a one-shot re-inject: the next processTurn re-offers T1 without waiting for the full growth floor, so the unharvested remainder drains instead of riding along and ratcheting the post-fold floor up monotonically (#6720). - kernel: NudgeState.partialFoldReinjectArmed (one-shot, armed on a partial fold, cleared on display or a compliant full fold); applyCompression reports the unharvested remainder (remainingPending) on a partial tier-1 fold; decideNudge gains the re-inject branch (not gated on usage — a low-usage 1M-window session never crosses minContextLimitPct, which is exactly the ratchet shape); the nudge-stamp node disarms on a displayed tier-1 nudge. - host: the compress receipt names the remainder instead of reading as a clean "done"; the nudge inject log line lists the offered ranges (capped at 4). kernel-change: #6720 partial-fold ratchet — the cadence gate (growthFloor) let each partial fold's remainder ride along for a full growth interval; the re-inject branch bypasses that wait for ONE re-offer after a partial fold, then the normal growth gate re-asserts (no loop on an unresponsive session).
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.11160-pr.6760.e11a0ddThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6760.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 查重: 不重复. Only PR #6760 targets #6720 (verified against the open [PR] list). Other open nudge/compress PRs (#6745 web chart, #6531 un-show rejected nudge, #5779 tier-merge screening, #6716/#6747/#6705 receipt/scan perf) are different mechanisms — no in-flight PR touches the cadence-gate / partial-fold follow-up. 标签: applied Review — read the full diff (8 files, +475/−11) at PR head Mechanism walkthrough:
Verification (targeted local runs on the PR head; full-suite verdict = CI):
Non-blocking observations:
结构化八问(审核结论):
Kernel boundary: PR body 声明 Verdict: code review passes — no regressions found, tests pin the mechanism in both directions, kernel boundary compliant. Awaiting CI green on the pushed head (12 checks pending at the time of this reply). Merge is human-only (kernel change). |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Post-review fix pushed to the PR branch (small-fix policy — CI-failure class, fixed in place rather than filed): The bump commit ( Fixed with an additive commit
Verified idempotent with the exact CI recipe ( CI re-runs on the new head; the review verdict above is unchanged. |
…eceipt conflict Single conflict: src/stream.ts success-receipt line, touched by both sides since the branch base (3858b69): - this branch (#6720): appends the partial-fold remainingPending note - master (#6855, fe5c5f3): builds the headline from the effective (kernel-clamped) range via effectiveCompressedDetail Resolution keeps BOTH intents: effectiveDetail for the headline, remainingNote appended after the saved-tokens clause. Kernel version: master independently bumped 0.0.197 -> 0.0.198 (399cd2b, #6709) for the same base this branch bumped for #6720 — git auto-resolved the identical change to 0.0.198. The merged tree now carries kernel changes from BOTH PRs, so the branch's diff vs master shows kernel/src edits (compress.ts, types.ts) with no version change — kernel-guard rule 2 would fail. Bumped to 0.0.199 and regenerated both lockfiles with the exact lock-sync recipe (npm install --package-lock-only --ignore-scripts; verified idempotent). Verified: host typecheck clean; kernel suite 1644 pass; targeted host tests issue6720-partial-fold-receipt + issue6855-compress-headline 7 pass.
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed — What I did this run
Live state (verified this run, not from memory): master tip is an ancestor of the branch head (deterministic local check), and a single read-only GitHub GET reports Behavior change flag (old → new): kernel version 结构化八问
收工判定:冲突已解并推送( |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Reviewed end-to-end: mechanism, tests, both compression modes, §7.3/§7.4. The fix is sound and well-tested. Findings below are non-blocking; this is a kernel/ change so it needs owner authorization before merge (see the follow-up 🔶 comment).
Mechanism — verified correct.
applyCompression(kernel/src/compress.ts:957-966): on a T1 fold that harvests< STALL_HARVEST_RATIO(0.5, compress.ts:194) of the offeredlastT1FirePending, armsnudge.partialFoldReinjectArmed = trueand setsremainingPending = max(0, firePending − tokensCompressed). A distill (any new block > tier 1) or a compliant full fold clears the flag (compress.ts:957).decideNudge(compress.ts:2487-2495): new one-shot re-inject branch fires wheninjectedTier === null && !pressure && partialFoldReinjectArmed && t1Eff >= 0.5 * tierThresholds[1]— deliberately NOT gated on the growth floor or usage, so the remainder is re-offered without a full 50K growth wait. One-shot: the flag is disarmed when the re-injected T1 nudge is displayed (nudge-stamp node, compress.ts:1619) or by a compliant full fold; an ignored re-offer keepslastNudgeShownTokensset so the normal growth gate re-asserts — no loop on an unresponsive session.remainingPendingmath is correct:tokensCompressedis the ORIGINAL token count of the folded content (compress.ts:1937-1949), sofirePending − tokensCompressedis the true unfolded remainder (0 on a full fold).- Host: the receipt names the remainder (src/stream.ts:1734-1735);
diagNudgelogs the offered ranges (src/server.ts:2821-2823).
Tests — valid, would catch regressions. Kernel issue6720-partial-fold-reinject.test.ts (4: partial arms + re-injects, not usage-gated, one-shot no loop, full fold never arms) all pass; nudge.test.ts 3 updated (49 pass). Host issue6720-partial-fold-receipt.test.ts (4: receipt names remainder, full fold omits note, log lists ranges, log omits when none) all pass. Typecheck clean (host + kernel). CI green on the rebased head.
Findings (non-blocking):
- §7.3 marker missing for the model-facing receipt. The new receipt text at src/stream.ts:1734-1735 ("N tokens of the offered ranges remain unfolded — include them in your next compress call.") is model-facing prompt surface. The PR body's "Behavior change" section describes it, but the mandatory
⚠️ MODEL-FACING TEXT CHANGEmarker at the top of the PR body + commit message, and the explicit consumption-chain inference, are absent. The number is the accurate unfolded remainder (not a phantom), so the consumption risk is low — but per §7.3 the marker + a sentence of consumption-chain inference should be added before merge. - Stale version prose. The PR body says "0.0.197 -> 0.0.198" and the lock-sync commit says "kernel 0.0.198 bump", but the actual bump is 0.0.198 → 0.0.199 (master moved). The version IS correctly bumped (CI version-discipline passes); only the prose is stale.
Modes (§6): re-inject + receipt are proxy-mode observable effects; the kernel changes (flag + remainingPending field) are additive/mode-agnostic and don't break plugin mode (the agent owns compression there, nudge suppressed). The issue is proxy-mode. ✓
Scoping: implements issue Props 1 (re-inject + receipt) + 5 (log line); Props 2/3/4/6 (escalation, per-stream metering, wording, client-side) are correctly deferred as separate mechanisms — not open debt.
Verdict: code is sound, tested, and CI-green. The only gate is owner authorization for the kernel/ change (HARD RULE — I do not approve kernel PRs). See the follow-up 🔶 需要决策 comment.
|
🔶 需要决策 This PR touches Gated diff (PR #6760):
The host-side changes (src/stream.ts receipt, src/server.ts diagNudge log) are additive and mode-safe; the kernel changes are the gated surface. The findings-only review above verifies the mechanism is correct and well-tested; the two non-blocking findings are a §7.3 marker gap and stale version prose. Requesting owner authorization to proceed with the human-only kernel review tier. |
(ai: vllm-qwen/qwen3.8-27b) Review complete — findings-only review posted above + 🔶 需要决策 + needs-decision label. Mechanism verified correct + tested; CI green; two non-blocking findings (both in PR body/commit, not code). This is a 8问(结构化审核结论)
判定:代码正确、测试有效、CI 绿;唯一门槛是 kernel 变更需 owner 授权(HARD RULE——不批准 kernel PR)。等 owner 走人工 kernel 审核档。 |
…eceipt conflict (2nd pass) Master advanced 178 commits since the 2026-11-16 merge (2d84c7d). Single conflict again: src/stream.ts success-receipt line. - this branch (#6720): remainingNote appended inside the brackets - master (497efc7, 2026-11-18 owner change): 'folded at <timestamp>' stamp appended after the closing bracket (receipt temporal footing) Resolution keeps BOTH: remainingNote inside the brackets, folded-at stamp after them. formatTagTime already imported from acp-kernel. Kernel version: master independently bumped 0.0.198 -> 0.0.199 (497efc7) from the same base this branch bumped for #6720 — auto-merge landed on 0.0.199. The merged tree carries kernel changes from BOTH sides, so the branch's diff vs master shows kernel/src edits (compress.ts, types.ts) with no version change — kernel-guard rule 2 would fail. Bumped to 0.0.200; both lockfiles regenerated with the exact lock-sync recipe (npm install --package-lock-only --ignore-scripts), verified idempotent. Verified: host typecheck clean; kernel suite 1644 pass; host targeted tests issue6720-partial-fold-receipt + issue6855-compress-headline 7 pass; master-side receipt regressions (compress-fingerprint-refold, issue5173-last-user-anchor, issue4313-fingerprint, text-safe) 49 pass.
(ai: vllm-qwen/qwen3.8-27b) Conflict resolved and pushed — What I did this run
Live state (verified this run, not from memory): master tip is an ancestor of the branch head (deterministic local check), and a single read-only GitHub GET reports Behavior change flag (old → new): kernel version 结构化八问
收工判定:冲突已解并推送( |
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) CI-engineer run complete — conflict resolved, pushed. Full 八问 summary is in the comment above (floor 16); short confirmation here:
Nothing further pending from this lane; if CI turns red on the new head, the same bot will pick it up. |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
Re-review of the new head (62d9eea). The PR contribution is byte-identical to the previous head (2d84c7d) — the only change is the merge of the newer master (a446a3c), which pulled in PR #7105 (compress-receipt rework) and moved the kernel version to 0.0.199.
Conflict resolution verified. The compress-receipt conflict (src/stream.ts:1746-1750) is resolved correctly: the #6760 remainingNote (from r.remainingPending) is appended to the receipt alongside the #7105 changes (effectiveDetail, the "folded at" timestamp) — they coexist without clobbering each other. The mechanism, tests, and mode analysis from the previous review all still hold.
Kernel version now 0.0.199 → 0.0.200 (master moved). CI green (0 failed on the new head).
Findings (unchanged from the previous review, still open — both in the PR body, not the code):
- §7.3 marker missing for the model-facing receipt text (src/stream.ts:1748-1749). The PR body's "Behavior change" section describes it, but the mandatory
⚠️ MODEL-FACING TEXT CHANGEmarker at the top + the explicit consumption-chain inference are absent. - Stale version prose. The PR body says "0.0.197 -> 0.0.198" but the actual bump is now 0.0.199 → 0.0.200.
Verdict: code is sound, tested, and CI-green (unchanged from the previous review). The only gate is owner authorization for the kernel/ change (HARD RULE — I do not approve kernel PRs). See the 🔶 需要决策 comment.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review done (head moved 2d84c7d → 62d9eea). The author merged a newer master (a446a3c, incl. PR #7105 compress-receipt rework); the PR's own contribution is byte-identical to the prior head (same 10 files, +478/-14) — no new code. Re-verified on the new head:
Re-review posted (COMMENT, findings-only — kernel PRs can't be approved). 🔶 需要决策 + needs-decision label already in place. Two findings still open (both PR-body-only, not spot-fixable): (1) §7.3 8问(结构化审核结论)
判定:代码正确、测试有效、CI 绿;唯一门槛是 kernel 变更需 owner 授权(HARD RULE——不批准 kernel PR)。等 owner 走人工 kernel 审核档。 |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
…sion conflict master advanced kernel 0.0.199 -> 0.0.201 (batch-seam double-claim fix + #7252 collision bump) while the PR carried its own 0.0.200. The merged tree has the PR's partial-fold re-inject kernel change ON TOP of master's 0.0.201, so the version resolves to 0.0.202 in kernel/package.json, kernel/package-lock.json, and the root package-lock.json. Source files (compress.ts, stream.ts, server.ts, types.ts) auto-merged cleanly; targeted kernel tests (issue6720 + nudge, 49) pass on the merged tree.
(ai: vllm-qwen/qwen3.8-27b) Merge conflict resolved and pushed — PR #6760 is no longer What I did this run:
Notes:
八问
判定:冲突已解决并推送,PR 现可合并(mergeable: true),等待新 sha( |
[ework] CI fix verified green ✓ |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b) Re-review (head moved 62d9eea → 80ca785).
What changed: the only new commit is a master merge (80ca785ce merges ba2e8198203), which pulled in a large batch of unrelated master work (batch-seam double-claim fix, dsh-mneme scan, storage-integrity, web fixes, etc.). The PR's own contribution is byte-identical to the prior head — I diffed the PR's contribution on top of master (ba2e8198203..80ca785ce): the partial-fold re-inject kernel change (compress.ts arm/clear/re-inject + remainingPending), the host receipt (stream.ts), and the diagNudge ranges (server.ts) are all unchanged. The merge resolved the kernel version conflict correctly: master had advanced to 0.0.201, so the PR's change now lands on top as 0.0.202 (kernel/package.json + kernel/package-lock.json both 0.0.202, consistent). CI green: 30/30, 0 failed.
Re-verified on the new head:
- Kernel mechanism intact:
partialFoldReinjectArmedarms on a partial T1 fold (compress.ts:974), clears on a compliant full fold (compress.ts:967) and on a displayed T1 nudge (compress.ts:1609); thedecideNudgere-inject branch (compress.ts:2491) fires wheninjectedTier===null && !pressure && partialFoldReinjectArmed===true && t1Eff >= 0.5*tierThresholds[1]— not usage-gated, one-shot, no loop.remainingPending = Math.max(0, firePending - tokensCompressed)(compress.ts:976) is the correct unfolded remainder (0 on a full fold). - Host receipt (stream.ts:1790-1794) + diagNudge ranges (server.ts:2838, 2852-2854) intact.
- Master's batch-seam double-claim fix to compress.ts is in a separate region and does not touch the partial-fold logic.
- Targeted kernel tests (issue6720 + nudge) present and passing on the merged tree (per the merge commit; CI green confirms).
Findings (both non-blocking, PR-body-only, NOT spot-fixable — the only permitted PR-body edit is the kernel-change: line, which is already present):
- §7.3
⚠️ MODEL-FACING TEXT CHANGEmarker still missing at the top of the PR body + commit message for the receipt text ("N tokens of the offered ranges remain unfold…"). The body has a "Behavior change" section but no marker and no explicit consumption-chain inference (what the model does with the number, where it anchors, adversarial pass). This is a model-facing string the model reads and may copy into its nextcompresscall. - Stale version prose: body says "Kernel version bumped 0.0.197 -> 0.0.198"; the actual bump on the current master is 0.0.201 → 0.0.202.
Verdict: findings-only (COMMENT) — this PR touches kernel/ and carries a kernel-change: declaration, so per the authorization boundary it cannot be approved by the review lane; the merge waits on the human-only kernel review tier. The 🔶 需要决策 comment + needs-decision label are already in place. Code is correct, tests valid, CI green; the only gate is owner authorization for the kernel change.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) Re-review #3 done (head moved 62d9eea → 80ca785). The only new commit is a master merge ( Re-review posted (COMMENT, findings-only — kernel PRs can't be approved). 🔶 需要决策 + needs-decision label already in place. Two findings still open (both PR-body-only, not spot-fixable): (1) §7.3 8问(结构化审核结论)
判定:代码正确、测试有效、CI 绿;唯一门槛是 kernel 变更需 owner 授权(HARD RULE——不批准 kernel PR)。等 owner 走人工 kernel 审核档。 |
Fixes #6720
What this is
The post-fold floor ratchets up monotonically in long low-usage sessions (1M window, usage <= 24%): each tier-1 fold is PARTIAL (the weak model folds only part of the offered list, leaving 15-60K on the table), and the cadence gate (
growthFloor, a full 50K growth wait) makes the next nudge come only after the remainder has already ridden along and grown another 10-20K. So the floor rises 114K -> 119K -> 132K -> 139K -> 212K and never recovers.Root cause
The cadence gate (
tokenCount - lastShownByTier < growthFloor-> "blocked: T1 (cadence)") has no partial-fold follow-up path. A partial fold's remainder waits a FULL growth interval before the next nudge, and by then the tail has grown. The gentle nudge wording ("Ranges the task still needs can wait") plus the done-shaped receipt (no mention of the unharvested remainder) let weak models treat a partial fold as complete.Fix
One-shot partial-fold re-inject (kernel). A partial tier-1 fold (harvest <
STALL_HARVEST_RATIOof the offered pending, i.e. < 50%) armsNudgeState.partialFoldReinjectArmed. The nextprocessTurnre-offers T1 without waiting for the full growth floor — but only while the armed flag is set ANDt1Eff >= 50%of the T1 threshold (so a tiny remainder doesn't spam). The branch is not gated on usage: a low-usage 1M-window session never crossesminContextLimitPct(45%), so the first-sight/backlog bypasses never fire and the remainder would otherwise stall for a full growth interval every round. The flag is cleared when the re-injected nudge is displayed (nudge-stamp node) or by a compliant full fold; an ignored re-offer keepslastNudgeShownTokensset so the normal growth gate re-asserts — at most one re-inject per partial fold, no loop on an unresponsive session.Receipt names the remainder (host).
applyCompressionnow reportsremainingPending(offered pending minus what folded, floored at 0) on a partial tier-1 fold; the compress receipt appends "N tokens of the offered ranges remain unfolded — include them in your next compress call" instead of reading as a clean "done".Nudge log line lists the offered ranges (host). The
nudge INJECTlog line now includesranges=[mXXXXX–mYYYYY(tokens), ...](capped at 4 + "+N more") so "the model saw this list and didn't fold it all" is verifiable from the log (previously onlypendingT1was logged).Behavior change (old -> new)
growthFloorgrowth interval). This is the fix — the remainder drains on the next request instead of ratcheting the floor up. A compliant (full) fold is unaffected: it never arms the re-inject, and the normal cadence still applies.pendingT1). Additive, no behavior change.Verification
issue6720-partial-fold-reinject.test.ts(4 tests: partial fold arms + re-injects at low usage; not gated on usage; one-shot no loop; full fold never arms). 3nudge.test.tstests updated for the new re-inject behavior (they did a partial fold then a low-usage request, where the re-inject now fires — the intended change).issue6720-partial-fold-receipt.test.ts(4 tests: receipt names the remainder; full fold no note; log line lists ranges; log line omits when none).kernel-change
kernel-change: #6720 partial-fold ratchet — the cadence gate (growthFloor) let each partial fold's remainder ride along for a full growth interval; the re-inject branch bypasses that wait for ONE re-offer after a partial fold, then the normal growth gate re-asserts. New NudgeState field (partialFoldReinjectArmed) + ApplyCompressionResult field (remainingPending); no wire-format or id-logic change.Kernel version bumped 0.0.197 -> 0.0.198.
Props 2/3/4/6 from the issue (escalate after N partial folds, per-stream metering, "already at minimum" wording, client-side 2-streams/51K-system) are separate mechanisms and deferred to their own issues.