Repository navigation
Description
Context
claudeHomeSnapshot (scripts/test-home.ts:7) records inode, mode, size, mtimeNs and ctimeNs at :16, then createInvokingTestHome compares that metadata snapshot to detect writes. Same-size writes within the filesystem's timestamp granularity can leave every recorded value unchanged. The guard then accepts modified sentinel bytes.
During #4314's full unit proof, all three existing overwrite tests in tests/test-home.test.ts:8 and :42 failed: the snapshot stayed identical after a same-size overwrite, and assertUnchanged did not throw TEST_WROTE_INVOKING_CLAUDE_HOME. Both test and implementation are byte-identical to origin/main.
At origin/main 7e861bdb3, with main's own preload in a separate Ubuntu 24.04 VM checkout, ten repetitions of those three cases produced 28 failures out of 30 cases. This is separate from the workspace alias walk in #4471, but shares the assumption that unchanged timestamps imply unchanged state.
Out of scope
No #4314 native-execution authority or transport changes, workflow changes, real invoking-home data, or product HOME fallback changes. Filed without a milestone as a pre-existing main failure.
Scope
Make the existing disposable invoking-home guard detect same-size byte changes independently of timestamp changes. Preserve environment-descriptor restoration and the rule that symlinks are not followed outside the guarded tree. Retain only evidence needed for comparison; do not log file contents.
Acceptance criteria
- Same-size changed bytes are detected even when inode, size, mtimeNs and ctimeNs are equal.
- Add deterministic proof of equal metadata with different real file bytes; do not add sleeps to hide the blind spot.
- Original files and environment property descriptors remain restored, and symlink containment remains unchanged.
- Removing the content-sensitive comparison makes the intended overwrite assertion fail.
Verification
Baseline: bun run test tests/test-home.test.ts -t 'same-size overwrite|snapshots detect' --rerun-each 10 on the main commit above with main's preload. Run the whole test-home file and launcher/host-storage consumers after the fix. Preserve workflow budgets and product timings.
Contract impact
No CLI/MCP/schema change. This repairs the existing test harness integrity check.
Activity