# Files

The files the gate reads and writes. `.mutation-gate/` holds local results
and proofs; it belongs in `.gitignore`, and `init` adds it there. Commit the
config and `mutation-gate.baseline.json`.

| Path                                                                                                                                                                                                  | What it is                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Decided in                                                                                                                                                                                                       |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mutation-gate.php`, `.json`, `.yaml`, `.yml` or `.neon`                                                                                                                                              | The config                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0002](/docs/decisions/one-typed-config-from-several-formats)                                                                                                                                                   |
| `mutation-gate.baseline.json`                                                                                                                                                                         | The committed floors, in the [baseline format](#the-baseline). A CI run that finds a tree with no floor prints the baseline it measured, ready to commit                                                                                                                                                                                                                                                                                                                                                                        | [0003](/docs/decisions/a-floor-only-rises), [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                       |
| The file `staticCheck.config` names, or else the analyser's own: `mago.toml`, `mago.yaml` or `mago.json`; `phpstan.neon`, `phpstan.neon.dist` or `phpstan.dist.neon`; `psalm.xml` or `psalm.xml.dist` | The static analyser's config. Every proof key holds the digest of the configuration the analyser resolves from it and of each file that configuration names, such as a baseline, an included config, or a bootstrap, stub or scanned file; where the analyser cannot say its configuration, of the config file alone                                                                                                                                                                                                            | [0020](/docs/decisions/a-change-lists-its-tests-an-analyser-can-kill-and-a-huge-repository-can-be-sampled)                                                                                                      |
| `.mutation-gate/plan.json`, `.mutation-gate/coverage/map.json.gz`, `.mutation-gate/results/<id>.json`                                                                                                 | The plan, its coverage and each shard's result, which `plan` and a run in one process leave and `explain` reads as the last run. A shard's result keeps each kill's evidence where its runner gives it: how far the mutant's own run went, and how a process that names no killer ended, with what it printed only where that holds no secret; it judges nothing                                                                                                                                                                | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once), [0014](/docs/decisions/every-test-is-judged-by-what-it-kills)                                                                         |
| `.mutation-gate/results/<id>.ended.json`                                                                                                                                                              | How the CI job of a shard that left no result ended, which the reusable workflow's verdict job writes from the run's jobs and their logs: `how`, one of `shutdown` (its runner received a shutdown signal), `lost` (its runner lost contact with GitHub), `cancelled`, `timed-out` or `failed`; `job`, the job's address; and `after`, for a cancelled job, the shard whose failure cancelled it under the matrix's fail-fast. The verdict, still *cannot judge*, names each shard's ending; a file it cannot read says nothing | [0121](/docs/decisions/a-shard-lost-to-its-machine-says-so)                                                                                                                                                     |
| `.mutation-gate/coverage/shard-<n>/map.json.gz`, `.mutation-gate/coverage/shard-<n>/killers.json`, `.mutation-gate/coverage/verdict/map.json.gz`                                                      | The part of the plan's coverage map each shard and the verdict open on, and the tests each shard's run found killing first, which the next run orders by                                                                                                                                                                                                                                                                                                                                                                        | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once), [0013](/docs/decisions/a-run-learns-which-tests-kill-and-how-wide-to-cut)                                                             |
| `.mutation-gate/delivery/planned/`, `survivors/`, `verdict/`: `delivery.json`, `ledger.json.gz`, `coverage.json.gz`                                                                                   | What a run left for `deliver` with `--deliver-later`: the comment, alert and OTLP payloads, and the ledger to write                                                                                                                                                                                                                                                                                                                                                                                                             | [0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads)                                                                                                                                        |
| `.mutation-gate/pipeline.yml`                                                                                                                                                                         | GitLab's child pipeline                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [0006](/docs/decisions/shards-are-cut-by-learned-cost-and-planned-once)                                                                                                                                         |
| `.mutation-gate/ledger/<scope>/ledger.json.gz`                                                                                                                                                        | The proof ledger of one ref; outside CI, the one a run writes whatever store the config names                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0007](/docs/decisions/a-proof-is-keyed-by-everything-its-verdict-reads), [0010](/docs/decisions/the-gate-runs-while-you-work-and-before-you-push)                                                             |
| `.mutation-gate/mutants/<native id>.php`                                                                                                                                                              | The mutated file of a mutant judged by reference (Pest)                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [0004](/docs/decisions/pest-and-infection-behind-one-runner-port)                                                                                                                                               |
| `infection.json5`, `infection.json`, `infection.json5.dist` or `infection.json.dist`                                                                                                                  | The project's own Infection config, the first found, whose mutators, `bootstrap`, `phpUnit`, `initialTestsPhpOptions`, `testFrameworkExtraArgs` and static analysis the gate keeps                                                                                                                                                                                                                                                                                                                                              | [0004](/docs/decisions/pest-and-infection-behind-one-runner-port)                                                                                                                                               |
| `.mutation-gate/mutators/<runner>/bridges.php`                                                                                                                                                        | The bridges through which Pest or Infection makes the mutants of the registered mutators the config turns on, which the gate writes for each run                                                                                                                                                                                                                                                                                                                                                                                | [0021](/docs/decisions/mutators-are-written-once-and-first-party-sets-can-leave)                                                                                                                                |
| `.mutation-gate/infection/`                                                                                                                                                                           | The config the gate writes for each run of Infection, Infection's logs, its temporary files, and the coverage the adapter runs PHPUnit for                                                                                                                                                                                                                                                                                                                                                                                      | [0004](/docs/decisions/pest-and-infection-behind-one-runner-port)                                                                                                                                               |
| `.mutation-gate/phpstan/check.neon`, `warm.neon`, `scope.json`, `resultCache.php`                                                                                                                     | The configs PHPStan's checks and its warm-up read, the files it analyses, and the result cache the warm-up saves and every check starts from, which the action keeps in the Actions cache between runs                                                                                                                                                                                                                                                                                                                          | [0020](/docs/decisions/a-change-lists-its-tests-an-analyser-can-kill-and-a-huge-repository-can-be-sampled), [0052](/docs/decisions/phpstans-warm-up-uses-every-core-and-its-result-cache-is-kept-between-runs) |
| `.mutation-gate/phpunit/`                                                                                                                                                                             | The PHPUnit runner's override, each mutant's mutated file, the tests its run selects, what the extension recorded and the guard, the coverage it runs PHPUnit for, and its memory cap                                                                                                                                                                                                                                                                                                                                           | [0023](/docs/decisions/the-gate-mutates-for-native-runners-and-reuses-what-it-measured)                                                                                                                         |
| `.mutation-gate/serve.sock`                                                                                                                                                                           | The Unix socket a daemon of `serve` listens on, readable and writable by its owner alone, removed once the daemon stops                                                                                                                                                                                                                                                                                                                                                                                                         | [0078](/docs/decisions/a-daemon-keeps-the-gate-loaded-between-local-runs)                                                                                                                                       |
| `.mutation-gate/phpunit-cache/`                                                                                                                                                                       | PHPUnit's caches, its test run history and its code coverage cache, for every PHPUnit the gate starts under the PHPUnit, Pest and Infection runners, whatever directory the project's PHPUnit config names, so no run writes a file a content key reads                                                                                                                                                                                                                                                                         | [0023](/docs/decisions/the-gate-mutates-for-native-runners-and-reuses-what-it-measured)                                                                                                                         |
| `.mutation-gate/phpspec/`                                                                                                                                                                             | The PhpSpec runner's override, each mutant's mutated file, the examples its run selects, what the extension recorded and the guard, the coverage and the list of examples it runs PhpSpec for, and its memory cap                                                                                                                                                                                                                                                                                                               | [0027](/docs/decisions/codeception-phpspec-and-testo-get-native-runners)                                                                                                                                        |
| `.mutation-gate/codeception/`                                                                                                                                                                         | The Codeception runner's override, each mutant's mutated file, the tests its run selects, what the extension recorded and the guard, the coverage and the list of tests it runs Codeception for, and its memory cap                                                                                                                                                                                                                                                                                                             | [0027](/docs/decisions/codeception-phpspec-and-testo-get-native-runners)                                                                                                                                        |
| `.mutation-gate/testo/`                                                                                                                                                                               | The Testo runner's override, each mutant's mutated file, the tests its run selects, what the plugin recorded and the guard, the XML coverage and each test's time, the list of tests it runs Testo for, and its memory cap                                                                                                                                                                                                                                                                                                      | [0027](/docs/decisions/codeception-phpspec-and-testo-get-native-runners), [0047](/docs/decisions/testos-runner-holds-a-minor-range-and-its-plugin-selects-stops-and-times)                                     |
| `.mutation-gate/publish/badge.json`, `trend.json`, `trend.svg`, `summary.json`, or the same in the `badge` report's `path`                                                                            | The badge, the trend, and the run's summary an organisation's dashboard reads                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                                   |
| `.mutation-gate/publish/savings.json`                                                                                                                                                                 | A shields.io endpoint with the time saved in `costs.savingsWindow`, the last 30 days by default                                                                                                                                                                                                                                                                                                                                                                                                                                 | [0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)                                                                                                                    |
| A `json`, `junit`, `sarif`, `stryker`, `digest`, `gitlab`, `sonar` or `kill-matrix` report's `path`                                                                                                   | That report                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                                   |
| `.mutation-gate/report.json`                                                                                                                                                                          | The last run's JSON report, which every verdict keeps and `digest` renders                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                                   |
| An `html` report's `path`: `index.html`, `mutation-report.json`                                                                                                                                       | The HTML report, and the report in the `mutation-testing-report-schema` format                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [0009](/docs/decisions/every-verdict-is-readable-by-a-machine-and-a-reviewer)                                                                                                                                   |
| A `tests` report's `path`, and the same path with `.md`                                                                                                                                               | The useless, removable and weakly asserting tests, as JSON and Markdown                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [0014](/docs/decisions/every-test-is-judged-by-what-it-kills)                                                                                                                                                   |
| `<out>/index.html`, `<out>/dashboard.json`                                                                                                                                                            | An organisation's dashboard, which `dashboard --out=<out>` writes                                                                                                                                                                                                                                                                                                                                                                                                                                                               | [0024](/docs/decisions/the-gate-runs-and-comments-beyond-github-and-aggregates-an-organisation)                                                                                                                 |

## What `init` writes

`init` writes each file only where it does not exist, and otherwise prints
what to add to it ([ADR-0015](/docs/decisions/a-survivor-reaches-the-editor-the-test-file-and-the-commit),
[ADR-0017](/docs/decisions/adopting-the-gate-takes-one-command-and-every-run-says-what-it-saved)).

| Path                                                                                             | What it is                                                                                                                                                                                                                  |
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The config: `mutation-gate.php`, or the format `--format` names                                  | The runner and preset it found, and the trees listed in a comment                                                                                                                                                           |
| `.gitignore`                                                                                     | Gains `.mutation-gate/`                                                                                                                                                                                                     |
| `composer.json`                                                                                  | Gains a `mutate` script, where you answer yes                                                                                                                                                                               |
| `.github/workflows/mutation.yml`                                                                 | The GitHub Actions workflow, `--ci=github`                                                                                                                                                                                  |
| `.gitlab/mutation-gate.yml`, or the file `ci.gitlab.template` names                              | The GitLab template, with the lines to add to `.gitlab-ci.yml` printed                                                                                                                                                      |
| `.buildkite/mutation-gate.yml`                                                                   | The Buildkite steps, with what to add to the pipeline Buildkite runs printed                                                                                                                                                |
| `.azure/mutation-gate.yml`                                                                       | The Azure Pipelines template, with what to add to `azure-pipelines.yml` printed                                                                                                                                             |
| `.circleci/config.yml`, `bitbucket-pipelines.yml`, the Jenkinsfile `ci.jenkins.definition` names | Not written: what to add to each is printed                                                                                                                                                                                 |
| `.vscode/tasks.json`, `.vscode/extensions.json`                                                  | VS Code's watch task and the recommended SARIF Viewer, `--editor=vscode`                                                                                                                                                    |
| `captainhook.json`, `grumphp.yml`, `.pre-commit-config.yaml`                                     | The hook manager's config calling the gate, `--hook=captainhook`, `grumphp` or `pre-commit`; an existing `grumphp.yaml`, `grumphp.yml.dist`, `grumphp.yaml.dist`, `grumphp.dist.yml` or `grumphp.dist.yaml` is read instead |
| `pre-push`, and `pre-commit` with `hook install --pre-commit`, in git's hooks directory          | git's own hooks, in the directory `git rev-parse --git-path hooks` names, `core.hooksPath` included                                                                                                                         |

## The baseline

`mutation-gate.baseline.json` holds each tree's floor, and each package's
security floor, one key per tree in byte order and each floor on a line of
its own, so a moved floor is a one-line diff:

```json
{
    "format": 1,
    "trees": {
        "app/Domain": { "floor": 100 },
        "app/Legacy": {
            "floor": 61.2,
            "lowered": { "from": 64.5, "reason": "The export feature and its tests were removed together" }
        }
    },
    "security": {
        "packages/billing": { "floor": 100 }
    }
}
```

| Key        | What it holds                                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------------------------------- |
| `format`   | `1`                                                                                                                 |
| `trees`    | Each tree, by its path, with its `floor`: a percentage from 0 to 100, at most two decimals                          |
| `security` | Each package's security set, by its path, held as a tree is; left out where there is none                           |
| `lowered`  | Beside a floor a pull request lowers: `from`, the floor on the branch it merges into, and `reason`, why it may fall |

A floor only rises ([ADR-0003](/docs/decisions/a-floor-only-rises)).
`baseline --write` raises the floors to what was measured, and a pull
request may lower one only by saying so: on a pull request the gate compares
the baseline with the one the branch it merges into keeps, or the default
branch's where its CI names no such branch
([ADR-0050](/docs/decisions/a-pull-request-is-read-against-the-branch-it-merges-into)),
and fails where

- a floor is lower and its entry has no `lowered`, or its `reason` is empty;
- `lowered.from` is not that branch's floor;
- a tree leaves the file while its path is still a tree, or a security set
  while its package is still there.
