Repository navigation
feat(github): Store PR requesters with their Junior identity instead of parsing PR bodies - #2306
Merged
Merged
Conversation
Junior opens most of its own pull requests, so authorRole filters see the bot instead of the person who asked. Add requesterUsername and requesterRole match fields. The create tool now saves the requester's linked GitHub login for the head branch before it opens the pull request, so the opened webhook can read it. On a Junior pull request, webhooks use that saved login. On other pull requests, or when Junior has no saved requester, they use the author. Webhooks do not read the attribution block in the body. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The create tool saves the requester before it opens the pull request. A rejected create left that row in place, so a create attempt on the branch of an existing pull request could change that pull request's requester. Restore the earlier requester when GitHub does not open the pull request.
Store one row per person who asks Junior to open or update a pull request, keyed by PR number and Junior identity id, with the user id and linked GitHub login. The create row is the opener; update rows never replace it. The create tool writes a pending row before it calls GitHub, links it to the number after GitHub opens the PR, and removes it when GitHub rejects the create. Only opened events read pending rows, and only when the PR has no create row, so a rejected create cannot change the opener of an open PR. Co-Authored-By: David Cramer <[email protected]>
Pending requester rows were keyed only by repository and head branch. A concurrent create on the same branch, or a fork head with the same branch name, could replace or attach another caller's opener. Each create call now writes, removes, and links only its own pending row, keyed by Junior identity. After GitHub opens the PR, the tool saves its own create row with the number. The opened webhook uses a pending row only for a same-repo head, when the PR has no create row, and when exactly one recent pending row exists for the branch. Fork heads get no pending row.
Requester rows now keep only the core Junior identity id. The user and linked GitHub login are no longer copied into the GitHub plugin table. Webhooks read the opener's identity through a new route-context capability, ctx.users.readIdentity(), and use the GitHub identity of the linked user. A person who links GitHub later now resolves on older PRs too. A failed identity lookup leaves the requester fields out, so filters on them do not match. Co-Authored-By: David Cramer <[email protected]>
Attribution, the saved pull request requester, and the pull request assignee each looked up the current actor on their own. Look it up once per write and pass the result to each step. This removes the separate requester actor helper and makes the request builders synchronous. Co-Authored-By: David Cramer <[email protected]>
dcramer
reviewed
Oct 28, 2026
dcramer
reviewed
Oct 28, 2026
Only the opener lookup read the action. The opener is the first row for a pull request number, because the create tool clears older rows for the number before it saves its own. So the column adds no information. Numbered rows also no longer save the head branch. Only pending rows, which do not have a number yet, need it to match the opened webhook.
The create tool removed the pending requester row before it saved the row with the pull request number, and it saved that row only after it saved the completed tool state. A failure between those steps lost the opener, and a retry of the same tool call returned early without it. Save the numbered row first, with the time the create call started, so it stays the first row for the number. Then remove older rows and the pending row. A retry of a completed call now saves the opener again.
The create tool saved a pending requester row, keyed by head branch, before it called GitHub. This let an early opened webhook find the requester, but it needed a head branch column, a pending lookup, and handling for concurrent and rejected creates. Save the opener only after the create succeeds, so each row is just a repository, number, and identity. A Junior bot pull request with no saved row now has no requester fields, so requester filters do not match an opened event that arrives first.
Junior pull requests have no requester until the create tool saves the opener, so an early opened event can lack the field. Co-Authored-By: David Cramer <[email protected]>
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 21b5429. Configure here.
Co-Authored-By: David Cramer <[email protected]>
dcramer
approved these changes
Oct 29, 2026
dcramer
added a commit
that referenced
this pull request
Oct 29, 2026
Follow-up to #2306. That PR added `requesterUsername` and `requesterRole` next to GitHub's `authorUsername` and `authorRole`. Filters could still mix up who opened a PR with who wrote it. On Junior's PRs, the GitHub `author` is the bot. This PR replaces those fields with two concepts. Each one can be matched and is in the event data that the agent gets. **Fields** - `openerUsername`, `openerEmail`, `openerRole`: who opened the PR. On Junior's PRs, this is the person who asked Junior to open it. Junior gets it from the saved opener row and that person's linked GitHub identity, as in #2306. When Junior does not know their GitHub login (no row yet, no linked account, or a failed lookup), the opener fields are left out. **This changes #2306:** Junior no longer uses the bot in its place, so `openerRole: "none"` cannot match Junior's own PRs. - `authors`: a list of the GitHub logins of the commit authors and of `Co-authored-by` trailers that use GitHub noreply emails. Bots are included, so Junior's PRs list `sentry-junior[bot]` and the people it credits. **Core: list match fields** - `eventMatchFieldSchema` accepts `list: true`. It is not allowed with `boolean`. - `eventMatches` now compares sets. A list event value matches when it includes the match value, or any entry of a match list. Scalar behavior does not change. - `searchEventTypes` output and the match schema description now include `list`. **Lazy loading** `withGitHubPullRequestMatchData` (it replaces `pull-request-roles.ts`) loads the opener on Junior's PRs, `openerRole`, and `authors`: 1. Before the match decision, it loads the values that a Watch or event automation filters on (`neededMatchKeys`). 2. It loads the other values only when an event matches (`hasMatch`), so delivered events have all of them. Repository-watch copies get the PR number through the shared `eventKey`. `authors` and the people involved in approvals and merges now share one read of the commit pages per delivery (`shareCommitPages`). Before this, they would read the commits twice. **Review notes** - This is a hard rename. A saved Watch or event automation that uses `authorUsername`, `authorEmail`, `authorRole`, `requesterUsername`, or `requesterRole` stops matching until it is recreated with the new keys. Check the paused issue-first automation before resuming it. I did not read or change it. - Check suites have the opener fields only when a filter needs the PR load, as before. `authors` works on check suites without that load. - Login matching is still exact and case-sensitive, as it was for `authorUsername`. **Checks** - `pnpm --filter @sentry/junior-github exec vitest run`: 256 passed. - `pnpm --filter @sentry/junior exec vitest run tests/unit/events`: passed. - Typecheck for `junior`, `junior-github`, `junior-plugin-api`. `pnpm lint`. - Two integration tests in `@sentry/junior` also fail on `main` (`event-automations` card delivery and `event-wake-delay` timeout). This change does not cause them. <!-- junior-request-attribution:start --> via **David Cramer**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0AHB7N2JCR%3A1793219736.990659 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0AHB7N2JCR%3A1793219736.990659) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0AHB7N2JCR%3A1793219736.990659/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: David Cramer <[email protected]>
sentry-junior Bot
added a commit
that referenced
this pull request
Nov 16, 2026
Review flagged a stored field that the provider or existing rows could give in #2306, #2824, #2828, #2850, #2951, #3042, #3181, and #3383. The rule goes in the interface-design Lifecycle state section, next to the rule that owns copies, instead of AGENTS.md. It names the cases that need a stored value: an earlier-time snapshot, missing read authority, and a measured read cost. Those cases match the durable payloads in serverless-background-work.md and the stored handles in context-bound-systems.md. Co-Authored-By: David Cramer <[email protected]>
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.

