Skip to content

[pr-review] Link each automated review and inline finding to the feedback form; say how to push back - #202436

Closed
izaitsevfb wants to merge 6 commits into
mainfrom
pr-review-report-link
Closed

izaitsevfb wants to merge 6 commits into
mainfrom
pr-review-report-link

Conversation

@izaitsevfb

@izaitsevfb izaitsevfb commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✴️ iz2: Every automated review gets a "Report a bad review" link, and each inline finding a "Report this finding" link. Both open the feedback form from pytorch/test-infra#9264 with the PR, reviewed commit and run filled in; the per-finding link also fills in the file and line. Reports land on the feedback board.

A change-request review's footer also tells the author how to push back: "Disagree with a finding? Reply with your reasoning, then comment @pytorchbot review to request a re-review." (a re-review reads the PR's comments, replies to findings included).

scripts/pr_review/post_review.py: report_url() builds the link with every value percent-encoded; the review footer and each inline comment carry it. run_url() links the attempt that posted the review (bare run link if the row has no attempt, nothing if it has no run id). Inline messages are posted unchanged, so a finding with an unclosed fence shows its link as text. The footer is appended after defuse_bot_commands runs on everything model-derived (and the link), so the hint's command survives; it sits mid-line, so it never matches pytorch-bot's ^ *@pytorch(merge|)bot .+$. Folding a superseded review defuses its hint like any other mention.

Merge pytorch/test-infra#9264 first: until the form exists, the links open a blank issue.

No ClickHouse query changes.

Test plan: python3 -m unittest discover -s scripts/pr_review -t . passes (534 tests), including cases for the review and inline links and their parsed prefill, the body fallback when GitHub refuses inline comments, the attempt link and its fallbacks, a hostile finding path staying inside the link, a closed code block in an inline finding posted unchanged, and the push-back hint appearing only on change requests, with no live bot command and no other mention under hostile input.

…back form

Adds a 'Report a bad review' link to the review body and a 'Report this finding'
link to each inline finding. Both open the pytorch/test-infra feedback form with
the PR, commit, run and (per finding) file and line filled in.
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 28, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

The PR adds a "Report a bad review" link to the automated review footer and a
"Report this finding" link to each inline finding, both opening the prefilled
pytorch/test-infra feedback form; the review found no issues. Recommendation:
Approve. The only open item is merge order: pytorch/test-infra# 9264 must merge
first, as the description already states.

Reviewed commit: 358b038 (NOT the current head 9129ad2)

Review run

🐛 Report a bad review

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202436

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 9129ad2 with merge base 1ad2a49 (image):

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • New feature, not a trivial class: report_url() and run_url() add feedback-form links to every review and inline comment in scripts/pr_review/post_review.py
    • Changes the shape of the bot's posted review footer and inline comment_body, which every PR author sees
  • Safety design
    • _compose now appends PUSH_BACK, containing a live @pytorchbot review mention, after defuse_bot_commands runs; a human should confirm this bypass
  • Socialization
    • Links depend on the ai-pr-review-feedback.yml form from pytorch/test-infra#​9264, which the PR body says must merge first
    • Comment says torchci/lib/prReview/prReviewReportLink.ts must stay in step, so changes here have to be coordinated across repos

reason: not_trivial
Reviewed commit: a5cdbb8 (NOT the current head 9129ad2)

Inference job

🐛 Report a wrong verdict

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Oct 28, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 28, 2026
github-actions[bot]

This comment was marked as outdated.

Inline messages are no longer fence-escaped: that broke every closed code
block to protect the report link from a rare unclosed one. The run link now
names the attempt that posted the review.
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of 358b038: nothing blocking; ready for human review.

The PR adds a "Report a bad review" link to the automated review footer and a "Report this finding" link to each inline finding, both opening the prefilled pytorch/test-infra feedback form; the review found no issues. Recommendation: Approve. The only open item is merge order: pytorch/test-infra# 9264 must merge first, as the description already states.

