Skip to content

Fold pr_review.py's Repeated Refusal, Subprocess, Confirmation, and Ref Checks Into Helpers - #3498

Merged
ptr727 merged 2 commits into
developfrom
feature/pr-review-helpers-3459
Oct 26, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/pr-review-helpers-3459

Conversation

@ptr727

@ptr727 ptr727 commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Summary

Each of the four shapes #3459 names in scripts/pr_review.py now has one primitive, and every site uses it:

  • Refusals. not_written(status, why, code, *details) prints a refusal that wrote nothing, with any detail lines after it. scope_refusal(owner) is the out-of-scope refusal that comment_on_pr, attest, reply_to_thread, and run_wait each wrote out.
  • Subprocess calls. _run(argv, timeout, unrun, **options) captures one command and returns a failure to start or finish as exit 1. _git, _gh_run, head_carries, receipt_reading, and origin_owner call it. _git, _gh_run, and head_carries stay as thin wrappers, since tests patch them. origin_owner keeps its broad except for a decode error.
  • Write confirmation. mutated(data, *path) walks a mutation's response. unconfirmed(status, why, response, code) reports a response that did not confirm the write. They are used in comment_on_pr, both steps of answer_thread, and request_copilot_review's response walk.
  • Ref checks. safe_ref(ref) is the REST-path ref check, used by required_contexts, attest, await_registered_head, and pr_cleanup.branch_rules.

Verification

Every printed line and exit code is unchanged:

  • I wrapped each touched function, plus main and pr_cleanup.branch_rules, and recorded its return value and stdout keyed by test id. I ran the full test_pr_review and test_pr_cleanup suites before and after the change, 1132 records each. After normalizing commit SHAs and temp paths, the records match. The one difference is a frozenset's repr order, which comes from string hash randomization.
  • The suite never makes _git, _gh_run, receipt_reading, or origin_owner fail to start. So I stubbed subprocess.run to raise FileNotFoundError, TimeoutExpired, and UnicodeDecodeError, and ran each of those four plus head_carries against both versions. All 15 results are identical.
  • The full suite (python -m unittest discover -s tests) passes: 2965 tests, 7 skipped. ruff and mypy are clean.

Two local strict-review passes ran at the frontier tier. The first found one missed mutation walk and one stale comment, and 7e63bc0 fixes both. The second found nothing in this change.

This PR carries the comments label for the one comment line it rewrites, in origin_owner.

Dropped findings

  • scripts/pr_review.py, answer_thread: the REPLY_NOT_CONFIRMED text says "Read the response above", but the response prints below it. This is wording on text this change did not touch, and this change keeps the string byte-identical by contract (style).

Refs #3459

🤖 Generated with Claude Code

ptr727 and others added 2 commits October 25, 2026 20:09
…ef Checks Into Helpers

Each of the four shapes #3459 names now has one primitive:

- `not_written` prints a refusal that wrote nothing, with any detail
  lines after it, and `scope_refusal` is the out-of-scope refusal
  `comment_on_pr`, `attest`, `reply_to_thread`, and `run_wait` shared.
- `_run` captures one command and returns a failure to start or finish
  as exit 1. `_git`, `_gh_run`, `head_carries`, `receipt_reading`, and
  `origin_owner` call it, and `origin_owner` keeps its broad `except`
  for a decode error.
- `mutated` walks a mutation's response and `unconfirmed` reports one
  that did not confirm the write, in `comment_on_pr` and both steps of
  `answer_thread`.
- `safe_ref` is the REST-path ref check, used by `required_contexts`,
  `attest`, `await_registered_head`, and `pr_cleanup.branch_rules`.

Every printed line and exit code is unchanged. Each touched function's
return value and stdout, recorded over the pr_review and pr_cleanup
suites before and after, match, and so does each subprocess wrapper's
answer to a missing binary, a timeout, and a decode error.

Closes #3459

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…omment

The local strict-review pass found one more hand-written walk of a
mutation response, in `request_copilot_review`, and it now uses
`mutated` like the other sites. It also found that `origin_owner`'s
comment named a missing git and a timeout as reaching its `except`,
which `_run` now absorbs, so the comment says what still lands there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 26, 2026 03:17
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Oct 26, 2026
@ptr727

ptr727 commented Oct 26, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 7e63bc098d9652147951d52fb0ffa6beb3865f61, the content this pull request carries at that commit against develop, and it recorded 1 finding.

Copilot AI 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.

🟢 Approval recommended

No unresolved review findings were identified, and all member assessments indicate approval readiness.

No open issues 🎉

What changed in this PR

This pull request consolidates repeated refusal, subprocess, write-confirmation, and reference-validation logic across the PR review and cleanup scripts while preserving existing behavior.

Changes:

  • Adds shared helpers for refusals, mutation responses, subprocess execution, and safe reference validation.
  • Updates affected pr_review.py paths to use the centralized helpers.
  • Reuses pr_review.safe_ref in pr_cleanup.py.
File Description
scripts/​pr_review.py Adds and applies shared refusal, mutation, subprocess, and safe-reference helpers across review workflows.
scripts/​pr_cleanup.py Reuses pr_review.safe_ref for branch reference validation.

Review effort: Lite

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.10%. Comparing base (162d1aa) to head (7e63bc0).

Files with missing lines Patch % Lines
scripts/pr_review.py 96.61% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3498      +/-   ##
===========================================
+ Coverage    81.07%   81.10%   +0.03%     
===========================================
  Files           26       26              
  Lines         8928     8907      -21     
===========================================
- Hits          7238     7224      -14     
+ Misses        1690     1683       -7     
Flag Coverage Δ
python-3.13 81.10% <96.66%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit ae27aa3 into develop Oct 26, 2026
14 checks passed
@ptr727
ptr727 deleted the feature/pr-review-helpers-3459 branch October 26, 2026 03:29
ptr727 added a commit that referenced this pull request Oct 26, 2026
## Summary

Promotes the pull requests merged into develop since release 2.0.1192.

- [#3498](#3498):
`scripts/pr_review.py`'s repeated refusal, subprocess,
write-confirmation, and ref-check shapes each get one primitive,
`not_written` and `scope_refusal`, `_run`, `mutated` and `unconfirmed`,
and `safe_ref`, and every site moves onto them,
`pr_cleanup.branch_rules` included. Every printed line and exit code is
unchanged, which a before-and-after recording of each touched function
over the `pr_review` and `pr_cleanup` suites shows, along with a probe
of each subprocess wrapper's start-failure paths.
- [#3500](#3500):
dependabot's `actions-deps` group bumps `docker/login-action` from 4.6.0
to 4.7.0, plus `astral-sh/setup-uv` and `actions/setup-python`, across
the workflows and composite actions that pin them.

Closes #3459

## Constituent coverage

Each change this promotion carries had coverage on its own pull request
into develop:

| Pull request | Merged head | Coverage |
| --- | --- | --- |
| [#3498](#3498) |
`7e63bc09` | attested local pass at the merged head, base `develop`, and
a Copilot table on the merged head naming exactly its 2 changed files,
no open findings |
| [#3500](#3500) |
`79f11c72` | merged by the `ptr727-codegen` app, with no local pass or
Copilot round on its own pull request, so this promotion's own Copilot
round covers it |

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants