From cf80b271fd492eb91de6a4999f3321d7c9ad4fe3 Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Tue, 1 Dec 2026 00:21:58 +0300 Subject: [PATCH] Name pitestDiff and both markers in the AGENTS.md note The AGENTS.md note the README suggests named only `test` and left everything else to the guide. An agent that never printed the guide did not learn that `pitestDiff` exists, that `test` does not run it, or that a line can record a verdict with `// diff-coverage: ignore` or `// mutant: equivalent `. The note now names both commands, both markers, where the id comes from (the brackets after each mutant in the pitestDiff report), and asks for the guide before the first measurement in a task. The syntax stays in the note because the coverage report never names its marker; only the guide does. The guides' marker section is cut to what changes what an agent writes: how the id is numbered, the `//` and `/* */` forms, comma- separated ids, the order next to `// diff-coverage: ignore`, and that a `#n` can come to name another mutant when the line changes. Text the report prints at the point of use goes: the counts line, and what to do with each kind of marker under `Markers to correct:`. So does the rule that a marker in a string literal or in Javadoc prose is not read, since neither form the guide prescribes puts one there. Refs #17 Co-Authored-By: Claude Opus 5.5 --- README.md | 25 ++++++++++++---- .../resources/io/github/cribrodev/guide.md | 30 ++++++++----------- .../io/github/cribrodev/maven/guide.md | 30 ++++++++----------- 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index d232263..7e7744f 100644 --- a/README.md +++ b/README.md @@ -94,12 +94,19 @@ script on a one-class build with both Gradle 8.14.3 and its tests on JDK 11. ``` 3. Tell the agents that work on the project. `./gradlew -q cribro` prints the guide for the version the build runs, so - a note in `AGENTS.md`, or in whichever file the project's agents read, needs only to name that command: + a note in `AGENTS.md`, or in whichever file the project's agents read, names the commands and the two markers and + leaves the rest to the guide: ```markdown After changing the Java or Kotlin sources under `src/main` of a module, run `./gradlew :test`, where - `` is that module's Gradle project path, such as `:app`, and act on the diff coverage report it - prints. `./gradlew -q cribro` prints how to read the reports and how to run mutation testing. + `` is that module's Gradle project path, such as `:app`, and act on the diff coverage report it prints. + Once the changed lines are covered, run `./gradlew :pitestDiff -Pcribro.pitestTargetTests=` + and act on the mutants it reports; `test` does not run it. + Mark an uncovered line that is unreachable or not worth a test with `// diff-coverage: ignore -- `, and a + mutant no caller can observe with `// mutant: equivalent -- `, where `` is the text in brackets + after the mutant in the `pitestDiff` report, such as `MathMutator#2`. + Before your first measurement in a task, run `./gradlew -q cribro`: it prints how to read both reports and how to + write the markers. ``` To upgrade, change the version in `settings.gradle(.kts)`. @@ -299,13 +306,21 @@ Tried on Guava, whose tests live in `guava-tests` and test the code of `guava`, ``` 3. Tell the agents that work on the project. `mvn -q cribro:guide` prints the guide for the version the build loads, - so a note in `AGENTS.md`, or in whichever file the project's agents read, needs only to name it: + so a note in `AGENTS.md`, or in whichever file the project's agents read, names the commands and the two markers and + leaves the rest to the guide: ```markdown After changing the Java or Kotlin sources under `src/main` of a module, run `mvn -pl -am test`, where `` is the module whose tests exercise the change, such as `:app`, and act on the diff coverage report it prints. - `mvn -q cribro:guide` prints how to read the reports and how to run mutation testing. + Once the changed lines are covered, run + `mvn -pl -am test-compile cribro:pitest-diff -Dcribro.pitestTargetTests=` and act on the + mutants it reports; `test` does not run it. + Mark an uncovered line that is unreachable or not worth a test with `// diff-coverage: ignore -- `, and a + mutant no caller can observe with `// mutant: equivalent -- `, where `` is the text in brackets + after the mutant in the `cribro:pitest-diff` report, such as `MathMutator#2`. + Before your first measurement in a task, run `mvn -q cribro:guide`: it prints how to read both reports and how to + write the markers. ``` To upgrade, change the version in `.mvn/extensions.xml`. diff --git a/cribro-gradle-plugin/src/main/resources/io/github/cribrodev/guide.md b/cribro-gradle-plugin/src/main/resources/io/github/cribrodev/guide.md index 7056735..7fad88d 100644 --- a/cribro-gradle-plugin/src/main/resources/io/github/cribrodev/guide.md +++ b/cribro-gradle-plugin/src/main/resources/io/github/cribrodev/guide.md @@ -85,24 +85,18 @@ survives marks a changed line whose behavior no test asserts. For each live muta The report ends each mutant with its id in brackets, such as `[RemoveConditionalMutator_EQUAL_ELSE#2]`: the PIT mutator, with a number where the mutator made more than one mutant on the line. The number counts them by method and, within a -method, in bytecode order, so on `a || b` the mutant of `a` comes first. Record an equivalent mutant on its line with -`// mutant: equivalent -- `, where `` is the text in the brackets, or with -`/* ... */` where the line goes on after it; several ids are separated by commas. Put the marker last on its line: the -reason of a `//` marker runs to the end of the line, so a `// diff-coverage: ignore` after it becomes part of the -reason. The marker counts where it starts a comment or sits anywhere later in a line comment, even where that text only -quotes the syntax; one inside a string literal or in the text of a block comment, such as a Javadoc paragraph, does not -count. The mutant leaves the list of live mutants and stays in the counts, the line with the counts ends with how many -live mutants are acknowledged, such as `; 1 of the live ones acknowledged as equivalent`, and the report lists the -mutant under `Live mutants acknowledged as equivalent` with the reason every time the line is changed again; -`survivors.txt` holds the whole list when the console cuts it. The number depends on the other mutants the same mutator -makes on the line, so when the line changes, check that each acknowledged id still names the mutant its reason is about. - -A marker is read only on a changed line. A marker that does not parse, or that has an id naming no mutant of its line or -a mutant that is not live (the tests killed it, or PIT gave it another status, such as `NON_VIABLE`), is listed under -`Markers to correct` with its line as written, followed by every id the line has and its status. Where an id names a -mutant that is not live, or no mutant, the code or the tests have likely changed since the verdict, so judge the line -again. A marker that names a mutator of a stronger group, such as `RemoveConditionalMutator_*`, names nothing in a run -with `DEFAULTS`: keep it, and check it in a run with the group it was written for. +method, in bytecode order, so on `a || b` the mutant of `a` comes first. + +Record an equivalent mutant on its line with `// mutant: equivalent -- `, where +`` is the text in the brackets; separate several ids with commas. A `//` marker takes the rest of the line as its +reason, so where the line goes on after the marker, write it as `/* mutant: equivalent -- */`, and on a +line that also carries `// diff-coverage: ignore -- `, put the mutant marker after it. The mutant then leaves +the list of live mutants, stays in the counts, and is listed with its reason under `Live mutants acknowledged as +equivalent` each time the line changes again. + +The number in an id depends on the other mutants the same mutator makes on the line, so when you change a line that +carries a marker, check that each id still names the mutant its reason is about. A marker the run cannot match is listed +under `Markers to correct:` with every id of its line, each with its status, followed by what to do with it. The report opens with the number of mutants and of the changed lines with bytecode that carry one, such as `8 mutants on 7 of 24 changed lines`. Mutation testing checks nothing on the other changed lines, whatever their coverage. A diff --git a/cribro-maven-plugin/src/main/resources/io/github/cribrodev/maven/guide.md b/cribro-maven-plugin/src/main/resources/io/github/cribrodev/maven/guide.md index c52e98c..f5911b4 100644 --- a/cribro-maven-plugin/src/main/resources/io/github/cribrodev/maven/guide.md +++ b/cribro-maven-plugin/src/main/resources/io/github/cribrodev/maven/guide.md @@ -90,24 +90,18 @@ survives marks a changed line whose behavior no test asserts. For each live muta The report ends each mutant with its id in brackets, such as `[RemoveConditionalMutator_EQUAL_ELSE#2]`: the PIT mutator, with a number where the mutator made more than one mutant on the line. The number counts them by method and, within a -method, in bytecode order, so on `a || b` the mutant of `a` comes first. Record an equivalent mutant on its line with -`// mutant: equivalent -- `, where `` is the text in the brackets, or with -`/* ... */` where the line goes on after it; several ids are separated by commas. Put the marker last on its line: the -reason of a `//` marker runs to the end of the line, so a `// diff-coverage: ignore` after it becomes part of the -reason. The marker counts where it starts a comment or sits anywhere later in a line comment, even where that text only -quotes the syntax; one inside a string literal or in the text of a block comment, such as a Javadoc paragraph, does not -count. The mutant leaves the list of live mutants and stays in the counts, the line with the counts ends with how many -live mutants are acknowledged, such as `; 1 of the live ones acknowledged as equivalent`, and the report lists the -mutant under `Live mutants acknowledged as equivalent` with the reason every time the line is changed again; -`survivors.txt` holds the whole list when the console cuts it. The number depends on the other mutants the same mutator -makes on the line, so when the line changes, check that each acknowledged id still names the mutant its reason is about. - -A marker is read only on a changed line. A marker that does not parse, or that has an id naming no mutant of its line or -a mutant that is not live (the tests killed it, or PIT gave it another status, such as `NON_VIABLE`), is listed under -`Markers to correct` with its line as written, followed by every id the line has and its status. Where an id names a -mutant that is not live, or no mutant, the code or the tests have likely changed since the verdict, so judge the line -again. A marker that names a mutator of a stronger group, such as `RemoveConditionalMutator_*`, names nothing in a run -with `DEFAULTS`: keep it, and check it in a run with the group it was written for. +method, in bytecode order, so on `a || b` the mutant of `a` comes first. + +Record an equivalent mutant on its line with `// mutant: equivalent -- `, where +`` is the text in the brackets; separate several ids with commas. A `//` marker takes the rest of the line as its +reason, so where the line goes on after the marker, write it as `/* mutant: equivalent -- */`, and on a +line that also carries `// diff-coverage: ignore -- `, put the mutant marker after it. The mutant then leaves +the list of live mutants, stays in the counts, and is listed with its reason under `Live mutants acknowledged as +equivalent` each time the line changes again. + +The number in an id depends on the other mutants the same mutator makes on the line, so when you change a line that +carries a marker, check that each id still names the mutant its reason is about. A marker the run cannot match is listed +under `Markers to correct:` with every id of its line, each with its status, followed by what to do with it. The report opens with the number of mutants and of the changed lines with bytecode that carry one, such as `8 mutants on 7 of 24 changed lines`. Mutation testing checks nothing on the other changed lines, whatever their coverage. A