Gate external PRs on an assigned, linked issue - #3291
Draft
maxisbey wants to merge 1 commit into
Draft
Conversation
Unsolicited pull requests now outnumber issues four to one and almost none are reviewable in the time we have. This adds a workflow that closes an external PR unless its description links an open issue the author is assigned to (or one labeled "help wanted"), and reopens it automatically once a maintainer assigns them. Maintainers, triage-role collaborators, bots and drafts are exempt; reopening a PR or removing the control label is a sticky maintainer override. PRs numbered below 3200 predate the gate and are only evaluated on manual dispatch. The workflow is adapted from PrefectHQ/fastmcp's require-issue-link.yml (itself from langchain), restructured into a single script that always reads PR state live, requires linked issues to be open and in this repo, finds gated PRs via the list API rather than search, and diagnoses a refused reopen instead of guessing. It ships in dry-run: set the PR_GATE_ENFORCE repository variable to "true" to enforce. CONTRIBUTING.md is rewritten around the policy (issues are the contribution; how PRs get in; who we want to hear from), AGENTS.md gains an agent-facing statement of it, and a short repo-level PR template leads with the Fixes line the gate looks for. No-Verification-Needed: workflow and docs only; exercised with a mock harness, actionlint and zizmor
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.
Adds an intake gate for pull requests from outside the maintainer team: a PR stays open only if it links an open issue its author is assigned to (or one labeled
help wanted). Everything else is closed by a bot with an explanation and reopens automatically once a maintainer assigns the author. CONTRIBUTING.md is rewritten around that policy.Motivation and Context
Over the last six months this repo received ~640 pull requests from outside the maintainer team — 2.7× the previous six months — of which 24 were merged. 41% of newly opened issues now attract an external PR within 48 hours (median under 11 hours), the open-PR backlog is ~80% external, and CONTRIBUTING.md's existing "issue first, no drive-by agents" rules have no mechanical backing. Reviewing a PR properly costs the same as it always did; producing one no longer does. With the maintainer time we actually have, issues are the contribution we can use, and this makes the repo say so and behave accordingly.
The workflow is adapted from PrefectHQ/fastmcp's
require-issue-link.yml(which came from langchain's); pydantic and pydantic-ai run similar gates. Within this org, inspector has already gone issues-only and typescript-sdk restricted PR creation for a month in June for the same reason.Behaviour
Fixes/Closes/Resolvesan open issue in this repo where the author is an assignee, or the issue carrieshelp wanted. Otherwise:missing-issue-linklabel, one comment, closed.editedevent; anyone triage+ reopens the PR or removes the label → stickybypass-issue-check.workflow_dispatch; from 3200 up a PR is evaluated on its next event. Once labeled, a PR is managed normally regardless of number.PASS/FAILand[dry-run] would …lines and mutates nothing until the repository variablePR_GATE_ENFORCEis set totrue.Differences from the fastmcp version (also listed in the file header): one job and one script for all three entry points (PR events, issue assignment, manual dispatch) so admission and reopening can't drift; PR state is always read live rather than from the event payload, which closes a race where a queued run could strip the label without reopening and orphan the PR; linked issues must be open and still in this repo; gated PRs are found with the list API rather than Search; reopen-before-unlabel with the refused-reopen diagnosis above; trust from capability flags rather than role-name strings; the waiver label is our existing
help wanted.Docs
ready for workmeans queued for a maintainer, not an invitation)..github/pull_request_template.md: a short repo-level template that leads with theFixes #line the gate looks for, replacing the inherited org template here.How Has This Been Tested?
help wanted; maintainer reopening their own vs a gated PR; triage-role and bot label removal; Dependabot; hand-closed PRs; closed/transferred/cross-repo/PR-number references; both refused-reopen diagnoses; issue assignment; dispatch backfill; drafts; pass→fail comment un-minimizing; a planted marker comment), in enforce and dry-run modes.actionlintandzizmor --pedanticclean (thepull_request_targettrigger carries an inline justification; the workflow never checks out or executes PR code and interpolates nothing from the PR into the script).collaborators/{user}/permissioncapability flags for admins, outsiders and app logins;issues.listForRepowithcreator+labels+state=closed;minimizeComment/unminimizeComment) were checked against the live API, and the same permission set is what fastmcp's copy has been running with since May.Breaking Changes
None for SDK users. For contributors: PRs opened without an assigned, linked issue will be closed automatically once enforcement is on; CONTRIBUTING.md describes the path.
Types of changes
Checklist
Additional context
Rollout after merge:
help wantedfrom the closed issues that still carry it, and update thehelp wanted/ready for worklabel descriptions to match CONTRIBUTING.md.PR_GATE_ENFORCE=true(Settings → Secrets and variables → Actions → Variables).gh workflow run require-linked-issue.yml -f pr_number=<n>.AI Disclaimer