ADR-0024: The gate runs on Bitbucket, Azure DevOps and Jenkins, comments on GitLab and Bitbucket without exposing a token to merge request code, plugs into Composer and hook managers, and aggregates an organisation
Status: Accepted Date: 2026-09-30
Context
The gate plans, runs and judges on GitHub Actions, GitLab CI, Buildkite, CircleCI and a JSON plan (ADR-0006). It comments and annotates only on GitHub (ADR-0009). It is started from the command line, git's hooks (ADR-0010) or CI. Its default branch publishes a badge, a trend and its savings to a data branch (ADR-0009, ADR-0017). Four gaps remain, and the facts that shape each, read in each platform's documentation, are these.
Three more CIs. A plan becomes jobs, a job learns its shard, the run names its ref, whether it is a pull request and its default branch, and a cache is either a trust boundary or not (ADR-0006, ADR-0007).
Bitbucket Pipelines Azure DevOps Jenkins A job count set at runtime No: parallelis static, at most 100 steps per pipeline; dynamic pipelines, a generated YAML uploaded by a pipe, are a Premium featureYes: strategy: matrixtakes a runtime expression holding a JSON object from an output variable; it always makes at least one jobYes, in a scriptblock: a map of closures handed toparallelThe shard BITBUCKET_PARALLEL_STEP(0-based) andBITBUCKET_PARALLEL_STEP_COUNTthe matrix leg's variables, or System.JobPositionInPhaseandSystem.TotalJobsInPhaseunderparallel: Nthe closure's own argument Files between jobs artifacts, kept 14 days, 1 GB each; a parallel group's artifacts may not reach its siblings PublishPipelineArtifactandDownloadPipelineArtifactstashandunstashThe verdict after a failed shard a finalstep, which runs whatever the others did, and which cannot deploycondition: succeededOrFailed()post { always { … } }Ref, pull request, run BITBUCKET_BRANCH,BITBUCKET_PR_ID,BITBUCKET_BUILD_NUMBERBuild.SourceBranch,System.PullRequest.PullRequestNumber(GitHub) orSystem.PullRequest.PullRequestId,System.PullRequest.TargetBranch,Build.BuildIdBRANCH_NAME,CHANGE_ID,BUILD_TAG,GIT_COMMITDefault branch not named not named not named Cache shared by every branch of the repository: no boundary a pull request build reads its source's, its target's, main's andmaster's caches and writes only its own; any other run reads its own branch's,main's andmaster's: a boundarynone built in Forks pull requests from forks start no pipeline fork builds get no secrets by default depends on the SCM plugin No Azure variable names the YAML file a pipeline runs. Azure's
System.AccessTokenreaches a step only when the pipeline maps it into that step's environment.On Bitbucket, repository and workspace variables, secured ones included, reach every branch's pipeline, and each branch's author controls its
bitbucket-pipelines.yml. A deployment environment's variables reach only the step that deploys to it, one step per environment in a pipeline, and restricting an environment's deployments to a branch takes Premium. While one pipeline deploys to an environment, Bitbucket pauses any other at its step that deploys there; once the first deployment ends, the paused pipeline is resumed or rerun by hand. A step can request an OpenID Connect token,BITBUCKET_STEP_OIDC_TOKEN, whose subject names a branch only through a deployment environment.Comments beyond GitHub.
- GitLab. A merge request note is created and updated through the
notes API, and a job finds its own note by its author.
CI_JOB_TOKENmay only read notes, so posting one needs a project or group access token. A note holds up to 1,000,000 characters. A line note is a discussion with a position built from the merge request's versions. The Code Quality report appears in the merge request widget on every tier, and on the diff on Ultimate only. A fork's merge request pipeline runs in the fork, with the fork's variables. - Bitbucket. A pull request comment is created and updated through the
pull request comments API, with a token that has
pullrequest:write. Code Insights holds a report per commit with up to 1,000 annotations, posted at most 100 per request. Inside Pipelines, Code Insights is reachable with no credential through the proxy atlocalhost:29418. Whether that proxy also authorises comments is not documented. - The bar. A GitHub comment is posted with the job's own
GITHUB_TOKEN: short-lived, scoped to the job, read-only for forks. A GitLab or Bitbucket token is long-lived. A job that runs merge request code, as the verdict job does throughcomposer installand the gate in the merge request's ownvendor, can read any variable in its environment. ADR-0019 keeps pull request content away from anything that can write.
- GitLab. A merge request note is created and updated through the
notes API, and a job finds its own note by its author.
Composer and hook managers.
- A Composer plugin is a package of type
composer-pluginwith aPluginInterface, and aCommandProvideraddscomposer <command>. Composer 2.2 and later require it inallow-plugins. Non-interactive Composer fails on a plugin that is not listed there, unless the plugin setsextra.plugin-optional: true(Composer 2.5.3 and later), which makes Composer skip it. A rootscriptsentry makescomposer <name>work with no plugin, and a script times out after 300 seconds unlessComposer\Config::disableProcessTimeoutcomes first. - CaptainHook hands a hook's stdin to an action as the
{$STDIN}placeholder, shell-escaped. - GrumPHP runs only
pre-commitandcommit-msg, notpre-push. A third-party task reaches it through YAML its extension imports, and its extensions cannot load PHP from its scoped PHAR. - The pre-commit framework has no PHP language.
language: unsupportedruns a command from the user's environment. A hook withstages: [pre-push]receives the refs asPRE_COMMIT_FROM_REFandPRE_COMMIT_TO_REF, not on stdin.
- A Composer plugin is a package of type
An organisation's view. GitHub Pages deploys from Actions (
actions/upload-pages-artifact,actions/deploy-pages, withpages: writeandid-token: write). A private Pages site needs Enterprise Cloud, and on Free its repository must be public. The REST API allows cross-origin requests from any origin.raw.githubusercontent.comdocuments no cross-origin policy.
Decision
Three more CIs
ci.plangainsbitbucket,azureandjenkins, each rendering a plan the way its CI allows.- Azure DevOps.
plan --ci=azuresets an output variable holding the matrix,{"s1": {"SHARD": "1"}, …}, with leg names of letters and digits only, which themutationjob'sstrategy: matrixreads. A plan with no shards emits one leg that passes having run nothing, because Azure always makes at least one job. The verdict job runs withcondition: succeededOrFailed(). - Jenkins.
plan --ci=jenkinsprints the JSON plan. The documented Jenkinsfile reads it with the Pipeline Utility Steps plugin'sreadJSONand builds the map it hands toparallel, one closure per shard, each on an agent of its own and naming its shard inSHARD, with the plan and each shard's results passed bystashandunstash. It runs the verdict inpost { always { … } }. A pull request is read fromCHANGE_ID, and a tag,TAG_NAME, has no scope, as on Bitbucket. Only a multibranch project sets these, so the Jenkinsfile runs from one. - Bitbucket Pipelines. Parallelism is fixed in the pipeline, as on
CircleCI (ADR-0006):
plan --shards=<N>, and each step's shard isBITBUCKET_PARALLEL_STEPplus 1. The verdicts of the default branch's pipeline and of the custom pipelinemutation-full, the full run, are each the last ordinary step, deploying to the environment that holds the store's keys, because afinalstep cannot deploy. After a failed shard Bitbucket skips such a verdict, and the pipeline is red with no cannot judge report, and while one such verdict deploys, Bitbucket pauses any other at its own. A pull request's verdict is thefinalstep. The README also shows the dynamic-pipelines form for Premium workspaces. ADR-0048 amends this: a pull request'sfinalstep sends the comment, and its verdict is an ordinary step before it.
This amends ADR-0006, whose two tables gain a row for each, and ADR-0007, whose list of the run a proof names gains three entries.
CI Ref Pull request Default branch The run a proof names Bitbucket BITBUCKET_BRANCHBITBUCKET_PR_IDis setci.defaultBranchbitbucket:<BITBUCKET_BUILD_NUMBER>Azure DevOps Build.SourceBranchBuild.ReasonisPullRequest, withSystem.PullRequest.PullRequestNumberwhere Azure sets it (a GitHub pull request, whose id is not its number), andSystem.PullRequest.PullRequestIdotherwiseci.defaultBranchazure:<Build.BuildId>Jenkins BRANCH_NAMECHANGE_IDis setci.defaultBranchjenkins:<BUILD_TAG>- Azure DevOps.
None of the three names its default branch, so
ci.defaultBranchdecides, and failing that git'sorigin/HEAD, and failing thatmain, as for the JSON plan and CircleCI (ADR-0006).init --cifor these three writesci.defaultBranchinto the config it writes, and where a config is kept that does not set it, says to set it to the branch the template is written for.Each CI's definition file is named for reach and the proof key.
ci.bitbucket.definition(a path,bitbucket-pipelines.ymlby default),ci.azure.definition(azure-pipelines.yml) andci.jenkins.definition(Jenkinsfile) name the file that runs the gate, asci.buildkite.definitiondoes. The file each names reaches everything and is read by every key through ADR-0005's rule 1 and ADR-0007's item 6, so the path affects results. The rest of these keys judge or report only. Where the named file is a template another pipeline takes in, asinit --ci=azurewrites it, that other pipeline is outside the key: a change to it, such as its PHP image, reaches nothing, as with Buildkite's uploading pipeline. This amends ADR-0005.Each template keeps the ledger where its CI draws a trust boundary.
- Azure DevOps: the directory store in the
Cache@2task, keyed by the digest of the scope, with the default branch's key restored second where Azure lets the run read that branch's caches: a pull request reads its target's, and any other run reads onlymain's andmaster's besides its own. A pull request build cannot write the target branch's cache, so this is a boundary, as GitHub's is. - Bitbucket and Jenkins: an S3-compatible store (or any store whose writes need credentials), with credentials only default-branch builds hold. Bitbucket's caches are shared by every branch and Jenkins has none, so neither is a boundary. This is ADR-0007's reasoning for Buildkite and CircleCI.
- Bitbucket's credentials are variables of the deployment environment
mutation-gate-store, which only the deploying verdicts name. Restricted to the default branch, which takes Premium, it is the boundary; without that restriction any branch whose pipeline names it gets the keys, and the template and README say so. Every other step, the default branch's plan included, holds no keys and reads the default branch's ledger throughproofs.store.with.publicUrl(ADR-0013). - Jenkins' credentials are the username-and-password credentials
mutation-gate-store, which only the default branch's verdict binds. A credential reaches every build of the folder that holds it, and a branch's author writes its Jenkinsfile, so held in a folder whose multibranch pipeline builds the default branch alone it is the boundary; held beside every branch, any branch whose Jenkinsfile Jenkins runs gets the keys, and the template and README say so. Every other step holds no keys and reads the default branch's ledger throughproofs.store.with.publicUrl.
This amends ADR-0007.
- Azure DevOps: the directory store in the
What the runners never see grows with these CIs. Azure's
SYSTEM_ACCESSTOKEN, theAZURE_DEVOPS_EXT_PATthataz devopsreads, and Bitbucket'sBITBUCKET_STEP_OIDC_TOKENjoin what every run withholds from the runner (CiPlan::withheld, ADR-0004), as do the comment tokens. Jenkins hands a build no credential of its own, so its plan adds none. A project adds any other Bitbucket or Jenkins credential it passes torunner.withhold.init --ci=bitbucket|azure|jenkinswrites a pinned template, by the rules of ADR-0015. Azure's and Bitbucket's templates are validated against each provider's published schema, which the test fetches from its URL into the system's temporary directory and holds to a SHA-256 digest, failing, never skipping, where the fetch fails or the digest differs. Azure's URL names the commit it is read at; Bitbucket's names no version, so the digest says when it changed. Jenkins publishes no schema for a Jenkinsfile, so its template is held by its snapshot test alone. This amends ADR-0015.- Azure DevOps.
init --ci=azurewrites the gate's jobs as a template,.azure/mutation-gate.yml, and prints the- template:line that takes them into the pipeline Azure runs, which it never edits (ADR-0015). A configinitwrites names that template asci.azure.definition, as it names Buildkite's pipeline, and where a config is kept,initsays to.Cache@2saves only from a job that succeeds, so a last job, run whatever the verdict decided, saves the ledger the verdict wrote. - Bitbucket Pipelines.
init --ci=bitbucketprints the pipelines to add tobitbucket-pipelines.yml, which it never edits: the default branch's, every pull request's andmutation-full's, each a plan step, four parallel shard steps and the verdict, each step cloning the full history. A configinitwrites setsci.defaultBranch. - Jenkins.
init --ci=jenkinsprints the declarative pipeline to add to the Jenkinsfileci.jenkins.definitionnames, which it never edits: a plan stage, the shards and the verdict, with acrontrigger for the full run on the default branch. A configinitwrites setsci.defaultBranch.
- Azure DevOps.
Comments beyond GitHub
A long-lived token never shares a process with merge request code.
- A separate job,
mutation-comment, posts the comment. It runs the released PHAR or container image of the gate (ADR-0022), pinned by version in the template, and never the merge request'svendor. - It reads the verdict job's JSON report as untrusted data. Only fields
valid against
resources/report.schema.jsonare rendered, and each is escaped as ADR-0009 escapes everything the project wrote. - The token is a masked CI variable passed to that job alone. The verdict job never has it, and the runners withhold it everywhere else.
- This is ADR-0019's relay pattern, serving users' CIs too. This amends ADR-0019.
- ADR-0048 amends this: the job runs
deliver, which posts the markdown the verdict job left in its delivery under--deliver-later, rather than rendering the comment again from the JSON report. - The token for GitLab is a project access token with the scope
apiand the lowest role that can post merge request notes. The build's first step proves which role that is, starting with Reporter. For Bitbucket it is a repository access token withpullrequest:writeonly.
- A separate job,
Each platform's own surface stands for GitHub's line annotations.
- GitLab: the
gitlabCode Quality report (ADR-0016), in the merge request widget on every tier and on the diff on Ultimate. No line notes are posted. - Bitbucket: a Code Insights report,
mutation-gate, of typeBUG,FAILEDwhen the verdict fails. It carries one annotation per mutant counted as not killed, at most 1,000, ranked as GitHub's annotations are (ADR-0009). The verdict job posts it through the pipeline's credential-free proxy, which holds no token to leak.
- GitLab: the
The comment has its planned state here too. The pipeline runs the
mutation-commentjob afterplan, where it reads the plan's JSON and posts the planned state (ADR-0019). It runs again after the verdict, where it posts the judged state. ADR-0048 amends this: it posts the planned state the plan left in its delivery.Mentions, forks and config.
- An
@in anything the project wrote is escaped: GitLab's@and Bitbucket's@{…}. Code owners' mentions follow ADR-0022. GitLab's CODEOWNERS sections ([Section],^[Optional], a section's default owners) are parsed on GitLab. - A fork's pipeline runs in the fork on GitLab, and not at all on Bitbucket, with none of the parent's variables. No comment is posted, and the job says why, as GitHub's reporter does (ADR-0009).
reportsgainsgitlab-commentandbitbucket-comment, each withwith.tokenEnv(MUTATION_GATE_GITLAB_TOKENandMUTATION_GATE_BITBUCKET_TOKENby default), andbitbucket-insights. A literal token in the config is refused, as a webhook URL is (ADR-0016). They report only.
This amends ADR-0009, and ADR-0016.
- An
Composer and hook managers
composer mutateis a root scriptinitadds.- The script is
"mutate": ["Composer\\Config::disableProcessTimeout", "mutation-gate"]: Composer's 300-second limit off, then the gate, socomposer mutate [args]runsmutation-gate [args]with no time limit. Composer hands a script its arguments and keeps its options, so the gate's options follow--:composer mutate -- run --budget=15m. initasks, last, whether to add it. Where the answer is yes, it writes the script into the project'scomposer.jsonwhen nothing else in the file changes: the file is laid out as Composer writes it, and has nomutatescript yet. Otherwise, and with--dry-run, it prints the line to add to the scripts.- The gate is a plain library that needs no
allow-pluginsentry (ADR-0001, alternatives), and no package of its own adds the command: the gate is published to no registry (ADR-0011), and a plugin published nowhere is one more repository a project would pin.
- The script is
Hook managers call the CLI, and the pre-commit framework reads one file the repository carries.
- CaptainHook: a
pre-pushactionvendor/bin/mutation-gate pre-push --stdin={$STDIN}, and apre-commitactionvendor/bin/mutation-gate pre-commit. - GrumPHP: a
shelltask runningvendor/bin/mutation-gate pre-commit, which never blocks (ADR-0015). GrumPHP has nopre-push, and the README says so. - pre-commit: the repository carries
.pre-commit-hooks.yaml, with the hooksmutation-gate-pre-push(stages: [pre-push],language: unsupported,entry: vendor/bin/mutation-gate pre-push,pass_filenames: false,always_run: true) andmutation-gate-pre-commit. Each needs pre-commit 4.4.0, the first release withlanguage: unsupported. The configinitwrites pins the repository to the gate's commit, as a CI definition pins it (ADR-0015), installs both hook types throughdefault_install_hook_types, and sets a hook'sentrywhere Composer links the gate elsewhere. - No code of the gate depends on any hook manager's classes.
init --hook=captainhook|grumphp|pre-commitwrites the manager's config where the manager reads none, and otherwise prints the block to add (ADR-0010); for GrumPHP, any of the six files it looks for counts. It then names the command that installs the manager's hooks.
This amends ADR-0010 and ADR-0017.
- CaptainHook: a
pre-pushreads its refs from three places. Git's hook input on stdin (ADR-0010),--stdin=<text>for CaptainHook's placeholder, and, where there is neither,PRE_COMMIT_FROM_REFandPRE_COMMIT_TO_REF. Each is parsed into the same refs. Where the remote holds none of a ref's history, the framework sets onlyPRE_COMMIT_LOCAL_BRANCHandPRE_COMMIT_REMOTE_BRANCH, and the push is read as a new ref at the commit the working tree is at. Each line must be a local ref, a local SHA, a remote ref and a remote SHA, the SHAs in hex, and anything else is refused. The.pre-commit-hooks.yamlhook ids are public API. This amends ADR-0010 and ADR-0011.
An organisation's view
mutation-gate dashboardbuilds a static site on a schedule.mutation-gate dashboard --org=<org> --out=<dir>reads each repository'smutation-gatedata branch through GitHub's API with a read-only token, and writes one self-contained HTML page and adashboard.json.- A workflow in an organisation repository runs it daily and on
workflow_dispatch, and deploys<dir>withactions/deploy-pages. It runs on those two triggers only, and runs no pull request content. - The repositories are those with the topic
dashboard.topic(a string,mutation-gateby default), or the listdashboard.repositories. Both report only. - The page loads nothing at view time. It shows, per repository, the verdict, the score, the trees below their floors and the time saved in the last 30 days, with sparklines drawn as SVG by the trend renderer (ADR-0009), in tables that sort.
- The command lives in
Cli, reads throughAdapter\GitHub, and aggregates inCore. dashboard.repositoriesnames repositories within the organisation. A named repository GitHub does not return is listed as private, with why, so a public site leaves it out. The command reads its keys from the config file alone, so the repository that builds the site needs no runner.dashboard.jsonis"format": 1: the organisation, the time, and each repository's name, address, whether it is private, and its commit, time, verdict, score, trees below their floors and savings, or why it published nothing.
Each repository publishes
summary.jsonfor it. The default branch's verdict writes it besidebadge.json,trend.json,trend.svgandsavings.json, and the publish job publishes it with them:{ "format": 1, "commit": "3f9a1c2…", "time": "2026-09-30T10:00:00Z", "verdict": "passed", "score": 87.41, "trees": [ { "path": "src", "floor": 83.41, "score": 87.41 } ], "newCode": { "floor": 100 }, "savings": { "last30Days": 147600 } }savings.last30Daysis in seconds. A set with nothing to mutate has noscore, a tree held to no floor nofloor, and a run with no history of what it saved nosavings.resources/summary.schema.jsondescribes it. Its format is public API. This amends ADR-0009 and ADR-0011.A public site never shows a private repository. Private and internal repositories are left out unless
--include-privateis given. Thendashboardrefuses to render unless the Pages site is private, which it reads from the Pages API for the repository it runs in,GITHUB_REPOSITORY: GitHub must answerpublic: false. The token reads contents only. This amends ADR-0011.
Alternatives considered
| Option | Why it lost |
|---|---|
A fixed --shards=<N> on all three CIs | Azure and Jenkins can fan out at runtime, and a fixed count holds N runners for a one-file change and cannot shrink to none. |
| Each CI's REST API for the default branch | Needs a token in every job to learn one name that ci.defaultBranch gives. |
| The directory store in each CI's cache everywhere, with a warning | On Bitbucket any branch could plant proofs the default branch trusts. |
| The verdict job posting the comment, as on GitHub | Any merge request author who can push a branch could print a long-lived token from a test. |
| A discussion per survivor line on GitLab | Visible on every tier, and one notification per survivor per push, which ADR-0009 rejected for GitHub. |
| The judged state only, with no planned state | Loses the early signal the planned state exists for. |
An optional Composer plugin package, nightworksio/mutation-gate-composer | A package of its own needs a registry or a repository a project pins beside the gate, and an allow-plugins entry, for the command one root script gives. |
| The plugin inside the main package | Every consumer would have to allow it, the cost ADR-0001 rejected for discovery. |
| A CaptainHook action class and a GrumPHP extension task | Ties the gate to each tool's PHP API, and GrumPHP's extensions cannot load PHP from its scoped PHAR. |
| A page that fetches every repository's files in the browser | Public repositories only, and it rests on a cross-origin header nobody documents. |
| Each repository pushing into the dashboard repository | Every repository would hold a token that can write another repository. |
The dashboard reading the baseline and trend.json itself | Two reads per repository, and the floors of trees that are gone. |
| Every repository the token can read | One token with too much reach would publish private names and scores. |
Consequences
The gate plans and judges on seven CIs, with each template honest about where its trust boundary is.
Merge requests and pull requests get the gate's comment on GitLab and Bitbucket without a long-lived token ever sharing a process with the code under review.
Hooks and Composer reach the gate from whatever a project already uses, and the CLI stays the one interface.
An organisation sees every repository's verdict, floors and savings on one page that needs no server, and that shows a private repository only on a private site.
Related
- ADR-0001: discovery with no Composer plugin
- ADR-0004: what the runners withhold
- ADR-0005: the CI definitions that reach everything
- ADR-0006: the CiPlan port and its tables
- ADR-0007: the key's CI definitions, and where each CI's trust boundary is
- ADR-0009: the sticky comment, annotations and the published files
- ADR-0010: the pre-push hook and its input
- ADR-0011: public API, and the one repository
- ADR-0015: the CI templates, and the pre-commit hook
- ADR-0016: the
gitlabreport, and credentials only from the environment - ADR-0017:
init's questions, and the savings the dashboard shows - ADR-0019: the relay pattern, and the planned state
- ADR-0021: the boundary rules for first-party plugins
- ADR-0022: code owners' mentions, and the PHAR and image the comment job runs
- ADR-0048: the comment jobs relay the delivery, Bitbucket's comment is found by editing, and a Bitbucket pull request's
finalstep sends it