Repository navigation
ci(merge-train): exact-SHA train proof with train-gate (merge-queue v2 step 1) - #4582
Merged
Merged
Conversation
Add .github/workflows/merge-train.yml: a push to queue/t*/p* or queue/b*/p* (or a manual dispatch) proves that exact SHA and reports one train-gate check. The -guard/-full ref suffix sets the scope: - scope parses the ref and resolves the train base (Queue-Base trailer, else the merge base with origin/main); - guard runs the lint chain, the architecture ratchet contracts, the remaining tests/quality module and the NOTICE check, with caches off; - tier1 and tier2 call ci.yml and ci-integration.yml through new workflow_call triggers (optional base_sha input); only tier2 inherits secrets, and each tier gets the union of its callee's permissions; - train-gate (if: always()) passes only when every job is green, with the tiers skipped on guard scope, and writes a step summary. Move the Lint steps into the .github/actions/lint-chain composite action, used by ci.yml's Lint job and the train guard, so the chain has one owner. pull_request and merge_group behaviour is unchanged. tests/quality/test_ci_topology.py pins the triggers, full-scope coverage of every merge_group EXPECTED_CHECKS name (derived from the workflows), the gate, the cache contract and the lint-chain owner, with mutation cases. Workflow uv and lint-step contracts now read local composite action steps. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 09:53
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical gaps can certify the wrong SHA, bypass baseline checks, reuse shared caches, and mistake a guard-only pass for a full proof.
7 open issues
Reject guard dispatches whose requested SHA differs from the event SHA · New Require Queue-Base to match the train head’s main merge base · New Disable shared caches for full trains in reusable workflows · New Verify full-proof scope, SHA, and successful gate · New Restrict lint-chain changes to lead maintainer approval · New Skip scope and gate checks for queue-branch deletions · New Use unique concurrency groups to preserve pending train runs · New
What changed in this PR
This PR adds step 1 of merge-queue v2 (#4574): running existing CI tiers against speculative queue commits and reporting their results through train-gate, before those commits land on main.
Changes:
- Adds guard-only and full train runs, with base resolution and an aggregate gate.
- Makes both CI tiers reusable and extracts the lint chain into a shared composite action.
- Adds topology contracts and documents the train workflow.
| File | Description |
|---|---|
tests/workflow_contracts.py |
Adds helpers to inspect composite-action steps. |
tests/unit/test_windows_native_symlink_workflow.py |
Follows the extracted action when checking lint coverage. |
tests/quality/test_ci_topology.py |
Adds train topology and mutation contracts; adapts existing action checks. |
scripts/check_complexity_ratchet.py |
Updates a comment identifying the lint path-list owner. |
docs/src/content/docs/contributing/integration-testing.md |
Documents train refs, scopes, and proof lookup. |
.github/workflows/merge-train.yml |
Adds scope resolution, guards, reusable tiers, and train-gate. |
.github/workflows/ci.yml |
Adds reusable-workflow inputs and delegates linting to the composite action. |
.github/workflows/ci-integration.yml |
Adds a reusable-workflow entry point and optional base input. |
.github/instructions/cicd.instructions.md |
Documents train topology and operating constraints. |
.github/actions/lint-chain/action.yml |
Centralizes the lint chain shared by CI and train guards. |
Review effort: Balanced
…tions from source (#4574) CodeQL flagged cache poisoning: the workflow_dispatch `ref` input let the guard check out an arbitrary SHA. Drop the input. Every job now checks out the triggering commit, a manual probe dispatches the queue branch itself (`gh workflow run merge-train.yml --ref queue/t<id>/p<k>-full`), and the scope job fails on any ref that is not queue/t<id>/p<k>-guard|-full or queue/b<sha12>/p0-full, whatever the event. The topology contracts pin a dispatch without inputs and default-ref checkouts, with mutation cases. APM Self-Check reported hash drift on the deployed cicd instructions. Put the merge-train section in the .apm/instructions source, redeploy with the tree's apm, and update the two lock hash lines; `apm audit --ci` is clean. Co-authored-by: Copilot App <[email protected]>
5 of 10 tasks
7 of 11 tasks
…#4574) Amendment A plus accepted #4582 review threads: - Caches: merge-train's guard restores caches (main's included) but never saves (setup-uv enable-cache: true, save-cache: false). ci.yml and ci-integration.yml are unchanged: under the call they save only into the queue branch's scope. The train contract now forbids any cache save in merge-train.yml and the lint chain; lifecycle-journeys stays caches-off. - cleanup deletes the train branch after train-gate (if: always(), the only job with contents: write, refs re-validated in the step, tolerates an already-deleted branch); train-gate never needs it. - Every job skips the push a branch deletion fires (github.event.deleted), so no failing check lands on main's commit. - Each run gets its own concurrency group, so a pending run is never replaced. - A Queue-Base trailer must equal the merge base with main; an older ancestor would weaken the baseline-growth ratchets. - CODEOWNERS gives .github/actions/** the workflow review bar. - Docs: queue refs are branches, restore-only caches, cleanup, and a full proof is a successful run on the -full branch at the exact SHA. The cicd instructions are edited at source and redeployed with the tree apm. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
main's #4337 requires Spec conformance gate and Spec tests (1-3/3) in merge_group, so a full train must produce them. spec-conformance.yml gains a workflow_call trigger, merge-train.yml calls it as the spec tier, and train-gate reads its result. Co-authored-by: Copilot App <[email protected]>
…ier (#4574) Co-authored-by: Copilot App <[email protected]>
Merged
5 of 9 tasks
…le_user_writes) (#4574) Co-authored-by: Copilot App <[email protected]>
…train # Conflicts: # apm.lock.yaml
…train # Conflicts: # .apm/instructions/cicd.instructions.md # .github/instructions/cicd.instructions.md # apm.lock.yaml
This was referenced Nov 21, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description
This is merge-queue v2 step 1: the exact-SHA train proof. Pushing a speculative ref
queue/t<id>/p<k>-full(or-guard, or the base probequeue/b<sha12>/p0-full) now produces ONEtrain-gateverdict on that exact SHA. That verdict covers the full merge-time gate, including hermetic integration, which today runs only onmerge_groupand on dispatch..github/workflows/merge-train.yml:queue/t*/p*andqueue/b*/p*, plusworkflow_dispatch. There is nopull_request_targetand no other push.scope: parses-guardor-full. The base comes from theQueue-Base:trailer, or elsemerge-basewith main.guard: the shared lint chain, the test-architecture ratchet contracts, the onetests/qualitymodule those leave out, and the NOTICE drift check (on the merge_group required list).tier1: callsci.yml.tier2: callsci-integration.yml, withsecrets: inheritbecause only it needs secrets.train-gate:always(). It passes only when every job is green, or when tier1 and tier2 areskippedfor a-guardref.ci.ymlandci-integration.ymlgain aworkflow_calltrigger with an optionalbase_shainput. Base expressions append|| inputs.base_sha. Nopull_requestormerge_groupjob behaviour changes..github/actions/lint-chain. ci.yml'sLintjob and the trainguardboth use it, so the chain has one owner.tests/quality/test_ci_topology.pycontracts, each with mutation-style negative cases:EXPECTED_CHECKSname, derived from the workflows rather than hardcoded;always();Existing frozen-environment and symlink-lint contracts now also read the composite's steps; none were weakened.
cicd.instructions.mdandcontributing/integration-testing.md.Deferred to step 3, where the runner first needs it: JUnit XML upload from every test job. No ruleset change, no
--adminchange.Issue and approved scope
Issue: Fixes #4574
Human scope-approval comment: the
apm-scope:v1record is in the issue body. The merge-queue v2 design and plan were approved by the regent on Daniel's behalf on 2026-11-21, and the work is owned by Ops (DM v3).Does this PR complete the issue, or what remains? It completes step 1. Acceptance runs on queue refs follow merge: (a) a ref at main's SHA is green; (b) a seeded lint-budget break fails
guard; (c) a-guardref runs only scope, guard and train-gate.Type of change
Testing
test_ci_topology.pycases, 44 passed. 13 other workflow and quality contract files, 266 passed. ruff 0.15.12 check and format clean. actionlint clean (one SC2086 already on main). The architecture-boundary, auth-signal, complexity-ratchet, taxonomy-allowance and taxonomy--changedchecks are all clean.test_ci_topology.pyfailed locally only because the shared venv imported a stalesrc.Changelog
## [Unreleased]inCHANGELOG.mdSpec conformance (OpenAPM v0.1)