Skip to content

[pr-review] Anchor findings on a deleted file's removed lines - #202456

Closed
izaitsevfb wants to merge 8 commits into
mainfrom
iz2/pr-review-anchor-deleted-files
Closed

izaitsevfb wants to merge 8 commits into
mainfrom
iz2/pr-review-anchor-deleted-files

Conversation

@izaitsevfb

@izaitsevfb izaitsevfb commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✴️ iz2: A PR that only deletes files has no new-side line, so the sanitizer discarded every finding and refused any blocking review. #202328 (removes three workflows) was rejected on all 4 automated runs and never got a review.

  • extract_verdict.parse_diff records a deleted file's removed lines, numbered as in the deleted file. Each finding must still point at a line the diff touches. A type change, where the path still exists, keeps only its new side.
  • post_review lists the PR's files and posts findings on removed files on the diff's LEFT side. In the review body they link to the diff line, since the file has no blob at the head. It matches earlier discussions on the same side only.
  • The Stage B prompt says how to number lines in a deleted file, and no longer lists a deletion among files with no anchorable line (added by [pr-review] Stage B: a defect that must be fixed means changes requested #202455).

Known limits: the review row's findings carry no side, so a deleted file's line is its pre-deletion number (noted in emit_row.py; Dr.CI shows path:line as plain text). If the file list can't be read or GitHub disagrees with git on a rename, the comment goes RIGHT, GitHub refuses the review's inline comments, and all of them land in the body.

This complements #202455, which covers findings on renamed-only files in PRs that change other files. Part of pytorch/test-infra#9260.

No ClickHouse query changes.

Test plan: python3 -m unittest discover -s scripts/pr_review -t . passes. The new tests fail against main.

A PR that only deletes files had no line a finding could anchor on, so the
sanitizer refused every blocking review of it. parse_diff now records a
deleted file's removed lines, and post_review posts findings on removed
files on the diff's left side.
@izaitsevfb
izaitsevfb requested a review from a team as a code owner October 28, 2026 22:05
@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 lets findings on files the PR deletes reach the review: parse_diff
records a deleted file's removed lines, and post_review posts those findings on
the diff's LEFT side. The review found no issues at HEAD, and the earlier
non-blocking findings are resolved or accepted. Recommendation: Approve.

Reviewed commit: c70c22e (NOT the current head 04d98a9)

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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

✅ No Failures

As of commit 04d98a9 with merge base 609ff97 (image):
💚 Looks good so far! There are no failures yet. 💚

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

  • Never trivial: CI review trust boundary
    • Edits the Stage B prompt in .github/workflows/hardened-pr-review-run.yml, which steers a model reading untrusted PR content
    • parse_diff in scripts/pr_review/extract_verdict.py is the anchoring guard against forged diff headers; new deletion and type-change state is added to it
  • Triviality
    • New behavior across parser and publisher: deleted-file anchors, with_removed file listing, and LEFT-side posting in post_review.py
    • Fits no trivial class; a single-cause fix that also changes what findings can block a PR is a design call for a human
  • Open maintainer concern
    • huydhn notes the merged prompt would contradict #​202455, which lists a deletion as unanchorable, and asks this PR to adjust that list and its test

reason: not_trivial
Reviewed commit: c70c22e (NOT the current head 04d98a9)

Inference job

🐛 Report a wrong verdict

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

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 28, 2026
@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.

…ed paths

with_removed re-raises OutOfTime like the other GitHub calls, and a test
covers a deleted path that neutralize_path escapes. (--no-verify: the only
lint failure is the pre-existing CODEOWNERS taxonomy error on main.)
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed stale reviews from themself October 28, 2026 22:57

Withdrawn: the automated review of bd0d370 found nothing blocking.

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 c70c22e: nothing blocking; ready for human review.

The PR lets findings on files the PR deletes reach the review: parse_diff records a deleted file's removed lines, and post_review posts those findings on the diff's LEFT side. The review found no issues at HEAD, and the earlier non-blocking findings are resolved or accepted. Recommendation: Approve.

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 29, 2026
@huydhn

huydhn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Heads-up for when this and #202455 both land: the merged Stage B prompt contradicts itself. #202455 lists "a deletion" among files with no anchorable line ("anchor it to the most relevant changed line"), while this PR says a deleted file's line is its number in the deleted file. The model would likely move deleted-file findings onto other files' lines, which undoes this PR's anchors. A trial merge applies cleanly, so nothing flags it, and #202455's test requires "deletion" in that list.

Since #202455 is the older one, could this PR drop "a deletion" from that list and from test_the_prompt_names_every_file_kind_that_cannot_anchor?

(Comment drafted by Claude Code on behalf of the reviewer.)

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

Stamped! Plz address the conflict from #202455 before merging

#202455 listed a deletion among files with no line to anchor on; this PR
anchors deleted files on their old lines, so the list now says a file with
no added, removed or context line.
@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

Copy link
Copy Markdown
Contributor Author

✴️ iz2: merging at Ivan's request.
@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 3, 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

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@izaitsevfb

Copy link
Copy Markdown
Contributor Author

✴️ iz2: re-issuing the merge at Ivan's request; the previous merge job hit the 6-hour limit while waiting on macOS shards, which are now green.
@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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Command git -C /home/runner/work/pytorch/pytorch merge --squash __pull-request-202456__init__ returned non-zero exit code 1

Auto-merging .github/workflows/hardened-pr-review-run.yml
Auto-merging scripts/pr_review/extract_verdict.py
Auto-merging scripts/pr_review/post_review.py
CONFLICT (content): Merge conflict in scripts/pr_review/post_review.py
Auto-merging scripts/pr_review/test_extract_verdict.py
Auto-merging scripts/pr_review/test_post_review.py
Auto-merging scripts/pr_review/test_workflow_contract.py
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.
Details for Dev Infra team

Raised by workflow job

…deleted-files

# Conflicts:
#	scripts/pr_review/post_review.py
@izaitsevfb

Copy link
Copy Markdown
Contributor Author

✴️ iz2: merging at Ivan's request after resolving the conflict with #202436.
@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
…h#202456)

✴️ iz2: A PR that only deletes files has no new-side line, so the sanitizer discarded every finding and refused any blocking review. pytorch#202328 (removes three workflows) was rejected on all 4 automated runs and never got a review.

- `extract_verdict.parse_diff` records a deleted file's removed lines, numbered as in the deleted file. Each finding must still point at a line the diff touches. A type change, where the path still exists, keeps only its new side.
- `post_review` lists the PR's files and posts findings on `removed` files on the diff's LEFT side. In the review body they link to the diff line, since the file has no blob at the head. It matches earlier discussions on the same side only.
- The Stage B prompt says how to number lines in a deleted file, and no longer lists a deletion among files with no anchorable line (added by pytorch#202455).

Known limits: the review row's findings carry no side, so a deleted file's `line` is its pre-deletion number (noted in `emit_row.py`; Dr.CI shows `path:line` as plain text). If the file list can't be read or GitHub disagrees with git on a rename, the comment goes RIGHT, GitHub refuses the review's inline comments, and all of them land in the body.

This complements pytorch#202455, which covers findings on renamed-only files in PRs that change other files. Part of pytorch/test-infra#9260.

No ClickHouse query changes.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes. The new tests fail against main.
Pull Request resolved: pytorch#202456
Approved by: https://github.com/huydhn
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…h#202456)

✴️ iz2: A PR that only deletes files has no new-side line, so the sanitizer discarded every finding and refused any blocking review. pytorch#202328 (removes three workflows) was rejected on all 4 automated runs and never got a review.

- `extract_verdict.parse_diff` records a deleted file's removed lines, numbered as in the deleted file. Each finding must still point at a line the diff touches. A type change, where the path still exists, keeps only its new side.
- `post_review` lists the PR's files and posts findings on `removed` files on the diff's LEFT side. In the review body they link to the diff line, since the file has no blob at the head. It matches earlier discussions on the same side only.
- The Stage B prompt says how to number lines in a deleted file, and no longer lists a deletion among files with no anchorable line (added by pytorch#202455).

Known limits: the review row's findings carry no side, so a deleted file's `line` is its pre-deletion number (noted in `emit_row.py`; Dr.CI shows `path:line` as plain text). If the file list can't be read or GitHub disagrees with git on a rename, the comment goes RIGHT, GitHub refuses the review's inline comments, and all of them land in the body.

This complements pytorch#202455, which covers findings on renamed-only files in PRs that change other files. Part of pytorch/test-infra#9260.

No ClickHouse query changes.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes. The new tests fail against main.
Pull Request resolved: pytorch#202456
Approved by: 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