# ADR-0025: Mutators that never let a mutant through are pruned on unchanged code, tests are judged by their assertions and by suite, and a surviving removal may suggest deletion

**Status:** Accepted
**Date:** 2026-09-30

## Context

The ledger knows every mutant's result per unit and per mutator
(ADR-0007). The kill matrix knows which tests cover and which kill
(ADR-0014). Four questions go unanswered.

- **Mutators that never let a mutant through still cost a run.** Runners take
  mutators per run, not per mutant: Pest's `--mutator` and the `mutators`
  block of Infection's config (ADR-0004). A mutator left
  out of a run generates no mutant, so its mutants' results have to come
  from somewhere, or the score's denominator changes without anyone seeing
  it. Offutt, Lee, Rothermel, Untch and Zapf showed that a few operators
  predict the full score (*An experimental determination of sufficient
  mutant operators*, ACM TOSEM, 1996). Here the selection is learned per
  project.
- **A test that kills nothing it covers is named, not explained**
  (ADR-0014). Research names the pattern: a *pseudo-tested* method is one
  whose whole body can be removed with every test still passing
  (Niedermayr, Juergens and Wagner, CSED 2016; Vera-Pérez, Danglot,
  Monperrus and Baudry, *Empirical Software Engineering*, 2019). *Checked
  coverage* asks whether an assertion depends on the code a test runs
  (Schuler and Zeller, STVR, 2013). The tests' assertions are in their
  tokens: PHPUnit's `Assert` methods and Pest's expectations.
- **A suite's share is invisible.** PHPUnit's `<testsuites>` and Pest's
  directories put every test in a suite. An ordinary run knows each killed
  mutant's first killer only (ADR-0014), and which suite that killer is in
  depends on test order (ADR-0013), so what one suite kills alone
  is exact only under a full kill matrix (ADR-0014).
- **A surviving removal is two possible findings.** A removed call that
  survives says only that no test observes the call: a missing test, or code
  nothing needs. *Extreme mutation* removes whole method bodies, and a body
  whose removal survives is pseudo-tested.

## Decision

### Pruning

1. **A pruned mutant's result is its last one, carried by mutant id.**

   - It comes from the unit's newest full result for the same unit content:
     the unit's own file digest and the digest of what decides its mutant set
     must match. Its key may differ, because pruning serves units whose key
     moved through another file (ADR-0007).
   - The plan names the pruned mutators and the units it prunes them in.
     Each shard asks its runner to make none of their mutants there: the
     PHPUnit runner leaves them out itself, and Pest and Infection through a
     list beside their results that `pest:patch` and `infection:patch` teach
     them to read. A runner that is not patched makes them all, and the
     verdict never carries a result over a mutant the run made.
   - A unit whose own content changed runs every mutator.
   - A carried pruned mutant is marked *carried (pruned)* in every report.
   - A unit result that holds carried pruned mutants is never written as a
     proof, as a budget-cut unit's is not (ADR-0007), and teaches
     the cost model no time. It still counts as judged, so the run can be the
     scope's last run.

   This extends the carried results of ADR-0003 to the grain of a
   mutant, and amends ADR-0003 and ADR-0007.

2. **A mutator is pruned when it has let no mutant through lately.**
   - Per project and runner, a mutator with no survivor, flaky, unjudged or
     uncovered mutant among its last `pruning.window` judged mutants (an
     integer, `500` by default), counted from what each run judged itself,
     in the order of the mutants' ids. *Killed by static analysis*
     (ADR-0020), by a timeout or by the memory cap counts as killed. A run
     narrowed by `--security` or `--suite` teaches nothing.
   - Only units whose content is unchanged are pruned.
   - **Never pruned:** new code; changed units; units a sampled run samples
     (ADR-0020), so the estimate stays unbiased; and mutators tagged
     `security` (ADR-0021).

3. **The scheduled full run is the audit.** A run with no base prunes nothing
   (ADR-0005). `pruning.audit`, a duration (`7d` by default), also
   forces every mutator on a unit whose newest full result is older than
   that, so no carried pruned result is older than a week.

