Skip to content

ci: add advisory diff-mutation check on PRs - #333

Open
potto007 wants to merge 5 commits into
mainfrom
ci/246-pr-diff-mutants
Open

potto007 wants to merge 5 commits into
mainfrom
ci/246-pr-diff-mutants

Conversation

@potto007

@potto007 potto007 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

This adds an advisory mutation check on pull requests, which runs cargo-mutants over the lines a PR changes in the workflow-layer files and grades each mutant with the pr_chaos tests, the same setup the nightly run uses. It lives in its own workflow, so it never feeds the required check job in ci.yml, and a surviving mutant leaves it green.

 .github/
 ├── workflows/
 │   ├── ci.yml                 # unchanged, required "check" job
 │   ├── chaos-nightly.yml      # unchanged
+│   └── mutants-diff.yml       # advisory, pull_request only, contents: read
 └── scripts/
+    ├── mutants-scope.py       # changed files that match examine_globs
     └── mutants-summary.sh     # new "diff" mode, nightly output unchanged
on pull_request touching src/**.rs, .cargo/mutants.toml, or the check's own files
  diff the merge commit against HEAD^1, with a/ and b/ prefixes pinned
  if no changed file matches examine_globs in .cargo/mutants.toml
    write "no mutants ran" to the summary and stop, before the toolchain installs
  cargo mutants --in-place --in-diff pr.diff
    exit 2 (missed) or 3 (timeout) passes, any other failure fails the job
  write per-file caught, missed, timeout and unviable counts, then the missed and timed-out mutants

The tool and action pins match chaos-nightly.yml: cargo-mutants 27.1.0, cargo-nextest 0.9.151, and the same SHAs for rust-toolchain, rust-cache and install-action. The scope and the grading come from .cargo/mutants.toml and [profile.mutants], so the PR check and the nightly run cannot drift apart on which files they mutate. I pinned the diff prefixes because cargo-mutants found no mutants in a diff written with git's mnemonic i/ and w/ prefixes, which a diff.mnemonicPrefix setting turns on. docs/src/contributing.md gets a "Diff mutation check" section next to "Nightly chaos".

Refs #246

Evidence

  • Before: a PR that changes src/wf.rs gets no mutation feedback until the nightly run, which grades all 2,183 mutants across 8 shards and took 4 hours on its slowest one.
    After: throwaway draft test: exercise the diff mutation check (throwaway, do not merge) #332 rewrote relays in src/wf.rs with no change in behavior, and mutants-diff graded the 7 mutants in that change in 7 minutes on a cold cache, with 6 caught and 1 missed: src/wf.rs:298:9: delete match arm "blocker" in relays. The job finished green with the missed mutant listed in its summary, https://github.com/OttoOps/t3-codemode/actions/runs/45641439082, so a survivor does not block the merge. I closed test: exercise the diff mutation check (throwaway, do not merge) #332 unmerged.
  • The required check job does not wait on mutants-diff, and ci.yml is unchanged, so Tier 1 time on a PR with no workflow-layer change stays where it was. On test: exercise the diff mutation check (throwaway, do not merge) #332 the ci run finished at 15:13 UTC, and mutants-diff kept grading until 15:14. On this PR, which touches only .github/ and docs/, mutants-diff starts because its own files changed and stops at the scope step in 6 seconds, before the toolchain installs, in https://github.com/OttoOps/t3-codemode/actions/runs/45641836930.
  • Local checks: actionlint on both chaos workflows and shellcheck on .github/scripts/*.sh are clean, cargo fmt --check and cargo clippy --all-targets -- -D warnings are clean, and cargo test --locked passes. mutants-summary.sh in diff mode prints the zero table and "The changed lines hold no mutants." for an empty outcomes folder, and a missing folder still exits 1 in both modes.
  • cargo mutants --in-diff with the pinned prefixes lists 7 mutants for the relays rewrite. With git's i/ and w/ prefixes it lists none.
  • Reviewed with sol-loop: 2 rounds with gpt-6.2-sol on high. Sol verdict: approved

Merge Danger

Door: two-way

Deleting mutants-diff.yml and the scope script undoes it, and the summary script's nightly mode is unchanged.

Blast Radius: CI-minutes

A PR that rewrites a lot of src/board.rs can produce hundreds of mutants at about 5 seconds each, on one runner with a 120-minute timeout. Expect many survivors there, because the chaos tests do not reach the board's rendering code. A new push to the PR cancels the run in progress.

Compatibility

None. The execute globals, the wf protocol, the board API, the config format and the service install are unchanged.

Publication checks

This PR adds no secrets or tokens, no personal data or private repository names, and no machine-specific absolute paths. The workflow needs no secrets and runs with contents: read, so it behaves the same on pull requests from forks.

Contribution provenance

Paul Otto authored the change with Claude Code and signed off each commit himself. It adds no third-party sources beyond the pinned GitHub Actions and cargo tools the nightly workflow already uses.

Signed-off-by: Paul Otto <219596+potto007@users.noreply.github.com>
Github-Issue: #246
Signed-off-by: Paul Otto <219596+potto007@users.noreply.github.com>
Github-Issue: #246
Signed-off-by: Paul Otto <219596+potto007@users.noreply.github.com>
Github-Issue: #246
Signed-off-by: Paul Otto <219596+potto007@users.noreply.github.com>
Github-Issue: #246
Signed-off-by: Paul Otto <219596+potto007@users.noreply.github.com>
Github-Issue: #246
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Pull requests now receive advisory mutation checks when changes fall within the configured scope. Results appear in the job summary, and a downloadable report is available for 14 days. Surviving mutants do not fail the check; failures are reported when the mutation-testing run encounters an error.
  • Documentation
    • The contributing guide explains when these checks run, how to interpret results, and their advisory behavior.

The pull request adds an advisory diff mutation check for selected Rust changes. The workflow filters changed paths, runs cargo mutants on the PR diff, and publishes results in the job summary and an artifact.

Changes: Diff mutation PR check

Layer / File(s) Summary
Workflow trigger and scope selection
.github/workflows/mutants-diff.yml, .github/scripts/mutants-scope.py
The workflow filters relevant pull-request paths and checks changed files against examine_globs. It records when no scoped files changed and skips mutation grading in that case.
Conditional setup and mutation grading
.github/workflows/mutants-diff.yml
When scoped files changed, the workflow installs the Rust and mutation-testing tools, runs diff mutation grading, and accepts exit codes 0, 2, and 3. Other exit codes fail the job.
Mode-specific summary and published results
.github/scripts/mutants-summary.sh, .github/workflows/mutants-diff.yml, docs/src/contributing.md
The summary script adds diff-mode headings and result reporting. The workflow appends the summary and uploads a 14-day artifact. The contributing guide documents the workflow and its advisory behavior.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant Actions as GitHub Actions
  participant Scope as mutants-scope.py
  participant Mutants as cargo mutants
  participant Summary as mutants-summary.sh
  participant JobSummary as GitHub job summary
  Actions->>Scope: Send changed paths and scope configuration
  Scope-->>Actions: Return selected paths
  Actions->>Mutants: Run diff mutation grading for selected changes
  Mutants-->>Actions: Return grading status and result files
  Actions->>Summary: Generate summary in diff mode
  Summary-->>Actions: Return summary text
  Actions->>JobSummary: Append summary
  Actions->>Actions: Upload summary directory as artifact
Loading

Possibly related issues

  • OttoOps/t3-codemode#187 — This PR adds the advisory cargo mutants --in-diff check and reports missed mutants in the job summary. The issue’s module-scope audits and core-module test gaps are not addressed.
  • OttoOps/t3-codemode#246 — This PR implements an advisory diff-mutation job using the mutation profile. The issue’s nightly chaos sweep, coverage diagnostics, and fuzz work are not addressed.

Possibly related PRs

  • OttoOps/t3-codemode#325 — This PR uses the mutation profile and .cargo/mutants.toml scope configuration added by PR #325.
Merge Risk: Minimal · up to 53ed8

This adds an advisory mutation check on pull requests that touch scoped Rust files, plus documentation. It does not block merging, and the only expected cost is extra CI time on large changes. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 43b73

The new check runs separately from required CI. It requests read-only repository access, does not persist checkout credentials, and does not add a deployment step. The review identified no material expansion of privileged access or weakening of the merge gate.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The added execution and reporting surface is the PR job, its cache integration, and its run-scoped output. Cancellation limits overlapping runs for the same PR, but separate eligible PRs can each consume runner capacity up to the job timeout.

Trust Boundaries and Controls

  • observed — The job runs scripts and Cargo grading from the checked-out PR merge tree, so PR content is inside the runner trust boundary. The ordinary pull_request trigger, contents: read permission, and disabled checkout credential persistence limit the authority declared by the workflow.

Resilience and Maintainability Implications

  • observed — A scope miss skips grading and upload. Grading exit codes for survivors and timeouts are advisory; other grading failures do not take the normal publication path. A newer run cancels the older run for the same PR, and the required CI check does not consume these results.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "ci: add advisory diff-mutation check on PRs" matches the main change: a new advisory pull-request workflow (mutants-diff.yml) that runs cargo-mutants over changed lines. It is short, specif…
Description check Passed The description states the purpose of the change: an advisory cargo-mutants check on pull requests, scoped by .cargo/mutants.toml and graded with pr_chaos tests. It names the changed files (mutants-di…
Linked Issues check Passed The only linked issue is #332. It is closed and marked throwaway, do-not-merge, historical context only. Per the assessment rules, it supplies background only. No active directly linked target remains…
Out of Scope Changes check Passed The change set matches the stated PR purpose: an advisory pull-request mutation check. The reviewed summary lists these files: .github/workflows/mutants-diff.yml (new workflow, pull_request only, cont…
Full details: Title check

Explanation

The title "ci: add advisory diff-mutation check on PRs" matches the main change: a new advisory pull-request workflow (mutants-diff.yml) that runs cargo-mutants over changed lines. It is short, specific, and follows a conventional-commit style.

Full details: Description check

Explanation

The description states the purpose of the change: an advisory cargo-mutants check on pull requests, scoped by .cargo/mutants.toml and graded with pr_chaos tests. It names the changed files (mutants-diff.yml, mutants-scope.py, mutants-summary.sh, contributing.md) and gives verification evidence. It is related to the changeset in substance.

Full details: Linked Issues check

Explanation

The only linked issue is #332. It is closed and marked throwaway, do-not-merge, historical context only. Per the assessment rules, it supplies background only. No active directly linked target remains, so no linked-issue coding requirements apply. The PR description refers to #246 only as a parent reference. The PR objectives state that no active directly linked issue targets remain.

Full details: Out of Scope Changes check

Explanation

The change set matches the stated PR purpose: an advisory pull-request mutation check. The reviewed summary lists these files: .github/workflows/mutants-diff.yml (new workflow, pull_request only, contents: read); .github/scripts/mutants-scope.py (new scope filter using examine_globs from .cargo/mutants.toml); .github/scripts/mutants-summary.sh (new diff mode, nightly mode unchanged); and docs/src/contributing.md (new 'Diff mutation check' section). Each file supports the workflow or documents it. The tool and action pins match chaos-nightly.yml, so no unrelated dependency change appears. The PR does not change execute globals, the wf protocol, the board API, the config format, or the service install. This verdict rests on the whole-PR summary. I did not read the hunks directly, so a small unrelated edit inside these files cannot be excluded by this review alone.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 43b738c and 53ed861.

Files selected for processing: 1

  • docs/src/contributing.md
Files skipped from review as they are similar to previous changes: 1

  • docs/src/contributing.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 25, 2026

This branch has not been deployed

No deployments
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