Plan: Merge trains on the 4xlarge runner are the gate; xtask keeps the stages and loses the battery
Status: Done (2026-11-11) — U1–U4 as planned; U5 narrowed to documentation
Epic: none
Issues: #3245 (parent) · U1 #3246 (w3) · U2 #3247 (w2) · U3 #3248 (w5) · U4 #3249 (w2) · U5 #3250 (w8)
Branches: refactor/xtask-ci-stages, feat/xtask-secrets-ephemeral, feat/ci-pipeline-4xlarge, chore/ci-merge-trains, refactor/xtask-drop-the-battery
A Design + Scope plan: GitLab owns tracking, the child issues carry the implementer brief, and the plan freezes when U1 starts.
Erratum (2026-11-05): D3's generator already existed (#3090's .env floor key and the .keys/ pairs every bring-up without an age key boots on). U2 makes that set the lanes' secrets whenever the host holds no age key (secrets::dev_pairs), so there is no secrets ephemeral command and no --ephemeral-secrets flag.
Erratum (2026-11-05): D2's /builds is not the same path on both sides of the socket: the 4xlarge job's /builds is a named runner volume, so each stack stage bind-mounts it at the volume's VM path and re-runs from there (xtask/src/builds_alias.rs), and the steps that reach the stack from the job process join the job container to the project network.
Erratum (2026-11-05): D4 builds two images from each commit (ADR-040 Amendment 3): images-test pushes the service image with the test features and writes images-test.env, the test jobs run it, and a smoke job boots the production images and runs the integration lane less the tests that need a test-only endpoint.
Erratum (2026-11-06): every gating job runs on one declared CI image, Dockerfile.ci, named by the content address CI_IMAGE_TAG that ci-config-lint checks, so no job installs anything, and the unit lane runs as its unprivileged tester. The test image set (the devstack-profile service image with the portal and Kanidm images) is all the stack jobs need, images builds only the release service image after it, and the stack jobs set COMPOSE_FILE for the whole job. On a merge request's own pipeline, outside a train, the image and stack jobs run only when code changes; a merge-train car, main, tags and schedules always run every job. The file runs to about 420 lines, past D4's 400.
Erratum (2026-11-06): D5's push rule reject_unsigned_commits was already on before U4 (read back from GET /projects/:id/push_rule), so U4 set only the project settings and dropped the hook's signature step.
Erratum (2026-11-06): the merge-request pipeline's path filter gave way to manual image and stack jobs on every merge request: GitLab adds a merge request to the train only once its own pipeline has finished, so an automatic stack there doubled each merge's wall time. A car, main, tags and schedules still run every job automatically.
Erratum (2026-11-06): D4's image builds run as three parallel jobs, images-shared (portal and Kanidm), images-test and images, rather than images after images-test, so smoke no longer waits on the test build (ADR-040 Amendment 5).
Erratum (2026-11-06): a merge request's own pipeline runs lint and docs only; clippy and unit, which git push already ran, run on cars, main, tags and schedules (maintainer, after an MR pipeline queued ~20 min on the saturated fleet).
Erratum (2026-11-06): a car runs nine jobs, from twelve (maintainer, fleet capacity): one check job runs the four check stages in sequence; identity runs after e2e on its stack; perf became smoke, which is now the k6 smoke profile on the production images (ADR-040 Amendment 6), and the ci smoke stage is gone.
Erratum (2026-11-08): a car, main, tags and schedules no longer all run every job (plan compile-once-per-car, #3275). build and the stack jobs run only when a code input changed, so a docs-only merge request and its car run lint and antora alone, and main's own pipeline only promotes what its car built (docker-promote, pages). Tags and schedules keep every job.
Erratum (2026-11-11): U5 narrows to documentation (maintainer, 2026-11-09, #3250). cargo xtask validate and its in-network runner stay as an optional, fuller local loop that nothing requires; the pages stop calling it the pre-push battery. Port publishing stays, because the car reaches the stack through it (CANOPY_TEST__PUBLISHED_HOST). D6's deletions and the dev compose override are not done.
Context
Direction (maintainer, 2026-11-05). "The whole point is to move verification out of prepush." "Nothing but absolute minimal testing happens locally now. Merge trains and CI/CD are now in charge of total correctness." "If clippy/compile/unit tests pass, it ships into the merge train to run the whole battery." "If we need to refactor xtask or decompose it or remove things to make CI/CD work better, that is fine. Everything is on the table. xtask became massive only because CI/CD has been broken for 6 months." #3244 (in review, landing before U1) does the first part: .githooks/pre-push runs commit-signature verification, cargo xtask test --unit (fmt, clippy, the unit lane) and git-lfs, and the docs and AGENTS.md say the merge train owns correctness. This plan builds that train.
The gate that was. cargo xtask validate (xtask/src/cmd/validate.rs, validate_report.rs: 69 fixed-order stages, a checkpointed JSON report, background stages) ran on the developer host before every push, with cargo deny, the e2e suite, rustdoc, the perf smoke and the identity matrix after it: 30–40 minutes per push. Around it grew what a shared host needs: host-port reservation and bind-casualty recovery (docker.rs, #3160, #3196), .ports.env reconciliation, source-hash staleness markers (devstack_guard.rs, 4,375 lines), two battery file locks, a 1 Hz resource sampler (sysmon.rs), a bootstrap typestate (bootstrap.rs) and a second runner that re-executes validate inside the compose network (validate_in_network.rs, its own image). xtask is 111,558 lines.
CI that is. .gitlab-ci.yml (about 1,380 lines, 40 jobs) runs a fragment of the battery: some twenty single-gate jobs on dhs-aws-autoscaler-docker.2xlarge, whose queue starved; integration-tests only on main and tags, through a docker:29-dind service; e2e only on a schedule. The pieces a train needs already exist: the image jobs push $CI_REGISTRY_IMAGE/build:$CI_COMMIT_SHA (and build/portal, the kanidm image) and already use the runner host’s socket (.image-build-base, DOCKER_HOST: unix:///var/run/docker.sock); docker-compose.prebuilt.yml composes from those refs; cargo xtask test --integration runs nextest inside the canopy-integration compose service, and cargo xtask e2e runs Playwright inside canopy-e2e, both on the project network.
The runner. Group runner 58561694, tag dhs-aws-autoscaler-docker-4xlarge: a docker+machine executor that gives every job a fresh VM (16 vCPU, 62 GB, 990 GB disk, about 100 s to provision), measured by canopy’s probe (pipeline 3033992615) and by craig’s on the same day. Docker-in-Docker does not work there: the dind service generates its certificates and never listens (unprivileged). The host VM’s Docker socket is mounted into every job container (craig verified docker info, a user network and container DNS through it; canopy’s image jobs rely on it on the same family), and /builds is host disk at the same path, so a bind mount from a job resolves. canopy’s dind probe failed only because DOCKER_HOST named the dead service.
craig (gadhs/application/ccwis/craig) approved the same design on 2026-11-05 (plans/merge-trains-gate.adoc there): a DAG of cargo xtask ci <stage> verbs, a host-free devstack, merge trains, no retries. The two projects compare notes on the cicd channel; the shapes here are chosen to match where canopy has no reason to differ.
Scope
In scope:
-
cargo xtask ci <stage>leaf verbs over the stage bodies that exist; the pipeline as the only orchestrator. -
Per-job generated devstack secrets; no SOPS key in CI.
-
The pipeline on the 4xlarge, as sibling containers on the runner’s socket, running the whole battery on merge-request, merged-results and merge-train pipelines, plus the release jobs.
-
Merge trains, pipelines-must-succeed and the server-side unsigned-commit rule, applied through the API and recorded in the docs.
-
The deletion of the local battery runner and the shared-host machinery, with the devstack’s host ports moved to a developer-only compose override.
Out of scope:
-
Changing what any test asserts; new lanes.
-
The pre-commit hook; the pi commit guard.
-
GitLab’s security templates,
pages, SBOM and promotion jobs beyond retagging them and calling the verbs they already call. -
A shared build cache node or warm runners (an issue once the train runs and its times are known).
Design
D1 — Stages are xtask verbs; the pipeline sequences them
cargo xtask ci <stage> is a pure function of the checkout and, for the devstack stages, a running stack: it exits 0 or non-0 and prints one timing table. The stages, each wrapping bodies that exist today:
-
lint: the in-process gates ofstage_static_gates(validate.rs:539, plan-lint through xtask-unix-guard) and the gates ofstage_build_gates(validate.rs:839:deny,machete,rules,vendor-check,capabilities,quality-budgetsand its folded subprocess gates, which includeci-config-lint,secrets-yaml-lintandtest-lanes-lint --static); each gate is in exactly one stage, pinned by a test over the stage consts; -
clippy:cargo fmt --check, clippy withlanes::CLIPPY_FEATURES,feature-builds; -
unit:lane-partitionthen nextest’s unit lane under profileci(whattest --unit --skip-staticruns); -
docs:rustdoc-private,doctest,api-docs --checkoffline; -
images: builds the service, portal and kanidm images once and pushes them as$CI_REGISTRY_IMAGE/build{,/portal,/kanidm}:$CI_COMMIT_SHA, writing each pushed digest toimages.env(a dotenv artifact:CANOPY_PREBUILT_SERVICE_IMAGE=<repo>@sha256:…and the other two); locally it builds without pushing; -
devstack: brings the stack up fromimages.env(docker-compose.yml:docker-compose.prebuilt.yml, pull andup --no-build --wait), with the secrets of D3, and prints the compose project name; it is the one place CI touches compose; -
infra:test --integration --skip-static(nextest insidecanopy-integration, profileci-integration),schema-sweep,api-docs --checkagainst the stack; -
e2e: the Playwright suite insidecanopy-e2e, with--fixture-smokefor the schedule that ranfixture-smoke; -
identity:identity matrix --all; -
perf:perf --profile smoke.
ci with no stage lists them. There is no sequencer: the pipeline orders the stages (D4), and a developer runs the one they want. Developer-machine checks that were battery stages and are not properties of the tree (preflight, visibility, signing) become cargo xtask doctor.
D2 — Sibling containers on the runner’s socket
No job declares a services: entry or sets DOCKER_HOST: the runner mounts the VM’s socket, and xtask’s compose calls run there, as the image jobs already do. The compose project runs beside the job container on the VM’s daemon, the test processes run inside the project network as they do today, and nothing publishes a host port in CI (U5 moves publishing to the developer override; until then the published ports bind on a VM nothing else uses). The job’s checkout is /builds/<path> on both sides of the socket, so the bind mounts canopy-integration and canopy-e2e declare resolve unchanged. CANOPY_CI=true keeps its two meanings: canopy-test-lib refuses to skip, and nextest takes the ci-integration profile. CANOPY_PREBUILT_IMAGES and CANOPY_VALIDATE_RUNNER go: ci devstack is the prebuilt path by construction, and the in-network runner no longer exists.
D3 — Secrets are generated per job
cargo xtask secrets ephemeral --out <file> writes the pairs secrets::decrypt_to_pairs yields from secrets/dev.yaml, with fresh values: CANOPY_ENCRYPTION_KEY from 32 random bytes, each program’s CANOPY_<PROGRAM>__SIGNING_KEY from canopy_signing::keygen::generate_key_pair, and the matching public halves where the devstack reads them (CANOPY_VERIFY_KEY_<PROGRAM>, the .keys/<program>-public.pem files), plus the applicant portal’s key pair, all written by devstack_identity::signing_keys::install as today. ci devstack --ephemeral-secrets uses it instead of SOPS. CANOPY_CI_AGE_KEY, the SOPS_AGE_KEY lines in the YAML and secrets init --for-ci go, with their docs.
D4 — The pipeline
workflow: admits $CI_PIPELINE_SOURCE == "merge_request_event" (detached, merged-results and merge-train pipelines all arrive as that source; CI_MERGE_REQUEST_EVENT_TYPE tells them apart), main, a tag and a schedule; a branch push with no merge request runs nothing. Stages check → build → test → release. Every gating job: tags: [dhs-aws-autoscaler-docker-4xlarge], CANOPY_CI: "true", interruptible: true, no allow_failure, script: one cargo xtask ci <stage> line:
-
check:lint,clippy,unit,docs(parallel; JUnit fromunit); -
build:images(artifactimages.env,reports: dotenv); -
test:infra,e2e,identity,perf, eachneeds: [images]and runningci devstack --ephemeral-secretsfirst in its ownbefore_script(its own VM, its own stack; JUnit frominfraande2e); -
release:docker-promote,sbom,pagesand the security templates keep their rules;coveragebecomes a scheduled job onmain.
The twenty single-gate jobs, cargo-fmt, cargo-clippy, cargo-test, cargo-doctest, cargo-audit, cargo-machete, integration-tests, validate-in-network, identity-conformance and fixture-smoke go; the probe branch and its jobs go. Caches: one cargo cache per check job, keyed on rust-toolchain.toml and Cargo.lock, pull-push on main and pull elsewhere, with the existing size bound. ci-config-lint keeps the download-pin and telemetry rules (#2621, #2623) and the ADR-040 promotion invariants, drops the dind and prebuilt-variable rules, and gains: every script: line of every job is cargo xtask …, or a line from an allow-list the lint holds (docker login, apk add, the syft and release-cli calls); every job in check, build and test is tagged 4xlarge and has no allow_failure, no services: and no retry:; .config/nextest.toml's ci and ci-integration profiles carry retries = 0; the workflow admits merge_request_event. The file ends under 400 lines.
D5 — Merge trains and the server-side rules
Applied through the API once two merge-request pipelines have passed on the 4xlarge, and recorded in contributor-workflow.adoc with the commands that set and undo them: merge_pipelines_enabled, merge_trains_enabled and only_allow_merge_if_pipeline_succeeds true, allow_merge_on_skipped_pipeline and merge_trains_skip_train_allowed false (PUT /projects/:id); the push rule reject_unsigned_commits (PUT /projects/:id/push_rule), after which the hook’s signature step goes and .githooks/pre-push is cargo xtask test --unit and git-lfs. Squash stays off; the merge method stays merge. Landing is PUT …/merge with auto_merge=true (the train); a direct merge is refused, the documented state. No retries anywhere (pinned by D4's lint rules): a flake fails its car and gets a root cause.
D6 — The battery machinery goes
Under the train, everything that existed to run the battery on a shared host is deleted, not switched off (by the Explore map of 2026-11-05):
-
cmd/validate.rs,cmd/validate/,validate_bg.rs,xtask/Dockerfile.validate-runner;cmd/validate_in_network.rsgoes exceptservice_mesh_env(validate_in_network.rs:140), which moves toapi_docs.rs, its one remaining reader;validate_report.rsgoes except its subprocess helpers (run_capture,run_capture_ok,spawn_and_tee,CmdMeta,capture_failure,Redactor,validate_report.rs:659-947), whichdocker.rs,devstack_guard.rsanddevtools.rsuse and which move toproc.rs; -
sysmon.rs, withSysMonitorremoved fromtest,e2eandcoverage; the identity perf harness keepsio_pressurein apressure.rsof its own; -
bootstrap.rs:test,e2eandcoveragerequire a healthy stack (dev status) and otherwise fail namingcargo xtask dev start; no auto-refresh, no reconciliation; -
devstack_guard.rsloses the source-hash markers and the minimum-refresh ladder:dev startiscompose up --build --wait,dev reloadiscompose buildthenup --wait,dev refreshgoes,ensure_readyis healthy-or-error; the signing-key install and the identity upstream wiring stay; -
docker.rslosesup_healthy_with_recovery's casualty rounds,reconcile_ports_env,acquire_battery_locks, the validate and JUnit locks; the per-project leaseacquire_lockstays for thedevandidentitycommands; -
host ports leave
docker-compose.ymlfordocker-compose.dev.yml, whichcargo xtask devapplies and CI never does;dev startstill reserves random ports (luchs hosts several projects) and writes.ports.envonce, for a browser and fortest --integration --host.
Risks
-
The socket is not there, or compose cannot bind-mount from a job (fail-closed:
ci devstackfails and nothing merges). Mitigation: U3’s first commit is a smoke job with no dind service (docker info, a user network, Postgres by name, a bind mount of the checkout) whose result goes on the issue before any stage moves. -
A flaky test fails cars (fail-closed). Mitigation: none by design; the standing rule is root cause, and the first month’s drop rate goes on the parent issue.
-
A window with no functional gate between #3244 and U4’s flip (fail-open locally). Accepted by the maintainer explicitly; the merge-request pipeline of U3 narrows it as soon as it is green.
-
U5 breaks a
devverb the pipeline does not exercise (fail-closed: the verb errors at its first compose call). Mitigation: eachdevsubcommand is run once by hand on luchs in U5, listed on its MR. -
Throughput (not a failure mode; visible in the train’s queue): one car per pipeline, about the battery’s length. The cache node is the follow-up issue once the times are known.
Units (weights by complexity) — U1 → U2 → U3 → U4 → U5
U1 (w3) — cargo xtask ci and doctor
Files: xtask/src/cmd/ci/ (new: mod.rs, one file per stage), xtask/src/cmd/doctor.rs (new), xtask/src/cmd/mod.rs, xtask/src/main.rs, xtask/src/cmd/validate.rs (its stage bodies become calls into ci; the runner stays until U5), docs/modules/ROOT/pages/tooling/xtask-catalog.adoc, local-dev.adoc.
D1. Tests: unit (each stage's command list is exactly its const; every gate validate runs is in exactly one ci stage, so a gate dropped from a const or listed twice fails; ci with no stage lists every stage; doctor holds the three developer-machine checks). Acceptance evidence: every stage green on luchs against the devstack, times on the issue.
U2 (w2) — Ephemeral secrets
Files: xtask/src/cmd/secrets.rs, xtask/src/devstack_identity.rs, xtask/src/cmd/ci/devstack.rs, docs/modules/ROOT/pages/configuration-reference.adoc, security-operations.adoc.
D3. Tests: unit (secrets ephemeral yields every key decrypt_to_pairs does and no other, with fresh values per run; each public half verifies a signature made with its private half and refuses one made with another run's). Acceptance evidence: ci devstack --ephemeral-secrets on luchs boots every service and ci infra passes against it.
U3 (w5) — The pipeline
Files: .gitlab-ci.yml, xtask/src/cmd/ci_config_lint.rs and ci_config_lint/, docs/modules/ROOT/pages/testing.adoc (CI vs local; the job table), contributor-workflow.adoc.
D2 and D4; the smoke commit first (its result on the issue), then the stages. Tests: ci-config-lint's new rules, each with a failing fixture; contract (the YAML’s needs: order is the stage order D4 names); the unit’s own merge-request pipeline green end to end on the 4xlarge, wall time per job on the issue.
U4 (w2) — Merge trains and the server-side rules
Files: .githooks/pre-push, xtask/src/githooks_tests.rs, docs/modules/ROOT/pages/contributor-workflow.adoc, AGENTS.md.
D5, after two green U3 pipelines. Tests: unit (githooks_tests::every_pre_push_step_header_goes_through_begin_step expects exactly cargo xtask test --unit and git lfs pre-push). Evidence: the settings read back from the API; a merge request landed through the train, with its pipeline id; an unsigned commit refused by the push rule on a scratch branch; a direct merge refused.
U5 (w8) — The battery machinery goes
Files: the D6 list; docker-compose.yml, docker-compose.dev.yml (new); xtask/src/cmd/{dev,test,e2e,coverage,api_docs,perf}.rs; docs/modules/ROOT/pages/{local-dev,testing,developer-guide,tooling/xtask-catalog,validate-in-network}.adoc (the last deleted, with its nav entry).
D6. Tests: contract (docker-compose.yml publishes no port; the dev override publishes every port the old file did); unit (dev start composes the base and the dev override, ci devstack the base and the prebuilt override); regression (every dev subcommand run by hand on luchs; test --integration --host and the browser reach the stack through .ports.env; the train pipeline green on the unit’s own merge request). Lines removed go on the MR.
Verification
-
U1–U2:
cargo xtask test; everycistage green on luchs. -
U3: the merge-request pipeline on the 4xlarge, every gating job green, JUnit attached, per-job wall time on the issue.
-
U4: the settings read back; a train merge; the push rule’s refusal; a direct merge refused.
-
U5: its own train pipeline; the
devverbs by hand;wc -lof xtask before and after on the MR.
Documentation Updates
-
testing.adoc,contributor-workflow.adoc,local-dev.adoc,developer-guide.adoc,configuration-reference.adoc,security-operations.adoc,tooling/xtask-catalog.adoc,AGENTS.md(the U4 override and the Build & Test lines), as each unit lists -
CHANGELOG.adoc— one entry per unit under== Unreleased -
Delivery: each unit's MR
Closesits issue, U5's also closes the parent #3245; after each merge one note with the merge SHA on the issue; U4's note carries the settings' API responses and the first train car's pipeline id.
Review log
| round | vendor | resolved model | verdict |
|---|---|---|---|
1 |
Anthropic |
claude-fable-5-1 |
FLAGS (P1: unfiled issues, an unclassified risk, smoke runs called regression tests; P2: |
2 |
gemini-4-argon |
FLAGS (the same P1 points and U4's missing test; P2: the double-counted lint gates, the applicant portal key, the unpinned no-retries rule); fixed in the draft |