4. **Pruning is configured, keyed and shown.**
   - `pruning.enabled` (a boolean, `true` by default) and `pruning.window`
     **affect results**: they decide which mutants run and which are
     carried, so both are in key item 3 (ADR-0007).
     `pruning.audit` judges only.
   - The ledger gains a `survival` section: per runner, each mutator's newest
     judged mutants, up to its window, as a `0` for each killed and a `1` for
     each let through, oldest first, and the id of the last let through. It
     is disposable like `killers`, and losing it disables pruning, never a
     verdict. A run reads its own scope's window of a mutator before the
     default branch's. The ledger's `mutators` list of names is unchanged. This
     amends ADR-0007.
   - The console, the step summary, the PR comment and the JSON report say
     *pruned: 4 mutators on 212 units; 3,180 mutants carried from runs of the
     last 7 days*. The JSON report lists each pruned mutator with its window
     and its last survivor, where it ever had one.
   - The carried mutants' recorded times appear in ADR-0017's savings line
     as *pruning saved*. This amends ADR-0017.

### Weak assertions

5. **A fixed table classifies assertions, read from a test's tokens.**
   - **Existence:**
     - `assertNotNull`, `assertNotEmpty`, `assertTrue(true)` and
       `assertNotSame(null, …)`;
     - Pest's `->not->toBeNull()`, `->not->toBe(null)`, `->toBeTruthy()`,
       `->not->toBeEmpty()`, and `->toHaveKey()` without a value.
   - **Shape:** `assertIsArray`, `assertIsString`, `assertInstanceOf`,
     `assertCount`, and Pest's `->toBeArray()`, `->toBeInstanceOf()` and
     `->toHaveCount()`.
   - **PhpSpec's matchers**, each written `should…` or `shouldNot…` on the
     object a spec describes, on what one of its calls returns, or on a
     collaborator:
     - existence: `->shouldNotBe(null)`, `->shouldNotReturn(null)`,
       `->shouldNotEqual(null)`, `->shouldNotBeLike(null)` and
       `->shouldNotBeNull()`, and `->shouldHaveKey()`, which takes no
       value. PhpSpec has no null matcher of its own.
     - shape: the type matchers (`->shouldHaveType()`,
       `->shouldBeAnInstanceOf()`, `->shouldReturnAnInstanceOf()`,
       `->shouldImplement()`), `->shouldHaveCount()`, and the scalar
       matchers (`->shouldBeString()`, `->shouldBeArray()` and the rest).
     - value: the identity matchers (`->shouldReturn()`, `->shouldBe()`,
       `->shouldEqual()`, `->shouldBeEqualTo()`), `->shouldBeLike()`, the
       approximately matchers, `->shouldBeNull()`,
       `->shouldHaveKeyWithValue()`, `->shouldContain()`,
       `->shouldStartWith()`, `->shouldEndWith()`, `->shouldMatch()`, the
       iterate matchers, `->shouldThrow()` and `->shouldTrigger()`; and the
       object-state matchers, `->shouldBeActive()` of `isActive()` and
       `->shouldHaveItems()` of `hasItems()`, of which a collaborator's
       `->shouldBeCalled()` is one by its name.
     - A matcher the spec's `getMatchers()` names by its key is the
       project's own, and leaves the example not assessed. One an
       extension registers is read by its name: as an object-state matcher
       where it begins with `be` or `have`, unclassified otherwise.
   - **Value:**
     - `assertSame`, `assertEquals`, and Pest's `->toBe()` and `->toEqual()`;
     - a key or a property handed its value, such as `->toHaveKey('total', 100)`;
     - snapshots, and expected exceptions, a test's `->throwsIf()` among
       them.
   - A test is **weak** when every assertion it makes is of existence or
     shape.
   - **Not assessed.** Some tests can't be judged from their own body, so
     they are not assessed:
     - a test that makes an assertion the table does not hold, such as a
       project's own;
     - a test that chains a call after `expect()` that is neither an
       expectation nor a change of subject (`->and()`, `->json()`), such
       as `->sequence()`, `->each(…)` or `->when()`, whose closures assert
       out of the scan's sight;
     - a test that calls, as a function, a helper its own file declares, or
       one a file that defines the runner declares, such as `tests/Pest.php`,
       since the helper may assert what the test does not;
     - a test that calls a method on `$this`, `self`, `static` or `parent`
       that is neither an assertion nor one of the methods of PHPUnit's
       `TestCase` and `Assert` that every supported release declares, such
       as a parent class's or a trait's helper, or a framework's.
   - **What the scan does not see.** A helper reached any other way is not
     seen: a function a file other than the test's own and the runner's
     definitions declares, a helper class's static method such as
     `CartChecks::total()`, or a helper object such as
     `$this->checks->total()`. A test that checks a value only through one
     may be named weak.
   - A table test fails when a supported PHPUnit release declares an
     assertion the table does not classify, or when the installed Pest or
     PhpSpec does.
   - `Core\Assertion\AssertionTable` holds the table, by name in any
     case, as PHP calls methods and functions:
     - every assertion of PHPUnit's `Assert` and `TestCase`, its
       `expect…` methods among them, every Pest expectation, and every
       matcher PhpSpec builds in, read from the keywords its matchers'
       sources answer to;
     - `AssertionTableTest` reads PHPUnit's methods from a file pinned
       per supported release, 12.5.8, 12.5.37, 13.0.0 and 13.3.4, and
       the installed PHPUnit and Pest by reflection. It fails on an
       assertion the table does not hold, on a method held as PHPUnit's
       own that some pinned release lacks, and on one every pinned
       release declares that the table does not hold.
   - The table reads a `Call`: its name, and its arguments as written.
     - `assertTrue(true, 'reached')` is existence by its first argument,
       and `assertNotSame($cart, null)` by a `null` on either side.
     - A negated `toBeNull`, `toBeEmpty`, `toBeTrue` or `toBeFalse` is
       existence, whatever the same expectation is unnegated.
   - `TestAssertions` reads a file's tokens once, and holds each test's
     assertions:
     - a PHPUnit method or a PhpSpec example by its name;
     - a Pest `it` or `test` by its description, with the calls chained
       after it, so a test's `->throws()` counts as a value;
     - a Pest test inside a `describe()`, however deep and however the
       name is qualified, is described by it, so a bare description finds
       only the test outside every one.
       A method with no body has no assertions.
   - `AssertionScan` reads the calls:
     - `assert…` and `expect…` as methods or functions, a qualified name
       such as `\PHPUnit\Framework\assertSame` by its last segment;
     - each call chained after `expect()`, where `->not` negates the
       expectation after it;
     - in a spec, a class that extends `ObjectBehavior` (`Core\Php\Spec`),
       each `should…` method call as a matcher, and a call on `$this` of a
       method the file does not declare as a call to the object the spec
       describes, which asserts nothing (`Core\Assertion\SpecCall`). A
       call on `$this` of a method the spec declares is a helper's, and
       leaves the example not assessed.
       A function or method declared inside a test's body, such as an
       anonymous class's, is not a call.

