Repository navigation
fix: preflight chunked retry — snap split boundaries past BLOCKED/unreferenced messages - #2726
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2962-pr.2726.63161faThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr2726.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #2726 审核中(agent 自产 PR,核对代码 + CI,不重做) 查重:无重复。相邻但不相同——#2723(多 range 合并成一次 external-summary 调用)、#2721(按 payoff 派发 fold)、#2660(structurally-dead span 不再每轮重提名)机制各不同;本 PR 独占「chunked retry 分裂边界落在 BLOCKED/无 ref 消息上」这一失效域。 代码审查(已完成):
CI:15 job 中 11 绿(lock-sync、kernel-guard、version-guard、config-surface-guard、pi-subagents-guard、lane-guard、docs-sync、docs-coverage、unused-exports、build-artifact、real-image billing e2e);4 个 test 矩阵 job(ubuntu/windows × node 22/24)仍在跑。 基线新鲜度:分支落后 master 152 commit,但 |
[bot] 🏷 审核结论:可合并(八问体例) 证据(本地在 rebase 到当前 master ① 是什么问题:preflight 摘要失败后的 chunked retry 按原始消息下标把失败 span 对半切;切点落在 protected 消息上时,两个半段都带着不可解析的边界,所有子块在 preview 被拒,整个 range 被放弃——尽管每个半段把 rim 挪过 protected 消息后本可正常摘要。生产表现:一次 timeout 毒化整个 range,烧光整轮 deadline(~180s)什么都没存下。 ② 什么原因导致的:两个事实叠加。(a) pop 时守卫只查 truthiness( ③ 影响范围与严重程度:proxy-mode preflight 自动折叠路径;触发条件=摘要失败触发 chunked retry 且切点落在 protected/无 ref 消息上。特定条件下有问题:整个可折叠 range 静默放弃 → payload 保持超窗 → 请求 502 而非恢复。非数据损坏类。 ④ 怎么修复的:snap 而非 drop/mint——新 ⑤ 是否有回归问题:无。触碰路径既有行为逐项清点:#726 oldest-half-first 工作表序保持(push 顺序未变);分裂前 floor gate 未变;#1001 ascending-pair 归一化未变(snap 之后照旧执行);#1372 preview 拒绝诊断未变;budget/deadline 逻辑未变。关键论证:snap 只在边界本身不可用时触发——这类 span 旧行为必败(整段丢弃或 kernel 拒绝),从未成功过;边界可解析时 snap 返回原区间,字节级无变化。原本成功的任何路径输出均不变。终止性:每次分裂严格变小且有 floor gate,无死循环。 ⑥ 是否破坏缓存:不涉及——未触碰任何缓存/重试/增量游标/去重键机制。 ⑦ 是否改了设计方向:不涉及——同一套 worklist halving 设计,只是使其边界安全。 ⑧ 是否引入了新的配置:不涉及——无新 env/config/默认值。 auto-merge gate(§7.4)核对:单模块 fix ✓ / 有牙回归测试 ✓ / rebased head 绿 ✓ / 无 config schema、persistence、wire、kernel 变更 ✓(kernel-guard 绿)/ 纯 fix: ✓ / diff 干净(2 文件 +341−12,每行相关)✓ / Fixes #2672 ✓ / 不碰 load-bearing infra ✓。分支落后 master 152 commit 但已验证 rebase 干净,合并前可选 rebase 或按现状合(GitHub mergeable=True)。合并动作留给人工。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.350-master.e99de4a # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #2672
What
Preflight's chunked retry after a summary failure split the failed span IN HALF ON RAW MESSAGE INDICES. Protected messages hold the truthy
BLOCKEDsentinel instate.messageRefs.byRaw, so when the blind midpoint landed on one, BOTH halves carried an unresolvable boundary, every sub-chunk was rejected at preview withInvalid boundary ref(s): startId="BLOCKED", and the whole range was abandoned — even though each half was summarizable once its rim snapped past the protected message(s). In the issue log one timeout thus poisoned the entire range and burned the full pass deadline (~180s passes saving nothing).Root cause
Two compounding facts:
if (!startRef || !endRef)) —"BLOCKED"is truthy, so protected boundaries sailed through into the kernel, which rejects them.mid = floor((cs+ce)/2)blind to the ref map — nothing ensured the resulting span boundaries were resolvable.The kernel already excludes protected messages from a block's effective ids (interior protected messages were always fine); only the BOUNDARIES must name resolvable messages.
Fix (
src/preflight.ts)snapToUsableBounds(idxToRef, lo, hi): walks inward to the nearest index whose ref is defined and !==BLOCKED_REF; null when nothing usable remains.pushSpanHalves(...): both halving sites now route through it — each half is snapped before being pushed; a half left with no usable message is dropped instead of pushing a doomed span (oldest-half-first worklist order preserved, [Bug] Codex 额度中断后恢复长会话,preflight SSE 摘要为空并持续 502 #726).Implements issue proposals 1+2 (split on non-protected boundaries; an invalid boundary can never reach the kernel) and proposal 3 (distinct logging for abandoned spans). Proposal 4 (a separate budget for the chunked retry) belongs to the external-summary batch domain (#2667/#2639) and is out of scope here.
Behavior change (disclosed)
Regression test
tests/issue2672-preflight-blocked-split.test.ts— deterministic 16-message geometry where the oversized first chunk's midpoint lands exactly on a protected pair (plus one protected message parked so the residual chunk stays sub-minimum regardless of recent-zone endpoint drift). Asserts 200 recovery via strictly-smaller snapped halves, no protected bytes in any summary body, forward happened, no dead-end marker.Verified both directions: PASSES with the fix; FAILS without it (502 with
Invalid boundary ref(s): startId="BLOCKED"— the exact production signature from the issue log).Targeted siblings green locally:
preflight-empty-summary(#726 halving owner),preflight-multi-range,issue1841-preflight-futility,preflight-fail-fast,preflight-round-budget(24/24). Full suite via CI.