Skip to content

feat(github): Ask named people to review a new issue - #4100

Closed
sentry-junior[bot] wants to merge 8 commits into
mainfrom
feat/github-issue-review-by
Closed

sentry-junior[bot] wants to merge 8 commits into
mainfrom
feat/github-issue-review-by

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

A pull request that Junior opens becomes an Inbox item by itself, because GitHub sends a review request. An issue gets nothing, but not every issue is for a person to act on: a bug filed for tracking is not. So the trigger is explicit and the item is deterministic.

Tool

github_createIssue gets a review_by input: the people whose review or decision the issue waits on. The tool text tells the agent to set it for design issues and proposals, and to leave it out for tracking issues and bugs. People resolve the way github_createPullRequest resolves reviewers (GitHub logins, emails, Slack mentions, or names) to a linked GitHub account. Like github_createPullRequest, the tool rewrites Slack mentions in its own text and leaves review_by out, so a mention keeps its Slack user ID for the lookup. The tool assigns each person on the issue, so GitHub shows whom it waits on, and adds their items. The result lists review_requested logins and review_left_out people with a reason: no match, more than one match, no linked GitHub account, not in the Conversation, or GitHub did not assign them. The review requests run after the issue's idempotency state is saved, so a failure there cannot open a second issue on retry.

Items

The GitHub plugin adds one "Review requested · #N" item for each assigned person, with the issue as its subject and the dedupe key issue-review:{repo}#{number}:{login} in the plugin's namespace. Only review_by adds items. An assignment that claims an issue (github_updateIssue with assign_requester) adds nothing, and a close for a person who has no item does nothing. There is no new table or column. The item closes as done when:

  • the issue closes: each assignee's item (issues webhook),
  • that person comments on the issue (issue_comment webhook), or
  • that person reacts to the issue. GitHub sends no webhook for reactions, so each heartbeat reads the next 10 open issues that Junior opened in the last 30 days (junior_github_issues), under one lock with a saved cursor. It reads the reactions only of an issue with assignees and reactions, and repeat reads are conditional.

Unassigning a person withdraws the ask, so the issues unassigned webhook dismisses their item. Webhooks find the item's Conversations in the issue's footer. A reopen does not bring an item back. Dismiss and Snooze stay generic.

Core contract

  • The plugin tool context gets inboxItems, the plugin Inbox items of the Conversation, with assignable(identityIds). It uses core's existing rule that a plugin item goes only to people in its Conversation, so the tool can say who is left out.
  • A found result of findLinkedHandle now has the identityId.

Design

design/github.md gets one rule: an issue that Junior opens for a person's review is an action for that person, and it closes when the issue closes or when they respond on it.

Dashboard

An issue review row shows like a pull request row: the issue title after the Review pill, with its number below. It gets no new pill and stays under Other, not PRs.

Desktop Mobile
Light light desktop light mobile
Dark dark desktop dark mobile

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 23, 2026 15:39
github_createIssue gets a review_by input: the people whose review or
decision the issue waits on, such as for a design issue or a proposal.
The agent leaves it out for tracking issues and bug reports.

The GitHub plugin adds one "Review requested" Inbox item for each named
person with a linked GitHub account who is in the Conversation. The item
closes as done when the issue closes, when that person comments on the
issue, or when they react to it. GitHub sends no webhook for reactions,
so the plugin heartbeat reads them for recent issues. A reopen does not
bring the item back.

The plugin tool context gets the Conversation's plugin Inbox items, with
a check for which Identities an item can go to, and a found linked
handle now carries its Identity.

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

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

# Conflicts:
#	packages/junior-github/tsconfig.json
@sentry-junior
sentry-junior Bot requested a review from BYK November 23, 2026 15:46
@vercel

vercel Bot commented Nov 23, 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 23, 2026 7:33pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 23, 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.

