Skip to content

Add a weekly report of the wrong edits gstack's tests fail to catch (GST-3386) - #4652

Merged
capy-ai[bot] merged 7 commits into
mainfrom
mutation-report
Nov 22, 2026
Merged

capy-ai[bot] merged 7 commits into
mainfrom
mutation-report

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

A new weekly Mutation report plants small wrong edits in the five lib/ files with the most landings in the last 30 days and lists the edits no test caught.
Why: agents write most of our code and tests, and a green suite only means something if the tests reject plausible wrong code; this trial measures where they don't.
Nothing to do: it runs Saturdays on main, is never a required check, and never blocks a merge.

What changed

The testing guide's Mutation report section now describes 30-day landings, file replacement, the baseline-and-message control and the shared 55-minute budget

The testing guide's Mutation report section says what the weekly job does and how to run it locally.

Before/after as text: The testing guide's Mutation report section now describes 30-day landings, file replacement, the baseline-and-message control and the shared 55-minute budget
--- Before · docs/TESTING_INTERNALS.md § Mutation report at 69ad103 · source text (section not present before)
+++ After · docs/TESTING_INTERNALS.md § Mutation report on this branch · source text
+## Mutation report
+A weekly, report-only trial of mutation testing. It checks whether gstack's tests reject plausible wrong code in the files agents change most. `.github/workflows/mutation-report.yml` runs every Saturday at 06:00 UTC, or on demand through workflow_dispatch, on `ubicloud-standard-16`. It is not a required check, never runs on pull requests, and never blocks a merge.
+
+`scripts/mutation-report.ts` does the work:
+
+1. It picks the five `lib/**/*.ts` files (not tests) with the most landings on main in the last 30 days (`git log --first-parent`), from the job's full-history checkout. A file that no test imports is listed as `no tests`, and a file Stryker finds nothing to mutate in (a data-only file) as `no mutants`; in both cases the next file takes its place.
+2. For each file it selects the test files that import it directly. If none do, it falls back to the transitive importers from `lib/pregate/import-graph.ts`. At most 20 run, and the report shows "20 of N" when it caps them.
+3. **Positive control.** The selected tests must first pass on the unedited file; if they don't, the file is reported as `failed`. Then the script prepends `throw new Error('mutation-report positive control')` to the file and runs the same tests, which must fail with that message. If they don't, the tests reach the file only through a spawned process, and every mutant would be a false survivor. The file is then reported as `control survived` and not mutated.
+4. It runs StrykerJS with the community Bun runner, using per-test coverage and `ignoreStatic`, within a 55-minute budget per file that also covers the two test runs before it (at most 10 minutes each). Stryker runs under `timeout`, which kills its whole process group at the budget, and the script then restores the tree with `git checkout -- .`. A file that runs out of budget is reported as `unfinished`. The report is rewritten after every file, so a job that hits its own limit still leaves the finished files.
+5. It writes a table (killed, survived, no coverage, timeout, mutation score) and up to 15 survivors per file, each with its line, mutator and replacement. The table goes to the step summary, and the Markdown, JSON and per-file Stryker reports go to the `mutation-report` artifact.
+
+Stryker (`@stryker-mutator/core`) and `@hughescr/stryker-bun-runner` are both Apache-2.0. They are installed at the exact versions in `STRYKER_PACKAGES` into the runner's temp directory with `--ignore-scripts`, so `package.json` and `bun.lock` don't change. Their own dependencies aren't locked.
+
+Stryker has to edit files in place, because its sandbox copy fails on this repo's symlinked directories (`EISDIR` on `connect-chrome`). The script therefore refuses a dirty tree, requires `--throwaway-checkout`, and must never run in a checkout you work in. If a run is killed, it can leave a mutated file behind: run `git checkout -- .` and remove `.stryker-tmp`. To run it locally, use a scratch worktree:
+
+```bash
+git worktree add /tmp/mut origin/main && cd /tmp/mut && bun install
+npm install --prefix /tmp/stryker --no-save --ignore-scripts @stryker-mutator/[email protected] @hughescr/[email protected]
+bun --no-env-file --config=/dev/null scripts/mutation-report.ts --throwaway-checkout --files 1 \
+  --stryker-dir /tmp/stryker --out-dir /tmp/mutation-out
+```

