merge-train-infra
Skill458 starsChanged 2 months agoApache-2.0View on GitHub
Reference for merge-train automation internals -- workflows, scripts, CI integration, and configuration. Use when modifying or debugging merge-train infrastructure.
- Reads credentials
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
If the merge-group event is for merge-train/spartan-v5 → upgraded to merge-queue-heavy mode (10 parallel grind runs instead of 4)
- Very specific: line 74
When a CI run fails on an EC2 instance, it calls merge_train_failure_slack_notify to send failure notifications to the appropriate Slack …
- Very specific: line 79
Add the branch to the loop in .github/workflows/merge-train-next-to-branches.yml.
- Very specific: line 81
Add the branch-to-Slack-channel mapping in ci3/merge_train_failure_slack_notify
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Merge-Train Infrastructure
This skill covers the automation internals of the merge-train system. For contributor-facing guidance (creating PRs, labels, handling failures), see the merge-trains skill.
Automation Lifecycle
The merge-train system is fully automated via GitHub Actions in .github/workflows/merge-train-*.yml:
- PR Creation (
merge-train-create-pr.yml): Triggered on push tomerge-train/*branches. Creates a PR targetingnext(orv5-nextfor-v5trains such asmerge-train/spartan-v5andmerge-train/fairies-v5) with theci-no-squashlabel (plusprivate-port-nextfor any train that targetsv5-next, andci-full-no-test-cacheformerge-train/spartan,merge-train/spartan-v5, andmerge-train/ci). Skips merge commits and commits already in the base branch. - Body Updates (
merge-train-update-pr-body.yml): Triggered on push tomerge-train/**branches. Updates the PR body with meaningful commits (those containing PR references like(#1234)). The body wraps the commit list inBEGIN_COMMIT_OVERRIDE/END_COMMIT_OVERRIDEmarkers. - Next Integration (
merge-train-next-to-branches.yml): Triggered on push tonextandv5-next. A push tonextmergesnextinto eachnext-based train; a push tov5-nextmergesv5-nextinto the-v5trains (merge-train/spartan-v5,merge-train/fairies-v5). Both go throughscripts/merge-train/merge-next.sh, which takes an optional second argument for the source branch (defaults tonext). Usescontinue-on-error: trueso a conflict in one branch does not block others. Skips branches whose PR already has auto-merge enabled. - Auto-Merge (
merge-train-auto-merge.yml): Runs hourly via cron (0 * * * *). Callsscripts/merge-train/auto-merge.shfor merge-train branches (4-hour inactivity). Uses separate GitHub tokens:AZTEC_BOT_GITHUB_TOKENfor API calls andMERGE_TRAIN_GITHUB_TOKENfor approvals. Will not auto-merge if the last merge-queue CI run failed or was cancelled. - Recreation & Wakeup (
merge-train-recreate.yml): Triggered when a PR is closed (merged). If the merged PR's head branch starts withmerge-train/, recreates the branch from the base branch (usuallynext). Then runsscripts/merge-train/wakeup-prs.shto add theci-wakeup-pr-after-mergelabel to all open PRs targeting the branch that have passed CI and have automerge enabled. This triggers a CI re-run (typically a no-op via tree-hash cache) so those PRs can proceed through the merge queue. The label is immediately removed by a step inci3.ymlso it can be re-applied on subsequent merges. - Failure Notification (
merge-queue-dequeue-notify.yml): Triggered when a PR is dequeued from the merge queue. If the PR's head branch starts withmerge-train/and the PR was NOT merged, sends a Slack notification viaci3/merge_train_failure_slack_notify.
Release-Line Ports
Ports between release lines are not automated in this repo. A PR labelled port-to-<branch> (for example port-to-v6 or port-to-next) is ported by ClaudeBox, which watches merged PRs through the GitHub webhook; see the root CLAUDE.md. The labs half of the tree lives in aztec-node, so mark-v5-port-candidates.yml labels PRs against v5/v5-next with port-to-aztec-node for a person to port there.
CI Integration Details
CI Mode Selection (.github/ci3_labels_to_env.sh)
Merge-train branches influence CI mode:
merge_groupevents orci-merge-queuelabel →merge-queuemode- If the merge-group event is for
merge-train/spartan-v5→ upgraded tomerge-queue-heavymode (10 parallel grind runs instead of 4) - Target branch
merge-train/barretenberg→ci-barretenbergmode
CI Concurrency (.github/workflows/ci3.yml)
group: ci3-${{ (startsWith(github.event.pull_request.head.ref, 'merge-train/') && github.run_id) || ... }}Merge-train PRs get full concurrency (each run has its own unique group via github.run_id), while non-merge-train PRs share a group by branch name with cancel-in-progress.
Instance Postfix (.github/ci3.sh)
if [[ "${PR_HEAD_REF:-}" == merge-train/* ]]; then
export INSTANCE_POSTFIX=${PR_COMMITS:-}
fiMerge-train PRs get a unique instance postfix (commit count) to allow parallel EC2 instances.
CI Modes in bootstrap.sh
ci-barretenberg: Only builds and tests barretenberg (AVM disabled)ci-barretenberg-full: Full barretenberg CI including acir_testsmerge-queue: 4x AMD64 full + 1x ARM64 fast in parallelmerge-queue-heavy: 10x AMD64 full + 1x ARM64 fast in parallel (used formerge-train/spartanandmerge-train/spartan-v5)
Test History Tracking (ci3/run_test_cmd)
if [[ "$is_merge_queue" -eq 1 || ("${TARGET_BRANCH:-}" =~ ^v[0-9]) || ("${TARGET_BRANCH:-}" == merge-train/*) ]]; then
track_test_history=1
fiFailure Notification (ci3/bootstrap_ec2)
When a CI run fails on an EC2 instance, it calls merge_train_failure_slack_notify to send failure notifications to the appropriate Slack channel based on the branch name.
Creating a New Merge Train
- Create a branch from the desired base (
nextfor most trains; a release line likev5-nextfor a release-specific train) with naming patternmerge-train/{team}. For a v5-release train use the-v5suffix (merge-train/{team}-v5):merge-train-create-pr.ymlroutes any*-v5branch to av5-nextbase automatically and adds theprivate-port-nextlabel. - Add the branch to the loop in
.github/workflows/merge-train-next-to-branches.yml. If it tracks a base branch other thannext, also add that base to the workflow'spushtrigger and pass it as the second argument tomerge-next.sh(see thev5-next→-v5trains wiring) - For a base other than
nextthat the*-v5convention does not already cover, set the PR base in.github/workflows/merge-train-create-pr.yml. Either way, add a stale-check job that passesBASE_BRANCHin.github/workflows/merge-train-stale-check.yml - Add the branch-to-Slack-channel mapping in
ci3/merge_train_failure_slack_notify - Optionally add CI mode overrides in
.github/ci3_labels_to_env.shandbootstrap.sh - Push code to the branch -- automation handles PR creation from there
Key Files Reference
Workflows
| File | Purpose |
.github/workflows/merge-train-readme.md | User-facing documentation |
.github/workflows/merge-train-create-pr.yml | Auto-creates PRs for train branches |
.github/workflows/merge-train-auto-merge.yml | Hourly cron to auto-merge inactive trains |
.github/workflows/merge-train-next-to-branches.yml | Syncs next into all train branches; defines active branches |
.github/workflows/merge-train-recreate.yml | Recreates branch after merge |
.github/workflows/merge-train-update-pr-body.yml | Updates PR body with commit list (merge-train branches) |
.github/workflows/merge-queue-dequeue-notify.yml | Slack notification on merge-queue dequeue |
.github/workflows/squashed-pr-check.yml | Squash enforcement (skipped for ci-no-squash) |
Scripts
| File | Purpose |
scripts/merge-train/auto-merge.sh | Auto-merge logic -- checks inactivity, last CI status, approves and merges |
scripts/merge-train/merge-next.sh | Merges next into a train branch, handles conflicts, cancels stale CI runs |
scripts/merge-train/update-pr-body.sh | Updates PR body with meaningful commits |
scripts/merge-train/squash-pr.sh | Squashes PR commits (used by ci-squash-and-merge label) |
scripts/merge-train/wakeup-prs.sh | Adds ci-wakeup-pr-after-merge label to qualifying PRs after branch recreation |
CI Configuration
| File | Purpose |
.github/ci3_labels_to_env.sh | CI mode selection based on labels and target branches |
.github/ci3.sh | Instance postfix for merge-train parallelism |
ci3/merge_train_failure_slack_notify | Slack failure notification with branch-to-channel mapping |
ci3/run_test_cmd | Test history tracking for merge-train branches |
ci3/bootstrap_ec2 | EC2 failure notification trigger |
bootstrap.sh | CI mode definitions (ci-barretenberg, ci-full, etc.) |
Other Scripts
| File | Purpose |
scripts/auto_close_issues.py | Auto-closes issues referenced in merged merge-train PRs (GitHub's native auto-close doesn't work for intermediate branches) |
scripts/find_orphaned_issues_in_prs.py | Finds PRs in merge-train commits that reference still-open issues |
scripts/dedupe_release_notes.py | Deduplicates release notes from merge-train merges |
scripts/commits | Pretty git log that groups merge-train children by subsystem |
scripts/filter_history | Filters git history, identifying merge-train merge commits as "containers" |
In this repository22 other files it gives its agents.
- avm-transpiler/CLAUDE.mdCLAUDE.md
- barretenberg/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- docs/llms.txtllms.txt
- acir-formal-proofsSkill
- adding-benchmarksSkill
- bench-regressionSkill
- capture-app-flowSkill
- chonk-inputsSkill
- ci-logsSkill
- create-issueSkill
- cycleSkill
- fixSkill
- genesis-constantsSkill
- merge-trainsSkill
- noir-sync-updateSkill
- prep-cycleSkill
- release-docsSkill
- release-network-docsSkill
- update-doc-referencesSkill
- updating-changelogSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

