Stop concurrent test packs from rewriting the shared build (pm-vcs-v5bg)
Fixes #175. Tracker: pm-vcs-v5bg
Problem
installPackedExtension (scripts/pm-environment.ts) ran npm pack --silent in the package root.
- npm pack runs
prepack, which isnpm run build(tsc). That build truncates and rewritesdist/. - The release suite runs up to four test files concurrently. One file's
tscrewrotedist/while another file'snpm packwas archiving it, and node-tar failed withEOF: encountered unexpected EOF. --silenthid that npm error. The test diagnostic showed only the prepare script's harmlessnpm pack: skipping merge-driver install during artifact creationline.
Where it failed:
| Run | Job | Test |
|---|---|---|
| main at 131dc3a | test (22) | bisect.test.ts: "a walk killed mid-flight resumes…" |
| #177 | test (26) | checkpoints.test.ts: "installed CLI attaches and inspects JSON and TOON…" |
Locally, 3 of 60 and then 5 of 60 staggered concurrent packs failed. Each failure was npm error code EOF, syscall read, on a dist/ file: dist/engine/lifecycle.js, dist/ledger.js and dist/engine/destruction.js.map.
Change
- Pack with
--ignore-scripts.test/composition-consumer.test.tsandscripts/verify-pack-privacy.tsalready do this. Every runner builds before packing:test,coverage,release:check, and the Windows job'snpm run buildstep. This helper was the only thing that rewrotedist/during the suite. - Replace
--silentwith--loglevel=error. A future pack failure then reports npm's own error. - Add a regression test in
test/quality-scripts.test.ts. A realnpm packmust leave everydist/file's mtime unchanged.
Verification
- The new test passes with the fix. With the old
--silentarguments restored, it fails because thedist/mtimes change. - Stress test with the new arguments: 0 of 60 staggered concurrent packs failed, and stderr was empty.
typecheck,lint,docstring,duplicates,changelog:checkandaccept:self-host(at HEAD) pass.test/quality-scripts.test.ts: 10 of 10 pass.- The self-host bundle was regenerated for the new tracker item.
Summary by Sourcery
Make concurrent package creation reuse the existing build while surfacing actionable npm pack failures.
Bug Fixes:
- Prevent concurrent test packs from rebuilding and rewriting the shared dist/ directory, eliminating intermittent npm pack EOF failures.
- Expose npm pack errors and whether the process exited by status or signal in installation diagnostics.
Enhancements:
- Ensure the native TOON acceptance workflow builds before packing so it can reuse the existing build.
Tests:
- Add regression coverage confirming packing preserves dist/ file modification times and reports pack failures, npm errors, missing executables, and terminated processes.
Chores:
- Regenerate the self-host bundle for the tracker update.
Summary by cubic
Fixes flaky EOF: encountered unexpected EOF failures when concurrent test files pack the same package root. installPackedExtension ran npm pack --silent, whose prepack step rebuilt dist/ while another test process was archiving it, and --silent hid npm's error.
The pack now uses --ignore-scripts to reuse the existing build (every runner builds first) and --loglevel=error so npm failures surface.
accept:native-toonnow builds first viapreaccept:native-toon, matching the other acceptance scripts, since the pack no longer rebuilds.- A failed pack now names how the child ended:
npm pack failed (status N): <npm error>ornpm pack failed (signal S). - Tests cover the regression (a real pack leaves every
dist/mtime unchanged), a missing executable, a refused pack carrying npm's error text, and a SIGKILL.