Skip to content

S18 — Test Strength (Mutation Score Publication) ​

Overview ​

Line coverage is already gated at 80% on all four c8 axes, and every spec clears it — the population sits between 90% and 99%. That is the gate working, but it also means coverage has no dynamic range left: cross-plotted against customer value across the scored feature specs it returns r ≈ 0.08, so it cannot rank one spec's test strength against another's and cannot answer "which valuable feature is thinly tested?".

Mutation testing can. Stryker is already configured (stryker.config.json, constitution Article V) with a break threshold, and npm run test:mutation already runs — but its output is an HTML report that is never committed, so no other tool can read it and no trend or comparison exists. This spec publishes the score: a committed, machine-readable per-file artifact generated from Stryker's own JSON reporter, which S10 then charts against the S16 value estimate.

The maturity scorer deliberately checks only that the mutation gate exists (mutation-gate, 2 points) rather than what it scores, because a full run is too expensive to make a scoring input. This spec does not change that.

User Stories ​

  • As a maintainer, I want to see which of my valuable features have weak tests, which line coverage can no longer tell me.
  • As a contributor, I want the mutation score of a file I am about to change without waiting for a full mutation run.
  • As the project, I want the score in a committed, tool-neutral file so any agent, script, or docs page can read it without re-running Stryker.

Functional Requirements ​

  • S18-SR-01 A committed artifact mutation-score.json MUST record the mutation results per source file: the mutant tallies by status and the score derived from them, plus a repository-wide total. It MUST be generated by node scripts/mutation-score.mjs from Stryker's JSON report and MUST carry a $comment marking it generated — never hand-edited, exactly like maturity-score.json, dora.json and bundle-size.json.
  • S18-SR-02 The artifact MUST store the tallies, not only a percentage, so the score is auditable and recomputable by a consumer that disagrees with the formula. The formula is the mutation-testing standard — (killed + timeout) / (killed + timeout + survived + noCoverage) — and MUST be declared once in the generator script, which is its machine-readable authority; this spec's prose mirrors it.
  • S18-SR-03 The artifact MUST carry provenance: the date generated and the Stryker break threshold in force at generation time. Because the score is a snapshot of code that keeps changing, any surface displaying it MUST show that date, so a stale figure is visibly stale rather than silently wrong.
  • S18-SR-04 Generating the artifact MUST NOT be part of the mandatory local gate (npm run verify) or of a blocking CI job: a full mutation run takes orders of magnitude longer than the rest of the gate. It is refreshed on demand like npm run maturity, and its absence MUST degrade gracefully — consumers MUST treat a missing artifact as "not measured" and MUST NOT fail or substitute a zero.
  • S18-SR-05 Files Stryker is configured not to mutate (the mutate!src/… exclusions, kept in lockstep with the coverage exclusions by npm run check:consistency) MUST be absent from the artifact rather than recorded with a zero or null score, so "not mutated by policy" is never read as "badly tested".

Keeping the published score current ​

  • S18-SR-06 The mutation workflow (.github/workflows/mutation.yml) MUST carry Stryker's incremental results from one run to the next, so a run re-tests only the mutants whose source or covering tests changed instead of all of them: a cold run already takes most of the hosted runner's six-hour job limit, and the mutant count only grows. The results MUST be saved even when the run fails the break threshold, MUST NOT be reused across a change to stryker.config.json, and the workflow MUST offer a manually triggered full run that ignores them — incremental mode sees changes to mutated sources and their tests, not to dependencies or tooling.
  • S18-SR-07 A run on the default branch MUST propose the regenerated mutation-score.json back to the repository as a pull request — never a direct push — whenever the scores differ from the committed artifact or the committed measurement is at least 14 days old. Otherwise the artifact is only ever as fresh as the last time someone refreshed it by hand, which is what S18-SR-03's date exists to expose, not to excuse. The write-scoped token MUST be confined to a job that does not install dependencies or run the test suite, and a run that produced no report MUST NOT propose anything.