6. **A weak test is reported only beside the survivors it let through.** It is
   reported when it is a judging test of a survivor in the Return value,
   Literal, Arithmetic, Collection or Unwrap family, which an assertion of
   value would see. The report pairs the test with those survivors and the
   assertion of value that would kill them, on the enclosing function's
   result, and `stub` offers it (ADR-0015).
   - **The assertion is written in the test's own style.** A PHPUnit
     assertion gets `$this->assertSame(<expected>, <subject>)`, and a Pest
     expectation gets `expect(<subject>)->toBe(<expected>)`. The style belongs
     to each assertion, not to the runner, since Pest runs PHPUnit classes
     too. A test that mixes both, such as a PHPUnit class that calls
     `expect()`, gets the style of its first weak assertion.
   - `Core\Assertion\Weakness` decides it over the verdict's survivors
     judged *survived*. A survivor's judging tests are those the kill
     matrix finds covering it that judge it: every test, or the group
     that holds its unit. Only a test the runner names is read, from the
     file its name gives, so a weak test is named by its file and
     description, its data set rows folded in (ADR-0014).
   - `AssertionScan` tags each assertion with the `AssertionStyle` it
     reads it in, and that enum holds both suggestions. The subject is the
     enclosing function's call, such as `fits(…)`, or `…` outside any
     function.
   - `Cli\Flow\Judging` builds the kill matrix before it reads the
     trees, reads the test files it names through the project's
     `Directory`, and hands each survivor its finding with
     `TreeVerdicts::found()`.

