Repository navigation
feat(ci): surviving mutants of changed lines as a sticky PR comment, with reviewer-style operators - #1338
Conversation
…mutation-ok waivers, MUTATION_GATE switch mutate_changed.py lists survivors and waived mutants in --json and writes a compact --comment-json. `# mutation-ok: <reason>` on the mutated line, or alone on the line above, waives a survivor; an empty reason waives nothing. mutation-diff keeps its read-only token and uploads the result; cli-interface-comment.yml also follows ci and posts it through the same validated workflow_run path. The repository variable MUTATION_GATE=true fails the job on an unwaived survivor; it ships unset, with no date to turn it on. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
✅ OpenCodeReview: Found nothing that must be fixed in this commit. CI at Review limit reached. This PR has had 6 reviews, so it will only be reviewed again when you ask. Other findings not posted (1)1 not shown by a run Review details
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
This PR enhances the “mutation of changed lines” CI signal by expanding mutation operators, adding waiver support, and publishing survivors as a single sticky PR comment via a safe workflow_run poster, with an optional repository-variable gate.
Changes:
- Add multiple new mutation operators plus
# mutation-ok: <reason>waivers and reporting for survivors/waived. - Emit a compact
--comment-jsonartifact and post/update a sticky PR comment (with hostile-text hardening and size caps). - Add an opt-in gate (
vars.MUTATION_GATE=true) and keep local CI behavior warn-only by default.
| File | Description |
|---|---|
| dokimi/tests/test_mutation_comment_workflow.py | New tests for the mutation-survivors sticky PR comment and CI job/artifact contracts. |
| dokimi/tests/test_mutate_changed.py | Expands tests for new mutation operators, waivers, comment-result shape, and gate behavior. |
| dokimi/tests/test_cli_interface_comment_workflow.py | Updates workflow_run poster tests to support posting both CLI and mutation results. |
| dokimi/tests/test_ci_local.py | Verifies local CI treats vars.MUTATION_GATE as unset. |
| dokimi/scripts/mutate_changed.py | Implements new operators, waiver parsing/application, and --comment-json output. |
| dokimi/scripts/ci_local.py | Adds local workflow context value for vars.MUTATION_GATE. |
| dokimi/changelog.d/20261125_180000_vchamarthi_mutation-survivors-comment.md | Changelog entry describing the new PR comment and gate. |
| dokimi/CONTRIBUTING.md | Documents the changed-lines mutation job, sticky comment, waivers, and gate. |
| AGENTS.md | Updates reviewer guidance to reference sticky comment, waivers, and increased mutant cap. |
| .gitignore | Ignores the new mutation-diff-comment.json output. |
| .github/workflows/cli-interface-comment.yml | Extends poster workflow to handle mutation results (validation, escaping, caps) and to post on failed ci runs. |
| .github/workflows/ci.yml | Produces/upload mutation comment artifact, raises max mutants, and adds optional gate flagging. |
Review effort: Lite
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1338 +/- ##
==========================================
- Coverage 96.21% 96.21% -0.01%
==========================================
Files 502 502
Lines 67062 67062
Branches 11645 11645
==========================================
- Hits 64524 64522 -2
Misses 1565 1565
- Partials 973 975 +2 🚀 New features to boost your workflow:
|
- a text in the middle of an `or` chain is a decision, not a fallback: only a trailing string constant is left unmutated - `warnings.append`/`extend` collect results; only log methods are skipped - a `mutation-ok:` with no reason is listed whatever its mutant's status - the waiver reason in the summary is a code span - the poster counts its "more in" notes and keeps room for the waived table Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 1 commit on Threads and comments:
What I checked on the new commit: all 5 new tests fail before the fix and pass after it; the full test suite passes with main merged in (34,450 tests), apart from 1 failure main has too. What each test shows
|
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
An incomplete run (candidate tests failing or not run) was posted as clean because the compact result dropped that information: carry untested counts through it and show them in the comment, and post even with no earlier comment. Give each followed workflow its own poster concurrency group so a pending cli-interface post and ci post no longer cancel each other. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 2 commits on Changes:
Threads and comments:
Not caused by this PR:
What I checked on the new commit: all 4 new tests fail before the fix and pass after it; the full test suite passes with main merged in (34,622 tests), apart from 1 failure main has too. What each test shows
|
A run that hit its time budget leaves mutants as 'not run'; the comment treated that as clean and could replace survivors with 'No surviving mutants'. Count not-run mutants as incomplete and say so in the comment. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
This is ready for another look: I've pushed 1 commit on Changes:
Threads:
What I checked on the new commit: the new test fails before the fix and passes after it; the full test suite passes with main merged in (34,713 tests), apart from 1 failure main has too. What each test shows
|
…t shown as clean The poster's incomplete check reads failing_tests and tests_not_run, but only failing_tests was tested: dropping the tests_not_run clause left every test green. Each count now has its own case. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
…an on every changed line comment_result() dropped mutants_covered, so a run where --max-mutants left most covered mutants untried was posted as "No surviving mutants on the changed lines". It now carries `capped`; the poster validates it, says how many the cap left out and no longer claims every line is clean. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
| `${total} mutants of the lines this PR changes, at ${sha}: ${c.killed} killed, ` + | ||
| `**${r.survivors.length} survived**, ${r.waived.length} waived, ${c.inconclusive} inconclusive, ` + | ||
| `${c.timeout} timed out, ${c.error} errors, ${c['not run']} not run.\n`]; | ||
| if (r.capped) parts.push(`The mutant cap left out ${r.capped} more mutants of covered changed lines.\n`); |
There was a problem hiding this comment.
Impact: the cap warning is silently omitted on the first survivor-free run.
Trigger: no existing mutation comment, all selected mutants killed, zero untested counts, and capped > 0 (for example, 80 killed out of 94 covered mutants).
Evidence: the early return at line 221 checks only survivors, existing comment and incomplete; capped affects none of these, so this new message is never reached. The new cap regression only uses comments=OLD, hiding the first-comment path. Let the early return apply only when r.capped === 0 as well, and test both OLD and [] with producer-consistent counts.
Workaround: inspect the run summary for omitted mutants.
Not shown by a run: A check of this claim did not show the problem.
Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
`# mutation-ok[<operator>]: <reason>` waives that operator's mutants on its line; one with no operator, an unknown one or no reason waives nothing and is listed, so a waiver kept after its line is rewritten no longer hides the new clauses. Main has no mutation-ok uses to convert. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
…he run With no comment yet, no survivor and nothing untested, the poster returned before saying the cap left mutants out, so a capped sample went unreported. Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
|
Pushed to this branch:
|
xaleryb
left a comment
There was a problem hiding this comment.
Approved on 3234057. The job posts surviving mutants of changed lines as one sticky comment and fails on survivors when asked; our commits make a capped or incomplete run never read as clean (also on the first comment) and scope each mutation-ok waiver to the operator it names. Full suite and gates are green on the head merged with main. Windows smoke had not started (the hosted Windows queue was stuck); every other check passed.