We had no way to tell whether a passing suite would notice a plausible wrong edit in the code agents touch most. Now a weekly job answers that:

  • It ranks lib/ files by first-parent landings on main over the last 30 days. A file no test imports is listed as "no tests", and a data-only file Stryker finds nothing to mutate in is listed as "no mutants"; in both cases the next file takes its place, so five files get scored.
  • Before mutating a file, the selected tests must pass on the unedited file, then fail with the planted message once a throw is added at the top. A file whose tests don't fail that way is reported as "control survived" instead of filling the report with false survivors.
  • One 55-minute budget per file covers both control runs (at most 10 minutes each) and Stryker, which runs under timeout --kill-after=60 so its whole process group stops at the budget. The tree is restored with git after every file, and the report is rewritten after every file, so a job that hits its own limit still leaves the finished files. The table shows "20 of N" when a file's tests are capped.
  • The workflow runs on a schedule or by hand only, with a read-only token that is not kept, no secrets and pinned actions. Stryker 10.1.1 and its Bun runner 1.6.0 install at exact versions outside the checkout, so package.json and bun.lock don't change.
Why

"A green suite only means something if the tests reject plausible wrong code." This report-only trial shows where gstack's tests miss wrong edits in the files agents change most, and its results decide whether mutation testing earns a permanent place.

Blast radius

Nothing that runs today changes, because the workflow has no pull request trigger and is not a required check, and the only edit to existing code is one entry in the list of workflow files that need only the free tests (scripts/test-pr-profile.ts:282, read), which the full free test run on this branch passed (run 44981232966 at this commit, 38,792 tests).

Test Coverage

The new helpers (churn ranking, the planted throw, scoring, Markdown escaping, the exact version pins), the refusal without --throwaway-checkout and the workflow's trigger and permission shape have unit tests. The other refusals (dirty tree, output folder inside the checkout, bad numbers, unknown --only file), test selection and the control and Stryker outcome branches have no unit test; the refusals and the control were checked by hand below, and the Stryker branches by the earlier end-to-end runs.

Tests: 1860 → 1860 (+0 new)
Coverage: 44% value-weighted (44% including 0 weakly covered paths)
Test value: 0 tests written, 0 rejected by the authoring gate, 0 existing tests extended, 0 paths weakly covered (weak = ★, gate-failing or unrated).
Tests ran: focused 46

Pre-Landing Review

No blocking issues. A final full review of this commit ran once with no fix round, because the change already had two full review rounds: the specialist, red-team and workflow-gate readers, a native adversarial reader and a second-model review (GPT-6.1 Sol). The second-model review marked two findings as blocking: the positive control can be satisfied by a test that echoes a spawned child's stderr (scripts/mutation-report.ts:132), and the planted throw above a #! line makes shebang files read as "control survived" (scripts/mutation-report.ts:56). Both are below the blocking floor (a test that would fail, a production break, or lost data or secrets), because the weekly report never runs on pull requests and fails no test; they ship as ruled notes and get fixed in the next mutation report change. The other readers raised the same two issues as non-blocking, and every remaining finding repeats one of the notes below.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL scripts/mutation-report.ts:161 Ignored static mutants may count, so a data-only file could be scored instead of no mutants (refuted for lib/result-codes-release.ts by the earlier end-to-end run, which reported no mutants)
  • INFORMATIONAL scripts/mutation-report.ts:143 14 workers share one GSTACK_HOME; cross-talk failures and Timeout-as-detected could inflate scores
  • INFORMATIONAL scripts/mutation-report.ts:128 Planted throw above a #! line makes a syntax error, so shebang files are misreported as control survived
  • INFORMATIONAL scripts/mutation-report.ts:132 A test that echoes a spawned child's stderr could satisfy the control message check
  • INFORMATIONAL scripts/mutation-report.ts:152 OOM exit 137 reported as budget exhaustion
  • INFORMATIONAL .github/workflows/mutation-report.yml:36 Replacement files can push total time to the 330-minute job limit; summary appended only at the end
  • INFORMATIONAL .github/workflows/mutation-report.yml:4 Workflow header says 90-day commits; changelog says every edit no test failed on but report lists Survived only, up to 15
  • INFORMATIONAL .github/workflows/mutation-report.yml:51 Stryker transitive dependencies are not locked (already documented)
  • INFORMATIONAL scripts/mutation-report.ts:154 When Stryker crashes, the row's detail is its last output line, which for a Node crash is the Node version line rather than the error
  • INFORMATIONAL scripts/mutation-report.ts:208 Files reported as "no mutants" still spend both test runs and a Stryker start, with no cap on how many the job tries
