Repository navigation
Closed
Closed
feat(source-control): start pr-merge when a gated input finishes instead of waiting for the schedule#8823
Feature
Copy link
Labels
needs-specNeeds a Brief or plan before anyone can build it.status: confirmedA maintainer confirmed the item is real and in scope; ready to be worked.
Description
Refs: #7576
Problem
The owner asked for pr-merge to wake on events rather than polling ("Ideally, it's not polling", 2026-10-19). pr-merge still relies on its 15-minute schedule to notice most changes that make a lane PR mergeable, and GitHub drops those cron ticks for 30-60 minutes at a time (no sweep between 18:29Z and 19:31Z on 2026-10-19).
Current behavior
.github/workflows/pr-merge.yml:55-75(origin/mainad020d08b5) wakes onpull_request_target(unlabeled,edited,ready_for_review),workflow_dispatch,schedule(11,26,41,56 * * * *) andpushto main.- None of these fires when the inputs the gate waits on most often finish: the pr-verify verdict for the head,
ci-statuson the head, and the two AI review lanes. A PR that becomes mergeable when one of those finishes waits for the next cron tick that GitHub actually delivers. merge.skip-unchanged.max-minutesis 60 (docs/conventions/pr-pipeline.yaml:557-558). Sweeps arrived more than 60 minutes apart, so every refusal had expired before the next sweep and the skip saved no gate calls (handoff 20261020T202630Z).
Desired behavior
- pr-merge starts a run when an input it gates on completes for an open lane PR's head: the pr-verify verdict,
ci-status, and each review lane. Which event carries each (for exampleworkflow_runon the producing workflow, orcheck_suite/status) is decided in the spec, with a debounce or concurrency group so a burst of completions starts one run. - The schedule stays as a backstop, at a slower interval if the event triggers cover the common paths.
skip-unchanged.max-minutesis set from the measured gap between sweeps after event dispatch lands, or removed if event dispatch makes it unnecessary.- No change to what the gate merges or refuses. A new trigger only wakes the gate; it does not decide anything (the existing rule at
pr-merge.yml:56-58).
Known calls
- This is pr-merge throughput work. Per the 2026-10-20 realignment it ranks below PLAN delivery (Phases 3-24). Filed so the owner's ask has a carrier;
needs-spec, not admitted. - It edits
.github/workflows/pr-merge.yml, so it merges under the workflow-PR rule (Security & Cost's pass on the final head) and its trigger change waits for that pass.
Out of scope
merge.max-in-flightsizing (feat(source-control): set merge.max-in-flight from measured merge rate and API budget #8267).
Origin: the owner's (the ask). The event list and the debounce: ours.
Metadata
Metadata
Assignees
Labels
needs-specNeeds a Brief or plan before anyone can build it.status: confirmedA maintainer confirmed the item is real and in scope; ready to be worked.
Type
Fields
No fields configured for Feature.
Activity
kyle-sexton commentedon Oct 22, 2026
Measured cost of the cron wait, from pipeline canary round 1 (2026-10-22, five one-line docs fixes, all merged with no human):
Green → enqueued (5.5-22 min) is the largest and most variable part of PR → merge. It matches the 15-minute schedule at
pr-merge.yml:88-89plus GitHub's cron delay. Source: GraphQL timeline (AddedToMergeQueueEvent) and the head commit's check runs per PR.kyle-sexton commentedon Oct 22, 2026
Decision recorded. The owner chose event wake-up (2026-10-22, Q680, "yes"):
workflow_run: completedof pr-verify, pr-review-hosted and pr-review-security-hosted. Only same-repo runs that were not skipped wake it, and the triggering run's conclusion is never read as a verdict.workflow_runrun on main like aschedulerun, with no actor check, because pr-merge reads every PR from the API and trusts nothing from the event. Today the broker refuses that case:claims.mjs:230-237refuses the lanes bot, andauthorize.mjs:175-181requires a listed human when no PR is named. Automation Lanes builds that change in azure-iac, with Security & Cost's review and a deploy.workflow_run, and GITHUB_TOKEN-started runs raise none.merge.skip-unchanged.max-skipsis raised for event-rate wakes;max-minutesstays 60.kyle-sexton commentedon Oct 22, 2026
Decision recorded. The owner added a condition (2026-10-22): ship only if the full criteria hold and the change introduces no concurrency or race condition.
No races: merge runs stay serialized. The
mergejob keepsgroup: pr-merge,queue: max, and is never cancelled (pr-merge.yml:292-315). New triggers only add waiting runs, and the superseded step skips the gate when a successor is waiting.Pile-up risk: GitHub caps the waiting line at 100 and rejects the rest (
pr-merge.yml:310-312). Each PR push can bring about 3 wakes.Build: a pre-check job, for
workflow_runwakes only, exits without joiningpr-mergewhen a pr-merge run is already queued. Nothing is cancelled, so no CANCELLEDmergechecks appear on PRs, and wakes add at most one waiting run.Probe, before merge:
workflow_run, and GITHUB_TOKEN-started ones do not;Any failed criterion stops the build and comes back to the owner.
kyle-sexton commentedon Oct 22, 2026
Security & Cost passed the broker side: azure-iac#78 at e47fd5b5, risk LOW. It stays a draft with do-not-merge until the probe passes; Automation Lanes merges and deploys it after that and sends the deploy SHA. Conditions S&C set for the pr-merge.yml trigger PR:
if:skips aworkflow_runwhose upstream run came from a fork (github.event.workflow_run.head_repository.full_name != github.repository). It does so before the job joins the pr-merge concurrency group, because today's fork skip covers only pull_request_target (pr-merge.yml:299-302).workflows:lists each producer explicitly withtypes: [completed]. No wildcard, and no workflow an outsider can start except through a fork PR.whostep (pr-merge.yml:384-404) treats workflow_run like schedule. TRIGGERING_ACTOR is never used in a security decision for that event.kyle-sexton commentedon Oct 23, 2026
More evidence (canary round 2, 2026-10-23): GitHub delivered no scheduled pr-merge run at 00:11, 00:26 or 00:41Z. The schedule runs went from 39875103905 (23:57Z) to 39880962334 (00:55Z), so a mergeable PR waited about an hour for its next sweep.
kyle-sexton commentedon Oct 23, 2026
Decision recorded. The owner accepted the recommendations on the probe results (2026-10-22, Q682-Q685, "go w/ recommended"):
github.event.workflow_run.triggering_actor.login != 'github-actions[bot]'). Probe: run 39512615757 attempt 2 (github-actions[bot]) was followed by pr-verify 39513091358.superseded.mjsranksworkflow_runbelowschedule, so a wake run with a newer run waiting ends in about 17 s instead of a full sweep.group: pr-merge,queue: maxand is never cancelled. The pre-check job and the Q683 rank keep the queue well under GitHub's 100 limit (simulated peak 12-17; the queue already reached 9 today without wakes).kyle-sexton commentedon Oct 23, 2026
Correction to the Q682 line above: the filter as written would not work. When pr-verify finishes, the
workflow_runpayload pr-merge receives is the pr-verify run itself, and it carries the original actor: pr-verify 39513091358 hastriggering_actormelodic-standards-sync[bot], although its upstream pr-require-checks attempt (39512615757, attempt 2) was started by github-actions[bot]. It would also drop the lost-run reconciler's own re-runs of pr-verify, which are started by github-actions[bot] and are trusted (check-trusted-trigger.mjs:1017-1018).Same intent, one step earlier: pr-verify's
check-intentjobif:addsgithub.event.workflow_run.triggering_actor.login != 'github-actions[bot]'. Its trust check already refuses every such run, because it requires the upstream run's triggering actor to be listed (check-trusted-trigger.mjs:964, 1014-1016) and github-actions[bot] is not on trusted-actors.json. A refused run writes nothing after that step, so no verdict changes. The run then concludesskipped(47 of the last 100 pr-verify runs did), and pr-merge's existingconclusion != 'skipped'wake filter drops it.kyle-sexton commentedon Oct 23, 2026
Decision recorded. The owner chose (2026-10-23, Q689, "go with recommendations") to let #9276 replace the event wake: clean PRs merge on GitHub native auto-merge once ci-status and both review checks pass, so pr-merge needs no workflow_run trigger. The built wake (pre-check job, superseded.mjs and rotation.mjs ranks, pr-verify skip, max-skips 16) stays on local branch feat/8823-pr-merge-event-wake, unpushed, as a fallback. The broker change azure-iac#78 is not needed for this. This issue closes when #9276 ships.
kyle-sexton commentedon Oct 26, 2026
More evidence (2026-10-26): scheduled pr-merge runs still arrive far below the cron rate.
11,26,41,56 * * * *(.github/workflows/pr-merge.yml:88-89) should give 96 runs in 24 hours. From 2026-10-25T16:33Z to 2026-10-26T16:28Z GitHub delivered 63 (gh run list --workflow pr-merge.yml --event schedule).Why it still matters after Q689: clean PRs now arm through native auto-merge, but only a scheduled or hand-started run reads the verifier verdict and arms (
pr-merge.yml:101-103,enable-auto-merge.mjsREADER_EVENTS). A verdict that landed just after 11:56Z could wait up to two hours to be read.Cause UNVERIFIED (GitHub schedule delivery under load); this is the second sign after the 2026-10-23 canary gaps above.
kyle-sexton commentedon Oct 30, 2026
Closing per the owner's decision Q689 (2026-10-23): "let #9276 replace the event wake ... This issue closes when #9276 ships." #9276 closed as completed on 2026-10-28T21:00Z: native auto-merge, #9508.
One gap remains. Only a scheduled run reads the verdict and arms (
enable-auto-merge.mjsREADER_EVENTS), and cron delivery has had gaps of up to 121 min. It is not re-filed for now: on 2026-10-29, running pr-merge on PR events measured more expensive than the 4/h cron.