Plan: the merge train is the merge gate, and git push runs the static checks only
Closes: #960. Branches: chore/ci-merge-train-gate, then chore/ci-first-car. Status: Done (2026-11-28) — merge train is the merge gate (!1044 798ab5522)
Context
The operator’s ruling (2026-11-28, in conversation): make this repository’s CI/CD mirror craig’s and canopy’s, with minimal testing on the pre-push hook and the heavy tests in CI. Two forks, answered the same day: the hook runs the static checks only, no suite; consumer-sim’s live-model rows run once per release, locally, before the tag.
What the tree and GitLab say today:
-
.githooks/pre-pushverifies signatures, guardsmain, and runsnode tools/task.mjs prepush-validate: the wholevalidate, unlesstools/lib/validate-stamp.mjsfinds it already passed on the pushed tree. -
validateintools/task.mjsislint,typecheck,spdx,planLint, the themes drift check,bundle,testandtestAsRoot.testAsRoot(tools/lib/as-root.mjs) repeats the suites underunshare -r; when the caller is root already it skips, so CI, whose container is root, runs the suites as root only. -
.gitlab-ci.ymlrunsvalidateon an MR’s pipeline, onmainand on a release tag, andrehearse(consumer-sim --no-model) on tags only. A branch pushed before its MR exists gets a pipeline of its own, so one MR costs three pipelines. -
The project’s settings (read through the API, 2026-11-28):
merge_trains_enabled,merge_pipelines_enabledandonly_allow_merge_if_pipeline_succeedsare false; the push rule’sreject_unsigned_commitsis unset. Nothing server-side waits for a pipeline: an MR is merged seconds after its push, and its pipeline ends five to seven minutes later (pipelines 3127792786, 3127670764: thevalidatejob 438 s and 313 s). -
The last local validate (
.pi/scratch/p952-validate.log) and the CI job of the same tree (pipeline 3127792786) disagree on what ran. Run as an ordinary user and skipped or not collected as root: 39 tests (pi-ssh 33, pi-agents 2, pi-modes 2, pi-remote 1, tools/lib 1). Run locally and skipped in CI: 35 (model-battery 33, pi-shellcheck 1, pi-vertex 1). -
The workspace token is a Maintainer’s (
permissions.project_access.access_level40).
Design
1. One verb for the static checks
tools/task.mjs gains check: lint(), typecheck(), spdx(), planLint() and node tools/generate-themes.mjs --check, in that order, the lines validate opens with today. validate becomes check(); bundle(); test(); testAsRoot(); and its closing === validate: OK === line. It writes no stamp. prepush-validate, prepushValidate and the import from ./lib/validate-stamp.mjs are removed; tools/lib/validate-stamp.mjs and tools/lib/test/validate-stamp.test.mjs are deleted with them. The stamp existed to skip a long hook, and its second job (#409: the pushed commit is the tree validate read) passes to CI, which checks out the commit. The file’s header comment lists check, drops prepush-validate and stops calling validate the pre-push battery.
2. The hook
.githooks/pre-push keeps its core.hooksPath warning, the branch-deletion exit and the direct-to-main guard as they are. The signature loop and the validate block are removed. Its last step is:
echo "=== pre-push: task check ===" >&2
node tools/task.mjs check
echo "=== pre-push: OK ===" >&2
Its header says what it is: the static checks before a push; the merge train’s pipeline runs the battery and decides the merge; the push rule refuses an unsigned commit.
3. The pipeline
| Job | MR’s own pipeline | Merge-train car | main |
vX.Y.Z tag |
|---|---|---|---|---|
|
runs |
- |
- |
- |
|
by hand |
runs, blocks |
- |
runs |
|
by hand |
runs, blocks |
- |
runs |
|
by hand |
runs, blocks |
- |
runs |
|
- |
- |
- |
as today |
|
- |
- |
as today |
- |
signature-check is deleted. The three car jobs share one stage, so they run side by side. The changed parts of .gitlab-ci.yml:
stages:
- security # lint, and GitLab's scans
- test # the car: validate, validate-unprivileged, rehearse
- release
- published
- pages
workflow:
auto_cancel:
on_new_commit: interruptible
rules:
# MR, merged-results and merge-train pipelines all arrive as this source; a failed job cancels the rest.
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
auto_cancel:
on_new_commit: interruptible
on_job_failure: all
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
# The car: automatic and blocking on a merge train and on a release tag; by hand on an MR's own pipeline.
.car-rules:
rules:
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
lint:
extends: .node-pnpm
stage: security
interruptible: true
tags:
- $RUNNER_2XLARGE
script:
- node tools/task.mjs check
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE != "merge_train"
validate:
extends: [.node-pnpm, .car-rules]
stage: test
interruptible: true
tags:
- $RUNNER_2XLARGE
script:
- node tools/ci-search-tools.mjs /usr/local/bin
- node tools/task.mjs validate
validate-unprivileged:
extends: [.node-pnpm, .car-rules]
stage: test
interruptible: true
tags:
- $RUNNER_2XLARGE
script:
- node tools/ci-search-tools.mjs /usr/local/bin
- node tools/task.mjs bundle
- chown -R node:node "$CI_PROJECT_DIR"
- setpriv --reuid=node --regid=node --init-groups env HOME=/home/node node tools/task.mjs test
rehearse:
extends: .node-pnpm
stage: test
interruptible: true
tags:
- $RUNNER_2XLARGE
script:
- !reference [.pi-host, script]
- node tools/task.mjs consumer-sim --no-model
rules:
- !reference [.car-rules, rules]
- if: $CI_COMMIT_TAG =~ /^test-publish-/
validate keeps its two comment lines about ci-search-tools. validate-unprivileged is the pass a developer’s task validate makes first: task test as a user who is not root, so the 39 tests that need a permission to bite run before a merge. bundle runs first because the distribution’s tests read packages/pi/dist/; node is the node image’s own user. The comment block above validate ("DIVERGENCE FROM THE UPSTREAM STANDARD") is replaced by one that says the car is the gate and why two jobs run the suites. .publish-base, publish, publish-dry-run, published, pages, .pi-host, .node-pnpm and the scan overrides stay as they are.
4. Signatures: the push rule
reject_unsigned_commits on the project’s push rule refuses an unsigned commit at the push, which is where the hook’s loop and the signature-check job looked. It is set before the MR that removes those two merges (Order, step 5).
5. The project’s settings
P=projects/gadhs%2Fstandard%2Fpackage%2Fpi
glab api $P/push_rule -X PUT -F reject_unsigned_commits=true # step 5
glab api $P -X PUT -F merge_pipelines_enabled=true -F merge_trains_enabled=true \
-F only_allow_merge_if_pipeline_succeeds=true -F allow_merge_on_skipped_pipeline=false \
-F merge_trains_skip_train_allowed=false # step 7
# undo, the operator's call when the runners are down:
glab api $P -X PUT -F merge_trains_enabled=false -F merge_pipelines_enabled=false \
-F only_allow_merge_if_pipeline_succeeds=false
Each call is read back with a GET before the next step. A call the API refuses stops the work there and goes to the operator.
6. Landing an MR
AGENTS.md, "Agent session constraints (operator-set)": the bullet "Merge your own MR once the pre-push validate passes" is replaced by this text, which the operator approves with the plan:
The merge train is the merge gate (#960).
git push -u origin <branch>(the hook runs the static checks,task check, and nothing else),glab mr createwithCloses #N, then add the MR to the train:glab api -X PUT projects/gadhs%2Fstandard%2Fpackage%2Fpi/merge_requests/<iid>/merge -F auto_merge=true -F squash=false -F sha=<HEAD>. No approval is needed. The train’s pipeline runs the battery on the merged result and merges on green; the same call withoutauto_mergeanswers 405 by design. Wait for the merge in a job or a monitor that ends when the MR is merged or has left the train. A dropped car is a finding: fix it and add it again. Then note the merge SHA on the issue.task validateandconsumer-simin full are the release rehearsal, run here before a tag.
7. The release rehearsal
A release keeps its local run, once: on the release commit, before release tag, node tools/task.mjs validate and node tools/consumer-sim.mjs in full on a box with ADC. It is the one place consumer-sim’s 12 model rows run, and the tests the car’s image has no tool for. The release MR lands through the train like any other; the tag pipeline is unchanged in what it runs.
Scope
| File | Change |
|---|---|
|
Design 1 |
|
deleted (Design 1) |
|
Design 2 |
|
Design 3 |
|
new: Tests, T1 to T6 |
|
Design 6 |
|
§ The task runner: a |
|
§ Contributing: |
|
the "must be green before push" step and the Development block name |
|
the CI images row: |
|
this plan, under Active |
|
|
packages/pi/test/distribution.test.ts reads .gitlab-ci.yml for the publisher line and the single pi pin; both stay, and the file is not edited.
Not in scope, each an issue or dropped: an Antora build on an MR’s pipeline; GitLab’s scans on MR pipelines (they stay on main, where the templates put them once bare-branch pipelines are gone); a switch that turns a skip the car should not have into a failure; Vertex credentials in CI; a Windows runner; `main’s push access.
Order of work
-
Release 0.185.0 finishes as releases have so far: its branch
chore/release-0.185.0is cut and unpushed, and it is not part of this plan. -
File the issue. Branch
chore/ci-merge-train-gatefrommain; commit this plan and its nav line; StatusIn progress. -
Design 1 to 3 and 6, the tests, the docs and the CHANGELOG entry, in commits on that branch. One full local
task validate, and each mutant of Tests planted and seen to fail its test. -
Push (V2), open the MR. On its pipeline
lintruns by itself; startvalidate,validate-unprivilegedandrehearseby hand (V1). A red job is fixed on the branch until the three are green. -
Set the push rule (Design 5, first call) and read it back; V6.
-
Merge the MR with the direct call, the last one made.
-
Flip the settings (Design 5, second call) and read them back.
-
Branch
chore/ci-first-car: this plan’s Status toDone (date) — …, with anErratumline for any deviation. Push, MR, V3, then add it to the train (V4). -
V5, the red car.
-
Note the merge SHAs on the issue; file the follow-up issue V1’s table calls for, if it has rows, and the one that asks whether GitLab’s scans join the car; post the new flow to
pi-winon the bus.
Tests
Contract, tools/lib/test/ci-gate.test.mjs. Each reads the files as text; a job’s block is the lines from its name at column 0 to the next line that starts at column 0.
| Test | Asserts | Mutant it fails on |
|---|---|---|
T1 |
|
the bare-branch rule put back |
T2 |
|
|
T3 |
|
a |
T4 |
|
the |
T5 |
the hook and the |
the hook’s line changed to |
T6 |
|
|
tools/lib/test/validate-stamp.test.mjs is deleted because the code it tests is; no other test is removed or changed.
Observed, recorded on the MRs:
-
V1 (step 4). The three car jobs green on the first MR’s pipeline. A table per package: tests run locally as user and as root (
.pi/scratch/p952-validate.log), run byvalidate-unprivileged, run byvalidate; every test in a difference is named with what it needs. -
V2 (step 4). The push runs
task checkand no suite; its wall time is recorded. A type error planted in the worktree refuses a push; it is removed. -
V3 (step 8).
PUT …/mergewithoutauto_mergeanswers 405. -
V4 (step 8). The first car: its train pipeline ran
validate,validate-unprivilegedandrehearsewithout a hand, the MR merged, andmain’s pipeline ran `pagesand the scans only. -
V5 (step 9). A branch whose one change is a failing assertion in
tools/judge-field(it passestask check), its MR added to the train: the car is dropped andmaindoes not move. The MR is closed; deleting its branch is the human’s step. -
V6 (step 5). A commit made unsigned with
git commit-treeand pushed torefs/heads/scratch/unsigned-probeis refused by GitLab.
Risks
| Risk | Kind | Mitigation |
|---|---|---|
The runner fleet is down or queued: no car runs and nothing merges |
fail-closed |
the undo call of Design 5, the operator’s decision, documented in |
A test that needs a tool the car’s image lacks skips there and no longer runs before a merge (35 today) |
silent |
V1’s table names each; the release rehearsal (Design 7) runs them before every tag; a follow-up issue for the rest |
The unprivileged pass cannot run in the container (no |
fail-closed |
the job is red at V1, before any setting changes |
Consumer-sim’s model rows no longer run for each MR: a break in model-facing wiring reaches |
silent until the release rehearsal, fail-closed there |
Design 7; the same run by hand for a change to a judge, review or helper prompt |
The hook reads the worktree, so a dirty tree can pass for a broken commit |
fail-closed |
CI checks out the commit: |
The hook is skipped ( |
fail-closed |
|
A pipeline is skipped or has no job, and the MR merges untested |
fail-closed |
|
A Maintainer pushes to |
silent |
the hook’s main guard, unchanged; pi’s commit guard refuses a commit on |
The push rule is not in force when the local and CI signature checks are removed |
fail-open |
step 5 sets it and V6 proves it before step 6 merges their removal |
A tag is cut on a tree no car tested |
fail-closed |
the tag pipeline runs the car’s jobs before |
A car is dropped and nobody looks |
silent |
Design 6: the wait is a job or monitor that ends on merged or dropped and wakes the session |
A Windows-only break |
silent, as today |
unchanged: |
GitLab’s scans (SAST, secret detection) ran on a branch’s own pipeline before its MR merged; with that pipeline gone they first run on |
silent |
they blocked no merge before either (the MR merged while they ran); an issue filed in step 10 asks whether they join the car |
Delivery
The canonical page is docs/modules/ROOT/pages/local-dev.adoc; the release note is the "Repo only" entry in CHANGELOG.adoc == Unreleased (nothing ships: no package changes). The first MR carries Relates to #960, the first car Closes #960. After the car merges: the merge SHAs on the issue, the follow-up issues of step 10, and the bus post to pi-win.