Skip to content

[pr-review] Raise the finding message cap and tell stage B about it - #201566

Closed
izaitsevfb wants to merge 6 commits into
mainfrom
pr-review-raise-finding-cap
Closed

izaitsevfb wants to merge 6 commits into
mainfrom
pr-review-raise-finding-cap

Conversation

@izaitsevfb

@izaitsevfb izaitsevfb commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

✴️ iz2: The automated review cut inline findings off mid-sentence at 600 characters: extract_verdict.py caps each finding message there, and stage B was never told about the limit. 18 of the 32 most recent bot inline comments hit the cap. Example: #201517 (comment)

  • MAX_MESSAGE goes from 600 to 1500, the same as MAX_SUMMARY.
  • The stage B prompt asks for at most 1200 characters per finding message, counting each &, < and > as five, since escaping lengthens them.
  • A message that still overflows ends in ... at a word boundary. The input slice and the output cut both drop the token they split. neutralize_message() then drops trailing tokens until the result passes the publish check (is_neutral_prose). If no prefix passes, it returns empty, and the existing empty-message drop applies. A message that fails the check as a whole (for example, a blob that neutralize() joins) is not trimmed: it is still dropped as failed_publish_check.
  • A contract test keeps the prompt's budget at or below 80% of MAX_MESSAGE, and tests cover the cut cases.

At the new cap, a review with 25 findings stays well under GitHub's body limit, and MAX_BODY still drops whole findings and says so when needed. Dr.CI's renderer has its own findings budget (PR_REVIEW_FINDINGS_BUDGET) and reports any findings it hides.

Test plan: python3 -m unittest discover -s scripts/pr_review -p 'test_*.py' (452 tests pass).

Inline findings were cut at 600 characters mid-sentence, and the stage B
model was never told the limit. Raise MAX_MESSAGE to 1500 (matching
MAX_SUMMARY) and ask stage B for at most 1200 characters per message.
@izaitsevfb
izaitsevfb requested a review from a team as a code owner October 20, 2026 17:34
@pytorch-bot

pytorch-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

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

✅ AUTOMATED REVIEW - Ready for human review:

The PR raises MAX_MESSAGE from 600 to 1500 characters, makes a message that
still overflows end in a ` ...` marker at a word boundary (neutralize_message),
and states a 1200-character budget in the stage B prompt, which a contract test
enforces. Recommendation: Approve. The truncation logic and its tests hold up
under tracing; the one performance point is low confidence and doesn't block.

Findings (1):

[minor] scripts/pr_review/extract_verdict.py:851
The worst-case sanitize time grows about 2.5x, because findings that fail the
publish check don't count toward the findings cap (low confidence: estimated
from the code's own measured figure, not run). `sanitize_findings` stops at
`MAX_FINDINGS` only once 25 findings have been *kept*. A finding that reaches
`neutralize_message` and is then dropped as `failed_publish_check` doesn't count
toward that limit; the only bound on how many such findings can arrive is
`MAX_STRUCTURED_BYTES` (1 MiB). `neutralize` is quadratic in its input (627 ms
for the bad bracket shape at 1500 characters, per the com

Reviewed commit: ac1cac4

Review run

🔗 Helpful Links

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

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

✅ No Failures

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

🟡 GREEN LIGHT - PR requires human review:

  • Trust boundary
    • scripts/pr_review/extract_verdict.py is the egress sanitizer for untrusted model output, per its module docstring; security plumbing is never trivial
    • Adds new cut-and-retry logic neutralize_message() with regexes _PARTIAL_TOKEN and _PARTIAL_ENTITY in the publish path
  • Consequential limits
    • MAX_MESSAGE rises from 600 to 1500, widening the per-finding output channel the docstring says caps exist to bound
    • Stage B prompt in .github/workflows/hardened-pr-review-run.yml gains a new 1200-character message budget
  • Tests
    • New TestAnOverflowingMessageEndsInAMarker and a workflow contract test cover the cut cases, but the security tradeoff needs a human

reason: not_trivial
Reviewed commit: ac1cac4

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 20, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 20, 2026
github-actions[bot]

This comment was marked as outdated.

…he cap

A message that still overflows MAX_MESSAGE now ends in ' ...' at a word
boundary, dropping trailing tokens until the result passes the publish
check. A contract test keeps the stage B budget at or below 80% of
MAX_MESSAGE.
github-actions[bot]

This comment was marked as outdated.

…cters in the budget

A message that fails the publish check whole (a blob neutralize() joins)
is returned whole, so build() drops it as failed_publish_check as before,
instead of the retry loop trimming it until it passes. The stage B prompt
now counts each &, < and > as five characters.
github-actions[bot]

This comment was marked as outdated.

A token split by the MAX_MESSAGE input slice (half a 128-hex digest) made
the whole message fail the publish check and dropped the finding. Drop the
split token before neutralizing, as the output cut already does.
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed stale reviews from themself October 20, 2026 19:03

Withdrawn: the automated review of a15dbb4 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 ac1cac4: nothing blocking; ready for human review.

The PR raises MAX_MESSAGE from 600 to 1500 characters, makes a message that still overflows end in a ... marker at a word boundary (neutralize_message), and states a 1200-character budget in the stage B prompt, which a contract test enforces. Recommendation: Approve. The truncation logic and its tests hold up under tracing; the one performance point is low confidence and doesn't block.

⚪ 1 non-blocking finding

clean_message = neutralize_message(message)

The worst-case sanitize time grows about 2.5x, because findings that fail the publish check don't count toward the findings cap (low confidence: estimated from the code's own measured figure, not run). sanitize_findings stops at MAX_FINDINGS only once 25 findings have been kept. A finding that reaches neutralize_message and is then dropped as failed_publish_check doesn't count toward that limit; the only bound on how many such findings can arrive is MAX_STRUCTURED_BYTES (1 MiB). neutralize is quadratic in its input (627 ms for the bad bracket shape at 1500 characters, per the com

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

@github-actions
github-actions Bot dismissed their stale review October 20, 2026 19:43

Withdrawn: the automated review of ac1cac4 found nothing blocking.

@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 20, 2026
@izaitsevfb
izaitsevfb requested review from d4l3k and huydhn October 21, 2026 00:52

@d4l3k d4l3k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm

@izaitsevfb

Copy link
Copy Markdown
Contributor Author

✴️ iz2: merging on Ivan's behalf.
@pytorchbot merge

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

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