Repository navigation
Conversation
Large stacks, which AI tools make easy to produce, can use up shared CI resources and block other contributors. Add a strong suggestion to keep stacks under 10 PRs, point to the ghstack-ci skill for deferring CI with [no-ci], and state that we may stop running CI on large stacks to protect the infrastructure, as already done in pytorch#185290. Test Plan: docs-only change. ``` lintrunner -a AI_POLICY.md ``` This PR was authored with the help of an AI assistant (Claude Code).
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". 🟡 AUTOMATED REVIEW - Changes requested:
Findings (17): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202800
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit e8b791f with merge base 68c8684 ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ast that Make the stack-size rule in AI_POLICY.md a requirement, and have the hardened PR review enforce it: a PR 10th or higher from the bottom of its ghstack gets changes requested. The check is deterministic, in extract_verdict.py, not left to the model. It reads the ghstack list in the PR body from /tmp/pr-comments.json (already written by the job, read-only to the model) with the same pattern filter_test_configs.py uses to skip CI. It prepends a fixed sentence to the summary and adds one major finding on the first changed line, so the model's minor findings stay non-blocking. Failed reviews and unreadable PR bodies are left unchanged.
|
@claude Review this change |
|
Claude finished @huydhn's task in 1m 31s —— View job This is an AI-generated review (Claude Code). I recommend Request Changes: one sentence in AI-generated review detailsPR Review: #202800SummaryThe PR adds a rule to Code Quality
RecommendationRequest Changes What blocks approval: the threshold sentence and the open |
- ghstack_position counts only the stack entries directly below the PR's __->__ line, so a "* #N" bullet elsewhere in the body is not counted. - AI_POLICY.md: CI skips PRs with 10 or more PRs underneath them (>= 10), [no-ci] is a title prefix (commit subject with ghstack), and link the CONTRIBUTING.md section. - Format the new tests (PYFMT).
|
@pytorchbot review |
|
The automated review only re-runs on PRs labeled |
Prepending the policy finding and slicing to MAX_FINDINGS dropped the model's last finding when it already had MAX_FINDINGS, whatever its severity, so a major listed last disappeared without being counted. Model findings are now sorted majors first before the policy finding is prepended, and the drop is added to findings_dropped. The bot message now says to rebase before submitting the stack again, matching CONTRIBUTING.md and CI's own message. Also drop the CONTRIBUTING.md path trigger from pr-review-scripts-test.yml rather than pinning it in the contract test: the limit test still runs on every scripts/pr_review change. Test Plan: ``` python3 -m unittest discover -s scripts/pr_review -t . ``` The cap test now has 24 minor findings and a major last; the major is kept and findings_dropped is 1. The same 6 macOS-only failures (sha256sum, BSD realpath) appear with and without this change. Authored with Claude Code.
|
@pytorchbot review |
test_extract_verdict.py reads the stack-size limit from CONTRIBUTING.md, so an edit to the limit alone has to run the suite: the path trigger is back in pr-review-scripts-test.yml, now pinned in REQUIRED_PATHS. ghstack_position splits the PR body on "\n" only, as CI's re.MULTILINE does; splitlines() also breaks on characters like \x0b and . The comments on the entry pattern and the findings cap now say what the code does: CI fails rather than skips and counts every entry after the marker, and the cap drops a minor finding only when one exists. Test Plan: ``` python3 -m unittest discover -s scripts/pr_review -t . ``` Removing the CONTRIBUTING.md trigger fails test_push_to_main_triggers_it_for_the_same_paths. The same 6 macOS-only failures (sha256sum, BSD realpath) appear with and without this change. Authored with Claude Code.
|
On the findings cap with 25 major findings (review of 144ecd3): corrected the comment in 80360a3 and kept the behavior. With 25 majors the PR is blocked either way, 24 of the model's majors are still posted, and the drop is counted in Drafted with Claude Code. |
When the policy finding pushes the findings over MAX_FINDINGS, the drop is now recorded in dropped_detail as an over_cap record, the same way sanitize_findings records its own cap drops, and the comment says which finding goes: the model's last non-major if there is one. The review's ghstack parser copies CI's entry pattern and marker, so a new test pins them, and CI's threshold that CONTRIBUTING.md states, to the exact lines in .github/scripts/filter_test_configs.py. That file is now a path trigger for the suite and is pinned in REQUIRED_PATHS. The counting still differs on purpose: CI counts every matching line after the marker, the review only the stack list. CONTRIBUTING.md now says CI's check applies from the 11th PR up (the review from the 10th), that adding ciflow/trunk needs a rerun of the failed workflows, and that CI counts any line that is only `* #N` after the current PR, so other PR references should not be written that way in the PR body. Test Plan: ``` python3 -m unittest discover -s scripts/pr_review -t . ``` Mutations checked by hand: changing CI's threshold to 100, dropping re.MULTILINE from CI's regex, discarding the drops build() recorded, or not returning dropped_detail each fail a test. The same 6 macOS-only failures (sha256sum, BSD realpath) appear with and without this change. Authored with Claude Code.
There was a problem hiding this comment.
Automated review of e2a100b: changes requested before human review.
The PR adds a "Keep PR stacks small" rule (fewer than 10 PRs) to CONTRIBUTING.md, links it from CLAUDE.md, and has extract_verdict.py request changes on any PR 10th or higher in its ghstack. The policy's verdict is correct, but the review recommends Request Changes because of a lossy summary cut, a policy finding anchored on unchanged lines, silent failure modes, a severity rule copied from post_review, stale docs, and tests that cannot catch regressions.
🔴 9 blocking findings are attached to the code below.
pytorch/scripts/pr_review/extract_verdict.py
Line 1039 in e2a100b
🔴 The severity promotion copies post_review.blocking_findings and overwrites the model's severities. The "no major -> everything blocks" rule is restated from post_review.py:263-268 in a comment; no test runs blocking_findings on apply_stack_policy output, so a change to that rule breaks this silently. The promotion also writes the model's minor/info severities as major into verdict.json; the policy finding's fixed message identifies the override but not which findings were originally non-major. Keep the original severity (or add a flag), and add a test pinning against blocking_findings.
An earlier comment near this line has replies: #202800 (comment)
⚪ 7 non-blocking findings
pytorch/scripts/pr_review/extract_verdict.py
Line 1046 in e2a100b
The sort comment is misleading. It says "At the cap, one finding makes room...", but findings.sort(...) runs at every length, so below the cap it also reorders a mixed list majors-first in verdict.json. Move the sort under the over-cap condition or reword the comment.
pytorch/scripts/pr_review/extract_verdict.py
Line 1205 in e2a100b
apply_stack_policy's output skips the final re-check build() runs on what it writes. build()'s comment says the final check_value_charset/check_value_blobs "is what makes the module's advertised invariants true of the artifact", but main now writes a dict that has not been through that check. Today every new string is checked individually, so this is not a hole, but it is a gap in the egress boundary. Run the two checks on apply_stack_policy's result, or apply the policy inside build() before the re-check.
Line 666 in e2a100b
The PR description's human-written summary still contradicts the change. It says "Propose that agent keeps its stack size under 10", but CONTRIBUTING.md:666-667 (as albanD asked) applies the rule to every contributor. The description becomes the commit message; update it.
pytorch/scripts/pr_review/test_extract_verdict.py
Line 1666 in e2a100b
Nothing ties load_pr_body's "body" key to the fetch script. load_pr_body (extract_verdict.py:1078) reads the key that fetch_pr_comments.py:241 writes. If that key is renamed, the policy silently turns off and every test still passes, because the end-to-end tests hand-write {"body": ...}. Feed fetch_pr_comments.collect() output into one test, or pin the key across the two modules.
pytorch/scripts/pr_review/test_extract_verdict.py
Line 1507 in e2a100b
The CI pin test checks text, not behavior. It matches three exact lines of .github/scripts/filter_test_configs.py and hard-codes 10 instead of deriving it from STACK_POSITION_LIMIT. It still passes if CI changes >= to > (filter_test_configs.py:747) or changes get_ghstack_below_count's counting. Nothing pins the CONTRIBUTING.md:676-679 sentences ("10th or higher", "10 or more PRs below it (11th or higher from the bottom)") that the inline comment says must track it; test_the_limit_matches_contributing_md only reads "fewer than N PRs".
pytorch/scripts/pr_review/extract_verdict.py
Line 1010 in e2a100b
One ghstack_position branch is untested: the final return 0 is never reached in tests. It needs __->__ in the body with no line that is a full entry, e.g. * __->__ \# 123 (wip). test_a_plain_body_is_not_in_a_stack only hits the early exit.
pytorch/scripts/pr_review/test_extract_verdict.py
Line 1633 in e2a100b
The end-to-end helper is duplicated: TestTheStackPolicyEndToEnd.run_script copies TestEndToEnd.run_script (637-659) and only adds --pr-comments-file. Give the existing helper an optional comments=None argument instead.
Please address the findings and push; a new commit normally gets a fresh automated review.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
Keep only what the policy needs. CONTRIBUTING.md states the rule, why it exists, and the two checks in two short paragraphs. extract_verdict.py keeps ghstack_position, apply_stack_policy and the --pr-comments-file input, plus the two guards that stop the bot from publishing something wrong: a model objection without a major finding stays blocking, and a diff with no line to anchor the policy finding is left unchanged. The majors-first sort and dropped_detail recording at the cap, the CI-constant and CONTRIBUTING.md pin tests, and their path triggers are removed. Test Plan: ``` python3 -m unittest discover -s scripts/pr_review -t . ``` The same 6 macOS-only failures (sha256sum, BSD realpath) appear with and without this change. Authored with Claude Code.
|
After trying my best to address review comments on my recent PR #202800. I have a feeling that trying to chase after these reviews only make sense up to a certain point. Beyond that, doing that actually detrimental to the quality of the PR, introducing bloat code, and pretty much not a minimal change that I ask for in the first place.
I'll opt-out this PR for the time being. |
albanD
left a comment
There was a problem hiding this comment.
SGTM !
And yes checking online for a bit sound ok. But I would limit it in time as I don't expect this happens very often. So if there is none next week, let's just do it!
|
@pytorchbot merge -f 'Policy change, no need to run trunk' |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
## Summary (human written only) Propose that agent keeps its stack size under 10 and highlight the tradeoff of having a large stack ## Agent details (if applicable) > **CONTRIBUTING.md** gets a short "Keep PR stacks small" section: stacks of PRs must have fewer than 10 PRs, because every PR in a stack runs CI on each push; land the bottom first and use `[no-ci]` on PRs that don't need CI yet. For ghstack stacks, the automated review requests changes from the 10th PR up, and CI fails with 10 or more PRs below unless the PR has `ciflow/trunk` (pytorch#185290). `CLAUDE.md` (`AGENTS.md`) links to it from the ghstack rules. > > **Hardened PR review** enforces it in `scripts/pr_review/extract_verdict.py`, deterministically rather than by the model. It reads the ghstack list from the PR body in `/tmp/pr-comments.json` (already written by the job; `hardened-pr-review-run.yml` passes `--pr-comments-file`), counting only the entries directly below the PR's `__->__` line. From the 10th PR up, the verdict becomes `changes_requested`, with a fixed sentence at the start of the summary and as one `major` finding. Two guards keep the output valid: a model objection without a major finding has its findings promoted to major so they stay blocking, and a diff with no line to anchor the finding on is left unchanged. Failed reviews and unreadable PR bodies are also left unchanged. > > Testing: 20 new tests (19 in `test_extract_verdict.py`, 1 workflow contract test pinning the flag); `python3 -m unittest discover -s scripts/pr_review -t .` shows the same 6 pre-existing macOS-only failures (`sha256sum`, BSD `realpath`) with and without this change. > > Drafted with Claude Code. Pull Request resolved: pytorch#202800 Approved by: https://github.com/jeanschmidt, https://github.com/albanD
## Summary (human written only) Propose that agent keeps its stack size under 10 and highlight the tradeoff of having a large stack ## Agent details (if applicable) > **CONTRIBUTING.md** gets a short "Keep PR stacks small" section: stacks of PRs must have fewer than 10 PRs, because every PR in a stack runs CI on each push; land the bottom first and use `[no-ci]` on PRs that don't need CI yet. For ghstack stacks, the automated review requests changes from the 10th PR up, and CI fails with 10 or more PRs below unless the PR has `ciflow/trunk` (pytorch#185290). `CLAUDE.md` (`AGENTS.md`) links to it from the ghstack rules. > > **Hardened PR review** enforces it in `scripts/pr_review/extract_verdict.py`, deterministically rather than by the model. It reads the ghstack list from the PR body in `/tmp/pr-comments.json` (already written by the job; `hardened-pr-review-run.yml` passes `--pr-comments-file`), counting only the entries directly below the PR's `__->__` line. From the 10th PR up, the verdict becomes `changes_requested`, with a fixed sentence at the start of the summary and as one `major` finding. Two guards keep the output valid: a model objection without a major finding has its findings promoted to major so they stay blocking, and a diff with no line to anchor the finding on is left unchanged. Failed reviews and unreadable PR bodies are also left unchanged. > > Testing: 20 new tests (19 in `test_extract_verdict.py`, 1 workflow contract test pinning the flag); `python3 -m unittest discover -s scripts/pr_review -t .` shows the same 6 pre-existing macOS-only failures (`sha256sum`, BSD `realpath`) with and without this change. > > Drafted with Claude Code. Pull Request resolved: pytorch#202800 Approved by: https://github.com/jeanschmidt, https://github.com/albanD
Summary (human written only)
Propose that agent keeps its stack size under 10 and highlight the tradeoff of having a large stack
Agent details (if applicable)