Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ uv run --no-project --script scripts/pr_review.py merge 123 --repo ptr727/Projec

Claude Code's auto-mode classifier refuses a hand-typed `gh pr merge --squash` on a pull request whose gate is met. It refuses most often inside a subagent, which sees neither the review nor the maintainer's go-ahead. A command matching the allow rule is settled before that classifier runs, so every check the merge needs lives here. Whether the merge is authorized stays with the skill that runs it. What the code checks is the Merge Gate's mechanically readable items, and that the merge is current, in the owner, and into `develop` only. The items no code reads, such as a finding the pull request's body lists, stay the driver's per `pr-review-conduct`'s Merge Gate.

Before any read it runs the write-scope check `cleanup` runs, so a `--cleanup` after a landed merge in a registered repository cannot refuse on scope. It reads the pull request live and refuses unless it is open, not a draft, based on `develop`, and headed in its own repository. A `main` base is refused by name, since a promotion merge belongs to `merge-and-release` with the maintainer's go-ahead. A permanent head branch, `develop`, `main`, or the default branch, is refused, and those are the only branches the fleet's rulesets cover. So a `main -> develop` pull request is never squashed into `develop`. It records the head, then reads the gate through `wait`'s own decision, so the two cannot drift apart. That read runs on a short bound and sends no review request, since `wait` is the step that waits and requests. A gate not met prints `wait`'s status line and returns its code unchanged. A `wait` exit of `0` does not decide every item, so a fresh read follows. It refuses unless coverage reads `full`, `table`, `carried:table`, or `local`, and no thread is unresolved, every page walked. Each count the digest builds of a finding no thread carries has to read zero. Otherwise every item under it carries an acknowledgment `comment --ack` posted. Those are `suppressed`, `previously_missed`, `cr_outside_diff`, `qodo_open`, and `FINDINGS WITH NO THREAD`. The code reads the fields the digest builds rather than its printed line. A count field the digest did not build refuses as `COUNT_UNREAD` rather than reading as zero. So does one holding no number, such as an `overview` count of `?`. A count built as no value reads zero only where its source is absent. That is a `previously_missed`, `cr_outside_diff`, or `qodo_open` with nothing to count, or an `overview` where no round covers the head. A `shapes=HELD` refuses as `UNPLACED_PARTS_UNACKNOWLEDGED` until its acknowledgment posts. A head round with no overview marker still refuses after it, as `COUNT_UNREAD` on `overview`, since item 3 reads no count there. A part under `REVIEWER OUTPUT NOTED` refuses as `OUTPUT_NOTED` until an acknowledgment answers its key, or its round's own head hold was acknowledged. A Copilot review request still pending refuses as `REVIEW_PENDING`. A request to a human or team reviewer is the driver's per `pr-review-conduct`. The fresh read refuses a hosted reviewer's check on the head that has neither passed nor failed as `CHECKS_PENDING`, whatever the merge state. A reviewer whose newest output is a rate limit posted since the check began is exempt. It also refuses an open registration grace as `CHECKS_PENDING`, on a line of its own naming when the grace ends. So a head no local pass covers cannot land inside the grace with no hosted reviewer's check on it. A `--checkout` that is not the primary clone of the target is refused before any merge. `cleanup`'s worktree and tip checks still run after it, so they can refuse once the merge has landed. The merge state has to read `CLEAN`, `UNSTABLE`, or `HAS_HOOKS`, the states `wait` treats as finished. Each unmet item prints its own `status=` line. Some of those counts span every round, such as `suppressed`, so an answer the acknowledgment does not name leaves the count standing. `FINDINGS WITH NO THREAD` reads the head's round alone, so an earlier round's no-thread finding stays the driver's. The head is read again after the gate, and a head that moved refuses as `HEAD_MOVED` before any unmet item prints. A merge `gh` refused on a head that moved prints `HEAD_MOVED` too. The merge runs as `gh pr merge "<number>" --squash --match-head-commit "<head>"`, never with `--admin`, `--auto`, or `--delete-branch`. Its output is printed whole. Reading the pull request back decides the outcome. A pull request read back merged at a head other than the gated one prints `status=PEER_MERGED` at exit `1`. This run merged nothing, so it runs no cleanup itself. A merge `gh` refused that reads back open is a refusal. A pull request that reads back closed is one too, whatever `gh` answered, since a closed pull request cannot merge later. A call that timed out or never ran, or a read back that stays ambiguous, may still have landed on the server. `--cleanup` runs `cleanup` on the same pull request once the merge is confirmed, with `--checkout` passed through to it, and its exit is the command's.
Before any read it runs the write-scope check `cleanup` runs, so a `--cleanup` after a landed merge in a registered repository cannot refuse on scope. It reads the pull request live and refuses unless it is open, not a draft, based on `develop`, and headed in its own repository. A `main` base is refused by name, since a promotion merge belongs to `merge-and-release` with the maintainer's go-ahead. A permanent head branch, `develop`, `main`, or the default branch, is refused, and those are the only branches the fleet's rulesets cover. So a `main -> develop` pull request is never squashed into `develop`. It records the head, then reads the gate through `wait`'s own decision, so the two cannot drift apart. That read runs on a short bound and sends no review request, since `wait` is the step that waits and requests. A gate not met prints `wait`'s status line and returns its code unchanged. A `wait` exit of `0` does not decide every item, so a fresh read follows. It refuses unless coverage reads `full`, `table`, `carried:table`, or `local`, and no thread is unresolved, every page walked. Each count the digest builds of a finding no thread carries has to read zero. Otherwise every item under it carries an acknowledgment `comment --ack` posted. Those are `suppressed`, `previously_missed`, `cr_outside_diff`, `qodo_open`, and `FINDINGS WITH NO THREAD`. The code reads the fields the digest builds rather than its printed line. A count field the digest did not build refuses as `COUNT_UNREAD` rather than reading as zero. So does one holding no number, such as an `overview` count of `?`. A count built as no value reads zero only where its source is absent. That is a `previously_missed`, `cr_outside_diff`, or `qodo_open` with nothing to count, or an `overview` where no round covers the head. A `shapes=HELD` refuses as `UNPLACED_PARTS_UNACKNOWLEDGED` until its acknowledgment posts. A head round with no overview marker still refuses after it, as `COUNT_UNREAD` on `overview`, since item 3 reads no count there. A part under `REVIEWER OUTPUT NOTED` refuses as `OUTPUT_NOTED` until an acknowledgment answers its key, or its round's own head hold was acknowledged. A held title refuses as `TITLE_NOT_CONVENTIONAL` on any head. A Copilot review request still pending refuses as `REVIEW_PENDING`. A request to a human or team reviewer is the driver's per `pr-review-conduct`. The fresh read refuses a hosted reviewer's check on the head that has neither passed nor failed as `CHECKS_PENDING`, whatever the merge state. A reviewer whose newest output is a rate limit posted since the check began is exempt. It also refuses an open registration grace as `CHECKS_PENDING`, on a line of its own naming when the grace ends. So a head no local pass covers cannot land inside the grace with no hosted reviewer's check on it. A `--checkout` that is not the primary clone of the target is refused before any merge. `cleanup`'s worktree and tip checks still run after it, so they can refuse once the merge has landed. The merge state has to read `CLEAN`, `UNSTABLE`, or `HAS_HOOKS`, the states `wait` treats as finished. Each unmet item prints its own `status=` line. Some of those counts span every round, such as `suppressed`, so an answer the acknowledgment does not name leaves the count standing. `FINDINGS WITH NO THREAD` reads the head's round alone, so an earlier round's no-thread finding stays the driver's. The head is read again after the gate, and a head that moved refuses as `HEAD_MOVED` before any unmet item prints. A merge `gh` refused on a head that moved prints `HEAD_MOVED` too. The merge runs as `gh pr merge "<number>" --squash --match-head-commit "<head>"`, never with `--admin`, `--auto`, or `--delete-branch`. Its output is printed whole. Reading the pull request back decides the outcome. A pull request read back merged at a head other than the gated one prints `status=PEER_MERGED` at exit `1`. This run merged nothing, so it runs no cleanup itself. A merge `gh` refused that reads back open is a refusal. A pull request that reads back closed is one too, whatever `gh` answered, since a closed pull request cannot merge later. A call that timed out or never ran, or a read back that stays ambiguous, may still have landed on the server. `--cleanup` runs `cleanup` on the same pull request once the merge is confirmed, with `--checkout` passed through to it, and its exit is the command's.