Non-Functional Requirements ​

  • S18-NFR-01 The generator MUST be plain Node with no third-party dependencies, like the repository's other checkers, and the artifact MUST be tool-neutral JSON (S15).
  • S18-NFR-02 The mutation score MUST NOT influence the maturity score: scripts/maturity-score.mjs MUST NOT read mutation-score.json. The scorer checks that the gate exists, and adding a score-derived input would make the maturity number depend on an artifact that is refreshed on demand and may be arbitrarily stale.

Out of Scope ​

  • Running mutation testing on every pull request, or gating a pull request on the score — the break threshold fails a local or scheduled run below 60, which is the gate. (The scheduled run itself is in scope: S18-SR-06/07.)
  • A time series of mutation scores; the artifact is a current snapshot, and trend reporting belongs to the maturity history if it is ever wanted.
  • Per-requirement mutation scores. Stryker reports per file; the file → spec join comes from the traceability matrix's impl paths, and a finer attribution would need a mapping the repository does not have.

Acceptance Criteria ​

  1. npm run test:mutation writes reports/mutation/mutation.json, and node scripts/mutation-score.mjs turns it into mutation-score.json with a per-file breakdown and an overall score.
  2. Re-running the generator on an unchanged report reproduces the file byte for byte.
  3. Every file listed carries tallies whose recomputation reproduces the stored score; no file excluded by stryker.config.json's mutate list appears.
  4. Deleting mutation-score.json leaves npm run verify passing and the docs site building, with the test-strength chart showing its "not measured" state.
  5. scripts/maturity-score.mjs contains no reference to mutation-score.json, and npm run maturity output is unchanged whether or not the file exists.

History ​

  • 2026-07-25 — Created after plotting per-spec line coverage against customer value across the scored features returned r ≈ 0.08, with every spec between 90% and 99%: the 80% gate compresses the population so far that coverage cannot discriminate test strength. Mutation data was already being produced by every npm run test:mutation run and thrown away with the HTML report.
  • 2026-11-16 — Added S18-SR-06 and S18-SR-07. The scheduled run had been failing unnoticed for two months, and once repaired a cold run took 4h25m for 13,660 mutants against a six-hour job limit; meanwhile the committed artifact still carried its July date, because nothing but a manual refresh ever wrote it back. Out of Scope narrowed accordingly: the scheduled run exists and is now specified, per-pull-request runs remain excluded.

Requirement traceability ​

Status of each requirement in specs/traceability.json. Test coverage is auto-discovered from [ID] tags in test titles and is not listed here.

RequirementStatusImplementationNote
S18-NFR-01implementedscripts/mutation-score.mjsplain Node, no dependencies
S18-NFR-02implementedscripts/maturity-score.mjsmaturity scorer never reads mutation-score.json; it checks only that the gate exists
S18-SR-01implementedscripts/mutation-score.mjsmutation-score.json generated from Stryker JSON report
S18-SR-02implementedscripts/mutation-score.mjstallies stored alongside the derived score; formula declared once in the script
S18-SR-03implementedscripts/mutation-score.mjs, docs/.vitepress/theme/SpecInsights.vuegeneratedAt + break threshold recorded and shown beside the chart
S18-SR-04implementedscripts/mutation-score.mjs, docs/.vitepress/specs.data.tsabsent artifact degrades to not-measured; never in npm run verify
S18-SR-05implementedscripts/mutation-score.mjsfiles stryker does not mutate are absent, not zeroed
S18-SR-06implemented.github/workflows/mutation.ymlcache restore/save around the Stryker step, keyed on stryker.config.json; `full` dispatch input forces a cold run
S18-SR-07implemented.github/workflows/mutation.ymlseparate write-scoped publish job opens/updates the standing chore/refresh-mutation-score PR from the default branch

Documented in ​

Documentation sections tagged spec:S18 (or one of its requirement ids) — 165 of ~525 expected words (31%). The expectation comes from this spec's evaluated complexity of 13.1 (9 documentable requirements — 7 SR, 2 NFR — weighted by kind and by each definition's length).

Changes over time ​

  • c717a9c2026-11-16ci(mutation): reuse incremental results and publish the score
  • c0156392026-07-26feat(docs): add requirement lifecycle stamps and publish the mutation score

Released under the MIT License.