Repository navigation
feat(ci): per-plugin mutation survival floor (closes #1003) - #1041
Merged
Merged
Conversation
Phase 3 of the plugin-testing-quality plan from #992. The aggregate mutation score in `mutation.yml` was permissive: a few well-tested plugins could mask many badly-tested ones. This PR adds per-plugin floor enforcement (default ≤10% survival rate) and inline PR annotations for surviving mutants. What's added - `scripts/per-plugin-mutation-report.sh`: parses `mutants.out/*.txt`, groups outcomes by source file, computes per-plugin survival rate (`missed / (caught + missed + timeout)`, excluding unviable), prints a table, and exits non-zero when any plugin exceeds MUTATION_FLOOR. Infrastructure files outside `src/native/plugins/` are reported but not enforced. - `GITHUB_ANNOTATIONS=1` on the script emits `::warning file=…,line=…` for every surviving mutant, satisfying the "PR inline comments" acceptance criterion. GitHub Actions surfaces these on the diff. - `scripts/test-per-plugin-mutation-report.sh`: 9-case self-test for the report script — covers empty, all-caught, plugin-over-floor, infrastructure-only-over-floor, MUTATION_FLOOR=0 disable, missing inputs (exit 2), GitHub annotations, utils/mod bucketing, and the exact-10% boundary. Wired into the existing `Plugin Test Quality` CI job. - `.cargo/mutants.toml`: skips `<impl NativePlugin for …>::name` and `<impl NativePlugin for …>::description` mutations. These metadata methods return fixed strings used only for registry lookup; cargo- mutants tries `""` and `"xyzzy"` replacements that survive because no behavior depends on the literal text. Filtering at config level keeps the report honest about real coverage gaps. - `.github/workflows/mutation.yml`: new `Per-plugin mutation floor check` step that runs the report script with `MUTATION_FLOOR=10` and `GITHUB_ANNOTATIONS=1`, gated on the plugin crate being in the package list. - `CONTRIBUTING.md`: documents the floor, the local invocation, and the `#[mutants::skip]` annotation pattern with a required reason. How to handle a missed mutant (when CI fails) 1. Tighten the relevant test to fail under the mutated code, OR 2. Annotate the function with `#[mutants::skip]` and a leading `// reason:` comment explaining why mutation testing isn't useful. Local validation The report script was driven through 9 synthetic scenarios via the self-test (all pass). A partial real-data run on the 3 plugins from \#1038 surfaced 4 surviving mutants on `description()` methods — addressed by the `.cargo/mutants.toml` exclusion above. The CI run on this PR validates the workflow change, but the per-plugin enforcement won't actually fire until a future PR touches `crates/rustledger- plugin/src/native/plugins/*.rs` (the `mutation.yml` trigger paths). Closes #1003 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds per-plugin mutation testing enforcement to prevent strong plugins from masking weak ones, and surfaces surviving mutants directly on PR diffs.
Changes:
- Introduces
scripts/per-plugin-mutation-report.shto compute per-plugin survival rates, gate CI on a 10% floor, and optionally emit GitHub annotations for missed mutants. - Adds a self-test harness for the report script and wires it into CI.
- Documents the new mutation-testing workflow and skip-annotation pattern; adds
cargo-mutantsexclusions for known false positives.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/per-plugin-mutation-report.sh | Implements per-plugin bucketing, reporting, floor enforcement, and GitHub annotations. |
| scripts/test-per-plugin-mutation-report.sh | Adds synthetic fixtures + assertions to validate the report script’s behavior. |
| CONTRIBUTING.md | Documents per-plugin floor, local invocation, and #[mutants::skip] usage. |
| .github/workflows/mutation.yml | Adds per-plugin floor check step to the mutation workflow. |
| .github/workflows/ci.yml | Runs the report script self-test in CI. |
| .cargo/mutants.toml | Configures cargo mutants to exclude specific known-noise mutation families. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
| Metric | Result |
|---|---|
| Check Compatibility | 100% |
| BQL Compatibility | 74% |
| Full AST Match | 99% |
| Total Files | 786 |
What's tested
- Check: Exit codes and error counts match
bean-check - BQL: Query results match
bean-query - Files: ~800 test files downloaded from 10+ beancount repositories
Full results available in workflow artifacts
Five Copilot inline findings, all real and actionable: 1. Truncation bug in floor enforcement. `survival_pct = m * 100 / total` loses precision: 11/101 = 10.89% truncates to 10 and incorrectly passes the `-gt 10` check. Replace with cross-multiplication `m * 100 > floor * total`, which is exact integer math and strictly greater. Pinned by a new self-test case (case 10: 11 missed out of 101 total → must fail). 2. Header doc mismatch. The "Usage" section called the bare invocation "report only" — actually wrong, since `MUTATION_FLOOR` defaults to 10 and enforcement is active unless explicitly set to 0. Also referenced `::error::` annotations when the script emits `::warning::`. Both fixed. 3. Process churn in GitHub annotation emission. Each missed mutant spawned 4 sed subprocesses + an echo for parsing — 4000 fork/exec pairs on a 1000-line missed.txt. Replace with a single bash `[[ $line =~ $regex ]]` capture; in-process, deterministic, faster. 4. Annotation guidance conflict with CONTRIBUTING.md. The script's failure message recommended `#[cfg_attr(test, mutants::skip)]` but CONTRIBUTING.md documents `#[mutants::skip]` (the canonical form, since cargo-mutants reads the AST without compiling). Align the script with the docs. 5. Test-coverage gap on the truncation boundary. Case 9 covered exactly-10% but didn't cover just-over-10%, which is the case the truncation bug would silently pass. New case 10 fills that gap and would have caught the original bug. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3 of the plugin-testing-quality plan (#992). The aggregate mutation score in
mutation.ymlwas permissive — a few well-tested plugins could mask many badly-tested ones. This PR adds per-plugin floor enforcement (default ≤10% survival rate) with inline PR annotations for surviving mutants, plus the#[mutants::skip]annotation pattern documented in CONTRIBUTING.md.Acceptance criteria from #1003:
cargo mutantsonrustledger-pluginfor every PR touching plugin code (already inmutation.ymltrigger paths)scripts/per-plugin-mutation-report.sh, called from a new step inmutation.ymlGITHUB_ANNOTATIONS=1mode emits::warning file=…,line=…for each missed mutant; GitHub Actions surfaces these on the diff#[mutants::skip]+ reason — documented in CONTRIBUTING.mdWhat's new
scripts/per-plugin-mutation-report.shmutants.out/*.txt, groups by source file, computes survival rate per plugin, emits GitHub annotations, exits non-zero on floor violationscripts/test-per-plugin-mutation-report.sh.cargo/mutants.toml<impl NativePlugin for …>::name/descriptionmutations — metadata methods returning fixed strings;""/"xyzzy"mutations survive because no behavior depends on the literal text.github/workflows/mutation.ymlPer-plugin mutation floor checkstep running the report withMUTATION_FLOOR=10andGITHUB_ANNOTATIONS=1.github/workflows/ci.ymlPlugin Test QualityjobCONTRIBUTING.md#[mutants::skip]annotation patternBucketing rules
crates/rustledger-plugin/src/native/plugins/<name>.rs→ bucket<name>(enforced)mod.rs,utils.rsunder that path → bucket_infrastructure(reported, not enforced)_infrastructureSurvival rate =
missed / (caught + missed + timeout).unviablemutants didn't compile and are excluded from the denominator.What this PR does NOT do
crates/rustledger-plugin/src/**, so this PR's own CI run won't fire the per-plugin check (the diff doesn't touch that path). The first plugin-touching PR after this lands will surface real per-plugin scores; if any exceed 10%, that PR's author can either tighten tests or annotate with#[mutants::skip].description()methods — addressed by the.cargo/mutants.tomlexclusion.Test plan
scripts/test-per-plugin-mutation-report.sh— 9 cases passscripts/check-plugin-test-quality.sh— cleanmutants.outfixtures showing pass/fail/exit-code pathsmutants.outfrom a partial scan; failure mode and GitHub annotations both verifiedCloses #1003
🤖 Generated with Claude Code