Skip to content

插件车道进仓库:真宿主 CLI × 真模型回归(#3416),远程默认不跑 - #3462

Merged
ranxianglei merged 7 commits into
masterfrom
feat/gate-plugin-lanes
Oct 17, 2026
Merged

ranxianglei merged 7 commits into
masterfrom
feat/gate-plugin-lanes

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

ai: zhipuai-lb/glm-5.3

插件车道进仓库:真宿主 CLI × 真模型(#3416)

这是干什么的

发版前的本地真模型回归现在能测插件模式了。之前 gate 只测代理模式,#3401 那种「dsh 插件会话里工具明明在 wire 上、nudge/压缩提示却被整关」的回归,gate 全程绿灯(实测:master 含病构建 gate GREEN,exit 0)。

本 PR 把车道脚本放进仓库,和被测代码同版本演进:

断什么

  • 上游流量、ACP 工具(compress/acp_status/…)真的在 wire 的 tools 里
  • 插件 claim:会话文件 payload.metadata.pluginAgent
  • nudge 硬断言:wire 上必须出现 nudge 文本——不接受「日志里有 INJECT」(注入可能落在永不转发的错误响应里,是假绿)
  • fold 开火(acp-compress-obs] shrink N%)、折后暗号回忆、无 unknown-tool 空转
  • 窗口收缩靠改宿主自己的模型配置(有效窗口经 x-bili-plugin-context-window 头),中窗从实测 usage 自校准到 75-95% 压力带

远程默认不跑

  • ci-gate-plugins.yml 仅 workflow_dispatch 手动触发,无 push/PR 触发器;没配 GATE_MODEL1_BASE_URL secret 时跳过且绿
  • 容器化包装(Docker/verdaccio/模型端点)留在仓库外的各机 harness——本 PR 不含任何机器细节
  • 本地跑法见 scripts/gate/README.md

红绿双证(#3416 验收)

测试

车道本身就是测试(真模型、真 CLI)。CI:无影响(新 workflow 无触发器;scripts/ 下无单测)。仓库其余零改动。

scripts/gate/plugin-lanes.mjs + upstream-recorder.mjs: drive dsh/pi/codex/
claude/opencode through native and /bili/ prefix lanes against a real model,
asserting on the recorded wire (tools declared, hard nudge-on-wire, fold,
marker recall, no unknown-tool loops). ci-gate-plugins.yml is manual-only
(workflow_dispatch, no push/PR trigger, skips green without an endpoint
secret). Container harness stays out of the repo.
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: feat/gate-plugin-lanes (eaa4c57)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4111-pr.3462.378ca2b

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-pr3462.tgz
npm install -g package

Install instructions are refreshed on each push.

awork added 2 commits October 17, 2026 09:44
The recorder logged every request header verbatim; bili forwards the model API key into this hop on every request, so the key landed in upstream.jsonl on disk. Mask authorization/proxy-authorization/cookie/x-api-key/api-key values, and warn once on stderr if the JSONL cannot be written instead of swallowing it silently.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 open+closed issue 与 PR 全检索过:相关条目只有 #3416(本 PR 的原始 issue)、#3417(同 bug 家族根因——四条 wire 适配器各带一份车道判定拷贝且已漂移,机制不同,已有独立修复在途)、#3461(真模型压测发现的三个问题,解释了 opencode2 为何不进默认集)。没有别的 #3416 平行实现。

方向审核(对照 #3416):方向对——车道进仓库与被测代码同版本演进、以「模型实际收到的 wire」而非内部日志为真相源,正是治 #3401 那类「日志说 ARMED-SUPPRESSED、gate 全程绿灯」的正解。与原始 issue 字面有两处偏差,分开列:

  1. DSH 只有 plugin-native 一条车道,没有 proxy 车道。原 issue 明确要 DSH 双车道。当前矩阵覆盖 两条激活路径 × 3 种 wire(chat-native / responses-prefix / anthropic-prefix),缺的格子是「proxy 模式下的 chat wire」。核心验收([bug] #3177 的 DSH compress-surface 抑制在「agent 能看到 bili 工具」的 DSH 环境下误伤:nudge 与 compress 系统提示被永久关闭 #3401 构建红 / 含修复构建绿)由 dsh-native 车道单独满足,此偏差不影响验收;我的建议:接受本 PR,dsh-proxy 车道另开 follow-up 补上(约 40 行,抄 codex recipe 形状即可);是否要求合并前先补,由你拍板。
  2. opencode2 车道有代码但不进默认集——有 Three issues found during real-model stress testing: WS passthrough can't connect — HTTP upstream is guaranteed to die; | 真模型压测发现的三个问题:WS 直通连不上 HTTP 上游必死、超限时死锁+紧急提示风暴、compress 激活本身太重 #3461 证据支撑(WS 直通对 HTTP-only 上游握手即死;http transport 依赖上游 /v1/responses 质量),README 和运行时 NOTE 都写明了,GATE_AGENTS=opencode2 可 opt-in。处理得当。

回归审查:diff 触碰既有产品行为为零——5 个文件全部纯新增(3 个新脚本 + 1 个新 workflow + 1 行 changelog;changelog 条目位置核实在 [Unreleased]→Added 下)。ci-gate-plugins.yml 逐行读过:仅 workflow_dispatch 触发器,无 push/PR 触发器;permissions contents:read;secret 未配时 notice + exit 0(跳过且绿,与描述一致)。无新 bili 配置/env(GATE_* 等只被 harness 脚本消费,README 有文档)。kernel/、update.ts、持久化、wire 协议:零改动。

代码审查要点(断言串全部对照当前 master 源码逐条验证过):

  • NUDGE_WIRE_RE 与 kernel/src/nudge-text.ts:32/40 的两段 nudge 文本逐字吻合(含 em-dash);fold 正则匹配 src/stream.ts:983 的 [acp-compress-obs] shrink N%;logNudge/ARMED-SUPPRESSED 与 src/server.ts nudge 决策行的格式吻合。三个断言串都验了,不是猜的。
  • 失效方向正确:recorder 写盘失败 → wire 断言看到零请求 → 红,不会假绿;清理逻辑(杀 proxy/recorder/自起实例)在 try 之外,必达。
  • hermetic 做得好:cleanEnv 剥掉环境里的 HTTP(S)_PROXY(防 claude 这类 plain-fetch 宿主经 x-bili-hop 二次穿过另一个 bili)、每车道独立 HOME/XDG、recorder 与手动 proxy 都只绑 127.0.0.1。
  • 已知耦合(不拦,记录在案):NUDGE_WIRE_RE 耦合 kernel 拥有的提示词措辞(golden-pinned,改动要走 justification 流程,可接受);harvestWireModels 依赖 [window] model=X source= 日志格式;dsh setWindow 只替换第一个 contextWindow(驱动的是第一个模型,无影响)。

测试有效性:核心断言「nudge reached the model (hard)」有牙且无 OR 兜底——这正是 #3416 的核心诉求;tools-on-wire、pluginAgent claim、fold 开火、折后暗号回忆、unknown-tool 守卫都是真断言。「model invoked plugin tool」是条件软记录(命中才记,不命中不算失败)——属有意设计(模型自主性),其缺失会被 fold 断言兜住。红绿双证基于作者实跑(本沙箱没有真模型端点/宿主 CLI,无法复跑);已确认 #3401 的修复在 master(Unreleased changelog 的 lane-decisions 条目),与「含 #3403 全绿」的说法自洽。

已直接推到分支的两个小修(独立标注 commit,新 head eecdcf2bb,CI 在新 head 重跑):

  1. upstream-recorder.mjs 原先把请求头原样落盘——bili 每一跳都把模型 API key 转发到这个 recorder,key 会明文写进 upstream.jsonl。现对 authorization/proxy-authorization/cookie/x-api-key/api-key 的值打码,JSONL 写失败时 stderr 一次性告警而非三处静默吞掉。本地冒烟实测:打码生效、转发正常、响应行正常。
  2. plugin-lanes.mjs mid-window 自校准循环里一行缩进错位,对齐。

PR 描述小瑕疵:正文说「仓库其余零改动」,实际还动了 CHANGELOG.md(+1 行,条目内容与位置都没问题,只是措辞不准)。

CI 状态(审时):已完成的全部 check 绿(static-gates、各 guard、docs-sync、gate 分片、build-artifact 等),4 个 test 分片当时仍在跑;新 head 会整体重跑。

结构化八问:

  1. 是什么问题:发版前真模型回归只覆盖代理模式,[bug] #3177 的 DSH compress-surface 抑制在「agent 能看到 bili 工具」的 DSH 环境下误伤:nudge 与 compress 系统提示被永久关闭 #3401 那类「插件会话工具在 wire 上、nudge/compress 提示被整关」的回归能全程绿灯溜过 gate——本 PR 把真宿主×真模型的插件车道放进仓库补上这个盲区。
  2. 什么原因导致的:老 gate 只把 dsh headless 当 driver 走 profile 托管的裸 endpoint(pluginMode=false),抑制条件在 gate 里永远不为真;叠加 nudge 断言是 OR 正则、preflight 单独满足即过。
  3. 影响范围与严重程度:产品行为零变化(纯测试设施)。修前严重度在流程层面高:任何插件模式抑制类回归都能溜过发版 gate;不直接影响用户。合并后此类回归会在 gate 变红。
  4. 怎么修复的:车道随仓库与被测代码同版本演进;bili 与真模型之间垫记录垫片,所有断言做在「模型实际收到的东西」上;每车道 wire 级 nudge 硬断言(不接受日志捷径);窗口收缩改写宿主自己的模型配置;中窗从实测 usage 自校准到 75–95% 压力带;远程 CI 仅手动触发、默认关。
  5. 是否有回归问题:无。逐项审过既有行为:请求管线/压缩语义/持久化/配置面/CI 触发面均未触碰(diff 纯新增);无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:不涉及(未触碰任何缓存/重试/增量游标/去重键逻辑)。
  7. 是否改了设计方向:产品侧不变;测试设施侧有意扩面——gate 获得「真宿主×真模型插件模式」维度,容器化 harness(Docker/verdaccio/模型端点)刻意留在仓库外。理由:与被测代码版本同步 + 仓库不带机器细节。
  8. 是否引入了新的配置:bili 自身零新增配置/env。harness 局部 GATE_/MODEL1_ env 见 scripts/gate/README.md;远程跑需在 repo secrets 配 GATE_MODEL1_BASE_URL/MODEL/API_KEY(仅手动 dispatch 时使用,未配则跳过且绿)。

判定:建议合并。 唯一悬而未决:dsh-proxy 车道是否要求合并前补齐——我的建议是不阻塞,另开 follow-up 补矩阵最后一格。合并按你的规矩来。

- BILI_ZONE_PORT per native lane (19000+hash): a leftover proxy on the
  default 18787 can no longer capture a lane or force a mid-run drift
- BILI_MODEL_INFO_RETRY_MS=1000: the dsh native plugin's boot-time
  model-info resolve races the host's provider-adapter registration
  ("no adapter registered"), and the failure shape eats a 30s cooldown —
  longer than a whole short headless turn; 1s retry + a leading cheap
  bash tool call per prompt (warmupPrefix) guarantees request #2+ lands
  with the x-bili-plugin-context-window header stamped
- t3/t4 retry loop (2x) absorbs tag-echo-only empty replies
…opencode-v1 bin knob

- seed mid from the biggest t1 request body on the wire (idle log lines
  lag the corpus read; a stale line put dsh t2 at 285% usage and the
  EMERGENCY nudge rode a fail-fast 502 that never forwarded)
- t2 retry: up to 3 attempts, require in-band + ok + non-empty + the
  S07 marker (wrong-marker answers get one cheap retry)
- dsh setWindow rewrite all contextWindow entries (multi-model cordis)
- opencode v1 bin honors GATE_OC1_BIN (image installs it as opencode-v1;
  plain 'opencode' resolves to the v2 line whose managed service fights
  the port and crashes at cli.server-connect)
scripts/gate/README.md becomes the English document (repo docs are
English-first); the previous Chinese text moves verbatim to
README.zh-CN.md, cross-linked from both headers. Ref #3475.
@ranxianglei
ranxianglei merged commit 95b39e5 into master Oct 17, 2026
39 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.513-master.95b39e5 (rolling master tag).

npm install -g billion-context@0.0.513-master.95b39e5  # this exact build
npm install -g billion-context@master  # always the newest merged build

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant