Skip to content

feat(#1958): warn on conflicting pre-routed /bili/ opencode config — expose, don't absorb, don't gate install - #2020

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-04_opencode-v2-routed-warn
Oct 4, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-04_opencode-v2-routed-warn

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1958. Supersedes #1959 and #1972.

定性(维护者拍板)

"native 插件 + 手写 /bili/ provider baseURL" 是矛盾配置:两条互斥接入路径同时认领同一批请求的路由权。纠正手段是运行时响亮警告:

改动

验证

  • tests/issue1958-routed-warn.test.ts 4/4;tests/opencode-native.test.ts 34/34;tests/opencode-v2.test.ts 31/31(干净 env)
  • tsc --noEmit --project tsconfig.build.json rc=0;tsconfig.json 下仅剩 dsh-settings-ui 的 4 个 pnpm-only esbuild 既有误报(CI 用 npm 不受影响)

七问速答

  1. 是啥:矛盾配置的暴露层。2. 原因:预烤前缀与插件路由权冲突且从不被看见。3. 修复:每 (session,origin) 一次运行时警告+指引,请求行为不变。4. 回归:无——唯一新增行为是 console.error;34+31 既有用例全绿。5. 缓存:不涉及。6. 方向:执行 owner 最新拍板(警告即可,不拒绝不盖章),替代 fix(#1958): bind V2 hook proxyBase to the baked origin on already-routed model requests #1959/feat(#1958): expose conflicting pre-routed /bili/ opencode configs at install and runtime #1972。7. 新配置:无。

…expose, don't absorb, don't gate install

Maintainer direction change on #1958: the 'native plugin + hand-written
/bili/ provider baseURL' combo is a conflicting configuration (two access
paths claiming routing ownership of the same requests). The correction is
a loud runtime warning — not silent compat (no stamping/rewrite, the
request stays on the plain-proxy path it encodes) and not an install-time
refusal (a scanner false positive would permanently block installs).

- src/agent/opencode-native.ts (createNativeRoute): on a pre-routed model
  URL, warn once per (session, origin) unless BILLION_CONTEXT_PROXY pins
  the SAME origin (supported attach posture — compared via URL.origin so
  trailing-slash/default-port spellings fold; env, not state.origin,
  because attach arming does not freeze state.origin synchronously).
  No behavior change to the request itself: #1365 pinned-channel
  recording (noteRoutedOrigin) and the isModelApiUrl fall-through are
  untouched; s.proxyBase stays unset for pre-routed URLs.
- tests/issue1958-routed-warn.test.ts: 4 cases — dedup per (session,
  origin) + no stamping; benign pin silent incl. port folding; mismatched
  pin warns; non-model /bili/ paths and /__bili/health never warn.
- CLIENTS(.zh-CN).md / CONFIGURATION(.zh-CN).md: the three OpenCode access
  paths are mutually exclusive; runtime warning + fix-it guide documented.

Supersedes #1959 (silent stamping) and #1972 (install refusal + stamping).
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-04_opencode-v2-routed-warn (2582c73)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.2052-pr.2020.35c26d0

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

Option B — Download artifact

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

Install instructions are refreshed on each push.

…URATION.md

The note was inserted between the Codex intro line and its toml example,
making it read as part of the Codex section. Placed after the OpenCode
jsonc block instead — matching the CONFIGURATION.zh-CN.md layout.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

Review 结论(#2020,head 2582c730,base = 当前 master,无需 rebase)

方向关(原 issue):与 floor 9 拍板完全一致——矛盾配置只做运行时响亮暴露:不盖章、不改写、不拦安装。#1959/#1972 已关闭并被取代,无并行工作。修的是「冲突从未被看见」这个暴露层缺陷,请求路径零改动。

回归审查(既有行为逐项清点):

  • launcher lane(bili opencode):launcher 给子进程设 BILLION_CONTEXT_PROXY=<origin> 且把 baseURL 重写为 <origin>/bili/… → baked===declared 静默;且 launcher 注入的 thin plugin 不带 route option,警告代码根本不进入。✅ 无误报
  • spawn mode:bootstrap 同步置 env=handle.origin → 插件重写过的 URL 重放时静默。✅
  • attach mode:env 在 arming 同步冻结,verifyAttachAndRecover 与 rebind 保持同步,死亡 fallback 先删 env 再 respawn → 陈旧手写前缀被判冲突是正确告警。比 env 而非 state.origin 的理由(attach 不同步冻结 state.origin)已在代码注释说明,成立。✅
  • stamping 路径(stampHeaders 需 proxyBase):pre-routed fall-through 使 proxyBase 保持 undefined → 无 x-bili-plugin 头 → proxy mode。这是有意保留 [Bug][OpenCode V2] 已带 /bili/ 前缀的模型请求跳过 proxyBase 初始化,缺失插件会话标记 #1958 的缺标记结果(拍板:不盖章)。✅
  • bug: dsh-native — attach 目标瞬时不可达 → 回退 spawn 第二实例:routed baseURL 下工具/模型通道必然脑裂(工具 404 → preflight 502 → 会话不可自愈) #1365 pinned channel:noteRoutedOrigin 仍最先执行,证据记录不变;测试 3 钉住冲突时不动 pinned channel。✅
  • 谓词边界:routedBiliModelUrl 只匹配 /bili/(responses/)?<model-endpoint>;非模型 /bili/ 路径与 /__bili/health 不进警告分支(测试 4);WS handshake 走同一 route,dedup key 相同,不会双报。✅
  • V1 lane(观察,非阻塞):V1 rewriteV1Providers 把手写 /bili/ 前缀静默 re-home 到插件自己的 origin(设计如此,早于本 PR,本次未动)。若将来要求两 lane 统一暴露语义,可另议。

代码关:dedup key ${sessionID}\u0000${baked} 防跨会话/跨源误去重;分支内 new URL(url) 不可抛(regex 保证绝对 http(s));Set 上限 sessions×origins,内存可忽略;console.error 与本模块既有模式一致(agent 侧文件)。

测试有效性:4 个新用例断言有牙——精确计数分别抓得住去重破坏、盖章回归、谓词漂移、指引文案丢失。本地定向验证:issue1958 4/4、opencode-native 34/34、opencode-v2 31/31 全绿;tsc --noEmit --project tsconfig.build.json rc=0。

diff 整洁度:6 文件 +181/-1,每行都为目的服务;两个线性 commit(第二个修文档落位);en/zh 四份文档同步且内容与实现一致。

七问:

  1. 是什么问题:native 插件 + 手写 /bili/ provider baseURL 是矛盾配置——两条互斥接入路径同时认领同一批请求的路由权,此前从不被看见(静默降级 proxy mode、plugin session markers 缺失)。
  2. 什么原因导致的:createNativeRoute 的 routed 分支在 noteRoutedOrigin 后经 isModelApiUrl 落空提前 return,跳过 proxyBase 初始化;宿主进程侧没有任何通道能察觉「前缀已存在」。
  3. 怎么修复的:在决策点暴露——预烤模型 URL 进入时,除非 BILLION_CONTEXT_PROXY 钉住同一 origin(URL.origin 归一化,尾斜杠/默认端口折叠),否则每 (session, origin) 一次 console.error + 二选一指引;请求字节零改动。
  4. 是否有回归问题:无。上述六条既有行为逐项过完均保持。行为变更披露:旧行为 = 矛盾配置不可见、请求无声走 proxy mode 且无 plugin markers;新行为 = 请求行为完全不变 + 每 (session, origin) 一条 stderr 警告——即拍板要求的暴露层,非漂移。
  5. 是否破坏缓存:不涉及(无缓存/重试/游标/去重键变更;conflictWarned 为进程内内存 Set,不参与持久化或上游缓存)。
  6. 是否改了设计方向:不涉及——执行 owner 最新拍板,取代 fix(#1958): bind V2 hook proxyBase to the baked origin on already-routed model requests #1959/feat(#1958): expose conflicting pre-routed /bili/ opencode configs at install and runtime #1972;架构/边界/数据流未转向。
  7. 是否引入新配置:无(无新 env/config/CLI)。

判定:CI 15/15 全绿(e2e 全矩阵 + registry e2e + 各 real-lane),本地定向测试与 typecheck 通过,方向/回归/测试/diff 四关全过——可合。按规则我不代合,请手动合并:#2020

@ranxianglei
ranxianglei merged commit ec95a6d into master Oct 4, 2026
15 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-04_opencode-v2-routed-warn branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][OpenCode V2] 已带 /bili/ 前缀的模型请求跳过 proxyBase 初始化,缺失插件会话标记

1 participant