Repository navigation
feat(github): Add an opt-in, policy-gated pull request merge tool - #2402
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
Add github_mergePullRequest. The app turns it on per repository with
githubPlugin({ pullRequestMerge: { repositories } }). With no list, the
tool is not registered and egress denies every merge.
Each merge must pass a deterministic policy:
- the requester has a linked GitHub account with write access
- the PR is open, not a draft, and its head is the checked SHA
- GitHub reports mergeable_state clean (or has_hooks)
- no reviewer has an open change request
- a bot-authored PR has a human approval on the current head
- a human-authored PR has a bot review on the current head and no
bot-written commits
Egress allows PUT /pulls/{n}/merge only with the tool's operation and
only on listed repositories, so raw gh/api merges stay denied.
Co-Authored-By: David Cramer <david@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
dcramer
marked this pull request as ready for review
October 30, 2026 02:34
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 95206fc. Configure here.
GitHub lists at most 250 commits for a pull request. Compare the listed commits with the PR commit count, so an unlisted bot commit cannot pass the person-authored merge rule.
This branch was successfully deployed
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.

Add
github_mergePullRequestso Junior can merge in a few narrow cases, such as the fair.io listing automation. Merging is off by default. It turns on per repository in app config.When the list is empty, the tool is not registered. The egress policy then denies every merge.
Merge policy (
src/pull-request-merge-policy.ts, deterministic, checked on every call)The rule: two parties, at least one of them a person. Junior never merges code that only Junior wrote and checked.
writeoradminon the repo. For automations, the requester is the automation creator. This is the code-checkable version of "you've been told you can merge."head.shaequals theheadShathe caller checked. The same SHA goes to GitHub's merge API, so a push that lands mid-flight fails the merge.mergeable_stateiscleanorhas_hooks. This requires passing checks, no conflicts, and met branch protection.unknown,unstable, andblockedare refused.CHANGES_REQUESTED.Enforcement layers
PUT /repos/{o}/{r}/pulls/{n}/mergeonly with the tool'sgithub.pull.mergeoperation and only on listed repos. Rawgh api -X PUT .../mergefrom the sandbox stays denied.gh pr mergeand auto-merge use GraphQL mutations, which are already denied.installation-write, so the App installation needsContents: writeon the repo.Open questions for review
squashOK, or should the method come from repo settings?Follow-up (junior-prod, not in this PR): list
fairsource/fair.ioinpullRequestMerge. Add the stricter fair-source-review checks (validcompanies.json, logo exists, hex color, no changes outside the entry). Then update the automation to merge only on apass.Checks
pnpm lintpassed.tsc --noEmitpassed forjunior-github.vitestpassed fortests/merge-pull-request.test.tsandtests/github-plugin.test.ts.junior-githubsuite had onewebhook-outcomestimeout. That test passes alone, and this PR does not change it.via David Cramer.
--
View Session [Sentry]