7. **The finding lives in the tests report and the hint.** It is a third
   section of the `tests` report and of `mutation-gate tests` (ADR-0014),
   which never fail anything, and the survivor's hint names the weak
   assertion (ADR-0009). It reports only. `Core` holds the table and the
   token read. This amends ADR-0014, and ADR-0009.
   - `Core\Report\WeakAssertions` is the section's one home, and
     `TestsReport` writes it in all three forms. The JSON's `weak` lists
     each test once as `{test, assertions, survivors, assert}`, which
     `resources/tests.schema.json` describes. Markdown and the console
     head it *Asserts only existence or shape* with its count.
   - The hint's second sentence names the first weak test on one plain
     line, each assertion it makes once, and how many more tests are
     weak: *`tests/CartTest.php::it fits` asserts only `->toBeBool()`,
     which no change of value fails.*

### Score per suite

8. **A suite's score is what that suite alone kills.**
   - It is killed over counted, among the mutants that suite's tests cover.
     A mutant the score leaves out counts for no suite, and so does one no
     test of the suite has a known outcome for: a timeout's, a flaky one's,
     one whose coverage moved since its proof, and one no test of the suite
     ran with, as for a mutant a static analyser killed (ADR-0014). A held
     unit's mutants count only for its group's tests.
   - It is **exact under a full kill matrix** (`--kill-matrix=full`, which
     Pest and the native runners of ADR-0023 and ADR-0027 give), and
     otherwise a **lower bound**, shown as *at least*, from first killers;
     a test stopped behind another suite's first kill counts as not killing.
   - Suites are the `<testsuite>` elements of the PHPUnit configuration,
     which Pest runs on too, so there is no key for them. A test is in a
     suite by the file the runner names it in; a run whose tests the runner
     named none of scores no suite and says so.
   - The console and the HTML report, among the run's details, say each
     suite's score in a sentence; the step summary gives a table; each says
     why the scores are lower bounds where they are. They show the suites
     where the configuration declares two or more, since one suite's score
     is the run's own. The JSON report lists every declared suite as
     `suites: [{name, covered, killed, score, exact, said}]`, `said` the
     sentence, with `suitesLowerBound` saying why the scores are lower
     bounds where any is, or none with `suitesUnscored` saying why. This
     amends ADR-0009 and ADR-0014.

9. **`--suite=<name>` judges one suite's tests alone,** for a scheduled job,
   exactly under every runner.
   - `plan` and `run` without a plan take it. A plan made with it briefs
     every shard and the verdict with the suite, inside its digest, and
     `run --plan` refuses it, since a shard runs the tests its plan was made
     for.
   - It narrows every run's tests, the coverage run's among them, to that
     suite, and its results are keyed apart from a whole-suite run's. It
     takes no `--coverage`, whose map may hold every suite's tests.
   - It holds no floor: each tree and security set is shown exempt, as
     *--suite judges no floor*, except that a run that also takes
     `--security` still holds the security sets (ADR-0021). The
     run records no commit as passed and teaches the cost model nothing.
   - A name the PHPUnit configuration does not declare fails the run with
     exit code 2, naming the suites it does declare.
   - It names its suite over the suites `tests.suites` lists (ADR-0002),
     whether or not that suite is among them.

