Skip to content

[PR] fix(omp): arm the direct-send window guard so a proxy outage cannot egress an oversized history (#5032) - #5077

Open
ranxianglei wants to merge 10 commits into
masterfrom
2026-10-28_omp-direct-window-guard-5032
Open

ranxianglei wants to merge 10 commits into
masterfrom
2026-10-28_omp-direct-window-guard-5032

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes the omp half of #5032 (the opencode half is external contribution #5037).

What & why

Same failure as #5025 on the pi lane: with no live proxy, the native intercept degrades to direct send, and the shared oversize arm in directSendOrRefuse (src/agent/native-intercept.ts) had no window to measure against on omp — the lane never armed declaredWindowForDirect. Result: multi-MB raw history egresses uncompressed and loops on upstream 400s until the proxy recovers.

The window source is the client-declared value ctx.model.contextWindow from the before_provider_request event — the same number reportOmpRuntimeInfo (src/agent/pi.ts, #1531/#955) already ships server-side as source: "client-config", i.e. exactly what the proxy enforces. No new config surface, no registry lookup (which would measure a different value than the proxy enforces).

Changes

Behavior change (flagged)

  • Old: omp direct send with no live proxy egressed any-size body (fail-open) → upstream 400 loop, session unusable until the proxy recovered.
  • New: once the client has declared a context window, a provably-oversized body (>4MB floor, same as the dsh/pi arms) is refused locally with HTTP 422 x-bili-gate: oversize-refusal-fallback before anything egresses. Bodies that fit are byte-for-byte unchanged; clients with no declared window still fail open.

Merge order

This branch reuses symbols introduced by #5027 (piDeclaredWindow, piDeclaredWindowForDirect); merge #5027 first. The head is stacked directly on #5027's head, so this diff view includes #5027's files until then. It does NOT depend on #5037 (disjoint files).

Verification (head 8e669d7, stacked on #5027 head 8ffff3a)

  • targeted: tests/issue5032-omp-direct-window.test.ts + tests/issue5025-pi-direct-window.test.ts — 10/10 pass
  • adjacent: tests/issue4894-direct-window-guard.test.ts, tests/pi-native.test.ts, tests/issue3433-pi-incremental-guard.test.ts, tests/issue2072-native-caller-stamping.test.ts, tests/fix-1897-leaked-tools-side.test.ts — 38/38 pass
  • npm run typecheck clean
  • full-suite verdict: remote CI on the pushed head

adlternative and others added 2 commits October 28, 2026 14:02
…not egress an oversized history (#5025)

Without a live proxy, directSendOrRefuse measured the raw body against a
window it read from the stamped x-bili-plugin-context-window header or from
state.declaredWindowForDirect. On the pi lane BOTH were empty on exactly that
path: before_provider_headers returns at `proxyBase === undefined` before it
stamps the header, and the lane never armed the slot (#4894 armed dsh only).
The check then failed open by construction, so a long session's unfurled
history (multi-million tokens) went straight to the provider, whose
"input exceeds the context window" 400 repeated on every retry and made the
session unrecoverable for as long as the proxy stayed down.

Record the per-request ctx.model.contextWindow at the TOP of the headers hook
(before the readiness return) and arm it as declaredWindowForDirect in
pi-native.ts. An unknown window records undefined — the guard keeps failing
open instead of guessing — and a healthy proxy is unchanged, since the
stamped header still outranks the reader.

Verification: tests/issue5025-pi-direct-window.test.ts (5 cases: recording
before the early return, unknown-window reset, the armed reader, local
oversize refusal with no upstream egress, and no false refusal when the body
fits); typecheck; issue4894/pi-native/issue3433/issue2072/fix-1897 suites;
unused-export and test-import-graph gates.
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-28_omp-direct-window-guard-5032 (1eaf49a)

Latest build — install this exact version

npm install -g billion-context@0.0.10905-pr.5077.c566fa1

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
1eaf49a billion-context@0.0.10905-pr.5077.c566fa1 build
e2d66be billion-context@0.0.10297-pr.5077.5c6adbf build
810b26c billion-context@0.0.10288-pr.5077.da418e3 build
5912250 billion-context@0.0.9009-pr.5077.ef9d565 build
7eedebe billion-context@0.0.7240-pr.5077.4f9499e build
b3953f9 billion-context@0.0.7124-pr.5077.7a15676 build
8e20312 billion-context@0.0.6905-pr.5077.4f75474 build
8e669d7 billion-context@0.0.6679-pr.5077.3509fe1 build

Download artifact

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(omp): arm the direct-send window guard so a proxy outage cannot egress an oversized history (#5032) [PR] fix(omp): arm the direct-send window guard so a proxy outage cannot egress an oversized history (#5032) Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。本 PR 即 #5032 清单里「omp 半边」的修复本体;open+closed 按失败签名(declaredWindowForDirect / oversize-refusal-fallback / direct window guard)重查无其他条目或在途 PR 覆盖 omp 车道。同家族条目关系:#5027 = pi 半边(本 PR 叠在其 head 之上,需先合),#5037 = opencode 半边(文件不相交,无依赖)。

标签: bug, omp, scope/wiring, p1 —— 缺陷类;缺的是 native-intercept 共享护栏的接线(协议接线层);严重度与 #5032/#5025 同级——代理宕机期间超窗 omp 会话每次重试重发整个未折叠历史 → 上游 400 死循环,会话完全不可用 = 用户不能用,p1。

开始审核:方向核对(原 issue #5032)→ 回归清点(触碰路径既有行为)→ 代码与测试有效性 → CI 状态(读镜像缓存)。结论按八问体例回复,稍候。

@ranxianglei ranxianglei added bug Something isn't working omp p1 scope/wiring labels Oct 29, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

审核结论:可合并——唯一前置条件是先合 #5027(stack base)。 查重:不重复(omp 半边,与 #5027/pi、#5037/opencode、#4894→#4904/dsh 各占一车道)。

按八问逐项:

  1. 是什么问题:omp 车道在代理不可用时,native intercept 降级为直发,而共享的超尺寸守卫(directSendOrRefuse)在 omp 上没有窗口可量——结果多 MB 原始历史不经压缩直接出网,上游一路 400 循环,直到代理恢复会话才可用。与 pi 车道的 pi lane: no-proxy direct send is unguarded — oversized raw history egresses and blows the provider window #5025 同族故障。
  2. 什么原因导致的:共享守卫的第二窗口源(lane reader declaredWindowForDirect)此前只给 dsh([PR] fix(#4894): arm the direct-fallback oversize guard on dsh not-ready sends #4904)和 pi([PR] fix: arm the pi lane's direct-send window guard so a proxy outage cannot egress an oversized history #5027)装过枪,omp 从未装过——omp 不触发 before_provider_headers(pi 用那条缝),它唯一的发送前缝是 before_provider_request(omp one-shot (-p) first request claims proxy mode — identity registration races the single dispatch (same class as #1214) #1230:runner 会 await 该 handler 再发请求)。属于「接线缺失」,不是设计缺陷。
  3. 影响范围与严重程度:仅 omp 客户端 × 代理宕机这一降级路径;正常期流量零影响(守卫只在无活代理时才被走到)。严重度 p1:降级期任意尺寸请求裸奔出网、成本浪费 + 400 死循环,期间会话不可用。
  4. 怎么修复的:在 before_provider_request handler 最顶部(任何 await 之前)为 omp agent 记录 ctx.model.contextWindow(未知/缺失即清空,fail-open,绝不猜),omp-native 把该 reader 装进 state.declaredWindowForDirect。窗口来源我逐行核对过:与 reportOmpRuntimeInfo(src/agent/pi.ts:1398,[native] runtime-info protocol: plugins report real model config (model / contextWindow / maxOutput) to the proxy #955/[Bug][OMP native][0.1.163] contextWindow 上报后仍使用 registry 窗口,runtime-info 存在跨会话覆盖 #1531)上报给服务端的 source:"client-config" 是同一个数——正是代理强制执行的值,所以本地守卫量的和线上量的一致。无新配置面、无 registry 查询(那会量到另一个值)。本 PR 的校验比上报路径更严(多了 Number.isFinite,上报路径对 Infinity 是放行的既有小瑕疵,非本 PR 引入)。
  5. 是否有回归问题:逐项审了触碰路径的既有行为——
  6. 是否破坏缓存:不影响。前缀缓存、会话账本、重试游标、去重键均未触碰;被拒请求是本地 422,不出网不进缓存。
  7. 是否改了设计方向:没有。按 omp/opencode lanes: oversized history egresses uncompressed when the proxy is down — direct-send window guard still unarmed (#5025 family residual) #5032 指定的 per-lane 配方走(请求缝记录 + 装共享守卫 + 双向测试),修的是根因(补上缺失的窗口源),不是治标(拦 400)。
  8. 是否引入了新的配置:无。无 env、无配置文件字段、无 CLI flag。

测试有效性:5 个用例全 hermetic、走真入口(createBiliPlugin/installNativeFetchIntercept),fake fetch sink 数出网次数,双向齐全(#3617):超尺寸 → 本地 422 + x-bili-gate: oversize-refusal-fallback + 零出网;放得下 → 直发、恰好一次出网、字节不变;外加 record-before-await(降级路径也记录)、unknown-window-clears、arm-in-place。断言有牙:装枪回归 → 用例 4 会出现出网变红;误拒 → 用例 5 变红。两个非阻塞小缺口:header-vs-reader 优先级无专测(已由 issue4894/issue5025 套件覆盖共享守卫)、ctx.model 整体缺失无专测(optional chaining 下行为与 contextWindow 缺失相同)。

CI:#5077 head 8e669d7a8 全绿(17 success + 13 skipped,0 failed,镜像缓存核对 sha 一致)。⚠️ 一个观察:#5027(head 8ffff3a31,未动)在镜像缓存里的最近一次 CI 显示 cancelled——其全部 diff 虽已在 #5077 的绿色运行里被验证,但建议合 #5027 本体前触发一次新鲜绿跑。另一个小观察(非阻塞):PR 正文写 "Fixes the omp half of #5032",合并后 GitHub 会自动关掉 #5032,而 opencode 半边(#5037)可能还在途——需要的话 reopen 即可。

判定:可合并。 合并顺序:#5027 → 本 PR(与 #5037 无依赖,文件不相交)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) Merged origin/master into the PR branch (clean, no conflicts) and pushed — head is now 8e20312, at parity with master; CI is running on the new head (0 failed so far, remaining jobs queued).

ci-check added 2 commits November 11, 2026 05:24
… inline default flip arms an origin waiter at import time that resolves the inline pseudo-origin, so awaitNativeProxyOrigin() no longer stays undefined and the direct-send early return this suite pins is never reached (manifest fetch lands in the hermetic sink); set BILI_PI_INLINE=0 before a dynamic pi-native import (same pin family as e2e-native-pi #4599, same import idiom as issue1958-routed-warn.test.ts)

@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: vllm-qwen/qwen3.8-27b)

Verdict: APPROVE (posted as a comment-style review — GitHub rejects event=APPROVE from this account because it authored the PR; the approval judgment stands as written below) — the omp half of #5032 is correct, complete, and well-pinned. Verified independently against master @ 58a8796 (= PR base; the branch contains the current master tip, so the effective merged state is exactly this diff).

Direction (issue #5032): the failure is real and the diagnosis is right. On a degraded direct send, directSendOrRefuse resolves its window as declaredWindowFromHeaders(...) ?? state.declaredWindowForDirect?.() (src/agent/native-intercept.ts:1804); omp never fires before_provider_headers (confirmed by four pre-existing code comments: src/agent/omp-native.ts:14, src/agent/pi.ts:1351, :1377, :1589), stamps no header, and had never armed the reader — so the guard silently failed open in exactly the outage state it exists for. Supplying the missing window input at the arm (rather than filtering payloads in transit) is the right layer.

Correctness:

  • The recording seam is omp's only per-request event (before_provider_request), recorded synchronously as its first statement — before any await — so it lands even when every readiness await below degrades to wire mode. Gated on agent === "omp"; the only createBiliPlugin consumers are pi (default) and omp (grep-verified across src/), so no cross-lane writer race in one process.
  • Window source = ctx.model.contextWindow, byte-for-byte the value reportOmpRuntimeInfo already ships server-side as source: "client-config" (src/agent/pi.ts:1398–1401) — the guard measures what the proxy enforces. Unknown/absent ⇒ cleared ⇒ fail-open; never guessed.
  • The arm sits with the other module-level arms in src/agent/omp-native.ts (same object, same process lifetime as prepareDirectSend/beforeSend); header precedence over the reader is untouched; all degraded call sites funnel through the one chokepoint.
  • Stacked #5027 content (pi lane) sanity-checked: identical pattern, its own suite green; the "merge #5027 first" note stands (those symbols are not yet on master).

Regression audit (prior behavior on touched paths):

  • before_provider_headers: two synchronous statements added at the top of the existing try — no awaits inserted, no early return moved, rest byte-identical.
  • before_provider_request: zero change for the pi lane (gated); omp gains one non-throwing sync read at the top.
  • Degraded omp sends WITHOUT a declared window: reader returns undefined ⇒ measurement skipped entirely (no clone, no buffer) ⇒ byte-identical to pre-PR.
  • Fitting bodies: doom check passes ⇒ direct send proceeds unchanged (pinned by test 5).
  • Wire/proxy-mode paths, config surface, persistence, kernel/: untouched.
  • One intended feed: the resolved window also reaches noteResolvedContextWindow (native-intercept.ts:1805, #5996 empty-slot doom check) — a designed consumer, same value class.

No unintended regression found.

Behavior change (disclosed in PR body; wording is accurate): OLD — once omp's proxy died, any-size history egressed uncompressed → upstream "input exceeds context window" on every retry, unrecoverable while down. NEW — when the client declared a window, bodies whose core text provably exceeds it are refused locally (HTTP 422, x-bili-gate: oversize-refusal-fallback, retryable wording), zero egress; everything else unchanged.

Tests: five cases pin BOTH directions per #3617 (record-before-await / unknown-clears / arm-in-place / oversized → local 422 + empty egress sink / fitting → 200 + egress intact). Assertions have teeth: disarming the reader flips case 4 to 200+egress; a false refusal flips case 5. Hermetic like the sibling suites (XDG_STATE_HOME redirect, env save/restore, fetch stub restored in finally, _resetForTest). The new file needs no registration — CI shards by the readdirSync(testsDir) glob. Ran locally on the PR head: 15/15 (issue5032-omp + issue5025-pi + issue4894 shared-guard) and 161/161 across adjacent suites touching these modules (omp-native, pi-native, native-intercept, issue5032-opencode, omp-native-identity, issue1958-routed-warn). Remote CI on head 5912250: all check-runs completed green (37 success + 13 skipped, 0 failures) — verified with a single check-runs GET because the mirror snapshot was ~17h stale with pendings still listed.

Note: the opencode half already landed on master (6393e0b, tests/issue5032-opencode-direct-window.test.ts) — no overlap. No small findings requiring fixes.

八问(中文):

  1. 是什么问题:omp 车道在代理挂掉降级直发时,把超大历史不加压缩直接发给上游;上游必然 400,且每次重试重发同样内容——代理恢复前该轮永远卡死(#5025 家族在 omp 上的残留)。
  2. 什么原因导致的:共享超限守卫的窗口来源有两个——请求头 x-bili-plugin-context-window 与车道自装的 declaredWindowForDirect 读取器;omp 从不触发 before_provider_headers、从不打该头,而本 PR 之前也没装读取器,两个来源在降级路径上恒空 ⇒ 守卫整体失效(fail-open)。
  3. 影响范围与严重程度:仅 omp 原生车道 + 代理故障窗口期;期间历史超出模型窗口时完全不可用(整轮卡在上游 400 循环)——特定条件下的可用性缺陷;窗口内请求与无声明窗口的场景不受影响。
  4. 怎么修复的:在 omp 唯一逐请求事件(before_provider_request)最前面同步记录客户端声明的 ctx.model.contextWindow(与 reportOmpRuntimeInfo 上报的 client-config 同值),并在 omp-native 模块级把该读取器装进共享守卫——治本(补上守卫缺失的输入),不在传输层过滤。
  5. 是否有回归问题:逐项审过既有行为——headers 处理器仅在原 try 顶部加两条同步语句;request 处理器对 pi 车道零改动(有 agent 门);无声明窗口的降级发送仍完全跳过测量(不克隆不缓冲,字节级不变);窗口内请求直发字节级不变;wire/proxy 模式、配置面、持久化、kernel 均未触碰。未发现无意回归。
  6. 是否破坏缓存:不涉及——不改任何缓存/重试/游标/去重键;唯一新增数据流是解析出的窗口喂给 #5996 的空槽 doom 检查(native-intercept.ts:1805),本就是设计好的消费方且值同源。
  7. 是否改了设计方向:未转向——沿用 #4894/#5027 既定的「车道供窗、共享守卫测量」架构,只是补齐 omp 这一格;opencode 半区已在 master(6393e0be85),无重叠。
  8. 是否引入了新的配置:无新配置/env/默认值;行为变更已在 PR 正文披露(旧:任意大小放行→上游 400 循环;新:已声明窗口且核心文本可证超窗时本地 422 x-bili-gate: oversize-refusal-fallback、零出站,其余不变)。

判定:可合并(已提交 APPROVE review)。 合并顺序提示:本 PR 堆叠在 #5027 之上(其符号随本 diff 带入),请按 PR 自身说明先合 #5027。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] Review done: PR #5077 verdict APPROVE — posted as PR review id 5862121009 (comment-style because GitHub rejects event=APPROVE from the author's own account; explicit approval judgment in the body). The omp half of #5032 correctly arms the shared direct-send window guard (records client-declared ctx.model.contextWindow synchronously at the top of omp's only per-request event, reader installed module-level beside its siblings); direction/correctness/regression/tests verified independently against master @ 58a8796, 176 targeted tests green locally on head 5912250 and remote CI all-green (37 success + 13 skipped); behavior change disclosed accurately; no findings, no kernel involvement. Merge-order note: stacked on #5027 — merge that one first per the PR body.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

# Conflicts:
#	src/agent/omp-native.ts
#	tests/issue5025-pi-direct-window.test.ts
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Conflict resolved and re-merged — PR is mergeable again, CI running on the new head.

What I did this run:

  1. Live state check first: PR was dirty (conflict), 618 master commits ahead of the branch head 59122503c3; the previous head's CI was fully green (mirror cache: 30 checks, 0 failed, 0 pending). Remote branch head unchanged — no concurrent agents.
  2. Merged origin/master into the PR branch (merge, not rebase — no force-push needed). Two conflicts:
  3. Final PR diff vs master is now minimal — 3 files, +193/−1: src/agent/pi.ts (+11, the omp-only window recording in before_provider_request), src/agent/omp-native.ts (+11/−1, arm + test hook), tests/issue5032-omp-direct-window.test.ts (+172, 5 tests).
  4. Local verification on the merged tree: typecheck clean; both direct-window test files 10/10; adjacent suites (issue4894-direct-window-guard, omp-native, pi-native, native-intercept) 143/143; omp incremental/identity/fork-adopt suites 54/54; check-unused-exports clean (12 waived); check-test-import-graph ok.
  5. Pushed fast-forward 59122503c3..810b26cf3b (verified remote head unchanged before pushing; no force-push). Live PR state after push: mergeable: true, mergeable_state: blocked (checks in flight), head 810b26cf3b. Mirror cache at the new sha: 0 failed so far, gate lanes just queued — the test shards start after them; I'll pick up any red in a follow-up run.

八问

  1. 是什么问题: PR 与 master 再次冲突——上次合并后 master 又前进了 618 个提交,分支落后且 merge state 为 dirty。
  2. 什么原因导致的: 分支长期未合并,期间 master 在 src/agent/omp-native.ts 落了两个提交(Replay a stream cut that lands after reasoning-only output #5951 截断恢复、PI_ANTHROPIC_MESSAGE_THREADS=0 默认),且 pi 侧的 pi lane: no-proxy direct send is unguarded — oversized raw history egresses and blows the provider window #5025 修复经另一条 PR 独立合入 master 并新增了同名测试文件,与本 PR 产生 add/add 冲突。
  3. 影响范围与严重程度: 仅阻塞本 PR 合并,不影响任何已发布行为;PR 本身修复的缺陷(omp 直发窗口守卫缺失)仍是真实缺陷,未变。
  4. 怎么修复的: 合并 master 进分支;两处冲突均按「意图并集」解决——omp-native.ts 保留双方新增的 import 与测试钩子;pi 测试文件直接采用 master 已合入的规范版本(其 _resetNativeOriginWaiterForTest 修法优于我上次的 BILI_PI_INLINE=0 固定,故弃用旧版)。
  5. 是否有回归问题: 无。最终 PR diff 收敛为 3 文件 +193/−1,只含 omp 侧守卫;本地 typecheck + 207 个定向测试全绿,unused-exports / test-import-graph 守卫通过;未触碰 wire 形状、配置面、持久化格式。
  6. 是否破坏缓存: 不涉及。
  7. 是否改了设计方向: 不涉及。
  8. 是否引入了新的配置: 不涉及。

收工判定: 冲突已解决并推送(810b26cf3b),PR 恢复可合并状态,CI 在新 head 上运行中(当前 0 失败);若测试分片转红,由本车道后续跟进。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Red CI fixed — inherited master-level flake, not a regression from this PR.

The only red check was test (windows-latest, 22, 2), failing on tests/wire-exit-matrix.test.ts:314 → abort x proxy-responses-sse: client abort mid-stream destroys the upstream request (closed=0 assertion, 22143 ms). This is a known flaky test on master, already diagnosed and fixed on ci-fixes (commit 297709ef5, #4599 floors 1423/1426): abortAfterFirstByte's 400 ms fallback fired before the proxy forwarded the first request on slow runners, so the proxy sent nothing upstream (requests=0) and the teardown assertion saw closed=0. Longer budgets can't fix it (the abort already happened). The fix adds a ready predicate (up.requests() >= 1) so the abort only fires once the proxy has actually forwarded.

This PR only arms the omp direct-send window guard (src/agent/omp-native.ts, src/agent/pi.ts, + new test) and does not touch the abort/teardown path — the flake is unrelated to the change.

Action taken (per owner policy 2026-10-24 CI coordination — inherited red converges on ci-fixes, not re-fixed per-branch):

  • Merged origin/ci-fixes (head 297709ef5) into the PR branch → new head e2d66bea41.
  • The merge brought in only the 3 test-file fixes (wire-exit-matrix ready-predicate, storage-durability chk-cache, issue4612-gc-online-guard batch insert); the PR's own 3 files are untouched.
  • Verified locally: typecheck clean; wire-exit-matrix 8/8 pass (all 4 abort cells green).
  • Pushed to 2026-10-28_omp-direct-window-guard-5032. CI re-running on the new head.

Note: the mirror check-cache was stale (poller stuck, fetched_at frozen ~87 min), so I verified the true check state with a single bounded GitHub API call before acting.

八问(中文):

  1. 是什么问题:红 CI 是 test (windows-latest, 22, 2) 分片,失败在 tests/wire-exit-matrix.test.ts:314 的 abort x proxy-responses-sse 用例(closed=0)。这是 master 侧已知 flaky 测试,非本 PR 引入。
  2. 什么原因导致的:abortAfterFirstByte 的 400ms 兜底在慢 runner 上先于 proxy 转发触发 → proxy 未往上游发(requests=0)→ 等满 budget 后 closed=0 断言失败。本 PR 只动 omp 直发窗口 guard,不碰 abort/teardown。
  3. 影响范围与严重程度:仅 Windows 慢 runner 上这一个 abort 用例,纯 CI 噪声,不影响产品行为;其余 9 个 test 分片 + 2 个 static-gates 全绿,同 run 兄弟 abort 用例(anthropic-sse/json)也绿。
  4. 怎么修复的:继承性 master 红不自己修——把哨兵收敛在 ci-fixes 的修复(297709ef5,abortAfterFirstByte 加 ready 谓词 up.requests() >= 1,四个 abort 用例都传)merge 进 PR 分支,本地 typecheck + wire-exit-matrix 8/8 验证后 push。
  5. 是否有回归问题:无。merge 只带入 3 个测试文件修复,本 PR 自己 3 个文件未触碰;无产品代码变更、无行为漂移。
  6. 是否破坏缓存:不涉及(纯测试修复)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

结论:红 CI 已修(继承性 flaky 测试,merge ci-fixes 修复),CI 在新 head e2d66bea41 上重跑中;本 PR 功能(omp 直发窗口 guard)未受影响,等 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: vllm-qwen/qwen3.8-27b)

Verdict: APPROVE (comment-style review again — GitHub rejects event=APPROVE from the author's own account; the approval judgment stands as written). Re-review of the updated head e2d66be; round 1 (review id 5862121009) covered 5912250.

What changed since the last review: two merge commits only (origin/master + origin/ci-fixes into the PR branch — the standard CI-failure coordination flow); no new content commits by the author.

  • The PR's own content is byte-identical to what round 1 reviewed: the 11-line if (agent === "omp") window-recording block at the top of before_provider_request (src/agent/pi.ts:1553), the module-level arm state.declaredWindowForDirect = piDeclaredWindowForDirect + test hook (src/agent/omp-native.ts:222, :467), and the 172-line two-direction test file (tests/issue5032-omp-direct-window.test.ts).
  • The stacked #5027 (pi lane) has since merged to master (piDeclaredWindowForDirect now at src/agent/pi.ts:880 on master) — the effective diff shrank accordingly and the merge deduplicated cleanly. The 3-dot diff against the current master tip (e0d63bf, which the branch contains → zero drift) carries only the omp hunks; no conflict-resolution damage.
  • The ci-fixes merge rides three flaky-test fixes (all byte-identical to origin/ci-fixes — the sanctioned sentinel flow): tests/issue4612-gc-online-guard.test.ts (21k autocommit inserts collapsed into one transaction — fsync perf, #4599, no assertion change), tests/storage-durability.test.ts (drops the #4609 verdict cache after corrupting the db so quick_check re-runs from fresh evidence, no assertion change), tests/wire-exit-matrix.test.ts (abortAfterFirstByte now waits up to 5 s for the proxy to actually forward before destroying the socket, with a done-guard against double-resolve — teardown assertions unchanged). All three are setup/timing fixes, not assertion weakening.

Verification on the new head: locally 15/15 core (issue5032-omp + issue5025-pi + issue4894 shared guard) and 183/183 across the three ci-fixes files plus the adjacent suites (omp-native, pi-native, native-intercept, issue5032-opencode, omp-native-identity, issue1958-routed-warn). Remote CI on e2d66be: all check-runs completed green (37 success + 13 skipped, 0 failures) — verified with a single check-runs GET; the mirror snapshot was captured mid-run with 11 pendings.

No kernel/ involvement, no new findings, no small fixes needed. The behavior-change disclosure in the PR body (fail-open egress → local 422 x-bili-gate: oversize-refusal-fallback when the client declared a window and the core text provably exceeds it) remains accurate. The round-1 merge-order note ("merge #5027 first") is now moot — #5027 is on master, so this PR can merge directly.

八问(中文):

  1. 是什么问题:omp 车道在代理挂掉降级直发时,把超大历史不加压缩直接发给上游,上游必然 400 且重试重发同样内容,代理恢复前该轮永远卡死(#5025 家族残留)。
  2. 什么原因导致的:共享超限守卫的两个窗口来源(请求头 + 车道自装读取器)在 omp 降级路径上恒空——omp 从不触发 before_provider_headers,本 PR 之前也没装读取器 ⇒ 守卫整体失效(fail-open)。
  3. 影响范围与严重程度:仅 omp 原生车道 + 代理故障窗口期;历史超窗时完全不可用(400 死循环)——特定条件下的可用性缺陷;窗口内请求与无声明窗口场景不受影响。
  4. 怎么修复的:在 omp 唯一逐请求事件最前面同步记录客户端声明的 contextWindow(与 reportOmpRuntimeInfo 上报的 client-config 同值),模块级装进共享守卫——补上守卫缺失的输入(治本),不在传输层过滤。
  5. 是否有回归问题:逐项审过——pi 车道零改动(agent 门);无声明窗口的降级发送仍完全跳过测量(不克隆不缓冲,字节级不变);窗口内请求直发不变;wire/proxy 模式、配置面、持久化、kernel 未触碰;本轮经 ci-fixes 带入的三个测试文件改动均为 flaky 修复(事务化插入 / 清判定缓存 / 等转发再断连),断言未削弱。未发现无意回归。
  6. 是否破坏缓存:不涉及——不改任何缓存/重试/游标/去重键;解析出的窗口喂给 #5996 空槽 doom 检查是设计好的消费方且值同源。
  7. 是否改了设计方向:未转向——沿用 #4894/#5027「车道供窗、共享守卫测量」架构,补齐 omp 一格;opencode 半区与 pi 半区均已在 master,无重叠。
  8. 是否引入了新的配置:无新配置/env/默认值;行为变更披露保持准确(旧:任意大小放行→上游 400 循环;新:已声明窗口且核心文本可证超窗时本地 422、零出站,其余不变)。

判定:可合并(APPROVE)。 本轮 head 已包含当前 master tip(e0d63bf8c8),无堆叠依赖残留,可直接合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] Re-review done on updated head e2d66be: verdict APPROVE (PR review id 5914800978, comment-style because GitHub rejects self-approval). Since round 1 the branch only gained two merge commits (origin/master + origin/ci-fixes, standard CI-coordination flow): the PR's own omp-guard content is byte-identical to what was already approved in round 1, the stacked #5027 has since merged to master so the effective diff now carries only the omp hunks (3-dot diff vs current master tip e0d63bf, which the branch contains — zero drift), and the ci-fixes merge rides three flaky-test fixes that are byte-identical to origin/ci-fixes with no assertion weakening. Verified on the new head: 198 targeted tests green locally (15 core + 183 ci-fixes/adjacent), remote CI all-green (37 success + 13 skipped, 0 failures). No kernel involvement, no findings, no open ends — the round-1 "merge #5027 first" note is moot, PR can merge directly.

Resolve conflict in src/agent/omp-native.ts: keep master's createOmpDirectSendGuard() (side-lane strict guard + prompt_cache_key drop) AND the PR's #5032 window arm (state.declaredWindowForDirect = piDeclaredWindowForDirect). Union of the ./pi.js import.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Resolved the merge conflict on this PR branch and pushed the merged head.

What I did this run

  • The PR branch 2026-10-28_omp-direct-window-guard-5032 (head e2d66bea41) conflicted with master (a446a3c1c8) in exactly one file, src/agent/omp-native.ts — both sides had changed the ./pi.js import line and the state.prepareDirectSend guard line.
  • Resolved by union: kept master's createOmpDirectSendGuard() (the side-lane strict guard, which internally still calls createPrepareDirectSend() and additionally drops the prompt_cache_key) and this PR's #5032 window arm (state.declaredWindowForDirect = piDeclaredWindowForDirect). The ./pi.js import now carries both createOmpDirectSendGuard and piDeclaredWindowForDirect; the ./incremental-client.js import auto-merged to master's form (no longer references createPrepareDirectSend directly, which is correct since the guard now wraps it).
  • Verified locally: npm run typecheck clean; targeted tests green — tests/issue5032-omp-direct-window.test.ts 5/5, and omp-direct-send-stamped-pck + issue3304-incremental-direct-send + issue4894-direct-window-guard + omp-native 57/57.
  • Pushed the merge commit 1eaf49a195 to the PR branch. (The local mirror git endpoint was returning 502 throughout this run while its API was up, so I pushed directly to GitHub via the upstream remote; the credential helper supplies the token. The Gitea mirror will re-sync from GitHub on its next poll.)
  • Confirmed live: PR merge state is now mergeable: true — the conflict is gone. mergeable_state: "blocked" is the pending-required-review gate, not a merge conflict.

八问 (structured review)

  1. 是什么问题: PR 分支与 master 冲突(merge state dirty),src/agent/omp-native.ts 的 import 行和 direct-send guard 行被两边同时改动。
  2. 什么原因导致的: master 侧的 side-lane 工作把 state.prepareDirectSend 从 createPrepareDirectSend() 换成 createOmpDirectSendGuard()(并从 ./incremental-client.js import 移除 createPrepareDirectSend),本 PR 在同一区域加了 #5032 window arm 并在 ./pi.js import 加 piDeclaredWindowForDirect——两处改动文本重叠成冲突。
  3. 影响范围与严重程度: 仅本 PR 分支的合并状态;不修则 PR 无法合并(blocked)。代码行为无影响——冲突只是文本重叠,两边改动都正确且正交。
  4. 怎么修复的: 取并集——保留 master 的 createOmpDirectSendGuard() + 保留本 PR 的 #5032 window arm;./pi.js import 合并为 createBiliPlugin, createOmpDirectSendGuard, piDeclaredWindowForDirect。
  5. 是否有回归问题: 无。两边改动都保留:master 的 side-lane guard 行为不变,本 PR 的 window arm 不变。declaredWindowForDirect 字段(native-intercept.ts:135)仍存在、消费点 :1805 不变,其他 lane(dsh/opencode/pi-native)都 arm 它——一致。定向测试 57/57 + 5/5 通过。
  6. 是否破坏缓存: 不涉及。只解决合并冲突,未改任何缓存/重试/游标逻辑。
  7. 是否改了设计方向: 不涉及。只是把 master 的 side-lane guard 和本 PR 的 window arm 合到一起,无架构/数据流转向。
  8. 是否引入了新的配置: 不涉及。

判定: 冲突已解决并推送(head 1eaf49a195),PR merge state 已转 mergeable: true,剩余 blocked 为待 review 门禁。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-verified live before acting: the conflict is already resolved. The PR branch head is 1eaf49a195 (the merge commit from my previous run, which merged origin/master and resolved the src/agent/omp-native.ts conflict by union). GitHub reports mergeable: true — no merge conflict remains. mergeable_state: "blocked" is the pending-required-review gate, not a conflict.

No further work needed this run.

@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: vllm-qwen/qwen3.8-27b)

Round 3 — head 1eaf49a195 (merge of master a446a3c1c8 into the PR branch).

What changed since round 2: a single merge commit. The effective 3-dot diff against current master shrank from 6 files to exactly the 3 PR files — the three ci-fixes flaky-test fixes landed on master and dropped out of the diff. The PR now contains the current master tip (zero drift, mergeable).

Re-verified on the new head:

  • src/agent/pi.ts (+11): the record block is byte-identical and still the FIRST statement of before_provider_request (before any await) — now at pi.ts:1705, if (agent === "omp") at :1712.
  • src/agent/omp-native.ts (+11): arm + test hook unchanged; the arm sits right after master's state.prepareDirectSend = createOmpDirectSendGuard(); line.
  • tests/issue5032-omp-direct-window.test.ts (+172): unchanged from rounds 1–2.

New master interaction checked (642124b, "drop the stamped prompt_cache_key on a direct send"): master swapped omp's prepareDirectSend from createPrepareDirectSend() to createOmpDirectSendGuard() (pi.ts:972 — wraps the shared prepare, strips the stamped prompt_cache_key from the outgoing text body). Composition with this PR's arm is safe by ordering: directSendOrRefuse (native-intercept.ts:1729) invokes state.prepareDirectSend FIRST (hook at :1667, unrestorable check at :1736), then resolves the window at :1805 (declaredWindowFromHeaders(...) ?? state.declaredWindowForDirect?.()), then the doom check. So the pck wrapper runs inside prepare, before measurement — the doom meter sees the actual egress bytes; the PR's arm is consumed downstream and is orthogonal; the wrapper only shrinks body text (and passes unrestorable through untouched), so it cannot turn a refusal into an egress. The wrapper is independently pinned by its own suite (tests/omp-direct-send-stamped-pck.test.ts), and the PR's arm is pinned by cases 3–5 of the PR suite. No finding.

Tests: local targeted 19/19 core (issue5032-omp 5 + issue5025-pi 5 + issue4894 5 + omp-direct-send-stamped-pck 4) + 164/164 adjacent (omp-native, pi-native, native-intercept, issue5032-opencode, omp-native-identity, issue1958-routed-warn) = 183 green on the new head. CI on 1eaf49a195: 37 success + 13 skipped, 0 failures.

Behavior change (disclosed in the PR body, still accurate): OLD — with the proxy down, an oversized omp history egressed direct to the upstream and looped on upstream 400s (the window reader was always empty ⇒ measurement skipped ⇒ fail-open). NEW — when the client has declared a window and the body is provably oversized, the send is refused locally with 422 + x-bili-gate: oversize-refusal-fallback (retryable) and nothing egresses. Fitting bodies and the no-window path are byte-identical to before.

No kernel/ touched, no kernel-change declaration, no config surface. No findings this round — nothing to fix, no decisions needed.


八问(中文):

  1. 是什么问题:omp 车道的直发窗口守卫没被装弹——omp 从不触发 before_provider_headers,窗口读取器永远为空,代理宕机时超大历史直接发往上游,陷入上游 400 循环。
  2. 什么原因导致的:共享守卫的窗口来源只有两条路——请求头或 state.declaredWindowForDirect;omp 没有盖头缝(无 before_provider_headers),而 state 字段无人写入,守卫只能整轮跳过测量、fail-open。
  3. 影响范围与严重程度:仅 omp 车道 + 代理宕机的降级直发路径。修复前:超大历史直发上游(上游 400 循环,用户表现为请求失败);修复后:本地 422 拒绝、客户端可回退。适配体与无窗口路径不变。
  4. 怎么修复的:在 omp 唯一的每请求缝 before_provider_request 里,在任何 await 之前同步记录 ctx.model.contextWindow 到模块级变量,并把读取器写入 omp-native state 的 declaredWindowForDirect,复用共享守卫既有的消费点(native-intercept.ts:1805)——不新增任何测量/拒绝逻辑。
  5. 是否有回归问题:审过的既有行为——pi 车道(agent !== "omp" 短路,不变)、opencode 车道(独立,已在 master)、适配体直发路径(字节不变,case5 钉住)、无窗口路径(fail-open,case2 钉住清除)、unrestorable 拒绝臂(#3304,独立分支)、新合入 master 的 642124b pck 剥离(已验证组合顺序 prepare→测量→拒绝,互不干扰)。无回归。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/增量游标;pck 剥离是 master 自身行为(642124b004),非本 PR。
  7. 是否改了设计方向:不涉及——复用既有共享守卫消费点,无新架构。
  8. 是否引入了新的配置:不涉及——无新 env/config/CLI。

Verdict: APPROVE (comment-style — GitHub rejects event=APPROVE from the author's own account, so this review is posted as a comment carrying the approval verdict.)

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] PR #5077 round-3 review done (head 1eaf49a, master merge only — effective diff back to the 3 PR files): re-verified the arm + new-master interaction (642124b pck-strip composes safely, prepare→measure→refuse ordering), local 183/183 targeted, CI 37 success + 13 skipped / 0 failed. No findings. Review posted (id 5966664461, APPROVE verdict, comment-style).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[ework] CI fix verified green ✓

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 omp p1 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants