Skip to content

[PR] test: PTC run_code form end-to-end — run all four wires through once; the gate must not false-positive (#3617 F) | test: PTC run_code 形态端到端——四张 wire 过一遍,门不许误杀(#3617 F) - #3626

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-18_ptc-runcode-shape-e2e
Oct 18, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

Part of #3617 item F(e2e 加 PTC 形状)。纯测试 PR,无源码改动。

背景

#3617 复盘:#3600(PTC run_code → 压缩面全关)修好时补的是决策矩阵断言(#3603),但没有任何测试用 PTC 形状的请求真正走一遍四张 wire 的 prepare 链并检查出站报文里的工具表。本 PR 补上这条端到端。

新增 tests/e2e-ptc-runcode-shape.test.ts(8 个测试:4 wire × 2 模式)

请求只带一个工具 run_code(PTC omnibus 形状),对每张 wire(anthropic/openai/responses/google)各起一个假上游走真实代理链,断言:

模式 出站工具表 压缩面
plugin(dsh) 恰好 [run_code]——门不得剥离宿主声明,bili 也不得往插件拥有的表里加自己的工具 standing prompt + nudge 都在(#3600 回归家族在 wire 层钉死)
proxy(对照) run_code 和 compress 同时在——mergeOwnedTools 只丢 bili 自己拥有的名字(#920),客户端的 PTC 声明必须活下来;注入若被门误杀则 compress 消失,客户端工具被剥则 run_code 消失,两种回归都会红 结构性 on,nudge + standing prompt 都在

不需要真模型:usage 教给代理 50k/64k=78%,第二轮 29 条消息历史确定性 arm nudge(与 lane-decisions-matrix.test.ts 同一配方)。

验证

  • 本地:node --import tsx --test tests/e2e-ptc-runcode-shape.test.ts → 8/8 通过(~27s);
  • 本地 npm run typecheck 干净;
  • 全量回归以 CI 为准。

Closes 无——本 PR 是 #3617 六项之一,issue 待六项全部合入后关闭。

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-18_ptc-runcode-shape-e2e (6748b23)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4274-pr.3626.80c8931

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title test: PTC run_code 形态端到端——四张 wire 过一遍,门不许误杀(#3617 F) [PR] test: PTC run_code form end-to-end — run all four wires through once; the gate must not false-positive (#3617 F) | test: PTC run_code 形态端到端——四张 wire 过一遍,门不许误杀(#3617 F) Oct 17, 2026
New hermetic suite tests/e2e-ptc-runcode-shape.test.ts: a request declaring exactly one tool (run_code, the PTC omnibus shape) is driven through all four wire prepare chains against per-wire fake upstreams. Per wire it pins: (1) the model-side compress surface stays alive on the PTC shape (standing prompt + armed nudge — the #3600 regression family, pinned at wire level); (2) plugin mode passes the host tool table through untouched (exactly [run_code] outbound — nothing stripped by the gate, nothing appended by bili); (3) proxy-mode control: mergeOwnedTools keeps non-bili-owned names (#920), so the client's run_code survives next to bili's injected compress tool — PTC-shaped input cannot starve the injection either. No source change: test-only.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 本 PR 是 #3617 的 F 项(PTC 形状端到端测试)。检索了 open+closed 的 issue/PR:没有别的条目覆盖「PTC 形状请求真走四张 wire 的 prepare 链并断言出站工具表」。最接近的 tests/ptc-runcode-tools.test.ts(#3252)只测注入函数的适配器层(直接调 injectTool / handlePluginManifest,不起代理链),与本 PR 不同层、互补而非重复。#3617 兄弟项 A/B/D 各自独立范围,无重叠。

审核结论(八问)

  1. 是什么问题:纯测试补强——[bug] 0.1.198 PTC(run_code)会话压缩面被永久压制:顶层 tools 只有 run_code ⇒ declaredTools.has("compress") 恒 false ⇒ nudge 从不注入 #3600(PTC 形态下压缩面被全关)修好时只补了决策矩阵断言(fix: dsh PTC run_code omnibus reads as compress-reachable — 0.1.198 nudge suppression regression (#3600) #3603),没有任何测试用「只声明一个 run_code 工具」的 PTC 形状请求真正走一遍四张 wire 的代理链、检查出站报文里的工具表。本 PR 把这条端到端钉上。
  2. 什么原因导致的(背景根因):可达性门(src/server/lane-decisions.ts:229-232)原先只看客户端有没有声明 compress 工具;PTC omnibus 把所有宿主工具塌缩成一个 run_code,门误读为「compress 不可达」,压缩面被压到 100% 窗口。[bug] 0.1.198 PTC(run_code)会话压缩面被永久压制:顶层 tools 只有 run_code ⇒ declaredTools.has("compress") 恒 false ⇒ nudge 从不注入 #3600 加了 run_code 档位修复;本 PR 不改代码,只防这个回归家族在 wire 层复发。
  3. 影响范围与严重程度:零运行时影响(diff 只新增一个测试文件,无任何源码改动)。价值是回归防线:门再误杀、或宿主工具表被剥/bili 往插件表里塞自己的工具,都会让 CI 红。
  4. 怎么修复的:每张 wire(anthropic/openai/responses/google)各起一个假上游,驱动真实代理链;双模式断言——plugin(dsh)模式出站工具表恰好 [run_code](门不剥宿主声明,bili 不加自己的工具)且 standing prompt + nudge 都在;proxy 对照模式 run_code 与 bili 注入的 compress 同时在场(mergeOwnedTools 只丢 bili 自己拥有的名字,opencode v1: keep opencode-acp legacy sessions working after switching to bili #920)。nudge 用 usage 教给代理 50k/64k=78% 确定性触发,第二轮 29 条消息历史。
  5. 是否有回归问题:无。diff 触碰路径 = 仅新增 tests/e2e-ptc-runcode-shape.test.ts;未碰任何运行路径、配置面、persistence、wire 协议、kernel/。逐项过了高危模式清单(语义漂移/fail-fast 变吞错/阈值时序格式漂移):均不涉及。既有行为审计结论:零变更。
  6. 是否破坏缓存:不涉及(不碰缓存/重试/增量游标/去重键逻辑)。
  7. 是否改了设计方向:不变。
  8. 是否引入了新的配置:无(复用现有 startServer 选项,无新 env/config key)。

验证证据(本地定向,非全量)

  • rebase 到当前 master 后复核:分支原本落后 master 4 个提交(涉及 src/plugin.ts、dsh attach 区域,与本文件零重叠)。已 rebase(零冲突,测试文件 blob 前后一致 a8ed93b…)并推回 PR 分支,新 head baf6fc5bb。在新 head 上:目标测试 8/8 通过(~26s),npm run typecheck 干净。
  • 「与矩阵同一配方」声明属实:tests/e2e-ptc-runcode-shape.test.ts 的 harness/historyTexts/outcome 检测器与 tests/lane-decisions-matrix.test.ts 逐字一致(同 29 条历史、同 50k/64k 教学、同 standing-prompt 标记检测)。
  • 断言有牙(不是假测试):门误杀 → nudge/standingPrompt 变 false,deepEqual 红;宿主表被剥或 bili 追加 → plugin 模式 deepEqual(["run_code"]) 红;proxy 模式 compress 或 run_code 任一消失 → includes 红。两条回归家族都被钉住。
  • 被钉机制逐一核实存在且 load-bearing:mergeOwnedTools(src/server/inject.ts:47-59);run_code 可达性档(lane-decisions.ts:229-232);host-profiles.ts:71 dsh toolsHostScopedByDefault: true(使该档对 dsh plugin 模式真正必需,测试非空转);plugin 模式整表透传(src/server/prepare-openai.ts:85 injectTools = shouldInject && !pluginMode)。
  • 代码整洁:命名达意、无死代码、错误带上下文、风格与仓库既有 e2e 套件一致(hermetic、listen(0)+重试、env 隔离)。一个非阻塞观察:harness/outcome 辅助函数是从矩阵测试复制的第二份——仓库惯例即每套自包含,与现有风格一致,不构成阻塞。

CI 状态(rebased head baf6fc5)

静态门禁全部绿(gate / kernel-guard / pi-subagents-guard / config-surface-guard / docs-sync / unused-exports / lock-sync 等);全量回归 12 条 test 车道(ubuntu/windows × node 22/24 × 3 shard)仍在跑,无失败。全绿后我再回帖最终判定。

判定:内容可合(纯测试新增、零运行时改动、断言经核实有效);等全量 CI 确认后收工。合并操作留给人。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

最终结论:CI 全绿,可合。

过程

  1. Rebase:PR 分支开出时落后 master 4 个提交(期间合入了 fix: dsh attach — superseded recovery flights must not revert the registered origin #3618 dsh attach 恢复、fix: persona-lineage follow requires candidates to hold refs (#2948) #2950 persona-lineage guard)。已干净 rebase 到当前 master(07501b353),零冲突;测试文件内容 rebase 前后逐字节一致(blob hash 不变),rebase 没有引入任何内容变化。
  2. 本地验证(rebased head 上):tests/e2e-ptc-runcode-shape.test.ts 8/8 通过(~26s),npm run typecheck 干净。
  3. CI 暴露一个无关的时序 flake:第一个 rebased head(baf6fc5bb)全 lane 唯一红的是 test (windows-latest, 22, 2),挂的 case 不是本 PR 的新测试,而是 tests/persist-guard-ownership.test.ts 的「DEBOUNCED saves stay stamped」:断言 4 !== 5,该 case 耗时 10.6s(同族 case ~100ms)。根因:这个测试用固定 sleep(150) 等 25ms debounce 的落盘完成、假设剩 ~125ms 余量,Windows 负载 runner 上第 5 次写入还没落盘就读文件了。本 PR diff 完全不碰该文件/子系统,同文件本地单跑 8/8 绿。
  4. 顺手修掉(独立标注 commit):按「几行级小修直接修」纪律(CI 红类直接进当前 PR):把 3 处盲 sleep(150) 换成有界轮询(最多等 5s 直到写入真实落盘 / guard 计数递增),断言不变、不引入时间假设。只动这一个文件,+22/−3。commit 6748b235a。修复前查重:无(无既有 issue/PR 记录此 flake)。
  5. 新 head 6748b235a 全量 CI:28 success / 12 skipped(env-gated real-client lane)/ 0 failure,含此前红的 windows shard,静态门禁全绿。

结构化八问

  1. 是什么问题:纯测试 PR——[bug] 0.1.198 PTC(run_code)会话压缩面被永久压制:顶层 tools 只有 run_code ⇒ declaredTools.has("compress") 恒 false ⇒ nudge 从不注入 #3600 修好时只补了决策矩阵断言(fix: dsh PTC run_code omnibus reads as compress-reachable — 0.1.198 nudge suppression regression (#3600) #3603),没有任何测试用 PTC 形状的请求(只声明一个 run_code 工具)真走四张 wire 的 prepare 链并检查出站工具表;本 PR 补这条端到端。
  2. 什么原因导致的:无缺陷根因可言(测试补强)。背景根因:[bug] 0.1.198 PTC(run_code)会话压缩面被永久压制:顶层 tools 只有 run_code ⇒ declaredTools.has("compress") 恒 false ⇒ nudge 从不注入 #3600 的可达性门把 PTC omnibus 形状(所有工具塌缩成一个 run_code)误读为「compress 不可达」,压缩面被压到 100% 窗口。
  3. 影响范围与严重程度:零运行时影响(纯加测试 + 修一个无关测试自身的计时问题);价值 = 回归防线。
  4. 怎么修复的:每张 wire 一个假上游驱动真实代理链,双模式各断言:plugin 模式出站工具表恰好 [run_code](门不剥宿主声明,bili 不往插件拥有的表里加自己的工具);proxy 模式 run_code 与 compress 同在(mergeOwnedTools 只丢 bili 自己拥有的名字 opencode v1: keep opencode-acp legacy sessions working after switching to bili #920);standing prompt + nudge 两模式都在。
  5. 是否有回归问题:审过无——diff 只碰两个测试文件(新增 e2e + 上述 flake 修复),不碰任何运行路径 / 配置面 / kernel / wire 协议 / 持久化格式;flake 修复只改目标测试的等待方式(sleep→有界轮询),断言与语义不变(每次保存仍逐个落盘,fast-path collapse 检查原样保留)。
  6. 是否破坏缓存:不涉及(未触碰缓存/重试/增量游标/去重键逻辑)。
  7. 是否改了设计方向:无。
  8. 是否引入新配置:无。

判定:可合。 分支 head 6748b235a = 原测试 commit(rebase 后)+ flake 修复 commit,CI 全绿,等你合并。

@ranxianglei
ranxianglei merged commit e4d42fd into master Oct 18, 2026
40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.554-master.e4d42fd (rolling master tag).

npm install -g billion-context@0.0.554-master.e4d42fd  # 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.

ranxianglei pushed a commit to tgazer933-boop/billion-context that referenced this pull request Oct 18, 2026
…anxianglei#3652)

The sibling test 'foreign write between DEBOUNCED saves' still races under
loaded CI runners even after ranxianglei#3626's poll-for-landed fix (6748b23): it waits
only for the envelope to be present on disk, but the ownership stamp is applied
asynchronously in .then() AFTER the write resolves (after the file already
landed). A foreign write slipping into that gap is adopted as ours by the stamp
(ranxianglei#3406 residual gap) and the guard below never trips. Reproduced ~1-in-4 under
CPU load. Waiting for __ownWriteStampedForTests closes it deterministically.
@github-actions github-actions Bot mentioned this pull request Oct 18, 2026
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.

1 participant