Two things:

  1. I don't want yet another table to keep track of this. Let's try to find a way around this. Can be unification if PR related tables somehow or completely going by the assignee field of the issue as I mentioned earlier
  2. The display seems like the old PR card where the title is not very helpful. This should be fully aligned with the PRs. Not sure if this deserves a new filter pill yet though as that area is getting crowded. I guess this may be grouped under decisions maybe? If not it should go to Todo or others

@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.

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

207 screenshot changes — 207 changed · 0 added · 0 removed

Review screenshots in Frameshift

Admin Cache Warming · Desktop
Admin Cache Warming · Desktop
Changed
Admin Cache Warming On · Desktop
Admin Cache Warming On · Desktop
Changed
Automation Attention · Desktop
Automation Attention · Desktop
Changed
Automation Details Failing · Desktop
Automation Details Failing · Desktop
Changed
Automation Details Failing Light · Desktop
Automation Details Failing Light · Desktop
Changed
Automation Details Healthy · Desktop
Automation Details Healthy · Desktop
Changed
Show 12 more changed screenshots
Automation Details Long Instruction · Desktop
Automation Details Long Instruction · Desktop
Changed
Automation Editor · Desktop
Automation Editor · Desktop
Changed
Automation Editor Conflict · Desktop
Automation Editor Conflict · Desktop
Changed
Automation Editor Public · Desktop
Automation Editor Public · Desktop
Changed
Automation Event Editor · Desktop
Automation Event Editor · Desktop
Changed
Automation Event Editor Any Resource · Desktop
Automation Event Editor Any Resource · Desktop
Changed
Automation Overview Run Details · Desktop
Automation Overview Run Details · Desktop
Changed
Automation Page · Desktop
Automation Page · Desktop
Changed
Automation Page Light · Desktop
Automation Page Light · Desktop
Changed
Automation Paused · Desktop
Automation Paused · Desktop
Changed
Automation Run Details · Desktop
Automation Run Details · Desktop
Changed
Automation Run Details Light · Desktop
Automation Run Details Light · Desktop
Changed

189 more changed screenshots in Frameshift.

sentry-junior Bot and others added 2 commits November 23, 2026 16:09
Drop the junior_github_issue_reviewers table and its migration.
github_createIssue now assigns each review_by person on GitHub and adds
their item. Only review_by adds items, so an assignment that claims an
issue adds and closes nothing.

A comment closes the commenter's item, and an issue close closes each
assignee's item, in the Conversations that the issue's footer names.
The reaction poll reads the open issues that Junior opened from
junior_github_issues, a few per heartbeat under one lock, and closes
the items of assignees who reacted.

The dashboard shows an issue review row like a pull request row: the
issue title after a Review pill, with its number below. It stays under
Other.

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

@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 3 potential issues.

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 ce7526c. Configure here.

github_createIssue now rewrites Slack mentions itself, as
github_createPullRequest does, and leaves review_by out of that rewrite.
A mention keeps its Slack user ID for the lookup, so an unlinked person
is not looked up by name and matched to someone else.

The tool also builds its result after the create try block. An auth
prompt while it asks for reviews no longer deletes the completed state,
so a retry of that tool call does not open a second issue.
sentry-junior Bot and others added 2 commits November 23, 2026 19:22
…iew-by

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

# Conflicts:
#	design/attention.md
…igned

Unassigning a reviewer withdraws the ask, so the issues unassigned
webhook dismisses that person's Review requested item in the
Conversations that the issue footer names. Assigning still adds no
item.

Co-Authored-By: BYK <[email protected]>
@sentry-junior

sentry-junior Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Changed in ce7526c:

  1. No new table. junior_github_issue_reviewers and its migration are gone, and there are no new columns. review_by now assigns those people on the issue and adds their items. Assignees are only GitHub's display of review_by: an assignment never adds an item, and a close for someone with no item does nothing, so a claim assignment changes nothing.
    • A comment closes the commenter's item. An issue close closes each assignee's item. Both use the Conversations named in the issue's footer, so webhooks need no lookup.
    • The reaction poll reads the next 10 open issues that Junior opened (existing junior_github_issues rows, last 30 days) per heartbeat, under one lock with a saved cursor. It reads reactions only when the issue has assignees and reactions.
  2. Display. An issue review row now renders like a PR row: the issue title after the Review pill, #N below, and the "waits on your review" text hidden under that head. No new pill. It stays under Other. The screenshots in the description are updated.

