ADR-3551: Anchor edited pull-request aggregator runs at ready-for-review¶
- Status: Accepted
- Date: 2026-11-15
- Deciders: Project maintainer
- Tags: ci, fork-local
Context¶
.github/workflows/rule-enforcement.yml triggers on [opened, edited, synchronize, reopened, ready_for_review], while .github/workflows/required-aggregator.yml triggered on [opened, synchronize, reopened, ready_for_review]. Editing a pull request's title or body after Required Checks Aggregator succeeded re-ran the governance gates (Deliverables Checklist, docs/state.md Gate, DCO Sign-off, and sibling jobs in rule-enforcement.yml) without re-running the aggregator (issue 3459). A gate turned red by that edit left the single required status check (ADR-0313) green, leaving the pull request UNSTABLE instead of BLOCKED.
Adding edited to required-aggregator.yml without adjusting its freshness window fails healthy pull requests. The aggregator computed minCreatedMs = runCreatedMs - 2 * 60 * 1000 from its own workflow run to drop draft-era GitHub Actions check runs. Because build, lint, and test workflows do not trigger on edited, their check runs on the unchanged head SHA predate the edited aggregator run and would be ignored as absent, failing every owed context under ADR-3293. Conversely, anchoring minCreatedMs at ready_for_review alone keeps earlier rule-enforcement.yml (Rules) check runs on the same head SHA inside the window: when the aggregator polls before the current edit's Rules run registers its gate jobs behind CI tier (Rules), newestByName would otherwise pick the earlier green gate runs and pass before the edit's gate fails.
Decision¶
Add edited to on.pull_request.types in .github/workflows/required-aggregator.yml ([opened, edited, synchronize, reopened, ready_for_review]), leaving workflow permissions: (actions: read authorises workflow-run reads; pull-requests: read authorises issue timeline reads) and ref-scoped concurrency: (cancel-in-progress: true off master) unchanged.
Derive the check-run freshness anchor in windowAnchorMs and exclude stale edited-rerun workflow suites:
- When
context.eventName === 'pull_request' && context.payload.action === 'edited', readgithub.rest.issues.listEventsForTimeline(per_page: 100, capped at 10 pages, wrapped inwithApiBackoff) and anchor atcreated_atof the latestready_for_reviewtimeline event. When the timeline contains noready_for_reviewevent (the pull request was never a draft), anchor atcontext.payload.pull_request.created_at. - On every other event, anchor at the aggregator workflow run's own
created_at, unchanged. - Compute
minCreatedMs = anchorMs - 2 * 60 * 1000(runTimestampMs >= minCreatedMscounts;< minCreatedMsis excluded), log the selected anchor source viacore.info, and fail closed without judging checks if the timeline call fails or the anchor timestamp cannot be derived. Non-Actionsgithub-advanced-securitychecks retain their any-age rule (ADR-3539). - Declare
editedRerunWorkflows = ['.github/workflows/rule-enforcement.yml']for workflows whosepull_requesttrigger includeseditedand that report required checks, and require every listed workflow to declare a top-levelrun-namestarting with"[${{ github.event.pull_request.updated_at }}] "before any author-controlled text (run-name: "[${{ github.event.pull_request.updated_at }}] ${{ github.event.pull_request.title }}"in.github/workflows/rule-enforcement.yml, enforced statically by the sync guard inscripts/ci/tests/test_aggregator_edited_window.py). Keep literal${{syntax out ofrequired-aggregator.yml'sactions/github-scriptscript:scalar (and enforce GitHub's 21,000-characterParseScalarexpression limit across all workflow scalars inscripts/ci/check-workflow-size.py) so the runner does not wrap the embedded script into an oversizeformat(...)expression. On aneditedevent, require a non-emptycontext.payload.pull_request.updated_at(failing closed viacore.setFailednamingpull_request.updated_atif missing). On eachedited-event poll, list workflow runs for the head SHA viagithub.rest.actions.listWorkflowRunsForRepo(reusing the 10-pagelistWorkflowRunsForShapager underwithApiBackoff) and classify each listed workflow's runs inclassifyEditedRerunSuites: a run matches the current edit stamp when itsdisplay_titlestarts with'[' + context.payload.pull_request.updated_at + '] ', and every other run of that workflow is stale. If any workflow ineditedRerunWorkflowshas more than one run (in any status, including cancelled or completed) matching the current edit-stamp prefix (ambiguousWorkflows), fail closed at once viacore.setFailednaming the workflow(s) and stamp and instructing the author to edit the pull request again (any title or body change re-stamps it) or push a commit. Otherwise add every stale run'scheck_suite_idtoexcludedSuitesinnewestByName, log the excluded stale-suite count viacore.info, keep polling throughregistrationGraceDeadlinewhile any workflow ineditedRerunWorkflowshas no current run, and fail closed withcore.setFailednaming the workflow file (the Rules workflow did not start for this edit) if still absent past the grace. Even when a single edit-stamped run is already green, do not exit theeditedpoll loop until alistWorkflowRunsForRepolisting started afterregistrationGraceDeadline(editedListingStartMs > registrationGraceDeadline), logging the grace wait viacore.infomeanwhile, so a later same-second duplicate run that registers within the 2-minute grace is listed and fails closed as ambiguous.
Alternatives considered¶
| Option | Pros | Cons | Why not chosen |
|---|---|---|---|
Option a: trigger on edited, anchor at latest ready_for_review or pull_request.created_at, and correlate editedRerunWorkflows suites by run-name edit-stamp prefix | Re-judges current-edit governance gates alongside ready-head build checks; correlates each edited aggregator run with the Rules run of the same edit; preserves draft-era exclusion | One extra aggregator run, one timeline API query, and one workflow-runs listing per edited-event poll; Rules run titles start with the edit stamp | Chosen; satisfies branch protection without re-running build matrices or admitting earlier Rules results |
Option b: reuse the previous aggregator verdict and re-check only rule-enforcement.yml gates | Avoids reading the issue timeline when a prior completed verdict exists | Ref-scoped cancel-in-progress cancels an in-progress aggregator when an edit lands mid-run, leaving no completed verdict to reuse | Rejected: cancel-in-progress leaves no verdict to reuse |
Option c: leave required-aggregator.yml triggers as is | Zero extra aggregator runs on PR edits | Title or body edits turning governance gates red leave the required check green (UNSTABLE, not BLOCKED), allowing forge-button merge | Rejected: forge-button merge on UNSTABLE |
Option d: disable minCreatedMs on edited runs | No timeline API call required | Admits skipped or stale draft-era GitHub Actions check runs from before the pull request became ready for review | Rejected: re-opens the draft-era masking gap |
| Option e: anchor only, no stale-suite exclusion | Avoids listing workflow runs on edited-event polls | Earlier rule-enforcement.yml runs on the same head SHA remain inside the ready_for_review window; if the aggregator polls before the edit's Rules run registers its gate jobs, stale green gate runs satisfy newestByName before the edit's gate fails | Rejected: race re-opens the UNSTABLE merge gap |
Option f: 60-second creation floor (created_at >= ownCreatedMs - 60 s) | Correlates editedRerunWorkflows runs without setting run-name on rule-enforcement.yml | Two edits less than 60 seconds apart place the earlier edit's Rules run inside the floor; if its gates finish green before the later edit's Rules run registers, missingWorkflows is empty and the aggregator passes on the superseded PR text (PR 3466 review) | Rejected: two edits inside the margin admit the earlier edit's suite (PR 3466 review) |
Consequences¶
- Positive: editing a pull request's title or body re-runs
Required Checks Aggregator; a redDeliverables Checklist,docs/state.md Gate, orDCO Sign-offcheck turns the required context red (BLOCKED), staleRulessuites from earlier events or rapid consecutive edits on the same head SHA cannot satisfy or mask the edit, same-second duplicate stamps fail closed instead of admitting an earlier edit's checks, and a valid edit counts earlier ready-head build and test runs and stays green. Draft-era GitHub Actions check runs older thanready_for_reviewminus two minutes remain excluded, and timeline errors, workflow-runs API errors, missing timestamps or edit stamps, ambiguous same-second stamps, or an unstartedRulesrun fail closed. - Negative: every pull-request title or body edit, including automated bot body edits, triggers one extra
Required Checks Aggregatorpolling run, one paginated timeline API read (listEventsForTimeline), and one paginated workflow-runs API read (listWorkflowRunsForRepo) peredited-event poll.Rulesworkflow run titles start with the"[<updated_at>] "edit stamp, and becausepull_request.updated_athas one-second resolution, two edits within the same second share a stamp: when more than one run of a workflow ineditedRerunWorkflows(in any status, including cancelled or completed) carries the current edit-stamp prefix, the aggregator fails closed immediately rather than guessing which run judged the latest PR text, requiring another pull-request edit (any title or body change re-stamps it) or a commit push to clear; revisit this fail-closed rule when GitHub exposes a sub-second timestamp or per-event edit id on workflow runs. Everyeditedaggregator run also polls for at least the 2-minute registration grace before trusting an edit-stamped run, while a same-second duplicate run that registers only afterregistrationGraceDeadlineis not seen by that aggregator run; its ownRuleschecks still report on the head commit. - Neutral / follow-ups: push,
workflow_dispatch,opened,synchronize,reopened, andready_for_reviewruns keep their existing own-run anchor, 2-minute registration grace, tier exemptions, and ADR-3539 external-app handling with no extra workflow-runs API calls.scripts/ci/required_aggregator_harness.pyandscripts/ci/tests/test_aggregator_edited_window.pycover edited pass/fail paths, rapid two-edit correlation and masking, same-second duplicate-stamp fail-closed rejection, the edit-stamp prefix boundaries, missing ownupdated_at, staticeditedRerunWorkflowstrigger andrun-namesync, draft-era exclusion, multipleready_for_reviewtransitions, pagination, and transient/permanent API failures, whilescripts/ci/check-workflow-size.pyandscripts/ci/tests/test_check_workflow_size.pyguard workflow YAML scalars againstactions/runner's 21,000 UTF-16 code-unit expression limit after.NETChar.IsWhiteSpaceexpression trimming.
References¶
- Issue 3459 (
T-CI-AGGREGATOR-EDITED-WINDOW-2026-11-15). - ADR-0313: Single required-checks aggregator.
- ADR-3293: Every owed required context must succeed.
- ADR-3539: Count non-Actions app check runs outside the aggregator run window.
- CI overview: Required-checks aggregator.
scripts/ci/tests/test_aggregator_edited_window.py: edited-event window, stale-suite exclusion, edit-stamp boundary, trigger andrun-namesync guard, draft-era exclusion, multipleready_for_reviewtransitions, and fail-closed API fixtures.- Source: decision
vmafx-3459-aggregator-edited-design(2026-11-15, aggregator edited-event window, paraphrased): addeditedtorequired-aggregator.ymlpull-request triggers and anchor its GitHub Actions check-run freshness window at the latestready_for_reviewtimeline event, orpull_request.created_atwhen never a draft, keeping the 2-minute margin.