Skip to the content
Howdah

being built · no release yet

Search

Skip the list of pages

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: mutators with their profiles and settings, bootstrap, phpUnit, initialTestsPhpOptions and testFrameworkExtraArgs (ADR-0004). The rest either becomes something of the gate's or is refused by it:

    • minMsi is a floor;
    • source decides the trees;
    • ignore and ignoreSourceCodeByRegex are native markers, refused by default (ADR-0008);
    • the logs are 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 ignore patterns match, so no mutant id can be recovered from them. source.excludes has 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 being no_text, and takes optional Block Kit blocks. It answers 400 invalid_payload, 403 action_prohibited or 404 no_service. Its channel, name and icon cannot be overridden.
    • A Discord webhook takes content (up to 2,000 characters), up to 10 embeds, and an optional username and avatar_url.
    • A webhook URL is a credential, and config files are committed.
  • Watching runs over time. OpenTelemetry is how CI telemetry is collected.

    • open-telemetry/sdk 1.15 requires, among others, php-http/discovery and tbachert/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

  1. init --from=<file> starts the gate's config from an Infection config.

    • It reads infection.json5, infection.json or a .dist of either.
    • It writes the gate's config in --format, as init does (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 testFramework other than phpunit stops it with exit code 2 before anything is written (ADR-0004).
    infection.json5Becomes
    source.directoriestrees[].path, one tree per directory. trees replaces the tree source's list whole (ADR-0002), and the report says where phpunit.xml's <source> differs
    source.excludestrees[].exclude of the tree holding each
    minMsi, minCoveredMsitrees[].floor, and uncovered
    timeouttimeouts.seconds
    timeoutsAsEscaped: truetimeouts.mode: unjudged
    mutators.<Name>.ignore, global-ignore, ignoreSourceCodeByRegex, global-ignoreSourceCodeByRegexignores.entries, or ignores.native: allow
    logs.html, logs.stryker.reporta reports entry html
    logs.jsona reports entry json, as a suggestion. The gate's JSON is its own format
    logs.gitlaba reports entry gitlab
    logs.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.json and logs.text in the config it generates
    maxTimeoutsdropped: 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)
    mutators profiles and settings, bootstrap, phpUnit, initialTestsPhpOptions, testFrameworkExtraArgs, staticAnalysisTool, staticAnalysisToolOptionsstays in the file; the adapter reads it
  2. minMsi becomes 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.

    • minCoveredMsi sets uncovered: exclude and, when minMsi is absent, the floor.
    • The report ends: run mutation-gate locally 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.
  3. 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.
  4. Infection's ignores are converted where they map, and allowed where they do not.

    • ignore patterns become path entries. mutators.<Name>.ignore: ["App\\Money::add"] becomes {path: <the class's file, from the autoload>, mutator: <Name>}. A Class::method or Class::method::line pattern 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 of composer.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-ignore and 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-ignore holds 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: allow and 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. ignoreSourceCodeByRegex has no equivalent, so where any exists the import sets ignores.native: allow and 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.
  5. A gitlab report 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), severity and location.path with location.lines.begin.
    • severity is major for a mutant in a failing set, and minor otherwise.
    • GitLab's merge request widget then shows survivors per line, the view ADR-0009 gives GitHub through annotations.
  6. 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.setup is 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).
  7. Money is shown only when the team gives a rate. costs.perRunnerMinute is {amount, currency}, and unset by default. When it is set, each time figure is shown with its price. It sits under costs, which the proof key leaves out (ADR-0007). The flows hand the verdict the rate as a Core\Cost\Rate, and the cost is priced with Cost::pricedAt(Rate). The config's Price stays with the config, since nothing a verdict carries names a config type.

  8. 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 cost object.
    • 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, from shards.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 cost object is {"planned": {"wallSeconds", "runnerSeconds", "price"?}, "measured": {…}, "spared": {"seconds", "price"?}, "setupEstimated", "perRunnerMinute"?}. Each price and perRunnerMinute is {"amount", "currency"}, present only where a rate is set.
  9. Chat alerts are reporters: slack, discord and webhook.

    • They are built-in Reporter adapters (ADR-0009). They send with symfony/http-client, which is already required (ADR-0001).
    • A failed post says so, and never changes the exit code.
  10. 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 lowered entry 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 judgement cannot-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 as cannotJudge, and JUnit as a failing case of type cannot-judge in its run suite.

    • The previous state comes from the newest entry of trend.json, which gains a verdict field (ADR-0009). It is restored into --publish-dir as the badge is.

    • With no previous state, only a failure alerts.

    • How a change is read. Each trend.json entry also records each tree's floor, under floors. 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 lowered gives.

      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.

  11. A webhook URL comes from the environment, never from the config.

    • Each reporter reads the URL from the environment variable its with.urlEnv names:
      • slack: MUTATION_GATE_SLACK_URL by default;
      • discord: MUTATION_GATE_DISCORD_URL by default;
      • webhook: MUTATION_GATE_WEBHOOK_URL by default.
    • A literal url in with is 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 verdict job only, with MUTATION_GATE_WEBHOOK_SECRET. The action reads them from its deliver step's env.
  12. 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: text as 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 at resources/webhook.schema.json. When MUTATION_GATE_WEBHOOK_SECRET (or the variable with.secretEnv names) is set, the request carries X-Mutation-Gate-Signature: t=<unix seconds>,sha256=<HMAC-SHA256 of "<t>.<body>">. t is the reporter's clock when it sends. A receiver recomputes the HMAC over t, a dot and the raw body, compares it in constant time, and rejects a t more 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.

    • 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.

  13. 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-After up to 30 seconds.
    • After that the reporter says not written, with the status and the body.
    • A Retry-After given 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.
  14. otlp exports traces and metrics as OTLP/HTTP JSON, without the SDK.

    • It is a built-in Reporter adapter. It POSTs to /v1/traces and /v1/metrics with symfony/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.
  15. 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), where run is 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, and verdict.
    • 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.
  16. 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.id and cicd.pipeline.name.
    • The gate's own attributes are mutation_gate.tree, mutation_gate.status, mutation_gate.shard, mutation_gate.runner and mutation_gate.mode.
    • None is per mutant or per file, so cardinality is bounded by trees times statuses.
  17. otlp is opt-in, and reads OpenTelemetry's own variables.

    • A reports entry {"use": "otlp"} turns it on. A CI that sets OTEL_* 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_NAME and OTEL_RESOURCE_ATTRIBUTES. with.endpoint may 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_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS as 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/traces only for a timed run, and /v1/metrics always, stamped with the clock's time.
      • With neither with.endpoint nor the variable set, the endpoint is http://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.name comes from OTEL_SERVICE_NAME, then the resource attributes, then mutation-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.
    • Attributes.
      • Spans carry the four conventional ones where the CI names them. They also carry mutation_gate.mode, change or full, and a shard's spans carry mutation_gate.shard.
      • Metrics use mutation_gate.tree for a score. A new-code set is new code in <package>.
      • They use mutation_gate.status for a mutant's judgement and for a unit's run, proved or carried.
      • They use mutation_gate.phase for a duration: plan, shard, a step's name, or verdict.
      • 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, with RunTimings::ranBy(Identity).
  18. The JSON report gains a run section. It holds:

    • the phase durations and per-shard timings;
    • the units run, proved and carried;
    • the runner-minutes;
    • the trace id.

    The cost object 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"}. start is an instant in UTC, as 2026-09-30T11:50:00Z, and measured is false where the runner time is estimated from shards.setup (ADR-0017). run, cost and savings are left out where the flows gave the verdict no timings.

  19. Phases are timed in Cli, and handed to Core as a value.

    • The flows read the PSR-20 clock (ADR-0001), and the verdict carries a RunTimings value.
    • 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 its step, 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 parts and static check. A step with nothing to do is not named.
    • Each runner names the steps of its own run on the MutationResult it returns, timed on its own clock from when the run began, and the runner contract checks that every runner names its mutation step 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 named mutation.
    • The console, JSON, cost and OTLP output all read these same numbers.