Since then:

  • 8194ffb: review_by mentions keep their Slack user ID for the lookup, and an auth prompt while asking for reviews can no longer open a second issue on retry.
  • ea226f8: unassigning a reviewer dismisses their item. Assigning still adds none. After merging main, the design rule now lives in design/github.md, word for word.

@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.

I feel like we should also invest in a GitHub User Id -> Internal Id map in redis or something as this is pretty common op now. The reverse may also be useful. This should be in a follow up.

Comment on lines +87 to +88
item.subject?.objectType === "task" &&
item.title.startsWith("Review requested · ")

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.

This looks like a terrible way to identify? Why are we not recording this in objectType or kind or something?

@sentry-junior

sentry-junior Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Opened #4123 for the GitHub account ↔ Identity map, as a cache layer (state adapter) in front of GitHub and the identity links, not a database mirror of GitHub data.

On the inline comment about how issue review rows are identified: this PR will rebuild on the generic Inbox item source refactor, so I'm leaving that code as is until then.

@sentry-junior
sentry-junior Bot requested a review from BYK November 23, 2026 20:51
BYK added a commit that referenced this pull request Nov 23, 2026
…e footer (#4132)

Stacked on #4128, which adds
`scripts/github-state-baseline.json`. This PR removes this table's entry
from that file.

`junior_github_issues` copies the state of Junior's issues from
webhooks. Nothing reads `state`, `state_reason`, `opened_at`, or
`closed_at`. The only reader is the close annotation, which fans out to
the row's `conversation_ids`. Those ids are also in the issue body
footer that Junior writes, and every `issues` webhook carries that body.

This drops the table. When a Junior-authored issue closes, the webhook
reads the Conversations from its footer and marks the issue closed in
each one that already holds a card for it.

Guard: a person can edit the footer, so the footer only picks the
candidates. The write needs the Conversation's own annotation for the
issue key in `junior_conversation_annotations`, which Junior adds when
it opens the issue. An edited footer cannot add a card to another
Conversation. The issue author must still be the bot.

#4100 reads this table for its reaction poll, so it
needs another source before it can merge.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Aa74cba793e2579695b0fbabff9e41a78)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aa74cba793e2579695b0fbabff9e41a78/?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]>
Co-authored-by: BYK <[email protected]>
BYK added a commit that referenced this pull request Nov 24, 2026
Closes #4123

No caller of the GitHub account ↔ Identity mapping calls GitHub. The
mapping already lives in `junior_identities`, which OAuth account
linking writes (`GET /user`, once). So caching it would save no GitHub
call, and lookups already work while GitHub is down. The real costs are
Postgres (Identity → User reads) and Slack (resolving a named person in
`findLinkedHandle`). This PR caches both in the state adapter. A miss
still reads Postgres and Slack as before.

**Identity → User.** `readIdentityByIdFromSql` reads through the
existing user cache in `chat/identities/user-cache.ts`. That covers
`loadGitHubLogin` in the GitHub webhooks, work owners, Inbox items, and
`readActorIdentity`. A new `identity:{id}` entry maps an Identity to its
User id. A linked Identity never moves to another User, so this entry
stays valid. The User entry is versioned and cleared on every Identity
write, as before. Unlink deletes the Identity, so the cached User no
longer has it, and the read falls back to SQL.

**`findLinkedHandle`.** A `found` result is cached by provider, team,
providers, and query, with stale-if-error. Other answers (`unlinked`,
`not_found`, `ambiguous`) are never cached, because they can change when
a person joins or links an account. A per-provider version clears every
cached handle of that provider. Each Identity write that changes a
lookup column (User, handle, or verified email) bumps the version, and
so does unlink. Writes that change none of these, such as the actor of
each message, do not bump it.

