mutation-gate or mutation-gate run | Plan, run and judge in one process: what changed since the last commit that passed, or everything where none passed yet or run.full asks for it. With --changed-since=<ref>, only what the change since <ref> reaches; with --full, everything. With --budget=<duration>, the riskiest code first, within that time. |
coverage [--into=<dir>] [--from=<dir>] | Run the suite under coverage and write the gate’s own map, <dir>/map.json.gz (.mutation-gate/coverage by default), for a later plan --coverage=<dir>. With --from, run nothing and read the reports this job’s own coverage run left in that directory instead: coverage.php from --coverage-php for Pest and PHPUnit; coverage-xml/, junit.xml and clover.xml for Infection |
plan | Work out the reach, drop proved units, cut shards and print the plan for a CI, saying first why it reaches what it does, what reaches every unit before the rest (--ci=github|gitlab|buildkite|circleci|azure|bitbucket|jenkins|json, or --shards=<n> for a fixed count; --coverage=<dir> reads the map coverage wrote instead of running the suite) |
run --plan=<file> [--shard=<id>] [--results=<dir>] [--leftover=<k>] | Mutate one shard: the one --shard names, or the one the CI’s environment names, and leave its result in --results; with --leftover=<k> and --shard, judge share k of the mutants that shard left at its deadline, as leftovers cut them, in its units that hold them, making only them, and leave the share’s result as <dir>/<shard>.leftover-<k>.json (ADR-0190) |
verdict --plan=<file> --results=<dir> | Merge every shard’s results, judge the floors, write reports and the ledger |
deliver [--from=<dir>] | Send what a run left in <dir> (.mutation-gate/delivery by default), with credentials that run never held: write the ledger to the store, post the comment on GitHub, GitLab or Bitbucket, as the CI it runs in says, post the alerts, and export OTLP. It runs from the gate’s own installation and loads none of the project’s code. Exits 2 where it cannot start or read the delivery, or where a trusted run’s ledger is not written to the store MUTATION_GATE_STORE names |
fetch [--to=<dir>] | Read the default branch’s ledger from the store with a key that only reads, and write it into .mutation-gate/fetched, where a run reads it beside the copy its own store keeps, as proofs.copies says. Written into another <dir>, a run reads it only where <dir> is the directory store’s path, and then as the copy it keeps. It runs from the gate’s own installation and loads none of the project’s code. Exits 0 where MUTATION_GATE_STORE names no store, the ledger cannot be read or the job holds no key, saying why, and 2 where it cannot start, locate the store it names, name the default branch or write the ledger |
baseline [--write] | Show, or write, floors raised to what was measured |
survivors [--plan=<file>], with the planning options of plan | On a branch’s run, run the last run’s survivors again before the shards: those the comment lists, on the change’s lines first, at most survivorsFirst.max, file by file within survivorsFirst.budget, each found again by its id, reported gone, or not re-checked where its file had no time left. It writes the comment over its planned state and the step summary, and says how many still survive. It re-checks what the plan reaches, or plans first without one; --jobs, --share and --from share it among jobs. It writes no ledger and judges nothing, so it exits 0, or 2 where it cannot re-check |
leftovers --plan=<file> --results=<dir> [--coverage=<dir>] | After the shards, cut the mutants each one left at its deadline into shares for a second wave of jobs, each share’s mutants grouped by source file and priced at the wall seconds a job’s split streams take over them, each test file once and each mutant’s second pass at every covering test, by the factor recent second-wave jobs measured, and each mutant no stream judged at the wall seconds its shard’s own runs took each, to fill a job that stops where shards.margin says less the time its shard took to start judging, or to come to its own runs where it came to any, every capacity growing until the matrix holds 256 jobs or fewer; write them to <dir>/leftovers.json and print the jobs’ matrix, a JSON list of each share’s shard and share, [] where no shard left any; and [], saying why on the error output, where the shards’ results alone decide the verdict: a shard left no result or one that cannot be judged, or a shard stopped once the run could not pass (ADR-0190, ADR-0196, ADR-0301, ADR-0336) |
reproduce <id> | Run one recorded mutant again, alone, and show why it survives, with the runner’s own output; the id may be a unique prefix of 6 or more. Exits 1 where the run finds other than what was recorded, and 2 where no ledger holds it or the run no longer makes it |
explain <id> [--format=text|json] | Show one mutant’s diff, hint, covering tests and their outcomes, for a kill by static analysis the analyser and its finding’s file, code and message, how the last run took its unit, and its history, from the ledgers and the last run, running nothing; the id may be a unique prefix of 6 or more, or a cluster’s id. --format=json is described by resources/explain.schema.json. Exits 2 where no record holds it |
digest [--detail=<file|id|legend>] [--survivors=<n|all>] [--tests=<n>] | Say the last run’s verdict one fact a line, for an agent or a terminal, from the JSON report every verdict keeps at .mutation-gate/report.json, running nothing: the verdict, why, what to do, the counts each with its grade, each set, where the verdict comes from, the warnings, and the first 25 survivors, or as many as --survivors asks for, each with what test would catch it. With --detail, one target in depth instead: a file, a mutant by its id or a unique prefix of 6 or more, naming as many of its covering tests as --tests or digest.tests says, 5 by default, a cluster, or legend for what each word means (reading the report). Exits 2 where no run left a report, it cannot be read, a count is no whole number, or the target names nothing the run holds |
affected [--changed-since=<ref>] [--coverage=<dir>] [--format=files|files0|ids|json] | List the tests the change since the coverage map was measured can make fail, and with --changed-since the change since <ref> besides, running nothing: each test file a line (files, for PHPUnit 13’s --test-files-file), each ended by a NUL byte (files0, for xargs -0 vendor/bin/pest, or vendor/bin/phpunit on PHPUnit 12), each test id a line (ids, for PHPUnit 13.2’s --test-id-filter-file), or the JSON answer. The reasons go to standard error but in JSON. A map that is missing, does not say where it was measured or was measured in a dirty tree lists every test. Exits 0 whenever it answered, and 2 where git cannot tell what changed or ids cannot select the tests |
tests | Print the tests report of the last run, judged again from the ledgers and the coverage map it left, running nothing: the useless, redundant and weakly asserting tests. Exits 0 whatever it finds, and 2 where no run has left one |
mutators [--format=text|json] [--ledger=<file>] | Print what each mutator costs and finds, from the tally the default branch’s ledger keeps, or the ledger.json.gz --ledger names: one row for each mutator of each runner, the costliest first, with its mutants, kill rate, survivors, runner time, time per kill and share of every mutator’s time, running and writing nothing. Each run that writes a ledger and judges every mutant adds to the tally. --format=json is described by resources/mutators.schema.json (ADR-0076). Exits 0 once printed, and 2 where the ledger cannot be read |
machine [-- <program>…] | Print this machine as one JSON object: its processor’s cpu where Linux names it, and its cores. Given a program, it runs it once untimed and then 5 times, each round timed from the program’s start to its exit, and adds rounds and their median seconds; the program’s output goes to standard error. CI scales the local budgets by it (ADR-0159). It reads no config. Exits 0, and 2 where a round of the program did not end with 0 |
triage <path> [--repeat=<n>] [--order=runner|killers-first] | Run a unit, a file of a tree or a held path, n times (5 by default, 2 or more) and list every mutant whose result varied, with the runs that gave each result, each mutant’s tests in the order --order names (tests.order by default). Exits 1 where a mutant varied, 0 where none did, and 2 where the unit cannot be run |
watch | Re-judge what each save reaches; in the daemon that serves the project, started where none runs and local.serveStart is watch |
lsp [--severity=error|warning|information|hint] [-- <watch option>…] | Serve an editor as a language server on standard input and output: run watch --output=events in the workspace’s root, with every other option given and those after --, and show each survivor as a diagnostic over the line its site starts on, coded with its id, a warning by default, with code actions that run explain, stub and stub --write for it (ADR-0133). --stdio, which editors pass, is the only transport. Exits 2 where no Outbreak binary is in use |
serve [--stop] [--detached] | Keep the gate loaded for the project, listening on .mutation-gate/serve.sock, and run watch, pre-commit and pre-push there, each in a child of its own, until no request comes for local.serveIdle, a request finds the gate’s version, composer.lock or the config changed since it started, or serve --stop stops it. pre-commit and pre-push use a daemon only where one runs, and each of the three runs on its own where no daemon serves it. --detached leaves the session of the command that started it, as watch starts it |
pre-push [<remote> [<url>]] [--stdin=<lines>] | Judge the commits being pushed, as CI will, after printing each reached tree’s score change. The refs come from git’s lines on standard input, from --stdin where a hook manager read them, as CaptainHook does, or, where neither holds a line, from the variables the pre-commit framework sets. Each line must be a local ref, its commit, a remote ref and its commit, each commit a full object name in hex |
pre-commit | Print each reached tree’s score change from the local ledger; runs nothing and always exits 0 |
hook install [--pre-commit] / hook uninstall | Add or remove the pre-push hook, and with --pre-commit the pre-commit hook too |
init [--format=php|json|yaml|neon] [--ci[=github|gitlab|buildkite|circleci|azure|bitbucket|jenkins]] [--editor=vscode] [--hook[=git|captainhook|grumphp|pre-commit]] [--no-hook] [--native=allow|refuse] [--dry-run] [--no-measure] | Detect the runner, preset, trees, CI and an Infection config; where no config is here, ask in turn what detection leaves open: the runner where both are installed, the CI where the files show none or several, whether to import the Infection config found, what to do with the runner’s own ignore markers found, where to set the pre-push hook up, and whether to add composer mutate to the scripts in composer.json, each defaulting to what detection found, and asking nothing with --no-interaction, with no terminal, or in CI; write a config holding the runner and the preset it found (PHP by default, or the file --config names, in the format of its extension), listing the trees the tree source finds in a comment, or for JSON in what it says, and add .mutation-gate/ to .gitignore; with --ci, a pinned CI definition (--ci alone takes the detected CI), with --editor, VS Code’s watch task, and with --hook, the hook, each only where none exists, and otherwise what to add to it; run the suite once under coverage and say what a full run takes, cut into shards as the config asks, with the hot paths nothing holds; then say what to run next: doctor, the first run, and git add of the files it wrote |
init --from[=<file>] or import [<file>] [--format=php|json|yaml|neon] [--no-measure] | Write a config from an Infection config, the file named or the one Infection itself would read, over what zero-config found; say of each of its keys whether it was imported, stays in that file or was dropped, and which keys to delete; then say what a full run takes, as init does |
doctor [--measure] [--online] [--format=text|json] [--fix [--yes]] | Report what would fail, run slowly or deserves attention, each with its fix, reading only files and earlier runs; exits 1 when something would fail. --fix shows the diff of every file it can fix and what it cannot fix, then asks once whether to write them; --yes answers yes, and with no terminal to ask and no --yes it writes nothing. It turns opcache off and loads pcov in the php.ini the runner’s PHP loads, where it can write it, and names pecl install pcov rather than running it; lowers the PHPUnit config’s memory_limit to runner.memory; adds the trees to its <source>; adds .mutation-gate/ to .gitignore; applies pest:patch and infection:patch; and pins the installed release in each CI definition. Once it wrote, it looks again and exits as doctor does (ADR-0083). --fix writes text, so it refuses --format=json |
stub <id> [--style=pest|phpunit|phpspec] [--write] | Print a failing Pest or PHPUnit test or PhpSpec example for a survivor or an uncovered mutant, or one for a cluster, in the style of its nearest covering test, found as explain finds the mutant, with Try: … and its scaffold calling the function with the values rules found to kill the survivor where they found any (ADR-0101); with --write, add it to that file, or create one, never overwriting. Exits 2 where there is nothing to stub, with the next step where there is one, and under the Codeception and Testo runners, whose tests are in no style it writes |
dashboard --org=<org> --out=<dir> [--include-private] | Build an organisation’s dashboard into <dir>: index.html, one page with no script or style it loads, and dashboard.json, from each repository’s summary.json on its mutation-gate branch, read through GitHub’s API with GITHUB_TOKEN, for the repositories with dashboard.topic or those dashboard.repositories names. Private and internal repositories are left out unless --include-private is given, which it accepts only where GitHub says the Pages site of GITHUB_REPOSITORY is private (ADR-0024). Exits 2 where it was not given both options, the config cannot be read, GitHub cannot list the repositories, private ones may not be shown, or it cannot write |
config:show [--format=…] [--resolved] / config:schema | Print the effective config (JSON by default), each context block as written, or with --resolved as a run in its contexts reads it; or the JSON Schema |
config:suggest [--ledger=<file>] | Print the config changes the ledger gives evidence for, each with its evidence: of the runner the config chooses, an idle mutator, which costs time and finds nothing, and a noisy one, whose mutants are mostly ignored or equivalent, turned off by mutators.except, and a paths entry doubling the timeout of a directory whose mutants run out of time, by the suggest.* thresholds; then the config file with them laid over it, as a unified diff in its own format. A change the config cannot say is named with why, and left out of the diff. It writes nothing (ADR-0076). Exits 0 whatever it suggests, and 2 where the config or the ledger cannot be read |
migrate [--write] | Show the diff that moves the config and the baseline to the current release, and with --write, write it. A PHP config keeps its comments and layout, and only the builder calls a release retired change. A JSON config and the baseline change key by key. A YAML or NEON config is written again, and its comments are not kept. The baseline is the one the config names, or mutation-gate.baseline.json while the config does not read. A change migrate cannot make is listed for a hand edit. Exits 0 where every file is current or written, 1 where a change is pending without --write or left for a hand edit, and 2 where a file cannot be read |
pest:patch | Apply the optional Pest patches (ADR-0004). Exits 0 once they are applied, and 2 where one cannot be |
infection:patch | Give Infection the gate’s mutant limit (ADR-0004). Exits 0 once it is applied, 1 where the installed Infection is not a release of 0.35.0 to 0.35.15, and 2 where Composer’s installed.json cannot be read, lists no Infection, or a change cannot be applied. In post-install-cmd, a non-zero exit fails composer install |