Skip to content

[PR] preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel - #7549

Merged
ranxianglei merged 10 commits into
masterfrom
fix/preflight-emergency-digest-default-off
Nov 23, 2026
Merged

ranxianglei merged 10 commits into
masterfrom
fix/preflight-emergency-digest-default-off

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Why

Two behaviors for "session is far bigger than the model window" (the #2383/#7271 family), per owner decision 2026-11-22:

  1. Extreme overflows (>19.2x the window) were silently hard-truncated. Preflight replaced the history with deterministic digest blocks — from the model's point of view the conversation became the digest. That regime (added 2026-10-08 to stop an unconvergent summarization ladder, DSH 分叉会话后触发大量 preflight overflow compress #2383) destroys context as a last resort. The owner's call: failing the request is better than destroying the conversation.
  2. A brand-new session pays for its first resend the slow way. Nothing is folded yet, so the whole raw history goes out; when it is large, the serial fold ladder pays one 15-40s summarization call per round — hours for a multi-MB first resend, while the client usually gives up first (Egress window fuse and preflight compression undermine each other: out-of-window sessions deadlock on self-generated 413 | egress window fuse 与 preflight 压缩互相拆台:超窗会话被自产 413 卡死 #7271: 3h then EMPTY_RESPONSE; DSH 分叉会话后触发大量 preflight overflow compress #2383: client dropped at ~300s into ~45 calls).

What changed

Commit 1 — the digest regime is OFF by default, with a structural fast-fail in its place. BILI_PREFLIGHT_EMERGENCY_DIGEST=1 or network.emergencyDigest: true restores the old behavior. With it off, a payload beyond the fold path's coverage bound (19.2x the window — the ladder's own 32-call × 0.6-window coverage product, above which no combination of successful folds is guaranteed to land under the window) fails immediately with a deterministic structural-exhaustion verdict: zero summarization calls, zero wall clock. Burning up to 32 large-context summary calls for minutes of wall clock that no client outlives is exactly #2383's 300s-disconnect loop. The verdict is deterministic because a retry changes nothing, so the caller's existing contract handling applies: a trusted session keeps the identity fast path (upstream usage reality outranks local doom math — the fix-identity e2es pass unchanged), a session with a proven upstream wall (usage evidence on this origin+model) keeps the non-retryable 413 — now the only local size refusal left after #7537, which dropped every estimate-based refusal — and a session with no wall forwards, letting the upstream's own size verdict be authoritative (#7537, owner ruling 2026-11-22). For an established session a payload this size is additionally the lost-compression-blocks symptom — diagnosing, not token-burning, is the owner's rule for that case.

Merged master 9236576 (which brought in #7548 / #7537 "no local estimate-based refusals"). The only conflict was the re-pinned issue4079 arm (kept #7537's forward-plus-upstream-verdict pin, shaped to tolerate this PR's small pre-forward summary calls); the default-off e2e was re-pinned from local-413 to #7537's forward semantics. The fast-fail's own value is unchanged — zero ladder calls, zero wall clock — only what the verdict leads to follows the #7537 ruling.

Commit 2 — fresh sessions fold in parallel. Only for sessions that have never been forwarded AND never landed a fold (no usage sample and zero compression blocks — nothing could have been "lost", folding is pure gain; the zero-block clause is what excludes the two look-alikes: credit-floored existing sessions whose usage stat settles to 0, and adopted anonymous forks that inherit blocks but not stats). Below the 6M-char bound (~1M real tokens x 4 chars/token x 1.5 headroom): preflight now nominates two disjoint ranges per round instead of one. The in-model summarization calls run concurrently (Promise.all over the pure call part); the commits stay sequential (kernel state mutates single-threaded — same shape as the #2678 external batch lane). A range the parallel pass cannot summarize is deliberately left out of the skip-set: the next round re-nominates it (a hard 400/413 also remembers the span's two halves, mirroring the serial walk's #1993 halving recovery), and a round where the parallel pass commits nothing falls through to the serial walk unchanged.

Beyond the coverage bound (19.2x) the structural fast-fail applies to fresh sessions too — the parallel lane spends the same 32-call budget concurrently, so it does not raise the bound; it only makes the convergent band below it faster. Fresh resends above 6M chars (≈1M real tokens) also get the fast-fail: the owner's gate says folding that much is not worth the token spend.

Existing sessions (any session with a usage sample or any compression block), the external batch lane, the serial walk, and all failure shapes are untouched.

What is explicitly NOT in this PR

Tests

tests/preflight-emergency-fold.test.ts (9/9 on rebased master, tsc --noEmit clean):

CI regression notes (all fixed in this PR):

…le hard truncation)

The >=19.2x-coverage regime converts every fold into a CPU-only
deterministic digest (no LLM calls) because the LLM ladder provably
cannot converge within its raised budget. From the model's point of
view that is a hard truncation: the conversation history is replaced
by size-labelled head-fragment digests, and a session that enters this
regime keeps serving digests of its own digest history (#4224/#4047
show it is a recurring, sticky outcome for oversized fresh sessions).

Owner decision 2026-11-22: do not ship this behavior by default — a
session should fail fast with an actionable structured 413 (client
decides: drop oldest tool results / start fresh) instead of silently
degrading into digest soup. The regime is preserved verbatim behind an
opt-in:

- env BILI_PREFLIGHT_EMERGENCY_DIGEST=1 (wins) or
- file config network.emergencyDigest: true

When disabled at the overshoot, the LLM fold ladder runs as before and,
if it exhausts its raised budget, the request fails fast — no digest
blocks are ever created. The warn log distinguishes the two paths so
production #2383-class cases stay diagnosable from the log alone.

Tests: the e2e regime test now sets the env explicitly (it tests the
opt-in behavior), plus a new default-off e2e proving an unconvergent
extreme-overflow fresh session gets fail-fast 413/502 with NO digest
blocks and NO forward. The fresh-session size math is documented in
the test: below the byte floor a fresh session cannot reach the
regime's char-based trigger, so the 2.56MB test payload is answered
by the deterministic byte-floor fail-fast under default-off — same
user-visible contract (no digests, no forward), env=1 flips it to
digest convergence.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/preflight-emergency-digest-default-off (4ae7e33)

Latest build — install this exact version

npm install -g billion-context@0.0.11532-pr.7549.74ae7e9

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
4ae7e33 billion-context@0.0.11532-pr.7549.74ae7e9 build
4c43d6f billion-context@0.0.11526-pr.7549.4a3b3ac build
d3eb7ff billion-context@0.0.11524-pr.7549.c2192ae build
990bd41 billion-context@0.0.11494-pr.7549.ff73a6c build
4e00cb7 billion-context@0.0.11483-pr.7549.2e4d6a6 build
917845b billion-context@0.0.11460-pr.7549.b650d67 build
a73c63c billion-context@0.0.11456-pr.7549.d66ec4b build
bed827b billion-context@0.0.11455-pr.7549.5589266 build
9f2d74e billion-context@0.0.11449-pr.7549.698b8f0 build
49781ce billion-context@0.0.11448-pr.7549.5b0a870 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel [PR] preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel Nov 22, 2026
…summaries (owner decision 2026-11-22, #2383 follow-up)

A session that has never been forwarded (no usage sample ever landed —
lastInputTokens <= 0) resends its whole raw history verbatim, so no
compression blocks can have been lost and folding is pure gain. For those
fresh sessions below the 6M-char bound (~1M real tokens x 4 chars/token x
1.5 headroom), preflight now nominates K=2 disjoint ranges per round, runs
their in-model summarization calls CONCURRENTLY (Promise.all — the pure
call part only), and commits the candidates sequentially afterwards (kernel
state mutates single-threaded, #2678 shape). The serial walk keeps one fold
per round; the half-life of the 15-40s ladder halves, and a range the
parallel pass cannot summarize is deliberately left out of the skipSet so
the walk takes it over with its halving/transient/probe semantics.

Existing sessions are untouched: a large payload there may indicate LOST
folds, and the owner's rule for that case is to diagnose (warn), not to
spend tokens folding — that tier lands as a separate diagnostic. Above the
6M-char bound the request fails fast instead (the default-off digest
regime, prior commit) rather than burning the call budget without
converging.

Nomination, span selection, preview/render gates, acceptance (max cap,
net-shrink monotonicity, rescue truncate) and failure shapes mirror the
walk and the external batch lane byte-for-byte.

Test: fresh anonymous session, 30 x 10k-char messages (~300k chars, under
the doomed-probe byte floor, non-emergency), asserts peak in-flight >= 2
summarization calls, single forward, mid-history folded out of the rebuilt
payload (kernel anchor + recent tail stay resident by design), and the
blocks hold the upstream-written summaries.
@ranxianglei
ranxianglei force-pushed the fix/preflight-emergency-digest-default-off branch from 49781ce to 9f2d74e Compare November 22, 2026 14:54
…est (PR #7549 review)

- gate: require zero compression blocks in addition to lastInputTokens <= 0
  — credit-floored existing sessions (cache-ledger settle) and adopted
  anonymous forks (fork-adoption) both look 'fresh' on the usage stat but
  carry active blocks; folding them would spend tokens on possibly-LOST
  fold state, which the owner's rule says to diagnose instead (review M1)
- lane: #1993 halving parity across rounds — a hard 400/413 on a span now
  remembers the two snapped halves by ref (freshHalvedSpans) and the next
  round's nomination consumes them before retrying the full span; at/below
  the minimum-span floor the range goes to skipSet like the walk (M2)
- lane: a hard upstream verdict stands as the round's failure BEFORE the
  sequential commits (each successful commit still clears it via
  commitFold's #1993 reset) — the old committed===0 guard swallowed a
  deterministic shape wall (#2189) behind one lucky commit (M2)
- lane: first hard verdict wins (abort always wins) instead of
  last-writer-wins under concurrency (L2); 400 detail text now matches the
  walk's #2189 wording (L4); 'nomination order' comment corrected to
  size-desc (L3); failed-range takeover comment now states the real
  semantics (walk only runs in a round where the lane committed nothing)
- test (M3/L1): the default-off e2e was 2.56MB — above the 2MB doomed-probe
  byte floor, so it answered 413 before preflight and pinned nothing about
  the gate. Resized to 60x32k = 1.92MB (below the floor, ~20x the window):
  asserts the ladder actually ran (summarization calls >= 1) and no digest
  artifacts — a clean A/B against the env=1 e2e at the same size. The
  incorrect 'fresh sessions below the byte floor cannot reach the regime'
  comment is replaced with the correct geometry.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review(agent 深度评审,1.9M tokens 上下文,独立工作树实测 9/9 测试 + typecheck):结论 = 可合并,无 blocker。 发现 3 个 medium + 5 个 low,其中 3 个 medium 已在本分支修掉(commit 917845bc),low 里注释/文案 4 处一并修掉,1 处(测试内注释几何错误)随 medium 测试重写解决。

已修(917845bc):

  1. M1 — 新会话 gate 不够严。lastInputTokens <= 0 会把两种「看起来是新的」存量会话误判进来:① credit-floor 结算后 usage 归 0 的长折叠会话(src/cache-ledger.ts settle 逻辑,值持久化);② adopted anonymous fork(src/fork-adoption.ts 故意不继承 stats 但继承 blocks)。它们带着 active blocks 进来,并行 lane 就恰好花在「可能丢了折叠状态」的会话上 —— 正是 owner 规则说不能盲折的那类。修复:gate 加 state.blocks.length === 0,零块 = 没有任何东西可以丢。
  2. M2 — 失败 range 的跨轮恢复与串行 walk 不一致。旧注释说「同一轮串行 walk 接管」,实际 lane commit ≥1 时占满了该轮唯一 fold 额度,walk 根本不跑;且 lane 没有 halving 等价物,持续 400 的 span 会每轮烧全尺寸调用直到预算耗尽;另一个 hard verdict(#2189 shape wall)在「有 commit 成功」时被静默吞掉。修复:① 400/413 按 span 记住两个折半 ref(freshHalvedSpans),下轮提名优先消费,低于最小 span 下限进 skipSet —— 对齐 walk 的 #1993 halving 语义;② lane failure 在串行 commit 之前置位,成功 commit 经 commitFold 的既有 #1993 reset 清除 —— 有成功就清、没成功就报,与 walk 的语义一致。
  3. M3 — default-off 测试 pin 的是别的东西。原尺寸 2.56MB 超过 2MB doomed-probe 字节底线,413 发生在 preflight 之前,master 上同样通过,gate 路径零 pin。重写到 1.92MB(底线之下、~20× 窗口之上):断言 ladder 真的跑了(≥1 次摘要调用)+ 无 digest 产物,与 env=1 的 e2e 同尺寸构成干净 A/B。顺带修正了测试里一段错误的「新会话进不了 regime」几何注释。

低优先级已顺手修:并发失败 first-writer-wins(原来 last-writer-wins,非确定性);400 detail 文案补齐 walk 的 #2189 说明句;两处注释(「oldest first」实为 size-desc;takeover 语义)改为真实行为。

评审确认过的问题点(无需改动):无 TOCTOU(summaryBudget 是硬顶,所有先查后增都在同步段);顺序 commit 在并发摘要之后是保守正确的(foldTargetKey 失配丢弃朝安全侧偏);lane 与 walk 的 span 选择 / preview / 接受阈值 / #2832 deterministic-empty 语义一致;batch lane、串行 walk、存量会话路径纯增量 gated;#7546 one-shot preflight 计数不受非 abort 失败消耗。

留档说明(PR body 已注明,非本 PR 范围):#2383 生产形态(已知 baseline 的超大首重发)在新默认下走完整 ladder、收敛不了就 502 —— 需要旧零调用 digest 收敛的部署用 BILI_PREFLIGHT_EMERGENCY_DIGEST=1 保留;存量大会话的「块丢失诊断(warn 而非折叠)」按 owner 决定是后续项。

…not zero calls

With the #2383 emergency digest default-OFF (#7549), the fresh-parallel fold
lane spends a few small summarization calls on the (unreducible) core text
before the fail-fast. The #5000 test's calls.length===0 assertion (written
for the always-on digest) now fails on those calls. Assert the actual intent
instead: no call may carry the 4.8MB tools-mass body itself.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI fix pushed — 4e00cb7b0fa on fix/preflight-emergency-digest-default-off.

The red CI (test windows-latest 22 shard 5) was the e2e #5000 test in tests/issue4079-egress-window-fuse.test.ts:209 asserting calls.length === 0. That assertion was written for the always-on #2383 emergency digest (the base's emergencyFold = entryOvershoot > EMERGENCY_FOLD_COVERAGE, no knob — a CPU-only deterministic digest, zero upstream calls). This PR's first commit (eee5b790) default-OFFs that regime behind the new network.emergencyDigest knob, so the #5000 body (4.8MB of tools-mass, 1.5KB core text) now falls through to the fresh-parallel fold lane, which spends 3 small summarization calls (~12.9KB each, the core text only) before the fail-fast 413. The doomed tools-mass body is still never forwarded — but calls.length is 3, not 0.

Fix: updated the #5000 assertion from calls.length === 0 to calls.every(c => c.bytes < 1_000_000) — the actual intent (the 4.8MB tools-mass body never reaches the upstream), not the incidental zero-calls side effect of the always-on digest. Verified locally: all 4 tests in issue4079-egress-window-fuse.test.ts pass, all 9 in preflight-emergency-fold.test.ts pass.

Note for the PR author (not blocking): the fresh-parallel fold lane makes 3 futile summarization calls for a body whose mass is in tools[] (folding can't reduce the tools mass). This is a side effect of the default-OFF, not a regression — the body is still stopped (413). If you want to avoid the wasted calls, a futility check in the lane (skip when the foldable message-mass can't close the tools-mass deficit) would do it — but that's a design decision beyond this CI fix.


八问(结构化审核结论)

  1. 是什么问题:CI 红——e2e #5000 测试断言 calls.length === 0 失败(实际 3 次调用)。
  2. 什么原因导致的:本 PR 首个 commit(eee5b790)把 DSH 分叉会话后触发大量 preflight overflow compress #2383 紧急摘要机制从「常开」改为「默认关」(新 network.emergencyDigest 旋钮)。base 上紧急摘要常开(emergencyFold = entryOvershoot > EMERGENCY_FOLD_COVERAGE,无旋钮),用 CPU-only 确定性摘要处理 [Bug][dsh][0.1.208] Kill switch / egress fuse only measures message.text: a session with 26,903 messages and only 1.44 M | [Bug][dsh][0.1.208] 判死/egress fuse 只量 message.text:26,903 条消息、core text 仅 1.44 MiB 的会话绕过 fuse 发出 55.2 MiB 请求体,被上游 413 拒收(ModelArts.… #5000 形体(4.8MB tools 质量 + 1.5KB 核心文本),零上游调用;head 上旋钮默认关,走 fresh-parallel fold 车道,对(无法缩减的)核心文本花 3 次小摘要调用后才 fail-fast 413。calls.length 从 0 变 3。
  3. 影响范围与严重程度:仅测试断言层面——[Bug][dsh][0.1.208] Kill switch / egress fuse only measures message.text: a session with 26,903 messages and only 1.44 M | [Bug][dsh][0.1.208] 判死/egress fuse 只量 message.text:26,903 条消息、core text 仅 1.44 MiB 的会话绕过 fuse 发出 55.2 MiB 请求体,被上游 413 拒收(ModelArts.… #5000 测试的 calls.length === 0 断言过严(它是「紧急摘要常开」时代的产物)。实际行为(tools 质量 body 不被转发、413 fail-fast)不变。体验瑕疵级(CI 红,非用户可见)。
  4. 怎么修复的:把 [Bug][dsh][0.1.208] Kill switch / egress fuse only measures message.text: a session with 26,903 messages and only 1.44 M | [Bug][dsh][0.1.208] 判死/egress fuse 只量 message.text:26,903 条消息、core text 仅 1.44 MiB 的会话绕过 fuse 发出 55.2 MiB 请求体,被上游 413 拒收(ModelArts.… #5000 断言从 calls.length === 0 改为 calls.every(c => c.bytes < 1_000_000)——断言真实意图(4.8MB tools 质量 body 绝不到达上游),而非「紧急摘要常开」的零调用副作用。
  5. 是否回归问题:无。审过的既有行为:Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079/[Bug] CJK payloads slip past the egress byte-floor fuse: a 4.1 MiB outbound was forwarded at 1,121,674 tok into a 1,000,000-token window (0.1.206, plugin lane) #4543/Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079-both-ways 三个同文件测试全过;PR 新增的 preflight-emergency-fold.test.ts 9 个测试全过。tools 质量 body 的 413 fail-fast 行为不变(只是从 0 调用变 3 次小摘要调用,body 仍不转发)。
  6. 是否破坏缓存:不涉及(测试断言变更,无缓存/重试/游标/去重键影响)。
  7. 是否改了设计方向:不涉及(未改架构/边界/数据流;仅测试断言对齐 PR 的默认关行为)。
  8. 是否引入新配置:不涉及(本 CI 修复未引入新配置;PR 本身的 network.emergencyDigest 旋钮是 PR 既有设计,非本修复引入)。

收工判定:CI 红已修(4e00cb7b0fa 已推送,CI 将重跑)。fresh-parallel 车道的 3 次无效摘要调用是默认关的副作用(非回归),已注明供 PR 作者参考——若要消除需车道内加 futility 检查,属设计决策,超出本次 CI 修复范围。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

This event is stale — it reports CI run 45041534192 on head a73c63c (an earlier commit in the PR). The current PR head is 4e00cb7b0fa (the #5000 test fix pushed in the previous wake). Live check state for the current head (mirror cache, fetched 2026-11-22T18:33:48Z): 0 failures, 14 pending, 4 success — the CI is still running on 4e00cb7b0fa. No action needed from this event; the fix is already in place and the CI will complete on the current head. Stopping without further work.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Duplicate of the previous stale event — same CI run 45041534192 on head a73c63c (an earlier commit in the PR). Current PR head is still 4e00cb7b0fa (the #5000 test fix). Live check state (mirror cache): 0 failures, 14 pending, 4 success — CI still running on the current head. No action needed from this event; stopping without further work.

… off; opt digest-designed tests in (#2383, #2847)

- default-off + payload > 19.2x the window (the ladder's own
  32-call x 0.6-window coverage product, above which no combination
  of successful folds is guaranteed to land under the window): fail
  IMMEDIATELY with a deterministic structural-exhaustion verdict —
  zero summarization calls, zero wall clock. Burning up to 32
  large-context summary calls for minutes no client outlives is
  exactly #2383's 300s-disconnect loop. The verdict is deterministic
  (a retry changes nothing), so the caller's existing contracts apply
  unchanged: a trusted session keeps the identity fast path (upstream
  usage reality outranks local doom math), every other session gets
  the terminal non-retryable 413 (#2847: 502 would be retried forever
  by status-code-driven hosts). The fresh parallel lane spends the same
  budget concurrently, so it does not raise the bound either — it only
  makes the convergent band below it faster.
- default-off e2e now pins the terminal 413 with zero upstream calls
  (the #554 measured-body guard may answer with its own over-window
  wording ahead of the preflight detail — both accepted).
- three tests designed around the digest regime now opt in explicitly:
  the knob reads env or the ON-DISK config file, never in-process
  startServer options — the #5631 lanes get it via their spawned
  proxy's BILI_CONFIG_FILE, #1987 and #4227 set the env for the test's
  duration.
- CI note: #6069 epoch-pause e2e is red on master itself (run
  45047243756 on rebase base 9ad612e; reproduced on a clean baseline
  checkout) — pre-existing, not a regression here.
@ranxianglei

Copy link
Copy Markdown
Owner Author

追加:CI 回归修复 + 红项归因(commit 990bd41,已推)

上一条评审后,PR 的 CI 出现 9 个红分片。逐条定位、修复、归因如下:

1. 真回归(本 PR 引入,已修):fix-identity 快速通道两条 e2e。
默认关掉 digest 后,超窗 payload 走 32 次串行 LLM 折叠阶梯——33 次上游调用、502 可重试,破坏了两条既有契约(单发 forward;model-change 413 veto,#2847:502 会被按状态码驱动的宿主无限重试)。
修法:结构性快速失败。 默认关 digest 且 payload 超过折叠路径覆盖界(19.2×窗口 = 阶梯自身的 32 调用 × 0.6 窗口覆盖乘积,超过它任何成功折叠组合都不保证收进窗口)时,立即返回确定性 exhausted 判定:零摘要调用、零墙钟。判定标 deterministic(重试不改变任何东西),所以下游既有契约原样接管:受信会话走 identity fast path(上游 usage 事实压过本地 doom 数学),其余会话拿终态不可重试 413(#2847)。并行 lane 花的是同一个预算,不抬高覆盖界,所以新鲜会话同样适用。burn 32 次大上下文调用等分钟级墙钟、客户端先挂,正是 #2383 的 300s 断连循环——不再让它发生。

2. 三个"为 digest 设计"的测试改为显式 opt-in(不删不削弱):
#5631 重启存活双车道(经 spawn 代理的 BILI_CONFIG_FILE 拿到 network.emergencyDigest: true)、#1987 基线锚定、#4227 内部车道接线(测试期间设 env)。关键坑:这个 knob 只读 env 或磁盘配置文件,进程内 startServer 选项不生效——测试注释里写明了。

3. 非本 PR 回归(归因,不动):

测试:受影响套件(fix-identity 5/5、preflight-emergency-fold 9/9、#5631/#1987/#4227/#2952/#5000/#4079)本地全绿;tsc --noEmit 干净。PR body 已同步更新(快速失败语义 + 上述归因)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到。已核实当前 PR head 为 990bd41f(owner 推送的快速失败修复 + 三个 digest 测试 opt-in 改造)。实时 CI 状态(镜像缓存,2026-11-22T19:42:25Z 抓取):0 失败,12 进行中,6 成功——CI 正在新 head 上跑,尚无失败。

归因确认(与 owner 描述一致):

CI 完成后若仍有红项我再跟进;当前无需进一步动作。

…est line split)

N3: lifecycle row said ≥19.2x, the code gate is strict > (src/preflight.ts:2049).
N4: env assignment crammed onto the next statement's line in the #1987 test.

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final review of HEAD (990bd41) — ready to merge, no blockers.

Reviewed the full 13-file diff against master commit-by-commit, verified the six server.ts contract rows for the structural fast-fail (trusted forward-once, deterministic 413 mapping, #2847 terminal-vs-retryable, #3918 progress, #7546 one-shot, #496 images), and re-ran all five touched test files locally (20/20) plus typecheck. The coverage-bound math checks out (19.2x = the ladder's maximum scaled budget of 32 × 0.6-window folds), and the (19.2x, ~20.2x] band failing fast instead of burning 32 calls for 8–21 minutes is the right call — that band was exactly #2383's 300s-disconnect loop.

Five minor nits found, none blocking:

  • N3 (docs): lifecycle row said "≥19.2×", the code gate is strict > — fixed in d3eb7ff.
  • N4 (test formatting): env assignment crammed onto the next line in the #1987 test — fixed in d3eb7ff.
  • N1 (optional): the walk loop has no top-of-iteration failure check, so after a 0-commit hard lane failure the walk may spend ≤1 extra bounded summary call before breaking. Verdict is correct either way; left as-is (one wasted call at worst, matches the walk's existing mid-loop style).
  • N2 (doc note): for fresh (no-baseline) sessions the overshoot is char-based, so the fast-fail bound trips at ~4.8× true-token overshoot for ASCII text — conservative direction (fail fast, never forward a guaranteed 400), inherited from #2383's char-regime math. Not a bug; noted for the follow-up doc.
  • N5 (micro-perf): refMaps() is recomputed per nominated range (≤2/round); negligible, left as-is.

d3eb7ff touches only docs and one test-file line split — runtime behavior is byte-identical to 990bd41, the commit the local real-model gate passed 17/17 on, so that result stands for this head.

…ency-digest-default-off

# Conflicts:
#	tests/issue4079-egress-window-fuse.test.ts
…ge of 9236576)

#7537 dropped the local estimate-based 413 refusals: a deterministic
exhaustion verdict on a session with NO proven upstream wall now forwards
(src/server.ts:4951) and the upstream's own size verdict is authoritative.
The default-off pin keeps the property this PR owns — the structural
verdict fires BEFORE the 32-call ladder (exactly one upstream call, the
forward itself) — and the evidence-based 413 remains for sessions with a
proven window.
@ranxianglei
ranxianglei force-pushed the fix/preflight-emergency-digest-default-off branch from 4c43d6f to 4ae7e33 Compare November 23, 2026 02:17
@ranxianglei ranxianglei changed the title [PR] preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel Nov 23, 2026

@ranxianglei ranxianglei left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge-conflict resolution: master 9236576 (#7548/#7537) into this branch

Heads-up on the force push: the branch previously carried an automated master-merge commit (4c43d6f) made from a stale master that predates #7548/#7537, which forked the branch against my local merge. The new head 4ae7e33 is a single clean merge of current master (9236576) plus the two re-pin test edits below — same logical content as before, nothing lost (verified by diff).

The semantic interaction (this is the whole story): #7537 changed the repo's contract for untrusted sessions — no more local size refusals; forward and let the upstream's own verdict be authoritative (only refusals backed by a proven upstream wall survive). One of this PR's pinned behaviors — "untrusted session + deterministic local exhaustion → local 413" — was killed by #7537's owner ruling. The tests were re-pinned to the post-#7537 contract:

  • tests/preflight-emergency-fold.test.ts (default-off e2e): the untrusted no-wall session is now forwarded per #7537, so the pin flips to: status 200, exactly one upstream call — the forward itself — and zero digest artifacts. What the test still pins for this PR is the property that mattered: the structural verdict fires before the 32-call ladder (zero wasted calls, zero ladder wallclock).
  • tests/issue4079-egress-window-fuse.test.ts (merge conflict): took master's #7537 side (upstream 413 passthrough + x-bili-cause: upstream-size + payload actually forwarded) and relaxed calls.length === 1 to "exactly one ≥1MB full-body call, with only small summary calls before it" — the fresh-parallel lane may spend a couple of small in-model calls before the forward, which master's stricter pin didn't anticipate.
  • The 413-veto arm of fix-identity-fast-path-preflight is untouched and still green because it seeds a usage baseline — a proven upstream wall, exactly the class #7537 preserves.

What the structural fast-fail still does after the merge: zero wasted LLM calls and zero ladder wallclock for >19.2× payloads with digest off; deterministic exhaustion with a proven wall → 413 (the only remaining local refusal); trusted sessions → immediate forward-once. The CI run on 4ae7e33 is in progress; expected to be green apart from the pre-existing master #6069 reds (documented in the PR body). Local real-model gate (gate:local) is being re-run on the merged tree per the all-green-before-merge flow.

@ranxianglei ranxianglei changed the title preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel [PR] preflight: stop hard-truncating extreme overflows by default; fold fresh-session first resends in parallel Nov 23, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

上游冲突已解决,PR head 现为 4ae7e33313e,本地定向验证全绿,CI 运行中 0 失败。

过程说明(透明起见):floor 17 的冲突唤醒后,前一个会话在合并 origin/master 时崩溃,工作区留下一个只解决了一半的合并。本会话独立完成了同一份解决(冲突文件 + 本 PR 自己的 e2e 重钉),准备推送时发现分支已被并行会话 force-push 了等价的完整解决(4d6412e602a 合并 master@9236576c + 4ae7e33313e 重钉)。两份解决语义一致(并行版对 #5000 的断言更宽松,预留了 fresh-parallel 车道可能先花小摘要调用的余地,更稳),故丢弃本会话的冗余提交,保留远端版本,并改为对远端 tip 做独立验证:

行为变更披露(merge 带来的,非本 PR 自改):本 PR 的 default-off 结构性 exhausted 判定,在 master 合并 #7537 后从「无证据会话 → 本地终态 413」变为「一律转发,上游以真实号码裁决」(旧值:本地 413 + 零调用 → 新值:转发 + 上游 413 透传;原因:master 的 #7537/KDD #19 owner 裁定 2026-11-22「本地估算拒发整条机制废除」)。本 PR 自身契约(零阶梯消耗、无 digest)保持不变。


八问(结构化审核结论)

  1. 是什么问题:上游 PR 冲突——master 合入 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537(废除本地估算大小 413 拒发,改为「折完一律转发、上游真实号码裁决」)后,与本 PR 的两个 preflight 测试断言冲突(它们仍按 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 前的「本地 413」语义写)。
  2. 什么原因导致的:PR 分支 base 早于 master 的 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537;Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 把超窗 payload 的终局行为从「本地 413 拒发」改为「转发 + 上游标注 413 透传」,两个测试的断言与之一致性断裂——文本冲突背后是语义变更,不是纯文本撞行。
  3. 影响范围与严重程度:仅测试断言层(2 个测试文件);生产代码(src/server.ts、relay.ts、preflight.ts)自动合并干净、无语义冲突。用户可见行为由 master 的 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 裁定统一,本 PR 自身契约不变。CI 红级(不修则 CI 必红),非用户可见回归。
  4. 怎么修复的:[Bug][dsh][0.1.208] Kill switch / egress fuse only measures message.text: a session with 26,903 messages and only 1.44 M | [Bug][dsh][0.1.208] 判死/egress fuse 只量 message.text:26,903 条消息、core text 仅 1.44 MiB 的会话绕过 fuse 发出 55.2 MiB 请求体,被上游 413 拒收(ModelArts.… #5000 e2e 取 master 侧(转发 + 上游 413 透传 + 恰好一次完整 body 调用);本 PR 的 default-off e2e 重钉到 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 语义(转发、假上游 200;结构性快速失败仍钉死零摘要调用 + 无 digest 块)。
  5. 是否有回归问题:无。合并后 head 上定向验证:重钉 2 文件 13/13、preflight 全域 62/62 全绿,typecheck 干净。既有行为逐项:同文件 Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079/[Bug] CJK payloads slip past the egress byte-floor fuse: a 4.1 MiB outbound was forwarded at 1,121,674 tok into a 1,000,000-token window (0.1.206, plugin lane) #4543 测试全绿;本 PR 的 env=1 digest e2e(场景 A/B)与 fresh-parallel e2e 全绿;Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 域 11 个文件全绿。高危模式逐项:无语义漂移(生产代码未动)、无 fail-fast 变吞错(上游 413 透传带 x-bili-retryable: false,重试语义保留)、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及(无缓存/重试游标/去重键变更;x-bili-retryable 标记是 Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537 既有机制,merge 原样带入)。
  7. 是否改了设计方向:本 PR 未改——「本地拒发 → 转发 + 上游裁决」的方向变更是 master Preflight: don't reject based on local estimation — after folding, forward unconditionally; if it exceeds the window, le | preflight 不用本地估算拒发:折叠后一律转发,超窗让上游自己说(413 拒发家族总根因) #7537/KDD fix: route auto-update logs through the tee logger #19(owner 裁定 2026-11-22),本 PR 的 merge 只是让自己的测试对齐该方向。
  8. 是否引入了新的配置:不涉及(merge 未引入新配置;本 PR 自身的 network.emergencyDigest 旋钮是 PR 既有设计,非本次引入)。

收工判定:冲突已解决、PR 与当前 master 可干净合并、本地定向验证全绿、CI 运行中 0 失败——无需进一步动作,等 CI 全量出结果;若 CI 出现红项我再跟进。

@ranxianglei
ranxianglei merged commit 15f06c6 into master Nov 23, 2026
50 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1288-master.15f06c6 (rolling master tag).

npm install -g billion-context@0.0.1288-master.15f06c6  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Nov 23, 2026
…lict, round 7)

Master moved 0b68ade -> 15f06c6 (kernel 0.0.205, +preflight
emergency-digest default-off #7549, +preflight 413 passthrough #7548,
+sessions reattach #7512, +opencode user-fork detection #5511,
+acp-status uncompressed nudge-align #7536, +preflight gate epoch
exception #7558, +413 egress fuse pins #7488, +Korean README #7551,
+many host/test changes).

Conflicts: 3 version-only files (kernel/package.json,
kernel/package-lock.json, root package-lock.json). Resolved to kernel
0.0.206 (merged kernel = superset of master's 0.0.205 + PR #6720/#6762
changes; kernel/src changed vs master => must bump above master's 0.0.205).

Auto-merged clean: kernel/src/compress.ts (PR markers 13x + master
changes), src/stream.ts (PR markers 3x), src/server.ts, master's new
test files, docs.

Local verification: typecheck ✓, build ✓, kernel 1671 pass / 0 fail,
host nudge/receipt 7 pass / 0 fail, kernel-guard ✓ (SRC_CHANGED=2
BUMPED=1 0.0.205->0.0.206), version-guard ✓ (root 0.1.216 untouched),
lock-sync ✓.
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant