Skip to content

[PR] test: Three lifecycle test cases landed — generic hot-swap driver, pinned-attach swap gate, transition window contract ( | test: 生命周期三条用例落地——热替换通用驱动、pinned-attach 换血门、过渡窗契约 (#3617-E) - #3630

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-18_lifecycle-tests
Oct 18, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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

Part of #3617 — item E (生命周期测试). One issue item = one PR per the issue's acceptance list; does NOT close #3617 (the issue closes after all six items merge).

What was already covered vs what this adds (coverage audit)

E① hot-replace helper (#3394 family) — the three #3394 regression tests existed but each hand-rolled its own patch/sink/dispose scaffolding; no reusable driver.

E② pinned-attach version-mismatch rotation (#3544) — tests/issue3544-stale-proxy-rotation.test.ts ALREADY pins the discovery-path rotation, rotatePinnedStaleProxy mechanics, /__bili/shutdown admin route and heartbeat semantics, but NOTHING drove the pinned-attach DECISION gate (verifyAttachAndRecover, private in dsh-native.ts while omp/pi/opencode all export their twins).

E③ old-host + new-proxy transition window (#3578) — side A (gate internals, mock endpoint: dsh-native.test.ts #3581 pair) and side B (endpoint + status wire, hand-crafted POSTs: issue3581-attribution-health.test.ts) were covered separately; the SEAM was not: nobody proved the plugin's ACTUAL report bytes pass the REAL endpoint validation into the real status surface.

Behavior changes

None at runtime. The only src change is adding the export keyword (no logic touched); everything else is test code. No config surface, no kernel/, no wire shape, no persistence format.

Verification

  • Local targeted runs: native-intercept + issue3544 suites 83/83; dsh-native suite 59/59 (incl. the new contract test, ~6s).
  • npm run typecheck clean on this head.
  • Full-suite verdict = remote CI on the pushed head.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-18_lifecycle-tests (7c6fce9)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4277-pr.3630.6f362af

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

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title test: 生命周期三条用例落地——热替换通用驱动、pinned-attach 换血门、过渡窗契约 (#3617-E) [PR] test: Three lifecycle test cases landed — generic hot-swap driver, pinned-attach swap gate, transition window contract ( | test: 生命周期三条用例落地——热替换通用驱动、pinned-attach 换血门、过渡窗契约 (#3617-E) Oct 17, 2026
…helper (#3630)

HotReplaceWorld / HotReplaceApi are driver-internal (referenced only inside
tests/helpers/hot-replace.ts); RecordedCall stays exported (cross-file used by
tests/native-intercept.test.ts). Gate-prescribed remedy: drop leading export.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复 — 本 PR 是 #3617 item E 的唯一 PR;同 issue 其余条目各有独立 PR(A=#3620、B=#3627、C=#3628、D=#3625、F=#3626),无其他在途生命周期测试 PR。

审核结论(独立复核,非转述 issue)

① 方向关(原 issue):#3617-E 验收 = ① 热替换通用驱动(#3394 家族)② pinned-attach 版本失配换血门(#3544)③ 老宿主+新代理过渡窗契约(#3578)。三项缺口逐一对照 master 核实为真:

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

  • src/agent/dsh-native.ts:仅给 verifyAttachAndRecover 加 export + 2 行 doc 注释,零逻辑改动;该函数原本就经 singleFlight 在 lane 内调用(dsh-native.ts:1395),导出本身不改变任何运行时路径。attach/rotation/register 行为不受影响。
  • tests/native-intercept.test.ts 三条 [BUG] DSH 插件热替换后 fetch 拦截仍绑在旧模块实例上 → 模型请求全部直连、压缩静默失效直到重启 #3394 用例重构上驱动:逐条核对断言字节等价(40901/40902 A→B 重导入、40903 同实例再激活压过迟到的 dispose、40904 最新 teardown→透传不重写);私有 fakeFetchRecordingHeaders 由共享 makeRecordingFetch 替代,记录语义一致(url+归一化 headers+顺序)。
  • 新 helper 的 captureDispose() = liveStateSlotEffect(state)() 立即执行,与原测试代码语义完全一致(thunk 被宿主运行时捕获 ACTIVE_STATE_SEQ,disposer 仅当 seq+state 仍匹配才清 slot——对照 src/agent/native-intercept.ts:1050-1058 核实);runHotReplace 前后 _resetForTest + 保存/恢复 globalThis.fetch,无跨测试污染。
  • 新增 A→B→C 三连重导入 + A 迟到 dispose:断言路由端到端骑 C(url 走 40913/bili/…、header x-bili-test=C),与 [BUG] DSH 插件热替换后 fetch 拦截仍绑在旧模块实例上 → 模型请求全部直连、压缩静默失效直到重启 #3394 不变量「路由跟随最新激活」一致。
  • tests/issue3544-stale-proxy-rotation.test.ts 4 条新例驱动真实 verifyAttachAndRecover:resident fake 的两个端点(POST /__bili/shutdown、GET /__bili/plugin/manifest)与生产请求路径逐一吻合(requestInstanceShutdown @ src/launcher.ts:4060、fetchProxyVersion @ src/agent/shared.js)。旋转例断言 shutdown 恰好一次 + spawn 恰好一次 + register 重基到 spawn origin + preset 解冻(BILLION_CONTEXT_PROXY 被删);负向三例(equal=newer/unparseable 边界取 VERSION/999.0.0/not-a-version)断言零 shutdown、零 spawn、preset 保持冻结——与函数分支一一对应(isVersionNewer false→原样 attach;true→rotate→spawnFallback),断言有牙,能抓住「比较方向反了」「忘解冻」「负向误旋转」这类回归。
  • tests/dsh-native.test.ts 新契约测试:真实 startServer(port 0) + 真实 apply() attach(等待真实 manifest 工具注册才继续)+ disposed agent scope → gate 返回 false(流量直连)且 fire-and-forget report 真实落在 /__bili/status 的 attribution 面({state:"threw", refusals>=1, since>0},bili-native key);pre-state 先断言空面,env 隔离(BILI_SESSIONS_DIR/BILI_CONFIG_FILE/XDG_*)与清理(server.close + rmrf + 全 hook reset)完整。是真端到端缝测,非恒真断言。

④ 测试有效性:全部断言打可观察结果(wire 字节、HTTP 状态、env/register 状态),无恒真/tautology;每个新用例都能在其守护的行为回归时变红。⑤ diff 整洁度:5 文件 +355/−88,每行都属 item E,无跑题文件、无空白噪音、无 lockfile/生成物。

发现并已直接修复的问题

head 9ed2659b9 的 unused-exports gate 红(本地复现确认):tests/helpers/hot-replace.ts 的 HotReplaceWorld/HotReplaceApi 导出但仅在文件内引用。按 gate 自身规定的修法直接修掉:去掉两个 export(RecordedCall 跨文件使用,保留导出)。独立 commit 7c6fce9aa 已推至本 PR 分支。修后本地 gate clean;三个涉及 suite 本地定向跑 142/142 全绿(native-intercept+issue3544 共 83、dsh-native 59,与 PR 正文声明数字一致——我独立复跑了,不是采信声明)。上一轮 CI 因 fail-fast tiering(guard 红→test matrix skip)没跑到测试矩阵;本轮 push 后 CORE matrix 会正常执行,全量 verdict 以远端 CI 为准。

八问

  1. 是什么问题:热替换、pinned-attach 版本换血、老宿主/新代理过渡窗三条生命周期路径缺可复用/泛化/契约级测试覆盖——是 Test Blind Spot Retrospective: Reinforcing Negative Assertion Discipline, Tightening Fake Upstream Strictness, Thin Inst | 测试盲区复盘:补反向断言纪律、假上游严格化、薄安装冒烟、形态矩阵与生命周期覆盖 #3617 测试盲区复盘的补洞,不是运行时缺陷。
  2. 什么原因导致的:当初修 [BUG] DSH 插件热替换后 fetch 拦截仍绑在旧模块实例上 → 模型请求全部直连、压缩静默失效直到重启 #3394/安装新版本后旧代理永远不换新:detach 代理躲过应用退出,重启只是重新挂上旧进程(「永远更新不了」) #3544/[Bug][dsh-native] 运行中自动换版后接管静默失效:旧 fetch hook 持有已 dispose 的 ctx,currentInitiator() 永久 threw,重启才恢复 #3578 时各自手写脚手架、决策函数未导出,后续场景没有复用入口;本 PR 补驱动、补导出、补契约测试。
  3. 影响范围与严重程度:纯测试代码 + 一个 export 关键字,运行期行为零变化,无用户可见影响。
  4. 怎么修复的:抽公共驱动(hot-replace)+ 打开测试面(export 对齐三条 lane 的 twin 惯例)+ 钉契约(真实 proxy × 真实插件端到端过一遍)。
  5. 是否有回归问题:无。既有行为逐项审过(见上②):dsh-native 零逻辑改动;[BUG] DSH 插件热替换后 fetch 拦截仍绑在旧模块实例上 → 模型请求全部直连、压缩静默失效直到重启 #3394 三例断言字节等价;helper 记录/重置语义与原私有实现等价;无阈值/时序/输出格式漂移。
  6. 是否破坏缓存:不涉及(不触碰缓存/重试/游标/去重逻辑)。
  7. 是否改了设计方向:不涉及(无架构/边界/数据流转向)。
  8. 是否引入新配置:不涉及(无新 env/config/默认值)。

判定:可合(等 7c6fce9aa 这轮 CI 转绿即满足合并条件;merge 仍按规矩由人来点)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 已全绿(head 7c6fce9aa):30 success / 14 skipped / 0 failure——CORE 测试矩阵 6 腿全过(ubuntu 22×3 shard、ubuntu 24、windows 22×2)、static-gates 两腿(含 windows 的 typecheck/build + kernel/pi-subagents suite)全过、unused-exports gate 转绿。skipped 的 14 个是 e2e/registry/lane 类工作流,按三层 CI 设计不在 PR core 范围内。

上一条评论的判定维持:可合,等 CI 绿即满足合并条件——现已满足。merge 由人来点:#3630

@ranxianglei
ranxianglei merged commit b0f9a40 into master Oct 18, 2026
44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.551-master.b0f9a40 (rolling master tag).

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

@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

1 participant