ADR-0016: The gate takes over from an Infection config, says what a run costs, alerts on the default branch, and exports its runs
Status: Accepted Date: 2026-09-30
Context
Operating the gate raises four needs its reports do not yet meet.
Adopting it from Infection. Many projects arrive with an
infection.json5. The Infection adapter already starts from that file and keeps what the runner owns:mutatorswith their profiles and settings,bootstrap,phpUnit,initialTestsPhpOptionsandtestFrameworkExtraArgs(ADR-0004). The rest either becomes something of the gate's or is refused by it:minMsiis a floor;sourcedecides the trees;ignoreandignoreSourceCodeByRegexare native markers, refused by default (ADR-0008);- the
logsare reports.
Infection's MSI is not the gate's score. It counts errors and, by default, timeouts as killed, and it leaves out skipped mutants, where the gate triages timeouts (ADR-0003, ADR-0008). Infection never generates a mutant its
ignorepatterns match, so no mutant id can be recovered from them.source.excludeshas no equivalent: a tree is a path, and only the phpunit tree source knows<source><exclude>.Knowing what a run cost. The plan and the shards already hold every figure needed:
- the cost model's estimate for each unit;
- each shard's measured time and opening run (ADR-0006, ADR-0013);
- the time of every unit that reach or a proof spared.
Nothing reports them.
Hearing when the default branch breaks. A red default branch, or one whose verdict could not be reached, is seen today only by whoever opens CI. The chat services differ:
- A Slack incoming webhook requires
text, a missing one beingno_text, and takes optional Block Kitblocks. It answers400 invalid_payload,403 action_prohibitedor404 no_service. Its channel, name and icon cannot be overridden. - A Discord webhook takes
content(up to 2,000 characters), up to 10embeds, and an optionalusernameandavatar_url. - A webhook URL is a credential, and config files are committed.
- A Slack incoming webhook requires
Watching runs over time. OpenTelemetry is how CI telemetry is collected.
open-telemetry/sdk1.15 requires, among others,php-http/discoveryandtbachert/spi, both Composer plugins that each consuming project would have to allow. ADR-0001 rejected that cost for its own discovery.- Its OTLP exporter adds
google/protobuf. - OTLP over HTTP also accepts JSON, and one request with
symfony/http-client, already required, can carry it. - The gate emits a handful of spans and data points once per process, and needs none of the SDK's batching, sampling or context propagation.
Decision
init --from=<file>starts the gate's config from an Infection config.- It reads
infection.json5,infection.jsonor a.distof either. - It writes the gate's config in
--format, asinitdoes (ADR-0002), seeded from that file as well as from zero-config. - It prints every key of the file with imported as, stays in infection.json5 or dropped, because.
- It never rewrites the Infection file, because a JSON5 rewrite loses its comments. It prints the keys to delete instead.
mutation-gate import <file>is the same command.- A
testFrameworkother thanphpunitstops it with exit code 2 before anything is written (ADR-0004).
infection.json5Becomes source.directoriestrees[].path, one tree per directory.treesreplaces the tree source's list whole (ADR-0002), and the report says wherephpunit.xml's<source>differssource.excludestrees[].excludeof the tree holding eachminMsi,minCoveredMsitrees[].floor, anduncoveredtimeouttimeouts.secondstimeoutsAsEscaped: truetimeouts.mode: unjudgedmutators.<Name>.ignore,global-ignore,ignoreSourceCodeByRegex,global-ignoreSourceCodeByRegexignores.entries, orignores.native: allowlogs.html,logs.stryker.reporta reportsentryhtmllogs.jsona reportsentryjson, as a suggestion. The gate's JSON is its own formatlogs.gitlaba reportsentrygitlablogs.githubdropped: annotations are automatic under GitHub Actions (ADR-0009) logs.stryker.badgedropped: the gate publishes its own badge (ADR-0009) logs.text,logs.summary,logs.summaryJson,logs.perMutator,logs.debugdropped: the gate owns logs.jsonandlogs.textin the config it generatesmaxTimeoutsdropped: timeouts are triaged, not capped (ADR-0008) ignoreMsiWithNoMutationsdropped: nothing to mutate already passes (ADR-0003) threads,tmpDirstays in the file; the gate overrides both (ADR-0004) mutatorsprofiles and settings,bootstrap,phpUnit,initialTestsPhpOptions,testFrameworkExtraArgs,staticAnalysisTool,staticAnalysisToolOptionsstays in the file; the adapter reads it - It reads
minMsibecomes each tree's declared floor. It is truncated to two decimals, and it is the policy minimum of ADR-0003, not a baseline entry, because nothing was measured. ADR-0040 amends this: it is rounded up, as every declared floor is.minCoveredMsisetsuncovered: excludeand, whenminMsiis absent, the floor.- The report ends: run
mutation-gatelocally once; it writes the baseline at what the gate measures, and says if a tree is below the imported floor. The difference between the formulas surfaces on the developer's machine, not in CI.
A tree may exclude paths:
trees[].exclude.- It is a list of globs spelt from the repository root, with the gate's
glob semantics:
*within one segment,?for one character,**for any number of segments. - A file a tree's exclude matches belongs to no tree. It is not mutated, counted or reached as a unit.
- An exclude that matches no file in its tree stops the run with exit code 2, as a misspelt key does (ADR-0002), because it would otherwise do nothing silently.
- The PHP builder takes it as
Tree::at('src', floor: 90, excluding: ['src/Legacy/**']). - It decides what the tree is, so it affects results and is in the proof
key beside
trees[].path(ADR-0007). The phpunit tree source's<source><exclude>keeps working as before.
- It is a list of globs spelt from the repository root, with the gate's
glob semantics:
Infection's ignores are converted where they map, and allowed where they do not.
ignorepatterns become path entries.mutators.<Name>.ignore: ["App\\Money::add"]becomes{path: <the class's file, from the autoload>, mutator: <Name>}. AClass::methodorClass::method::linepattern widens to the whole file, and the report lists every entry that widened. The file is found from the psr-4 and psr-0 autoload ofcomposer.json, without loading any code.- A pattern over a whole namespace,
App\Legacy\*, becomes an entry for<the namespace's directory>/**. Any other wildcard names no one class or namespace, so it stays native. global-ignoreand a profile's ignores become one entry per family the profile holds whole, and one per other mutator of it by name, because a gate ignore names a mutator or a family (ADR-0008). The installed Infection's own profile list says which mutators each profile holds;global-ignoreholds them all, those of no family among them.- A pattern that maps to no entry stays native: one whose class no
autoloaded file holds, one whose namespace no autoloaded directory
holds, another wildcard, or a profile's where Infection is not
installed. The import sets
ignores.native: allowand says why each stays. - Every imported entry has a reason and an end. Its reason is
Imported from infection.json5 (<pattern>): write the real reason, and it expires 90 days after the import, so no imported entry outlives a person's look at it. - Regex ignores are kept native.
ignoreSourceCodeByRegexhas no equivalent, so where any exists the import setsignores.native: allowand says so. - The markers left in the file would make the run refuse to start
under
ignores.native: refuse. The report prints the keys to delete, and so does the refusal itself.
A
gitlabreport writes GitLab's Code Quality JSON.- Each result carries
description,check_name(the SARIF rule),fingerprint(a digest of the gate's id, as SARIF's is),severityandlocation.pathwithlocation.lines.begin. severityismajorfor a mutant in a failing set, andminorotherwise.- GitLab's merge request widget then shows survivors per line, the view ADR-0009 gives GitHub through annotations.
- Each result carries
A run's cost is its time, planned and measured, and what it was spared.
- Planned: the wall time and runner-minutes the plan expects. That is
the cost model's estimate plus each shard's overhead, its opening run
and
shards.setup(ADR-0013). - Measured: the same two figures from the shards' results.
- Spared: the cost-model time of every unit reach carried or a proof covered, "saved 41 runner-minutes".
shards.setupis included, and labelled estimated, where the gate cannot see the CI's setup. On GitHub the jobs' own start and end times replace it (ADR-0017).
- Planned: the wall time and runner-minutes the plan expects. That is
the cost model's estimate plus each shard's overhead, its opening run
and
Money is shown only when the team gives a rate.
costs.perRunnerMinuteis{amount, currency}, and unset by default. When it is set, each time figure is shown with its price. It sits undercosts, which the proof key leaves out (ADR-0007). The flows hand the verdict the rate as aCore\Cost\Rate, and the cost is priced withCost::pricedAt(Rate). The config'sPricestays with the config, since nothing a verdict carries names a config type.The cost appears once, out of the way.
- It is a collapsed
<details>section at the end of the sticky PR comment (ADR-0009). What the run saved is one line directly under the verdict, outside it (ADR-0017). - The step summary and the console each give one line.
- The JSON report gains a
costobject. - The section is
<details><summary>What this run cost</summary>, then a table of the planned and measured wall and runner time, then Reach and proofs spared 41m of runner time. Where the CI did not measure setup it adds Setup is estimated at 1m a job, fromshards.setup. With a rate it adds At 0.20 EUR a runner minute: planned 3.00 EUR, measured 2.80 EUR, spared 8.20 EUR. Money is written with two decimals and the currency as the team gave it. - The
costobject is{"planned": {"wallSeconds", "runnerSeconds", "price"?}, "measured": {…}, "spared": {"seconds", "price"?}, "setupEstimated", "perRunnerMinute"?}. EachpriceandperRunnerMinuteis{"amount", "currency"}, present only where a rate is set.
- It is a collapsed
Chat alerts are reporters:
slack,discordandwebhook.- They are built-in
Reporteradapters (ADR-0009). They send withsymfony/http-client, which is already required (ADR-0001). - A failed post says so, and never changes the exit code.
- They are built-in
An alert fires when the default branch changes state, in CI only.
The states:
- failed: a tree below its floor, or a failure that belongs to no floor;
- cannot judge;
- recovered: the first pass after either;
- floor lowered: a baseline
loweredentry landed (ADR-0003).
A verdict that cannot judge says so itself. The flows add each reason with
Verdict::withCannotJudge(CannotJudge), and any one makes the verdict's judgementcannot-judge, whatever its trees scored. Every report that shows the verdict's judgement shows it with the reasons: the console and the Markdown under Cannot judge, the JSON report ascannotJudge, and JUnit as a failing case of typecannot-judgein itsrunsuite.The previous state comes from the newest entry of
trend.json, which gains averdictfield (ADR-0009). It is restored into--publish-diras the badge is.With no previous state, only a failure alerts.
How a change is read. Each
trend.jsonentry also records each tree's floor, underfloors. Against the newest entry:- failed fires when the verdict failed and the entry did not, or recorded no judgement;
- cannot judge fires when the entry judged something else;
- recovered fires when the verdict passed and the entry failed or could not judge;
- floor lowered fires when a tree's floor is below the floor the
entry recorded, so once, and names the reason the baseline's
loweredgives.
One verdict may alert twice, a lowered floor beside the recovery it brought.
Alerts::of(Verdict)gives them. It reads the trend the flows hand the verdict on the default branch (ADR-0017), and a verdict with none alerts nothing.A run cut short by its budget never alerts, as it never updates the badge (ADR-0009).
Pull requests never alert. Their authors have the sticky comment.
A webhook URL comes from the environment, never from the config.
- Each reporter reads the URL from the environment variable its
with.urlEnvnames:slack:MUTATION_GATE_SLACK_URLby default;discord:MUTATION_GATE_DISCORD_URLby default;webhook:MUTATION_GATE_WEBHOOK_URLby default.
- A literal
urlinwithis refused by the config's definition, and the message names the variable to use. - The reusable workflow takes these as optional secrets, passed to its
verdictjob only, withMUTATION_GATE_WEBHOOK_SECRET. The action reads them from itsdeliverstep'senv.
- Each reporter reads the URL from the environment variable its
Each alert is one short summary, rendered three ways.
Every message carries the event, the failing trees with floor, score and previous score, at most five survivors, and the run's link.
Slack:
textas the one-line fallback, and Block Kit sections.Discord: one embed, red, green or grey. It sets
allowed_mentions: {"parse": []}, so no tree or test name can ping anyone.Webhook:
{"format": 1, "event", "repository", "ref", "commit", "run", "verdict", "trees": [{"path", "floor", "score", "previous"}]}. Its schema is generated as the report's is, and committed atresources/webhook.schema.json. WhenMUTATION_GATE_WEBHOOK_SECRET(or the variablewith.secretEnvnames) is set, the request carriesX-Mutation-Gate-Signature: t=<unix seconds>,sha256=<HMAC-SHA256 of "<t>.<body>">.tis the reporter's clock when it sends. A receiver recomputes the HMAC overt, a dot and the raw body, compares it in constant time, and rejects atmore than 5 minutes off its own clock, so a captured post cannot be replayed. This amends the body-only signature this decision first named.Every chat limit, Discord's 2,000 characters among them, holds by construction.
The layout. The title is mutation-gate: failed on octo/gate main. The groups under it are:
- for a failure: Below the floor, one line a tree, as
`src`: 72.50%, below its floor of 80.00%; it was 81.00%.; then Failures; then Survivors, each as`src/Money.php:7` LessThan, survived; - for cannot judge: Why, the reasons;
- for a recovery: Trees, each passing tree against its floor;
- for a lowered floor: Floors lowered, as
`src`: its floor went from 90.00% to 80.00%.and the reason, or The baseline gives no reason.
A path or reason is cut at 120 characters. A block that would pass its limit keeps the whole lines that fit and says And 3 more.
- for a failure: Below the floor, one line a tree, as
The webhook's trees are every tree the verdict judged. A tree whose floor went down also carries
"lowered": {"from", "reason"?}, and the payload carries"cannotJudge", the reasons, which is empty for a verdict that judged. A tree leaves out a floor, score or previous score it has none of.What an alert says of its run is a
Core\Ci\CiRun: the repository, the full ref, the full commit and the run's link.
An alert is sent within 10 seconds or reported unsent.
- The request times out at 10 seconds.
- A 429 or a 5xx is retried once, after its
Retry-Afterup to 30 seconds. - After that the reporter says not written, with the status and the body.
- A
Retry-Aftergiven as a date is read against the clock. One the gate cannot read is not waited for. - A redirect is not followed, so the body and the webhook's signature reach only the URL given. A failure never repeats that URL, which holds the chat's credential.
- A reporter with nothing to send says not written and why. That is when its URL is unset, outside CI, off the default branch, for a run cut short, or when the state did not change.
- The run an alert names is read from the environment of GitHub Actions, GitLab CI, Buildkite or CircleCI. In any other CI the reporter says it cannot name the run.
otlpexports traces and metrics as OTLP/HTTP JSON, without the SDK.- It is a built-in
Reporteradapter. It POSTs to/v1/tracesand/v1/metricswithsymfony/http-client. - A contract test checks each payload against OTLP's JSON mapping: 64-bit integers as decimal strings, trace and span ids as lowercase hex.
- Nothing is added to
require, and no Composer plugin.
- It is a built-in
One trace per CI run, across its jobs, and metrics from the verdict.
- The trace id is the first 16 bytes of
sha256("mutation-gate:" + run), whererunis the run a proof names (ADR-0007). So the plan job, every shard job and the verdict job add spans to the same trace, with nothing passed between them. - Span ids are derived the same way from the trace id and the span's path. The gate draws no random number (ADR-0001).
- Spans:
plan,shard <n>with a child for each step its time went to, named by the step and begun when it began, andverdict. - Metrics, emitted by the verdict:
mutation_gate.score, a gauge per tree and for new code;mutation_gate.mutants, a sum by status;mutation_gate.units, a sum by run, proved or carried;mutation_gate.duration, per phase, and per shard with each step's seconds over the shard beside it;mutation_gate.runner_minutes.
- The trace id is the first 16 bytes of
Attributes follow OpenTelemetry's semantic conventions, and stay few.
- The resource carries
service.name=mutation-gate. - Spans carry
vcs.ref.head.name,vcs.ref.head.revision,cicd.pipeline.run.idandcicd.pipeline.name. - The gate's own attributes are
mutation_gate.tree,mutation_gate.status,mutation_gate.shard,mutation_gate.runnerandmutation_gate.mode. - None is per mutant or per file, so cardinality is bounded by trees times statuses.
- The resource carries
otlpis opt-in, and reads OpenTelemetry's own variables.- A
reportsentry{"use": "otlp"}turns it on. A CI that setsOTEL_*for other tools does not make the gate send. - The endpoint, headers, service name and resource attributes come from
OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_HEADERS,OTEL_SERVICE_NAMEandOTEL_RESOURCE_ATTRIBUTES.with.endpointmay override the endpoint. - Each request times out at 5 seconds, is not retried, and a failure is not written.
- The reusable workflow takes
OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_EXPORTER_OTLP_HEADERSas optional secrets, passed to every job, because every job adds spans. - The verdict job sends every span, since the verdict
holds each phase's timings, and the trace id ties them to the run, one
trace per CI run. It sends
/v1/tracesonly for a timed run, and/v1/metricsalways, stamped with the clock's time.- With neither
with.endpointnor the variable set, the endpoint ishttp://localhost:4318, OpenTelemetry's default. - A header or resource list is
key=value,key=value, its values percent-encoded. A pair it cannot read is left out. service.namecomes fromOTEL_SERVICE_NAME, then the resource attributes, thenmutation-gate.- Like an alert's post, it follows no redirect. A failure repeats no URL, and a collector's answer is shown as one plain line.
- It names its endpoint by scheme, host and port alone, whether it wrote or not. A vendor may put its key in the userinfo, the path or the query.
- A signal's path goes before any query the endpoint holds.
- With neither
- Attributes.
- Spans carry the four conventional ones where the CI names them.
They also carry
mutation_gate.mode,changeorfull, and a shard's spans carrymutation_gate.shard. - Metrics use
mutation_gate.treefor a score. A new-code set isnew code in <package>. - They use
mutation_gate.statusfor a mutant's judgement and for a unit'srun,provedorcarried. - They use
mutation_gate.phasefor a duration:plan,shard, a step's name, orverdict. - A sum is this run's alone, as OTLP's delta temporality.
- Spans carry
mutation_gate.runner, the runner's name, where the flows give the timings the runner that judged the run, withRunTimings::ranBy(Identity).
- Spans carry the four conventional ones where the CI names them.
They also carry
- A
The JSON report gains a
runsection. It holds:- the phase durations and per-shard timings;
- the units run, proved and carried;
- the runner-minutes;
- the trace id.
The
costobject sits beside it. A team without a collector reads the same numbers from a file CI already keeps.Its shape:
{"id", "traceId", "phases": {"plan"?: {"start", "seconds"}, "verdict"?: {…}}, "shards": [{"shard", "start", "seconds", "steps": [{"step", "since", "seconds", "count"?}]}], "units": {"run", "proved", "carried"}, "wallSeconds", "runnerSeconds", "measured"}.startis an instant in UTC, as2026-09-30T11:50:00Z, andmeasuredis false where the runner time is estimated fromshards.setup(ADR-0017).run,costandsavingsare left out where the flows gave the verdict no timings.Phases are timed in
Cli, and handed toCoreas a value.- The flows read the PSR-20 clock (ADR-0001), and the verdict carries a
RunTimingsvalue. - Shards write their timings into their result files, which already hold
what the shard measured (ADR-0006), and the verdict merges
them: each shard from its start, the instant its result was written
less what it spent, with its steps, and the verdict from when it began.
What the run took is estimated, each job's setup from
shards.setup: the wall time from the first job's setup to the verdict's end, and the runner time of every shard and the verdict, each with its setup. - A shard's result names the steps its time went to under
measured.steps, in the order they started: each itsstep, the seconds after the shard began that it started (since), the seconds it took, and, where it handled more than one, how many (count). The steps are one closed set, whichever runner runs:held coverage,coverage,value reader coverage,value readers,preparing,mutation,reading,trial coverage,trials,baselines,confirmation,equivalence,survivors,controls,heavy partsandstatic check. A step with nothing to do is not named. - Each runner names the steps of its own run on the
MutationResultit returns, timed on its own clock from when the run began, and the runner contract checks that every runner names itsmutationstep with every mutant it judged. The flows time the steps around the runner: held coverage, retry, equivalence, survivors, controls and static check. A runner that names no step has its whole run namedmutation. - The console, JSON, cost and OTLP output all read these same numbers.
- The flows read the PSR-20 clock (ADR-0001), and the verdict carries a
Alternatives considered
| Option | Why it lost |
|---|---|
Only import <file>, a separate command | A second command writing the file init writes. It stays as an alias of init --from. |
Writing minMsi into the baseline | The baseline records what was achieved (ADR-0003), and nothing was measured. |
Dropping minMsi | Loses a policy the team chose. |
Splitting a tree around source.excludes | Multiplies trees and floors, and reverts to a phpunit.xml edit past twenty trees. |
| An ignore per excluded path | The excluded code is mutated at full cost, only to be left out. |
| Leaving Infection's ignores native | They stay without reasons and without ends, which ADR-0008 exists to stop. |
| Resolving ignores to mutant ids by running Infection | Infection never generates what its ignore patterns match, so there is nothing to resolve. |
Rewriting infection.json5 | A JSON5 rewrite loses the file's comments. |
| No GitLab Code Quality report | GitLab users would lose per-line survivors in the merge request. |
| Measured time only | Cannot say what reach and proofs spared, which is the figure worth showing. |
| Money by default, from list prices | Prices vary by plan and runner size and change over time. A wrong price in every pull request is worse than none. |
| No money at all | Teams that budget in money would compute it by hand. |
| A second sticky comment for cost | Two gate comments per pull request. ADR-0009 settled on one. |
| Leaving CI setup out of the estimate | Understates what a pull request costs. |
| A port for notifications | The Reporter port already takes the whole verdict and never changes an exit code. |
| A separate chat package | The HTTP client is already required. A split adds a version matrix and saves nothing. |
| An alert on every failing default-branch run | A red default branch would post on every merge until fixed. |
| Alerts on pull requests | Authors already have the sticky comment, and a channel would flood. |
${ENV} interpolation in every config string | Adds a template language to a config that is data (ADR-0002), and makes every value depend on the environment. |
| A literal URL with a warning | One leak per careless commit. |
| The whole JSON report as the webhook body | Megabytes per post, in a format built for another job. |
| No retry | A 429 from a busy workspace would lose the alert. |
| The OpenTelemetry SDK, required or suggested | Twelve or more packages and two Composer plugins for a handful of spans. |
| A JSON file only, with no OTLP | Most OpenTelemetry users expect to point a tool at an endpoint. |
| Metrics only, or traces only | Metrics alone lose where the time went. Traces alone bury scores in span attributes. |
| The gate's own attribute names throughout | Foreign to every backend's CI views. |
Exporting whenever OTEL_EXPORTER_OTLP_ENDPOINT is set | The gate would start sending in any CI that configured OpenTelemetry for something else. |
A separate metrics report | A second JSON format with overlapping counts. |
| Each reporter timing what it needs | The PR comment and the dashboard would disagree. |
Consequences
A project on Infection adopts the gate with one command, keeps its mutator settings where they were, and sees every place where the gate means something different.
Every pull request says what its check cost and what it was spared, in time, and in money for teams that give a rate.
A broken default branch is announced once, where the team talks, and its recovery is announced too.
Runs become telemetry in any OpenTelemetry backend, one trace per CI run across its jobs, with no new dependency.
Related
- ADR-0002:
init --from, and a config that holds no secret - ADR-0003:
trees[].exclude, andminMsias a declared floor - ADR-0004: what the Infection adapter keeps from
infection.json5 - ADR-0007:
trees[].excludein the key, andcostsleft out - ADR-0008: native ignores, and the entries that replace them
- ADR-0009: the new reporters, the JSON report's
costandrun, andtrend.json'sverdict - ADR-0011: the reusable workflow's secrets
- ADR-0013: shard overhead and
shards.setup - ADR-0017: measured job times on GitHub, and the savings line outside the collapsed section