Skip to content

fix(dev): Windows-proof the Pi patch checks and fork test paths - #1370

Closed
yexisu wants to merge 1 commit into
vastsa:mainfrom
yexisu:fix/windows-dev-env-checks
Closed

yexisu wants to merge 1 commit into
vastsa:mainfrom
yexisu:fix/windows-dev-env-checks

Conversation

@yexisu

@yexisu yexisu commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Two Windows-only dev-environment failures from #1361 (Linux CI unaffected):

  1. check:pi-dependencies / check:pi-patches detect pnpm's patched instance by matching the literal patch_hash= segment in realpathSync output. Windows shortens .pnpm store directory names (long-path limit), the segment disappears, and both checks misreport a healthy install.
  2. native-pi-session.test.ts "never deletes a foreign publication" compared foreignPath.split("/").at(-1) with readdirSync output; on Windows the split never breaks the path, so an absolute path was compared against a bare file name.

Fix

  1. The patch hash is now proven through the lockfiles instead of path strings: the root pnpm-lock.yaml patchedDependencies entry declares the 64-hex hash for name@version, and node_modules/.pnpm/lock.yaml must embed that hash in the installed snapshot's version: <v>(patch_hash=...) line. This survives Windows's shortened directories, is stricter than the old substring match, and is unchanged on Linux. The installed manifest is still version-checked directly via realpath.
  2. foreignPath.split("/").at(-1)! replaced with basename(foreignPath).

Validation

  • The fork test now passes on Windows (failed on pristine main): native-pi-session.test.ts targeted run 1/1
  • Two-stage hash chain verified against this machine's lockfiles: the declared 1.0.1 hash resolves from pnpm-lock.yaml, and the stale 0.99.1 virtual-store snapshot correctly fails the embed check (proving the check is strict)
  • Full check:pi-* end-to-end run requires a 1.0.1 install this machine does not have yet; logic verified as above, CI covers the rest

Fixes #1361

check:pi-dependencies and check:pi-patches detected pnpm's patched
instance by matching the literal `patch_hash=` segment in realpath
output. Windows shortens `.pnpm` store directory names (long-path
limit), so the segment disappears and both checks misreport a healthy
install (vastsa#1361). The patch hash is now proven through the lockfiles:
the root pnpm-lock.yaml patchedDependencies entry declares the 64-hex
hash and the virtual-store lockfile must embed it in the installed
snapshot's `version: <v>(patch_hash=...)` line, which survives the
shortened directories. The installed manifest is still version-checked
directly.

The native fork fixture compared `foreignPath.split("/").at(-1)` with
readdirSync output; on Windows the split never breaks the path, so the
assertion compared an absolute path against a file name. Use
path.basename instead.

Validated: the fork test now passes on Windows (it failed on pristine
main); the two-stage hash chain verified against this machine's 0.99.1
lockfiles (declared hash resolves, stale virtual store correctly fails
the embed check).
@yexisu
yexisu force-pushed the fix/windows-dev-env-checks branch from a70812f to a7e393b Compare October 4, 2026 03:17
@yexisu

yexisu commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (c5a16e9aa, includes #1371/#1372) and force-pushed (a7e393bc5). The Windows fork-path test this PR fixes now passes on the rebased head (native-pi-session.test.ts targeted run 1/1); note it still fails on current main itself, which is exactly the baseline defect being fixed here. Ready for a landing review.

@vastsa

vastsa commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Thanks for contributing the Windows portability fixes. The issue is real, and #1363 now covers both the patch-check and path-test failures with a seven-case shortened-store regression suite; its CI passed and it has merged. Closing this duplicate as superseded.

@vastsa vastsa closed this Oct 4, 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.

[Bug] Windows 开发环境两例:check:pi-* 误报 patched 实例;native fork 测试路径断言失败

2 participants