Junior opens most of its own pull requests. Filters on
authorRoletherefore see the bot, not the person who asked for the PR. The issue-first automation closed Junior's own PRs (#2302, #2304) because of this.This PR saves every person who asks Junior to open or update a PR as a link to their core Junior identity. It adds the
requesterUsernameandrequesterRolematch fields. Webhooks get them by following normal core relationships (identity → user → linked GitHub identity), not from the PR body.Data model
New GitHub-plugin table
junior_github_pull_request_requesters. One row per (repository, PR number, Junior identity):identity_id: the corejunior_identities.idof the person who acted. The plugin does not copy the user id or GitHub login.action:createfor the person who asked Junior to open the PR,updatefor anyone who later asked Junior to change it. This mirrors how the attribution block grows.Core contract
ctx.users.readIdentity(identityId)in@sentry/junior-plugin-api. It returns the identity and the user it links to now, with every identity of that user. Core implements it withreadIdentityByIdFromSqlinchat/plugins/viewer.ts.How it works
github_createPullRequestwrites a pendingcreaterow for the caller's identity (no number, keyed by head branch) before it calls GitHub, because GitHub can deliveropenedfirst. After GitHub opens the PR, the tool saves its owncreaterow with the number. When GitHub rejects the create, the tool removes only its own pending row.github_updatePullRequestadds anupdaterow after each successful update.pull_request.openedfor a same-repo head falls back to a pending row, and only when the PR has nocreaterow and exactly one recent pending row exists for the branch. Concurrent creates on one branch give no opener until the tool saves the row. Fork heads get no pending row.requesterUsernameis the GitHub login linked to the opener's user. On other PRs, or when the opener has no linked GitHub identity, it is the author. If the identity lookup fails, the event has no requester fields, so filters on them do not match.requesterRoleuses the same cached lookup asauthorRole, and loads only when a filter needs it.via @someonechanges nothing.Why not the existing PR → conversation links? Junior already links PRs to conversations (
junior_github_pull_requests.conversation_idsand corejunior_code_changes). But a conversation's actor is the person who started the thread, not always the person who called the tool. On #2304, the thread starter was a different person from the requester. The tool-call actor's identity is the only reliable source, so this change stores it.Limits
requesterUsernameorrequesterRole.Rollout: After this deploys, change the issue-first automation's trigger to
requesterRole: [write, triage, read, none]and remove its assignee-based maintainer check. The automation is paused right now.Verification:
pnpm typecheckpasses. For@sentry/junior-github, lint and all 256 tests pass. In@sentry/junior, lint,tests/unit/pluginsandtests/componentpass (907 tests). That includes a new component test forreadIdentityByIdFromSqlthat links GitHub after the identity exists.migration-metadata:check,file-length:checkandtest-architecture:checkpass. The GitHub integration test covers:openedbefore the create returns, concurrent creates on one branch, a rejected duplicate create, an update by another person, an opener with no linked GitHub, that opener linking GitHub later, and a human-authored PR.via David Cramer.
--
View Junior Session [Sentry]