This review is AI-generated and advisory. Each new automated review replaces the previous one.

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Oct 28, 2026
@izaitsevfb izaitsevfb changed the title [pr-review] Link each automated review and inline finding to the feedback form [pr-review] Link each automated review and inline finding to the feedback form; say how to push back Nov 3, 2026
@jeanschmidt
jeanschmidt self-requested a review November 3, 2026 22:49

@jeanschmidt jeanschmidt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review summary

🟡 1 minor

  • 🟡 The module docstring's invariant "@​pytorchbot is escaped in all posted text" is now false: the push-back hint ships an undefused mention — scripts/pr_review/post_review.py:84
Extended analysis (ai-generated section)

What this changes

scripts/pr_review/post_review.py gains two feedback links and one hint. report_url builds a pre-filled pytorch/test-infra issue link — template, title, PR, commit, optionally the run and the finding's path:line — with every value passed through urllib.parse.urlencode; run_url turns the terminal row's review_run_id and review_run_attempt into an attempt-specific Actions link, degrading to the bare run link and then to "". The review footer carries "Report a bad review", each inline comment appends a <sub>[Report this finding]​(...)</sub> line, and the link threads through run → publish → post → review_body / comment_body. A change-request footer additionally gains PUSH_BACK, a sentence telling the author to reply and comment `@​pytorchbot review` for a re-review. The test file adds two classes covering the links, the attempt fallbacks, the body fallback path, a hostile path, and the hint's verdict gating.

What it gets right

