From eb56cb756fb203009f9a1a2eadbb6ed82a633fbc Mon Sep 17 00:00:00 2001 From: awork Date: Sat, 17 Oct 2026 14:27:45 +0800 Subject: [PATCH 1/2] feat(gate): dsh protocol matrix + proxy lane with per-door wire assertions (#3475) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend the dsh gate lanes from one protocol to all four pi-ai protocols (openai-completions / openai-responses / anthropic-messages / google-generative-ai) plus a dsh proxy-mode lane for same-host two-activation-path contrast. Same headless driver and corpus flow; only the cordis provider api + baseURL suffix differ per lane. - per-door WIRE_EXPECT hard assertion: every recorder POST must match the door path regex AND body top-level shape; first request dumped to egress-sample.json as round-trip evidence - blocked semantics: ENV-BLOCKED (door unhealthy: all-rejected or degraded mid-flow, opencode2/#3461 rule) and CLIENT-BLOCKED (client config surface cannot express the api yet — dsh's cordis schema lists no google-generative-ai in 0.2.0-rc.2 / 0.2.1-rc.1); excluded from tally, printed at exit - calibration fixes from real-model runs: GATE_OUTPUT_TOKENS (thinking models degenerate when output budget < thinking budget), p1 = max over full post-t1 log, post-fold small-window widening for adaptive recipes, mid-seed guard, lane-local dsh install (GATE_DSH_VERSION) + lane TMPDIR - t1 dual marker (S40+S07): verify the read precondition so downstream S07 recalls can't fail for fixture reasons Existing lanes' generated configs are byte-identical to pre-#3475 (parity harness); new lanes are GATE_AGENTS opt-in. Local real-model run: 56/56 passed (dsh-responses:env, dsh-google:client). --- .github/workflows/ci-gate-plugins.yml | 2 +- scripts/gate/README.md | 73 ++++- scripts/gate/README.zh-CN.md | 56 +++- scripts/gate/plugin-lanes.mjs | 435 +++++++++++++++++++++----- 4 files changed, 485 insertions(+), 81 deletions(-) diff --git a/.github/workflows/ci-gate-plugins.yml b/.github/workflows/ci-gate-plugins.yml index 6a14dc01c8..3eaad84aaf 100644 --- a/.github/workflows/ci-gate-plugins.yml +++ b/.github/workflows/ci-gate-plugins.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: inputs: agents: - description: "comma-separated lanes: dsh,pi,codex,opencode,claude" + description: "comma-separated lanes: dsh,pi,codex,opencode,claude (+ dsh matrix/proxy #3475: dsh-responses,dsh-anthropic,dsh-google,dsh-proxy)" required: false default: "dsh,pi,codex,opencode,claude" diff --git a/scripts/gate/README.md b/scripts/gate/README.md index 424096b55b..93cf32d24e 100644 --- a/scripts/gate/README.md +++ b/scripts/gate/README.md @@ -33,10 +33,68 @@ actually received — internal logs can be fooled by suppression-class bugs S40 last CODEWORDS markers) - no `unknown tool` loops +## dsh protocol matrix (#3475) + +dsh's model client (pi-ai) speaks all four common protocols, so the dsh lane +expands from one door to four — same headless driver, only the cordis provider +`api` and the baseURL suffix change; the t1→t4 flow and assertions are +unchanged: + +| lane | pi-ai api | bili front door | upstream door required | +|------|-----------|-----------------|------------------------| +| `dsh` (original) | openai-completions | `/v1/chat/completions` | chat completions | +| `dsh-responses` | openai-responses | `/v1/responses` | a real `/v1/responses` (404 / mapping 400 → env-blocked) | +| `dsh-anthropic` | anthropic-messages | `/v1/messages` | `/v1/messages` (cross-checks the claude lane) | +| `dsh-google` | google-generative-ai | `/v1beta/models/:streamGenerateContent` | a `/v1beta` google door | +| `dsh-proxy` | openai-completions (**proxy mode**) | `/bili/…/v1/chat/completions` | chat completions (via the `/bili/` prefix) | + +`dsh-proxy` is the **other activation path** of the same host (owner add-on): +the profile does **NOT** load the billion-context bundle (its fetch intercept +would stamp `x-bili-plugin` and flip the lane back into plugin mode); dsh +drives the manually started proxy's `/bili/` URL directly — the same shape as +codex/claude. Contrasted with the native `dsh` lane within ONE script: +#3177/#3401-style suppression only exists on the plugin path; in proxy mode +nudge/fold must ride the wire with the acp_summary carrier; window truth = +bili.json (like every prefix lane). + +Every door gains a **wire-shape hard assertion**: each recorder POST through +the door must match the protocol's path AND top-level body fields +(chat=`messages` / responses=`input` / anthropic=`system`+blocks / +google=`contents`) — a silent rewire must not read green; the first egress +request is dumped to `//egress-sample.json` as round-trip +evidence. + +Two known facts: + +- **bili does not translate google→chat on egress** — the recorder sees exactly + the google shape dsh sends (`:streamGenerateContent` + contents/parts). The + google lane can only go fully green against an upstream that has a real + google door; requiring "it must come out as chat" would be a new + egress-translation feature for bili — separate issue. +- **blocked demotion rules** (two kinds; the script prints an + `ENV-BLOCKED`/`CLIENT-BLOCKED [lane] ` line at the end): + - **env**: the upstream door is unhealthy — ALL requests on the door are + 4xx/5xx/connection errors with no turn completed (the original + opencode2/#3461 rule), OR degraded mid-flow (some 200s at first, then + rejections, the flow never completes — the classic self-hosted + responses→chat mapping-bug shape, #3461 sibling). Traffic + wire shape + stay hard assertions; turn-dependent records drop out of the gate tally. + - **client**: the client version cannot express the api at all (dsh + ≤0.2.1-rc.1 cordis schema lists only openai-completions / openai-responses / + anthropic-messages; google-generative-ai exists in the pi-ai library but + dsh's config surface does not expose it) — zero upstream traffic + every + turn dies on a ValidationError. The whole lane drops out of the gate; it + auto-promotes when the client ships the protocol — no script change needed. + +Not in the default GATE_AGENTS set; runs only when explicitly listed: +`GATE_AGENTS=dsh,dsh-responses,dsh-anthropic,dsh-google,dsh-proxy`. + ## Lane flow -1. **t1 @ big window**: read the corpus, echo the S40 codeword (fold must NOT - fire in this phase) +1. **t1 @ big window**: read the corpus, echo the S40 + S07 codewords (dual + marker proves the corpus middle was really read — models may chunk-read or + elide the middle, and an elided middle turns the later S07 recall assertions + into false reds; fold must NOT fire in this phase) 2. **window shrink**: rewrite the **host's own** model config (dsh cordis / pi models.json / opencode.json limit / codex config.toml / claude model alias) — the effective window reaches bili via the @@ -66,8 +124,17 @@ node scripts/gate/plugin-lanes.mjs - `GATE_AGENTS` selects a subset of lanes; `GATE_TURN_TIMEOUT_MS` (default 300000), `GATE_BIG/MID/SMALL_WINDOW`, and `PLUGIN_LANES_WORK` (artifact dir, default `./plugin-lanes/`) are tunable +- dsh lanes: `GATE_DSH_VERSION` (each lane self-installs + `@deepseek-ai/dsh@`, default latest — system dsh may be too old and a + global billion-context shadows the candidate bundle), `GATE_OUTPUT_TOKENS` + (output budget: bili.json reservation + dsh cordis maxTokens, default 4096; + raise it when a thinking model burns the whole budget on reasoning with no + visible text), `GATE_DSH_SMALL_WINDOW` (fixed override of the t3 small + window; by default derived from the live t2-end payload — dsh's fixed + scaffolding is ~18k tok and a static 24576 minus the output reservation + cannot fit even an empty session) - per-lane artifacts: `//turn-t{1..4}.txt`, `upstream.jsonl`, - `bili.log` + `bili.log`, plus `//egress-sample.json` for the dsh family - the opencode2 lane is not in the default set: transport websocket passes Responses-WS straight through (HTTP-only upstreams die on the handshake), and transport http depends on upstream `/v1/responses` quality — see diff --git a/scripts/gate/README.zh-CN.md b/scripts/gate/README.zh-CN.md index acd7c4e9de..ac15a9de5d 100644 --- a/scripts/gate/README.zh-CN.md +++ b/scripts/gate/README.zh-CN.md @@ -26,9 +26,56 @@ wire 骗不了: - 折叠前后暗号回忆(corpus 40 段,S07 早段/S40 末段 CODEWORDS 暗号) - 无 `unknown tool` 空转 +## dsh 协议矩阵(#3475) + +dsh 的模型客户端 pi-ai 支持全部四种通用协议,dsh 车道因此从一门扩成四门—— +同一套 headless 驱动,只换 cordis provider 的 `api` 与 baseURL 后缀,t1→t4 +流程和断言不变: + +| 车道 | pi-ai api | bili 前门 | 上游门要求 | +|------|-----------|----------|------------| +| `dsh`(原有) | openai-completions | `/v1/chat/completions` | chat completions | +| `dsh-responses` | openai-responses | `/v1/responses` | 真实 `/v1/responses`(404/映射 400 → env-blocked) | +| `dsh-anthropic` | anthropic-messages | `/v1/messages` | `/v1/messages`(claude 车道的交叉验证) | +| `dsh-google` | google-generative-ai | `/v1beta/models/:streamGenerateContent` | `/v1beta` google 门 | +| `dsh-proxy` | openai-completions(**代理模式**) | `/bili/…/v1/chat/completions` | chat completions(经 `/bili/` 前缀) | + +`dsh-proxy` 是同一宿主的**另一条激活路径**(owner 加项):profile **不装** +billion-context bundle(装了它的 fetch 拦截会盖 `x-bili-plugin` 头把车道翻回 +插件模式),dsh 直连手动起的代理 `/bili/` URL——codex/claude 同款形状。与 +native `dsh` 车道同脚本对照:#3177/#3401 类抑制只存在于插件路径,代理模式下 +nudge/fold 必须以 acp_summary 载体正常上 wire;窗口真值 = bili.json(与所有 +prefix 车道一致)。 + +每门新增 **wire 形状硬断言**:recorder 里该门的每个 POST 必须路径+顶层体字段 +都是该协议形状(chat=`messages` / responses=`input` / anthropic=`system`+blocks / +google=`contents`),防止静默换线假绿;首个出站请求存 +`//egress-sample.json` 作往返证据。 + +两个已知事实: + +- **bili 出站不做 google→chat 翻译**——recorder 看到的正是 dsh 发出的 google + 形状(`:streamGenerateContent` + contents/parts)。google lane 只能在有真 + google 门的上游上满绿;要「必须 chat 出」则是给 bili 加出站翻译功能,单独立项。 +- **blocked 降级规则**(两种 kind,脚本结尾打印 `ENV-BLOCKED`/`CLIENT-BLOCKED + [lane] <原因>` 行): + - **env**:上游门不健康——门上请求**全部** 4xx/5xx/连接错误且无回合完成 + (opencode2/#3461 原规矩),或**中途劣化**(前若干请求 200、后续被拒、流程 + 未走完——自建服务 responses→chat 映射 bug 的典型形态,#3461 同族)。 + traffic + wire 形状仍是硬断言,turn 相关断言不计入 gate 成败。 + - **client**:客户端当前版本根本表达不了该 api(dsh ≤0.2.1-rc.1 的 cordis + schema 只列 openai-completions/openai-responses/anthropic-messages 三门, + google-generative-ai 在 pi-ai 库里有实现但 dsh 配置面没暴露)——零上游流量 + + 每回合死于 ValidationError。整条车道不计入 gate,客户端放出该协议后 + 自动转正,脚本不用改。 + +不进默认 GATE_AGENTS 集,显式加入才跑:`GATE_AGENTS=dsh,dsh-responses,dsh-anthropic,dsh-google,dsh-proxy`。 + ## 车道流程 -1. **t1 @ 大窗**:读 corpus,回显 S40 暗号(此阶段 fold 必须不触发) +1. **t1 @ 大窗**:读 corpus,回显 S40 + S07 双暗号(双标记验证「真的读全了」—— + 模型可能照指令分块读、也可能漏读中段,漏读会让后续 S07 回忆断言变成假红; + 此阶段 fold 必须不触发) 2. **窗口收缩**:改**宿主自己的**模型配置(dsh cordis / pi models.json / opencode.json limit / codex config.toml / claude 模型别名)——有效窗口经 `x-bili-plugin-context-window` 头进 bili,native 代理的 zone 端口是粘滞的, @@ -55,7 +102,14 @@ node scripts/gate/plugin-lanes.mjs - `GATE_AGENTS` 选车道子集;`GATE_TURN_TIMEOUT_MS`(默认 300000)、 `GATE_BIG/MID/SMALL_WINDOW`、`PLUGIN_LANES_WORK`(工件目录,默认 `./plugin-lanes/`)可调 +- dsh 车道:`GATE_DSH_VERSION`(每车道自装 `@deepseek-ai/dsh@`,默认 + latest——系统 dsh 可能太旧且全局 billion-context 会遮蔽候选 bundle)、 + `GATE_OUTPUT_TOKENS`(输出预算:bili.json 预留 + dsh cordis maxTokens, + 默认 4096;思考型模型吃光预算只出 reasoning 不出正文时调大)、 + `GATE_DSH_SMALL_WINDOW`(固定覆盖 t3 小窗;默认从 t2 末尾实际 payload + 推导——dsh 固定脚手架 ~18k tok,静态 24576 扣掉输出预留后连空会话都装不下) - 每车道工件:`//turn-t{1..4}.txt`、`upstream.jsonl`、`bili.log` + (dsh 家族另有 `egress-sample.json`) - opencode2 车道不进默认集:transport websocket 直通 Responses-WS(HTTP-only 上游握手必死)、transport http 依赖上游 /v1/responses 质量——见 #3461; 车道仍断言 tools/claim/流量 diff --git a/scripts/gate/plugin-lanes.mjs b/scripts/gate/plugin-lanes.mjs index dd564bb088..b39ffac7fc 100644 --- a/scripts/gate/plugin-lanes.mjs +++ b/scripts/gate/plugin-lanes.mjs @@ -29,9 +29,26 @@ // t3 @ small window : "DONE" — preflight fold path must fire // t4 : recall S07 again — must survive the fold // +// dsh protocol matrix (#3475): the dsh recipe is parameterized over the four +// provider api types pi-ai supports — openai-completions (the original lane), +// openai-responses, anthropic-messages, google-generative-ai. Same headless +// driver, only the cordis provider `api` + baseURL suffix change. Each variant +// carries a WIRE_EXPECT entry: the recorder must see POSTs whose path AND body +// top-level shape match that wire (hard wire assertion, not log). When the +// upstream lacks the door (404/405/mapping-400 with no completed turn) the +// lane degrades to env-blocked (traffic + wire shape + plugin claim stay +// hard) instead of failing the gate — same rule as opencode2/#3461. +// // Env: TGZ, REPO, MODEL1_BASE_URL, MODEL1_MODEL, MODEL1_API_KEY, -// GATE_AGENTS (default "dsh,pi,codex,opencode,claude"), GATE_SKIP=p, -// GATE_TURN_TIMEOUT_MS (default 300000), PLUGIN_LANES_WORK +// GATE_AGENTS (default "dsh,pi,codex,opencode,claude"; matrix + proxy +// lanes opt in: dsh-responses,dsh-anthropic,dsh-google,dsh-proxy), +// GATE_SKIP=p, GATE_TURN_TIMEOUT_MS (default 300000), PLUGIN_LANES_WORK, +// GATE_DSH_VERSION (dsh lanes install @deepseek-ai/dsh@ per lane, +// default "latest"), GATE_OUTPUT_TOKENS (output budget: bili.json +// reservation + dsh cordis maxTokens, default 4096 — thinking models +// need more or they degenerate to zero-visible-text turns), +// GATE_DSH_SMALL_WINDOW (fixed override for the dsh lanes' phase-3 +// window; by default it derives from the live t2-end payload) import { spawn, spawnSync } from "node:child_process"; import fs from "node:fs"; @@ -58,11 +75,24 @@ const AGENTS = (process.env.GATE_AGENTS || "dsh,pi,codex,opencode,claude") .split(",").map((s) => s.trim().toLowerCase()).filter(Boolean); if (AGENTS.includes("opencode2")) console.log("[opencode2] NOTE env-blocked on some upstreams: transport websocket passes Responses-WS straight through (HTTP-only upstreams fail the WS handshake); transport http needs a real /v1/responses endpoint (some self-hosted servers have a Responses->chat mapping bug or 404). Lane asserts tools/claim/traffic; turn completion may fail against such upstreams — see #3461."); +if (AGENTS.includes("dsh-responses")) + console.log("[dsh-responses] NOTE env-blocked when the upstream has no healthy /v1/responses door (self-hosted servers: 404, or a broken Responses->chat mapping answering 400 — same failure class as opencode2/#3461). bili forwards the responses wire as responses; the door must be real. Wire shape + traffic stay hard-asserted; turn/nudge/fold degrade to env-blocked."); +if (AGENTS.includes("dsh-anthropic")) + console.log("[dsh-anthropic] NOTE env-blocked when the upstream has no /v1/messages door. Cross-validates the claude lane's front door from the dsh side (pi-ai Anthropic SDK)."); +if (AGENTS.includes("dsh-google")) + console.log("[dsh-google] NOTE bili does NOT translate google->chat on egress — the recorder sees the google wire (:streamGenerateContent + contents/parts) exactly as dsh sent it. The lane is env-blocked unless the upstream exposes a /v1beta/models/:generateContent door; the observed egress shape is recorded as the round-trip evidence (#3475 acceptance 2)."); +if (AGENTS.includes("dsh-proxy")) + console.log("[dsh-proxy] NOTE proxy-mode contrast lane (#3475): same dsh host WITHOUT the billion-context bundle, driving the /bili/ prefix door (proxy mode, acp_summary carrier) — contrasts the native plugin lane in one script."); const TMO = Number(process.env.GATE_TURN_TIMEOUT_MS || 300_000); +const DSH_VERSION = process.env.GATE_DSH_VERSION || "latest"; const BIG_WINDOW = Number(process.env.GATE_BIG_WINDOW || 262144); const MID_WINDOW = Number(process.env.GATE_MID_WINDOW || 58368); const SMALL_WINDOW = Number(process.env.GATE_SMALL_WINDOW || 24576); const CORPUS_TOKENS = Number(process.env.GATE_CORPUS_TOKENS || 25000); +// #3475: output budget (bili.json `output` reservation + dsh cordis maxTokens). +// Thinking models can spend the whole budget on reasoning and end the turn with +// zero visible text — raise it per environment when the gate model thinks hard. +const OUTPUT_TOKENS = Number(process.env.GATE_OUTPUT_TOKENS || 4096); if (!TGZ || !REPO || !MODEL1.base || !MODEL1.model) { console.error("plugin-lanes: TGZ, REPO, MODEL1_BASE_URL, MODEL1_MODEL are required"); @@ -70,6 +100,9 @@ if (!TGZ || !REPO || !MODEL1.base || !MODEL1.model) { } const results = []; +// #3475: lanes whose upstream lacks the protocol door — degraded verdict, +// excluded from the failure tally (see runLane's env-blocked rule). +const BLOCKED = new Map(); // lane -> { kind: "env" | "client", reason } function record(lane, name, ok, note) { results.push({ lane, name, ok, note }); console.log(`${ok ? "PASS" : "FAIL"} [${lane}] ${name}${note ? ` — ${note}` : ""}`); @@ -143,6 +176,36 @@ const NUDGE_WIRE_RE = /efficiency nudge to compress early|Context limit reached // must not pass — hence full codeword + TITLE anchor. const MARK_RE = (i) => new RegExp(`TITLE:\\s*GATE-MARK-${S(i)}-${CODEWORDS[i]}\\b`); +// #3475 protocol matrix: what each pi-ai api type MUST look like at the +// bili→upstream hop (the recorder's view). pathRe selects the door requests +// (POST model calls only — GET /models discovery is ignored); bodyCheck pins +// the wire's top-level shape so a silent wire swap (e.g. google arriving as +// chat) fails loudly instead of reading green. +const WIRE_EXPECT = { + "openai-completions": { + door: "/v1/chat/completions", + // SDKs append query params (?beta=true on Anthropic's messages door, + // ?alt=sse on google) — match the path prefix, not a bare $ anchor. + pathRe: /\/chat\/completions(\?[^#]*)?$/, + bodyCheck: (b) => Array.isArray(b.messages), + }, + "openai-responses": { + door: "/v1/responses", + pathRe: /\/responses(\?[^#]*)?$/, + bodyCheck: (b) => b.input !== undefined, + }, + "anthropic-messages": { + door: "/v1/messages", + pathRe: /\/messages(\?[^#]*)?$/, + bodyCheck: (b) => Array.isArray(b.messages) && b.model !== undefined, + }, + "google-generative-ai": { + door: "/v1beta/models/:streamGenerateContent", + pathRe: /\/models\/[^/:?]+:(?:streamGenerateContent|generateContent)/, + bodyCheck: (b) => Array.isArray(b.contents), + }, +}; + function hashStr(s) { let h = 0; for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0; @@ -203,7 +266,7 @@ async function runLane(agent, recipe) { providers: { [recUrl]: { models: Object.fromEntries( - [MODEL1.model, ...extraModels].map((m) => [m, { context: w, output: 4096 }]), + [MODEL1.model, ...extraModels].map((m) => [m, { context: w, output: OUTPUT_TOKENS }]), ), }, }, @@ -268,10 +331,15 @@ async function runLane(agent, recipe) { try { await recipe.setup(ctx); const sid = { v: null }; - const t1 = await recipe.turn(ctx, `Read corpus.md in your cwd fully (~1300 lines). Your read tool may truncate or ELIDE the middle of a long file (e.g. claude-code's Read shows head+tail with "... N lines elided ...") — read in sequential chunks (offset 1, 201, 401, …, ~200 lines each, or equivalent line-range calls) until you have seen EVERY line including the middle; do not stop at a truncation or elision. Then reply with ONLY the TITLE line of section S40. Do not run any other tool or command.`, sid, "t1"); + // Dual marker: the t2/t4 S07-recall assertions presume t1 actually READ + // the corpus middle — models sometimes elide it despite the chunk-read + // instruction (observed in proxy mode). Verify the precondition at t1 + // instead of letting downstream recalls fail for fixture reasons. + const t1 = await recipe.turn(ctx, `Read corpus.md in your cwd fully (~1300 lines). Your read tool may truncate or ELIDE the middle of a long file (e.g. claude-code's Read shows head+tail with "... N lines elided ...") — read in sequential chunks (offset 1, 201, 401, …, ~200 lines each, or equivalent line-range calls) until you have seen EVERY line including the middle; do not stop at a truncation or elision. Then reply with ONLY the TITLE lines of sections S40 and S07 (one per line). Do not run any other tool or command.`, sid, "t1"); fs.writeFileSync(path.join(ctx.laneDir, `turn-t1.txt`), t1.out || ""); record(agent, "t1 read @ big window completes", t1.ok, t1.why.slice(0, 160)); record(agent, "S40 marker answered (t1)", MARK_RE(39).test(t1.out), `"${t1.out.trim().slice(0, 80)}"`); + record(agent, "S07 marker answered (t1)", MARK_RE(6).test(t1.out), `"${t1.out.trim().slice(0, 80)}"`); // ---- phase 2: MID window — high-usage band, nudge must ride the wire -- // At ~77% usage with ≥5k pending, the over-limit nudge tier injects and @@ -283,10 +351,13 @@ async function runLane(agent, recipe) { // include. Attempt 1 seeds mid from p1×1.6 (surface guess); after the t2 // request the log carries the REAL payload P ("usage=X% (P/eff)"), so // attempt 2 recomputes mid = P/0.77 + 4096 exactly. Bounded at 2 tries. + // p1 = largest session payload seen during the BIG phase (= t1-end state). + // Do NOT slice at the first [window-change]: source flips (configured→ + // runtime-info, #2283) land mid-t1 and truncate the phase before the + // payload-bearing idle lines, zeroing p1 and mis-seeding mid. const log1 = ctx.readLog(); - const bigPhase = log1.slice(0, log1.indexOf("[window-change]")); - const usageMatches = [...bigPhase.matchAll(/nudge idle: usage=\d+% \((\d+)\//g)]; - const p1idle = usageMatches.length ? Number(usageMatches[usageMatches.length - 1][1]) : 0; + const usageMatches = [...log1.matchAll(/nudge idle: usage=\d+% \((\d+)\//g)]; + const p1idle = usageMatches.length ? Math.max(...usageMatches.map((m) => Number(m[1]))) : 0; // wire seed: the biggest t1 request body ≈ the real live payload // (scaffolding included). Idle log lines lag the final corpus read — // a container run seeded mid from a stale idle line (9.3k) while the @@ -298,6 +369,13 @@ async function runLane(agent, recipe) { let mid = process.env.GATE_MID_WINDOW ? MID_WINDOW : (p1 > 0 ? Math.ceil((p1 * 1.6 / 0.77 + 4096) / 1024) * 1024 : MID_WINDOW); + // A recipe whose small window can grow past the seeded mid (dsh adaptive, + // #3475) would shrink UP in phase 3 — no fold would ever fire. Keep the + // mid strictly above the small-window estimate. + if (recipe.smallWindow && !process.env.GATE_MID_WINDOW) { + const swEst = recipe.smallWindow(ctx, p1); + if (mid <= swEst) mid = Math.ceil((swEst * 1.2) / 1024) * 1024; + } let t2 = { ok: false, why: "never ran", out: "" }; let attempts = 0; @@ -306,10 +384,7 @@ async function runLane(agent, recipe) { ctx.harvestWireModels(); writeWindow(mid); if (recipe.setWindow) await recipe.setWindow(ctx, mid); - if (recipe.type === "prefix") { - if (ctx.proxy) { try { process.kill(-ctx.proxy.pid, "SIGKILL"); } catch {} ctx.proxy = null; } - await startManualProxy(ctx, ctx.proxyArgs ? ctx.proxyArgs() : { port: ctx.proxyPort }); - } + await restartLaneProxy(ctx, recipe); await new Promise((r) => setTimeout(r, 1000)); const mark = ctx.readLog().length; // dsh: a leading cheap tool call guarantees ≥2 LLM requests — the @@ -351,10 +426,7 @@ async function runLane(agent, recipe) { const smallWin = recipe.smallWindow ? recipe.smallWindow(ctx, lastP) : SMALL_WINDOW; writeWindow(smallWin); if (recipe.setWindow) await recipe.setWindow(ctx, smallWin); - if (recipe.type === "prefix") { - if (ctx.proxy) { try { process.kill(-ctx.proxy.pid, "SIGKILL"); } catch {} ctx.proxy = null; } - await startManualProxy(ctx, ctx.proxyArgs ? ctx.proxyArgs() : { port: ctx.proxyPort }); - } + await restartLaneProxy(ctx, recipe); await new Promise((r) => setTimeout(r, 1000)); if (recipe.turnTimeoutMs) ctx.TMO = recipe.turnTimeoutMs(ctx, "t3"); @@ -365,6 +437,36 @@ async function runLane(agent, recipe) { fs.writeFileSync(path.join(ctx.laneDir, `turn-t3.txt`), t3.out || ""); record(agent, "t3 @ small window completes (preflight fold path)", t3.ok, t3.why.slice(0, 160)); + // phase 3b (#3475): hosts with a large fixed scaffolding (dsh 0.2.x ~18k) + // leave a post-fold FLOOR that can sit AT the small-window preflight + // target — t4 then dead-ends ("0 compressible ranges" fail-fast 502, the + // #2847 shape) although the fold itself fired correctly in t3. Measure the + // floor (raw wire estimate from the last preflight line) and widen just + // enough for t4 to land with margin. Adaptive-smallWindow recipes only — + // fixed-SMALL_WINDOW lanes keep byte-identical behavior. + if (recipe.smallWindow && t3.ok) { + // Direct evidence = the last preflight trigger line's raw wire estimate. + // Without one (clean t3, no over-window request ran yet) assume the + // WORST CASE: the fold removed nothing net, floor ≈ the t2-end payload. + const floorM = [...ctx.readLog().matchAll(/local-est=[\d.]+ raw=(\d+)/g)].pop(); + const floor = floorM ? Number(floorM[1]) : lastP; + const headroom = (w) => Math.min(OUTPUT_TOKENS, Math.floor(w / 4)); + if (floor > 0 && floor >= smallWin - headroom(smallWin)) { + const want = Math.ceil((floor * 1.1) / 1024) * 1024; + let w2 = smallWin; + while (w2 - headroom(w2) < want && w2 < BIG_WINDOW) w2 += 1024; + if (w2 !== smallWin && w2 <= mid) { + console.log(`[${agent}] post-fold floor ${floor} tok at the target edge — widening small window ${smallWin} -> ${w2} so t4 lands with margin`); + writeWindow(w2); + if (recipe.setWindow) await recipe.setWindow(ctx, w2); + await restartLaneProxy(ctx, recipe); + await new Promise((r) => setTimeout(r, 1000)); + } else if (w2 > mid) { + console.log(`[${agent}] post-fold floor ${floor} tok needs more than mid ${mid} — leaving ${smallWin}, t4 will report honestly`); + } + } + } + let t4 = { ok: false, why: "never ran", out: "" }; const warm4 = recipe.warmupPrefix || ""; for (let i = 0; i < 2 && !(t4.ok && t4.out.trim()); i++) @@ -376,9 +478,73 @@ async function runLane(agent, recipe) { } // ---- wire + proxy truth assertions ------------------------------------ - const reqs = readJsonl(recOut).filter((r) => r.tag === "req"); + const allLines = readJsonl(recOut); + const reqs = allLines.filter((r) => r.tag === "req"); + const respBySeq = new Map(allLines.filter((r) => r.tag === "resp").map((r) => [r.seq, r])); + const errSeqs = new Set(allLines.filter((r) => r.tag === "error").map((r) => r.seq)); const log = ctx.readLog(); record(agent, "upstream saw traffic", reqs.length > 0, `${reqs.length} requests`); + + // #3475 protocol matrix: hard wire-shape assertion — every door POST at the + // bili→upstream hop must carry this api type's path AND top-level body + // shape. A silent wire swap (google arriving as chat, responses as chat…) + // must fail here, not read green on a generic "turn completed". + if (recipe.wireApi && WIRE_EXPECT[recipe.wireApi]) { + const expect = WIRE_EXPECT[recipe.wireApi]; + const doorReqs = reqs.filter((r) => r.method === "POST" && expect.pathRe.test(r.path)); + const badBody = doorReqs.filter((r) => !expect.bodyCheck(r.body || {})); + record(agent, `wire shape ${recipe.wireApi} at bili->upstream hop`, doorReqs.length > 0 && badBody.length === 0, + doorReqs.length === 0 + ? `no POST matched ${expect.door}; paths seen: ${[...new Set(reqs.map((r) => `${r.method} ${r.path}`))].slice(0, 6).join(" | ") || "(none)"}` + : badBody.length > 0 + ? `${badBody.length}/${doorReqs.length} off-shape body(s); first off-shape keys: [${Object.keys(badBody[0].body || {}).join(",")}]` + : `${doorReqs.length} request(s), all on-shape (path ~${expect.door})`); + // round-trip evidence (#3475 acceptance 2): what the model hop actually + // received — first door request, persisted for the report. + if (doorReqs[0]) { + const b = doorReqs[0].body || {}; + console.log(`[${agent}] egress sample: ${doorReqs[0].path} top-level=[${Object.keys(b).join(",")}]`); + fs.writeFileSync(path.join(ctx.laneDir, "egress-sample.json"), JSON.stringify({ + path: doorReqs[0].path, headers: doorReqs[0].headers, topLevelKeys: Object.keys(b), bodyHead: JSON.stringify(b).slice(0, 2000), + }, null, 2)); + } + // Blocked-lane rules — two kinds, both excluded from the gate tally: + // (env) the UPSTREAM door is unhealthy, so bili never ran against a + // live model: either EVERY door request was rejected (4xx/5xx or + // connection error) and no turn completed (opencode2/#3461 rule), + // or the door DEGRADED MID-FLOW — some requests succeeded, later + // ones were rejected, and the flow never finished. A self-hosted + // door mapping bug (responses→chat validation, #3461 sibling), + // not a bili wire defect. Traffic + wire-shape + tools stay the + // hard verdict; turn-dependent records drop out of the tally. + // (client) the CLIENT cannot drive this protocol at its installed version: + // zero upstream traffic and every turn died on a config-validation + // error (dsh ≤0.2.1-rc.1's cordis schema lists no + // google-generative-ai among provider apis). Nothing ran, so the + // whole lane drops out of the tally; it auto-promotes when the + // client ships the protocol — no script change needed. + const turnRecs = results.filter((r) => r.lane === agent && /completes/.test(r.name)); + const flowComplete = turnRecs.length >= 4 && turnRecs.every((r) => r.ok); + const anyTurnOk = turnRecs.some((r) => r.ok); + const doorStatusOf = (r) => errSeqs.has(r.seq) ? "conn-error" : (respBySeq.get(r.seq) ? `HTTP ${respBySeq.get(r.seq).status}` : "no-response"); + const rejected = doorReqs.filter((r) => errSeqs.has(r.seq) || !respBySeq.get(r.seq) || respBySeq.get(r.seq).status >= 400); + const statuses = [...new Set(rejected.map(doorStatusOf))].join(", "); + const turnStderr = fs.existsSync(path.join(ctx.laneDir, "turn-stderr.log")) ? fs.readFileSync(path.join(ctx.laneDir, "turn-stderr.log"), "utf8") : ""; + let blocked = null; + if (rejected.length === doorReqs.length && doorReqs.length > 0 && !anyTurnOk) { + blocked = { kind: "env", reason: `upstream ${expect.door} unhealthy (${statuses})` }; + } else if (rejected.length > 0 && doorReqs.length - rejected.length > 0 && !flowComplete) { + blocked = { kind: "env", reason: `upstream ${expect.door} degraded mid-flow (${statuses}) after ${doorReqs.length - rejected.length} OK request(s)` }; + } else if (doorReqs.length === 0 && !anyTurnOk && /ValidationError/.test(turnStderr) && /api expected/.test(turnStderr)) { + const m = /\$\.providers\.\w+\.api expected [^\n]+/.exec(turnStderr); + blocked = { kind: "client", reason: `client config surface rejects api ${recipe.wireApi} (${m ? m[0] : "ValidationError"}) — zero upstream traffic` }; + } + if (blocked) { + BLOCKED.set(agent, blocked); + record(agent, "BLOCKED degraded verdict", true, + `${blocked.kind}-blocked: ${blocked.reason} — ${blocked.kind === "env" ? "turn-dependent records below are excluded from the gate tally (opencode2/#3461 rule); rerun against an endpoint exposing a real " + expect.door + " door for the full verdict" : "nothing ran (client cannot express this api yet); the whole lane is excluded from the tally and auto-promotes when the client ships the protocol"}`); + } + } const fold = /acp-compress-obs\] shrink (\d+)%/.exec(log); record(agent, "fold fired (preflight or model-side)", !!fold, fold ? `shrink ${fold[1]}%` : "no acp-compress-obs line"); const t4txt = fs.existsSync(path.join(ctx.laneDir, "turn-t4.txt")) ? fs.readFileSync(path.join(ctx.laneDir, "turn-t4.txt"), "utf8") : ""; @@ -387,7 +553,11 @@ async function runLane(agent, recipe) { const toolsNames = (r) => { const b = r.body || {}; const flat = (arr) => Array.isArray(arr) ? arr.map((t) => t?.function?.name ?? t?.name).filter(Boolean) : []; - return [...flat(b.tools), ...flat(b.input_tools)]; + // google wire declares tools as tools[].functionDeclarations[].name (#3475). + const gdecls = (arr) => Array.isArray(arr) + ? arr.flatMap((t) => (Array.isArray(t?.functionDeclarations) ? t.functionDeclarations.map((d) => d?.name) : [])).filter(Boolean) + : []; + return [...flat(b.tools), ...gdecls(b.tools), ...flat(b.input_tools)]; }; const allTools = [...new Set(reqs.flatMap(toolsNames))]; record(agent, "ACP tools declared on wire", allTools.some((n) => n === "compress" || n === "acp_status"), @@ -446,6 +616,14 @@ async function startManualProxy(ctx, args) { throw new Error(`manual proxy :${args.port} did not become healthy (see ${ctx.laneDir}/proxy.log)`); } +// Prefix lanes re-read bili.json through a fresh proxy per phase (native lanes' +// self-spawned zone proxy picks the new window up per request instead). +async function restartLaneProxy(ctx, recipe) { + if (recipe.type !== "prefix") return; + if (ctx.proxy) { try { process.kill(-ctx.proxy.pid, "SIGKILL"); } catch {} ctx.proxy = null; } + await startManualProxy(ctx, ctx.proxyArgs ? ctx.proxyArgs() : { port: ctx.proxyPort }); +} + // --------------------------------------------------------------------------- // host recipes // --------------------------------------------------------------------------- @@ -464,68 +642,160 @@ function parseEvents(stdout) { return { sid, final: final.trim() }; } -const RECIPES = { - // ---- dsh: native plugin lane (THE #3401 lane) ------------------------- - dsh: { - type: "native", pluginAgent: "dsh", +// ---- dsh family: native plugin lanes (THE #3401 lane) + protocol matrix +// (#3475) + proxy-mode contrast lane (owner add-on) ----------------------- +// One headless driver parameterized over the four pi-ai provider api types. +// Only the cordis provider `api` and the baseURL change per variant; profile +// layout, window rewrite and turn shape are shared. The openai-completions +// NATIVE variant emits a cordis.patch.yml byte-identical to the pre-#3475 dsh +// lane (zero behavior change for the existing lane). +// BaseURL suffixes follow each SDK's URL assembly: +// openai-completions / openai-responses — OpenAI SDK appends /chat/completions | /responses +// anthropic-messages — Anthropic SDK appends /v1/messages +// google-generative-ai — genai SDK appends /models/:streamGenerateContent?alt=sse +// (pi-ai sets apiVersion="" so NO version segment is added): +// the suffix must carry /v1beta itself. +const DSH_WARMUP_PREFIX = "First run the bash tool with command `echo warmup`. Then "; + +async function dshProfileSetup(ctx, { api, baseURL, withBili }) { + // Lane-local dsh install: the system dsh may be too old for the + // headless --json shape, and resolveBundleDir() tries the dsh install + // anchor BEFORE the profile dir — a stale global billion-context on the + // machine would shadow the candidate bundle ("declares no dsh.bundle"). + // A per-lane prefix keeps the lane hermetic on any machine. + const dshPrefix = path.join(ctx.laneDir, "dsh-prefix"); + console.log(`-- lane ${ctx.agent}: installing @deepseek-ai/dsh@${DSH_VERSION}`); + must("npm", ["install", "-g", "--prefix", dshPrefix, "--no-audit", "--no-fund", `@deepseek-ai/dsh@${DSH_VERSION}`], { timeout: 300_000 }); + const dshHome = path.join(ctx.laneDir, "dsh-home"); + const profile = path.join(dshHome, "profiles", "headless"); + fs.mkdirSync(path.join(profile, "node_modules"), { recursive: true }); + fs.mkdirSync(path.join(ctx.laneDir, "tmp"), { recursive: true }); + const bundles = ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-headless"]; + const deps = {}; + if (withBili) { + // candidate as a REAL copy in the profile (e2e-native-dsh.test.ts shape; + // bundles @deepseek-ai/dsh-base/-headless resolve from the dsh install) + fs.cpSync(ctx.cand, path.join(profile, "node_modules", "billion-context"), { recursive: true }); + deps["billion-context"] = ctx.candV; + bundles.push("billion-context"); + } + const pkg = { + name: withBili ? "dsh-profile-plugin-gate" : "dsh-profile-proxy-gate", private: true, + dependencies: deps, + dsh: { profile: { bundles, patchReload: "startup" } }, + }; + fs.writeFileSync(path.join(profile, "package.json"), JSON.stringify(pkg, null, 2) + "\n"); + fs.writeFileSync(path.join(profile, "cordis.yml"), "[]\n"); + const cordisFor = (window) => + fs.writeFileSync(path.join(profile, "cordis.patch.yml"), [ + "- id: llm-pi-ai", + " config:", + " providers:", + " gate:", + " displayName: Gate Upstream", + ` apiKeyEnv: GATE_UPSTREAM_KEY`, + ` api: ${api}`, + ` baseURL: ${baseURL}`, + " models:", + ...MODEL_IDS.map((id) => [ + ` - id: "${id}"`, + ` contextWindow: ${window}`, + ` maxTokens: ${OUTPUT_TOKENS}`, + ].join("\n")), + "- id: agent-default-model", + " config:", + " provider: gate", + ` model: "${MODEL_MAIN}"`, + ].join("\n") + "\n"); + cordisFor(BIG_WINDOW); + fs.writeFileSync(path.join(profile, "pnpm-workspace.yaml"), "packages:\n - .\nnodeLinker: hoisted\nautoInstallPeers: false\n"); + ctx.dshEnv = { + ...ctx.baseEnv, + DSH_HOME: dshHome, + DSH_TELEMETRY_MODE: "DISABLED", + // spill-local mkdtemps into the lane (host /tmp may be read-only) + TMPDIR: path.join(ctx.laneDir, "tmp"), + PATH: [path.join(dshPrefix, "bin"), process.env.PATH].filter(Boolean).join(path.delimiter), + }; +} + +const dshSetWindow = (ctx, w) => { + // window truth on plugin lanes = the host's own model config (rides + // the x-bili-plugin-context-window header); bili.json is ignored there. + // On the proxy-mode lane the same rewrite keeps the host view consistent + // with the bili.json window that writeWindow() writes. + const profile = path.join(ctx.laneDir, "dsh-home", "profiles", "headless"); + const txt = fs.readFileSync(path.join(profile, "cordis.patch.yml"), "utf8"); + // /g: MODEL_IDS may name several models — every entry carries its own + // contextWindow and all must move together (multi-model cordis). + fs.writeFileSync(path.join(profile, "cordis.patch.yml"), txt.replace(/contextWindow: \d+/g, `contextWindow: ${w}`)); +}; + +const dshTurn = async (ctx, prompt, sid, tag) => { + const args = ["--profile", "headless", "headless"]; + if (sid.v) args.push("--session-id", sid.v); + args.push("--json", prompt); + const r = sh("dsh", args, { cwd: ctx.workDir, env: ctx.dshEnv, timeout: ctx.TMO }); + fs.appendFileSync(path.join(ctx.laneDir, "turn-stderr.log"), `\n=== ${tag} exit=${r.status} ===\n${r.stderr}\n`); + const { sid: s, final } = parseEvents(r.stdout); + if (s) sid.v = s; + return { ok: r.status === 0 && !!final, why: r.stderr.slice(-300) || `exit ${r.status}`, out: final }; +}; + +const dshSmallWindow = (ctx, lastP) => { + // dsh's fixed scaffolding (system prompt + tool defs, ~18k tok on 0.2.x) + // exceeds the static SMALL_WINDOW minus the output reservation — preflight + // fail-fasts forever at 24576. Derive from the LIVE t2-end payload instead: + // deep enough to force a fold, wide enough that the folded session fits. + const base = Number(process.env.GATE_DSH_SMALL_WINDOW || 0); + if (base > 0) return base; + const p = lastP > 0 ? lastP : 30000; + return Math.min(BIG_WINDOW >> 1, Math.max(SMALL_WINDOW, Math.ceil((p * 0.85 + OUTPUT_TOKENS) / 1024) * 1024)); +}; + +function dshRecipe(api) { + const baseSuffix = api === "anthropic-messages" ? "" : api === "google-generative-ai" ? "/v1beta" : "/v1"; + return { + type: "native", pluginAgent: "dsh", wireApi: api, // guarantee ≥2 LLM requests per turn so the model-info retry (see // BILI_MODEL_INFO_RETRY_MS) gets a second request to stamp the window on - warmupPrefix: "First run the bash tool with command `echo warmup`. Then ", + warmupPrefix: DSH_WARMUP_PREFIX, async setup(ctx) { - const dshHome = path.join(ctx.laneDir, "dsh-home"); - const profile = path.join(dshHome, "profiles", "headless"); - fs.mkdirSync(path.join(profile, "node_modules"), { recursive: true }); - // candidate as a REAL copy in the profile (e2e-native-dsh.test.ts shape; - // bundles @deepseek-ai/dsh-base/-headless resolve from the dsh install) - fs.cpSync(ctx.cand, path.join(profile, "node_modules", "billion-context"), { recursive: true }); - const pkg = { - name: "dsh-profile-plugin-gate", private: true, - dependencies: { "billion-context": ctx.candV }, - dsh: { profile: { bundles: ["@deepseek-ai/dsh-base", "@deepseek-ai/dsh-headless", "billion-context"], patchReload: "startup" } }, - }; - fs.writeFileSync(path.join(profile, "package.json"), JSON.stringify(pkg, null, 2) + "\n"); - fs.writeFileSync(path.join(profile, "cordis.yml"), "[]\n"); - const cordisFor = (window) => - fs.writeFileSync(path.join(profile, "cordis.patch.yml"), [ - "- id: llm-pi-ai", - " config:", - " providers:", - " gate:", - " displayName: Gate Upstream", - ` apiKeyEnv: GATE_UPSTREAM_KEY`, - " api: openai-completions", - ` baseURL: ${ctx.recUrl}/v1`, - " models:", - ...MODEL_IDS.map((id) => [ - ` - id: "${id}"`, - ` contextWindow: ${window}`, - " maxTokens: 4096", - ].join("\n")), - "- id: agent-default-model", - " config:", - " provider: gate", - ` model: "${MODEL_MAIN}"`, - ].join("\n") + "\n"); - cordisFor(BIG_WINDOW); - fs.writeFileSync(path.join(profile, "pnpm-workspace.yaml"), "packages:\n - .\nnodeLinker: hoisted\nautoInstallPeers: false\n"); - ctx.env = { ...ctx.baseEnv, DSH_HOME: dshHome, DSH_TELEMETRY_MODE: "DISABLED" }; - }, - setWindow(ctx, w) { - // window truth on plugin lanes = the host's own model config (rides - // the x-bili-plugin-context-window header); bili.json is ignored here - const profile = path.join(ctx.laneDir, "dsh-home", "profiles", "headless"); - const txt = fs.readFileSync(path.join(profile, "cordis.patch.yml"), "utf8"); - fs.writeFileSync(path.join(profile, "cordis.patch.yml"), txt.replace(/contextWindow: \d+/g, `contextWindow: ${w}`)); + await dshProfileSetup(ctx, { api, baseURL: `${ctx.recUrl}${baseSuffix}`, withBili: true }); }, - async turn(ctx, prompt, sid, tag) { - const args = ["--profile", "headless", "headless"]; - if (sid.v) args.push("--session-id", sid.v); - args.push("--json", prompt); - const r = sh("dsh", args, { cwd: ctx.workDir, env: ctx.env, timeout: ctx.TMO }); - const { sid: s, final } = parseEvents(r.stdout); - if (s) sid.v = s; - return { ok: r.status === 0 && !!final, why: r.stderr.slice(-300) || `exit ${r.status}`, out: final }; + setWindow: dshSetWindow, + turn: dshTurn, + smallWindow: dshSmallWindow, + }; +} + +const RECIPES = { + dsh: dshRecipe("openai-completions"), + "dsh-responses": dshRecipe("openai-responses"), + "dsh-anthropic": dshRecipe("anthropic-messages"), + "dsh-google": dshRecipe("google-generative-ai"), + + // ---- dsh-proxy: PROXY-mode contrast lane (#3475 owner add-on) ---------- + // Same host, OTHER activation path: the profile does NOT load the + // billion-context bundle (its fetch intercept would stamp x-bili-plugin and + // flip the lane back into plugin mode) — dsh drives the chat wire straight + // into a manually started proxy via the /bili/ URL, codex/claude style. + // Contrasts the native dsh lane within ONE script: #3177/#3401-style + // suppression only exists on the plugin path; here nudge/fold must ride the + // wire in plain proxy mode (acp_summary carrier). Window truth = bili.json + // (writeWindow), like every other prefix lane. + "dsh-proxy": { + type: "prefix", pluginAgent: "dsh", wireApi: "openai-completions", + warmupPrefix: DSH_WARMUP_PREFIX, + async setup(ctx) { + const port = await freePort(); + await dshProfileSetup(ctx, { api: "openai-completions", baseURL: `http://127.0.0.1:${port}/bili/${ctx.recUrl}/v1`, withBili: false }); + ctx.proxyArgs = () => ({ port }); + await startManualProxy(ctx, { port }); }, + setWindow: dshSetWindow, + turn: dshTurn, + smallWindow: dshSmallWindow, }, // ---- pi: native lane, three wires possible — drive openai-chat --------- @@ -766,8 +1036,21 @@ async function main() { console.log(`\n===== plugin lane: ${agent} (${recipe.type}) =====`); try { await runLane(agent, recipe); } catch (e) { record(agent, "lane", false, String(e).slice(0, 400)); } } - const failed = results.filter((r) => !r.ok); - console.log(`\nplugin-lanes: ${results.length - failed.length}/${results.length} passed`); + // #3475: env-blocked lanes (upstream lacks the protocol door) keep their + // degraded verdict — FAIL records from turn-dependent assertions are honest + // output but excluded from the gate tally, mirroring the opencode2/#3461 rule. + // Blocked lanes drop turn-dependent records from the tally: env-blocked + // lanes keep their observable hard assertions (traffic, wire shape, tools, + // claim), client-blocked lanes ran nothing so the whole lane drops out. + const isTurnDependent = (name) => /completes|marker answered|self-calibrated|recalled|nudge reached|fold fired|model invoked/.test(name); + const counted = results.filter((r) => { + const b = BLOCKED.get(r.lane); + if (!b) return true; + return b.kind === "env" ? !isTurnDependent(r.name) : false; + }); + const failed = counted.filter((r) => !r.ok); + for (const [lane, b] of BLOCKED) console.log(`${b.kind.toUpperCase()}-BLOCKED [${lane}] ${b.reason}`); + console.log(`\nplugin-lanes: ${counted.length - failed.length}/${counted.length} passed${BLOCKED.size ? ` (${[...BLOCKED.keys()].map((l) => `${l}:${BLOCKED.get(l).kind}`).join(", ")})` : ""}`); process.exit(failed.length ? 1 : 0); } main(); From 4f012b9dd06f2d37d3b5bf149d317adc66bcc719 Mon Sep 17 00:00:00 2001 From: awork Date: Sat, 17 Oct 2026 14:27:45 +0800 Subject: [PATCH 2/2] chore(gate): ignore plugin-lanes/ work dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7e2336bcda..799e541967 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ tmp/ tests/.pp-stamp-state-*/ .tmp/ +plugin-lanes/