Repository navigation
ci: bring behind pull requests up to date automatically - #349
Merged
Merged
Conversation
On every push to main, update-behind-prs.yml merges main into each open, ready, same-repo PR that is behind it and dispatches the PR's required checks and the enforcement gate, because a GITHUB_TOKEN push starts no pull_request run. Conflicting PRs get one comment. The PR body validator accepts a head commit followed only by clean merges from main (ADR 0129). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Predict workflow-file refusals instead of trying, clear notices once a PR is current, enforce DISPATCHES in gates:check, harden the pr-quality dispatch, add a read-only dry run, and record why merge keeps the sign-off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finish an update whose dispatches failed on the next run, pin the update to the compared head, take the PR-quality base from the checkout, and rewrite the one notice when its reason changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A current head with no enforcement-approval status gets its checks dispatched again, and a one-PR dispatch of the updater uses its own concurrency group so it never replaces a queued full run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BenSheridanEdwards
force-pushed
the
ci/auto-update-behind-prs
branch
from
November 10, 2026 12:31
c2c401f to
18a4d30
Compare
Contributor
Enforcement sign-offRan at Tuesday, the 10th of November, at 4:48 pm on commit This PR changes gated enforcement or product intent, so it needs sign-off.
@BenSheridanEdwards: tick to approve.
|
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why does this feature exist?
Branch protection on
mainis strict, so a PR that falls behind main cannot merge. The maintainer ticked an enforcement sign-off on #345 after #347 merged, and the PR still could not merge because it was behind. The repository is user-owned, so GitHub's merge queue is not available. Updating by hand also broke thePR qualitycheck: on #345 and #346 the body's- Head commit:(and on #346- North Star commit:) no longer matched the head.This PR keeps every open, ready PR current. When main moves, each behind PR has main merged in, its required checks run on the new head, its body stays valid, and an unchanged sign-off carries.
What changed?
About 70% of the 1,500 added lines are tests. The change is one idea: keep behind PRs current and keep every gate judging the updated head.
.github/workflows/update-behind-prs.ymlrunsscripts/update-behind-prs.mjsfrom main on every push to main, or by dispatch with aprnumber. It needscontents: write,pull-requests: writeandactions: write, and refuses any ref but the default branch.planUpdate, which skips drafts, forks, bot PRs and other bases..github/workflows/, becauseGITHUB_TOKENmay not push that change.enforcement-approvalstatus, gets its checks dispatched, so an update whose dispatches failed or came late is finished by the next run.GITHUB_TOKENpush starts nopull_requestrun, so the script dispatchesci.yml,codeql.yml,lighthouse.yml,visual.ymlandpr-quality.ymlon the PR branch, andenforcement-approval.ymlon main with the PR number. Each gained aworkflow_dispatchtrigger. Their job names are the required check names, so no personal token or GitHub App is needed.pnpm gates:checknow fails when a required-check workflow is missing fromDISPATCHESor has no dispatch trigger.origin/main.lighthouse-scope.mjsruns audits in full outsidepull_request; docs-only scope already did.pr-quality.ymlreads the title and body from the API, and on a dispatch it requires the open PR whose head is this branch. Both events take the base from the base branch's tip in the checkout, because GitHub refreshesbase.shalazily.inputs.pr.validate-pr-body.mjsaccepts a- Head commit:followed only by clean merges from main. A clean merge has two parents, the second in main, and a tree equal togit merge-treeof those parents. The North Star field is then read at that commit. A rebase, an ordinary commit, or a merge that also edits the PR still needs the body re-checked.node scripts/update-behind-prs.mjs --dry-run [<pr>]prints the plan for every open PR through read-onlygh apicalls.QUALITY_GATES.md,PR_QUALITY.mdanddocs/required-gates.mdare updated.Why #345's tick did not carry. The gate never recorded a tick on #345. Every
enforcement-approvalstatus on its pre-update headc3b27acisfailure, and noissue_commentgate run touched #345 after 9 November 18:33 UTC. The only tick on 10 November was on #346, at head77d9f2b, at 10:58:25 UTC. Nine seconds later #346 was rebased onto main and force-pushed to1bce1d8. Its guard fingerprint was identical (2bc7777…), but77d9f2bwas no longer a commit of the PR, so ADR 0122's carry rule correctly refused. For #345, the fingerprint before and after its update (7690f33…) is identical andc3b27acstays in the PR, so a tick there would have carried. This is why the workflow merges and never rebases.Behavioural Proof (with video and screenshots)
Not applicable: this change adds a CI workflow and gate scripts with no user-visible UI. Deterministic proof follows.
scripts/update-behind-prs.test.tscovers the selection logic: behind, draft, conflicting, up to date, workflow change, fork, bot and unknown mergeability. It also covers the shell: one notice per PR, rewritten when the reason changes and cleared once current; a head that moves during the read or the update; an asynchronous update; a head that never moves; a failed dispatch finished by the next run; and a dry run.scripts/validate-pr-body.test.tscovers earlier heads, the North Star read at the named commit, and real-Git clean, edited, side-branch and ordinary commits.scripts/enforcement-approval.test.tscovers a dispatched gate carrying the tick, and a badinputs.pr.scripts/required-gates.test.tscovers missing dispatch triggers andDISPATCHESentries.scripts/lighthouse-scope.test.tscovers the dispatched full run.pnpm e2estill passes.#343 and #344 target
feat/todo-example-app, not main, so the workflow never lists them.Verification Summary
5cd630f4ac19c6679a939b4361b85026cc8bd98dpnpm verify,pnpm e2e):pnpm verify,pnpm e2e,node scripts/required-gates.mjs --check,node scripts/update-behind-prs.mjs --dry-run, the validator on feat(lint): add six policy rules mined from nine agent rebuilds #345 and feat(gates): fail the gate on Fallow, Playwright worker and runner warnings #346 as above.pnpm verifypassed in the pre-push hook (3023 Jest tests plus the integration and contract projects) andpnpm e2epassed (15 Playwright tests) onc2c401f. At 12:31 UTC the branch was rebased onto main after feat(lint): add six policy rules mined from nine agent rebuilds #345 merged;git range-diffshows this head's four commits identical to those atc2c401f, and this head is judged by its CI run. The rebase also took the ticked commit out of the PR, so the sign-off cannot carry (ADR 0122) and needs a fresh tick at this head. Locally the contract suite needsPACT_DIRset to a private directory, because another worktree lefttodos.addinteractions in the shared default pact file; one earlier hook run failed on an unrelatedscripts/bench/run.test.tspnpm tarball-integrity retry and passed on rerun..agents/project/PR_QUALITY.md) satisfied, or each gap named: satisfied, except the live gaps listed under known risks.pnpm verifypnpm e2e.agents/project/ARCHITECTURE.mdandCONVENTIONS.md; new decisions recorded as ADRs.workflow_dispatch. The first run after merge is the live proof. Watch the Update behind PRs run and the dispatched checks on the first updated PR.maindoes not require theenforcement-approvalstatus orVisual regression, thoughdocs/required-gates.mdlists both. A carried tick shows on the PR but does not gate merging until the settings match. This predates the PR;pnpm gates:protectionreports the difference.PRD Behaviours to Review
PR Proof Law
.agents/project/PR_QUALITY.mdand.agents/skills/pr-quality-contract/SKILL.md; thePR qualitycheck verifies the proof format.🤖 Generated with Claude Code