ADR-3556: Trigger required checks and aggregator on merge-queue merge_group events¶
- Status: Accepted (Superseded-in-part 2026-11-22 by ADR-3610 for queue admission of fork pull requests)
- Date: 2026-11-16
- Deciders: Project maintainer
- Tags: ci, fork-local
Context¶
Branch protection on master requires one status check, Required Checks Aggregator (ADR-0313, ADR-1297). When master merges pull requests through a GitHub merge queue, GitHub dispatches merge_group events (types: [checks_requested]) on synthetic queue refs (refs/heads/gh-readonly-queue/master/...), setting GITHUB_SHA to the merge group's head commit and GITHUB_REF to the queue ref. Workflows that trigger only on pull_request and push never start on a merge group, leaving Required Checks Aggregator and its owed check contexts absent so the merge queue stalls.
Two required contexts cannot run on a merge group. Scorecard Master Gate (.github/workflows/scorecard.yml) publishes OpenSSF Scorecard results (publish_results: true, allowed only on the default branch) and checks git/ref/heads/master (scripts/ci/scorecard_gate.py master). Scorecard PR Gate (.github/workflows/security-scans.yml) requires a pull-request event payload and already ran on the pull request before queueing. Meanwhile, steps and jobs that publish packages, push container images, deploy Pages, sign releases, or write to the repository must remain confined to their existing release, dispatch, or master push events and never execute on a speculative merge group.
Decision¶
Merge pull requests into master through a GitHub merge queue (the master ruleset merge_queue rule is applied separately through the GitHub rulesets API with read-back after this change lands, so merge_group runs start only from then on), and add merge_group (types: [checks_requested], branches: [master]) to .github/workflows/required-aggregator.yml and to every calling workflow that produces a required context owed on merge_group (.github/workflows/praetor-api.yml, which is byte-locked to the pinned Praetor asset, keeps its existing bare merge_group: trigger):
- Admit only pull requests whose head branch lives in
vidiko/vmafx. Adding a pull request to the queue requires write access to the repository. Maintainers pin the reviewed head when enqueueing withgh pr merge <number> --match-head-commit <sha>or withexpectedHeadOidon the GraphQLenqueuePullRequestmutation.scripts/dev/merge_train_guard.pyrefuses cross-repository pull requests, and maintainers enqueueing by hand apply the same rule. Thetest_guard_refuses_cross_repository_prsregression test inscripts/dev/tests/test_merge_train_guard.pycovers this refusal. A fork contribution enters only after its reviewed change sits on an in-repository branch. Semgrep and CodeQL retainsecurity-events: writeonmerge_groupunder this rule. Semgrep scans the checkout in its pinned image without executing code from the change, so the same admission rule covers it. - Keep
merge_groupon thefullCI tier (scripts/ci/ci_tier.py) and full impact plan (scripts/ci/plan-ci-impact.py), without addingmerge_grouprouting to either script. - In
.github/workflows/required-aggregator.yml, define an event-scopedmergeGroupExemptlist holding'Scorecard Master Gate'next topullRequestOnly. Oncontext.eventName === 'merge_group', exemptpullRequestOnly,'Scorecard PR Gate'(already dropped offpull_request), andmergeGroupExempt, logging each exempt context viacore.info(Scorecard Master Gateruns on themasterpush after the merge, andScorecard PR Gateran on the pull request). Keeppushandpull_request(includingedited, ADR-3551) behaviour unchanged. - Extend job and step guards on the path to owed
merge_groupcontexts (sanitizers.ymlasan-ubsan,sycl-parity.ymlrunner-available,tests-and-quality-gates.ymlgpu-full-runner-available,windows-tester-bundle.ymlvalidateref and source resolution, andlint-and-format.ymldiff-base steps readinggithub.event.merge_group.base_sha). - Exclude
merge_groupalongsidepull_requeston thedocker-publish-tester.ymlbuild-gpurunner-cost guard so the three tester GPU image builds run after merging only if themasterpush selectstester_image(own_paths_onlyin.github/ci-impact.json);validaterequiresimpact.outputs.selectedandbuild-gpurequiresvalidate. When the changed paths of the push are known, a merge limited to other paths, such ascore/, builds no tester GPU image; when the planner cannot read them, the selector stays set and the images are built.scripts/ci/tests/test_merge_group_workflow_contract.pyrefuses anypull_requestcost guard lacking amerge_groupexclusion. - Keep
release-dry-run.yml,rule-enforcement.yml,scorecard.yml, and every publish, deploy, registry-push, release-signing, or repository-write step on their existing events only. Thewindows-tester-bundle.ymlpublishjob explicitly excludesmerge_group. The contract test refuses amerge_groupjob reading a secret other thanGITHUB_TOKENor running self-hosted without that exclusion or the provenance guard in.github/actions/runner-probe/action.yml.
Alternatives considered¶
| Option | Pros | Cons | Why not chosen |
|---|---|---|---|
Option a: trigger required-aggregator.yml and feeding workflows on merge_group (checks_requested, branches: [master]), exempt Scorecard Master Gate via mergeGroupExempt on merge_group, and keep tier full and existing publish gates | Evaluates the combined merge group under the full CI tier; preserves single-context ruleset enforcement, push parity, and publish safety | Runs the full CI matrix on each merge group before master lands | Chosen; satisfies GitHub merge-queue requirements without weakening master verification or triggering publish jobs |
Option b: route merge_group through the light tier or diff-routed plan-ci-impact.py | Shorter queue runtime when queued pull requests touch narrow paths | Skips full-tier cross-PR integration legs on the combined merge candidate | Rejected: ci_tier.py and plan-ci-impact.py fail closed to full off own pull requests so combined merge candidates run every owed check |
Option c: trigger scorecard.yml on merge_group instead of exempting Scorecard Master Gate | Zero merge_group-specific exemptions in required-aggregator.yml | ossf/scorecard-action refuses publish_results: true outside the default branch, and scorecard_gate.py master inspects refs/heads/master rather than the queue ref | Rejected: incompatible with default-branch Scorecard publishing and ref lookup |
Option d: require individual build and test contexts directly in the master ruleset | Avoids merge_group handling in required-aggregator.yml | Breaks ADR-0313 single-context branch protection and hardware-lane operator switches | Rejected: violates ADR-0313 |
Consequences¶
- Positive: the
masterruleset can requireRequired Checks Aggregatorinside a GitHub merge queue; every workflow producing an owedmerge_groupcontext starts onchecks_requestedformaster, evaluates the combined queue head under tierfull, rejects foreignpull_requestcheck runs on the same SHA, and blocks queue merges when any owed context is absent or red. Publish, Pages, and release jobs remain confined to their existing triggers. - Security boundary: queue admission is the primary enforcement point: the merge group head includes queued diffs that can rewrite workflow conditions, permissions, guards and scripts, so in-file permission scoping cannot enforce provenance against a hostile diff. The merge-group provenance guard before hardware probes and hosted ARC routing provide a second barrier against an enqueue mistake. Workflow-token access to
mergeQueueis unproven until the first live merge group; lookup failures fail closed. The guard writessame_repo=falseand exits successfully on refusal; the probe step runs only when the output istrue. - Negative: merge-group runs execute the full CI tier across 21 feeding workflows before commits reach
master, and adding a new required context outsidepullRequestOnlyrequiresmerge_groupon its calling workflow (enforced byscripts/ci/tests/test_merge_group_workflow_contract.py). - Neutral / follow-ups:
Scorecard Master Gatecontinues to run and enforce its gate on themasterpush immediately after the merge queue lands a group, andScorecard PR Gatecontinues to run on every pull request before queueing.scripts/ci/tests/test_aggregator_event_scope.pycoversmerge_grouppass, missing/failing context, Scorecard andpullRequestOnlyboundary exemptions, and foreignpull_requestrun rejection;scripts/ci/tests/test_merge_group_workflow_contract.pyenforces the feeding workflow trigger set and forbidsmerge_grouponrelease-dry-run.yml,scorecard.yml, andrule-enforcement.yml.
References¶
- ADR-0313: Single required-checks aggregator.
- ADR-1297: Gate every reporting check in Required Checks Aggregator.
- ADR-2169: Two-tier CI check contract.
- ADR-3293: Every owed required context must succeed.
- ADR-3551: Anchor edited pull-request aggregator runs at ready-for-review.
- CI overview: Merge queue.
scripts/ci/tests/test_aggregator_event_scope.pyandscripts/ci/tests/test_merge_group_workflow_contract.py.- Source: maintainer request (paraphrased; vmafx-merge-throughput-queue-20261116, 2026-11-16, merge queue): add
merge_group(checks_requestedonmaster) torequired-aggregator.ymland every workflow producing an owedmerge_groupcontext, exempt both Scorecard gates onmerge_groupwhile keeping tierfulland existingpushandpull_requestbehaviour, and keep publish steps on their prior events.