Summary
"Removing X leaves every test green" is found by reviewers today, although
mutate_changed.pyalready finds much of it on every PR: the result sits in a warn-only job log. This puts the survivors in one sticky PR comment, adds the breaks reviewers make by hand that the mutator did not, and adds an opt-in gate.Closes #1296
Changes
scripts/mutate_changed.py: new operators for the breaks reviewers write by hand — a comparison moved across its boundary (<=to<), a clause dropped fromand/or, one branch of a conditional expression taken, a filter clause dropped from a comprehension, an element dropped from a literal tuple, list or set of constants, and a statement deleted (a call, an augmented assignment, araise, acontinue, an assignment to an attribute or subscript). Not mutated:value or "text"fallbacks, logging andprintcalls, plain name assignments,breakandreturn.--jsongainssurvivorsandwaived(file, line, mutation, tests run) andwaivers_without_reason. A new--comment-jsonwrites the compact form the comment is built from.# mutation-ok: <reason>at the end of the mutated line, or alone on the line above. An empty reason waives nothing and is listed.ci.ymlmutation-diff: up to 80 mutants (was 40) with no new mutant started after 900 s; keeps its read-only token and uploadsmutation-diff-result, also when the gate fails the step.cli-interface-comment.ymlalso followsciand posts the result through the same validatedworkflow_runpath: size caps, PR and head checks, one sticky comment, too-large handling. Every cell is an escaped code span and rows are capped.MUTATION_GATE=truefails the job on an unwaived survivor. It ships unset.scripts/ci_local.pytreatsvars.MUTATION_GATEas unset, somake ci-localkeeps running the mutation step.AGENTS.md,dokimi/CONTRIBUTING.md, changelog fragment.Risk
not run.ciworkflow name and the artifact name;tests/test_mutation_comment_workflow.pyreads both workflow files and fails on the PR that renames either.staticfails,mutation-diffis skipped and uploads nothing, so an earlier comment stays as it was.workflow_runfires forciis seen only after merge.Testing
return True.make ci-local CI_LOCAL_ARGS='--offline --jobs static,typecheck': 0 failed, 17 passed, 3 skipped.test_help_text_reads_a_real_help, which needspipin the venv, andtest_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart, a float result on arm64).Open questions
None. The gate does not count
inconclusivesurvivors: the script defines one as a survivor whose module has a candidate test file that did not run, so it is not evidence of a gap; they stay listed in the comment.Revert
Revert the commit. A sticky comment already posted on open PRs stays until deleted by hand; unset
MUTATION_GATEif it was set.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)