ADR-086: Merge Trains Are the Merge Gate — the Car DAG Blocks on a Train, on the 4xlarge Runner, with No Retries

Status

Accepted (2026-11-06), #2923 (plan merge-trains-gate U4, epic &111). The project settings flip right after the MR that carries this ADR merges, which is the last MR to land the old way.

Supersedes: ADR-080 § D3 (the server-side battery is a detector and the local pre-push battery is the merge gate) and § D4 (the host firewall rules, which no job has needed since the devstack went host-free in #2922). Stands: ADR-080 § D1 (the battery runs server-side) and § D2 (one battery body, now cargo xtask ci battery, which both validate and the CI battery job call).

Amended (2026-11-10, #3046): the one battery body is cargo xtask test --integration, which validate and the car job both run; cargo xtask ci is gone (D2, amended 2026-11-10).

Ruling (the maintainer, 2026-11-05): the hook shrinks to a five-minute gate; merge trains on the 4xlarge are the gate; no retries on the train.

Context

Under ADR-080 the merge gate was the local pre-push hook: the whole battery, 23 to 41 minutes per push on the maintainer’s host. One devstack served every car, so cars waited on each other. A hook can also be skipped, and nothing server-side enforced a green run, because only_allow_merge_if_pipeline_succeeds was off by decision.

Plan merge-trains-gate removed what kept the gate on that host:

  • the battery is nine cargo xtask ci <stage> verbs, and .gitlab-ci.yml only orchestrates them (#1739);

  • the devstack is host-free: container DNS, no published ports, and the stack and craig-tools run as sibling containers (#2922);

  • the pre-push hook runs cargo xtask validate --profile fast (#2921).

The runner smoke (MR !2153, pipeline 3034044930, recorded on #2923) found the dhs-aws-autoscaler-docker-4xlarge runner usable for this project. Each job gets its own autoscaled VM (16 vCPU, 61.6 GiB, a 991 GB disk) and drives the VM’s own Docker through a mounted socket. A docker:dind service does not start there, and /builds is a per-job Docker volume, which the stack stages bind-mount onto its VM path (testing-reference § .gitlab-ci.yml).

Decision

D1 — A merge train is the merge gate

The project runs merged-results pipelines and merge trains, and a merge needs a green pipeline: merge_pipelines_enabled, merge_trains_enabled and only_allow_merge_if_pipeline_succeeds are true; allow_merge_on_skipped_pipeline and merge_trains_skip_train_allowed are false. Each car’s train pipeline tests main merged with every car ahead of it plus this one. A car merges only when that pipeline is green. A red car is dropped from the train, and the cars behind it restart without it.

D2 — On a train the car DAG blocks and runs whole; on a plain MR it advises

Train pipelines arrive as $CI_PIPELINE_SOURCE == "merge_request_event"; $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train" tells them apart. The .car-rules template’s first rule matches that and sets allow_failure: false with no changes:, so every car runs check, build, battery and e2e, whatever it touched, and any red job drops the car. A plain MR pipeline (merged-results or detached) meets the second rule instead: the code-and-stack changes: filter with allow_failure: true, which gives early signal and blocks nothing. On main, check and build run to write the caches the cars read (.car-cache-writer, .stack-cache-writer). They stay advisory there.

Amended (2026-11-06, #2937): on a plain MR only check (and the required jobs) runs on its own. build, battery and e2e meet .stack-rules, which makes them when: manual there (early signal on demand). The reason: GitLab adds a car to the train only after its MR pipeline has finished, every job included, so an advisory DAG on the MR made each car run the DAG twice, serially, before it landed. On a train the four jobs run and block, unchanged.

Amended (2026-11-06, #2941): check is three jobs, lint, clippy and unit, each needs: [], so a red lint no longer hides the other two. Each keeps .car-rules (blocking on a train, advisory and path-filtered on a plain MR); only clippy runs on main, as the cargo cache’s one writer. Read check above as those three.

The required jobs outside the DAG never allow failure: secrets-policy, cargo-audit, cargo-deny, docs-xref-check and docs-content-lints. Each keeps its own path filter. That filter is the set of inputs the job reads, so a car that leaves them unchanged cannot change the job’s answer.

Amended (2026-11-06, #2658): cargo-audit is retired; cargo-deny is the one RustSec scanner, so the required jobs outside the DAG are secrets-policy, cargo-deny, docs-xref-check and docs-content-lints. cargo-deny also runs on every scheduled pipeline, where a new advisory against an unchanged lock shows; on a train it stays filtered to the dependency graph’s inputs.

Amended (2026-11-07, #2982, #2984; plan ci-compile-once U2, U3): the car DAG is ci-image → xtask → check ∥ build ∥ docs → battery ∥ e2e. check is one job again, xtask ci check, which runs lint, clippy and unit each to completion on one VM, so the #2941 amendment’s property holds without three jobs; read check above as that job. The xtask job compiles xtask once and runs the docs' content lints, replacing docs-content-lints; the docs job, one Antora build that is also the review environment, replaces docs-xref-check and review. On a train exactly those seven jobs run whatever the car changed, and all block (docs may fail with the dead-link exit 42 alone, D6). On a plain MR check (path-filtered) and docs advise. The required jobs outside the DAG are ci-image, xtask, secrets-policy, cargo-deny and docs.

Amended (2026-11-08, #2997): the car DAG’s shape has moved on since (plan ci-battery-ahead, #2994: battery needs only xtask), and it is described once, in Quality Gates § CI: the car; read the DAG in the amendment above as that section’s. D2’s ruling is unchanged.

Amended (2026-11-10, #3043–#3046; plan ci-dev-loop D2–D4): a car is one car job on one 4xlarge VM, not the four-job DAG of check, build, battery and e2e. A train runs ci-image → xtask → car ∥ docs, and each blocks. The car’s script is the developer’s commands, word for word the list validate::car_lines (xtask/src/cmd/validate/car.rs), which cargo xtask validate --profile full runs on a host. The gates come first (fmt, the config fetch, every precompilation gate), so a convention break fails before any compile. Then dev clean --any-project and dev start, which compiles the workspace once. Then the lanes, from that one compile. cargo xtask ci is gone. A plain MR changes too (plan D4, #3028): one whose changes touch code or a stack input runs the car blocking (allow_failure: false), so the train never admits a car that its MR pipeline already showed red. A docs-only MR runs docs alone. Read "advises" above, and the #2937 amendment’s manual stack jobs, as that. On main no car runs and no job writes a car cache. A car pushes nothing. The release images come from a separate protected job, release-build (resource_group: release; on a tag, on the weekly main schedule or by hand on main, never on a merge request or a train), which builds them, smoke-tests them and pushes them last (#3045). The contract tests are now xtask/src/pipeline_tests.rs. D2’s ruling, that every car runs whole and blocks a train, is unchanged. The first green car took about 59 min from pipeline start to the car’s end (the car job 54 min of it) and about 62 runner-minutes on one pool slot, against the four-job car’s 40–49 min and 70–90 runner-minutes over up to four slots (#3046).

Amended (2026-11-17, #3101; plan docs-only-car; the maintainer’s rulings of 2026-11-15 and 2026-11-17): a car whose change is documentation no lane reads does not run whole. The car job starts on every train and every merge request, runs every gate, and then stops as a success when xtask car-scope proves that HEAD is the merge commit GitLab made and that every path it changes is documentation (Quality Gates § CI: the car has the definition). Any doubt runs the whole car. The changes: list on the plain-MR rule is gone: it ran the car when any listed path changed, so a path it forgot (a web template, an SDK file) ran no car until the train. Read "every car runs whole" above, and "a docs-only MR runs docs alone", as this. D2’s ruling that every job a car runs blocks the train is unchanged, and no project setting changes: a car that stops early is a successful job, not a skipped pipeline. A docs-only train car had taken 42.6 minutes (job 18123169347).

Contract tests over the parsed YAML hold this (xtask/src/cmd/ci/pipeline_tests.rs). They evaluate each job’s resolved rules: against a train’s variables and against a plain MR’s.

D3 — The stack jobs run on the 4xlarge, through a variable

build, battery and e2e take their runner from $CI_BATTERY_RUNNER_TAG, whose YAML default is dhs-aws-autoscaler-docker-4xlarge. No job declares services: [docker:dind]. The variable is the fallback switch: setting it to cma-runner-craig moves the stack jobs back to the instance runner without a code change (§ Tripwires).

Amended (2026-11-07): the fallback switch is dropped (the maintainer’s ruling: pre-1.0, the 4xlarge is the only runner). CI_BATTERY_RUNNER_TAG is gone and every job, the stack jobs included, runs on the pipeline default tags: [$CI_RUNNER_TAG], the 4xlarge; a contract test fails on a job or template that names any other tag. The switch could no longer work: cma-runner-craig is an instance executor that ignores image:, so it cannot run the craig-ci image every job now runs in (plan ci-compile-once U1). A 4xlarge outage therefore stops the train. A future fallback must be a docker-executor runner able to pull craig-ci from the project registry, and comes back as a new amendment with its own tag contract.

D4 — No retries

A flake fails the car. The integration and ci-integration nextest profiles set no retries, and neither does [profile.default], so every run takes nextest’s default of zero. A contract test fails if any of the three tables, or any override in them, gains a non-zero retry. That keeps the #1165 ruling: a retry runs on top of the partial state the failed attempt left, and it hides the failure.

The car’s author files the flake as an issue and fixes it. Nobody presses retry on a job in a train pipeline. A dropped car is re-added once the cause is fixed. For an infrastructure failure (runner_system_failure, an interrupted or stuck runner), it is re-added once the failure is named on an issue.

D5 — Landing: auto_merge=true adds the car to the train

Push the branch (the fast hook runs), open the MR, then call PUT …/merge_requests/:iid/merge with auto_merge=true, squash=false and should_remove_source_branch=true. That call adds the MR to the train. A direct merge (the same call without auto_merge) answers 405 Method Not Allowed. That is the designed state: there is no path around the train. POST …/cancel_merge_when_pipeline_succeeds takes a car off the train. The full procedure is in Known Issues § Landing an MR.

D6 — A check that reads a live external source is a detector, not a gate

A car is dropped only for what the car changed. A job whose verdict can change without a commit, because it reads an outside site, registry or feed, would drop cars that changed nothing. So such jobs never block a train. docs-deadlinks (external links through lychee) is allow_failure: true, and docs-xref-check gates the internal links. policy-drift runs on a schedule. cargo-audit runs only when the dependency graph changes, so a new advisory blocks only a car that changes the dependencies.

Amended (2026-11-07, #2981): docs-deadlinks and lychee are gone. docs-xref-check checks the external links from the AsciiDoc sources in its own Antora build, and allows only the verdict’s exit 42 for a dead one, so the internal links still gate and an external site never does.

Tripwires

This decision stands while none of these fires. Any one reopens it.

  • Car wall time over 60 minutes. A car’s train pipeline, on a warm cache, takes longer than an hour, measured from the pipeline’s created to finished time. Revisit the DAG’s shape, the cache and the runners. The cache node and warm runners are the issues the plan names.

    Amended (2026-11-10, #3046): the one-job car runs serially on one VM, and its first green pipeline took about 59 minutes to the car’s end, just under this line (D2, amended 2026-11-10). The tripwire stands unchanged; the car leaves little headroom under it.

  • Flake rate over one car in ten across a rolling twenty. More than two of the last twenty cars were dropped for a failure that did not reproduce. Revisit the no-retries ruling (D4) together with the open flake issues; do not quietly add a retry.

  • The 4xlarge offline for an hour. No runner picks up the stack jobs for 60 minutes. Set the project CI/CD variable CI_BATTERY_RUNNER_TAG=cma-runner-craig, which overrides the YAML default, and record it on an issue. Remove the variable once the 4xlarge is back.

    Amended (2026-11-07): there is no fallback runner (D3, amended). Record the outage on an issue; the train waits for the 4xlarge.

  • A merge lands without a green train pipeline. The project or group settings of D1 have drifted. Stop landing, restore them, and file a fix: issue.

Consequences

  • The gate leaves the maintainer’s host. Cars no longer wait on one devstack, and a skipped hook no longer reaches main unchecked: the train runs the whole battery on every car.

  • The pre-push hook is a five-minute fast battery (fmt, the static lints, clippy and the unit tests). The full legacy hook text (devstack/hooks/pre-push-legacy) is deleted, together with the two xtask tests that pinned its lines.

  • A train runs its cars' pipelines in parallel, each on the result of the cars ahead of it, so throughput is several cars per pipeline duration (about 35 minutes on a warm cache), not one car per pipeline. A dropped car restarts the pipelines of the cars behind it. Amended (2026-11-10, #3046): a car is one job on one VM and its pipeline takes about an hour (D2, amended 2026-11-10); a car holds one runner slot rather than up to four.

  • A flaky test now costs a car. Each flake becomes an issue rather than a retry.

  • ADR-080’s firewall rules (§ D4) and its "detector" ruling (§ D3) no longer describe the system. Its § D1 and § D2 describe it as reshaped by U3.

Alternatives considered

  • Keep the local hook as the gate (ADR-080). Rejected: it serialises every car on one host for half an hour or more, and nothing server-side enforces it.

  • A blocking MR pipeline without merge trains (only_allow_merge_if_pipeline_succeeds alone). Rejected: the MR is tested against the main it branched from, not the main it lands on. Two green MRs can merge into a red main.

  • Retry a failed test once (retries = 1). Rejected by ruling (#1165, plan design 5): it turns a real contention failure into a green run, as it did on 2026-07-27.

  • Stay on cma-runner-craig. Rejected as the default: it is a single runner the project does not operate. It remains the fallback (D3). Amended (2026-11-07): no longer the fallback; it cannot run craig-ci (D3, amended).

Edit this page · latest