Skip to content

Require PR stacks to stay under 10 PRs - #202800

Closed
huydhn wants to merge 9 commits into
pytorch:mainfrom
huydhn:ai-policy-stack-size
Closed

huydhn wants to merge 9 commits into
pytorch:mainfrom
huydhn:ai-policy-stack-size

Conversation

@huydhn

@huydhn huydhn commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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 (#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.

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).
@pytorch-bot

pytorch-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

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

🟡 AUTOMATED REVIEW - Changes requested:

The PR adds a "Keep PR stacks small" rule (fewer than 10 PRs) to
CONTRIBUTING.md, links it from CLAUDE.md, and makes extract_verdict.py request
changes on any ghstack PR 10th or higher from the bottom. Recommendation:
Request Changes. Blocking reasons: the findings cap can silently drop the
model's only major finding, the summary cut can silently discard the model's
summary, and the policy finding is anchored on lines the PR did not change.

Findings (17):

[major] scripts/pr_review/extract_verdict.py:1045
The cap drops a finding without counting it and can remove the model's only
major finding. `[finding, *findings][:MAX_FINDINGS]` cuts the model's last
finding when it already had 25, but does not increment `findings_dropped`
(published via emit_row.py:312) or append `{"reason": "over_cap"}` to
`dropped_detail`, unlike `sanitize_findings`' `drop()`. The promotion check
(1033-1036) runs before the cut: a `changes_requested` result with 24 minors and
its one major at index 24 gets no promotion, then the slice removes that major,
so post_review blocks only on the policy finding and the model's real issue
disappears from verdict.json. The author's reply (6616210565) saying the drop is
counted in `findings_dropped` is not true at HEAD. Fix: drop the lowest-severity
finding rather than the last, and record it the way `drop()` does (respecting
`MAX_DROPPED_TRACKED`).

[major] scripts/pr_review/extract_verdict.py:1027
The summary cut is cruder than the file's own truncation and can discard the
model's summary with no trace. `f"{policy} {result['summary']}"[:MAX_SUMMARY]`
cuts mid-word with no TRUNCATED marker. A 128-hex digest straddling the cut
leaves 120-127 hex chars (not in `_DIGEST_LENGTHS`); for most of those lengths
`_decodes_to_binary` trips, `is_neutral_prose` fails, and `summary = policy`
silently replaces the whole model summary. The policy text is ~200 chars, so any
model summary over ~1,300 chars gets cut. Fix: truncate only the model's part to
`MAX_SUMMARY - len(policy) - 1`, using `neutralize_message`'s backoff (word
boundary, partial entity, TRUNCATED, drop tokens until the check passes)
factored into a shared helper.

[major] scripts/pr_review/extract_verdict.py:1040
The policy finding usually sits on an unchanged line. `parse_diff` puts both
context and `+` lines into `touched`, so `min(touched[path])` of the
alphabetically first file is normally a context line ~3 lines above the first
change. The tests pin this (they expect `README.md:1`, the context line ` #
Project` in `DIFF`). Sorting by name also favours `.ci/`, `.github/` and
uppercase docs over the code under review. Fix: anchor on the first added line,
which needs `parse_diff` to expose added lines separately.

[minor] scripts/pr_review/extract_verdict.py:1058
The policy can be skipped with no log line. `load_pr_body` returns "" with
nothing on stderr if `--pr-comments-file` is missing, invalid JSON, not a dict,
or has a non-string `body`. The no-anchor `else: return result` branch
(1047-1049) is equally quiet: a 10th+ PR whose diff has no new-side lines (only
deletions/renames) keeps `ready_for_human_review`. Fix: print a `::warning::`
line to stderr in both cases, as `fetch_pr_comments.py`'s `warn()` does.

