Skip to content

fix(update): probe pi-stable in resolvePiBinary + e2e no-op assertion - #1883

Merged
ranxianglei merged 2 commits into
masterfrom
2026-10-02_update-test-hardening
Oct 2, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-10-02_update-test-hardening

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Three follow-ups out of the Windows update/install audit (#1880), validated on a real Windows 10 VM.

1. resolvePiBinary: also probe pi-stable (fallback for renamed installs)

The canonical npm package is pi (npm i -g pi lays down pi), and the existing probe already covers it. But pi is also distributed under renamed package names (e.g. this project's test envs use pi-stable), whose stock npm install lays down only pi-stable(.cmd) with no pi alias — on such machines the probe missed, fell back to a bare "pi" spawn → ENOENT, and refreshPiNpmCopy never converged.

Fix: probe both names, pi first (canonical name wins when both exist; zero behavior change for stock installs).

2. e2e no-op assertion

The hermetic npm -g e2e only covered the flip branch. Now, after the flip, a second update run must:

  • exit 0
  • log (up to date) and never Restart to finish
  • leave package.json mtime untouched

3. Real-Windows validation (not in CI, reported here)

Local: typecheck clean, update-pi-self-refresh 12/12, hermetic registry e2e 5/5 (Linux).

resolvePiBinary probed only `pi`(.cmd), but a stock
`npm install -g pi-stable` lays down just `pi-stable`(.cmd) — the
npm package's declared bin name. Every stock npm install missed the
probe and fell back to a bare "pi" spawn that ENOENTs. Probe both
names, `pi` first (canonical UX name wins when both exist).

Also extend the hermetic npm -g e2e with the no-op branch: after the
flip, a second `update` run must exit 0 with "(up to date)", never
"Restart to finish", and must not touch package.json.

Validated end to end on a real Windows 10 VM against a real
`npm i -g pi-stable` agent tree: the pi-managed copy's own `update`
run takes the #991 managed branch, drives `pi-stable update
--extension npm:billion-context`, and the copy converges 0.1.100 →
0.1.179 with the settings entry untouched.
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-02_update-test-hardening (19a8ef0)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.1883-pr.1883.71b6c8a

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

Install instructions are refreshed on each push.

The 'canonical pi wins' sub-case called resolvePiBinary({PATH: binDir}, 'linux', fs.existsSync, ...) where binDir was a real mkdtemp path. On a Windows host that path carries a drive-letter colon (C:/Users/...); the 'linux' branch splits PATH on ':' and shreds the single directory into two non-matching fragments, so the resolver returned bare 'pi' and the assert failed. Red on both windows-latest jobs; ubuntu has no drive colons so it stayed green.

Rewritten with a synthetic colon-free dir plus a stubbed existsImpl reporting both names present - pins the pi-before-pi-stable probe order without depending on host path shape. Production code unchanged.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 ## Review — #1883 (pi-stable probe + e2e no-op)

Reviewed direction, diff, log-string soundness, and full CI. Found and fixed one blocking issue: the PR's own new unit test was red on both windows-latest jobs. Fixed inline (labeled commit 19a8ef02, pushed to the branch). Everything else is clean and mergeable once the re-run Windows jobs go green.

What I verified

  • Item 1 (probe pi-stable) — real bug, correctly fixed. resolvePiBinary (src/pi-channel.ts) previously probed only pi; stock npm i -g pi-stable lays down only pi-stable(.cmd), so refreshPiNpmCopy resolved nothing → bare-pi spawn ENOENT → copy never converged. Fix probes ["pi","pi-stable"] per dir, pi first. Single production caller confirmed: runPiAsync (src/pi-channel.ts:120) ← refreshPiNpmCopy (src/update.ts:750). The win32 stock-install sub-case passed on the real Windows CI host, corroborating your VM validation.
  • Item 2 (e2e no-op assertion) — sound. Checked the strings against src/update.ts: pure no-op logs (up to date) via reportNotNewer (update.ts:194); Restart to finish fires only on an actual install/advisory flip, so doesNotMatch(/Restart to finish/) can't false-positive; mtime-not-touched is robust because the file isn't rewritten. Passes on both ubuntu + windows hermetic registry e2e.
  • Item 3 (real-Windows validation) — report-only, consistent with the dsh 渠道把桌面应用独占的 profiles/desktop 当普通 profile 驱动 —— 第二写者冲突 #1575-accepted in-place overwrite; junction/store behavior matches design.

The blocking issue (now fixed)

CI on the original head: 12 checks green, test (windows-latest, 22) and test (windows-latest, 24) red — sole failure in each: the new resolvePiBinary test, assertion at tests/update-pi-self-refresh.test.ts:47, actual 'pi' vs expected <bindir>/pi.

Root cause (test defect, not a production regression): the "canonical pi wins" sub-case called resolvePiBinary({PATH: binDir}, "linux", fs.existsSync, …) where binDir is a real mkdtemp path. On a Windows host that path carries a drive-letter colon (C:/Users/…); the "linux" branch splits PATH on :, shredding the single directory into two non-matching fragments, so the resolver fell back to bare "pi". Ubuntu has no drive colons → stayed green. (The ENOSPC lines elsewhere in the log are unrelated noise.) Author validated Linux-only, which is why this slipped.

Fix: rewrote that one sub-case to be host-independent — synthetic colon-free dir (probedir) + a stubbed existsImpl reporting both names present. It still pins the pi-before-pi-stable probe order (if the order were reversed it'd return pi-stable and fail) but no longer depends on host filesystem/path shape. No production code touched. Local: update-pi-self-refresh 12/12 + strict typecheck clean. (Linux-green alone doesn't prove Windows since the original was also ubuntu-green; the fix is host-independent by construction, and the re-run windows-latest jobs on 19a8ef02 are the definitive check — in progress, I'll confirm.)


结构化七问

  1. 是什么问题:PR 修一个真实 bug(resolvePiBinary 只探测 pi,漏掉 stock npm i -g pi-stable 装的机器)+ 补 e2e no-op 断言 + 真实 Windows 验证报告。但 PR 自带的新单元测试在两个 windows-latest job 上红了。
  2. 什么原因导致的:红的是测试缺陷而非生产回归。新测试的「canonical pi 优先」子用例强制 platform="linux" 却在 Windows 主机上跑,其真实临时路径带盘符冒号(C:/Users/…);linux 分支按 : split PATH,把单个目录撕成两段都匹配不到 → 解析器回退成裸 "pi" → 断言失败。ubuntu 无盘符冒号所以绿。生产修复本身正确且已在真实 Windows 上验证。
  3. 怎么修复的:把该子用例改成宿主无关——用无冒号的合成目录 probedir + 打桩 existsImpl(同时报告两名字存在),仍钉住 pi 先于 pi-stable 的探测顺序,但不再依赖主机路径形态。独立标注 commit 19a8ef02 已推分支,未动任何生产代码。
  4. 是否回归:无。清点触碰路径既有行为:pi 的既有解析逐字节不变(每个目录仍先探 pi、扩展名顺序不变),改动只在「原先什么都找不到」处新增 pi-stable 命中;e2e no-op 块纯追加(在 flip 断言之后);无 config/wire/persistence/version 变更;dsh-channel 不做多探测是刻意的(pi 特有需求),非不一致。
  5. 是否破坏缓存:不涉及(未触碰缓存/重试/游标/去重键)。
  6. 是否改设计方向:不涉及(同一机制、仅扩大探测面;native模式下自动更新问题需要解决 #991/dsh plugin-market installs never auto-update: the refresh chain's only trigger is a global bili self-update #1196 单写者/属主通道契约不变)。
  7. 是否引入新配置:不涉及(BILI_PI_BIN override 早已存在;无新 env/config/默认值)。

判定:可合 —— 待 19a8ef02 上重跑的 test (windows-latest, 22/24) 转绿即可(其余 12 项在前一 head 已全绿,唯一失败就是这一条测试)。合并仍由人工执行。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 ## CI confirmation — #1883 now fully green ✅

Re-ran check on the fixed head 19a8ef02: all 14 check runs pass, including the two that were red before:

  • test (windows-latest, 22) → success (was failure)
  • test (windows-latest, 24) → success (was failure)
  • test (ubuntu-latest, 22/24) → success
  • hermetic registry e2e (ubuntu + windows), real client lanes, build-artifact, version-guard → all success

So the host-independent test rewrite resolved the Windows drive-colon failure with no regression anywhere else. Verdict unchanged: ready to merge — the only outstanding item was those two Windows jobs, now green. Merge stays human-only; go ahead when you're ready: #1883

@ranxianglei
ranxianglei merged commit 562d0e6 into master Oct 2, 2026
14 checks passed
@ranxianglei
ranxianglei deleted the 2026-10-02_update-test-hardening 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.

1 participant