Skip to content

[PR] fix(opencode-lane): stop rewriting the shared http.request payload — route model traffic at fetch time (#5625) - #5626

Open
ranxianglei wants to merge 11 commits into
masterfrom
2026-11-04_opencode-fetch-time-routing
Open

ranxianglei wants to merge 11 commits into
masterfrom
2026-11-04_opencode-fetch-time-routing

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

Rework of PR #4280 (reverted by c076614 over a master conflict; original report #4276) on top of current master. Closes #5625.

What

The opencode-lane http.request hook used to replace e.request with a new Request pointed at ${proxyOrigin}/bili/<originalUrl>. opencode hands that one mutable event to every later http.request/http.response hook, including provider-scoped hooks from other plugins, so provider auth plugins validating the upstream URL broke:

  • Kiro (@servoy/opencode-kiro-auth): bridge silently stopped engaging → empty assistant responses after ~10 retries.
  • Antigravity (@cortexkit/opencode-antigravity-auth): threw "pool requests need the default Google base URL" before its own hook could run.

The routes now only DISCOVER the proxy (state.proxyBase; oversize refusal / direct-degrade on death) and leave the hook-visible payload untouched. Both setup()s install the shared native fetch intercept chain, which performs the /bili/ rewrite at fetch time. The WS handshake hook builds its own tunnel URL instead of relying on the rewritten request.

Config surface

No new fields. Completes the already-documented providers.<url>.direct (#1622) for the OpenCode V2 lanes — previously implemented only in the ZCode lane. Matching requests are marked biliDirect in the hook and sent direct by the chain; CONFIGURATION.md wording updated accordingly.

Behavior changes (disclosed per policy)

Tests

New tests/issue5625-opencode-v2-hook-payload.test.ts pins the hook payload contract (untouched request, fetch-time routing, pool dialect, direct exemption, child-process install gate); launcher/native suites updated to the fetch-time contract; the #4669 inline-composition test installs the chain like its sibling and asserts the hook keeps the payload intact. Local targeted runs green (3 suites, 75 tests) + typecheck clean; full-suite verdict = remote CI.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-04_opencode-fetch-time-routing (e61137d)

Latest build — install this exact version

npm install -g billion-context@0.0.11201-pr.5626.e850b6c

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
e61137d billion-context@0.0.11201-pr.5626.e850b6c build
538a8d4 billion-context@0.0.11033-pr.5626.bfdcfbc build
7c3c54d billion-context@0.0.10772-pr.5626.941835b build
a82b65e billion-context@0.0.10060-pr.5626.f1646a5 build
cb408bc billion-context@0.0.9370-pr.5626.676d036 build
7dad138 billion-context@0.0.9167-pr.5626.f4f2589 build
58f72ac billion-context@0.0.9152-pr.5626.00b11d8 build
629a10a billion-context@0.0.8059-pr.5626.86b0749 build
209b24b billion-context@0.0.8054-pr.5626.f275d70 build
50fc076 billion-context@0.0.8052-pr.5626.e64a5fd build

Download artifact

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

Install instructions are refreshed on each push.

ranxianglei pushed a commit that referenced this pull request Nov 3, 2026
… the fetch-time contract (#5625)

CI follow-up on PR #5626 head 58438f1:
- unused-exports gate: replaceRequestTarget had no remaining callers once the
  routes stopped rewriting e.request — removed.
- tests/opencode-native.test.ts: the #4669 V2-composition pin asserted the old
  hook-time rewrite; it now installs the chain like its sibling and asserts
  the hook keeps the payload intact while the chain rewrites at send time.
- tests/issue5625-opencode-v2-hook-payload.test.ts: the pool-endpoint pin
  predated #4256's classifier arm for the v1internal dialect (DSH Desktop
  Code-Assist traffic rides exactly that URL); it now asserts the post-#4256
  contract — the hook stays out of the provider plugin's way and the chain
  forwards the pool URL byte-preserving with no bili identity invented.
ranxianglei pushed a commit that referenced this pull request Nov 3, 2026
…#1248)

CI follow-up on PR #5626 head a40ef0f: every test shard died at the
#1248 SPAWN_RE tripwire because tests/issue5625-opencode-v2-hook-payload.test.ts
spawns node children (setup-gate probe) but was never registered. Concurrency
reviewed: three rows are in-process with a fake fetch sink (no sockets), the
probe server is listen(0), child env is mkdtemp-isolated — appended (slot = index
drives zone bands, mid-list inserts renumber later files).
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。 e-work 镜像检索("opencode http.request payload kiro antigravity"、"kiro auth bridge empty responses")无命中;GitHub open PR 检索只返回本 PR。本 PR 即被 revert 的 #4280(原始报告 #4276/#5625)的官方重做,无并行在途修复。

标签: bug, p1, scope/wiring, opencode, opencodev2, dsh(Kiro 用户拿到空回复、Antigravity 直接抛错——核心能力整体停摆 = p1;改动面是客户端接入层钩子管线;DSH Desktop Code-Assist 流量被披露的行为变更明确波及)。

审核结论(八问)

1. 是什么问题:opencode 车道的 http.request 钩子过去把每个模型请求的 URL 改写成 <proxy>/bili/<原URL>,而 opencode 把同一个可变事件对象递给之后所有钩子(包括 Kiro/Antigravity 这类 provider 鉴权插件),插件看到的是改写后的 URL:Kiro 静默失败 ~10 次重试后回空回复,Antigravity 直接抛 "pool requests need the default Google base URL"。

2. 什么原因导致的:根因是插件在钩子层改写了共享状态(e.request),而不是只决定自己的出站路由——钩子 payload 是宿主递给所有插件的共享基础设施,不是 bili 私有对象。fetch-time 改写方向正确:钩子只做发现/标记,真正的 /bili/ 改写发生在共享 native fetch 拦截链(发送时刻,bili 私有路径)。

3. 影响范围与严重程度:opencode V2 车道(native 插件安装 + bili opencode launcher)且同时装有 provider 鉴权插件的用户,核心能力整体停摆(p1)。不修则 Kiro/Antigravity 持续不可用。

4. 怎么修复的:route() 改为 discovery-only(oversize 本地拒绝不变);两个 setup() 都装共享 fetch 拦截链,统一承担 /bili/ 改写、dead-origin recover/retry/give-up-direct、signed-body 拒绝(#1884)、direct 豁免(providers.<url>.direct,补全 #1622 的 V2 车道);WS handshake 钩子自建隧道 URL。

5. 是否有回归问题:逐项清点既有行为——

  • 常规 HTTP 模型请求(raw / fresh-baked / self-origin 三种形状):新旧路径出站字节一致 ✅(代码比对 + 测试矩阵);
  • HTTP 侧代理死亡后的 stale baked origin:master 靠钩子时刻 re-bake,现在由链条 recover/retry/give-up-direct 接管(PR 已披露)✅;
  • WS 隧道发现一处未披露回归:launcher 的 respawn 用动态端口,代理会话中死亡重启后 origin 变化;master 的隧道基于改写后 URL 构建(stale→live re-bake 成功),新代码基于未触碰的请求构建——stale URL 既不匹配 live 前缀、/bili/ 路径又过不了 isModelApiUrl → 隧道不建,宿主直连死 origin,WS 模型通道直到宿主重启才恢复。已在 PR 分支直接修掉(commit 209b24b:分支 2 额外解码 routedBiliModelUrl、从 live origin 建隧道,输出与 master 逐字一致 + 回归测试);
  • 其余稳态情形(fresh bake / raw / exempted / non-model)新旧字节全同;signed-body、增量 divert(replaceRequestPayload 仍在用,未动)、fork adopt、stamp 无语义漂移;
  • 一个单测无法证实的残留风险:方案假设 opencode V2 宿主发送时惰性解析 globalThis.fetch(PR 声称已在 2.0.x binary 实测,V1 有同类先例写在代码注释)。若某版本宿主提前捕获 fetch 或用内部客户端,压缩会静默失效——建议保留 ACP_TEST_E2E_OC_WS 真机车道作最终兜底。

6. 是否破坏缓存:不涉及。缓存/重试/增量游标/去重键均未动;pf-* 水位头照旧(协议头,转发上游前剥除)。

7. 是否改了设计方向:是,本 PR 的目的——opencode 车道路由决策点从「钩子层共享 payload 改写」移到「fetch-time 私有出站改写」,与 pi/omp/dsh 等车道的共享链架构对齐;钩子层保留发现 + 标记(biliDirect/豁免/本地拒绝)。

8. 是否引入新配置:无。补全已文档化的 providers.<url>.direct 到 OpenCode V2 车道(此前仅 ZCode 实现),CONFIGURATION.md 措辞同步更新。

审核中发现的问题与处置(全部已在 PR 分支修掉)

本地跑相关套件发现 3 处必红 + 上述 WS 回归:

  1. tests/opencode-native.test.ts [PR] pi inline full rollout: fixed real-device stream drops + default to in-process engine (previously scattered across unmer | pi inline 全套落地:修好真机断流 + 默认走进程内引擎(之前散在未合并的 #4527/#4571 里) #4669 V2 composition 仍断言旧钩子时刻改写、且没装链 → 必红;
  2. tests/issue5625… pool 用例断言「不走代理」,但 v1internal 自 Under DSH Desktop, the Google Cloud Code protocol endpoint is identified as an unknown interface, causing requests to co | DSH Desktop 下 Google Cloud Code 协议端点被判定为未知接口,导致请求直连绕过压缩代理 (acp_status 报 404) #4256 起就是模型形状(DSH Desktop Code-Assist 流量恰走该 URL,PR 描述也披露了走 bili)→ 测试与实现和披露矛盾;
  3. replaceRequestTarget 成死代码,unused-exports 门禁红;
  4. WS 隧道 stale-origin 回归(见第 5 问)。

开审时 CI follow-up 已向分支推了 a40ef0f / 50fc076,修掉 1–3(与我的定位等价,采纳其版本)并把新套件登记进 LIVE_FILES;我在 50fc076 之上只 cherry-pick 了我独有的第 4 项(209b24b)并推送。新 head 本地验证:5 个套件 84/84 绿 + typecheck 干净 + unused-exports 干净;全量裁决看远程 CI(镜像缓存尚停留在上一 sha,未轮询)。

行为变更披露(PR 原有 + 本次审核)

判定:方向正确、机制成立、披露完整;发现的 4 处问题已全部在分支上修复(3 处 CI follow-up + 1 处我修)。等新 head 209b24b 远程 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)

Reviewed end-to-end against current master. PR head 50fc076af is 0 commits behind master (merge-base == master), clean 3-commit linear history. CI: no check failures at read time (kernel-guard / version-guard / gate green; e2e lanes gated-skip; a few guard jobs still running). No kernel/ touched.

The core #5625 fix is correct and I approve it. It does exactly what #4276 asks: the opencode-lane http.request hook stops replacing the shared e.request (which leaked the rewritten proxy URL into every later hook, including provider-scoped plugins like Kiro/Antigravity) and only discovers state.proxyBase; the <proxy>/bili/<url> rewrite moves to fetch time in the shared intercept chain (installNativeFetchIntercept, now installed by the new setup() wrappers in both opencode-native.ts and opencode.ts). Verified independently:

  • replaceRequestTarget removed cleanly — zero remaining references at head (grep across src/+tests/+scripts/).
  • Steady-state HTTP output is byte-identical to the old rewrite path (same ${origin}/bili/<upstream> target, same stamps); the new tests/issue5625-opencode-v2-hook-payload.test.ts pins the payload contract (untouched request, fetch-time routing, pool dialect, direct exemption, child-process install gate) and is registered in scripts/live-files.mjs.
  • Dead-origin handling moving to the chain's recover/retry/give-up-direct is covered by the updated launcher suite (respawn re-route + failed-respawn direct degrade).
  • providers.<url>.direct completion for the V2 lanes reuses the zcode store lane's boundary rule (exact key or key+"/", directExemptMatch); no new config field invented (respects the owner-gated config surface).
  • Behavior changes are disclosed old→new in the PR body per policy.

One semantic edge to close before/at merge — see 🔶 below.

结构化八问

  1. 是什么问题:opencode 车道在 http.request hook 里把共享请求对象改写成代理 URL,泄漏给后续所有 hook(含其它插件的 provider-scoped hook),导致校验上游 URL 的插件(Kiro/Antigravity)失效。
  2. 什么原因导致的:根因是「在 hook 里改写共享可变 payload」——opencode 把同一个 Request 对象递给每个后续 hook,而 Request.url 运行时只读(#810),只能整体替换引用,于是改写串到所有下游。
  3. 影响范围与严重程度:所有「opencode 车道 + 挂了 URL 校验型 provider 插件」的用户;Kiro 表现为静默空回复(体验级 p1),Antigravity 直接抛错。修后恢复。
  4. 怎么修复的:hook 只做发现(state.proxyBase)+打戳+本地拒绝;真正的 /bili/ 改写下沉到 fetch 时刻的共享拦截链(V1/V2 两个 setup 都装链)。共享 payload 原样透传,provider 插件重新看到上游原始 URL。
  5. 是否有回归问题:稳态 HTTP 字节等价、已测;死源降级 / direct 豁免 / 签名体本地拒绝(#1884)均按披露生效。但有一处相邻路径回归见下方 🔶:experimental.ws.handshake 隧道重建丢了「陈旧 baked overlay 在端口漂移重启后重定向到 live origin」的旧行为。
  6. 是否破坏缓存:不破坏。打戳仍落在同一请求对象上,稳态出站 URL 不变,prefix cache 行为一致;direct 豁免是用户按上游显式 opt-out(本就不压缩)。
  7. 是否改了设计方向:是且有意——从「hook 时改写」转向「fetch 时路由」,与 pi/zcode 等车道统一;这是 #4276 的正解方向,合理。
  8. 是否引入了新的配置:无新字段;补全既有 providers.<url>.direct(此前仅 ZCode 车道实现),CONFIGURATION.md 措辞同步更新。

🔶 需要决策 — ws.handshake 隧道重建丢失「陈旧 overlay 重定向到 live」

src/agent/opencode-v2.ts:439-452(ws.handshake handler):新逻辑只覆盖两种情况——(a) reqUrl.startsWith(${state.proxyBase}/bili/)(baked overlay 且 origin == 当前 live,即稳态),(b) isModelApiUrl(httpUrl)(裸模型 URL)。它没有覆盖「baked overlay 的 origin ≠ state.proxyBase」这一格——即 launcher 车道里 proxy 死亡后 respawn 到不同端口(port drift)时,baked 进 opencode 配置的 /responses WS URL 仍指向旧端口:

  • branch (a) 失败(baked origin ≠ live origin);
  • branch (b) 失败:isModelApiUrl 对 /bili/ 前缀 URL 恒为 false(native-intercept.ts:309 segments[0]==="bili" → return false);
  • → httpTunnel === undefined → return,不建隧道。

改动前的代码靠 route 里 replaceRequestTarget(e, ${live}/bili/${upstream}) 先把合成请求重写到 live origin,所以旧代码对这一格是正确重定向的。opencode 车道没有装全局 WebSocket wrapper(只有 pi-native.ts 装 installNativeWebSocketIntercept),fetch 链也覆盖不到 WebSocket,所以 ws.handshake hook 是唯一出路——HTTP 能靠 fetch 链自愈,WS 不能,这个不对称就是缺口所在。

触发条件较窄(launcher 车道 + Responses-over-WS provider + 端口漂移重启),且下次 opencode 启动会重新 bake 配置而自愈,会话本身不死,故判为非阻塞(p2~p3)。但它是本 PR 引入的相邻路径回归,且 opencode-v2.ts:444-447 注释声称 tunnel「byte-identical to the old rewrite + replace pipeline」——该等价性只在 baked-origin == live-origin 时成立,对漂移场景不成立;此外这段隧道重建逻辑在本 PR 中无任何测试钉住。

请二选一:

  • A(推荐):在 else-if 链补一格——当 httpUrl/reqUrl 是 /bili/ baked overlay(origin 任意)时,用 routedBiliModelUrl 解出内层 upstream,对 state.proxyBase(live)重建 ${live}/bili/responses/<inner>,复刻旧的重写行为,并加一条「stale-origin-after-restart」的 pin;
  • B:确认该路径不可达(launcher 从不产出 baked 的 /responses WS URL),在注释里写明边界。

此项属路由语义、跨 native/launcher 两车道,我不擅自改;给出方向供拍板。


Verdict: APPROVE (substantive) — the #5625 fix itself is correct, tested, green and current with master; the single 🔶 item above is a narrow non-blocking edge routed for your decision (label needs-decision applied), not a merge blocker.

(Process note: a formal APPROVE review event could not be filed from this identity — GitHub rejects self-approval when the reviewer account is the PR author. This comment carries the complete assessment; the merge call is yours as usual.)

@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Correction to my review comment above — that one was filed against head 50fc076af, which predates the current live head.

I independently reproduced the same WS stale-origin regression the prior review thread called out: a launcher-baked <stale-origin>/bili/<upstream> Responses-WS overlay misses branch 1's live-prefix match and its /bili/ path fails isModelApiUrl, so the handshake is dropped and the host dials the dead origin after a mid-session proxy respawn (respawn binds a fresh dynamic port).

Verified the live head 209b24b71 already fixes it correctly:

  • src/agent/opencode-v2.ts ws.handshake branch 2 now computes const upstream = routedBiliModelUrl(httpUrl) ?? (isModelApiUrl(httpUrl) ? httpUrl : undefined) and builds ${state.proxyBase}/bili/responses/${upstream} — byte-identical to master for the raw / steady-state shapes, and re-tunnels a stale overlay from the live origin (exactly the previously-missing case).
  • Regression pin added in tests/responses-websocket.test.ts ("stale-baked overlay tunnels from the live origin after a respawn") asserting the rebuilt ws://<live>/bili/responses/<upstream> URL plus the stamped headers.

So the 🔶 需要决策 item in my earlier comment is already resolved on-branch — no open decision remains. I have withdrawn that framing and removed the needs-decision label I had applied.

Net verdict stands: the #5625 core fix is correct, tested, green and current with master; with 209b24b71 the single adjacent-path regression is closed. Mergeable once remote CI is green (human merge).

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Review 完成(第二次独立复核)。 核心 #5625 修复经独立代码走查确认正确、已测、绿、与 master 同步。我独立复现了前一轮 review(floor 8)指出的同一处 WS stale-origin 回归(launcher baked overlay 在端口漂移 respawn 后隧道不建、宿主连死 origin),并核实当前 live head 209b24b71 已正确修复:opencode-v2.ts ws.handshake branch 2 现用 routedBiliModelUrl(httpUrl) ?? … 从 live origin 重建隧道(与 master 逐字一致)+ tests/responses-websocket.test.ts 补了回归钉。说明:我首条 review 评论是对旧 head 50fc076af(修复前)提交的,当时把该 WS 项标成 🔶 需要决策并打了 needs-decision 标签——现该缺陷已在分支上修掉,该项作废,我已撤回该表述并移除标签。无未决项;等远程 CI 绿即可人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 修复完成:11 个红掉的 test 分片是同一个根因,已在 PR 分支修掉并验证全绿。修复提交 50fc076af(该 head 核心矩阵 run 41710646716:11 test 分片 + static-gates×2 + mysql-contract + 12 guard 全部 success)。

根因:PR 新增的 tests/issue5625-opencode-v2-hook-payload.test.ts 会 spawn 子进程(node --import tsx -e 安装门探针)但未登记进 scripts/live-files.mjs 的 LIVE_FILES,CI 的 #1248 tripwire 在每个分片的预检阶段直接中止——测试一个都没跑。

修法:先做并发假设审查(3 个用例纯进程内 fake-fetch、第 4 个 listen(0) 临时端口 + mkdtemp 隔离子进程,无固定端口、无需端口区带),再按 append-only 纪律把文件追加到 LIVE_FILES 表尾(slot=index 决定端口区带,中途插入会重编号后续所有文件)。本地双重验证:tripwire 逻辑复刻干净(1082 文件扫描)+ 该套件定向跑 4/4 通过。

回归审查:改动仅 +7 行(1 条表项 + 注释),不动任何既有登记项、不改 tripwire 语义;不涉及缓存/配置面/设计方向。另核对了后续落下的功能提交 209b24b71 改动的 tests/responses-websocket.test.ts——不命中 SPAWN_RE,无同类风险,其 CI 在途且健康(0 红)。

两个非缺陷现象:①推送后自动打标签 1 秒内连加 6 个标签触发 6 次 labeled ci.yml run,被 #3772 的 -skip 并发组互相隔离取消(最后一次 scope=skip 跳过矩阵)——防护按设计生效,真实矩阵不受影响;镜像缓存按名字取最新会把这批 skip check 顶到前面,看起来吓人实际无害。②PR 上已有 needs-decision 标签(owner 审核评论里披露的 DSH pool 流量行为变更待拍板),该部分我未触碰。

判定:我负责的红 CI 已全部修完并实证绿,收工;PR 现头 209b24b71 的 CI 在途健康,等其跑完 + owner 决策即可推进合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到更正,CI 侧确认完毕——现头 209b24b71 远程 CI 已全绿,无遗留红项:

  • 推送触发的矩阵 run 41713647059(20:33Z):27 个 job = 26 success + 1 skipped(red-signal 失败通知器,跳过即代表零失败)。11 个 test 分片(含之前红的 ubuntu 22,2 / 24,2)、static-gates×2、mysql-contract 全部实跑通过;tests/responses-websocket.test.ts 的新回归钉("stale-baked overlay tunnels from the live origin after a respawn")就在其中跑过。
  • 同 sha 的第二次 run 41714540016(labeled 触发)也 success。
  • 镜像缓存里那批模板名(test (${{ matrix.os }}...))的 skipped 又是 latest-per-name 显示假象——被第二次 run 的 skip-scope check 按名字顶掉了真实分片名,实际矩阵是上面这个全绿的。

与你的独立复现结论一致:209b24b71 的 ws.handshake branch 2 从 live origin 重建隧道,raw/steady-state 形状与 master 字节一致,补上了 stale overlay 这一格;我此前也核过该提交改动的测试文件不命中 SPAWN_RE,没有引入新的 tripwire 风险。

CI 车道收工:我负责的两段(11 分片 tripwire 根因修复 50fc076af + 后续提交的健康监控)都已闭环并实证绿。PR 现头无任何失败 check,等你人工合并。

ci-check added 4 commits November 4, 2026 09:22
…route model traffic at fetch time (#5625)

Rework of PR #4280 (reverted by c076614 over a master conflict; original
report #4276) on top of current master.

The opencode-lane http.request hook used to replace e.request with a new
Request pointed at `${proxyOrigin}/bili/<originalUrl>`. opencode hands that
one mutable event to every later http.request/http.response hook, including
provider-scoped hooks from other plugins, so provider auth plugins validating
the upstream URL broke: Kiro's bridge silently stopped engaging (empty
responses after ~10 retries) and Antigravity threw "pool requests need the
default Google base URL" before its own hook could run.

The routes now only DISCOVER the proxy (state.proxyBase; oversize refusal /
direct-degrade on death) and leave the hook-visible payload untouched. Both
setup()s install the shared native fetch intercept chain, which performs the
/bili/ rewrite at fetch time — the bytes other plugins see in their hooks are
unchanged. The WS handshake hook builds its own tunnel URL instead of relying
on the rewritten request. These lanes also honour providers.<url>.direct
(#1622), previously implemented only in the ZCode lane: matching requests are
marked biliDirect in the hook and sent direct by the chain.

Behavior changes (disclosed per policy):
- Provider plugins in opencode lanes see original upstream URLs again.
- Signed-body model requests (x-goog-api-key / SDK-HMAC-SHA256) in V2
  processes get the local #1884 refusal instead of unsigned-through-bili.
- #3304 prepareDirectSend and #3248 onResponse acks activate in V2 processes
  (dead code before the chain existed there).
- Launcher dead-origin handling moves from preemptive unwrap-to-upstream to
  the chain's recover/retry/give-up-direct path.
- v1internal pool-shaped URLs (e.g. daily-cloudcode-pa.googleapis.com,
  recognized since #4256 for DSH Desktop Code-Assist traffic) ride the chain
  like any other model request: byte-preserving forward through bili, no
  bili identity headers invented. Hosts wanting such traffic fully off bili
  opt out per upstream via providers.<url>.direct.

Tests: new tests/issue5625-opencode-v2-hook-payload.test.ts pins the hook
payload contract (untouched request, fetch-time routing, pool dialect,
direct exemption, install gate); launcher/native suites updated to the
fetch-time contract; the #4669 inline-composition test installs the chain
like its sibling and asserts the hook keeps the payload intact.

Closes #5625
… the fetch-time contract (#5625)

CI follow-up on PR #5626 head 58438f1:
- unused-exports gate: replaceRequestTarget had no remaining callers once the
  routes stopped rewriting e.request — removed.
- tests/opencode-native.test.ts: the #4669 V2-composition pin asserted the old
  hook-time rewrite; it now installs the chain like its sibling and asserts
  the hook keeps the payload intact while the chain rewrites at send time.
- tests/issue5625-opencode-v2-hook-payload.test.ts: the pool-endpoint pin
  predated #4256's classifier arm for the v1internal dialect (DSH Desktop
  Code-Assist traffic rides exactly that URL); it now asserts the post-#4256
  contract — the hook stays out of the provider plugin's way and the chain
  forwards the pool URL byte-preserving with no bili identity invented.
…#1248)

CI follow-up on PR #5626 head a40ef0f: every test shard died at the
#1248 SPAWN_RE tripwire because tests/issue5625-opencode-v2-hook-payload.test.ts
spawns node children (setup-gate probe) but was never registered. Concurrency
reviewed: three rows are in-process with a fake fetch sink (no sockets), the
probe server is listen(0), child env is mkdtemp-isolated — appended (slot = index
drives zone bands, mid-list inserts renumber later files).
…ale baked overlays (#5625)

Review fix on the #5625 rework branch: master rebuilt the Responses-WS tunnel from the route()-rewritten URL, so a launcher-baked overlay whose origin had died was re-baked to the live origin. The fetch-time rework builds the tunnel from the untouched request instead: a stale baked URL misses the live-prefix branch and its /bili/ path fails isModelApiUrl, so the handshake is dropped and the host connects to the dead origin. The launcher respawns its proxy on a fresh dynamic port (port 0), making this reachable after any mid-session proxy death. Branch 2 now also decodes routedBiliModelUrl and tunnels the embedded upstream from the live origin — byte-identical to master's output; regression test added.
@ranxianglei
ranxianglei force-pushed the 2026-11-04_opencode-fetch-time-routing branch from 209b24b to 629a10a Compare November 4, 2026 01:25

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

Pass-2 re-review after rebase — head 629a10a37 (previously 50fc076af → 209b24b71). The branch was rebased onto current master (5dee4850b; merge-base == master, i.e. up-to-date). Same 4 logical commits / 10 files as my prior review — no content change, only base movement. I re-verified the rebase is clean rather than trusting it:

  • Master's concurrent changes preserved. Between the old and new base, master independently edited several of the same files. All its additions survive at head: the native-intercept.ts silent-direct body-cap feature (outgoingBodyBytesCapped / streamBytesCapped / MAX_SILENT_DIRECT_BODY_BYTES / emptySlotOversizeRefusal / unattributedByteOversizeRefusal) is intact; opencode-v2.ts received modifications only (no symbols dropped).
  • No rebase duplication / drift. isModelApiUrl(:303) / directExemptMatch(:321) / installNativeFetchIntercept(:1158) each defined exactly once; replaceRequestTarget still fully removed (zero refs); the fetch chain is installed in both opencode-native.ts and opencode.ts; the WS stale-origin tunnel fix is present (opencode-v2.ts:458 → routedBiliModelUrl(httpUrl)).
  • Cross-feature coherence. The providers.<url>.direct exemption branch (native-intercept.ts:1514) sits after the isModelApiUrl gate and before the #1884 signed-body logic, short-circuiting to a byte-untouched send() by design — so it correctly never trips master's separate oversize-refusal branches (different decision points, no collision).
  • CI green on 629a10a37. 30 checks, 0 failed, 0 pending — all test shards + static-gates + unused-exports + version-guard + lifecycle-ledger-guard success; e2e lanes gated-skip as normal.

Eight questions (deltas vs pass 1):

  1. 是什么问题: opencode-lane 的 http.request hook 重写了共享 e.request,把 <proxy>/bili/<upstream> 泄漏给后续所有 hook(含 provider 插件)→ Kiro/Antigravity 等拿到错误 URL。
  2. 什么原因: 原设计在 hook 层改写共享请求对象;正确的层次是 hook 只做发现,真正改写在 fetch 时完成(共享拦截链)。
  3. 影响范围与严重程度: dsh/opencode 宿主 + provider 插件场景;p1(provider 插件拿到错误 URL = 该车道功能错乱)。核心修复在 pass 1 已逐行验证。
  4. 怎么修复的: hook 只发现 + 打戳 + 本地拒绝;/bili/ 改写在 fetch 时经 installNativeFetchIntercept 链完成,两个 setup() wrapper 都装链。
  5. 是否有回归问题: 本轮重点是 rebase 完整性——master 并发改动全部保留、无重复定义、无语义漂移;pass 1 发现的 WS stale-origin 边角回归已由同分支 commit 修复并带回归钉;CI 全绿。
  6. 是否破坏缓存: 不涉及(不动压缩 / 缓存键 / 重试策略)。
  7. 是否改了设计方向: 不变(仍是「hook 发现 / fetch 路由」的分层)。
  8. 是否引入新配置: 无(补全既有 providers.<url>.direct,未新增字段)。

Verdict: approvable / mergeable. Rebase is clean, the diff is identical to what I verified line-by-line in pass 1, and CI is green on the live head. GitHub forbids author self-approval (reviewer == author here), so I'm posting this as a COMMENT-event review carrying the approval recommendation rather than an APPROVE event — please merge manually.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) PR #5626 pass-2 复审完成(分支已 rebase 到最新 master 5dee4850b,head 629a10a37):rebase 干净——master 对共享文件的并发改动全部保留、无重复定义/语义漂移,PR 逻辑与上轮已逐行验证的内容一致;CI 全绿(30 checks / 0 failed / 0 pending)。已发 COMMENT 复审 id 5762199956(GitHub 禁止作者自批 reviewer==author,故以 COMMENT 事件给出批准建议)。判定:可合并,待人工 merge。

@milesbuckton

milesbuckton commented Nov 4, 2026 •

Copy link
Copy Markdown

@ranxianglei, please rebase this branch off master.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Checked the branch state before touching anything: it has fallen 14 commits behind master since the last rebase — master is now at 23a826d37, the PR head is still 629a10a37. The new master commits include a kernel change (#5620, ref-based media becomes foldable) along with the #5491 pi-inline-default and #5629 media-ref work, so a rebase onto the new base is worth doing and re-verifying.

I haven't pushed it yet: rewriting the branch would reset the currently-green CI and invalidate the pass-2 sign-off, and this request came in as an external comment rather than from the owner — so I'd like a quick confirm before rewriting history. On confirmation I'll rebase onto current master, resolve any conflicts by union-of-intent, push the same branch, and re-run typecheck/build + let CI re-verify. (The PR stays fully mergeable in the meantime — "behind" is not a merge blocker.)

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

冲突处理进行中(interim)——分支与 master 已脱节 775 个提交(master 推进到 58a8796224,而分支此前被 rebase 到旧基点 5dee4850b7),正在把 origin/master merge 进 PR 分支(merge 策略,不改写历史、无需 force-push,避免与并发 agent 抢分支)。

共 6 个文件冲突 / 8 个 hunk,已完成 3 个:

文件 冲突性质 处置
scripts/live-files.mjs 双方各自在表尾追加新条目 并集:保留 master 的 5 个新条目 + 本 PR 的 #5625 套件登记
CONFIGURATION.md master 文档重组:根文件已移入 docs/configuration.md(只剩重定向 stub),分支还在改旧文件的完整内容 采 master stub;把本 PR 对 providers.direct 描述的行为更新(OpenCode V2 direct 标记语义)移植到 docs/configuration.md,zh-CN 同步
src/agent/native-intercept.ts _resetForTest() 同一位置:分支加 directExemptSeen.clear()、master 加 declaredPatterns = [] 两个模块级状态都在合并后的文件里活着,测试重置必须清两者 → 两行都留

剩余 3 个文件 5 个 hunk(opencode-native.ts×3、opencode-v2.ts×1、opencode.ts×1)正在逐个按「意图并集」解决。全部解完后:本地 typecheck + build 验证 → 重新 fetch 确认远端头未动 → push → 等 CI 全绿后发最终七问报告。若后续 hunk 出现需要设计取舍的语义冲突,会按规矩发「🔶 需要决策」停手。

…lict resolution (#4599 help-merge)

Conflicts (6 files / 8 hunks), all union-of-intent:

- scripts/live-files.mjs: both sides appended LIVE_FILES entries -> keep master's 5 new suites then the #5625 hook-payload suite

- CONFIGURATION.md: master moved docs to docs/ (redirect stub) -> take stub; port the branch's providers.direct description update (#1622/#4276/#5625 OpenCode V2 direct-marking semantics) into docs/configuration.md en+zh-CN

- src/agent/native-intercept.ts: _resetForTest clears both module states (branch directExemptSeen + master declaredPatterns)

- src/agent/opencode-native.ts: imports = master additions minus replaceRequestTarget (dropped by this PR as dead after fetch-time routing; zero refs remain in merged tree); state setup keeps BOTH directPrefixes (#4276) and declaredWindowForDirect (#5032); V2 setup wrapper keeps the branch's fetch-intercept install AND passes master's onResponse option (merged V2SetupOptions accepts both)

- src/agent/opencode-v2.ts: V2HttpRequestEvent gains both optional fields (biliDirect #4276 + response for http.response events)

- src/agent/opencode.ts: imports = master additions minus replaceRequestTarget; keep V2PluginContext (used by merged setup wrapper)
…ogHostEvent

Master merged #5706 since this branch's base: its new guard test
(tests/issue5706-opencode-host-console.test.ts) forbids raw console.* in the
two opencode plugin entries (host TUI terminal) and requires every relocated
diagnostic to ride logHostEvent. The v2 install lines added here still used
raw console.log, so the merge-of-master head failed the guard on CI shard
ubuntu-22-2 (not ok 1833/1834). Both lines now match their v1 siblings;
behavior is unchanged apart from the output channel (terminal -> bili.log),
which is exactly what #5706 mandates.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 红项定位完成,确定性回归已修并推送(新 head 7dad138221)——merge-of-master head 58f72ac25f 的 run 43036329761 共 3 个红分片,逐一定位如下:

① test (ubuntu-latest, 22, 2) = 跨分支交互回归(本分支引入,已修):master 在本分支基点之后合入了 #5706,其新增守卫测试 tests/issue5706-opencode-host-console.test.ts 禁止两个 opencode 插件入口文件出现裸 console.*(宿主进程里 stdout 就是 TUI 终端),并要求每条诊断改走 logHostEvent。本 PR 新增的两行 v2 fetch-patch bootstrap 日志还是裸 console.log,merge 后两个方向同时成立 → 守卫红(not ok 1833/1834)。修法:两行改为与各自 v1 兄弟行一致的 logHostEvent("info", "[native-client]", …)(src/agent/opencode.ts:184、src/agent/opencode-native.ts:1024)——输出通道从终端变为 bili.log,这正是 #5706 的强制要求,无其他语义变化。

② test (windows-latest, 22, 1) 与 ③ test (ubuntu-latest, 24, 2) = 瞬态噪音(判定,待重跑证实):两份日志的 TAP 流都正常推进到中途后戛然而止(断在行中间),无任何错误注解/退出码;日志最后时间戳比 job 结束早 1~3.5 分钟 = 测试进程运行中被杀(OOM/runner 故障特征),不是测试失败。与 #4599 今日记录的全局抖动(#6138 Windows npm-ci ECONNRESET、多起 flake 自愈)吻合。本次重跑会直接给出裁定。

本地定向验证(全量裁决仍归远程 CI):#5706 套件 2/2 绿、#5625 hook-payload 套件 4/4 绿、opencode-native 套件绿(65 内层用例)、typecheck 干净。

CI 在新 head 上跑完后我会补最终结论(含八问)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 车道收工:新 head 7dad138221 全绿(30 checks = 17 success + 13 skipped,零失败),3 个红分片全部闭环。

八问

1. 是什么问题:merge-of-master head(58f72ac25f)的 CI 有 3 个红 test 分片——一个是本 PR 引入的跨分支交互回归,两个是测试进程运行中被杀的瞬态噪音。

2. 什么原因导致的:① ubuntu-22-2:master 在本分支基点之后合入 #5706,其新增守卫测试禁止两个 opencode 插件入口文件出现裸 console.*(宿主进程里 stdout 就是 TUI 物理终端)并要求诊断改走 logHostEvent;而本 PR 新增的两行 v2 fetch-patch bootstrap 日志还是裸 console.log,merge 后两个方向同时成立 → 守卫红。② windows-22-1 / ubuntu-24-2:日志无任何错误注解/退出码,TAP 流断在行中间、最后时间戳比 job 结束早 1~3.5 分钟 = 进程运行中被杀(OOM/runner 故障特征),与 #4599 今日记录的全局抖动(ECONNRESET、flake 自愈)吻合;重跑证实与代码无关。

3. 影响范围与严重程度:仅影响本 PR 的 CI 门禁,无用户面影响。修复本身对用户是正向小改进(见行为变更披露)。

4. 怎么修复的:两行改为与各自 v1 兄弟行字节级一致的 logHostEvent("info", "[native-client]", …)(src/agent/opencode.ts:184、src/agent/opencode-native.ts:1024),其余逻辑零改动;另两个分片无需修复,重跑即绿。

5. 是否有回归问题:逐项审过既有行为——修复只改变这两行的输出通道;#5706 守卫双向断言(禁裸 console + 诊断必须仍在)本地 2/2 绿;#5625 hook-payload 契约套件 4/4、opencode-native 套件全绿、typecheck 干净;远程 CI 上原先红的 3 个分片全部转绿,e2e lane 的 skip 为 env 门控跳过(与前几轮一致,非异常)。merge base 之后 master 新增 5 提交与本 PR 文件集仅重叠 docs/configuration.md(删除 compressAtFoldPoint 文档行,与本 PR 的 providers.direct 措辞不同区域)→ behind 状态不构成合并障碍。

6. 是否破坏缓存:不涉及。

7. 是否改了设计方向:否——本次修复是向 #5706/#2827/#2831 已确立的 host-log 惯例(所有 native 车道走 logHostEvent)对齐。

8. 是否引入了新的配置:无。

行为变更披露(旧值 → 新值 + 原因)

v2 fetch-patch 安装提示行:[bili-opencode(-native)] v2: fetch patch installed … 从「打印到 opencode TUI 终端」→「经 logHostEvent 写入 bili.log」。原因:#5706 强制要求——raw console.* 落在宿主 TUI 物理屏幕上且无法静音;内容语义不变。

判定:CI 车道全部闭环并实证绿,PR head 7dad138221 待人工合并。

…lict resolution (#4599 help-merge)

Single conflict: scripts/live-files.mjs — both sides appended LIVE_FILES
entries at the table tail. Union resolution keeps master's two new entries
(pack-install, ci-janitor-fork-heads) in master's slot order and appends the
#5625 suite entry after them (its comment states no zone band is needed, so
the slot shift is inert). docs/configuration{,.zh-CN}.md auto-merged: master's
compressAtFoldPoint doc removal applied, this PR's providers.direct V2
wording preserved. No other files conflicted.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已处理完毕:master(259cd87)已合入分支,唯一冲突已解,新 head cb408bcc56 全矩阵 CI 绿,merge state 已回 blocked(可合并,待人工)。 本轮同时覆盖了 11-12 01:18Z 那次未及回复的冲突转发(同一事件,本次为最终处置)。

本轮做了什么:

  1. 活体核实(不凭记忆):PR 远端 = 本地 = 7dad138221;master 已前进 133 提交至 259cd87674;merge state dirty,与系统判定一致。
  2. git merge origin/master --no-ff(用 merge 不用 rebase,保留分支既有提交历史):恰好 1 处冲突 —— scripts/live-files.mjs(CI-lane tripwire 的测试文件登记表);docs/configuration.md / docs/configuration.zh-CN.md 自动合并,已逐项核实(master 的 compressAtFoldPoint 文档移除生效、本 PR 的 providers.direct V2 措辞保留)。
  3. 冲突解法(union-of-intent):保留 master 新增的两条登记(tests/pack-install.test.ts、tests/ci-janitor-fork-heads.test.ts)在 master 的槽位顺序,本 PR 的 tests/issue5625-opencode-v2-hook-payload.test.ts 追加到表尾——该条目注释明确不需要 zone band,槽位平移对端口带映射无影响;两侧登记全部保留,无删改。
  4. 本地验证:tripwire 逻辑复现(1224 个测试文件扫描 / 67 登记 / 0 漏登记 spawner)、typecheck 干净、build 成功(dist 注解 + 外部依赖检查 OK)、定向套件 49/49 绿(opencode native plugin: un-silenceable startup console.log noise + "opencode" config key falsely warned as unknown #5706 守卫、opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276) #5625 hook-payload、opencode-native、responses-websocket)。
  5. 普通 push(推送前已 fetch 确认远端 head 未变,无 force-push)。

CI 结论(新 head cb408bc,活体核实): 50 个 check run = 37 success + 13 skipped(设计内 env-gated e2e 车道)+ 0 失败;merge state = blocked(= 可合并、等待人工,不再是 dirty)。注:镜像缓存轮询器本次卡在 16:59:35Z 未刷新(>25 分钟),CI 结论改用单次 GitHub API 读取核实(非轮询)。

八问:

  1. 是什么问题:PR 分支落后 master 133 提交,CI-lane 登记表 scripts/live-files.mjs 两侧各自新增条目形成冲突,merge state dirty 挡住合并。
  2. 什么原因导致的:双方在同一登记表的相邻区域追加条目——常规并发编辑冲突,无语义分歧、无设计问题。
  3. 影响范围与严重程度:仅本 PR 的合并性被挡(blocked 不可合并);无用户功能影响;严重度 = 合并阻塞,无数据/行为风险。
  4. 怎么修复的:merge master 入分支(非 rebase),唯一冲突按 union-of-intent 解——两侧登记全保留、槽位顺序以 master 为准、本 PR 条目追加表尾;本地复现 tripwire 逻辑验证登记表完整性。
  5. 是否有回归问题:无——冲突解是 append-only 登记表,无语义变更;docs 自动合并区域逐项核实;本地定向 49/49 绿 + 全矩阵 CI 0 失败。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突已解、CI 全绿,PR 就绪,等待人工合并。

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

Pass-3 review — head cb408bcc56. The branch has been rebased onto current master (259cd87674) via CI-lane merge commits (#4599 help-merge) and is now up-to-date (0 behind). The only new logical change since the previous reviewed head is 7dad138221, which routes the two v2 fetch-patch bootstrap lines from console.log to logHostEvent — required because master merged #5706 (a guard test forbidding raw console.* in the two opencode plugin entries). Verified: logHostEvent is imported in both src/agent/opencode-native.ts:93 and src/agent/opencode.ts:27, the new lines (opencode-native.ts:1024, opencode.ts:184) match their v1 siblings, and behavior is unchanged apart from the output channel (terminal → bili.log), which is exactly what #5706 mandates. All core markers of the fix survive the merges: replaceRequestTarget is gone (0 refs), directExemptMatch + the isModelApiUrl /bili/ guard are present in src/agent/native-intercept.ts, installNativeFetchIntercept is installed in both the native and launcher setups, and the WS routedBiliModelUrl tunnel rebuild is in src/agent/opencode-v2.ts:497. The doc (now docs/configuration.md + docs/configuration.zh-CN.md) correctly describes the new opencode-lane behavior and the URL-boundary match rule. CI is green (30 jobs, 0 failed, 0 pending). No new findings this pass — the one small finding (raw console.log in the v2 bootstrap lines) was already fixed on-branch by the CI sentinel. Verdict: clean and mergeable. (Self-approval is not possible — reviewer identity == author — so this is posted as a comment; human merge.)

八问(结构化审核):

  1. 是什么问题:opencode-lane 的 http.request 钩子不再改写共享的 e.request 请求对象——旧实现在钩子里把目标 URL 替换成 <proxy>/bili/<upstream>,把改写过的前缀泄漏给之后所有钩子(包括 Kiro/Antigravity 等 provider 插件),它们看到的是被 bili 改写的 URL 而非真实上游。
  2. 什么原因导致的:根因是"在错误的层做路由改写"——在 http.request 钩子链中间改共享请求对象,污染了后续钩子的视图。正确做法是把 <proxy>/bili/<upstream> 的重写下沉到 fetch 时刻(所有钩子都跑完之后)才做。
  3. 影响范围与严重程度:仅当 opencode-lane 同时挂了 provider 插件时,这些插件看到的是被改写的 URL 而非真实上游(可能影响签名/识别);属"特定条件下有问题"。修后 provider 插件重新看到真实上游 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 打标(e.biliDirect)+ 本地拒绝;真正的目标重写在共享 fetch 拦截链 installNativeFetchIntercept 里做,native 与 launcher 两个 setup() 入口都装;direct 豁免走 directExemptMatch(精确匹配或 <prefix>/ 边界),与 zcode store lane 语义一致。
  5. 是否有回归问题:逐项过既有行为——provider 插件重新看到真实上游 URL(有意变更,已披露);signed-body(#1884 x-goog-api-key/SDK-HMAC-SHA256)本地拒绝在 V2 生效(有意);#3304 prepareDirectSend + #3248 onResponse acks 激活(原为死代码);launcher 死 origin 走链 recover/retry/give-up-direct;v1internal 池 URL 走链字节保持;WS 隧道对 stale baked overlay(端口漂移重启后)经 routedBiliModelUrl 从 live origin 重建(pass 1 发现、分支已修)。无回归。
  6. 是否破坏缓存:不涉及缓存/重试/增量游标/去重键的失效策略;fetch 时刻重写不改变上游请求语义。
  7. 是否改了设计方向:路由改写层从"钩子内改共享对象"下沉到"fetch 时刻共享链"——这是本次修复的核心方向变化(有意),让 provider 插件看到真实 URL。
  8. 是否引入新的配置:无新配置字段;完成既有 providers.<url>.direct 的语义(en/zh 文档已同步更新,补 #4276/#5625 引用与 URL 边界规则措辞)。

结论:干净、可合并(合入权在 human)。本 PR 未触碰 kernel/(#5620 的 kernel 变更属 master,非本 PR),无授权门禁。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b) PR #5626 pass-3 review done (head cb408bcc56): branch rebased onto current master 259cd87674 (0 behind) via #4599 help-merge; only new change 7dad138221 (v2 bootstrap console.log→logHostEvent, required by master #5706) verified correct, all core markers intact, doc en+zh updated, CI green 30/0, no new findings → clean / mergeable (human merge). Review: #5626 (review)

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已再次处理完毕:master(f21b601)已合入分支,3 处冲突全部解决,新 head a82b65e64 全矩阵 CI 绿,merge state 已回 blocked(可合并,待人工)。

本轮做了什么:

  1. 活体核实(不凭记忆):PR 远端 = cb408bcc56(11-13 的合并提交);master 已再前进至 f21b601893(分支落后 390 提交);git merge-tree 干跑确认 3 处真实冲突(与系统 dirty 判定一致)。另注:工作区本地分支曾被重置,已从远端 head 重建后操作。
  2. git merge origin/master --no-ff(用 merge 不用 rebase,保留分支既有提交历史),三处冲突逐一解决:
    • scripts/live-files.mjs(CI-lane tripwire 登记表):union——master 新增的 tests/web-logs-query.test.ts、tests/content-encoding-zstd.test.ts 保留其槽位,本 PR 的 tests/issue5625-opencode-v2-hook-payload.test.ts 追加到表尾(该条目注释明确不需要 zone band,槽位平移对端口带映射无影响);
    • src/agent/opencode-v2.ts(import 行):union——本 PR 的 native-intercept.js 三符号 import 与 master 的 opencode-msgids.js import 都保留(已核实 master 自身即如此携带该 import,合并后与 master 状态一致);
    • src/agent/native-intercept.ts:取 master 侧——master 新增的 replaceRequestTarget() 函数(本侧在该位置无新增),其调用方(master 的 tests/native-request-signal.test.ts)已随合并带入。
    • docs/configuration.md / docs/configuration.zh-CN.md / src/agent/opencode-native.ts 自动合并,逐项核实:本 PR 的 v2 fetch-patch logHostEvent 行保留(opencode-native.ts:1024、opencode.ts:184),master 的 msgids 注释更新正常落位。
  3. 本地验证:无残留冲突标记;tripwire 逻辑复现(1304 测试文件 / 70 登记 / 0 漏登记);typecheck 干净;build 成功(dist 注解 + 外部依赖检查 OK);定向套件 92/92 绿(9 个文件:本 PR 的 opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276) #5625 hook-payload、opencode native plugin: un-silenceable startup console.log noise + "opencode" config key falsely warned as unknown #5706 TUI 守卫、opencode-native、responses-websocket,以及 master 新动区域的 native-request-signal、identity-harvest、msgid-lane-identity、opencode-direct-window、launcher-opencode-inline)。
  4. 普通 push(推送前 fetch 确认远端 head 未变,无 force-push)。

CI 结论(新 head a82b65e,活体核实): 50 个 check run = 37 success + 13 skipped(设计内 env-gated e2e 车道)+ 0 失败;merge state = blocked(可合并、等待人工,不再是 dirty)。注:镜像缓存轮询器本轮两次停更(>10 分钟不刷新),CI 结论以单次 GitHub API 读取核实(非轮询),镜像恢复后亦确认同一状态。

八问:

  1. 是什么问题:PR 分支落后 master 390 提交,两侧在 opencode 车道与 CI-lane 登记表上并发演进,形成 3 处文本冲突,merge state dirty 挡住合并。
  2. 什么原因导致的:master 两天内新增 V2 msgids 采集接线、replaceRequestTarget 请求改写函数与两条测试登记,恰好落在本 PR 触碰的同一批文件的相邻区域——常规并发编辑冲突,无语义分歧。
  3. 影响范围与严重程度:仅本 PR 的合并性被挡;无用户功能影响;严重度 = 合并阻塞。
  4. 怎么修复的:merge master 入分支,三处冲突按 union-of-intent / 取新增侧解决(两侧代码与登记全保留,无删改);本地复现 tripwire + 92 项定向测试覆盖双方新动区域,确认无语义漂移。
  5. 是否有回归问题:无——冲突解均为纯追加(import、函数、登记条目);自动合并区域逐项核实;本地 92/92 绿 + 全矩阵 CI 0 失败。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突已解、CI 全绿,PR 就绪,等待人工合并。

…lict resolution (#4599 help-merge)

Single conflict in scripts/live-files.mjs (LIVE_FILES registry): union-of-intent — kept master's new tests/upstream-ca-default-trust.test.ts entry at its slot and appended this PR's tests/issue5625-opencode-v2-hook-payload.test.ts at table end (both entries are SPAWN_RE tripwire-only, no zone band needed). docs/configuration.md + zh auto-merged; verified the PR's providers.direct V2 wording survives and master's compressAtFoldPoint removal is intact. Local: tripwire scan clean (1351 files / 71 registered / 0 unregistered), typecheck clean, build OK, targeted suites 84/84 green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已再次处理完毕:master(548e396022)已合入分支,唯一冲突已解,新 head 7c3c54d836 合并态回 blocked(可合并、待人工),CI 在新 head 上运行中(25 success + 12 skipped + 12 in progress,0 失败)。

本轮做了什么:

  1. 活体核实(不凭记忆):PR 远端 = a82b65e64f(11-15 的合并提交);master 已再前进至 548e396022(分支落后 244 提交);git merge-tree 干跑确认 1 处真实冲突(scripts/live-files.mjs),与系统 dirty 判定一致。
  2. git merge origin/master --no-ff(用 merge 不用 rebase,保留分支既有提交历史、无需 force-push):恰好 1 处冲突 —— scripts/live-files.mjs(CI-lane tripwire 的测试文件登记表)。
  3. 冲突解法(union-of-intent):保留 master 新增的 tests/upstream-ca-default-trust.test.ts 登记在其槽位,本 PR 的 tests/issue5625-opencode-v2-hook-payload.test.ts 追加到表尾——两条都是 SPAWN_RE tripwire-only 登记(注释明确不需要 zone band),槽位平移对端口带映射无影响;两侧登记全部保留,无删改。
  4. 自动合并区域逐项核实:docs/configuration.md / docs/configuration.zh-CN.md 自动合并——本 PR 的 providers.<url>.direct OpenCode V2 措辞完整保留(en/zh 两侧均确认);master 的 compressAtFoldPoint 文档移除正常生效(未被本 PR 文本覆盖)。
  5. 本地验证:tripwire 逻辑复现(1351 个测试文件 / 71 登记 / 0 漏登记 spawner)、typecheck 干净、build 成功(dist 注解 + 外部依赖检查 OK)、定向套件 84/84 绿(本 PR 的 opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276) #5625 hook-payload、opencode native plugin: un-silenceable startup console.log noise + "opencode" config key falsely warned as unknown #5706 TUI 守卫、responses-websocket WS 隧道回归钉,以及 master 新动区域的 opencode-native、native-request-signal、identity-harvest、msgid-lane-identity、launcher-opencode-inline、issue5032-opencode-direct-window)。
  6. 普通 push(推送前 fetch 确认远端 head 仍为 a82b65e64f 未变,无 force-push)。

CI 结论(新 head 7c3c54d836,活体核实): 镜像缓存轮询器本轮停更(仍停留在 11-15 的旧 sha a82b65e64f),CI 状态以单次 GitHub API 读取核实(非轮询):PR head = 7c3c54d836,mergeable = true,mergeable_state = blocked(可合并、等待人工,不再是 dirty);49 个 check run = 25 success + 12 skipped(设计内 env-gated e2e 车道)+ 12 in progress,0 失败。全量裁决以远程 CI 跑完为准。

八问:

  1. 是什么问题:PR 分支落后 master 244 提交,两侧在 CI-lane 测试登记表 scripts/live-files.mjs 上各自追加条目形成 1 处文本冲突,merge state dirty 挡住合并。
  2. 什么原因导致的:双方在同一 append-only 登记表的表尾各自新增条目(master 加 upstream-ca-default-trust,本 PR 加 issue5625-opencode-v2-hook-payload)——常规并发编辑冲突,无语义分歧、无设计问题。
  3. 影响范围与严重程度:仅本 PR 的合并性被挡(dirty 不可合并);无用户功能影响;严重度 = 合并阻塞,无数据/行为风险。
  4. 怎么修复的:merge master 入分支(非 rebase),唯一冲突按 union-of-intent 解——两侧登记全保留、master 条目在其槽位、本 PR 条目追加表尾;本地复现 tripwire 逻辑验证登记表完整性(0 漏登记)。
  5. 是否有回归问题:无——冲突解是 append-only 登记表,无语义变更;docs 自动合并区域逐项核实(本 PR 的 providers.direct V2 措辞保留、master 的 compressAtFoldPoint 移除生效);本地 84/84 定向绿 + typecheck/build 干净;CI 在新 head 上 0 失败(运行中)。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突已解、本地验证全绿、合并态回 blocked,CI 在新 head 上运行中(0 失败),PR 就绪,等待人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Re-review (pass 4) — head 7c3c54d836

The branch advanced since the last review: the CI sentinel merged two newer masters (f21b601893, 548e396022) into it. No new PR-logical commits — the PR's own commits (b4c0347941, 0001a9b82d, d38027b0f5, 629a10a376) plus the sentinel's 7dad138221 (console→logHostEvent) are unchanged. The branch is now up-to-date with master (548e396022, 0 behind).

Verified against the new base:

  • The PR's own diff is the same 11 files (485+/74−). All core markers intact: production replaceRequestTarget usages gone; directExemptMatch (def native-intercept.ts:341 / use :2028); isModelApiUrl bili-guard (:327/:397); installNativeFetchIntercept in BOTH setups (opencode-native.ts:493/979/1023, opencode.ts:136/183); WS routedBiliModelUrl tunnel rebuild (opencode-v2.ts:497); logHostEvent v2 bootstrap lines (both files).
  • Master re-added replaceRequestTarget (native-intercept.ts:1459) between the old and new base, with production usages in opencode.ts:161/167 + opencode-native.ts:265 (the old leaky hook-time path). The PR correctly removes those production usages (the leak) while retaining the function + its unit test (tests/native-request-signal.test.ts calls it directly). So the function is a tested utility, not dead code — no regression, nothing to clean up. (I confirmed the full tree before concluding; removing it would have broken that test.)
  • Docs (docs/configuration.md + .zh-CN.md) correctly describe the new opencode-lane direct behavior + the URL-boundary match rule (exact key or <prefix>/).
  • No kernel/ touched.

CI: 19/30 checks done (7 success, 12 skipped), 11 test shards in progress, 0 failures so far. The PR content is byte-identical to the prior head that was fully green, so the re-run is expected to pass.

Verdict: clean / mergeable (human merge). The core fix — stop rewriting the shared http.request payload, route model traffic at fetch time — is correct, tested, and current; the rebase onto the latest master is clean with no new findings.


8问(中文,供人工 reviewer)

  1. 是什么问题:opencode 车道的 http.request 钩子会改写共享的 e.request(把模型流量重写到 <proxy>/bili/<upstream>),导致每个后续钩子(含 provider 插件 Kiro/Antigravity)都看到被改写的 URL,而非原始上游地址。
  2. 什么原因导致的:旧实现([PR] fix(opencode-v2): stop rewriting the shared http.request payload — route model traffic at fetch time (#4276) #4280,已回滚)在钩子层直接替换共享 request 对象,而该对象被所有后续钩子共享——改写会泄漏给 provider 插件。根因是"在错误的层(钩子层)做路由",而非 fetch 时刻。
  3. 影响范围与严重程度:opencode 车道(V1+V2)下,provider 插件会看到 <proxy>/bili/<upstream> 而非原始上游 URL;若插件按 URL 做鉴权/路由会出错。特定条件下有问题(需同时装 provider 插件)。修复后恢复原始 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 打戳 + 本地拒绝;/bili/ 重写移到 fetch 时刻(installNativeFetchIntercept 共享链,由 opencode-native.ts 与 opencode.ts 的 setup() 都安装)。
  5. 是否有回归问题:本轮(rebase 到 548e396022)无新回归。已核对:master 重新加回的 replaceRequestTarget 其生产调用被本 PR 正确移除(泄漏路径),函数本体 + 单测保留(受测工具函数,非死代码);WS 隧道重建(routedBiliModelUrl)仍在;fetch 链在两个 setup 都在。高危模式逐项:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  6. 是否破坏缓存:不涉及。改动在请求路由层,不动缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及新方向——完成既有 providers.<url>.direct 机制,把 opencode 车道接入 fetch 时刻路由(与 zcode 存储车道同一 directExemptMatch 边界规则)。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:可合(人工合并),待 CI 全绿(当前 0 失败)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Pass-4 review complete (head 7c3c54d836, up-to-date with master 548e396022, 0 behind). Since pass 3 the branch only gained two CI-sentinel master merges (f21b601893, 548e396022) — no new PR-logical commits. The rebase onto the latest master is clean: the PR's own 11-file diff is intact, all core markers present, and master's re-added replaceRequestTarget is correctly handled (production leak usages removed, tested utility + its unit test retained — verified full-tree, not dead code). No new findings. CI: 0 failures (11 test shards still running). Verdict: clean / mergeable (human merge). Full review posted on the PR.

…lict resolution (#4599 help-merge)

Single conflict in scripts/live-files.mjs (LIVE_FILES registry): union-of-intent — kept master's new tests/storage-integrity-cache.test.ts (#7156) entry at its slot and appended this PR's tests/issue5625-opencode-v2-hook-payload.test.ts at table end (both SPAWN_RE tripwire-only, no zone band needed). docs/configuration.md + zh auto-merged; verified the PR's providers.direct V2 wording survives. Local: tripwire scan clean (1360 files / 72 registered / 0 unregistered), typecheck clean, build OK, targeted suites 97/97 green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已再次处理完毕:master(1e357bf2d6)已合入分支,唯一冲突已解,新 head 538a8d4136d 合并态回 blocked(可合并、待人工),CI 在新 head 上运行中(6 success + 8 skipped + 14 in progress + 3 queued,0 失败)。

本轮做了什么:

  1. 活体核实(不凭记忆):PR 远端 = 7c3c54d836(上一轮 11-20 的合并提交);master 已再前进至 1e357bf2d6(分支又落后 57 提交);git merge-tree 干跑确认 1 处真实冲突(scripts/live-files.mjs),与系统 dirty 判定一致。
  2. git merge origin/master --no-ff(用 merge 不用 rebase,保留分支既有提交历史、无需 force-push):恰好 1 处冲突 —— scripts/live-files.mjs(CI-lane tripwire 的测试文件登记表)。
  3. 冲突解法(union-of-intent):保留 master 新增的 tests/storage-integrity-cache.test.ts([Bug][storage] Takeover spawns before reclaim: old and new sidecars simultaneously hold index.db, causing corruption; em | [Bug][storage] 接管时先 spawn 后回收:新旧侧车同时持有 index.db 引发损坏;空 payload_json 又让历史会话静默变 0 #7156 close-time cache-refresh gate)登记在其槽位,本 PR 的 tests/issue5625-opencode-v2-hook-payload.test.ts 追加到表尾——两条都是 SPAWN_RE tripwire-only 登记(注释明确不需要 zone band),槽位平移对端口带映射无影响;两侧登记全部保留,无删改。
  4. 自动合并区域逐项核实:docs/configuration.md / docs/configuration.zh-CN.md 自动合并——本 PR 的 providers.<url>.direct OpenCode V2 措辞完整保留(en/zh 两侧均确认命中)。
  5. 本地验证:tripwire 逻辑复现(1360 个测试文件 / 72 登记 / 0 漏登记 spawner)、typecheck 干净、build 成功(dist 注解 + 外部依赖检查 OK)、定向套件 97/97 绿(本 PR 的 opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276) #5625 hook-payload、opencode native plugin: un-silenceable startup console.log noise + "opencode" config key falsely warned as unknown #5706 TUI 守卫、responses-websocket WS 隧道回归钉,以及 master 新动区域的 opencode-native、native-request-signal、identity-harvest、msgid-lane-identity、launcher-opencode-inline、issue5032-opencode-direct-window、storage-integrity-cache)。
  6. 普通 push(推送前 fetch 确认远端 head 仍为 7c3c54d836 未变,无 force-push)。

CI 结论(新 head 538a8d4136d,活体核实): 镜像缓存轮询器本轮仍停更在旧 sha,CI 状态以单次 GitHub API 读取核实(非轮询):PR head = 538a8d4136d,mergeable = true,mergeable_state = blocked(可合并、等待人工,不再是 dirty);31 个 check run = 6 success + 8 skipped(设计内 env-gated e2e 车道)+ 14 in progress + 3 queued,0 失败。全量裁决以远程 CI 跑完为准。

八问:

  1. 是什么问题:PR 分支落后 master 57 提交,两侧在 CI-lane 测试登记表 scripts/live-files.mjs 上各自追加条目形成 1 处文本冲突,merge state dirty 挡住合并。
  2. 什么原因导致的:双方在同一 append-only 登记表的表尾各自新增条目(master 加 storage-integrity-cache [Bug][storage] Takeover spawns before reclaim: old and new sidecars simultaneously hold index.db, causing corruption; em | [Bug][storage] 接管时先 spawn 后回收:新旧侧车同时持有 index.db 引发损坏;空 payload_json 又让历史会话静默变 0 #7156,本 PR 加 issue5625-opencode-v2-hook-payload)——常规并发编辑冲突,无语义分歧、无设计问题。
  3. 影响范围与严重程度:仅本 PR 的合并性被挡(dirty 不可合并);无用户功能影响;严重度 = 合并阻塞,无数据/行为风险。
  4. 怎么修复的:merge master 入分支(非 rebase),唯一冲突按 union-of-intent 解——两侧登记全保留、master 条目在其槽位、本 PR 条目追加表尾;本地复现 tripwire 逻辑验证登记表完整性(0 漏登记)。
  5. 是否有回归问题:无——冲突解是 append-only 登记表,无语义变更;docs 自动合并区域逐项核实(本 PR 的 providers.direct V2 措辞保留);本地 97/97 定向绿 + typecheck/build 干净;CI 在新 head 上 0 失败(运行中)。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突已解、本地验证全绿、合并态回 blocked,CI 在新 head 上运行中(0 失败),PR 就绪,等待人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Re-review (pass 5) — head 538a8d413

The branch advanced once more: the CI sentinel merged the latest master (1e357bf2d6) into it. No new PR-logical commits — the PR's own commits (b4c0347941, 0001a9b82d, d38027b0f5, 629a10a376) plus the sentinel's 7dad138221 are unchanged. The branch is up-to-date with master (1e357bf2d6, 0 behind).

Verified against the new base:

  • The PR's own diff is byte-identical to the prior head (same 11 files, 485+/74−). All core markers intact: production replaceRequestTarget usages gone (def + its unit test retained); directExemptMatch (def native-intercept.ts:341 / use :2028); isModelApiUrl bili-guard (:327/:397); installNativeFetchIntercept in BOTH setups (opencode-native.ts:493/979/1023, opencode.ts:136/183); WS routedBiliModelUrl tunnel rebuild (opencode-v2.ts:497); logHostEvent v2 bootstrap lines (both files).
  • The master advance pulled in #6816 (route OpenCode 2.x built-in Claude Agent provider through the proxy) — it lands in src/doctor.ts + src/plugin-install.ts (the install/doctor flow), zero overlap with this PR's files, so no interaction.
  • No kernel/ touched by the PR.

CI: fully green — 30/30 (17 success, 13 skipped, 0 failed).

Verdict: clean / mergeable (human merge). No new findings; the rebase onto the latest master is clean and the full suite is green.


8问(中文,供人工 reviewer)

  1. 是什么问题:opencode 车道的 http.request 钩子会改写共享的 e.request(把模型流量重写到 <proxy>/bili/<upstream>),导致每个后续钩子(含 provider 插件 Kiro/Antigravity)都看到被改写的 URL,而非原始上游地址。
  2. 什么原因导致的:旧实现([PR] fix(opencode-v2): stop rewriting the shared http.request payload — route model traffic at fetch time (#4276) #4280,已回滚)在钩子层直接替换共享 request 对象,而该对象被所有后续钩子共享——改写会泄漏给 provider 插件。根因是"在错误的层(钩子层)做路由",而非 fetch 时刻。
  3. 影响范围与严重程度:opencode 车道(V1+V2)下,provider 插件会看到 <proxy>/bili/<upstream> 而非原始上游 URL;若插件按 URL 做鉴权/路由会出错。特定条件下有问题(需同时装 provider 插件)。修复后恢复原始 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 打戳 + 本地拒绝;/bili/ 重写移到 fetch 时刻(installNativeFetchIntercept 共享链,由 opencode-native.ts 与 opencode.ts 的 setup() 都安装)。
  5. 是否有回归问题:本轮(rebase 到 1e357bf2d6)无新回归。PR 自身 diff 与上一轮逐字节一致(11 文件 485+/74−),核心标记全在;master 引入的 [Bug][opencode v2] Plugin-native mode is silently inactive for OpenCode's built-in Claude Agent provider: requests bypass the proxy and the mcp__opencode__* context tools have no session state #6816 落在 doctor/plugin-install(安装流程),与本 PR 文件零重叠,无交互。CI 全绿 30/30。
  6. 是否破坏缓存:不涉及。改动在请求路由层,不动缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及新方向——完成既有 providers.<url>.direct 机制,把 opencode 车道接入 fetch 时刻路由(与 zcode 存储车道同一 directExemptMatch 边界规则)。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:可合(人工合并),CI 已全绿。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Pass-5 review complete (head 538a8d413, up-to-date with master 1e357bf2d6, 0 behind). Since pass 4 the branch only gained one CI-sentinel master merge — no new PR-logical commits; the PR's own 11-file diff is byte-identical to the prior head. The master advance pulled in #6816 (OpenCode 2.x Claude Agent provider install routing), which lands in src/doctor.ts + src/plugin-install.ts — zero overlap with this PR's files, no interaction. No new findings. CI fully green 30/30. Verdict: clean / mergeable (human merge). Full review posted on the PR.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Pass-5 review of PR #5626 done — verdict: clean / mergeable (human merge).

What I verified this pass (head 538a8d413):

  • Branch is up-to-date with master 1e357bf2d6 (0 behind). Since pass 4 it gained only one CI-sentinel master merge — no new PR-logical commits; the PR's own 11-file diff is byte-identical to the prior head.
  • The master advance pulled in #6816 (OpenCode 2.x Claude Agent provider install routing) — it lands in src/doctor.ts + src/plugin-install.ts, zero overlap with this PR's files, so no interaction.
  • All core markers intact (fetch-time routing in both setups, directExemptMatch boundary rule, isModelApiUrl bili-guard, WS routedBiliModelUrl tunnel rebuild, logHostEvent v2 lines; production replaceRequestTarget usages gone, def + unit test retained).
  • CI fully green 30/30 (17 success, 13 skipped, 0 failed). No new findings.

Full review with the Chinese 8问 is on the PR (comment 7030863524) and is synced into this thread above.

…lict resolution (#4599 help-merge)

Single conflict in scripts/live-files.mjs (LIVE_FILES registry): union-of-intent — kept master's new tests/storage-backup-repair.test.ts (#7156) entry at its slot and appended this PR's tests/issue5625-opencode-v2-hook-payload.test.ts at table end (both SPAWN_RE tripwire-only, no zone band needed). docs/configuration.md + zh auto-merged; verified the PR's providers.direct V2 wording survives. Local: tripwire scan clean (1381 files / 73 registered / 0 unregistered), typecheck clean, build OK, targeted suites 105/105 green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

上游冲突已再次处理完毕:master(98fa9575f)已合入分支,唯一冲突已解,新 head e61137d1b 合并态回 blocked(可合并、待人工),CI 在新 head 上运行中(10 success + 12 skipped + 13 in progress,0 失败)。

本轮做了什么:

  1. 活体核实(不凭记忆):PR 远端 = 538a8d413(上一轮 11-21 的合并提交);master 已再前进至 98fa9575f(分支又落后 94 提交);git merge-tree 干跑确认 1 处真实冲突(scripts/live-files.mjs),与系统 dirty 判定一致。
  2. git merge origin/master --no-ff(用 merge 不用 rebase,保留分支既有提交历史、无需 force-push):恰好 1 处冲突 —— scripts/live-files.mjs(CI-lane tripwire 的测试文件登记表)。
  3. 冲突解法(union-of-intent):保留 master 新增的 tests/storage-backup-repair.test.ts([Bug][storage] Takeover spawns before reclaim: old and new sidecars simultaneously hold index.db, causing corruption; em | [Bug][storage] 接管时先 spawn 后回收:新旧侧车同时持有 index.db 引发损坏;空 payload_json 又让历史会话静默变 0 #7156 stale-lock fixture)登记在其槽位,本 PR 的 tests/issue5625-opencode-v2-hook-payload.test.ts 追加到表尾——两条都是 SPAWN_RE tripwire-only 登记(注释明确不需要 zone band),槽位平移对端口带映射无影响;两侧登记全部保留,无删改。
  4. 自动合并区域逐项核实:docs/configuration.md / docs/configuration.zh-CN.md 自动合并——本 PR 的 providers.<url>.direct OpenCode V2 措辞完整保留(en/zh 两侧均确认命中)。
  5. 本地验证:tripwire 逻辑复现(1381 个测试文件 / 73 登记 / 0 漏登记 spawner)、typecheck 干净、build 成功(dist 注解 + 外部依赖检查 OK)、定向套件 105/105 绿(本 PR 的 opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276) #5625 hook-payload、opencode native plugin: un-silenceable startup console.log noise + "opencode" config key falsely warned as unknown #5706 TUI 守卫、responses-websocket WS 隧道回归钉,以及 master 新动区域的 opencode-native、native-request-signal、identity-harvest、msgid-lane-identity、launcher-opencode-inline、issue5032-opencode-direct-window、storage-integrity-cache、storage-backup-repair)。
  6. 普通 push(推送前 fetch 确认远端 head 仍为 538a8d413 未变,无 force-push)。

CI 结论(新 head e61137d1b,活体核实): 镜像缓存轮询器本轮仍停更在旧 sha,CI 状态以单次 GitHub API 读取核实(非轮询):PR head = e61137d1b,mergeable = true,mergeable_state = blocked(可合并、等待人工,不再是 dirty);35 个 check run = 10 success + 12 skipped(设计内 env-gated e2e 车道)+ 13 in progress,0 失败。全量裁决以远程 CI 跑完为准。

八问:

  1. 是什么问题:PR 分支落后 master 94 提交,两侧在 CI-lane 测试登记表 scripts/live-files.mjs 上各自追加条目形成 1 处文本冲突,merge state dirty 挡住合并。
  2. 什么原因导致的:双方在同一 append-only 登记表的表尾各自新增条目(master 加 storage-backup-repair [Bug][storage] Takeover spawns before reclaim: old and new sidecars simultaneously hold index.db, causing corruption; em | [Bug][storage] 接管时先 spawn 后回收:新旧侧车同时持有 index.db 引发损坏;空 payload_json 又让历史会话静默变 0 #7156,本 PR 加 issue5625-opencode-v2-hook-payload)——常规并发编辑冲突,无语义分歧、无设计问题。
  3. 影响范围与严重程度:仅本 PR 的合并性被挡(dirty 不可合并);无用户功能影响;严重度 = 合并阻塞,无数据/行为风险。
  4. 怎么修复的:merge master 入分支(非 rebase),唯一冲突按 union-of-intent 解——两侧登记全保留、master 条目在其槽位、本 PR 条目追加表尾;本地复现 tripwire 逻辑验证登记表完整性(0 漏登记)。
  5. 是否有回归问题:无——冲突解是 append-only 登记表,无语义变更;docs 自动合并区域逐项核实(本 PR 的 providers.direct V2 措辞保留);本地 105/105 定向绿 + typecheck/build 干净;CI 在新 head 上 0 失败(运行中)。
  6. 是否破坏缓存:不涉及——未触碰缓存/重试/游标/去重逻辑。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

判定:冲突已解、本地验证全绿、合并态回 blocked,CI 在新 head 上运行中(0 失败),PR 就绪,等待人工合并。

@ranxianglei

Copy link
Copy Markdown
Owner Author

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

Re-review (pass 6) — head e61137d1b

The branch advanced once more: the CI sentinel merged master 98fa9575f into it. No new PR-logical commits — the PR's own commits (b4c0347941, 0001a9b82d, d38027b0f5, 629a10a376) plus the sentinel's 7dad138221 are unchanged. The PR's own 11-file diff is byte-identical to passes 4/5 (485+/74−). The branch is 8 commits behind the latest master (e8c2dae51) — not a merge blocker (GitHub merges via a merge commit).

Verified against the new base:

CI: 29/30 green (17 success, 12 skipped, 0 failed); one test shard (ubuntu-latest, node 22, shard 2) still in progress. Since the PR's own diff is byte-identical to the fully-green pass 5 and the master advance is in the baseline (coherent union verified above), the in-progress shard is expected to finish green.

Verdict: clean / mergeable (human merge). No new findings.


8问(中文,供人工 reviewer)

  1. 是什么问题:opencode 车道的 http.request 钩子会改写共享的 e.request(把模型流量重写到 <proxy>/bili/<upstream>),导致每个后续钩子(含 provider 插件 Kiro/Antigravity)都看到被改写的 URL,而非原始上游地址。
  2. 什么原因导致的:旧实现([PR] fix(opencode-v2): stop rewriting the shared http.request payload — route model traffic at fetch time (#4276) #4280,已回滚)在钩子层直接替换共享 request 对象,而该对象被所有后续钩子共享——改写会泄漏给 provider 插件。根因是"在错误的层(钩子层)做路由",而非 fetch 时刻。
  3. 影响范围与严重程度:opencode 车道(V1+V2)下,provider 插件会看到 <proxy>/bili/<upstream> 而非原始上游 URL;若插件按 URL 做鉴权/路由会出错。特定条件下有问题(需同时装 provider 插件)。修复后恢复原始 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 打戳 + 本地拒绝;/bili/ 重写移到 fetch 时刻(installNativeFetchIntercept 共享链,由 opencode-native.ts 与 opencode.ts 的 setup() 都安装)。
  5. 是否有回归问题:本轮(rebase 到 98fa9575f)无新回归。PR 自身 diff 与第 4/5 轮逐字节一致(11 文件 485+/74−),核心标记全在;master 大跨度推进(含 [Bug][storage] Takeover spawns before reclaim: old and new sidecars simultaneously hold index.db, causing corruption; em | [Bug][storage] 接管时先 spawn 后回收:新旧侧车同时持有 index.db 引发损坏;空 payload_json 又让历史会话静默变 0 #7156 存储备份/修复、[Bug][opencode][ingest/0.1.216] Long sessions on the opencode lane are permanently 413'd by the 32 MiB ingest hard limit | [Bug][opencode][ingest/0.1.216] opencode 车道的长会话被 32 MiB ingest 硬闸永久 413(且 #6908/#6933 的修复只豁免 dsh 车道,opencode 仍在外) #7426 ingest 带宽、kernel 0.0.201 等)只触碰本 PR 的 3 个文档/注册文件,合并 union 已逐一核对(PR 的 doc 增补 + LIVE_FILES 注册与 master 的增补并存,无覆盖)。CI 29/30 绿(0 失败,1 个 test shard 仍在跑)。
  6. 是否破坏缓存:不涉及。改动在请求路由层,不动缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及新方向——完成既有 providers.<url>.direct 机制,把 opencode 车道接入 fetch 时刻路由(与 zcode 存储车道同一 directExemptMatch 边界规则)。
  8. 是否引入了新的配置:不涉及。无新 env/config/默认值。

判定:可合(人工合并)。 CI 29/30 绿、0 失败,仅剩 1 个 test shard 在跑(PR 自身 diff 与全绿的第 5 轮逐字节一致,预期收尾即绿)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Pass-6 review complete (head e61137d1b). Since pass 5 the branch gained one CI-sentinel master merge (98fa9575f) — no new PR-logical commits; the PR's own 11-file diff is byte-identical to passes 4/5. The large master advance (storage backup/repair #7156, ingest band #7426, kernel 0.0.201, many web/proxy fixes) touched only 3 of the PR's files — docs/configuration.md, docs/configuration.zh-CN.md, scripts/live-files.mjs — and the merge union'd both cleanly (PR's doc addition + LIVE_FILES registration present alongside master's). All core markers intact. CI 29/30 green (0 failed), 1 test shard (ubuntu-latest, node 22, shard 2) still in progress — expected to finish green since the PR diff is byte-identical to the fully-green pass 5. Verdict: clean / mergeable (human merge). Full review posted on the PR.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

Re-review (pass 7) — head e61137d1b (unchanged since pass 6)

The branch has not advanced: head is still e61137d1b and the PR's own 11-file diff is byte-identical to passes 4/5/6 (485+/74−). Two things moved since pass 6:

CI is now fully green. Pass 6 left 29/30 with one test shard (ubuntu, node 22, shard 2) still in progress; it has since finished green. Current state: 30/30 completed, 0 failed, 0 pending (17 success + 13 skipped — the skips are the env-gated real-client e2e lanes, unchanged across all passes).

Master advanced 98fa9575f → f03e33576 (PR now 26 commits behind — not a merge blocker; GitHub merges via a merge commit). I checked the advance against the PR's 11 files: only docs/configuration.md / docs/configuration.zh-CN.md were touched, and only in the fakeCompletion section (~line 1113) — a different area from the PR's providers.<url>.direct edit (~line 1307). No semantic conflict; the merge unions both cleanly. All 7 source/test files are untouched by the advance.

My independent verification (re-done this pass, not a re-read of pass 6):

  • Traced the WS tunnel rebuild (src/agent/opencode-v2.ts:484-502) through all three input shapes — live /bili/ overlay, stale dead-origin overlay, raw model URL — and confirmed each yields the same ws://<live>/bili/responses/<upstream> the old rewrite+replace pipeline emitted. The stale-overlay case is exactly why branch 2 decodes via routedBiliModelUrl first (a /bili/ path fails isModelApiUrl by design, src/agent/native-intercept.ts:331).
  • Confirmed directExemptMatch (src/agent/native-intercept.ts:341) uses the same boundary rule as the zcode store lane (src/zcode/json-edit.ts:136 directExemptionHit): url === prefix || url.startsWith(prefix + "/") — so https://x.com never exempts https://x.com.evil.
  • Confirmed installNativeFetchIntercept is idempotent (returns false when a chain is already present, src/agent/native-intercept.ts:1557-1564), so the V1 server() + V2 setup() double-install is a silent no-op, not a double-wrap.
  • Ran the targeted suites locally: tests/issue5625-opencode-v2-hook-payload.test.ts (4/4) + opencode-native / opencode-launcher / responses-websocket / native-request-signal (60/60); typecheck clean.
  • version is 0.1.216 (untouched — correct for a content branch); no kernel/ in the diff; kernel-guard / version-guard / lane-guard / unused-exports all green.

One observation (not a blocker): replaceRequestTarget (src/agent/native-intercept.ts:1459) is now production-dead — only its own unit test (tests/native-request-signal.test.ts) exercises it. Pass 6 already noted the def + test were retained; I concur that's defensible (the test pins its signal-retention behavior and it's a general helper), so I'm flagging it for the record rather than requesting removal.

Verdict: clean / mergeable (human merge). CI 30/30 green, 0 failed; PR diff byte-identical to the green pass 6; master advance is a clean doc-area union; no regression found on independent re-verification.


8问(中文,供人工 reviewer)

  1. 是什么问题:opencode 车道(V1+V2)的 http.request 钩子会改写共享的 e.request(把模型流量重写到 <proxy>/bili/<upstream>),而 opencode 把同一个被改写的 Request 交给每一个后续钩子——包括 provider 插件(Kiro 响应桥、Antigravity base-URL 守卫)。这些插件按 URL 鉴权/路由,看到代理 URL 而非原始上游地址就静默坏了。
  2. 什么原因导致的:旧实现在钩子层直接替换共享 request 引用,而该对象被所有后续钩子共享——改写泄漏给了 provider 插件。根因是"在错误的层(钩子层)做路由";正确层是 fetch 时刻(provider SDK 在调用时解析 globalThis.fetch,可被共享 fetch 链拦截)。
  3. 影响范围与严重程度:opencode 车道(V1+V2)下,同时装了 provider 插件(Kiro/Antigravity 等)时,插件看到 <proxy>/bili/<upstream> 而非原始上游 URL,按 URL 鉴权/路由的插件静默出错。特定条件下有问题(需同时装 provider 插件);修复后所有后续钩子恢复看到原始 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 就地打戳 + 本地拒绝 + 对 providers.<url>.direct 豁免打 biliDirect 标记;/bili/ 重写移到 fetch 时刻(installNativeFetchIntercept 共享链,opencode-native.ts 与 opencode.ts 的 setup()/server() 都安装,幂等)。WS 隧道从"改写后的 URL"改为"按到达形状 + 存活 origin 重建",三种输入形状逐字节等价于旧管线。
  5. 是否有回归问题:无。本轮独立核对——钩子不再改写共享 request(测试断言 e.request === original 对象同一性);fetch 时刻重写产出正确的 <origin>/bili/<url>;WS 隧道三形状逐字节等价;V1 路径本就用 fetch 链、V2 现也接入,双安装幂等无双重包裹;direct 豁免是 config 门控(opt-in),不影响存量用户。master 推进只碰 2 个 doc 文件且在 fakeCompletion 段(~1113 行),与 PR 的 direct 字段改动(~1307 行)不同区,合并无语义冲突。CI 30/30 绿、0 失败。
  6. 是否破坏缓存:不涉及。改动在请求路由层,不动缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及新方向——完成既有 providers.<url>.direct 机制,把 opencode 车道接入 fetch 时刻路由(与 zcode 存储车道同一 directExemptMatch 边界规则),并把路由决策点从钩子层下移到 fetch 层。
  8. 是否引入了新的配置:不涉及。direct 字段本就存在([Bug] zcode 原生模式路由白名单与主流用法错配:多模型/子代理场景需要全量压缩,仅 plan 账号反而是少数 #1622),本 PR 只是补齐 opencode 车道对它的支持;无新 env/config/默认值。

判定:可合(人工合并)。 CI 30/30 绿、0 失败,PR 自身 diff 与全绿的第 6 轮逐字节一致,master 推进为 doc 区干净 union,独立复核无回归。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

APPROVE — head e61137d1b

Formal review verdict. The full independent verification is in the preceding pass-7 comment (same head); this confirms the state is unchanged and green.

Why clean:

  • CI 30/30 green (17 success + 13 skipped env-gated e2e lanes, 0 failed, 0 pending) at head e61137d1b; mergeable_state: behind is not a blocker (GitHub merges via a merge commit).
  • No kernel/ in the diff, no kernel-change declaration → the authorization boundary (HARD RULE 5) is not triggered; no human-tier kernel gate required.
  • No regression on independent re-verification (pass 7): hook no longer rewrites the shared e.request (test asserts object identity e.request === original); fetch-time rewrite emits the correct <origin>/bili/<url>; WS tunnel rebuild is byte-identical to the old pipeline across all 3 input shapes; directExemptMatch boundary rule matches the zcode lane; installNativeFetchIntercept is idempotent (V1+V2 double-install is a no-op, not a double-wrap).
  • No behavior drift: version 0.1.216 untouched (correct for a content branch); the direct field pre-existed ([Bug] zcode 原生模式路由白名单与主流用法错配:多模型/子代理场景需要全量压缩,仅 plan 账号反而是少数 #1622) — this PR only completes opencode-lane support for it; no new env/config/default.
  • Master advance (98fa9575f→f03e33576) touched only the two docs/configuration*.md files in the fakeCompletion section (~line 1113), a different area from the PR's providers.<url>.direct edit (~line 1307) — clean union, no semantic conflict.

Small findings: none requiring a fix commit. (replaceRequestTarget at src/agent/native-intercept.ts:1459 is production-dead — only its own unit test exercises it — but it is a defensible general helper, the project's unused-exports guard passes, and it was intentionally retained; below the fix-effort bar, so dropped, not filed.)


8问(中文,供人工 reviewer)

  1. 是什么问题:opencode 车道(V1+V2)的 http.request 钩子改写共享的 e.request(把模型流量重写到 <proxy>/bili/<upstream>),而 opencode 把同一个被改写的 Request 交给每一个后续钩子——provider 插件(Kiro/Antigravity)按 URL 鉴权/路由,看到代理 URL 而非原始上游地址就静默坏了。
  2. 什么原因导致的:旧实现在钩子层直接替换共享 request 引用,该对象被所有后续钩子共享——改写泄漏给 provider 插件。根因是"在错误的层(钩子层)做路由";正确层是 fetch 时刻(provider SDK 在调用时解析 globalThis.fetch,可被共享 fetch 链拦截)。
  3. 影响范围与严重程度:opencode 车道(V1+V2)+ 同时装 provider 插件时,插件看到代理 URL 而非原始上游 URL,按 URL 鉴权/路由的插件静默出错。特定条件下有问题(需同时装 provider 插件);修复后所有后续钩子恢复看到原始 URL。
  4. 怎么修复的:钩子只做发现(state.proxyBase)+ 就地打戳 + 本地拒绝 + 对 providers.<url>.direct 豁免打 biliDirect 标记;/bili/ 重写移到 fetch 时刻(installNativeFetchIntercept 共享链,opencode-native.ts 与 opencode.ts 的 setup()/server() 都安装,幂等);WS 隧道按到达形状 + 存活 origin 重建,三种输入形状逐字节等价旧管线。
  5. 是否有回归问题:无。钩子不改写共享 request(对象同一性测试);fetch 时刻重写正确;WS 三形状逐字节等价;双安装幂等无双重包裹;direct 豁免 config 门控(opt-in)不影响存量用户;master 推进只碰 2 个 doc 文件且在 fakeCompletion 段(~1113 行),与 PR 的 direct 改动(~1307 行)不同区,合并无语义冲突。CI 30/30 绿、0 失败。
  6. 是否破坏缓存:不涉及。改动在请求路由层,不动缓存/重试/增量游标/去重键。
  7. 是否改了设计方向:不涉及新方向——完成既有 providers.<url>.direct 机制,把 opencode 车道接入 fetch 时刻路由(与 zcode 存储车道同一 directExemptMatch 边界规则),路由决策点从钩子层下移到 fetch 层。
  8. 是否引入了新的配置:不涉及。direct 字段本就存在([Bug] zcode 原生模式路由白名单与主流用法错配:多模型/子代理场景需要全量压缩,仅 plan 账号反而是少数 #1622),本 PR 只补齐 opencode 车道支持;无新 env/config/默认值。

判定:APPROVE(可合,人工合并)。 CI 30/30 绿、0 失败;无 kernel 改动、无授权门禁;独立复核无回归、无行为漂移、无缓存破坏。合并按仓库规则由人工执行。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode lane: native /bili/ URL rewrite breaks provider-scoped plugins (rework of reverted #4280 / #4276)

2 participants