The percent-encoding decision is the right one and is pinned by a test that feeds a path containing )[x]​(https​://evil.example), @​pytorchbot merge, and <b> and asserts the resulting URL contains none of ()\s<>[]@. run_url validates with type(value) is int and value > 0, which rejects True as well as "2" and 0 — and the test enumerates exactly those cases. comment_body appends the link outside contained() with a comment explaining the trade: wrapping would break every closed fence to rescue the rare unclosed one. The body-size loop in review_body threads report into _compose so the link is counted against MAX_BODY rather than pushing past it after trimming.

Where the risk is

Both findings land on the same four lines: the PUSH_BACK constant at post_review.py:82-85 and the footer splice at post_review.py:437-440. They are separate clusters and separate defects, but one edit to that region settles both. The deeper one is documentary: the module docstring's invariant at post_review.py:27-28 still says @​pytorchbot is escaped in all posted text, while _compose now defuses the joined body and the report link and then interpolates an undefused mention after them. The posted text is inert today — the mention is backticked and mid-line, so pytorch-bot's anchored ^ *@​pytorch(merge|)bot .+$ cannot match — but the checkable rule "defusing runs last" no longer holds, and the test that enforced it was narrowed to strip PUSH_BACK before asserting. The second is the invisible trailing space inside PUSH_BACK doing the work of a separator at the join site, with no test pinning it. They compound in the same direction: the safety of this footer now rests on properties of a string literal that nothing in the file's stated invariants or its tests records.

Before merge, and after

Amending the invariant block in scripts/pr_review/post_review.py to name the push-back exception and the two conditions it rests on — backticked and mid-line — is a few lines and belongs with this change, since the live command text is the point of the change and a maintainer reflowing the footer later has no other warning. Moving the separator out of the PUSH_BACK constant and into _compose is the same edit's neighbourhood; it costs one line and both existing tests keep passing. The description's note that pytorch/test-infra#​9264 must merge first is a real ordering constraint, not a code issue.

Comment thread scripts/pr_review/post_review.py Outdated
# A re-review reads the PR's comments, replies to earlier findings included.
PUSH_BACK = (
"Disagree with a finding? Reply with your reasoning, then comment "
"`@pytorchbot review` to request a re-review. "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 The module docstring's invariant "`@​pytorchbot` is escaped in all posted text" is now false: the push-back hint ships an undefused mention (ai-generated section)

PUSH_BACK (scripts/pr_review/post_review.py:82-85) carries a literal @​pytorchbot review, and _compose splices it into the footer after defuse_bot_commands has run: line 434 defuses only "\n".join(lines) and report_link, then lines 437-440 interpolate push_back into the returned string. So defuse_bot_commands is no longer the last operation on a posted body, and every changes_requested review now carries an unescaped bot mention — but the file's "Invariants:" block at post_review.py:27-28 still states the escaping unconditionally, and the comment at post_review.py:66-68 still gives the opposite rationale ("defusing a harmless mention costs nothing and missing a live one runs a command"). The exception and the reasoning that makes it safe exist only in the local comment at post_review.py:435-436, some 350 lines below the invariant. post_review.py:27-28 reads "- @​pytorchbot is escaped in all posted text, because pytorch-bot reads commands from review bodies." and is untouched by this change. post_review.py:434 is body, report_link = map(defuse_bot_commands, ("\n".join(lines), report_link)); post_review.py:437-440 then returns f"{body}\n<sub>{push_back}This review is AI-generated and advisory. ...", and post passes that straight to gh.request, so the mention never reaches _BOT_MENTION (post_review.py:69). The only later defusing is in folded (post_review.py:679), which runs after the review has already been live. The test contract was narrowed to match: test_post_review.py:1601-1604 now strips post_review.PUSH_BACK from the body before asserting assertNotRegex(text, r"(?i)@​pytorch(merge)?bot"), and the property that still holds — no line matching ^ *@​pytorch(merge|)bot .+$ — is the weaker one asserted at test_post_review.py:602. .github/workflows/hardened-pr-review-run.yml:1181 points maintainers at this docstring ("See the docstring of post_review.py"). The posted text is inert today — the mention sits mid-line inside <sub> and is backticked, so pytorch-bot's anchored pattern cannot match it — but the single checkable choke point ("everything posted goes through defuse_bot_commands last") is gone and the file's authoritative summary of its safety properties does not say so. A maintainer who later reflows or moves the footer, puts the hint on its own line without the backticks, or reuses PUSH_BACK elsewhere will read the invariant list and not realise that only placement and backticks keep @​pytorchbot review from executing on every automated change request. Amend the invariant at post_review.py:27-28 to state the exception and the condition it rests on, e.g. "- @​pytorchbot is escaped in all posted text, with one exception: the push-back hint in a change request's footer, which is deliberately live and must stay mid-line and backticked so it cannot match pytorch-bot's ^ *@​pytorch(merge|)bot .+$."; the comment at post_review.py:435-436 is then the detail behind it. The narrower alternative restores the invariant unchanged: drop the command text from PUSH_BACK (post_review.py:82-85) and point at the documented bot commands instead ("comment the review bot command"). I would take the docstring amendment, since the live command text is the point of the change and the structural guard is already pinned by the test at test_post_review.py:602.

Reviewed by claude-opus-5[1m] at max effort, against a5cdbb8.

Jean Schmidt's review: the docstring's escaping invariant no longer held
once the change-request footer carries a live `@pytorchbot review`. State
the exception and the two conditions it rests on, and move the separator
out of the PUSH_BACK constant into the splice. Posted text is unchanged.
@pytorchgreenlight pytorchgreenlight Bot added GL/superseded GreenLight review is superseded by changes and removed GL/human GreenLight marked as needing human review labels Nov 3, 2026
izaitsevfb added a commit to pytorch/test-infra that referenced this pull request Nov 4, 2026
…ction (#9264)

✴️ iz2: Gives people a one-click way to report a bad automated PR
review, landing on the [feedback
board](https://github.com/orgs/pytorch/projects/181).

- `.github/ISSUE_TEMPLATE/ai-pr-review-feedback.yml`: an issue form (PR,
commit, run, finding, what went wrong, details). Its `labels:` applies
`AI PR review: feedback`, which auto-adds the issue to the board; form
labels apply for any reporter, outside contributors included. This is
test-infra's first issue template, so "New issue" now shows a chooser
with it next to the blank issue.
- Dr.CI's AUTOMATED REVIEW section links each verdict to the form with
the PR, commit and run prefilled (query params named after the form's
field ids). No link while a review is running or when it produced no
verdict.

The links in the GitHub review and on each inline finding are
pytorch/pytorch#202436, which should merge after this; both build the
same URL, and the form's field ids are part of it.

No ClickHouse query changes.

Test plan: new cases in `torchci/test/prReviewRender.test.ts` (link
present for both verdicts with the prefill parsed back, absent for
started/too-large/failed rows, bad repo/PR gives no link, bad commit/run
id is left out, URL carries no markdown delimiters). torchci gates
(lint, prettier, tsc, jest) pass locally.
@izaitsevfb

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 4, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / macos-py3-arm64 / test (default, 1, 3, macos-m1-stable)

Details for Dev Infra team

Raised by workflow job

@izaitsevfb

Copy link
Copy Markdown
Contributor Author

✴️ iz2: retrying the merge; Dr.CI now classifies the macOS MPS failure as flaky.

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…back form; say how to push back (pytorch#202436)

✴️ iz2: Every automated review gets a "Report a bad review" link, and each inline finding a "Report this finding" link. Both open the feedback form from pytorch/test-infra#9264 with the PR, reviewed commit and run filled in; the per-finding link also fills in the file and line. Reports land on the [feedback board](https://github.com/orgs/pytorch/projects/181).

A change-request review's footer also tells the author how to push back: "Disagree with a finding? Reply with your reasoning, then comment `@pytorchbot review` to request a re-review." (a re-review reads the PR's comments, replies to findings included).

`scripts/pr_review/post_review.py`: `report_url()` builds the link with every value percent-encoded; the review footer and each inline comment carry it. `run_url()` links the attempt that posted the review (bare run link if the row has no attempt, nothing if it has no run id). Inline messages are posted unchanged, so a finding with an unclosed fence shows its link as text. The footer is appended after `defuse_bot_commands` runs on everything model-derived (and the link), so the hint's command survives; it sits mid-line, so it never matches pytorch-bot's `^ *@pytorch(merge|)bot .+$`. Folding a superseded review defuses its hint like any other mention.

Merge pytorch/test-infra#9264 first: until the form exists, the links open a blank issue.

No ClickHouse query changes.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes (534 tests), including cases for the review and inline links and their parsed prefill, the body fallback when GitHub refuses inline comments, the attempt link and its fallbacks, a hostile finding path staying inside the link, a closed code block in an inline finding posted unchanged, and the push-back hint appearing only on change requests, with no live bot command and no other mention under hostile input.
Pull Request resolved: pytorch#202436
Approved by: https://github.com/jeanschmidt
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…back form; say how to push back (pytorch#202436)

✴️ iz2: Every automated review gets a "Report a bad review" link, and each inline finding a "Report this finding" link. Both open the feedback form from pytorch/test-infra#9264 with the PR, reviewed commit and run filled in; the per-finding link also fills in the file and line. Reports land on the [feedback board](https://github.com/orgs/pytorch/projects/181).

A change-request review's footer also tells the author how to push back: "Disagree with a finding? Reply with your reasoning, then comment `@pytorchbot review` to request a re-review." (a re-review reads the PR's comments, replies to findings included).

`scripts/pr_review/post_review.py`: `report_url()` builds the link with every value percent-encoded; the review footer and each inline comment carry it. `run_url()` links the attempt that posted the review (bare run link if the row has no attempt, nothing if it has no run id). Inline messages are posted unchanged, so a finding with an unclosed fence shows its link as text. The footer is appended after `defuse_bot_commands` runs on everything model-derived (and the link), so the hint's command survives; it sits mid-line, so it never matches pytorch-bot's `^ *@pytorch(merge|)bot .+$`. Folding a superseded review defuses its hint like any other mention.

Merge pytorch/test-infra#9264 first: until the form exists, the links open a blank issue.

No ClickHouse query changes.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes (534 tests), including cases for the review and inline links and their parsed prefill, the body fallback when GitHub refuses inline comments, the attempt link and its fallbacks, a hostile finding path staying inside the link, a closed code block in an inline finding posted unchanged, and the push-back hint appearing only on change requests, with no live bot command and no other mention under hostile input.
Pull Request resolved: pytorch#202436
Approved by: https://github.com/jeanschmidt
pytorchmergebot pushed a commit that referenced this pull request Nov 10, 2026
…till on the way (#203462)

✴️ iz2: opened for @izaitsevfb, who asked for this change.

A merge fails on the first loop iteration that sees a failed job outside Dr.CI's ignorable categories, even when Dr.CI is about to classify it:

- #202436 failed 41 s after its macOS job did. Dr.CI's live answer didn't list the job in any category yet, and Dr.CI later classed it as flaky.
- #203136 failed while the AI CI Advisor verdict that later cleared the job was still running.

With this change, `merge()` counts a failed GitHub Actions job as pending, for up to 15 minutes per job, while either:
- Dr.CI's live answer lists the job in no category (Dr.CI reads jobs from a database that lags GitHub), or
- Dr.CI lists it under `AI_PENDING` (pytorch/test-infra#9332): a verdict that may clear it is on the way.

As soon as the job is classified, or after 15 minutes, it is handled as today. Waiting clears nothing; only Dr.CI's existing categories do. Check names in the merge record are unchanged. For the PR being merged, and for a stacked PR's mandatory checks, the retry and reject messages say a job is waiting on its classification, and a failure message says when the merge waited on a job that still blocks it. A stacked PR's other failed or pending jobs keep today's messages.

Scope:
- Only plain `FAILURE` conclusions of GitHub Actions jobs. App check runs such as EasyCLA never wait.
- Only a non-empty live Dr.CI answer starts a wait. The check-run summary fallback never does. An empty answer doesn't either, because Dr.CI also answers `{}` for a repo it has no data for. Once open, a wait survives a failed or empty Dr.CI call until its 15 minutes run out.
- Only `merge()`, including the lower PRs of ghstack and native stacks. Other callers of `get_classifications` / `find_matching_merge_rule` pass no window and skip the wait logic entirely.
- `merge_into` now runs a ghstack stack's lower-PR rule checks before the GreenLight check, as it already did for native stacks. Whether a lower PR's human approvals suffice without GreenLight's can depend on its CI, and that answer is cached for the merge, so it is asked only once the PR's own checks pass; a waiting job retries first. Lower ghstack PRs are now checked against the clone's rules file before it is reset to trunk, as the top PR already was.

Cost: a merge whose failure is real reports later if Dr.CI hasn't listed the job or its verdict comes back `related`: at most about 20 minutes, since the 15-minute budget is checked on 5-minute retries. Usually that is one or two retries, since the advisor's p95 is 6 minutes from dispatch.

Known limits:
- The unlisted check matches Dr.CI's answer by job id. When trymerge holds a different run's id for a job than Dr.CI lists (a newer run dropped the job, or an older run's entry overwrote the newer one), that failure, which blocks today, reports 15 minutes late.

Test plan: `python -m unittest test_trymerge`, with new `TestClassificationWait` tests: the matchers (including a malformed `AI_PENDING` list and checks that are not Actions jobs), precedence over arrived classifications and `-i`, the real `find_matching_merge_rule` with a waiting and an expired mandatory job, a wait surviving a failed Dr.CI call, one window shared by a stack, and `merge()` (on a clock its sleeps advance) looping until the job is classified or the budget runs out, with the failure note only for jobs it slept on, plus a test that a waiting lower ghstack PR retries before the GreenLight check is asked. Removing any window hand-off, wait condition, waiting reason or expiry note fails a test. The full suite passes (274 tests).
Pull Request resolved: #203462
Approved by: https://github.com/jeanschmidt, https://github.com/huydhn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request GL/superseded GreenLight review is superseded by changes Merged ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants