Repository navigation
[PR] fix(preflight): re-land #4288 — stop burning the fold ladder on an already-fitting payload after a model switch - #4771
ranxianglei wants to merge 13 commits into
Conversation
…ment #4316 PR3/3 (restampRefsToLedger) re-homes citation numbers once on every full-mode cold load; goldens pinning exact ref numbers are born-red. Re-pin the 7 storage-lane tests (engine-proofs x6 + orphan-recovery x1) modulo that renumbering — zero production code touched. - golden-storage-drive.ts: per-turn citation-normalized digest (shaCiteNorm) and state digest modulo stripOneTimeAlignment (stateDigestAligned); the deep-sort helper is hoisted into golden-canonical.ts for sharing. - corrupt-index-child.ts: new stripOneTimeAlignment normalizer — strips the refLedgerAligned stamp and re-homes refs onto canonical raw-id order so a clean full-mode read and the legacy fallback load compare equal. - storage-engine-proofs.test.ts: wire legs assert shaCiteNorm equality vs the legacy restart leg and the committed goldens; state legs assert stateDigestAligned; rollback leg now spells BILI_STORAGE_UNIFIED=legacy explicitly (#3818 flip: absent resolves to full, deleting the env would vacate the legacy path). - storage-orphan-recovery.test.ts: pins the content-addressable byRaw->byRef round-trip instead of a counter-era m00003 literal. - golden/storage-render/*.json regenerated with shaCiteNorm/stateDigestAligned. Converges the master-red storage-lane family (#4599 plan A, owner directive).
…dger parity masks The #4316 one-time renumbering restamped messageRefs but left state.tokenSnapshot keyed by the OLD refs, so post-restart bodies carried stale per-message token counts (1.3K vs 1.4K) and the full-mode-restart wire drifted off the legacy baseline (#4599). persist.ts: two-pass remap (stage moves, delete old keys, then write new keys) so entries whose new ref collides with another move's old ref survive; fires only when superseded refs exist. Aligned normalizer (corrupt-index-child.ts): the cacheLedger's segment bookkeeping (be/bl/bs, unfinalized tail line), the derived agg block, and per-line miss-attribution (prov/seam) are restart experience, not content — no-restart and restart legs legitimately differ there. Masked in the aligned view only; raw digests keep full accounting. Goldens regenerated (stateDigest + aligned). storage-engine-proofs 12/12, golden-storage-render 5/5 locally.
…persisted state (#4599) The fork-survival test asserted immediately after the compress tool response, but the fold lands in the live session state asynchronously (#3573 replay semantics). Slow CI runners persisted the pre-fold state ('0 block(s) (compressions=0)' cold load) and the deepEqual diverged. Bounded 5s wait on the in-memory fold; fast machines exit on the first iteration. Product semantics unchanged.
The #4316 cold-load alignment reads the unified sidecar; its ingest of just-flushed records completes asynchronously. Slow runners compared the pre-ingest state and saw refLedgerAligned missing while the fold itself had landed. Poll (bounded 5s) until the loaded state carries the flag; fast machines exit on the first probe.
Git-for-Windows autocrlf checks the bundled .md posts out with CRLF; the exact-match '---' fences then failed to parse and every post lost its title/excerpt/date frontmatter (Windows CI: 'bundled meet-bili post found' assertion). Normalize CRLF to LF inside parseFrontmatter when the fence is CRLF-shaped; LF content is byte-identical as before. Regression test with a CRLF fixture.
… storage mode (#4599) The #4316 cold-load alignment sets refLedgerAligned only when the unified store is available; config-clean machines (CI runners) run legacy mode where it is an honest skip. The test asserted the flag unconditionally, so every shard carrying this file was born-red on CI while unified-config machines passed. Expectation now mirrors store.replicasAvailable(); verified 49/49 in BOTH modes locally.
…t < limit) Round-top stop judged on decisionTokens, which is floored by the session usage baseline; after a smaller-window model switch that baseline can sit above the new window, so the floored exit never trips and preflight burns the multi-round summarization ladder on an already-fitting payload until the client times out (the model-switch-stuck symptom). Judge on the payload's own floorless estimate instead. Use the fold target (textTarget = min(limit, compressionTarget) - imageReserve), NOT the hard window limit: callers legitimately fold window-fitting payloads toward a tighter target (compressionTarget plans, codex native-compaction headroom #68f6bfe3). The earlier naive form (621c35a) used 'limit' and broke exactly those, hence its revert f4c10bd. Floored implies floorless, so folding never increases versus pre-#4288 behavior. Updates affected fixtures (#301 e2e asserts zero summarization calls; summary-length-budget single-chunk case uses an explicit compressionTarget) and adds tests/issue4288-preflight-stale-baseline-fit-exit.test.ts (e2e fit + target-awareness band). Full preflight suite green (217/217). Supersedes revert f4c10bd. Closes #4288.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 本 PR 是 #4288 的干净重落地。相关条目已核对:
开始按 PR Review 规范审核:①原 issue(#4288)方向 → ②回归清点 → ③代码 → ④测试有效性 → ⑤diff 整洁度。分支 |
(ai: vllm-qwen/qwen3.8-27b) 审查完成(①方向 → ②既有行为清点 → ③代码 → ④测试有效性 → ⑤diff 整洁度)。判定:hold —— 方向对、主切片已修,但退出判据的写法混了通道,PR 里两条核心不变量声明在 imageReserve>0 时不成立;请在本 PR 内做一个小机械修正后再合。 一句话结论:round-top 退出从 八问
测试有效性(④):e2e 主测试有牙——拷到 master 上跑,红,报 "got 2 call(s)"(与本 PR 注释预测一致);band unit test 在 master 上也绿(B≥C 时两分支都折,不构成判别)。两个问题:
diff 整洁度(⑤):干净——单 commit、4 文件、每行都与目的相关,无无关改动。 验证记录:typecheck clean;PR 点名的 3 个测试文件本地 14/14 绿(全量留给 CI——审查时 22 个 check-run 均 queued);最小 preflightCompress 驱动做双分支 A/B(上面 cfg2/cfg3 即其输出)。 修复清单(小、机械、同一机制家族,建议本 PR 内做完):
确认写法 ①(或 ②)后我可以直接把修复 commit 推到这个分支。 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.5946-pr.4771.0bc96e2This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr4771.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…mspec wrap on win32 (#4599)
The ci-check lane's expectation change (c496cfb) exposed a real Windows bug: stripInheritedProxy builds inlineEnv as a spread copy of process.env, which keeps the original key casing (ComSpec) — Windows env vars are case-insensitive but plain objects are not. planClientSpawn's exact env.COMSPEC probe then missed it and silently degraded every wrapped spawn to the bare-name 'cmd.exe' fallback (verified by repro on a real win32 box: childEnv.COMSPEC=undefined while process.env.COMSPEC was set). Fix: probe COMSPEC/ComSpec/comspec in planClientSpawn and planDshSpawn. Verified on real Windows (Node 22): launcher-opencode-inline + fix-679 + dsh-refresh 37/37; host tsc clean, 35 pass / 2 win32-skips.
…OMSPEC case-probe c496cfb re-derived the win32 expectation from ambient process.env, which still mismatches production: Node's process.env member access is case-insensitive on Windows while the child env handed to the planner is a plain object whose key keeps the OS casing (ComSpec), so the exact env.COMSPEC probe fell through to the bare-name fallback. The assertion now derives from the child's OWN captured env/options and probes COMSPEC/ComSpec/comspec exactly like planClientSpawn does post-dfeea8a11 — self-contained under any concurrent-test env churn in single-process CI shards — and additionally pins windowsVerbatimArguments=true on the wrap.
… help-merge sweep)
🔶 需要决策 CI conflict lane (attempt 1/3), bot: ci-engineer-r1. I did NOT rebase/push: no conflict resolution on this PR can produce a mergeable branch, because the fix it carries is already on master in a strictly better form. Details and options below. What I verified live this run
Why the PR's own form is the inferior one (not just stale) Options
Default if undecided: treat as superseded — I will not push anything to the branch, and further auto-fix attempts on this PR should stop (they will hit the same wall); owner closes at convenience. 标签: needs-decision(PR 已被 master 上的演进版本完全取代,关不关由 owner 拍板) 八问(中文结构化结论)
收工判定:本轮不动分支(不 rebase、不 push),已打 needs-decision 标签;等 owner 在 A/B/C 中拍板,推荐 A(以 superseded 关闭)。 |
[ework] auto-fix stalled: test (windows-latest, 22, 1), test (ubuntu-latest, 22, 2), test (ubuntu-latest, 24, 1), test (windows-latest, 22, 5), test (ubuntu-latest, 22, 1), test (windows-latest, 22, 4), test (windows-latest, 22, 3), test (ubuntu-latest, 24, 3), test (windows-latest, 22, 2), test (ubuntu-latest, 22, 3), test (ubuntu-latest, 24, 2) — stopping for human review |
Closes #4288
Supersedes revert f4c10bd (the naive form was commits 621c35a / cherry-pick 041c32b).
What & why
After switching to a smaller-window model, preflight kept burning its multi-round
summarization ladder on a payload that already fit the new window, until the client
timed out — the "switch model → stuck" symptom in #4288. Root cause: the round-top stop
criterion judged on
decisionTokens, which is floored by the session usage baseline.That baseline was measured under the prior, wider-window model and can sit ABOVE the new
window, so the floored exit never tripped.
Fix
Judge the round-top exit on the payload's own floorless estimate
(
result.payloadEstimate < textTarget) — the same quantity the forward gate alreadytrusts (#1839/#1492). Floored implies floorless, so folding never increases versus
pre-#4288 behavior.
Why
textTargetand not the hard windowlimit(the reverted form): callers legitimatelyfold window-fitting payloads toward a TIGHTER target — compressionTarget plans (a66353a)
and codex native-compaction headroom (#68f6bfe3). Judging on the raw window would have
stopped those folds early; that is exactly why f4c10bd reverted the naive change.
textTarget = max(0, min(limit, compressionTarget ?? limit) - imageReserve).Behavior change (old → new)
Round-top stop criterion:
decisionTokens < textTarget(floored by a possibly-stalebaseline) →
result.payloadEstimate < textTarget(floorless, same target).Effect: a fitting payload under a stale high baseline now forwards immediately (zero
summarization calls); genuinely-overflowing and tighter-target folds are unchanged.
An info log fires only when the stale-baseline scenario actually occurs
(
baselineFloor >= textTarget).Tests
tests/issue4288-preflight-stale-baseline-fit-exit.test.ts: e2e (fitting payload +stale 300k usage baseline forwards with zero summarization calls) plus the
target-awareness band (a payload above the fold target but below the window still gets
its 429-retry attempt, then stays forwardable).
tests/preflight-fail-fast.test.ts(fix: honor anthropic-beta context-1m to size the context window #301 e2e): now asserts zero summarization calls(the previous
≥1expectation had encoded the old over-fold behavior).tests/preflight-summary-length-budget.test.ts: the single-chunk case now exertstarget-pressure via an explicit
compressionTarget(the old stale-floor trick no longertriggers a fold once the trigger is target-aware).
Scope note
Clean, minimal re-land of ONLY the #4288 fit-exit. Deliberately excludes the #4740
fragment-merge work (tracked separately) and is distinct from the mislabeled 50-file PR
#4725 (branch
2026-10-25_empty-pr), which carries the same one-line fix entangled with~49 unrelated files.
Config surface: none (no config/env/CLI changes).