Skip to content

Let a marker on its line acknowledge an equivalent PIT mutant - #31

Merged
vlsi merged 3 commits into
cribro-dev:mainfrom
vlsi:claude/coverage-ignore-solution-33b4ff
Nov 30, 2026
Merged

vlsi merged 3 commits into
cribro-dev:mainfrom
vlsi:claude/coverage-ignore-solution-33b4ff

Conversation

@vlsi

@vlsi vlsi commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

A mutant that no caller can tell apart from the original, such as the EQUAL_ELSE removal of a condition the caller already checked, was listed as live by pitestDiff on every branch that changed its line, so each author and each agent judged it equivalent again (#17).

A line may now record the verdict, in the form diff-coverage: ignore takes:

if (a || b) { // mutant: equivalent RemoveConditionalMutator_EQUAL_ELSE#2 -- b is checked by the caller

The id is the text the report now prints in brackets after each mutant: the mutator's simple name, with #n where the mutator made more than one mutant on the line, numbered by method, descriptor, class, and instruction index over every status, with a run of digits in a method or class name compared as a number, so lambda$run$9 comes before lambda$run$10. An acknowledged mutant leaves the live list, stays in the counts, and is listed with its reason each time its line changes. A marker is read only on changed lines; one that does not parse, or has an id naming no mutant of the line or a mutant that is no longer live, is listed under Markers to correct: with the line's ids and statuses, so a verdict the code has outgrown comes up when someone changes the line. A marker without ids was rejected: it would also hide a mutant a later change adds to the line.

Report outcomes:

  • survived: removed conditional, in m [RemoveConditionalMutator_EQUAL_ELSE#2]
  • 8 mutants on 6 of 7 changed lines: ...; 1 of the live ones acknowledged as equivalent
  • Live mutants acknowledged as equivalent: with reason: ... under each mutant
  • Markers to correct: with VoidMethodCallMutator: the tests kill this mutant, so it is not equivalent, MathMutator: PIT reports this mutant as TIMED_OUT, MathMutator: no mutant on the line has this id, or the marker does not parse; write it as // mutant: equivalent <id> -- <reason>, then the line has ...; this section quotes the line as written, markers included, while the live and acknowledged lists quote it without its markers
  • the advice after Markers to correct: says to keep an id of a mutator the run did not use, such as RemoveConditionalMutator_EQUAL_ELSE in a run with DEFAULTS, which is listed as no mutant on the line has this id, and to check it in a run with the mutator group it was written for
  • the advice after the live list says to add // mutant: equivalent <id> -- <reason> to the line of an equivalent mutant, where it used to say only to say so in the pull request

A marker counts only where its opener, a // or a / followed by one or more *, opens a comment or lies inside a line comment, and its reason ends where that comment ends. Text in a string, or anywhere inside a block comment, acknowledges nothing, a Javadoc line that wraps right before mutant: equivalent included. A marker later in a line comment counts even where the comment only quotes the form, as in // write it as // mutant: equivalent <id> -- <reason>; that is what lets a marker follow // diff-coverage: ignore -- <reason> on one line. The regions come from SourceFileKey.regions, which extends the scan SourceFileKey already uses for the package declaration: it lexes a Java file after its Unicode escapes are translated, and the code of a Kotlin ${} template as code.

Scope. Where a mutator keeps two or more mutants on a line and their set changes, for instance after a PIT upgrade filters one, #n can come to name another live mutant of the same mutator, and nothing flags it; the acknowledged row still prints the mutant's description beside the reason when the line changes. A fingerprint of the mutant in the id would catch it at the cost of a readable id, and is left out. Two limits that diff-coverage: ignore already has apply to markers too: sources are read as UTF-8, and two files with one package and name share a key.

Fixes #17

🤖 Generated with Claude Code

A mutant that no caller can tell apart from the original survives every
test that could be written, such as the EQUAL_ELSE removal of a
condition the caller already checked. pitestDiff and cribro:pitest-diff
listed it as live on every branch that changed its line, so each author
and each agent judged it equivalent again, and nothing in the code
recorded the verdict.

A line may now carry the verdict, in the form diff-coverage: ignore
takes:

    if (a || b) { // mutant: equivalent RemoveConditionalMutator_EQUAL_ELSE#2 -- b is checked by the caller

The id is the text the report prints in brackets after each mutant: the
mutator's simple name, with #n where the mutator made more than one
mutant on the line. The mutants of one mutator are numbered by method,
descriptor, class, and first instruction index, over every status, so
the number does not depend on the order PIT reports them in and stays
when a test starts killing another mutant of the line. mutants.tsv
gains the method descriptor, the mutator, and the instruction index for
this. A marker without ids was rejected: it would also hide a mutant
that a later change adds to the line.

An acknowledged mutant leaves the list of live mutants, stays in the
counts, and is listed with its reason each time its line changes, so
the reviewer of that change sees the verdict next to the new code. A
marker is read only on a changed line. A marker that does not parse, or
that has an id naming no mutant of the line or a mutant that is no
longer live, is listed with every id the line has and its status, so a
verdict the code has outgrown comes up when the line changes. A marker
inside a string literal does not count; the literals are found in the
whole file by the scan SourceFileKey reads the package declaration
with, so text blocks, raw strings, and Kotlin templates that span lines
are literals on each of their lines.

User-visible:
Each live mutant ends with its id: `survived: removed conditional, in m [RemoveConditionalMutator_EQUAL_ELSE#2]`.
Where markers acknowledge mutants, the summary ends with `; 1 of the live ones acknowledged as equivalent`, and the mutants are listed under `Live mutants acknowledged as equivalent:` with `reason: ...`.
A marker to correct is listed under `Markers to correct:` with a line such as `VoidMethodCallMutator: the tests kill this mutant, so it is not equivalent`, then `the line has VoidMethodCallMutator (killed)`.
The console limits on files and lines hold across the live list and both new sections; survivors.txt holds all of them.
The guide's step for an equivalent mutant says to add the marker and say so in the pull request.

Fixes cribro-dev#17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vlsi added 2 commits November 30, 2026 20:38
The mutant: equivalent marker was found by text on each line, skipping
only string literals. A comment that quoted the syntax in its prose,
such as /* write it as // mutant: equivalent X -- why */, acknowledged
X, and so did a * anywhere on a line. The reason ran to the end of the
line or to the first */, so a nested Kotlin comment cut it short, and a
Java */ or line break written as a Unicode escape did not end it. A
quote written as \u0022 opened a string the scan did not see, and a
comment in the code of a Kotlin ${} template was read as string text.

SourceFileKey.tokens now gives each character of a file its token
(code, line comment, or the start, body, or close of a block comment)
by the rules javac and kotlinc lex with: a Java text after its Unicode
escapes are translated, and the code of a Kotlin template as code. A
marker starts at a // or a / followed by one or more *, where that
opener starts a comment or lies in a line comment, or at the run of *
that leads a line inside a block comment; its reason ends where that
comment ends. A run of * is tried once, so a long run takes linear
time.

User-visible:
A mutant: equivalent text in code, in the prose of a comment, or after a * that does not lead a block-comment line acknowledges nothing and is not listed under `Markers to correct:`.
A marker after /** or /*** counts.
`Markers to correct:` quotes the line as written, markers included; the live and acknowledged lists still quote it without its markers.
The status in `the line has ...` is printed as PIT names it: `(KILLED)`, `(TIMED_OUT)`.
For an id that names no mutant of the line, the report says that an id of a mutator the run did not use is kept and checked in a run with the mutator group it was written for.
The guides say to put the marker last on its line, since its reason runs to the end of its comment.
The description of the cribro-core artifact says its classes are not an API and change with each plugin release.

See cribro-dev#17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block-comment line that started with * mutant: equivalent was read as
a marker, so a Javadoc sentence that wrapped right before the quoted
form landed under `Markers to correct:` with "no mutant on the line has
this id", while the same text mid-line in that comment was ignored. A
line inside a block comment holds no code unless the comment closes on
it, so the opener at its leading * acknowledged nothing a reader would
mark there. A marker now starts only at a // or a / followed by one or
more * that opens a comment or lies in a line comment. A marker later in
a line comment still counts, so one can follow
// diff-coverage: ignore -- <reason>; the guides now say so instead of
saying that quoted prose never counts.

The #n of a mutant ordered method and class names as strings, so
lambda$run$10 sorted before lambda$run$9, and a lambda added above two
others moved an id to the other mutant. A run of digits in those names
now compares as a number.

SourceFileKey.Token is renamed Region, and tokens() regions(): the
values classify the comment a character lies in, and the file already
uses "token" in the JLS sense, where a comment is none.

User-visible:
A line inside a block comment that starts with * mutant: equivalent is no marker and is no longer listed under `Markers to correct:`.
A marker that does not parse is listed with `the marker does not parse; write it as // mutant: equivalent <id> -- <reason>`, where it said that the marker names no mutant or gives no reason.
Mutants of one mutator on a line in methods lambda$m$9 and lambda$m$10, or in classes A$9 and A$10, get cribro-dev#1 and cribro-dev#2 in that order.
The guides limit "the code or the tests have likely changed since the verdict" to an id that names a mutant that is not live, or no mutant.

Refs cribro-dev#17

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vlsi
vlsi force-pushed the claude/coverage-ignore-solution-33b4ff branch from 73cb3e2 to 9cc5265 Compare November 30, 2026 17:38
@vlsi vlsi added the enhancement New feature or request label Nov 30, 2026
@vlsi
vlsi merged commit c66f36c into cribro-dev:main Nov 30, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to record an equivalent mutant, so pitestDiff lists it again on every branch that changes its line

1 participant