Update pytorchbot comment to have a PR status section - #8664
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
e7ce42a to
3285df6
Compare
izaitsevfb
left a comment
There was a problem hiding this comment.
the approach is ok with me, but please take a look at the nits below
cce3bf9 to
61f01a8
Compare
izaitsevfb
left a comment
There was a problem hiding this comment.
please check the nits below
| const ASSIGNABLE_REVIEWER_ASSOCIATIONS = ["COLLABORATOR", "MEMBER", "OWNER"]; | ||
|
|
||
| /** | ||
| * The PR's approval verdict from its reviews: "" (nobody has decided), |
There was a problem hiding this comment.
test-infra/torchci/lib/reviewApproval.ts
Lines 144 to 160 in 2df0b6f
test-infra/torchci/lib/prStatus.ts
Lines 342 to 350 in 2df0b6f
not blocking, but something to be aware of.
🟡 Any org member who leaves one review comment is listed as an assigned reviewer who must agree, and cannot be taken off the list. (ai-generated section)
To recover reviewers GitHub drops from requested_reviewers once they review, fetchPrStatusState adds everyone returned by getReviewerLogins, which keeps any COLLABORATOR, MEMBER or OWNER review of any state. On pytorch/pytorch MEMBER covers every org member, so a drive-by inline comment makes that person one of the "assigned reviewers" the pre-review note says must agree. Review history is never removed, so once someone has reviewed, removing their review request does not take them off the list, although the handler subscribes to review_request_removed to keep the list current. Recovering reviewers from the timeline's review-request events would track actual assignment; failing that, the note could say "requested reviewers" and list only requested_reviewers.
Reviewed by codex gpt-6-astra + claude-fable-5 at high effort, against 2df0b6f.
There was a problem hiding this comment.
I think this is okay--if an org member takes the time to review a pre-review PR, that person likely is appropriate to react or prevent the PR from going forward
There was a problem hiding this comment.
The reason for this is because GitHub has requested_reviewers and requested_teams which exclude people who've already reviewed. So to approximate the reviewer box we union both (and subtract the PR author and anyone who is not COLLABORATOR, MEMBER, or OWNER)
| return; | ||
| } | ||
| } else if ( | ||
| payload.action === "review_requested" || |
There was a problem hiding this comment.
flagging this race. not sure how frequent that could happen in real world, but a re-check with re-try seems cheap enough?
🟡 A section built from labels read earlier can overwrite a newer one, and nothing may correct it for a long time. (ai-generated section)
The webhook path renders from the label list in the event payload (prStatusBot.ts line 41) and writes the whole comment body it read before its GitHub calls; the sweep reads labels live, then writes only after classifying that PR's CI. Nothing re-checks before writing. So if a bot swaps triaged for in progress and the unlabeled delivery finishes after the labeled one, or a label changes while the sweep is mid-PR, the older stage is what lands; the webhook write can likewise put back CI results a sweep just replaced. The description relies on the sweep for convergence, but the sweep only revisits PRs with workflow activity in the last 30 minutes or with pending jobs, so a PR waiting quietly for review keeps the wrong stage until its next label or review event. Re-reading the labels, and the comment, immediately before updateComment would narrow this a lot.
Reviewed by codex gpt-6-astra + claude-fable-5 at high effort, against 2df0b6f.
There was a problem hiding this comment.
Did a few things to narrow the race:
- during the webhook triggered update, make sure to get the latest comment at the latest time possible--right before write (which is the same thing as recheck essentially)
- fetch live labels in the sweep after finishing CI classification
This doesn't eliminate the race but make it less likely.
| `before the PR will be marked "in progress".` | ||
| ); | ||
| case "none": | ||
| return ""; |
There was a problem hiding this comment.
valid nit.
⚪ A triaged PR with no reviewer renders "All assigned reviewers () must agree". (ai-generated section)
formatReviewers returns an empty string for an empty list and the pre-review message interpolates it unchanged, which a test pins. At rollout this note goes onto the open pytorch/pytorch PRs that already carry triaged, and any of them without a requested reviewer shows the empty parentheses and an instruction nobody can act on. A separate sentence for the empty case, such as saying reviewers have not been assigned yet, would fix it.
Reviewed by codex gpt-6-astra + claude-fable-5 at high effort, against 2df0b6f.
There was a problem hiding this comment.
I did notice this, and this shouldn't really happen, and if it does happen it should be fixed elsewhere, so i think we're fine for this pr
9fe850b to
08cfdc4
Compare
Move the existing approval rules into a shared module and add unit coverage. Keep PytorchBotHandler's behavior unchanged.
Sort a copy of the review list instead of mutating caller input, and ignore reviews whose GitHub user is null.
6d48724 to
c21e17f
Compare
albanD
left a comment
There was a problem hiding this comment.
The message look good.
The logic sound fair, but I'm not really a TS expert.
Map workflow labels and approval state to contributor-facing guidance. Add helpers to extract and replace the section without changing the rest of the Dr.CI comment.
Use reviews to determine approval and recover reviewers who have already responded. For triaged PRs, combine them with current reviewer assignments. Return null if reviews cannot be fetched so callers preserve the existing section.
For pytorch/pytorch, render the section from live GitHub labels so lagging mirrored labels cannot overwrite newer state. Preserve the existing section when GitHub inputs cannot be fetched.
Update existing Dr.CI comments on label, review-request, and review events. Preserve the section during push updates and read the comment last to narrow races with the sweep.
b1ed2ee to
a0f5311
Compare
a0f5311 to
3eec7f3
Compare
Summary
Add a contributor-facing PR Status note at the top of the existing Dr.CI comment on
pytorch/pytorch.triaged,in progress, andready for reviewlabelsThis PR only reports the workflow state. It does NOT apply or transition lifecycle labels.
Contributor-facing text
See https://github.com/pytorch/test-infra/pull/8664/changes#diff-dd76dc7f6bcf9ce8104683b4598c5a5e03e019aec397acfa8f5199a328dd52e4R109
Precedence is approval,
ready for review,in progress, thentriaged, so transient overlap reports the furthest stage.Design and commit structure
We implemented this in stages so each commit does one thing:
Rollout note
As of 2026-09-22,
pytorch/pytorchhas roughly 1,708 open PRs carryingtriagedand none carrying either later-stage label. We therefore do not add the automation for 'triaged' yet but we do land the rest so that we can slowly test. We can phase in functionality for "triaged" later by reverting the seventh commit.Validation