10. **Suite scores are reported, never judged.** A lower bound cannot gate
    soundly, so there are no floors per suite.

### Removable code

11. **A surviving removal suggests deletion only when four facts hold
    together:**

    - a Removed-call mutant survived, so it is covered;
    - it removed a whole statement that is one call and nothing else, whose
      result is therefore unused;
    - every other mutant inside the called function's body, where that
      function is in the project, also survived, so the callee is
      pseudo-tested;
    - at least one test judges it, and none of those is weak,
      so the tests do assert things, only not this.

    The family's hint then adds: *No test depends on this call, and nothing
    `save()` does is checked either: if nothing outside the tests needs
    `save()`, it can be deleted.* The gate suggests, and never edits or
    counts anything by it.

    - **The call.** The statement is `$this->m(…);`, `self::m(…);`,
      `static::m(…);`, `Name::m(…);` or `f(…);`, and the diff removes it
      whole, adding nothing. A chain, an assignment, a call on another
      object, `parent::m(…)` and a call a mutator replaces rather than
      removes suggest nothing.
    - **The callee.** It is looked for among the survivors' own files:
      - `$this`, `self` and `static` lead to a method of the named class
        around the statement, never an anonymous class or a trait, whose
        methods a class using it may override;
      - `Name::m()` leads to a method of the class `Name` resolves to
        through the file's imports;
      - `f()` leads to the function `f` resolves to first: the namespace's
        own where the call is in a namespace. PHP calls the global one
        only where the namespace's is declared nowhere, which the
        survivors' files cannot show, so a global function suggests
        nothing from inside a namespace unless the name is fully
        qualified.
    - **The evidence.** The callee's body, from its opening brace to its
      closing one, holds at least one other mutant, and each other one is
      *survived*. One proven *equivalent* or left out by an ignore says
      nothing either way. Any other judgement, a kill, a rejection by
      static analysis, *uncovered*, *flaky*, *unjudged* or *too slow to
      judge* among them, suggests nothing.
    - **The tests.** A test not assessed does not count as weak, since it
      makes an assertion or calls a helper the table does not hold.

12. **The suggestion shows where hints show.** It is the hint's second
    sentence in every report that shows hints, and a *removable* marker in
    the JSON report and in `explain`. `stub` still offers the test and the
    ignore (ADR-0015). It reports only, and `Core` decides it
    over the verdict's mutants, the enclosing and called functions with
    names resolved through imports (`Core\Php`), and the assertion table.
    This amends ADR-0009 and ADR-0014.
    - `Core\Removal\Removals` decides it, `CallStatement` reads the
      statement, and `Core\Php\Declarations` holds each named function
      and method with its body.
    - A removable mutant's JSON entry holds `"removable": true`; every
      other entry leaves the key out. `resources/report.schema.json`
      describes it, and the format stays 1.
    - Its text block, which the console and the JUnit report print,
      holds a line `Removable: save()` after the hint.

### Identical mutants

13. **Mutants that leave their file alike run once, and share one verdict.**
    Two mutants of one file whose mutated files hold the same bytes are one
    program, whichever mutators made them, so one run judges both.
    - **Pest.** Pest names each mutated copy by a digest of its whole source.
      Where the gate records the run and `pest.patch` is on, the patched
      generation loop keeps a mutant whose file and copy an earlier mutant
      has out of Pest's run, after the run-again list and pruning have had
      their say. The plugin records it as a *twin* beside the mutants Pest
      planned, and the adapter judges it by its copy's run: its status,
      killers, limit, reason and evidence are the first's.
    - **The PHPUnit runner.** The gate makes every mutant itself, and runs
      only the first of those whose file and mutated text are alike.
    - **Infection.** Infection makes, runs and counts every mutant, twins
      included: it logs only the mutants it ran, so a mutant it skipped would
      leave the verdict without a record of it.
    - **Every mutant stays.** A twin keeps its own id, mutator and place in
      every report, counts in the score as its first does, and is judged in
      no time, so it teaches the cost model nothing. No mutator is dropped.
      This amends ADR-0013's context, by which a runner cannot skip a mutant
      before it runs: a patched runner can.

