Skip to content

[PR] fix: guard the #5974 probe baseline write against overflow-arm demotion (#6865) - #6867

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-11-16_probe-arm-guard
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-11-16_probe-arm-guard

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

The #5974 corrective-pass probe (preflightCompressIfNeeded, src/server.ts) measured the fresh rebuild and wrote a local estimate onto the session baseline without an overflow-arm guard:

if (probeTextSize > session.stats.lastInputTokens) {
    session.stats.lastInputTokens = probeTextSize;
    session.stats.lastInputTokensSource = "estimate";   // no overflow-arm guard
}

In the caliber-delta case (post-fold local probe slightly above the armed wall, but the payload actually fits) the probe demotes the ACTIVE overflow-arm evidence tag to estimate before the post-rebuild anchor write runs. That silently drops the evidence floor that keeps an armed session folding instead of trusting optimistic local estimates (which undercount ~19-20% on code-heavy content). The next turn then fit-forwards on a stale estimate until the upstream 400 CONTEXT_WINDOW_EXCEEDED re-arms it — the exact fold → forward → 400 livelock #5880 fixed, re-opened on the probe path.

Fix

Extract the probe's baseline write into applyProbeBaselineAnchor (src/session.ts) with the same overflow-arm guard as armFailureShrink (src/server/relay.ts #2484):

export function applyProbeBaselineAnchor(session: Session, probeTextSize: number): void {
    if (session.stats.lastInputTokensSource === "overflow-arm") return;
    if (probeTextSize > session.stats.lastInputTokens) {
        session.stats.lastInputTokens = probeTextSize;
        session.stats.lastInputTokensSource = "estimate";
    }
}

