Plan: CI-Integration Build-Once, Fan-Out Decomposition (#1739)

Archive record

Never started; superseded by plan merge-trains-gate U3 (the battery as cargo xtask ci stages, #1739).

Status

Deferred (superseded by plan merge-trains-gate U3, #1739)

Issue: #1739
Branch: chore/1739-ci-build-once-fanout
Builds on: ADR-080 (the as-built ci-integration detector, #1189) and the cma-runner-craig runner (#1645), both on main

Context

ci-integration (ADR-080 D1) is one serial job on one cma-runner-craig microVM: bootstrap, an ephemeral field key, an advisory check-docs, docker compose --profile fault build, up -d --wait, the shared battery (xtask test --skip-lint --profile ci-integration --fault-gate), a reseed, then e2e --no-refresh, sdk-test, security --skip-zap --skip-fuzz and perf --profile smoke. CI is not the merge gate (ADR-080 D3), so #1739’s "MR-gate critical path" argument is gone. What still holds (#1739; ADR-080’s last tripwire): one flaky phase reds the whole job and hides the others, a retry repeats the image build, one allow_failure key covers every phase, nothing runs in parallel.

  • The fan-out phases compile nothing. xtask e2e --no-refresh skips the cargo run -p craig-seed manifest regen; sdk-test runs its suites in standalone containers mounting sdks/ read-only (sdk_test::run_suites, docker::run_sdk_suite), perf runs k6 in a container (plus a best-effort host-side Postgres drain check), and security probes the services over HTTP from the job. The xtask binary needs cargo on PATH only because workspace::locate_workspace_root runs cargo locate-project.

  • Placement off cma-runner-craig is unproven. On the shared docker:27-dind pool a devstack’s ports are published on the docker service, not the job’s localhost, and xtask security probes http://localhost:{port}. The cluster-tests job calls that routing "UNPROVEN", and Known Issues & Lessons Learned records recurring pentest/perf reds on that pool (disk OOM). Hence the spike (Step 2).

  • Nothing needs handing off. Each job stands up its own stack from the pushed images, with its own key and seed.

Scope

In scope: the files under Files Touched, plus the MR registry path, tag scheme, digest manifest and cleanup policy.

Out of scope:

  • Flipping any job’s allow_failure, or any project merge setting. Every job here stays advisory (ADR-080 D3); a flip needs a superseding ADR (ADR-080 tripwires).

  • Concurrency on cma-runner-craig: the project does not operate that runner.

  • One shared running devstack across jobs; cargo nextest archive sharding.

  • DOCKER_HOST-aware service addressing in xtask: the follow-up if the spike fails (Step 2).

  • The existing docker-promote / pentest docker login -p lines; L3 cluster chaos (ADR-067 §D9).

Decisions

D1 — Registry path and tag. The jobs set CI_REGISTRY_IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/mr and CRAIG_IMAGE_TAG: mr-$CI_MERGE_REQUEST_IID-$CI_PIPELINE_ID, so compose’s image: template ($\{CI_REGISTRY_IMAGE:-craig}/<svc>:$\{CRAIG_IMAGE_TAG:-local}) resolves to <project>/mr/<svc>:mr-<iid>-<pipeline>. Why: MR images never share a repository with release tags, no two pipelines write one tag, and the as-built CI_REGISTRY_IMAGE: craig (Docker Hub, if pushed or pulled) is gone.

D2 — A success-only digest manifest. ci-build-images pushes exactly the registry-prefixed images docker compose --profile fault config --images prints (16 tags in 14 repositories today), records each push’s digest, and only after every push succeeded writes image-digests.txt (<compose ref> <repo>@sha256:<digest> per line) as an artifacts: when: on_success file. Why: ci-build-images is allow_failure: true, and GitLab starts a needs: dependant even when an allowed-to-fail job failed; a failed or partial build uploads no manifest.

D3 — Consumers run the manifest’s digests. A consumer requires the xtask binary and the manifest, checks the manifest’s refs equal compose’s image set, pulls each <repo>@<digest> and tags it as its compose ref, builds the infra services by name (a build: and no registry image: postgres, postgres-test, rabbitmq, keycloak, garage, garage-init today) and runs up --no-build. A missing file or a failed digest pull exits with "run a new pipeline for this MR", which rebuilds both artifacts. Why: every stack runs exactly the images one successful build pushed.

D4 — The build stays docker compose --profile fault build on cma-runner-craig. ADR-080 accepted this concurrent build on this runner against the #1347 serial-build rule, with a tripwire, which moves to ci-build-images unchanged. If it fires, docker::build_devstack_images_serial (it already reads CI_REGISTRY_IMAGE and CRAIG_IMAGE_TAG) becomes the builder, never a retry.

D5 — xtask is built once. ci-xtask builds target/release/xtask in $RUST_IMAGE (rust:1.97-alpine, whose musl target links statically) as a 7-day artifact. Why: one binary runs on the Alpine dind image and the Debian microVM, replacing five release builds of a crate that pulls sqlx, zen-engine, lapin, jsonschema, craig-test-lib and craig-policy.

D6 — The spike decides placement. The fan-out jobs run on the shared dhs-aws-autoscaler-docker.medium dind pool if the Step 2 spike passes, on cma-runner-craig if it fails. Why: parallelism is only real on a concurrent pool. No mixed shape.

D7 — No check-docs in the family. ci-integration drops its advisory step and no split job is added. Why: the standalone check-docs job already runs on every MR pipeline with the same exit-3-is-clean rule and allow_failure: true. Erratum (2026-11-01, #2880): the standalone check-docs job and `ci-integration’s step are both gone with the template sync engine; D7’s decision stands and its rationale is moot.

D8 — Every family job is allow_failure: true, pinned by the job-shape test; one key per phase meets #1739’s "liftable per phase". Why: the maintainer’s ruling — CI is not the merge gate; allow_failure only sets the pipeline’s colour.

D9 — One ephemeral key per stack job, written by the as-built lines (32 urandom bytes, base64, umask 077, chmod 600, never printed or an artifact). Not pentest’s cargo xtask secrets write-field-key: CRAIG_CI_AGE_KEY is protected, so it does not reach pipelines on the ordinary unprotected feature branches MRs come from. ci-build-images needs the file only because compose resolves the required env_file at project load.

D10 — The firewall opens only where a host-side devstack runs: ADR-080 D4’s rules sit in .ci-devstack-host-net, used by ci-integration and the fallback fan-out; no other job or block carries a firewall command.

D11 — Runtime targets only. Every pushed image is a FROM runtime target, and no family job exports a build cache (--cache-to, compose cache_to:), so no builder-stage layer is published. The Dockerfile’s build args live in the builder stage, and any future credential build arg stays there.

D12 — Two rules blocks. .ci-integration-rules holds the as-built rules: verbatim; .ci-sdk-rules is the same list plus sdks/**/*. ci-sdk-test and ci-xtask take .ci-sdk-rules; every other family job takes .ci-integration-rules. Why: a needs: target absent from the pipeline fails pipeline creation, and ci-xtask’s superset keeps every target present; an SDK-only MR runs exactly `ci-xtask and ci-sdk-test.

D13 — Registry cleanup in a reserved namespace. A project container_expiration_policy deletes only tags matching ^mr--[0-9]$ (older_than: 7d, keep_n: 10 per repository). The policy is project-wide and cannot target a repository path, so the namespace is reserved instead: docker-promote’s tag rule accepts only SemVer tags ($CI_COMMIT_TAG =~ /^v[0-9]\.[0-9]\.(-[0-9A-Za-z.-])?$/; the one existing tag is `v0.1.0-alpha), so no release tag can match. A retry within 7 days finds its tags; past that, "run a new pipeline for this MR". Release tags never match.

D14 — The SDK job is devstack-free. ci-sdk-test needs only ci-xtask and Docker: no image pull, no key, no stack. Why: its suites run in their own containers; an unrelated migration or service failure must not decide the SDK verdict.

Design

All family jobs are stage: scan on MR pipelines. ci-xtask (dind pool) and ci-build-images (cma-runner-craig) start together; ci-integration, ci-e2e, ci-security-regression and ci-perf-smoke each needs: [ci-build-images, ci-xtask]; ci-sdk-test needs: [ci-xtask].

Hidden blocks

Block Content Used by

.ci-integration-rules / .ci-sdk-rules

the as-built rules: list / plus sdks/**/* (D12)

per D12

.ci-mr-vars

variables: CI_REGISTRY_IMAGE, CRAIG_IMAGE_TAG (D1), CRAIG__ACTIVE_STATE_BUNDLES: georgia, CRAIG_XTASK_ALLOW_SECONDARY_CHECKOUT: "1" (xtask e2e calls require_primary_checkout, #1636)

ci-build-images, the stack jobs

.ci-docker-engine

the as-built Docker lines (distro packages when absent; start; wait), plus apt jq

cma-runner-craig jobs

.ci-devstack-host-net

the as-built host.docker.internal line and the four bridge-scoped iptables rules

per D10

.ci-registry-login

printf '%s' "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"

ci-build-images, the stack jobs

.ci-field-key

the as-built ephemeral-key lines (D9)

ci-build-images, the stack jobs

.ci-mr-stack-up

the D3 listing below

the stack jobs

ci-xtask (new)

image: $RUST_IMAGE, tags: [dhs-aws-autoscaler-docker.medium], before_script: apk add --no-cache curl git openssl (as check-docs and docs-content-lints), script: cargo build --release --locked -p xtask, artifacts: paths: [target/release/xtask], expire_in: 7 days, allow_failure: true, .ci-sdk-rules.

ci-build-images (new)

tags: [cma-runner-craig], timeout: 1h, extends: .ci-mr-vars, no needs:; before_script: .cma-runner-bootstrap, .ci-docker-engine, .ci-registry-login; script: .ci-field-key, then one - | item; artifacts: paths: [image-digests.txt], when: on_success, expire_in: 7 days. It runs no up, seed or test.

set -euo pipefail
docker compose --profile fault build
imgs=$(docker compose --profile fault config --images | grep "^${CI_REGISTRY_IMAGE}/" | sort -u)
test -n "$imgs"
: > image-digests.tmp
for img in $imgs; do
  d=$(docker push "$img" | sed -n 's/.*digest: \(sha256:[0-9a-f]\{64\}\).*/\1/p' | tail -1)
  test -n "$d"
  echo "$img ${img%:*}@$d" >> image-digests.tmp
done
mv image-digests.tmp image-digests.txt

ci-integration (narrowed)

Keeps tags: [cma-runner-craig], timeout: 2h, after_script, artifacts and allow_failure: true; gains needs: [ci-build-images, ci-xtask]; extends: .ci-mr-vars replaces its variables: (the craig / local pins go). before_script: .cma-runner-bootstrap, cargo install cargo-nextest, the .ci-run marker, .ci-docker-engine, .ci-devstack-host-net, .ci-registry-login. script: .ci-field-key, .ci-mr-stack-up, then ./target/release/xtask test --skip-lint --profile ci-integration --fault-gate. Removed: the xtask build (D5), check-docs (D7), the image build and, in Step 3, the reseed and the four tail phases.

The fan-out jobs (new)

ci-e2e, ci-security-regression and ci-perf-smoke carry extends: .ci-fanout, a one-line script: (./target/release/xtask e2e --no-refresh / security --skip-zap --skip-fuzz / perf --profile smoke) and the integration rules. .ci-fanout (hidden, extends: .ci-mr-vars) holds timeout: 1h, the needs:, the as-built after_script and artifacts, and a before_script of the shape’s setup, then .ci-registry-login, .ci-field-key and .ci-mr-stack-up. ci-e2e still builds the Playwright craig-e2e image (a Node build outside the fault profile).

ci-sdk-test has no .ci-fanout: needs: [ci-xtask], the shape’s setup, script: chmod +x target/release/xtask and ./target/release/xtask sdk-test, .ci-sdk-rules, allow_failure: true.

  • Dind (the spike passed): image: $RUST_IMAGE, services: [docker:27-dind], tags: [dhs-aws-autoscaler-docker.medium], DOCKER_HOST: tcp://docker:2376, DOCKER_TLS_CERTDIR: "/certs", DOCKER_TLS_VERIFY: "1", DOCKER_CERT_PATH: /certs/client, plus the job-level settings the spike proved; setup apk add --no-cache docker-cli docker-cli-compose jq.

  • Fallback (the spike failed): tags: [cma-runner-craig]; setup .cma-runner-bootstrap, .ci-docker-engine and, for the stack jobs, .ci-devstack-host-net. The single-instance runner runs them one after another.

.ci-mr-stack-up is one - | item; the test guards stop an empty list passing vacuously.

set -euo pipefail
test -f target/release/xtask && test -s image-digests.txt \
  || { echo "artifacts missing or expired: run a new pipeline for this MR"; exit 1; }
chmod +x target/release/xtask
want=$(docker compose --profile fault config --images | grep "^${CI_REGISTRY_IMAGE}/" | sort -u)
test -n "$want"
test "$want" = "$(cut -d' ' -f1 image-digests.txt | sort -u)" \
  || { echo "image-digests.txt does not match compose's image set"; exit 1; }
while read -r ref pinned; do
  docker pull -q "$pinned" || { echo "cannot pull $pinned: run a new pipeline for this MR"; exit 1; }
  docker tag "$pinned" "$ref"
done < image-digests.txt
infra=$(docker compose --profile fault config --format json | jq -r --arg p "${CI_REGISTRY_IMAGE}/" \
  '.services | to_entries[] | select(.value.build and ((.value.image // "") | startswith($p) | not)) | .key')
test -n "$infra"
docker compose --profile fault build $infra
docker compose --profile fault up -d --wait --wait-timeout 900 --no-build
CRAIG_CASES__DATABASE_URL="postgres://craig:craig@localhost:5432/craig_cases" \
  ./target/release/xtask verify-seed --expect keyed

The job-shape test

ci_integration_job_is_a_bridge_scoped_non_blocking_detector (xtask/src/cmd/test.rs) is extended to the family; top_level_block already reads hidden keys. The pinned set grows per step (Steps); a pinned job or block missing from .gitlab-ci.yml fails the test.

  • The firewall assertions (present; each rule on -i docker0 ` or `-i br-+ `; `FORWARD only with --ctstate DNAT) read .ci-devstack-host-net. Every OTHER pinned job and hidden block has no iptables / ip6tables / nft ` / `ufw ` line, no pipe-to-shell and no `get.docker.com.

  • Each pinned job has allow_failure: true, no allow_failure: false, and the !reference to its D12 rules block.

  • ci-integration drives xtask test --skip-lint --profile ci-integration --fault-gate with no nextest run or --run-ignored. ci-build-images never references .ci-devstack-host-net and uploads image-digests.txt with when: on_success; the stack jobs reference .ci-mr-stack-up; ci-sdk-test references neither it nor ci-build-images.

  • No pinned job or block contains --cache-to, cache_to or CI_REGISTRY_IMAGE: craig; docker-compose.yml has no cache_to; `docker-promote’s tag rule is the D13 SemVer pattern.

Registry cleanup policy

A maintainer applies it once with glab api --method PUT projects/:id and the container_expiration_policy_attributes[…​] fields (name_regex_delete replaces the deprecated name_regex):

{"enabled": true, "cadence": "1d", "keep_n": 10, "older_than": "7d", "name_regex_delete": "^mr-[0-9]+-[0-9]+$", "name_regex_keep": null}

The check reads glab api projects/:id and compares only these six fields of container_expiration_policy (never next_run_at).

The ADR-080 amendment

== Amendment — #1739 records: D1 as the job family (placement, registry path, tag, manifest, no check-docs); D3 over every family job; D4’s rules in .ci-devstack-host-net; the #1347 tripwire naming ci-build-images; the "single serial job" tripwire retired; new tripwires (a stack job builds a service image or runs without the manifest; the policy’s six fields differ from the recorded JSON; a non-SemVer tag reaches docker-promote); Step 6’s numbers.

Steps

Step 1 pins ci-xtask, ci-build-images, ci-integration, .ci-devstack-host-net, .ci-docker-engine and .ci-mr-stack-up; Step 2 adds ci-security-regression, ci-e2e, ci-sdk-test and .ci-fanout; Step 3 adds ci-perf-smoke. A pinned job missing from .gitlab-ci.yml fails the test (no skip-if-absent).

  1. Shared blocks, the build, the narrowed battery. The hidden blocks, ci-xtask, ci-build-images with the manifest, docker-promote’s SemVer tag rule; `ci-integration switched to the manifest, keeping its tail phases until Step 3 so no MR pipeline loses a phase. Extend the job-shape test.

  2. Spike. On the branch’s MR pipeline, add ci-security-regression, ci-e2e and ci-sdk-test in the dind shape. The spike passes when all three go green with job-level settings only (variables:, /etc/hosts lines, image packages), with no change to xtask or docker-compose.yml: security dials localhost:<port> from the job container; e2e proves Playwright’s OIDC redirect through host.docker.internal and that the LFS screenshot baselines arrive (the docker executor’s helper smudges them; #1891’s git lfs pull is instance-only); sdk-test proves a bind mount of the checkout reaches the dind daemon. Record runs and timings on #1739. On a fail, use the fallback shape and file a chore: issue for DOCKER_HOST-aware service addressing in xtask.

  3. Fan-out. Add ci-perf-smoke in the chosen shape; remove the reseed and the four tail phases from ci-integration.

  4. Registry cleanup. A maintainer applies the policy; its six fields go into the amendment (Step 5).

  5. Docs. The ADR-080 amendment; Testing Reference (CRAIG) (the CI-stage list, the Runner Tags list, the ci-integration entry); Known Issues & Lessons Learned (the detector note: the job family, the registry path, and that a missing-artifact red means running a new pipeline); a CHANGELOG.adoc == Unreleased entry.

  6. Measure. From the MR pipelines: the wall-clock from pipeline start to the last family job’s finish, against the median of the as-built ci-integration’s last five completed MR runs; each fan-out job’s stand-up time (pull, `up, seed); the aggregate tagged-image size (the sum of total_size over the pushed tags from GET projects/:id/registry/repositories/<repo_id>/tags/<tag>; it counts shared layers, not transfer). Record them on #1739 and in the amendment. The dind shape meets all five #1739 criteria if its wall-clock is lower. The fallback meets criteria 2 (independent verdicts), 4 (per-job stand-up, measured) and 5 (per-phase allow_failure), plus the retry-without-rebuild cost, but not 3 (parallel wall-clock); #1739 then closes with a pointer to the Step 2 follow-up, which owns criterion 3. If the dind wall-clock is not lower, the dind shape still ships (criteria 2, 4 and 5 are met): record the numbers, file a chore: issue that owns criterion 3, and close #1739 with a pointer to it.

Files Touched

  • .gitlab-ci.yml: the hidden blocks; new ci-xtask, ci-build-images, ci-e2e, ci-sdk-test, ci-security-regression, ci-perf-smoke; ci-integration narrowed; `docker-promote’s tag rule.

  • xtask/src/cmd/test.rs: the job-shape test extended to the family.

  • docs/modules/ROOT/pages/adrs/adr-080-ci-server-side-test-gate.adoc: == Amendment — #1739.

  • docs/modules/ROOT/pages/testing-reference.adoc: the CI-stage list, the Runner Tags list, the ci-integration entry.

  • docs/modules/ROOT/pages/known-issues.adoc: the detector note for the job family.

  • CHANGELOG.adoc: an == Unreleased entry.

Verification

  1. glab ci lint passes.

  2. cargo xtask validate passes, including the extended job-shape test. Checked once locally and not committed: deleting allow_failure: true from any family job, or adding an unscoped iptables line to any family job or hidden block other than .ci-devstack-host-net, fails it.

  3. ci-build-images pushes as many tags as D2’s compose command prints (16 today) and uploads a manifest with that many lines. Cancelling it mid-push uploads no manifest, and the stack jobs then fail on the missing-artifact line.

  4. The stack jobs each log digest pulls and no service-image build, and pass; ci-sdk-test pulls no image.

  5. An SDK-only MR runs exactly ci-xtask and ci-sdk-test.

  6. Retrying one fan-out job alone reuses the manifest. Once a manifest digest is unpullable (its image deleted from the mr/ repository), a retry fails with the "run a new pipeline" line; a new pipeline goes green.

  7. The ci-xtask binary runs on the Debian microVM and in the fan-out jobs.

  8. In the dind shape, the fan-out jobs' started_at / finished_at overlap.

  9. The policy’s six fields read back as recorded, and a cadence run leaves every tag in the release repositories.

Review log

round vendor resolved model verdict

1

Anthropic — the landing review of the teammate’s plan MR (plan checked against main, the as-built job and the rules)

Claude Opus 5.5

no-ship (blocker B1) — B1, B2, M1–M3, m1–m5, n1, n3 folded

verify

Anthropic — one fresh contextless verifier over the folds

Claude Opus 5.5

no-ship — 2 blockers and 10 defects, all fixed

2

maintainer-run (2026-09-29)

as reported

no-ship — 9 findings folded: per-pipeline tags and the success-only digest manifest, the firewall guard over every block, the reserved SemVer tag namespace, the SDK rules and the devstack-free SDK job, new-pipeline recovery, the normalized policy check, the image-size naming, the protected-variable wording

Edit this page · latest