Alternatives considered

OptionWhy it lost
Only import <file>, a separate commandA second command writing the file init writes. It stays as an alias of init --from.
Writing minMsi into the baselineThe baseline records what was achieved (ADR-0003), and nothing was measured.
Dropping minMsiLoses a policy the team chose.
Splitting a tree around source.excludesMultiplies trees and floors, and reverts to a phpunit.xml edit past twenty trees.
An ignore per excluded pathThe excluded code is mutated at full cost, only to be left out.
Leaving Infection's ignores nativeThey stay without reasons and without ends, which ADR-0008 exists to stop.
Resolving ignores to mutant ids by running InfectionInfection never generates what its ignore patterns match, so there is nothing to resolve.
Rewriting infection.json5A JSON5 rewrite loses the file's comments.
No GitLab Code Quality reportGitLab users would lose per-line survivors in the merge request.
Measured time onlyCannot say what reach and proofs spared, which is the figure worth showing.
Money by default, from list pricesPrices vary by plan and runner size and change over time. A wrong price in every pull request is worse than none.
No money at allTeams that budget in money would compute it by hand.
A second sticky comment for costTwo gate comments per pull request. ADR-0009 settled on one.
Leaving CI setup out of the estimateUnderstates what a pull request costs.
A port for notificationsThe Reporter port already takes the whole verdict and never changes an exit code.
A separate chat packageThe HTTP client is already required. A split adds a version matrix and saves nothing.
An alert on every failing default-branch runA red default branch would post on every merge until fixed.
Alerts on pull requestsAuthors already have the sticky comment, and a channel would flood.
${ENV} interpolation in every config stringAdds a template language to a config that is data (ADR-0002), and makes every value depend on the environment.
A literal URL with a warningOne leak per careless commit.
The whole JSON report as the webhook bodyMegabytes per post, in a format built for another job.
No retryA 429 from a busy workspace would lose the alert.
The OpenTelemetry SDK, required or suggestedTwelve or more packages and two Composer plugins for a handful of spans.
A JSON file only, with no OTLPMost OpenTelemetry users expect to point a tool at an endpoint.
Metrics only, or traces onlyMetrics alone lose where the time went. Traces alone bury scores in span attributes.
The gate's own attribute names throughoutForeign to every backend's CI views.
Exporting whenever OTEL_EXPORTER_OTLP_ENDPOINT is setThe gate would start sending in any CI that configured OpenTelemetry for something else.
A separate metrics reportA second JSON format with overlapping counts.
Each reporter timing what it needsThe 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.

  • ADR-0002: init --from, and a config that holds no secret
  • ADR-0003: trees[].exclude, and minMsi as a declared floor
  • ADR-0004: what the Infection adapter keeps from infection.json5
  • ADR-0007: trees[].exclude in the key, and costs left out
  • ADR-0008: native ignores, and the entries that replace them
  • ADR-0009: the new reporters, the JSON report's cost and run, and trend.json's verdict
  • 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