TTLs and stale window:
- Identity → User id: 24 h for a linked Identity, the same safety net as
the user cache. 60 s for an Identity without a User. A write that gives
an Identity a User clears that entry.
- User and their Identities: unchanged (24 h, cleared on write).
- Linked handle: fresh for 1 h. A link change clears it at once, so the
TTL bounds only Slack directory changes, such as a new person with the
same name. When Slack fails, the last found handle serves for up to 24 h
after the TTL.
- Reads in the first 10 s after a write do not fill either cache, as the
user cache already does.

`review_by` resolution in #4100
(`tool-support/issue-reviewers.ts`) should go through
`ctx.users.findLinkedHandle` when it rebuilds, so it gets this cache.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A0cb2154446e60476068694fc5d524147)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A0cb2154446e60476068694fc5d524147/?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]>
@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Replaced by #4308: GitHub assignees now drive the issue's Inbox item, so review_by and the reaction poll go away.

@sentry-junior sentry-junior Bot closed this Nov 25, 2026
BYK added a commit that referenced this pull request Nov 25, 2026
…4305)

When Junior hands a decision back to the requester in a pull request
comment, the requester gets no Inbox item, and the pull request leaves
Code · Mine. This happens in two ways.

**Inside a change request.** Only Junior's mark asks the requester to
review again (`pull-request-review-again.ts`). The event guidance said
to mark a comment only "after acting on actionable feedback or answering
a question". So a reply that pushed back, deferred, or left the decision
to the reviewer left the comment unmarked. Examples:
getsentry/devinfra-deployment-service#1019 (review body answered with a
disagreement, unmarked) and #4100 (inline comment
deferred to a later refactor, unmarked).

**Outside a change request**, such as a reply to a comment-only review.
A comment-only review ends GitHub's review request, so the next action
ends too. A question back to the requester then has no signal, and a
child agent cannot add an Inbox item.

## Changes

- `events/pull-request.ts`: the feedback guidance says to mark a comment
after Junior acts on it or replies to it, also when Junior pushes back,
defers, or answers with a question.
- `github_updatePullRequestFeedback`: the `status` param says what each
value means. "declined" covers push-back, deferral, and a decision left
to the author.
- `github_commentOnPullRequest`: new `asks_requester` param. When it is
true, the tool asks the person who asked Junior for the pull request for
a review on GitHub, and returns `requester_asked`. It asks only when
Junior opened the pull request for the person whose work the Turn does,
and that person has a linked GitHub account.
- `design/github.md`: a comment that Junior pushes back on or defers is
declined, and a question to the requester in a PR comment asks for their
review on GitHub.
- Evals in `pull-request-reviews.eval.ts`: a pushed-back change request
is marked declined, and a comment-only review is answered with
`asks_requester` only when the requester asked to decide.

## Design

The review request carries the signal, so `pull-request-action.ts` does
not change. GitHub's `review_requested` webhook already makes the next
action "review" when the requester has not acted since they were asked.
That shows the pull request's one `pull-request-action:` item, with the
pull request as its subject, assigned to the requester. GitHub also
notifies them. When they review, GitHub ends the request, and the item
closes. No new item stream, table, or state key.

A "reply" action from Junior's latest comment would not work, because
the derivation cannot tell whether a comment asks the requester
something. Every "Fixed in abc" reply would ask them.

Trade-offs:

- The item text is the general "GitHub asks you to review #N." A text
for a question needs a new reason in `pull-request-action.ts`, and that
file is in stack getsentry/junior#4307.
- A plain comment reply from the requester does not end GitHub's review
request, so the item stays until they review. Review requests from
GitHub already work this way.

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

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

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Aeb8917bd0ee6f1c48d0ea567d9aab5d9)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aeb8917bd0ee6f1c48d0ea567d9aab5d9/?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 — ea226f8a Deployed Nov 23, 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