## Alternatives considered

| Option                                                                               | Why it lost                                                                                                      |
| ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| **Counting pruned mutants as killed**                                                | A prediction written down as a result.                                                                           |
| **Leaving pruned mutants out of the score**                                          | The score's meaning would move with the pruning.                                                                 |
| **Pruning per family**                                                               | A family holds strong and weak mutators alike.                                                                   |
| **A separate audit command**                                                         | A second full run to schedule, where the scheduled full run already exists.                                      |
| **Measuring weakness by running each covering test against a value-changing mutant** | Exact, and a new kind of mutation run for an insight report.                                                     |
| **Weakness inferred from survivors alone**                                           | That is ADR-0014's first tier, which names the test and not the assertion.                                       |
| **Every weak test reported**                                                         | Many shape assertions are exactly what a test means to check, and a finding with no survivor behind it is noise. |
| **Separate mutation runs per suite as the only score**                               | Exact, and the cost times the number of suites. It stays as `run --suite`.                                       |
| **The suite of each killed mutant's first killer**                                   | Moves with `tests.order`, so it means nothing stable.                                                            |
| **Floors per suite, judged under a full matrix**                                     | A gate that fails differently by runner, on a figure that is a bound under the others.                           |
| **Any surviving removal suggesting deletion**                                        | It would suggest deleting half of every untested codebase.                                                       |
| **Never suggesting deletion**                                                        | Hides the dead code a pseudo-tested callee points at.                                                            |
| **A report of removable code of its own**                                            | A second report beside `tests`, for what one sentence of a hint says.                                            |
| **Dropping a mutator whose mutants another mutator also makes**                      | Two mutators alike on one node differ on others, so the mutants only one of them makes would go too.             |
| **Leaving a twin out of the verdict**                                                | The score's denominator would move with which mutators happen to agree.                                          |

## Consequences

**Unchanged code costs less on every run,** with every pruned mutant shown
beside the run its result came from, and a weekly run that prunes nothing.

**A useless test is explained:** the report names the weak assertion and the
survivors it let through, and offers the assertion that would kill them.

**A suite's real share of the killing is visible,** exactly where a full kill
matrix exists and as a stated lower bound elsewhere.

**Dead code can be told from a missing test** where the gate's own records
say so, and nowhere else.

**Mutators that agree cost one run,** under Pest and the PHPUnit runner, with
every mutant still in every report.

## Related

- [ADR-0003](/docs/decisions/a-floor-only-rises): carried results
- [ADR-0004](/docs/decisions/pest-and-infection-behind-one-runner-port): how each runner takes its mutators
- [ADR-0005](/docs/decisions/what-a-change-reaches-is-what-is-mutated): the scheduled full run that audits
- [ADR-0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads): the key, what is recorded, and the ledger's sections
- [ADR-0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer): the reports and hints
- [ADR-0013](/docs/decisions/a-run-learns-which-tests-kill-and-how-wide-to-cut): the order first killers depend on
- [ADR-0014](/docs/decisions/every-test-is-judged-by-what-it-kills): the tests report, the full kill matrix and `explain`
- [ADR-0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit): `stub`
- [ADR-0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved): the savings line
- [ADR-0020](/docs/decisions/a-change-lists-its-tests-an-analyser-can-kill-and-a-huge-repository-can-be-sampled): killed by static analysis, and sampled runs
- [ADR-0021](/docs/decisions/mutators-are-written-once-and-first-party-sets-can-leave): security-tagged mutators
- [ADR-0023](/docs/decisions/the-gate-mutates-for-native-runners-and-reuses-what-it-measured): the native PHPUnit runner and its full kill matrix
- [ADR-0027](/docs/decisions/codeception-phpspec-and-testo-get-native-runners): the other native runners