The probe call site now invokes the guarded function. Unarmed and usage-grade behavior is unchanged (#1987 anchor, #604 usage→estimate).

Relationship to PR #5899

This is master's code (from the #5974 fix, now closed), a separate concern from PR #5899. PR #5899 guards the post-rebuild anchor path (applyPostRebuildBaselineAnchor); this PR guards the probe path (applyProbeBaselineAnchor). Both close the same #5880-class gap (an unguarded estimate write demoting an active overflow-arm) on different code paths. This PR is independent and can land on its own.

Behavior change (flagged)

Old: the #5974 probe could demote an active overflow-arm tag to estimate in the caliber-delta case, disarming the evidence floor and re-opening the #5880 livelock.
New: the probe never demotes an active overflow-arm tag — an armed session keeps folding on the upstream-proven value.
Why: the overflow-arm tag is the evidence floor; demoting it is what produces the livelock. Same doctrine as the #5880 fix and armFailureShrink.

Tests

tests/issue6865-probe-arm-guard.test.ts (new) pins both directions (#3617 gate discipline):

Verified the test has teeth: with the guard stripped, the armed case fails.

Verification

  • npm run typecheck clean (0 errors).
  • tests/issue6865-probe-arm-guard.test.ts 4/4 pass.
  • tests/issue5974-preflight-view-divergence.test.ts 5/5 pass (probe path unregressed).

Fixes #6865

…on (#6865)

The #5974 corrective-pass probe (preflightCompressIfNeeded) measured the fresh
rebuild and wrote a local estimate onto the session baseline without an
overflow-arm guard. In the caliber-delta case (post-fold local probe slightly
above the armed wall, but the payload actually fits) the probe demoted the
ACTIVE overflow-arm evidence tag to "estimate" before the post-rebuild anchor
write ran — silently dropping the evidence floor that keeps an armed session
folding instead of trusting optimistic estimates. The next turn then
fit-forwarded on a stale estimate until the upstream 400 re-armed it: the exact
fold → forward → 400 livelock #5880 fixed, re-opened on the probe path.

Extract the probe's baseline write into applyProbeBaselineAnchor (session.ts)
with the same overflow-arm guard as armFailureShrink (relay.ts #2484). Unarmed
and usage-grade behavior is unchanged (#1987 anchor, #604 usage→estimate).
Regression test pins both directions (armed survives, unarmed anchors).

Fixes #6865
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-16_probe-arm-guard (cb03a71)

Latest build — install this exact version

npm install -g billion-context@0.0.10255-pr.6867.4c3c1bb

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
cb03a71 billion-context@0.0.10255-pr.6867.4c3c1bb build
e92da12 billion-context@0.0.10251-pr.6867.6c6e44c build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6867.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei added bug Something isn't working p1 regression labels Nov 15, 2026
@ranxianglei ranxianglei changed the title fix: guard the #5974 probe baseline write against overflow-arm demotion (#6865) [PR] fix: guard the #5974 probe baseline write against overflow-arm demotion (#6865) Nov 15, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重: 不重复 — 本 PR 与 PR #5899 同属 #5880 机制族(无守卫的本地 estimate 写入可把活跃的 overflow-arm 降级),但守卫的是两个不同写入点:本 PR = #5974 probe 写入(src/server.ts:4298),#5899 = post-rebuild anchor 写入(src/server.ts:4375)。同一 fold 轮两个点都会执行(probe 先跑),各需各的守卫,互补而非并列重复修。

Live state verified: PR head e92da12 基于当前 master(f648217);最新 CI run(2026-11-15 19:12–19:22)全绿 — test 分片(ubuntu/windows × node 22/24)、全部 guard lane、build-artifact;e2e lane 按三层 CI 设计 skip(需 ci:full 标签/dispatch/30-min cron,普通 PR push 不触发)。PR 已带标签(bug/p1/regression/root-cause),Fixes #6865 指向正确(已核 GitHub #6865 标题匹配)。

Code review(独立审 diff,非复读 issue):

  1. Probe 点确认: master 上 src/server.ts:4298-4301 的无守卫写入与 issue 描述一致;新函数 applyProbeBaselineAnchor(src/session.ts:1204)的守卫与 armFailureShrink(src/server/relay.ts:176, 超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484)逐字同构。
  2. 写入点清点: 枚举了 src/ 全部 lastInputTokensSource 写入点 — usage settle(cache-ledger.ts:1898,升级,无碍)、armFailureShrink(已守卫)、两处 overflow-arm 武装(relay.ts:1730/1809,武装本身)、两处 estimate 写入 = probe(本 PR)+ post-rebuild anchor([PR] Fix 400 CONTEXT_WINDOW_EXCEEDED on anthropic-wire sessions bili believes fit #5899)。两个 PR 合起来覆盖全部无守卫 estimate 写入,各自独立成立。
  3. 顺序主张核实: probe 写入(4298)确实在 post-rebuild anchor 写入(4375)之前、同一请求内执行 — caliber-delta 形态下 probe 就是降级者,其后 post-rebuild 写入看到的是更小的最终 rebuild,不会补回。issue 框架准确。
  4. 消费端核实: statusInputBaseline(src/session.ts:956-963)只在标签为 overflow-arm 时返回 arm 值;降级为 estimate 后回落到 lastUsageGradeTokens ?? 0(fold 前的 usage 样本)—— 这正是证据地板塌陷,nudge/growth meter(stream.ts:646/697、plugin.ts:2086/2127)据此 fit-forward 直到下一次 400 重新武装。机制成立。
  5. 守卫无副作用: armed 会话跳过写入只是把 baseline 更新推迟到下一次 usage-grade settle(settleUsageReport),与 超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484 同一教义;无 fail-fast→吞错、无阈值/时序/输出格式漂移。
  6. 行为变更已正确披露(PR 正文 "Behavior change (flagged)" 段,旧→新+原因齐备)。
  7. 测试: 本地 4/4 通过;独立验证了牙齿 — 剥掉守卫行后 armed case 失败(3/4 过、armed 挂),[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 回归套件 5/5 通过;Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 双向钉死(armed=守卫触发;unarmed 升/降 + usage + fresh=守卫不触发)。typecheck 0 错误(本地 npm ci 曾跳过 @deepseek-ai/cordis devDependency,环境怪癖,与 PR 无关,补装后干净)。
  8. 合并顺序备注: [PR] Fix 400 CONTEXT_WINDOW_EXCEEDED on anthropic-wire sessions bili believes fit #5899 与本 PR 都在 src/session.ts 同一位置(setPostRebuildAnchor 后)插入姊妹函数、都扩展 src/server.ts:58 同一 import 行 — 后合入者需一次平凡 rebase(两处单行冲突),非阻塞。

结构化八问(供 reviewer):

  1. 是什么问题: [Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 纠正轮 probe 把本地 estimate 无守卫地写进会话 baseline,把上游实证武装的 overflow-arm 降级为 estimate 级,在 probe 路径上重开 Estimate-only fit decision ignores system prompt + tool definitions, and the output-budget clamp never fires → 400 CONTEXT_WINDOW_EXCEEDED on sessions that bili thinks fit #5880 的 fold→forward→400 活锁。
  2. 什么原因导致的: [Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 修复引入 probe 写入时未带上 Estimate-only fit decision ignores system prompt + tool definitions, and the output-budget clamp never fires → 400 CONTEXT_WINDOW_EXCEEDED on sessions that bili thinks fit #5880/超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484 的证据地板教义 —— 一处可降级 overflow-arm 标签的无守卫 estimate 写入。
  3. 影响范围与严重程度: 受影响的 armed 会话(上游 400 CONTEXT_WINDOW_EXCEEDED 武装过)在 fold 轮上,当 post-fold 本地 probe 略高于武装墙(caliber-delta;代码密集内容本地 estimate 低估 ~19-20%)时触发 —— 会话被解除武装、fit-forward 直到下一次 400 重新武装,活锁;p1 级(核心承诺「不发出上游必拒的 payload」在该路径上失效)。
  4. 怎么修复的: 把 probe 写入抽成 applyProbeBaselineAnchor(src/session.ts),带与 armFailureShrink 相同的 overflow-arm 早退守卫;probe 调用点改调守卫函数。unarmed 与 usage 级行为逐字节不变。
  5. 是否有回归问题: 审过全部 lastInputTokensSource 写入点与 probe 路径既有行为 — 唯一语义变更是被守卫的降级(已披露);[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 回归套件 5/5、新 4-case 双向钉死均过;无 fail-fast→吞错、无阈值/时序/输出漂移。
  6. 是否破坏缓存: 不涉及 — 未触碰任何缓存/重试/游标/去重键逻辑,仅会话 baseline meter。
  7. 是否改了设计方向: 不涉及 — 把既有 Estimate-only fit decision ignores system prompt + tool definitions, and the output-budget clamp never fires → 400 CONTEXT_WINDOW_EXCEEDED on sessions that bili thinks fit #5880/超窗拒答以 5xx 返回时出现探测死循环;外部摘要链路三处静默/上限问题(含文件:行号与本地验证) #2484 证据地板教义应用到又一处写入点;与 PR [PR] Fix 400 CONTEXT_WINDOW_EXCEEDED on anthropic-wire sessions bili believes fit #5899(post-rebuild anchor 路径)互补,两者合起来闭合全部无守卫 estimate 写入。
  8. 是否引入了新的配置: 不涉及。

判定: 可合 — 单模块纯 fix、双向回归测试、rebased head 上 CI 全绿、行为变更披露完整。合并顺序注意:#5899 与本 PR 谁后合谁做一次平凡 rebase。

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decision request: #5974 preflight probe demotes the overflow-arm (unguarded estimate write, re-opens the #5880 400-livelock)

1 participant