πŸ› fix(test): the mutation gate can judge src/hermetic-git.ts

Merged
AT
14h ago
+48-11

Slice: #634

The mutation gate can now judge src/hermetic-git.ts. The inventory on #580 could not judge it, because one of its mutants deleted the run's temp directory.

Cause

  • removeFixtureRoot's test handed it the real tmpdir() and the checkout's process.cwd(), expecting a refusal.
  • A mutant that broke the refusal check therefore removed the run's temp directory (agnipariksha refused the file) or Stryker's sandbox.

Fix

  • removeFixtureRoot(path, root = tmpdir()) takes the root it judges against. Its callers (doc-numbers, work-item-number and renumber-doc tests) are unchanged.
  • The refusal tests now pass only folders they made: a root, a folder beside it, a name that only starts like the root, and a link out of it. Each must be refused with its exact message, and still exist afterwards.
  • The check is now one prefix test, realpath(path) against realpath(root) + sep, in place of relative() plus isAbsolute(). On POSIX, relative() never returns an absolute path, so the isAbsolute mutant could never be killed.
  • rmSync drops force: true, which the existsSync guard above it already made dead.

Evidence

agnipariksha --lane src --files src/hermetic-git.ts --no-reuse
src: 26 killed of 26 in 1 file(s) (26 Killed; 0 timeout(s) retried) - pass
agnipariksha total: 26 killed of 26 in 1 lane(s), 0 blocking, 0 refused - exit 0
  • The file has 26 mutants now, down from 32: the rewrite removed six.
  • pnpm check passes locally.

πŸ€– Generated with Claude Code


Summary by cubic

The mutation gate can now judge src/hermetic-git.ts. Previously it refused the file because a mutant that broke the refusal check removed the run's temp directory or Stryker's sandbox.

  • removeFixtureRoot now takes a root to judge against, defaulting to tmpdir(). The refusal tests hand it only folders they created, so a broken check can't touch anything real.
  • The containment check is now a single prefix test against the realpath of the root plus a separator. A root that already ends in the separator, like filesystem-root /, is used as is; appending a separator to realpath('/') would yield '//', which no path starts with.
  • rmSync drops force: true, which the existsSync guard had made dead.

This resolves the blocker for inventory #634; agnipariksha now kills 27 of 27 mutants in the file, down from 32.