Skip to content

[PR] fix(preflight): fail fast locally when a post-drift transform failure leaves an over-window raw body (#5223) - #5275

Open
ranxianglei wants to merge 5 commits into
masterfrom
2026-10-31_drift-overwindow-local-failfast
Open

ranxianglei wants to merge 5 commits into
masterfrom
2026-10-31_drift-overwindow-local-failfast

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

What

#5223: after a cross-provider re-serialization drifts the whole history (repair mode honestly re-emits the unfolded originals), a kernel-transform failure on that drifted history made bili forward the entire raw client history upstream — ~50MB / ~5.5M tokens against a 1M window in the field: guaranteed 413 after a 30–42s upload, repeated per retry and per turn until the next turn re-folded.

Root cause

The prepare catch keeps the inbound JSON as the outbound body while leaving prepared.processedMessages empty (src/server/prepare-openai.ts:441). The trigger still fires correctly (outboundPayloadBreakdown already falls back to originalMessages for sizing, #1498-F2), and preflight returns zero foldable ranges (#3641 epoch pause or deterministic exhaustion). But the zero-range fits judgment measured processedMessages — the empty array — so 0 + overhead < window read "fits" and the raw body shipped ("preflight made no progress but the payload fits; forwarding as-is"). The sibling branch (compressedRanges>0) already carried the right fallback; this one missed it.

Changes (all src/server.ts, host-side)

  1. Zero-range fits judgment now measures the view that ACTUALLY ships (processedMessages, falling back to originalMessages when empty) — mirroring outboundPayloadBreakdown's fix: arm emergency shrink on outbound payload size, not raw body (#1493) #1498-F2 fallback and the compressedRanges>0 branch.
  2. The 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 arbitration escape now carries the same doomed-bytes bar as its sibling escapes (billion-context 卡死问题 —— 上报材料 usage获取不到导致上下文估计失误 #2313 probe, [PR] fix: cache report misattributes bili's projected thinking-token meter as a client seam break (#4054) #4056 gate): a rebuilt body whose core text alone exceeds max(2MB, window×7.5B/tok) fails fast instead of being forwarded "for upstream arbitration".
  3. The fail-fast verdict names the Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641 fold pause explicitly when folding is epoch-paused — instead of a generic "could not bring it under" that left hosts guessing.

Behavior change (old → new)

state old new
transform failed + raw body over window + zero folds raw body forwarded upstream (413 after full upload) local fail-fast: 502 retryable=false while folding is paused / 413 on deterministic exhaustion
rebuilt bookkeeping fits but shipping body past the doomed bar (#1839 escape) one forward "for upstream arbitration" local fail-fast
transform failed + raw body FITS forward as-is unchanged
all non-empty-view paths — unchanged

No new config surface, no kernel changes, no wire-shape changes.

Tests

New tests/issue5223-drift-unmeasured-forward.test.ts (4 tests): pins both holes (verified failing on unpatched master via stash-run) plus two controls (an over-window MEASURED view still fails fast; a fitting raw body still forwards). Adjacent preflight / fail-fast / epoch suites green locally (25 tests); full-suite verdict comes from CI on this head.

Closes #5223

…ansform failed (#5223)

After a cross-provider re-serialization drifts the whole history, repair mode
re-emits the unfolded originals AND a kernel-transform failure leaves
prepared.processedMessages empty while the outbound body IS the raw client
history. preflightCompressIfNeeded judged the zero-fold-result fit on the
empty array ("0 + overhead < window") and forwarded a ~50MB / ~5.5M-token
body upstream — guaranteed 413 plus a wasted upload per turn.

- zero-range fits judgment now mirrors outboundPayloadBreakdown's #1498-F2
  fallback and the compressedRanges>0 branch: measure the shipping view
  (processedMessages, falling back to originalMessages when empty)
- the #1839 arbitration escape now carries the same doomed-bytes bar
  (max(2MB, window*7.5B/tok)) as its sibling escapes (#2313/#4056): a rebuilt
  body past the bar fails fast instead of "letting the upstream arbitrate"
- the fail-fast verdict names the #3641 fold pause explicitly when folding is
  epoch-paused, so hosts see why no fold could be applied this turn

Behavior change (old -> new): a session whose transform failed and whose raw
body exceeds the effective window used to ship that body upstream (413 after
a full upload); it now fails fast locally (502 retryable=false while folding
is paused, 413 on deterministic exhaustion). Fitting raw bodies and all
non-empty-view paths are unchanged.
@ranxianglei ranxianglei changed the title fix(preflight): fail fast locally when a post-drift transform failure leaves an over-window raw body (#5223) [PR] fix(preflight): fail fast locally when a post-drift transform failure leaves an over-window raw body (#5223) Oct 30, 2026
@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-31_drift-overwindow-local-failfast (25f15c1)

Latest build — install this exact version

npm install -g billion-context@0.0.9519-pr.5275.9dc5246

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
25f15c1 billion-context@0.0.9519-pr.5275.9dc5246 build
7e9a66d billion-context@0.0.8971-pr.5275.52ade88 build
ed35b7e billion-context@0.0.8933-pr.5275.d13cd9d build
7bfd392 billion-context@0.0.7318-pr.5275.bf7c165 build
1fc4185 billion-context@0.0.7239-pr.5275.2e8f463 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Merge conflict resolved — PR is mergeable again. Merged current master (4dea18eabf, 1154 commits ahead of the branch's last integration) into 2026-10-31_drift-overwindow-local-failfast, resolved both conflicts in src/server.ts, pushed ed35b7ef90. Remote branch head was verified unchanged before pushing (no concurrent work) — plain fast-forward push, no force-push. GitHub now reports mergeable: true (state blocked = waiting on checks/branch protection, not a conflict); CI re-triggered on the new head with all test lanes in progress.

What the conflicts were and how they were resolved:

  1. Import line (mechanical). Master extended the ./preflight.js import with estimateRawBodyBreakdown / type RawBodyBreakdown (the [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/[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/[Bug][dsh] Rewind (fork+seed) leaves non-monotonic refs: preflight folds only ~5k tokens/round, so 31 rounds (649 s) cannot close a 283k deficit — and the "NOT forwarded" payload is sent anyway #5885 measured-body work); this PR added import { epochConfirmPending } from "./fold-reconcile.js". Resolved as the union of both lines.

  2. The 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 arbitration arm (semantic — same problem, two generations of the mechanism). While this PR was branched, master landed a stronger guard in this exact branch: a MEASURED body doom tier ([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/[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/[Bug][dsh] Rewind (fork+seed) leaves non-monotonic refs: preflight folds only ~5k tokens/round, so 31 rounds (649 s) cannot close a 283k deficit — and the "NOT forwarded" payload is sent anyway #5885) that runs the side request(max_tokens<=200)绕过 preflight 且不检查载荷体积,携带全量历史直转上游导致 400 #554 CJK-aware meter over the actual serialized outbound body and answers 413 when it exceeds the native window (with noteLocalRefusal). The PR's hunk adds an ESTIMATED doomed-bytes bar (max(2MB, window×7.5 B/tok) over the shipping view) that withholds the forward and falls through to the generic fail-fast below (which carries the Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641 fold-drift-pause context). Resolution keeps BOTH, ordered: the byte-bar gate runs first — past the bar, withhold and fall through to the generic verdict (exactly what the PR's own test feat: OpenAI Responses API support (/v1/responses) #4 pins: 502 via fall-through, not an immediate 413, so drift-paused sessions get actionable context instead of "remove or trim"); under the bar, master's measured tier still answers its precise 413 for the dense-CJK band the conservative byte bar cannot see; otherwise the original forward-once stands. Neither side's behavior was dropped.

Verification (targeted suites only, per local-test discipline): typecheck clean; tests/issue5223-drift-unmeasured-forward.test.ts 4/4, tests/issue4185-identified-fresh-forward.test.ts 5/5, tests/issue5000-count-gate.test.ts 3/3, tests/issue4079-egress-window-fuse.test.ts 4/4. Final PR diff vs master is unchanged in scope: src/server.ts plus the one new test file — no kernel/, no config surface, no version field touched, so no authorization checkpoint applies. The full-suite verdict comes from the CI re-run on ed35b7ef90.

结构化结论(七问)

  1. 是什么问题:PR 分支与 master 冲突(dirty)——master 在 PR 分叉后前进了 1154 个提交,其中 [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/[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/[Bug][dsh] Rewind (fork+seed) leaves non-monotonic refs: preflight folds only ~5k tokens/round, so 31 rounds (649 s) cannot close a 283k deficit — and the "NOT forwarded" payload is sent anyway #5885 恰好重写了本 PR 要改的同一处代码(任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 仲裁逃逸臂),外加一行 import 的机械冲突。
  2. 什么原因导致的:两代机制撞在同一分支上——PR 用「估算字节 vs 注定失败线」拦截注定失败的转发,master 其后落地了更精确的「实测 body token vs 原生窗口」拦截,两者都改 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 臂内部,文本冲突之下是语义重叠。
  3. 影响范围与严重程度:仅本 PR 的合入被阻塞(冲突态无法合并),线上行为不受影响;不解决则 PR 永远停在 dirty。
  4. 怎么修复的:把当前 master 整支合入 PR 分支;import 取并集;任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 臂按「PR 字节线在前 → 超线 withholding 走下方通用 fail-fast;线内再走 master 实测档(超窗 413);都不中才转发-once」的顺序保留两套机制。顺序依据:PR 自有测试钉死超线场景为 fall-through 502(带 Snapshot as session reconstruction: identity claim order takes priority, message hash demoted to reference signal (root- | 快照即会话重构:身份认领顺序优先,消息哈希降级为参考信号(根治 #3588/#3640 一类误判) #3641 drift-pause 上下文),master 测试钉死实测超窗为 413,两者并存互不覆盖。
  5. 是否有回归问题:逐项审过既有行为——任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 转发-once 语义保留(两档都不中时照旧转发);[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/[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/[Bug][dsh] Rewind (fork+seed) leaves non-monotonic refs: preflight folds only ~5k tokens/round, so 31 rounds (649 s) cannot close a 283k deficit — and the "NOT forwarded" payload is sent anyway #5885 实测 413 档完整保留(含 noteLocalRefusal 与详细诊断文案);[Bug] 新会话(无 usage 基线)preflight 把字符数当 token——折叠其实成功(2263796→1111212)却 fail-fast 502,上游实际只计费 540828 #3146/413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185 post-fold 块与 dsh压缩与bili压缩冲突 #2490 probe 门未触碰;PR 三处 hunk 全部在位(零折叠 fit 判定改用 shipMsgs、仲裁臂拦截、fail-fast 文案带 epoch-pause 说明)。定向套件 16/16 绿;全量回归以远端 CI 为准。
  6. 是否破坏缓存:不涉及——纯 preflight 转发决策路径,无缓存、重试游标或去重键改动。
  7. 是否改了设计方向 / 引入新配置:均不涉及——无架构转向,无新 env/config/默认值;最终 PR diff 范围不变(src/server.ts + 新增测试文件,不碰 kernel/、不碰 version)。

收工判定:冲突已解,mergeable: true,CI 在新 head ed35b7ef90 上重跑中;等 CI 全绿即可交人工合并。本轮无需要决策项,未触碰任何授权卡点。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

The full run summary for this conflict-fix lane is already posted above (comment by ci-engineer-r1, ~12:37 UTC): master merged into the branch, both src/server.ts conflicts resolved (import union + ordered union of the #5223 byte-bar gate with master's #5000/#4543/#5885 measured-body tier), pushed as ed35b7ef90, targeted suites 16/16 green, typecheck clean.

Fresh status since that reply (verified live from the mirror cache at 12:45 UTC): CI on head ed35b7ef90 is fully green — all 30 checks completed, 14 success + 16 skipped, zero failures; GitHub reports mergeable: true. The remaining blocked state is branch protection only (human merge), not a conflict or red check. Nothing further needed from this lane — ready for human merge.

@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.

probe

@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.

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

APPROVE — clean, well-scoped preflight fail-fast fix. No kernel / config / wire-shape changes; both holes are pinned by regression tests with both-direction controls; every behavior change is disclosed old→new. Reviewed independently against the diff (not the issue's own conclusions).

Independently verified:

  • Symbols resolve: DOOMED_PROBE_BYTES_PER_TOKEN = 7.5 / DOOMED_PROBE_ABSOLUTE_BYTES = 2_000_000 (src/server.ts:3312-3313), estimateCoreMessagesUpperBytes (src/preflight.ts:544), epochConfirmPending (src/fold-reconcile.ts:212); imports present at src/server.ts:89-90.
  • Data flow is correct: outbound is rebuilt when compressedRanges > 0, else stays prepared; each new fallback reads the object that actually ships. The transform-failure catch (src/server/prepare-openai.ts:561-564) resets processedMessages = [] while originalMessages keeps the full parsed history — so measuring originalMessages proxies the shipped raw body. Same idiom already used at src/server.ts:4335/4553/4598 and prepare-openai.ts:619/624.
  • Change 1 activates ONLY when processedMessages is empty (the transform-failure shape); non-empty paths are byte-identical to before → no regression surface.
  • Change 2 reuses the established doomed-bytes bar (#2490/#2313): a core-text body past max(2MB, window×7.5 B/tok) cannot fit on any tokenizer → no false refusal.
  • Change 3 is additive message text only (zero behavior change) and reads through the sanctioned epochConfirmPending helper, never the raw metadata key.
  • Tests match the 17-arg preflightCompressIfNeeded signature exactly. Test 1 fails without change 1 (it would forward the raw history); test 4 fails without change 2 (it would ride the #1839 arbitration escape); tests 2–3 are controls pinning the measured over-window path and the fitting-body passthrough.

八问:

  1. 是什么问题:跨提供方重序列化触发漂移后,repair 模式把未折叠的原始历史重放到线上;若此时 kernel transform 又失败(processedMessages 被清空),preflight 用空数组判 fit、读成"fits",把 ~50MB / 5.5M token 的原始请求体整包转发上游——必然 413,且每次重试、每一轮都白传一次。
  2. 什么原因导致的:零折叠分支的 fits 判定只量了 prepared.processedMessages(失败时为空),没有像兄弟分支那样回退到真正出站的视图(originalMessages);#1839 仲裁逃生门也缺一道 doomed-bytes 闸。
  3. 影响范围与严重程度:仅当「transform 失败 + 原始体超窗 + 该轮零折叠」三者叠加(典型是漂移 repair 轮)才触发——特定条件下的严重浪费(30–42s 上传 × N 次重试 × 每轮),非全局不可用;正常非空路径完全不受影响。
  4. 怎么修复的:让 fits 判定与 #1839 逃生门都改判"实际出站的视图"(空则回退 originalMessages),并给 #1839 逃生门加上与兄弟逃生门一致的 doomed-bytes 闸(超 max(2MB, window×7.5B/tok) 直接本地 fail-fast 而非转发仲裁);漂移暂停时在 verdict 里点名 #3641 epoch pause,给出可操作指引。
  5. 是否有回归问题:无。改动只在 processedMessages 为空时生效(transform 失败形态),非空路径逐字节不变;doomed-bytes 闸不可能误拒(超该字节数在任意 tokenizer 下都装不进窗口);第 3 处纯加消息文本、零行为变更。
  6. 是否破坏缓存:不涉及(未改任何缓存键 / 游标 / 去重逻辑)。
  7. 是否改了设计方向:不涉及(沿用既有 #1498-F2 回退惯用法与 #2490/#2313 字节闸,无新架构 / 边界)。
  8. 是否引入了新的配置:无新 env / config / 默认值。

行为变更(已按交付规范披露 old→new):

状态 旧 新
transform 失败 + 原始体超窗 + 零折叠 整包转发上游(上传后 413) 本地 fail-fast:漂移暂停时 502 retryable=false / 确定性耗尽时 413
重建记账 fit 但出站体超 doomed 闸(#1839 逃生门) 转发一次"交上游仲裁" 本地 fail-fast
transform 失败 + 原始体 FITS 原样转发 不变
所有非空视图路径 — 不变

判定:可合(merge 仍由人工执行)。CI 绿(head ed35b7e)。


Posting as a COMMENT review: GitHub blocks self-APPROVE (the posting identity is the PR author), so this records the verdict without flipping the approval state — merge stays human-only regardless. The preceding one-word "probe" entry on this PR was an accidental endpoint diagnostic made while preparing this review; disregard it.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

review-worker-r1 完成:PR #5275(本线程)已端到端审完,独立核对(未照抄 issue 结论)三处改动的符号解析、数据流与测试有效性后判定 APPROVE。已在 GitHub 提交 COMMENT review(review_id 5843661017)。

说明两点:① 发布身份即 PR 作者(ranxianglei),GitHub 禁止自我 APPROVE(返回 422),故以 COMMENT 记录结论——merge 本就归人工,不受影响;② 准备期间误发过一条单字 "probe" review,已在正式 review 里声明作废,请忽略。

结论要点:改动仅 host 侧 src/server.ts + 新增测试文件,不碰 kernel/、不碰 config/wire-shape/version → 无授权卡点;三处 hunk 全部正确(零折叠 fit 判 shipMsgs、#1839 臂加 doomed-bytes 闸、fail-fast 文案点名 #3641 epoch pause);非空视图路径逐字节不变、doomed-bytes 闸不可能误拒、第 3 处纯加文本;4 个测试双向钉死两个洞 + 两个对照。行为变更 old→new 已在 review 内披露。CI 全绿(head ed35b7e,30 checks 无失败)、mergeable:true,可交人工合并。本轮无需决策项。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict re-resolved (second pass) — PR is mergeable again. Note: my earlier resolution (ed35b7ef90) had already landed and its CI run went fully green — but master then advanced 5154 commits (tip 58a8796224, incl. #5983/#5974 preflight view-vs-rebuild divergence work touching the very function this PR edits), which put the PR back into dirty. This run merged current master into the branch and pushed 7e9a66d867 (fast-forward — remote head verified unchanged before pushing, no force-push, no concurrent work on the branch). GitHub now reports mergeable: true (state blocked = waiting on checks/branch protection, not a conflict); CI re-triggered on the new head.

What conflicted and how it was resolved:

Only ONE textual conflict this time — the ./preflight.js import line: master added type PreflightDeps (the #5974 refactor hoists the deps object into a typed variable) while this branch carries the PR's import { epochConfirmPending } from "./fold-reconcile.js". Resolved as the union of both.

The rest auto-merged cleanly, so I verified the semantics rather than trusting the text: master's #5974 corrective second pass runs strictly UPSTREAM of the #1839 arbitration arm (it improves the fold before the arm's decision point and updates result.*), so it cannot disturb the ordered structure this PR pins — byte-bar gate first (past bar → withhold → fall through to the generic fail-fast carrying the #3641 drift-pause context), master's measured-body 413 tier inside the under-bar branch, forward-once otherwise. Confirmed intact in the merged file (src/server.ts:4535-4576).

Verification (targeted suites only, per local-test discipline): typecheck clean; 21/21 green across tests/issue5223-drift-unmeasured-forward.test.ts (PR's own, 4), tests/issue5974-preflight-view-divergence.test.ts (master's new test for the adjacent behavior, 5), tests/issue4185-identified-fresh-forward.test.ts (5), tests/issue5000-count-gate.test.ts (3), tests/issue4079-egress-window-fuse.test.ts (4). Final PR diff vs current master is unchanged in scope: src/server.ts + the one new test file — no kernel/, no config surface, no version field touched. Full-suite verdict comes from the CI re-run on 7e9a66d867.

结构化结论(七问)

  1. 是什么问题:上一轮解冲突后 master 又前进了 5154 个提交(其中 [PR] fix(preflight): converge view-vs-rebuild fit judgment at the window edge (#5974) #5983/[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 恰好改了本 PR 同一函数 preflightCompressIfNeeded 的上游段),PR 重新变回 dirty。
  2. 什么原因导致的:仓库合入节奏极快,本 PR 分支在两次触发之间落后了整整一天多的 master;新冲突只有 import 行一处(PreflightDeps 类型是 master 重构新增)。
  3. 影响范围与严重程度:仅本 PR 的合入再次被阻塞;线上行为不受影响(上一轮推的 ed35b7ef90 当时 CI 已全绿)。
  4. 怎么修复的:把当前 master tip(58a8796224)整支合入 PR 分支;import 取并集(master 的扩展 preflight import + 本分支的 fold-reconcile import);任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 臂区域无文本冲突,逐行核对了合并后结构——[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 修正性二次折叠严格位于仲裁臂上游,与本 PR 钉死的「字节线在前、实测档在内、都不中才转发」顺序无交互问题。
  5. 是否有回归问题:逐项核对——[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 修正路径完整保留(含 pendingRebuild 复用与 stats 计数修正);fold drift (reconcile=repair) re-emits originals while folding is deferred to the next turn — one request escapes over the window (5.49M tokens / ~50MB) #5223 三处 hunk(零折叠 fit 判定、仲裁臂拦截、epoch-pause 文案)全部在位;[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/[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/[Bug][dsh] Rewind (fork+seed) leaves non-monotonic refs: preflight folds only ~5k tokens/round, so 31 rounds (649 s) cannot close a 283k deficit — and the "NOT forwarded" payload is sent anyway #5885 实测 413 档未动。定向套件 21/21 绿(含 master 新增的 [Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974 行为测试);全量以远端 CI 为准。
  6. 是否破坏缓存:不涉及——纯 preflight 转发决策路径,无缓存、游标或去重键改动。
  7. 是否改了设计方向 / 引入新配置:均不涉及——无架构转向,无新 env/config/默认值;最终 PR diff 范围不变(src/server.ts + 新增测试文件,不碰 kernel/、不碰 version)。

收工判定:冲突已解,mergeable: true,CI 在新 head 7e9a66d867 上重跑中;等 CI 全绿即可交人工合并。本轮无需要决策项,未触碰任何授权卡点。若 master 再前进导致重脏,按同一流程处理即可。

@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.

(ai: qwen3.8-27b) Re-reviewed on the new head after the branch was rebased onto current master.

Head moved ed35b7ef9 → 7e9a66d86. The new commit is a pure Merge remote-tracking branch 'origin/master' into pr5275-local (parents ed35b7ef9 + 58a8796224) — 77 commits of upstream master, no new work in this PR. Base is now master@58a8796224.

What I verified on the new head:

  • The PR's src/server.ts added lines (all 55) and removed lines are byte-for-byte identical between 4dea18eabf..ed35b7ef9 (old base..head) and 58a8796224..7e9a66d86 (new base..head); same for the new test file. The visible server.ts delta across heads is entirely master's own changes in the window, not this PR's.
  • Every referenced symbol still exists at the new head — DOOMED_PROBE_BYTES_PER_TOKEN / DOOMED_PROBE_ABSOLUTE_BYTES (src/server.ts:3330-3331), estimateCoreMessagesUpperBytes (src/preflight.ts:546), epochConfirmPending (src/fold-reconcile.ts:212); imports intact (src/server.ts:89-90).
  • Re-read all three hunks against the newer master context: the else-branch shipMsgs fallback (src/server.ts:4434), the #1839-arm doomed-byte gate (src/server.ts:4542-4575), and the additive fail-fast drift-pause text (src/server.ts:4731). Logic and ordering unchanged; no semantic drift introduced by the re-merge.

Verdict: APPROVE stands. CI green on 7e9a66d86, mergeable:true; the only remaining gate is human merge. No code changes needed — nothing mechanical to fix, no open ends.


八问(新头 7e9a66d 复审,结论与上一轮一致):

  1. 是什么问题:跨 provider 重序列化漂移后,若 kernel 变换也失败(processedMessages 被清空),preflight 用空数组判 fit,把 ~50MB / 550万 token 的原始历史原样转发上游,必然 413。
  2. 什么原因导致的:fit 判定度量的是空数组而非实际要发的视图;#1839 逃生分支对「重建失败、原始体兜底」这一形状没有字节兜底门。
  3. 影响范围与严重程度:仅当「漂移修复重放原始史 + kernel 变换失败」叠加时触发;触发即整轮不可用且每轮重试都白传几十 MB(p1 可用性缺陷)。非该形状的路径零变化。
  4. 怎么修复的:三处——① else 分支改用实际要发的视图判 fit(processedMessages 为空时回退 originalMessages);② #1839 逃生前加 doomed-bytes 门,超阈值直接本地 fail-fast 而非转发;③ fail-fast 文案在折叠暂停时补一句可操作说明(纯文案追加)。
  5. 是否有回归问题:无。非空视图路径字节级不变;doomed 门只在「重建成功但核心文本超窗」时收紧转发;fail-fast 文案纯追加。已逐项过既有行为,无高危模式命中。
  6. 是否破坏缓存:不涉及(不改缓存 / 游标 / 去重键)。
  7. 是否改了设计方向:不涉及(host 侧 preflight 局部修正,无架构转向)。
  8. 是否引入新配置:无新 env / config / 默认值。

判定:可合(仅剩人工合并)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: qwen3.8-27b) review-worker-r1 复审完成:PR #5275 新头 7e9a66d86 为纯 master re-merge(父 ed35b7e + 58a8796),#5223 修复内容字节级未变;三处 hunk 已在新 master 上下文逐一复核、无漂移,符号/导入齐全。结论维持 APPROVE,CI 绿、mergeable:true,仅剩人工合并。GitHub review id 5847446313。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict re-resolved (third pass) — PR is mergeable again. Same pattern as the previous two passes: my last push (7e9a66d867, CI fully green at the time) was overtaken — master advanced 183 commits (tip 99c22d283f) and the PR went dirty again. This run merged current master into the branch and pushed 25f15c1aa1 (fast-forward — remote head verified unchanged before pushing, no force-push, no concurrent work on the branch). GitHub now reports mergeable: true (state blocked = waiting on checks/branch protection, not a conflict); CI re-triggered on the new head.

What conflicted — and this one was semantic, not mechanical:

One conflict, in the zero-fold else branch of preflightCompressIfNeeded — exactly the line this PR's first hunk (#5223) rewrites. Master's f75e45f287 ("preserve calibrated fit after zero folds") independently fixed the SAME bug the PR's hunk 1 targets: a kernel-transform failure leaves processedMessages empty, and judging fit on that empty array reads "fits" and ships the over-window raw body. Master's fix reuses payloadFitsWindow — the entry-time calibrated judgment built on outboundPayloadBreakdown, whose #1498-F2 fallback already measures the raw view that actually ships. Master's version is a strict superset of the PR's: same shipping-view fallback, plus per-route k̂ calibration on one scale with the entry judgment (the PR's fresh core-only estimate is exactly what master's comment rejects: "can reject fitting requests or admit oversized ones"). In a session without usage reports the two are numerically identical.

Resolution: took master's side — the PR's hunk 1 is superseded, not lost. The PR's other two hunks are intact and still needed (no conflict there): the #1839 arbitration arm's doomed-bytes bar (withhold past the bar → fall through to the generic fail-fast) and the fold-drift epoch-pause explanation in the fail-fast verdict (#3641). I left a short comment at the resolution site recording that #5223's zero-fold case is covered by the entry breakdown's fallback, so the supersession is visible in the diff.

Verification (targeted suites only, per local-test discipline): typecheck clean; 37/37 green across the PR's own tests/issue5223-drift-unmeasured-forward.test.ts (4 — proving the superseded hunk's end-to-end behavior still holds through master's judgment) plus master's new tests for the exact conflicting line (preflight-zero-fold-calibration, preflight-image-budget) and the adjacent lanes (issue5974-preflight-view-divergence, issue4185-identified-fresh-forward, issue5000-count-gate, issue4079-egress-window-fuse). Final PR diff vs current master: src/server.ts (+74/−25, now carrying only hunks 2+3) + the test file — no kernel/, no config surface, no version field touched. Full-suite verdict comes from the CI re-run on 25f15c1aa1.

结构化结论(七问)

  1. 是什么问题:前两轮解冲突后 master 又前进了 183 个提交,PR 第三次变回 dirty;这次的冲突点在零折叠 else 分支——master 的 f75e45f287 与本 PR 第一处 hunk(fold drift (reconcile=repair) re-emits originals while folding is deferred to the next turn — one request escapes over the window (5.49M tokens / ~50MB) #5223)改的是同一行、修的是同一个 bug。
  2. 什么原因导致的:本 PR 的 hunk 1 与 master 的修复是同一缺陷的两代方案——PR 用「对实际发出的视图重新裸估」,master 复用入口处的 payloadFitsWindow(其底层 fix: arm emergency shrink on outbound payload size, not raw body (#1493) #1498-F2 回退已测原始体,且带 k̂ 校准、与入口判定同尺度)。master 方案是严格超集。
  3. 影响范围与严重程度:仅本 PR 合入被阻塞;线上行为不受影响(上一轮推的 head 当时 CI 全绿)。对 PR 本身的影响:净 diff 缩小——hunk 1 被 master 取代,PR 现只贡献仲裁臂字节线 + drift-pause 文案 + 测试。
  4. 怎么修复的:把 master tip(99c22d283f)合入 PR 分支;冲突处取 master 侧(hunk 1 被取代,附一行注释说明 fold drift (reconcile=repair) re-emits originals while folding is deferred to the next turn — one request escapes over the window (5.49M tokens / ~50MB) #5223 场景由入口 breakdown 的 fix: arm emergency shrink on outbound payload size, not raw body (#1493) #1498-F2 回退覆盖);其余自动合并部分逐行核对,任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 臂字节线、epoch-pause 文案均在位。
  5. 是否有回归问题:逐项核对——fold drift (reconcile=repair) re-emits originals while folding is deferred to the next turn — one request escapes over the window (5.49M tokens / ~50MB) #5223 端到端行为(零折叠+transform 失败→502 带 drift-pause 上下文)由 PR 自有测试在 master 判定下复验通过;master 新增的 preflight-zero-fold-calibration/preflight-image-budget 测试通过;[Bug][preflight] Folding pass expansion asymmetry: view meets target but outbound reconstruction exceeds window, only ~5 | [Bug][preflight] 折叠 pass 展开不对称:视图达标但出站重建超窗,每轮只推进 ~5k token (#4543-①) #5974/413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185/[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/Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079 相邻车道测试通过。定向 37/37 绿;全量以远端 CI 为准。
  6. 是否破坏缓存:不涉及——纯 preflight 转发决策路径,无缓存、游标或去重键改动。
  7. 是否改了设计方向 / 引入新配置:均不涉及——无架构转向,无新 env/config/默认值;行为面唯一变化是零折叠 fit 判定从「裸估」变为「k̂ 校准同尺度」,且这是 master 既有行为(f75e45f),非本 PR 引入;无 usage 报告的会话下两者数值相同。

收工判定:冲突已解,mergeable: true,CI 在新 head 25f15c1aa1 上重跑中;等 CI 全绿即可交人工合并。本轮无需要决策项,未触碰任何授权卡点。

@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.

(ai: qwen3.8-27b) Re-reviewed on the new head 25f15c1aa after the branch was rebased onto current master. This re-merge changed the PR's content — unlike the prior head (where the fix was byte-identical), I re-verified the actual contribution rather than assuming carry-over.

Head moved 7e9a66d86 → 25f15c1aa (pure merge origin/master, 184 commits; base now 99c22d283).

What the re-merge did to the fix
Master's window independently refactored the preflight image-token path and rewrote the zero-fold else-branch to fits = unknownBaseline ? result.fitsWindow : payloadFitsWindow. That superseded the PR's original hunk 1 (the explicit shipMsgs + estimateCoreMessages(shipMsgs) + overheadEstimate + imageTokens < limit). The PR's hunk 1 is now only a 3-line comment noting that master's payloadFitsWindow covers the #5223 zero-fold case.

Verified: master's payloadFitsWindow genuinely covers the #5223 zero-fold transform-fail case (no lost fix)

  • textEstimate (src/server.ts:3937) is destructured from outboundPayloadBreakdown (src/server.ts:3885), which uses the #1498-F2 raw-body fallback (src/server.ts:3541: msgs = processedMessages.length > 0 ? processedMessages : originalMessages).
  • So calibratedPayload (src/server.ts:3938) → payloadFitsWindow (src/server.ts:4094) measures the raw body when the transform empties processedMessages; an over-window raw body fails the gate and falls to the local fail-fast. Master's version is a calibrated superset of the PR's raw estimate and is consistent with the compressedRanges>0 branch — no regression.

The PR's remaining code contributions (intact, correct, coherent against master's new image refactor)

  • epochConfirmPending import (src/server.ts:88).
  • #1839-arm doomed-bytes gate (src/server.ts:4515-4556): wraps master's measured tier inside if (shipDoomBytes <= max(DOOMED_PROBE_ABSOLUTE_BYTES, limit*DOOMED_PROBE_BYTES_PER_TOKEN)); a rebuilt body past the bar is withheld and fails fast locally instead of riding the #1839 forward-once escape. Master does not have this gate (its #1839 arm goes straight to the measured tier), so this is a genuine, non-redundant fix.
  • Fail-fast drift-pause text (src/server.ts:4710-4715): additive; makes the verdict actionable when folding is drift-paused.

Tests — all 4 in tests/issue5223-drift-unmeasured-forward.test.ts still pass (CI green; T1/T2/T3 exercise the else-branch via payloadFitsWindow, T4 exercises the #1839 gate). File unchanged between heads.

Scope — 2 files, +207/-25; no kernel/, no config surface, no wire-shape, no version change. mergeable:true, mergeable_state:blocked (human merge only).

Behavior deltas (old→new)

  • (a) zero-fold transform-fail fit judgment: PR's raw estimateCoreMessages(shipMsgs)+overhead+image → master's calibrated payloadFitsWindow; identical outcome for the #5223 shape (5.5M ≫ 1M at any k̂∈[0.25,4]), more consistent otherwise.
  • (b) #1839 escape withheld past the doomed bar (local fail-fast) — unchanged from prior heads.
  • (c) fail-fast message gains an actionable drift-pause note — additive.

Verdict: APPROVE stands (self-approve blocked — reviewer identity = PR author — so this is posted as a review comment). No code changes needed; nothing mechanical to fix, no open ends.


八问(新头 25f15c1 复审;本次 re-merge 改变了 PR 内容,已重新独立核验,非沿用上轮结论):

  1. 是什么问题:跨 provider 重序列化漂移后,kernel 变换失败(processedMessages 清空)时,preflight 若按空数组判 fit,会把 ~50MB / ~550万 token 原始历史原样转发上游,必然 413 且每轮白传;#1839 逃生分支对「重建后核心文本超窗」的 doomed 体也会白转一次。
  2. 什么原因导致的:fit 判定必须度量「实际要发的视图」(#1498-F2 原始体回退)而非空数组;#1839 逃生缺字节兜底门;fail-fast 文案在折叠暂停时缺可操作说明。
  3. 影响范围与严重程度:仅「漂移修复重放原始史 + kernel 变换失败」或「#1839 逃生撞上 doomed 体」时触发;触发即整轮不可用且每轮白传几十 MB(p1 可用性缺陷);其余路径零变化。
  4. 怎么修复的:① 零折叠 transform-fail 的 fit 判定由 master 既有的 payloadFitsWindow(复用 #1498-F2 原始体回退)覆盖,PR 在此仅补一句文档注释;② #1839 逃生前加 doomed-bytes 门(shipDoomBytes <= max(2MB, window×7.5B/tok)),超阈值本地 fail-fast 而非转发;③ fail-fast 文案在 epochConfirmPending 时追加可操作说明。
  5. 是否有回归问题:无。非空视图 / 非 doomed 体路径行为不变;doomed 门只在数学上必然 400 的体上收紧;文案纯追加。已逐项过既有行为,无高危模式命中。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及(host 侧 preflight 局部修正;零折叠修复由 master 既有 payloadFitsWindow 承接)。
  8. 是否引入新配置:无新 env / config / 默认值。

判定:可合(仅剩人工合并)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] (ai: qwen3.8-27b) 已对 PR #5275 新头 25f15c1aa 完成复审(GitHub review 已提交,review_id 5894004049,COMMENT 状态——自批被禁,因审核者身份=PR 作者)。

关键发现(与上轮不同:本次 re-merge 改变了 PR 内容,已重新独立核验,非沿用上轮「字节一致」结论)

八问

  1. 是什么问题:漂移后 kernel 变换失败(processedMessages 清空)时,preflight 若按空数组判 fit 会把 ~50MB/550万 token 原始史原样转发上游必然 413 且每轮白传;任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 逃生对 doomed 体也会白转。
  2. 什么原因:fit 判定须度量「实际要发的视图」(fix: arm emergency shrink on outbound payload size, not raw body (#1493) #1498-F2 原始体回退)而非空数组;任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 逃生缺字节兜底门;fail-fast 文案缺可操作说明。
  3. 影响范围/严重度:仅「漂移重放原始史+变换失败」或「任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 撞 doomed 体」触发;触发即整轮不可用+每轮白传几十 MB(p1);其余路径零变化。
  4. 怎么修:① 零折叠 fit 判定由 master 既有 payloadFitsWindow 覆盖(PR 仅补注释);② 任何一轮没有拿到 usage 报告的请求,都会把上下文分母放大 12–20×(nudge 读到 >1000% usage、假 EMERGENCY、基线冻结数分钟) #1839 逃生前加 doomed-bytes 门,超阈值本地 fail-fast;③ fail-fast 文案在 epochConfirmPending 时追加可操作说明。
  5. 回归:无——非空视图/非 doomed 体路径不变,doomed 门只在数学上必然 400 的体上收紧,文案纯追加。
  6. 破坏缓存:不涉及。
  7. 改设计方向:不涉及(host 侧局部修正;零折叠修复由 master 既有 payloadFitsWindow 承接)。
  8. 新配置:无。

判定:可合(仅剩人工合并)。无机械小修可补,无遗留。

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

bug Something isn't working p2 scope/other

Projects

None yet

1 participant