Skip to content

feat(github): Backfill next actions and ask for reviews on Junior PRs in limbo - #4310

Merged
BYK merged 5 commits into
mainfrom
junior/pr-action-backfill
Nov 25, 2026
Merged

BYK merged 5 commits into
mainfrom
junior/pr-action-backfill

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The next action of a Junior pull request ("Review requested", "Ready to merge", or the held-draft ask from #4306) is derived only when a webhook that can change it arrives. Two groups of open PRs have no item:

This is a one-off run with a done key, not a recurring poll. A new started task, backfillPullRequestActions, does the run. It follows the repository-name-repair one-off (#4192):

  • After deploy, the GitHub heartbeat starts one page per tick: 50 open Junior PRs, in GitHub id order. Each page has its own task key.
  • Each page goes through the webhook sync path, syncGitHubPullRequestActions, with the same claim and the same concurrency limit of 5. A PR that no person asked for returns before any GitHub read.
  • After the last page, the task sets pull-request-action-backfill:v1:done in plugin state, and the heartbeat never starts it again. To run it again after a later rule ships, bump VERSION in pull-request-action-backfill.ts.

Limbo

inLimbo in pull-request-action.ts uses only what nextAction already reads, plus the head commit time. An open Junior PR is in limbo when all of these are true:

  • The derived action is none.
  • It is not a draft, and auto-merge is off.
  • It has a stored requester with a linked GitHub login.
  • GitHub has no pending user review request for the requester. A pending request for another person or a team does not count, because it asks the requester for nothing.
  • The requester has not reviewed or commented since the last push (the head commit's committedDate).
  • No reviewer approved it. Such a PR waits only on others.
  • No reviewer, the requester included, requests changes. On such a PR, Junior acts next.

For each PR in limbo, the backfill asks for the requester's review on GitHub. It uses requestPullRequestReviewers, the same call that #3250 makes on ready_for_review. It asks only the requester, and never code owners or teams. The next read then derives the normal "Review requested" item. To show approval on a PR that is not clean, the merge-state read now computes reviewOutcome for every open PR. nextAction still reads it only for clean PRs.

Side effect: after deploy, the backfill sends one GitHub review request to the requester on each PR in limbo, for all users. GitHub data from 11-25: 98 open, ready Junior PRs, from 21 requesters, have an assignee that GitHub does not ask for a review, are not approved, have no change request, and have auto-merge off. This is an upper bound. PRs that derive merge, PRs where the requester commented after the last push, and PRs with no stored requester or linked login are not asked. BYK has 34 of these PRs. About 14 of them derive "Ready to merge" under #4304, so BYK gets about 20 review requests.

Dismissed items stay dismissed. The sync changes an item only when the derived action is different from the saved one. getsentry/sentry-rust#1400 has merge saved, so its dismissed "Ready to merge" item does not come back. A PR in limbo has no saved action, so asking for its review cannot bring back a dismissed item.

Started plugin tasks now get inboxItems and users.readIdentity, as plugin routes do. The task needs them to show items and to map the requester's linked GitHub login.

PRs that go into limbo after this one-off are handled by the PR stacked on this one.

Proposed design/github.md rule (not edited here)

A ready Junior PR always has an Inbox ask or a pending GitHub review request for its requester. When it asks nothing of the requester, Junior asks for the requester's review on GitHub once the required checks pass, but not after a push when the requester has already reviewed or commented.

via @BYK.

--

View Session [Sentry]

@sentry-junior
sentry-junior Bot added this pull request to stack #4307 November 25, 2026 13:30
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 25, 2026 11:40pm UTC

Request Review

@blacksmith-sh

This comment has been minimized.

@sentry-junior sentry-junior Bot changed the title feat(github): Backfill the next action of quiet Junior pull requests feat(github): Backfill next actions and ask for reviews on Junior PRs in limbo Nov 25, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check and address Warden comments. Also plan for the removal of this one-time backfill when we are done with it?

@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

There is one Warden finding on this PR, ZAN-4M6, and I declined it. A pending request for someone else or a team doesn't take a PR out of limbo, because the confirmed rule in design/github.md is about the requester's own ask. Cursor's busy-page finding is fixed in ca2ef6046, which is now d6158c5 after the restack. Warden is still running on d6158c5. I'll answer anything it finds there.

The removal plan is in #4388. Once this ships and the backfill sets its done key, delete the backfill file, its task registration and heartbeat start, its tests, and the options only it uses (askAfterRequesterActed and the busy list). The webhook limbo ask from #4317 stays.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d6158c5. Configure here.

Base automatically changed from feat/github-held-draft-inbox to main November 25, 2026 23:05
@BYK
BYK force-pushed the junior/pr-action-backfill branch from 4f56ea4 to 6bba487 Compare November 25, 2026 23:05
@sentry-junior
sentry-junior Bot force-pushed the junior/pr-action-backfill branch from 6bba487 to 4f56ea4 Compare November 25, 2026 23:13
sentry-junior Bot and others added 5 commits November 25, 2026 23:31
The next action of a Junior pull request derives only when a webhook that
can change it arrives. A pull request that went quiet before a derivation
rule shipped keeps no action and no Inbox item for it. A one-off started
task now syncs each open Junior pull request once, one page per heartbeat,
through the webhook sync path.

Started plugin tasks get Inbox items and stored identities, as plugin
routes do, so the task can show items and map the requester's GitHub login.

Co-Authored-By: BYK <[email protected]>
…imbo

A ready Junior pull request can wait on nobody: its action is none, GitHub
does not ask the requester for a review, the requester has not reviewed or
commented since the last push, and no reviewer approved it or requests
changes. The one-off backfill now asks only the requester's review on
GitHub for such a pull request, and the sync then shows its review item.

The next-action read now gives the head commit time, and the review
outcome for every open pull request, not only one that GitHub can merge.

Co-Authored-By: BYK <[email protected]>
… its PRs

A webhook that holds a pull request's sync claim checks it again without
askInLimbo, so the backfill skipped that pull request's limbo ask. The
sync now returns the pull requests it could not claim, and the backfill
keeps its cursor and runs the page again on the next heartbeat.

Co-Authored-By: BYK <[email protected]>
The ready-sync claim returned undefined both when another webhook held
the check and when Junior has no row for the pull request. The backfill
counted both as busy, so an untracked pull request ran its page again
forever. The claim now returns held for a check that another webhook
runs.
@sentry-junior
sentry-junior Bot force-pushed the junior/pr-action-backfill branch from 4f56ea4 to 10695ba Compare November 25, 2026 23:40
@BYK
BYK merged commit a899a78 into main Nov 25, 2026
58 checks passed
@BYK
BYK deleted the junior/pr-action-backfill branch November 25, 2026 23:56
BYK added a commit that referenced this pull request Nov 25, 2026
…er answers (#4317)

Stacked on #4316, on top of #4310, which
backfills the PRs that are in limbo now. This PR keeps new PRs out of
limbo, and it decides what counts as the requester's answer to a review
ask. It applies to webhooks and to the #4310 backfill. Every ask goes
only to the requester, through `requestPullRequestReviewers`, the call
#3250 makes on `ready_for_review`. The next read shows
the normal "Review requested" item.

## 1. Ready PRs that wait on nobody

New PRs can still enter limbo:

- The requester links GitHub after Junior opens the PR, so the request
at open and the request on `ready_for_review` had no login to ask.
- The request at open or on `ready_for_review` fails. Both only log a
warning.

`inLimbo` in `pull-request-action.ts` decides it. A PR is in limbo when
its derived action is none and all of these are true:

- It is open, not a draft, and auto-merge is off.
- No review ask for the requester is open: GitHub does not ask them, and
no comment-only review keeps an ask open (see 2).
- The requester has not commented, approved, or requested changes since
the last push.
- No reviewer approved it, so it does not wait only on others, and no
reviewer requests changes, so Junior does not act next.
- The requester did not remove their own review request since the last
ask (see 3).

A pending request for another person or a team does not take a PR out of
limbo. It asks nothing of the requester.

When a PR is in limbo and the base branch's required checks pass, the
sync asks for the requester's review. A webhook asks only a requester
who has not commented or reviewed, so a push never asks again. The
one-off backfill also asks one who acted before the last push
(`askAfterRequesterActed`). Review-again already reads the required
checks, so that reader is now shared as `readGitHubRequiredChecksPass`.
Until the checks pass, each `check_suite` webhook syncs again. An ask
counts only once Junior sends it, so a later check in the same sync can
still ask. Each limbo sync costs one more GraphQL read and one REST
branch-rules read until the requester is asked.

## 2. A comment-only review is not an answer

A comment-only review neither approves nor requests changes, but GitHub
drops the pending request on it. GitHub also records a reply in a review
thread as a comment-only review. Now the ask stays open
(`askStaysOpen`): the requester was asked, then left a comment-only
review, and has not approved, requested changes, or removed their own
request since. While the ask is open:

- The derivation treats the requester as asked, so the PR keeps its
"Review requested" item until they approve or request changes.
- The limbo check counts the ask as pending, so Junior sends no new
GitHub request.

A plain PR comment still means Junior acts next, as before. A change
request still follows the review-again flow.

## 3. A removed request stays removed

The requester can remove their own review request. GitHub records this
as a `review_request_removed` timeline event with the requester as both
actor and reviewer. After that, neither the backfill nor a webhook asks
them again, until someone asks them again on GitHub. If another person
removes the request, it does not count. The next-action read now
includes `ReviewRequestRemovedEvent` in its timeline.

## design/github.md

This PR adds the rule text that BYK confirmed:

- The change-request bullet now reads "When the requester comments,
approves, or requests changes, Junior acts next, and the Inbox stops
asking."
- "A comment-only review is not an answer to a review ask. The ask stays
open: the PR keeps asking the requester to review in the Inbox, and
Junior does not ask again on GitHub."
- "A ready Junior PR always has an Inbox ask or a pending GitHub review
request for its requester. When it asks nothing of the requester, Junior
asks for the requester's review on GitHub once the required checks pass.
A push does not ask a requester who has already reviewed or commented."
- "When the requester removes their own review request, Junior does not
ask them again until someone asks them again on GitHub."

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A6eedb91e2d3dfa1fd070e65575e7799d -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A6eedb91e2d3dfa1fd070e65575e7799d)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A6eedb91e2d3dfa1fd070e65575e7799d/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 10695bad Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant