āœ… test(guard): every mutant in scripts/guard.mjs dies

Merged
AT
2d ago
+491-107

Slice: #632

Part of #580's one-time sweep. This is part 2 of 2 of scripts/guard.mjs, line 519 (after #631, #703) to the end. Every Survived and NoCoverage mutant in it now dies. This is the file's last part, so the gate on the whole file exits 0.

Re-measured on main

On 1ebdaea, the merge of #631 (#703), a direct Stryker run of scripts/guard.mjs:519-910 counted 117 blocking mutants: 101 Survived and 16 NoCoverage. The slice named 121 on 0a9c8be; #631's tests had killed 4 of them already, as #703 shows.

How they die

The tests read:

  • Scripts and tags.
    • package.json's scripts, compared as text where they do not parse.
    • niyam's tag, through every answer GitHub gives that is not a commit on its main: a refused or empty ref or annotated tag, a commit with no sha or one with more around it, and a refused or empty compare.
  • The slice's approval.
    • Another repository's Approvals issue, where its default branch names no branch or its settings do not parse.
    • Every owner named.
    • The Work item's last approved label alone, past events of other labels or none.
    • A slice's last addition, in any order, and one added at the moment of approval.
  • Answers.
    • A Decision at the moment the slice joined, with spaces before it, or one named in passing.
    • Work item events that are not comments.
    • Two answers at one moment.
    • Agents' proposals and šŸ‘, past comments and reactions with no user, at the proposal's own moment and the edit's.
  • The remedy.
    • The remedy, with agents and with none.
    • A Mergify draft's GraphQL read.
    • A stack in which each pull request passes a different file.
  • Exemptions and reads.
    • Dependabot's and onboard's exemptions at their edges.
    • The ruleset, read once and from its required-checks rules alone.
    • Paths with no old name.
    • package.json and workflows, read only where they are there.
    • The newest pin on the default branch.
    • Every GraphQL answer that holds no slice body.
  • main.
    • Repository names of any width.
    • No token, when a GitHub is given.
    • The event, named or not.
    • The API address.
    • The default branch.
    • entry.

Source rewrites, for mutants no test can see

The guard's behaviour is unchanged, its exit included: entry still ends the run with process.exit.

  • Missing text. A missing title, body, sha, file or settings text is read as String(undefined), which names nothing.
  • Approvals.
    • approvalsThere reads settings that are not there as text that does not parse, and its catch leaves the answer undefined.
    • approvedAt takes the name function judge always gives.
    • It reads the Approvals issue's comments only where the settings name one.
  • judge.
    • It takes its own guard paths with no default, as main always gives them; the tests now pass [].
    • It builds the refusal's slice text once the slice is known.
  • Draft reads. A Mergify draft's reads are keyed by Boolean(raw).
  • judgeAs.
    • It works out onboard's exemption for any title, since nothing moves to a title that names no release.
    • It reads a workflow's jobs at the merge base through Object.values, with no empty fallback.
  • main. It reads the default branch from the answer read gives.
  • entry. It takes main and process.exit, and the tests call it in-process, with no second import that coverage would count.

Only the files the 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: 1424 killed of 1424 in 1 file(s) (1417 Killed, 3 Timeout, 4 RuntimeError; 3 timeout(s) retried) - pass
agnipariksha total: 1424 killed of 1424 in 1 lane(s), 0 blocking, 0 refused - exit 0

The gate ran before this branch's rebase onto e6bdc03 (#704), which changes neither guard file.

  • pnpm test:scripts passes 207 of 207 on the rebased head, with scripts/guard.mjs at 100% line and function coverage.
  • The pre-push hook passed on the push.

šŸ¤– Generated with Claude Code


Summary by cubic

Kills every surviving mutant in scripts/guard.mjs from line 519 to the end, completing the file's mutation sweep. agnipariksha now reports 0 blocking mutants and the guard gate exits 0.

The new tests cover niyam's tag, approvals and decisions at their edges, Dependabot and onboard exemptions, ruleset reads, and main's configuration. Source rewrites make the code testable without changing behavior.

Source rewrites

  • Missing title, body, sha, file, or settings text reads as String(undefined), which names nothing.
  • judge takes its own guard paths and a name function with no defaults, as main always gives them.
  • entry takes main and process.exit as arguments, so the exit path runs in-process under test.
  • Approvals comments are read only where the settings name an issue.

The guard behaves identically, its exit code included.