Skip to content

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 with gh pr merge <number> --match-head-commit <sha> or with expectedHeadOid on the GraphQL enqueuePullRequest mutation. scripts/dev/merge_train_guard.py refuses cross-repository pull requests, and maintainers enqueueing by hand apply the same rule. The test_guard_refuses_cross_repository_prs regression test in scripts/dev/tests/test_merge_train_guard.py covers this refusal. A fork contribution enters only after its reviewed change sits on an in-repository branch. Semgrep and CodeQL retain security-events: write on merge_group under 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_group on the full CI tier (scripts/ci/ci_tier.py) and full impact plan (scripts/ci/plan-ci-impact.py), without adding merge_group routing to either script.
  • In .github/workflows/required-aggregator.yml, define an event-scoped mergeGroupExempt list holding 'Scorecard Master Gate' next to pullRequestOnly. On context.eventName === 'merge_group', exempt pullRequestOnly, 'Scorecard PR Gate' (already dropped off pull_request), and mergeGroupExempt, logging each exempt context via core.info (Scorecard Master Gate runs on the master push after the merge, and Scorecard PR Gate ran on the pull request). Keep push and pull_request (including edited, ADR-3551) behaviour unchanged.
  • Extend job and step guards on the path to owed merge_group contexts (sanitizers.yml asan-ubsan, sycl-parity.yml runner-available, tests-and-quality-gates.yml gpu-full-runner-available, windows-tester-bundle.yml validate ref and source resolution, and lint-and-format.yml diff-base steps reading github.event.merge_group.base_sha).
  • Exclude merge_group alongside pull_request on the docker-publish-tester.yml build-gpu runner-cost guard so the three tester GPU image builds run after merging only if the master push selects tester_image (own_paths_only in .github/ci-impact.json); validate requires impact.outputs.selected and build-gpu requires validate. When the changed paths of the push are known, a merge limited to other paths, such as core/, 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.py refuses any pull_request cost guard lacking a merge_group exclusion.
  • 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. The windows-tester-bundle.yml publish job explicitly excludes merge_group. The contract test refuses a merge_group job reading a secret other than GITHUB_TOKEN or 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 master ruleset can require Required Checks Aggregator inside a GitHub merge queue; every workflow producing an owed merge_group context starts on checks_requested for master, evaluates the combined queue head under tier full, rejects foreign pull_request check 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 mergeQueue is unproven until the first live merge group; lookup failures fail closed. The guard writes same_repo=false and exits successfully on refusal; the probe step runs only when the output is true.
  • Negative: merge-group runs execute the full CI tier across 21 feeding workflows before commits reach master, and adding a new required context outside pullRequestOnly requires merge_group on its calling workflow (enforced by scripts/ci/tests/test_merge_group_workflow_contract.py).
  • Neutral / follow-ups: Scorecard Master Gate continues to run and enforce its gate on the master push immediately after the merge queue lands a group, and Scorecard PR Gate continues to run on every pull request before queueing. scripts/ci/tests/test_aggregator_event_scope.py covers merge_group pass, missing/failing context, Scorecard and pullRequestOnly boundary exemptions, and foreign pull_request run rejection; scripts/ci/tests/test_merge_group_workflow_contract.py enforces the feeding workflow trigger set and forbids merge_group on release-dry-run.yml, scorecard.yml, and rule-enforcement.yml.

References