With `--cleanup`, a `status=MERGED` line means the merge landed, and the exit is then `cleanup`'s own. Otherwise exit `0` is merged and confirmed. Exit `1` is a run that merged nothing. That is a refusal, a moved head, an unmet item, a registry refusal, or a merge `gh` refused. It is also a pull request another hand already merged, which still owes cleanup. Exit `2` is a read that did not answer or a usage error. It is also a merge call the read back could not settle, which may have happened on the server. Exit `64` is the owner check. Any other code is the gate's, from the `pr_review.py` exit codes above, and nothing was merged.

Expand Down
5 changes: 3 additions & 2 deletions scripts/pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@
excerpt under `UNPLACED ON THE HEAD`. A trusted comment acknowledging its
fingerprint clears it, `shapes=ACKNOWLEDGED`. 50 is also a held title, `title=HELD` with
each fix under `TITLE NOT CONVENTIONAL`. It is over 72 characters, ends in a period, or
holds a capitalized bind word. It exits 50 where a Copilot round covers the head and its
coverage does not read partial. A retitle clears it, and `merge` refuses it on any head.
holds a capitalized bind word inside it. It exits 50 where a Copilot round covers the
head and its coverage does not read partial. A retitle clears it, and `merge` refuses
it on any head.
Dependabot's reads `title=exempt`.
`coverage=` names how the head's diff is shown read: `full` or `PARTIAL` as the round
states it, `UNKNOWN` for a statement this cannot believe or a body the reader failed
Expand Down
Loading