[minor] scripts/pr_review/extract_verdict.py:1191
The policy's output skips `build()`'s final re-check. `main` writes
`apply_stack_policy`'s result without the
`check_value_charset`/`check_value_blobs` pass, which `build()`'s own comment
says "is what makes the module's advertised invariants true of the artifact".
Not exploitable today, since every new string passes `is_neutral_prose` or
`is_publishable_finding` individually. Fix: run the two checks on the new result
(`main` already catches `Rejected`), or apply the policy inside `build()` before
its re-check.

(12 more not shown, see the review run)

Reviewed commit: e8b791f

Review run

🐛 Report a bad review

🔗 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 Failures

As of commit e8b791f with merge base 68c8684 (image):
💚 Looks good so far! There are no failures yet. 💚

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

  • Policy documentation
    • AI_POLICY.md hunk adds a contributor rule: keep PR stacks under 10 PRs and land the bottom first
    • It also states the project reserves the right to stop running CI on large stacks, a project-level decision
  • Triviality
    • Docs that add a rule or restriction or state policy are never trivial, so a human should sign off
  • Correctness
    • The linked .agents/skills/ghstack-ci/SKILL.md exists in the checkout; no defect found

reason: not_trivial
Reviewed commit: 9ae1379 (NOT the current head e8b791f)

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 30, 2026
@huydhn
huydhn requested review from albanD and drisspg October 30, 2026 19:35
@huydhn huydhn assigned jeanschmidt and unassigned jeanschmidt Oct 30, 2026
@huydhn
huydhn requested review from jeanschmidt and removed request for drisspg October 30, 2026 19:36
@huydhn
huydhn marked this pull request as ready for review October 30, 2026 19:36
@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Oct 30, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 30, 2026
github-actions[bot]

This comment was marked as outdated.

@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 30, 2026
…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.
@huydhn
huydhn requested a review from a team as a code owner November 2, 2026 20:35
@huydhn huydhn changed the title [AI policy] Ask contributors to keep PR stacks under 10 PRs [AI policy] Require PR stacks to stay under 10 PRs Nov 2, 2026
@pytorchgreenlight pytorchgreenlight Bot added GL/superseded GreenLight review is superseded by changes and removed GL/human GreenLight marked as needing human review labels Nov 2, 2026
@huydhn

huydhn commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@claude Review this change

@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

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_POLICY.md misstates the CI threshold, and two [no-ci] points from the earlier automated review are still open.

AI-generated review details

PR Review: #202800

Summary

The PR adds a rule to AI_POLICY.md that stacks must have fewer than 10 PRs. It also enforces the rule in scripts/pr_review/extract_verdict.py: a PR at position 10 or higher from the bottom of its ghstack gets changes_requested, plus one major finding. The enforcement logic is sound. Positions 1–9 are left alone, failed reviews stay failures, an unreadable body is ignored, and /tmp/pr-comments.json is written by the same review job and can only be read by the model. The problems are in the policy wording and in two edge cases.

Code Quality

  • AI_POLICY.md:31-33: the CI threshold is stated wrong. The text says "CI already skips PRs with more than 10 PRs underneath them". .github/scripts/filter_test_configs.py:747 actually skips at get_ghstack_below_count(pr_body) >= GHSTACK_BELOW_SKIP_THRESHOLD (10). So CI skips with 10 or more PRs underneath, which is position 11 and up. Reword to "10 or more PRs underneath them". The doc should also mention the ciflow/trunk override that CI accepts; nothing comparable exists for the review policy.

  • AI_POLICY.md:29-30: two earlier automated findings are still open. The 9ae1379 review flagged these points, and HEAD has not addressed them:

    • "use [no-ci] on PRs" still doesn't say it is a PR title prefix. For ghstack it must go in the commit subject before the PR is created, or CI starts anyway (.agents/skills/ghstack-ci/SKILL.md).
    • The only link still points to an agent skill. CONTRIBUTING.md#skip-ci-while-iterating is the doc for humans.

    The other two earlier points are addressed now: the text says who the rule applies to, and "large stacks" is defined.

  • scripts/pr_review/extract_verdict.py:75 (_GHSTACK_ENTRY): every matching line in the body counts, not just the stack list. ghstack_position matches any line of the form * #N anywhere in the body. Example: a ghstack PR whose description, below the stack block, has a bullet list like * #12345 (follow-ups, related PRs). Those lines count as PRs below the current one, so a PR low in its stack can get changes_requested. filter_test_configs.py has the same flaw, but there the cost is a skipped CI run, not a blocking review. Fix: count only the entries that directly follow the Stack from [ghstack] header, up to the first non-entry line. Apply the same fix in both places so the two copies of the regex don't drift.

  • scripts/pr_review/extract_verdict.py:1027-1036: a PR with no added lines turns the model's minor findings into blockers. If touched has no non-empty path (a deletion-only PR), no policy finding is added, but the verdict still becomes changes_requested. post_review.py:264-267 then treats every finding as blocking when there is no major one. The model's minor findings become blocking, which is exactly what the comment at line 1024 says this code prevents. test_with_no_touched_line_the_verdict_still_changes only covers the case with zero model findings. Fix: in that case, downgrade the model's findings explicitly, or anchor the policy finding to a deleted file, and add a test with a minor finding.