Exploratory QA

Status: pass. Five command runs in a throwaway worktree at this commit, within a 5-minute smoke budget:

  • A run on a lib file no test imports (--only lib/model-policy-freshness-parser-worker.ts) listed it as "no tests", wrote mutation-report.md and .json outside the checkout, exited 0 and left the tree clean.
  • A missing --throwaway-checkout, an output folder inside the checkout, --files 0 and an --only file that hasn't landed in the window were each refused with exit 1 and a message naming the problem.

Stryker itself was not run here; the earlier end-to-end runs stand for it (--only lib/sanitize-echo.ts: 89 mutants, 70 caught, 15 survived, 4 not covered, controls passing). The dirty-tree refusal was not rechecked in this run.

Scope Drift

Scope Check: CLEAN
Intent: a weekly, report-only mutation trial over the most-changed lib files (part A of the plan).
Delivered: the workflow, the script and its tests, a docs section, a changelog fragment and the free-tests list entry with its harness pin.

Documentation

Status: blocked, shipped under an exception. One stale workflow comment needs a correction that a read-only audit does not allow.

Scope: docs/, README.md, AGENTS.md, CONTRIBUTING.md and CLAUDE.md against the committed changes from 6484fd5 to cc9b831 (7 files). Nothing staged, unstaged or untracked.

Documentation health:

  • docs/TESTING_INTERNALS.md: current. The Mutation report section matches the script and the workflow on every checked claim, and the workflow's #mutation-report anchor resolves.
  • changelog.d/mutation-report.md: current.
  • .github/workflows/mutation-report.yml header comment: stale. It says files are picked by commits in the last 90 days, but the script uses landings in the last 30 days.

The exception, accepted by the maintainers on 2026-11-22, is recorded word for word in the Agent notes below.

Tests
  • Full free test run at this commit (run 44981232966): 38,792 tests, green.
  • Focused tests (mutation-report, test-pr-profile, harness-version): 46 pass, 0 fail.
  • Typecheck, module-size and conflict-marker guards: pass.
Agent notes

