Filter the shipped instruction list to files selected by the install profile and make the retained paths independent of the launch directory. Record the resolved paths for repair, and anchor the bundled skill lookup to the same config root.
Refs #4029
canonicalize walked Object.keys and never called toJSON, so every Date
hashed as {}. Replay fixtures are keyed by hashValue({ tool, args }), so a
call with a different Date argument replayed the fixture recorded for
another date instead of failing with tool.fixture_missing, and the stored
response held {} where the live call returned a date.
Call toJSON with the holder key before canonicalizing, matching the JSON
coercion policy the module already follows. Plain JSON data hashes are
unchanged; the pinned byte and hash vectors still pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
digestDir hashed each file as `path \0 bytes \0` with no length, so file
contents holding NUL could absorb the following files: a one-file tree and
a two-file tree produced the same digest. Frame each file as
`path \0 byteLength \0 bytes`.
Entries were also sorted with localeCompare, which follows the host locale
(sv_SE sorts `ä` after `z`), so the same tree got different digests on
different machines. Sort by code point.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review feedback (CodeRabbit, Greptile): the attempt cap still assumed
25 ms per wait, but the jittered waits average about 15 ms, so writers
ran out of attempts at roughly 1 s on the default budget and about 5 s
on the 10 s install-state budget.
- Derive the safety cap from the minimum wait, so the elapsed budget is
what actually stops retries.
- Raise the minimum jittered wait from 1 ms to 5 ms. That keeps the
safety cap meaningful (401 attempts per default write) while the
5-25 ms spread still breaks contender lockstep.
- Add tests whose fake clock advances by the requested wait. They fail
on the previous commit (retries stopped at 1073 ms and 5127 ms) and
pass now.
- Update the session-aliases bound that encoded the old cap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Windows, concurrent writeInstallState calls (and real-time antivirus
scans of each freshly published file) can hold replacement sharing locks
for over a second. renameAtomic retried at a fixed 25 ms interval, which
kept contenders in lockstep, so one writer could lose every round and
give up with EPERM at the 2 s deadline. This made
tests/lib/install-state.test.js fail in about half of isolated runs.
- Retry with a uniform random wait of 1-25 ms instead of a fixed 25 ms.
Exponential backoff was measured and made starvation worse.
- Add a renameRetryBudgetMs option to writeFileAtomic. The default stays
2 s, so hook callers keep their latency bound, and the attempt cap is
derived from the budget (81 for the default).
- writeInstallState uses a 10 s budget, since it runs only during installs.
Measured on Windows 11 with Defender on: install-state test 0/12
failures (previously 4/8).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>