Recommendation

Request Changes

What blocks approval: the threshold sentence and the open [no-ci] wording in AI_POLICY.md, plus the deletion-only edge case. The stray-bullet miscount is lower likelihood but cheap to fix. jeanschmidt approved; no maintainer comments are unaddressed.

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

huydhn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

The automated review only re-runs on PRs labeled in progress and neither ready for review nor no automated review.

Comment thread AI_POLICY.md Resolved
albanD
albanD previously requested changes Nov 3, 2026
@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed ready for review Automated review passed, ready for a final review by a maintainer. labels Nov 3, 2026
@huydhn huydhn changed the title [AI policy] Require PR stacks to stay under 10 PRs Require PR stacks to stay under 10 PRs Nov 3, 2026
github-actions[bot]

This comment was marked as outdated.

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

huydhn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot review

@pytorch-bot pytorch-bot Bot added in progress PR is being worked on by the author, until the automated review accepts it and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 3, 2026
github-actions[bot]

This comment was marked as outdated.

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

huydhn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

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 findings_dropped. Capping the model's findings at MAX_FINDINGS - 1 before prepending, as suggested, drops the same finding.

Drafted with Claude Code.

github-actions[bot]

This comment was marked as outdated.

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.

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

if result["verdict"] == "changes_requested" and all(

🔴 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

findings.sort(key=lambda f: f["severity"] != "major")

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.


result = apply_stack_policy(result, body, touched)

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.


Stacks of pull requests must have fewer than 10 PRs. This applies to every

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.


result = self.run_script(json.dumps({"body": stack_body(10, 12)}))

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.


def test_the_ghstack_constants_match_ci(self):

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


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.


def run_script(self, comments: str | None) -> dict:

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.

Comment thread scripts/pr_review/extract_verdict.py Resolved
Comment thread scripts/pr_review/extract_verdict.py Resolved
Comment thread scripts/pr_review/extract_verdict.py Resolved
Comment thread scripts/pr_review/extract_verdict.py Resolved
Comment thread CONTRIBUTING.md Resolved
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.
@huydhn huydhn added the no automated review Request skipping the automated PR review process label Nov 3, 2026
@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 Nov 3, 2026
@huydhn

huydhn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

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 use pr-review skill locally, get it to a state where everything pass locally, but there are still new things coming up after pushing.
  • It looks like the bot has the tendency to bubble up every single nits as the next batch of blocking points once the previous batch is fixed. The vicious circle is more fix -> more nits -> more blocking -> more fix.
  • I don't think pushing back comments work, at least not reliably.

I'll opt-out this PR for the time being.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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!

@pytorch pytorch deleted a comment from pytorch-bot Bot Nov 4, 2026
@huydhn

huydhn commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f 'Policy change, no need to run trunk'

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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
## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GL/superseded GreenLight review is superseded by changes Merged no automated review Request skipping the automated PR review process 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.

5 participants