Name the Directory the Scope Refusal Probed, Not the Checkout - #1563
Conversation
`pr_review.py` reads the owner a write may stay within from the script's own directory, which is deliberate, since the helper is reached from a hub checkout while the repository being answered is named on the command line. The refusal called that directory "this checkout", which an operator reads as the working directory, so a copy of the script outside any checkout produced a refusal the operator could immediately disprove with `git remote get-url origin` in the tree they were standing in, with nothing on screen explaining the disagreement. Both refusals now name the directory that was actually probed, and the unreadable-origin one names the remedy as well, so the message is self-diagnosing. A `script_dir()` helper is the single reader for the probe and for the messages that name it, so the two can never drift apart. The anchoring, the refusal, and the refusal writing nothing are unchanged. Message only. Fixes #1557
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are scoped to messaging/documentation plus targeted regression tests, and the updated wording matches the actual control flow (scope refusal occurs before any GitHub reads).
Pull request overview
This PR updates scripts/pr_review.py scope-refusal messaging and supporting documentation/tests so the refusal names the directory actually probed (the script's own directory) rather than ambiguously referring to “this checkout”, which can be misread as the operator’s working directory.
Changes:
- Introduces a
HEREmodule constant and uses it consistently for thegit -C ... remote get-url originprobe and for refusal messages that name the probed directory. - Updates the scope refusal strings (including the exit-64 gloss) to describe the probe and provide a concrete remedy for the “script copied outside a checkout” scenario.
- Adds regression tests ensuring the probe and refusal text stay aligned, and updates
scripts/README.mdto match the corrected behavior.
File summaries
| File | Description |
|---|---|
| scripts/pr_review.py | Unifies scope anchor via HERE and updates exit-64/refusal wording to name the probed directory and remedy. |
| scripts/README.md | Updates the reply/comment exit-64 documentation to match the clarified probe behavior and refusal wording. |
| scripts/tests/test_pr_review.py | Adds tests that assert the probe uses HERE and the refusal messages name the probed directory and avoid “this checkout”. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…1564) Promotes one commit from `develop` to `main`. - `1c7e1f1` Name the Directory the Scope Refusal Probed, Not the Checkout (#1563) `scripts/pr_review.py` reads the owner a write may stay within from the script's own directory rather than the working directory, deliberately, since the helper is hub-hosted and reached from a hub checkout while the repository being answered is named on the command line. Its out-of-scope refusals called that directory "this checkout", which an operator reads as the working directory and can disprove on the spot with `git remote get-url origin` in the tree they are standing in. Both refusals now describe the probe and name the directory it ran against, and `reply`'s exit-64 gloss, `origin_owner`'s docstring and the matching `scripts/README.md` sentence agree with them. Message only. The anchoring, the refusal, and the refusal writing nothing are unchanged. Copilot reviewed the feature pull request at its merged head, 3 of 3 changed files, no findings and none suppressed. Closes #1557
scripts/pr_review.pyresolves the owner a write may stay within from the script's own directory, which is deliberate: the helper is hub-hosted rather than carried, so it is reached from a hub checkout while the repository being answered is named on the command line, and the working directory says nothing about who owns either. Its refusals called that directory "this checkout", which an operator reads as the working directory. A copy of the script outside any checkout therefore produced a refusal the operator could disprove on the spot withgit remote get-url originin the tree they were standing in, with nothing on screen explaining the disagreement.Message only, per the issue. The anchoring, the refusal, and the refusal writing nothing are unchanged.
What changed
HEREis a module constant, the single reader for the probe and for the messages that name it, matching the shape six sibling scripts already use.reply's exit-64 gloss andorigin_owner's docstring each said less than the code does, andscripts/README.mdcarried the same "this checkout" claim. All three now agree with the messages.Before, from a copy outside any checkout:
After, against the same reproduction:
Verification
Reproduced the issue's own scenario against the fix, a copy of the script outside any checkout and a cross-owner target from a fleet checkout, and read both messages back. 322 cases in the module and 1403 under discovery, plus
prose_lint,repo_gate --check eol,spec/validate.py,ruff format --checkandruff check, all clean.The new probe case was proved by mutation rather than by passing: against a copy whose probe reads
Path.cwd()instead ofHERE,test_the_probe_reads_the_directory_the_refusal_namesfails. Without that, the assertion passed on a path coincidence whenever the working directory happened to equal the anchor.Five local review rounds ran over this diff. Each message clause was checked against every state that reaches its branch, meaning a missing
git, a timeout, no remote namedorigin, a directory under no repository, anoriginURL the owner regex cannot parse, and an inheritedGIT_DIR. Three earlier wordings were rejected for failing one of those: one asserted the probe had executed when a missinggitmeans it never did, one named a remedy that read as an instruction to change directory and so reproduced the same refusal, and one claimed a repository encloses the probed directory, which an inheritedGIT_DIRfalsifies.Raised separately rather than folded in
Two real defects surfaced during review that are code changes rather than wording, so they are filed instead of carried here:
GIT_DIR, so an inherited one redirects it to a different repository. The messages here describe the probe rather than the directory's repository, which keeps them true under that leak, but the leak itself is untouched.wait's Copilot review request is a mutation that never passes throughin_scope, so the in-process owner check does not cover it.Addresses #1557. The closing reference goes on the promotion pull request, since a
develop-targeted one never registers.