Skip to content

test: name dsh launcher fixture agent/dsh-native.js so the shim test is hermetic (#1889) - #1890

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-02_dsh-shim-test-hermetic
Oct 2, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-02_dsh-shim-test-hermetic

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #1889

What

The runLaunch dsh: non-loopback upstreams ride proxy envs test (tests/launcher.test.ts) asserts the #1590 bare-specifier patch entry (name: billion-context), which only holds when the pre-seeded fixture shim satisfies dshPluginEntry's identity check. On a clean tree (no dist/) it failed deterministically; after npm run build it passed. CI runs npm test BEFORE npm run build (.github/workflows/ci.yml: install → typecheck → test → build; no pretest hook), so a fresh runner goes red — flaky only when stale dist lingers.

Root cause (refined vs the issue)

Not a dangling symlink: the pre-seeded fixtures (<home>/host-bundle.js, <home>/client-bundle.js, added by 4f8cd37) resolve fine, but 3e838ab (#1590/#1816) tightened dshPluginEntry (src/launcher.ts) to require realpath.endsWith("agent/dsh-native.js"). The old fixture names fail that check → fallback to the legacy file-URL entry → the bare-entry assertion fails. The dedicated unit test (tests/launcher.test.ts, "writeDshClientShimFiles + dshPluginEntry") already uses the correct agent/dsh-native.js shape and stays green; only this integration test kept the stale names. Classic incomplete first pass: the check got stricter without updating the existing consumer of the hermetic fixture contract.

Fix (issue option A, refined)

Rename the pre-seeded fixtures to agent/dsh-native.js / agent/dsh-native-client.js (+ mkdir of the dirname) and document the naming obligation in the existing comment. This restores the hermetic design 4f8cd37 intended: the bare-entry assertion now holds WITHOUT a build, and with a build present, runLaunch's own writeDshClientShim overwrites the fixture with real dist symlinks exactly as before. Deliberately NOT skip-gated: skipping would drop CI coverage of the #1590 bare-specifier mechanism on every clean runner. Option B (build before test in CI) rejected: costs a build per matrix leg (2 OS × 2 Node) and still leaves fresh-checkout local runs red.

Verification (rebased onto master 6cab41b)

  • Unpatched master + clean tree: targeted test FAILS (repro confirmed on this exact base)
  • Patched + clean tree (no dist): targeted PASS; full tests/launcher.test.ts → 254 pass / 1 skip (pre-existing version-stamp gate) / 0 fail
  • Patched + built tree: full tests/launcher.test.ts → 255/255 pass
  • npm run typecheck clean; npm run build clean (dist-import-annotations OK)

Test-only change: no production code, no config surface, no wire behavior touched. Disjoint from open launcher PRs (#1888 node-wrapper resolution, #1861/#1581 dsh lanes) — different functions/regions.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-02_dsh-shim-test-hermetic (1faaba6)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1886-pr.1890.82e2683

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

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

审查结论:PR #1890(dsh launcher fixture 改名 → hermetic)

方向正确、改动最小、无回归。已按「审核先于实现」独立核验(代码路径追踪 + CI 证据),未重做实现。查重:全仓无其他 open/closed issue/PR 针对此 flaky-test 的 fixture 命名修复;本 PR 关闭 #1889,与并行 launcher PR(#1888 node-wrapper、#1861/#1581 dsh lanes)不同函数不同区域。

① 是什么问题
runLaunch dsh: non-loopback upstreams ride proxy envs 这条集成测试在**干净树(无 dist/)**上确定性失败、构建过的树上通过。CI 是「test 先于 build」跑(核过 .github/workflows/ci.yml:37-46:install → typecheck → test → build,无 pretest hook),所以全新 runner 必红;只有 stale dist 残留时才侥幸绿。本质是 hermetic fixture 契约被后续收紧的身份检查打破后,消费方没同步更新。

② 什么原因导致的(因果分层)

  • 表面:host-bundle.js / client-bundle.js 两个预置 fixture 不满足 dshPluginEntry 的身份检查。
  • 机制层:dshPluginEntry(src/launcher.ts:2231)解析裸包名 billion-context 后要求 fs.realpathSync(entry).endsWith(path.join("agent","dsh-native.js"))(src/launcher.ts:2235);而 writeDshClientShimFiles 把 index.js 软链到 fixture(src/launcher.ts:2198)——fixture 的文件名就是判据。旧名 realpath 不以 agent/dsh-native.js 结尾 → 落 legacy file-URL 分支 → 断言 /name: billion-context/(tests/launcher.test.ts:3510)失败。
  • 时序层:3e838ab3(给deepseek定制一个跳转到状态的链接 #1590/fix: dsh web/desktop bili settings entry self-heals once proxy origin becomes known #1816)把检查从「可解析即可」收紧为「必须命中 dsh host half」,只更新了专用单测、漏改这条集成测试的预置 fixture——典型「首遍不完整」。作者描述与代码事实一致,我独立复现了整条因果链。

③ 怎么修复的
两个预置 fixture 改名为 agent/dsh-native.js / agent/dsh-native-client.js,补 fs.mkdirSync(dirname, {recursive:true}),并在原注释写明命名义务。即作者 option A 的精化版:不 skip-gate(skip 会让 CI 在每个干净 runner 上丢掉对 #1590 裸包名机制的覆盖)、也不在 CI 里先 build(每 matrix leg 多一次 build,且本地 fresh checkout 仍红)。恢复 4f8cd37 本意的 hermetic 设计。

④ 是否有回归问题 —— 无。逐条核过既有行为:

  • 构建过树(dist 存在):runLaunch 走 writeDshClientShim(base) + writeDshClientShim(overlay)(src/launcher.ts:3690-3691),用真实 dist 软链覆盖 fixture(rmSync recursive,src/launcher.ts:2186)→ realpath 仍命中 agent/dsh-native.js → 走裸包名。与改动前完全一致,fixture 叫什么无所谓。
  • 干净树(无 dist):writeDshClientShim 因 selfDistFile 不存在提前 return false(src/launcher.ts:2185),不覆盖 fixture;改名后的 fixture 自身即满足检查 → 由「红」变「绿」,正是本 PR 目的,非回归。
  • 专用单测 writeDshClientShimFiles + dshPluginEntry(tests/launcher.test.ts:3162-3190)早已用 path.join(dir,"agent","dsh-native.js") 并断言 dshPluginEntry(home)==="billion-context" —— 本改动是让集成测试对齐既有契约,不是新造契约。
  • 全仓 grep:旧名 host-bundle / client-bundle 仅出现在被改这一处(tests/launcher.test.ts:3423-3427),无其他消费方、无孤儿引用。
  • version-stamp「无 dist 则 skip」的门(tests/launcher.test.ts:3229 附近)是既有逻辑、未被触碰——解释了作者报告的 clean 254 pass/1 skip vs built 255/255 差异,合理。
  • wire / config / persistence / session-id:零触碰(纯测试改动)。高危模式(fail-fast 变吞错、阈值/时序/输出格式漂移):均不涉及。

⑤ 是否破坏缓存:不涉及。未触碰任何缓存 / 重试 / 增量游标 / 去重键。

⑥ 是否改了设计方向:不涉及架构 / 边界 / 数据流转向;恰恰是恢复 4f8cd37 既有的 hermetic 意图。

⑦ 是否引入新配置:不涉及。无新 env / config / CLI flag / 默认值。

证据与 CI(对 PR head 1faaba69):

  • 代码路径已完整追踪:clean 与 built 两条 launch 路径都走到 dshPluginEntry 同一判据(src/launcher.ts:2235),结论分别为 pass / pass。
  • CI:test (ubuntu-latest, 24) success ← 这就是「全新 runner、test 先于 build」的 hermetic 铁证;e2e 各 lane(pi / codex / opencode / dsh headless)、build-artifact、version-guard、hermetic-registry-e2e(win+ubuntu)全绿;仍在跑:test (windows 24/22)、test (ubuntu 22)。mergeable_state: blocked 仅因这几条腿未完成,非失败。
  • 透明说明:按本地测试纪律未在本地跑全量(交 CI),也未做本地 npm ci 全量复现——依据是「代码追踪 + 已绿的 ubuntu-24 test 腿」。若你希望我再补一条定向 node --import tsx --test tests/launcher.test.ts 的 clean-tree 复现,我可以装依赖后单跑该文件确认;但 CI 的 ubuntu-24 腿已等价覆盖此场景。

判定:可合并。 改动正确、最小、边界清晰(纯测试,单文件 +7/-3,每行都在目的内)。等剩余三条 CI 测试腿(windows 24/22、ubuntu 22)转绿即可合。我不执行合并——PR 合并仅限人工,请 owner 自行合并:#1890

@ranxianglei
ranxianglei merged commit e22f802 into master Oct 2, 2026
13 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-02_dsh-shim-test-hermetic 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] CI red on clean runner: dsh #1590 client-shim test needs a prior npm run build, but CI orders test before build

1 participant