Refs GST-3386. Part A, report-only trial. workflow_dispatch works only once the file is on main, so the workflow itself has not run yet; the first scheduled run measures real throughput on the top five files. Lane GSTA-749, /ship run ship-4652-r3: R51 read-only final review at cc9b831 (the PR's third full read, after 1470740 and f94a76a), no fix round.

Approvals

Approved: yes (record r-de0c878cef05). The full approval record stays private.
Plan: approved (record r-4819689303c4)
Plan check: approved (record r-4819689303c4)

REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=7 fixed=0 scope=frozen open=2 dispatches=2 est_input_tokens=16727
Gate edits: 2 listed, 1 read, 0 findings — 0 kept, 0 restored, 0 open
Ruled note: scripts/mutation-report.ts:132:adversarial at cc9b831 ruled by GStack Minder (GSTA-36) (relayed from GSTA-749:2026-11-22T03:53Z) at 2026-11-22T03:53:50.764Z: Below the floor: the weekly mutation report never runs on PRs and fails no test; fix in the next mutation PR (approval a-d31b1938597f)
Ruled note: scripts/mutation-report.ts:56:adversarial at cc9b831 ruled by GStack Minder (GSTA-36) (relayed from GSTA-749:2026-11-22T03:53Z) at 2026-11-22T03:53:50.862Z: Below the floor: the weekly mutation report never runs on PRs and fails no test; fix in the next mutation PR (approval a-42952a43e8b8)
Documentation exception: accepted by Captain GStack Minder (GSTA-36) 2026-11-22 via GSTA-36 relayed by lane GSTA-749, 2026-11-22: Accept: the workflow header's stale 90-day comment ships as a known note; fix it in the next mutation PR.

{
  "schema_version": 1,
  "pr": 4652,
  "head": "cc9b831d5279afd87a8848caf254125a101f44a9",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "focused": {
      "pass": 46,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 44981232966,
      "attempt": 1,
      "tree": "f0765e2de1d65db133ed28773c58e51fa6e343f9"
    }
  ],
  "calls": 18,
  "session_kind": "unattended",
  "run": "ship-4652-r3",
  "head_tree": "f0765e2de1d65db133ed28773c58e51fa6e343f9",
  "product_patch_id": "17aa55f9615a5b2f8bdce55c54821436e3ec476c",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 284,
    "rules": "630fd3101899e28e",
    "base": "6484fd58aea61aa9ea84f269fa9ab68d8e913ed3",
    "registry": "6484fd58aea61aa9ea84f269fa9ab68d8e913ed3",
    "gate_scan": {
      "tagged": 1,
      "head": "cc9b831d5279afd87a8848caf254125a101f44a9"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=284"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @f0765e2de1d6 (8 checks, current for cc9b831d5279)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44981232966/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=f0765e2de1d6 tests=38792 skipped=67 runs=44981232966/1 profiles=ci-reuse/free-tests heads=cc9b831d5279 verified=2026-11-22T04:01:06.088Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "blocked",
    "scope": "docs/, README.md, AGENTS.md, CONTRIBUTING.md, CLAUDE.md (committed range 6484fd58..cc9b831d)",
    "exception": {
      "accepted_by": "Captain GStack Minder (GSTA-36)",
      "date": "2026-11-22",
      "via": "GSTA-36 relayed by lane GSTA-749, 2026-11-22",
      "reason": "Accept: the workflow header's stale 90-day comment ships as a known note; fix it in the next mutation PR."
    }
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 2,
    "deferred": 0,
    "noted": 7,
    "fixed": 0,
    "scope": "frozen",
    "rounds": 1,
    "est_input_tokens": 16727,
    "dispatches": {
      "specialist": 1,
      "red-team": 1
    }
  },
  "ruled_notes": [
    {
      "finding": "scripts/mutation-report.ts:132:adversarial",
      "head": "cc9b831d5279afd87a8848caf254125a101f44a9",
      "by": "GStack Minder (GSTA-36)",
      "reason": "Below the floor: the weekly mutation report never runs on PRs and fails no test; fix in the next mutation PR",
      "at": "2026-11-22T03:53:50.764Z",
      "approval": "a-d31b1938597f",
      "relayed": "GSTA-749:2026-11-22T03:53Z"
    },
    {
      "finding": "scripts/mutation-report.ts:56:adversarial",
      "head": "cc9b831d5279afd87a8848caf254125a101f44a9",
      "by": "GStack Minder (GSTA-36)",
      "reason": "Below the floor: the weekly mutation report never runs on PRs and fails no test; fix in the next mutation PR",
      "at": "2026-11-22T03:53:50.862Z",
      "approval": "a-42952a43e8b8",
      "relayed": "GSTA-749:2026-11-22T03:53Z"
    }
  ],
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "gate"
    ],
    "rules": "b3f6f8b4843c0c30",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "17aa55f9615a5b2f8bdce55c54821436e3ec476c",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

…GST-3386)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 6 commits November 22, 2026 01:21
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	scripts/harness-pins/scripts/test-pr-profile.ts.json
…s, and checks tests pass before the control

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…and Stryker

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

# Conflicts:
#	scripts/harness-pins/scripts/test-pr-profile.ts.json
@capy-ai
capy-ai Bot merged commit 6963fa8 into main Nov 22, 2026
55 checks passed
capy-ai Bot added a commit that referenced this pull request Nov 22, 2026
…ed harness pin, and warns when reviewers ran unlogged (GST-3463) (#4669)

A pull request no longer needs a fresh /ship when merging main only
updates a harness pin file it shares with another PR, and /ship's review
summary now warns when reviewers produced output that the run never
logged.

Why: #4652 paid for a full new review after such a merge, and a
harness-evals run lost its granted follow-up review because nothing was
logged.

Nothing to do.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1/red-team#1 reader=red-team
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant