ADR-3557: Queue same-head pull-request runs on merge-gate workflows¶
- Status: Accepted
- Date: 2026-11-17
- Deciders: Project maintainer
- Tags: ci, fork-local
Context¶
The master ruleset requires one status-check context: Required Checks Aggregator (.github/workflows/required-aggregator.yml, job aggregator, ADR-0313). GitHub evaluates branch protection across the latest check run of every check suite on the head commit, so a cancelled Required Checks Aggregator run in one check suite keeps the pull request BLOCKED even when a sibling suite on the same head passes (pull request 3445 rollup: CANCELLED at 01:35:32Z plus SUCCESS at 01:48:19Z, rollup state FAILURE).
Since ADR-3551, required-aggregator.yml triggers on [opened, edited, synchronize, reopened, ready_for_review] with group: required-aggregator-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} and cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}. A review bot edits the pull-request body 7-10 seconds after each push (pull_request action edited), so the edited run cancels the running push run of the same head (observed on pull requests 3434, 3445, 3456, 3505, 3510, and 3522 on 2026-11-17). .github/workflows/rule-enforcement.yml (Rules) has the same defect: its triggers include edited with group: rule-enforcement-${{ github.event.pull_request.number }} and cancel-in-progress: true, while on edited the aggregator correlates editedRerunWorkflows by the "[<pull_request.updated_at>] " display_title prefix and fails when that Rules run's jobs are cancelled (pull request 3456, aggregator run 43996540618 attempt 3: nine Rules jobs cancelled, aggregator failed); re-running one twin cancels the other.
Keeping one pull-request concurrency group on rule-enforcement.yml also leaves a two-edit pending-replacement defect (PR 3529 review). Under GitHub Actions concurrency (github/docs data/reusables/actions/actions-group-concurrency.md, commit 336b7f546d), a concurrency group holds at most one running and one pending run, and queuing a new run cancels the existing pending run in the group even when cancel-in-progress is false. When edit A starts aggregator A while an earlier Rules run holds the group, Rules A waits as pending; edit B then queues Rules B and cancels pending Rules A with zero jobs, so aggregator A finds only a cancelled Rules run bearing its "[<pull_request.updated_at>] " stamp, its Rules check runs never register, and aggregator A fails at its 2-minute registration grace deadline, leaving a failed Required Checks Aggregator suite on the head commit that keeps the pull request BLOCKED even after aggregator B passes.
Decision¶
Enable cancel-in-progress only for synchronize pull-request events in both merge-gate workflows, keep the aggregator concurrency group: unchanged, and give each edited run of .github/workflows/rule-enforcement.yml its own concurrency group keyed on github.run_id:
- In
.github/workflows/required-aggregator.yml, setcancel-in-progress: ${{ github.event_name == 'pull_request' && github.event.action == 'synchronize' }}, leaving triggers,permissions:,group:, and the embeddedscript:block unchanged. - In
.github/workflows/rule-enforcement.yml, setgroup: rule-enforcement-${{ github.event.pull_request.number }}-${{ github.event.action == 'edited' && github.run_id || 'head' }}andcancel-in-progress: ${{ github.event.action == 'synchronize' }}, leaving triggers,permissions:, andrun-name("[${{ github.event.pull_request.updated_at }}] ${{ github.event.pull_request.title }}") unchanged while the aggregator concurrencygroup:stays unchanged. - Under GitHub Actions concurrency (at most one running and one pending run per group), a
synchronizepush to a new head still cancels the stale running run in the pull-request group, while same-headedited,reopened, andready_for_reviewaggregator runs wait as pending and repeated pending aggregator runs collapse to the newest (release-please.ymlruns37229262831and37230781106endcancelledwith zero jobs and zero check runs when replaced while pending). Onrule-enforcement.yml, eacheditedrun gets its own group keyed ongithub.run_id(unique per workflow run), so no later edit (same second or not) or other same-head event replaces or cancels it;run-namekeeps the"[<pull_request.updated_at>] "stamp for aggregator correlation, and same-second edits sharing that stamp fail closed as ambiguous when an aggregator run lists bothRulesruns inrequired-aggregator.yml(ADR-3551), while non-editedevents share the-headgroup. Leave the 24 other pull-request workflows unchanged: none reports a required context directly on branch protection, and the aggregator'snewestByNameselection picks their surviving newer twin. - Run
.github/actions/edit-supersede-guard/action.ymlin each requiredRulesjob after checkout.scripts/ci/edit_supersede_guard.pywaits for a five-second settle (capped at 30 seconds), then fails the job if the live title, body or base differs from its edited-event payload;scripts/ci/tests/test_edit_supersede_guard.pycovers the comparison and workflow wiring. - Extend
scripts/ci/tests/test_master_concurrency_contract.py(pr_pushandpr_eventwithupdated_atand optionalrun_id,gate_workflows,same_head_findings,pending_replacement_findings,serial_second_look_findings,skip_findings) so the gate workflow set (required-aggregator.ymlplus basenames ineditedRerunWorkflows, failing on a missing or empty array) forbids same-head cancellation on every non-synchronize(!= 'opened',!= 'closed')pull_requesttype with a distinctrun_idatT1andT2compared against every runningpull_requesttype of the workflow atT1(includingsynchronizeand the incoming action itself) at workflow and job level, forbids any non-aggregator gate workflow witheditedinpull_request.typesfrom sharing aneditedrun's concurrency group (T1,run-edit-1) with a later same-headpull_requestaction carrying a distinctrun_idatT1(same second) orT2(pending_replacement_findings), pins the shared, non-cancelling aggregator group for two same-secondeditedevents with distinct run ids (serial_second_look_findings), verifiessynchronizeacross distinct SHAs still shares a group withcancel-in-progresstrue, and forbids anyif:onjobs.aggregatoror step-levelif:in that job mentioninggithub.event.actionoredited.
Alternatives considered¶
| Option | Pros | Cons | Why not chosen |
|---|---|---|---|
Option a: keep existing group: and set cancel-in-progress true only on pull_request synchronize | Preserves master SHA isolation and new-head superseding; same-head edited, reopened, and ready_for_review aggregator runs wait as pending and collapse to the newest with zero check runs on replaced pending suites | Same-head edited aggregator twin waits for the running push run to finish; re-running a synchronize run while an edited twin runs cancels the twin; on rule-enforcement.yml alone, a second edit replaces a pending Rules run and fails the first edit's aggregator | Chosen for required-aggregator.yml (paired with Option h on rule-enforcement.yml) |
Option b: head-SHA concurrency group with cancel-in-progress: true | Separates distinct commits into distinct concurrency groups | A same-head edited, reopened, or ready_for_review event shares the head SHA and still cancels the same-head twin, while a push to a new head no longer cancels the older head's run | Rejected: still cancels the same-head twin |
Option c: concurrency.queue: max | Declares queueing explicitly in workflow YAML | The pinned actionlint v1.7.12 in .pre-commit-config.yaml refuses it (unexpected key "queue" for "concurrency" section), and it cannot combine with cancel-in-progress | Rejected: actionlint 1.7.12 refuses queue, and it cannot combine with cancel-in-progress |
Option d: job-level if: skipping jobs.aggregator on edited | Starts no second aggregator job on pull-request edits | Branch protection counts a skipped required status check as passing, which masks a failed or pending aggregator run on the same head | Rejected: skipped counts as passing and masks a failed run |
| Option e: per-head-SHA group without cancel plus an in-script supersede check | Avoids Actions concurrency cancellation between same-head suites | A synchronize push to a new head no longer cancels the stale run natively (holding runner slots until script polling notices) and adds extra GitHub API calls on every poll | Rejected: new heads no longer cancel stale runs natively, and polling adds extra API calls |
Option f: queue: max on rule-enforcement.yml with cancel-in-progress: ${{ github.event.action == 'synchronize' }} | Keeps up to 100 pending Rules runs in one group without replacing earlier edits | Combining queue: max with cancel-in-progress: true (when synchronize evaluates true) is a GitHub Actions workflow validation error (github/docs data/reusables/actions/actions-group-concurrency.md, commit 336b7f546d) | Rejected: validation error with cancel-in-progress: true on synchronize |
Option g: per-edit updated_at group on rule-enforcement.yml (rule-enforcement-<number>-<stamp>, where the stamp is pull_request.updated_at on edited and head on every other action) with cancel-in-progress: ${{ github.event.action == 'synchronize' }} | Gives edits stamped in distinct seconds separate concurrency groups matching the run-name edit stamp while non-edited events share the -head group and synchronize cancels stale head runs | pull_request.updated_at has one-second resolution, so two edits in the same second share one concurrency group and the second edit replaces a pending first edit's Rules run; a synchronize push also no longer cancels an old-head edited Rules run | Rejected: one-second updated_at resolution still lets same-second edits share one group and replace a pending Rules run |
Option h: per-edit github.run_id group on rule-enforcement.yml (rule-enforcement-<number>-<key>, where the key is github.run_id on edited and head on every other action) with cancel-in-progress: ${{ github.event.action == 'synchronize' }} | github.run_id is unique per workflow run, so no two edited runs ever share a concurrency group (including edits stamped in the same second), while run-name keeps pull_request.updated_at for aggregator correlation and non-edited events share the -head group | A synchronize push no longer cancels an old-head edited Rules run; same-second edits still share the updated_at prefix in run-name, where the aggregator fails closed as ambiguous per ADR-3551 | Chosen for rule-enforcement.yml |
| Option i: content supersede guard in every required job | A stale earlier job fails even if the later same-second run registers after the grace | Adds a pull-request read per required job; it waits until five seconds after the event stamp, capped at 30 seconds, and its single read can miss a later edit made shortly before it even with API lag under five seconds, and an edit after the read is left to the later edit's own Rules run | Chosen over a separate guard job: a failed needs: dependency skips the gate, and the aggregator accepts a not-owed skipped gate |
Consequences¶
- Positive: same-head
edited,reopened, andready_for_reviewevents (including automated review-bot body edits seconds after a push) no longer cancel a runningRequired Checks AggregatororRulesrun of the same head; repeated pending aggregator edits collapse to the newest pending run with zero check runs on replaced pending suites; eacheditedRulesrun keeps its owngithub.run_idconcurrency group so no later edit (same second or not) replaces or cancels it, whilerun-namekeeps theupdated_atstamp and same-second edits sharing that stamp fail closed when an aggregator run lists bothRulesruns (ADR-3551);synchronizepushes to a new head still cancel superseded head-group runs immediately; master push SHA isolation (ADR-1673) holds unchanged. - Negative: same-head aggregator edits can wait pending, and a push no longer cancels an old-head edited
Rulesrun. Manually re-running a same-headsynchronizerun can cancel an edited aggregator twin;docs/development/ci.mddescribes the re-run procedure. The guard waits until five seconds after the event stamp, capped at 30 seconds, and reads the pull request once (scripts/ci/edit_supersede_guard.py), so a later edit made shortly before that read can be missed even with API lag under five seconds, and an edit made after the read is not detected by that run; theRulesrun of that later edit judges the current text. - Neutral / follow-ups:
test_known_gap_third_edit_replaces_pending_second_lookinscripts/ci/tests/test_master_concurrency_contract.pypins the concurrency path where a third edit replaces a pending second look. The guard now fails the earlierRulesjob and aggregator when its live read observes the replacement, including when a same-second run registers after the grace (test_late_registering_same_second_edit_fails_on_superseded_rules_runinscripts/ci/tests/test_aggregator_edited_window.py). An aggregator suite failed by a superseded edit may remain red until a new commit is pushed; a re-run reuses that edit's event payload and fails again while the live fields still differ, as discussed in ADR-3551. A new title or body edit starts a new aggregator run, but its success does not establish that the earlier failed suite clears.
References¶
T-CI-AGGREGATOR-SAME-HEAD-CANCEL-2026-11-17in docs/state.md.- ADR-0313: Single required-checks aggregator.
- ADR-1673: A push to master never cancels the runs of an earlier master commit.
- ADR-3551: Anchor edited pull-request aggregator runs at ready-for-review.
- CI overview: Master push runs.
scripts/ci/tests/test_master_concurrency_contract.py:gate_workflows,same_head_findings,pending_replacement_findings,serial_second_look_findings,skip_findings, repository checks, and positive/negative/boundary synthetic workflow cases.- Source: decision
vmafx-aggregator-same-head-queue(2026-11-17, merge-gate same-head concurrency, paraphrased) and PR 3529 review: restrictcancel-in-progresstosynchronizepull-request events inrequired-aggregator.ymlandrule-enforcement.yml, and isolateeditedruns ofrule-enforcement.ymlinto per-run (github.run_id) concurrency groups so no later edit (same second or not) replaces or cancels a pendingRulesrun while same-second edits sharing theupdated_atrun-namestamp fail closed when an aggregator run lists bothRulesruns, with a serialised second look bounded by the later aggregator run's own registration grace deadline.