✨ feat(mutation): a scripts lane judges the root's scripts/*.mjs
Slice: #327
The mutation gate now judges the root's own scripts/*.mjs: the lane planner, the version rule, the provenance check and the temp-folder wrapper. Its first run found survivors in all four, and each is killed. No mutant is left: 863 of 863 killed (859 Killed, 4 RuntimeError), in about 50 s on an 18-core Mac. On CI's Linux runner the lane job took 1 min 37 s.
This waits for Alok's code-owner review. It touches agnipariksha.json, stryker/ and scripts/version-rule.mjs and scripts/mutation-lanes.mjs, which .github/CODEOWNERS names. Auto-merge is on, so it merges once he approves and the checks pass.
The lane
-
The lane:
agnipariksha.jsongains ascriptslane:- it is the only lane that runs from the root (
cwd: "";judgeLanehandles an empty cwd); - it includes
^scripts/[^/]+\.mjs$, with the extension.mjs; \.test\.mjs$is added toignore.
- it is the only lane that runs from the root (
-
Its Stryker config,
stryker/scripts.config.mjs, islane('')withignorePatterns. It lives understryker/, which CODEOWNERS already owns, so neither CODEOWNERS nor CLAUDE.md changes.- Run from the root, Stryker would otherwise copy the whole tree into its sandbox:
packages/,.tmp/, and in the main checkout every worktree under.claude/worktrees/. The sandbox keeps onlyscripts/,package.jsonandagnipariksha.json. pnpm-lock.yamlmust stay out. The 4 RuntimeErrors are the mutants that forceown-provenance.mjs's entry condition true, and they die on its absence before any request leaves the machine. The config says so.
- Run from the root, Stryker would otherwise copy the whole tree into its sandbox:
-
released-pins.mjsis out, through the lane'sexclude. It is a hook file agents don't change (CLAUDE.md, "Git hooks"), so a survivor there would block a push only you could make.guards.shisn't JavaScript. -
The pin needed no change. The root already pins agnipariksha 0.8.5 (#421), which carries #325's
.test.mjsownership. Going back to 0.8.4 would drop--pushed-refs, which the pre-push hook uses (#423). -
CI plans the lane with no change to the planner's logic. A new case in
mutation-lanes.test.mjsplans veda's realagnipariksha.json:- a changed
scripts/x.mjsbeside its suite gives thescriptslane work; - a changed suite alone gives it none, and neither does
released-pins.mjs.
Run by hand on this branch,
scripts/mutation-lanes.mjs --base origin/mainprintslanes to judge: scripts, so this PR'sMutationcheck runs the lane on Linux. A lane job's 90-minute timeout is far above that. - a changed
-
The lint rule that refuses
// Stryker disable(MUTABLE ineslint.config.js) already coversscripts/**, so no comment can take a script's mutants out of the lane.
The sources changed too
The slice expected the survivors to die in the suites alone. They couldn't, so all four sources changed. Each change keeps the command line, output and exit codes as they were:
- Every script, the entry. The
/* node:coverage disable */blockif (process.argv[1] && import.meta.url === …) { … }was untestable in-process: Stryker sees no coverage from a spawned child. It becomes an exportedentry(argv, url, io)that returns the exit code, orundefinedwhen the module is imported. The module ends withprocess.exitCode = (await entry(process.argv, import.meta.url)) ?? process.exitCode;, so an import leaves the importer's exit code as it was. Each suite checks that in a child that sets the code to 7 before importing the script.- Its real I/O is injectable, with the real one as the default.
- The suites test it in-process with fakes, so a forced-true mutant reaches no network, spawns nothing, and runs no git in the real repository.
mutation-lanes.mjs:gitIn'sstdiowent from['ignore', 'pipe', 'pipe']to'pipe'. The array's[]mutant was equivalent. The''mutant of'pipe'makesexecFileSyncprint git's stderr as well, which a spy sees.version-rule.mjs:gitTags,fetchJsonandrealIo()are exported.majorApproved:(a.environments ?? []).some(…)becamea.environments?.some(…) === true, with the same result.- Manifests are read as
String(readFileSync(…)), with no encoding named. checkgetstagdirectly; it already treats an absent tag and an undefined one alike.main's last branches were reordered so "nothing unreleased" comes first.checkalways returns a version with a bump, soresult.version ?? ''in the major warning could never be reached, and it is gone.defaultManifests(root, list)takes the folder listing, so the.sort()kill does not depend on the order the filesystem lists folders in: APFS sorts them, ext4 does not.
own-provenance.mjs:main(io)writes to an injectable stdout and stderr, and returns 1 where the block calledprocess.exit(1). Nothing runs after it.fetchJson(url, { get, env })andreadTextare exported.bundleVerifiertakes the verifier class, so a test sees its thresholds, which equal the library's defaults.utf8Stringtakes the byte length ofBuffer.from(text). The bytes are the same for the ASCII it is given (a commit id,refs/heads/main).- Two
Array.isArray(x) ? x : []fallbacks became directfindandsomecalls; their["Stryker was here"]mutants could not be told apart.
fresh-tmpdir.mjs:runtakes aspawnoption, so a fake child can reach the'error'handler and the signal forwarding.- A comment was wrong: Node does send
'close'(code -2) after a spawn's ENOENT'error'. It now says so.
The suites:
- Each suite yields once per test (
beforeEach→setImmediate), so the tap runner'sforceBaillands on a mutant's first failure. - Messages are asserted whole, as literals.
- fresh-tmpdir's tests that run a real process have a 10 s timeout. Each such child first checks that its temp folder is the run's own scratch folder, so no mutant can aim a removal at the real tmpdir.
pnpm test:scriptshas 100% lines and functions in all four.
Not done
docs/lessons/stryker.md still describes the lanes as one per package. That page is copied into sarathi's package at build, so the fix is left for a docs change.
🤖 Generated with Claude Code