Skip to content

test(cli): the prune's production mtime fallback is witnessed, not just its consumer (TASK-174) - #1969

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/task174-prune-fallback
Sep 27, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/task174-prune-fallback

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Test-only follow-up to the merged #1965 (62d226c9), closing the one mutation survivor Vera found in her own gate (74902). One file, +24 lines, no cli/src change, so no version bump.

The survivor. In pruneVersionDirs, the consumer checks typeof installedAt !== 'number' and the default reader's catch returns null. My arm for that hazard ("a dir with no readable mtime is left alone") injected mtime: () => null — so it witnessed the consumer's branch and never the production fallback, which is the code that actually runs when statSync throws. Change that catch to return 0 and all 49 tests stayed green: an unreadable directory becomes maximally old and is pruned, which is precisely the hazard the branch exists to prevent.

The arm. the REAL mtime reader leaves an unstat-able dir alone (the production fallback, not an injected one): a home holding the newest three versions, a readDir that also reports 0.3.9 (past the count, so a genuine prune candidate) while the filesystem does not have it — the real reader's statSync throws, so the default catch is what decides. Injected remove spy asserts the decision, not the filesystem outcome (removed === [], remove never called). The positive control is the arm next to it — keeps the newest N and removes the rest — which shows the same default reader pruning the same shape of candidate when it can read the mtime, so this test cannot pass by pruning being broken generally.

Verified both ways. Baseline at this head: 1 suite / 50 tests, green. Mutation: default catch { return null } → return 0 → 50 tests, 1 failed, killed by exactly this arm. One instrument note for whoever re-runs it: my first mutation run used npx jest instead of node --experimental-vm-modules node_modules/.bin/jest and reported 0 tests / 1 runtime error — a suite that never loaded. It showed up as a zero in the count, not as a pass, which is the only reason it did not read as a kill.

Correction to the record of this row, since this PR replaces a bad one. #1967 was my attempt to correct #1965's stated cause, and it was wrong in the opposite direction: it adopted a cold-install/create-race reading that Vera withdrew in 74839 and that Wren's hashing settles the other way (74837 — sha512('@commonlyai/mcp@latest')[0:16] = 6d82e98be466b586 is ONE shared dir, its package re-created in place at 10:53:03Z; the 4401305a… dir was Wren's own exact-version probe, not a second seat). The sentence main carries in mcp-home.js and in the test header is the true one — a shared @latest dir rewritten in place after a publish (the post-publish CONNECTION_CLOSED window), plus registry/lock work on every npx run (the no-publish 30 s CONNECT_TIMEOUT) — so nothing there needed changing. #1967 is closed.

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Sep 27, 2026
Merged via the queue into main with commit 6cb5b7c Sep 27, 2026
15 checks passed
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