✅ test(guard): every mutant in scripts/guard.mjs lines 1–518 dies

Merged
AT
2d ago
+304-25

Slice: #631

Part of #580's one-time sweep. This is part 1 of 2 of scripts/guard.mjs, lines 1–508 on main, now lines 1–518. Every Survived and NoCoverage mutant in those lines dies. Part 2 (#632) is left alone.

Re-measured on main

scripts/guard.mjs and its test have not changed since 0a9c8be. A direct Stryker run on main (b4a44ab) gave:

  • Lines 1–508: 807 mutants. 121 are blocking (119 Survived, 2 NoCoverage), as the slice named. 4 are Timeouts, all at Stryker's hit limit.
  • Lines 509–900 (#632): 730 mutants, 121 blocking (105 Survived, 16 NoCoverage).

How they die

The tests read:

  • Guard files and tests.
    • Each floor guard path counts only at the root and only as itself.
    • Test files with longer names count.
    • A guard list with anything but names in it is refused.
  • Sections.
    • Read in any case, and to the end of the body.
    • They stop at the next section, indented or not, but not at a section named in passing.
    • guardsNamed strips list marks.
  • Slice lines.
    • With no space, or a trailing space.
    • With numbers of any width.
    • Not when text comes before or after.
  • bodyAt.
    • At the very moment the slice was made, of an edit, and of the last edit.
    • Before the slice was made, never edited, and with a revision of no text.
  • Settings. Owners, agents, features, guard paths and the Approvals issue, at their edges, with every refusal to the letter.
  • Changes.
    • Tests counted with spaces before the bracket or the colon.
    • Releases compared at every width.
    • Dependabot's sha moves in each shape it writes, and in every shape it does not.
    • Onboard's version moves with one version more, and a sha256 after a version.
  • Workflows.
    • Workflows, jobs, events and pins of every shape.
    • The shared Guard's caller at any width, with steps, with another's uses: of the same length, or with none.
    • A workflow must sit right in .github/workflows/.
  • GitHub.
    • The client's requests to the letter.
    • The slice's GraphQL query.
    • Raw reads, and a failing commit named by its short sha.
    • A refusal with no message, and a 200 that is no JSON.
    • Lists that are missing or not, read past a full page, stopped at the most read, and with a query of their own.
    • An approval no actor gave.
  • package.json. One that does not parse.
  • Onboard and caller pins. Onboard titles and caller pins of every width and shape.

Source rewrites, for mutants no test can see or that could hang

The guard's behaviour is unchanged.

  • Defaults. isGuardFile takes its paths as judge gives them, with no default.
  • Equivalent checks.
    • guardsNamed splits at each separator; the empty words go with the prose.
    • named matches a name with no * through the glob's pattern, where it reads as itself.
  • Missing text. sliceOf and pinsIn read missing text as String(undefined), which names no slice and is no workflow.
  • No loop. newer compares padded parts, with no loop a mutant could make endless.
  • Shapes.
    • A job that is no mapping, and events of a shape it does not read, go through Object() in pinsIn, workflowOf and isCaller.
    • workflowOf's and client's catches leave the value undefined.
    • A null jobs: needs no check of its own.
  • Implied checks. guardPathsIn needs no word count and approvalsIn no typeof: the checks beside them already imply both.
  • package.json. scriptsOf gives a missing package.json no word that a file's own text could stand in for.

Only the files this slice names under Guards: change: scripts/guard.mjs and scripts/guard.test.mjs. No // Stryker disable and no new dependency.

Evidence

agnipariksha --lane scripts --files scripts/guard.mjs --no-reuse
scripts: 1353 killed of 1470 in 1 file(s) (16 NoCoverage, 1348 Killed, 3 Timeout, 101 Survived, 2 RuntimeError; 3 timeout(s) retried) - 117 blocking
agnipariksha total: 1353 killed of 1470 in 1 lane(s), 117 blocking, 0 refused - exit 1

agnipariksha 0.8.8's --files takes no line range, so the gate judges the whole file. It exits 1 on part 2's mutants. The blocking mutants this run lists, by line:

LinesBlocking
1–518 (#631)0
519–910 (#632)117 (101 Survived, 16 NoCoverage), down from 121

A direct Stryker run of scripts/guard.mjs:1-519 on this branch gave 742 mutants: 737 Killed, plus 3 Timeouts at the hit limit, which agnipariksha counts as killed. Its last 2 survivors were on named's exact match and on a 200 with no JSON. Both die since, as the gate above shows.

  • scripts/guard.test.mjs passes 91 of 91.
  • The pre-push hook passed on the push.

🤖 Generated with Claude Code


Summary by cubic

Makes every Stryker mutant in scripts/guard.mjs lines 1–518 die, completing part 1 of 2 of the mutation sweep (#631). Lines 1–518 go from 121 blocking mutants to 0; the source rewrites preserve behavior and exist only to remove mutants no test can see or that could hang. No // Stryker disable and no new dependency. Part 2 (#632) still leaves 117 blocking mutants, so the gate still exits 1.

Tests

  • Covers settings edges (owners, agents, features, guard paths, Approvals), slice-line and section reading, bodyAt timing, release-width comparisons, Dependabot sha moves in every shape, workflow/job/pin/caller shapes, GitHub paging and client requests, and a package.json that does not parse.

Source rewrites

  • isGuardFile takes paths with no default; guardsNamed splits one separator at a time; named matches no-* names through the glob pattern; sliceOf and pinsIn read missing text as String(undefined), which names no slice and is no workflow.
  • newer pads parts instead of looping; non-mapping jobs and events pass through Object(); workflowOf's and client's catches leave the value undefined; scriptsOf gives a missing package.json no word a file's own text could stand in for.