Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
334ddbf
docs: design for review tracking, incremental rounds, status and shep…
catalan-adobe Nov 26, 2026
f95294a
docs: plan phases 1-2 of review tracking; spec: rounds command, no pa…
catalan-adobe Nov 26, 2026
c370452
docs: keep internal repo details out of the public spec examples
catalan-adobe Nov 26, 2026
5fafca5
docs: design the terminal dashboard (standalone, Rust + Ratatui, opti…
catalan-adobe Nov 26, 2026
b68b75d
docs: record dashboard decisions (tui-markdown, r posts after confirm)
catalan-adobe Nov 26, 2026
1b98802
docs: reorder review tracking so the review flow changes first (PR 1 …
catalan-adobe Nov 26, 2026
28399b2
Move shared helpers to lib/ and dispatch subcommands
catalan-adobe Nov 26, 2026
0820df9
docs: record per-severity open counts in round records
catalan-adobe Nov 26, 2026
73520a4
Add the loop rules: labels, flags and the next-round decision
catalan-adobe Nov 26, 2026
35f5614
Add round records: findings parser, record builder and marker
catalan-adobe Nov 26, 2026
df270d5
Record each review round on the PR and in round.json
catalan-adobe Nov 26, 2026
b8022ad
Add gh pr-review rounds to print a PR's review history
catalan-adobe Nov 26, 2026
da78a1d
Check the review loop before a round, and stop loops that do not conv…
catalan-adobe Nov 26, 2026
ce76209
docs: PR 1 results on real review history (calibration, loop check, p…
catalan-adobe Nov 26, 2026
e958692
Keep one answer when the loop check cannot read the PR's comments
catalan-adobe Nov 26, 2026
7a15370
Recognize a generated review by its first line only, and read its rec…
catalan-adobe Nov 26, 2026
4115f06
Take round numbers, times, commits and authors from GitHub, and lift …
catalan-adobe Nov 26, 2026
158a92f
Feed the round history to jq on stdin, never as one argument
catalan-adobe Nov 26, 2026
fdab3ad
Use the findings block only when every entry is valid, else parse the…
catalan-adobe Nov 26, 2026
11eba6b
Number new findings after the highest ID in the whole history, and ke…
catalan-adobe Nov 26, 2026
bdb12be
Size the marker on the exact posted body, and publish only titles and…
catalan-adobe Nov 26, 2026
36bc67d
Suggest follow-ups for every Nit loop, and keep the split for Churning
catalan-adobe Nov 26, 2026
ff31c33
Fail loudly when the round record cannot be built, and never approve …
catalan-adobe Nov 26, 2026
af8b12e
Ask before a round on an unchanged head, and let a code-only run foll…
catalan-adobe Nov 26, 2026
10033cc
Check the history again before posting, and refuse a round number som…
catalan-adobe Nov 26, 2026
bea1504
Test that rounds and --check read back the round the review posted
catalan-adobe Nov 26, 2026
3ae728f
Run the post-decision tests with the libraries and a round record, an…
catalan-adobe Nov 26, 2026
45c7fc3
Do not let GitHub's ghost placeholder lift a loop-check stop
catalan-adobe Nov 26, 2026
393cf73
Publish a file or title in the marker only as the review shows it
catalan-adobe Nov 26, 2026
ad5691d
Post a minimal marker when the counts do not fit, and read its counts…
catalan-adobe Nov 26, 2026
6b00d16
Parse the Markdown when the findings block shows fewer blockers than …
catalan-adobe Nov 26, 2026
81beec9
Renumber the new findings of rounds posted at once by their position
catalan-adobe Nov 26, 2026
b0bf9bd
Post the review on the commit it read, and never approve a head that …
catalan-adobe Nov 26, 2026
7dac715
Never post over a round that landed during the review, and post nothi…
catalan-adobe Nov 26, 2026
eb48937
Follow the head and the history through three rounds in the producer-…
catalan-adobe Nov 26, 2026
776e143
Approve automatically only with a posted record that was built and ch…
catalan-adobe Nov 27, 2026
13a1e51
Fail the history read when any step of rebuilding the rounds fails
catalan-adobe Nov 27, 2026
1e24a0d
Give a compacted round posted at once the next IDs after the floor
catalan-adobe Nov 27, 2026
e8c74c2
Match the block's blockers to the review's by location, one to one
catalan-adobe Nov 27, 2026
76bd427
Read a code span as one whole path, spaces included
catalan-adobe Nov 27, 2026
496d96e
Keep the loop line first when the head moved during the review
catalan-adobe Nov 27, 2026
7691265
Document that a push right before posting can still leave an approval…
catalan-adobe Nov 27, 2026
505c56d
Check whether the review landed when posting fails, instead of saying…
catalan-adobe Nov 27, 2026
5e22d1e
Match a Markdown location range to a findings-block line inside it
catalan-adobe Nov 27, 2026
e99d758
Read the record from the Markdown when the findings block is not exac…
catalan-adobe Nov 27, 2026
ef5ea3b
Read the record from the Markdown when the block adds findings to a s…
catalan-adobe Nov 27, 2026
4e650ed
Rebuild a code-review marker's missing counts instead of reading them…
catalan-adobe Nov 27, 2026
2066493
Compare the rounds by GitHub review ID before posting, not by count
catalan-adobe Nov 27, 2026
b0f6b0b
Confirm a failed post only by a new review with the posted body, comm…
catalan-adobe Nov 27, 2026
e56add1
Say that +COMMITS counts commits by date between two reviews
catalan-adobe Nov 27, 2026
032de48
Say the visibility filter covers the GitHub marker, not round.json
catalan-adobe Nov 27, 2026
9fff993
Count only reviews by repo members, collaborators or this account as …
catalan-adobe Nov 27, 2026
0f749ef
Explain in the README which reviews count as rounds
catalan-adobe Nov 27, 2026
cdac987
Keep a known Critical when rebuilding a missing blocking count
catalan-adobe Nov 27, 2026
c42f55c
Drop a marker's findings list when its counts come from the Markdown
catalan-adobe Nov 27, 2026
131a1ad
Judge a findings block as the record stores it
catalan-adobe Nov 27, 2026
2c695da
Stop when the account running the tool can't be read
catalan-adobe Nov 27, 2026
e2cd944
Say in the README that contributors' own rounds are not shared
catalan-adobe Nov 27, 2026
a053ef0
Test that a round's marker compaction never makes it ready
catalan-adobe Nov 27, 2026
ab70d2c
Read a none line given as a list item as an empty section
catalan-adobe Nov 27, 2026
75c8695
Count a posted record's findings with the statuses it stored
catalan-adobe Nov 27, 2026
8baaeba
Use a marker's critical and important only when they agree with the v…
catalan-adobe Nov 27, 2026
5bea1fe
Keep a dropped findings list's highest IDs in last_ids
catalan-adobe Nov 27, 2026
cfb05f7
Drop a findings list that can't account for the counts kept from the …
catalan-adobe Nov 27, 2026
3dcacf0
Keep a minimal Rethink marker's null counts
catalan-adobe Nov 27, 2026
fc51044
Test that a damaged round 5 marker keeps its blockers, fixed findings…
catalan-adobe Nov 27, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Install shfmt
run: sudo apt-get update && sudo apt-get install -y shfmt
- name: shellcheck
run: shellcheck gh-pr-review tests/*.sh
run: shellcheck gh-pr-review lib/*.sh tests/*.sh
- name: shfmt
run: shfmt -d gh-pr-review tests/*.sh
run: shfmt -d gh-pr-review lib/*.sh tests/*.sh
- name: tests
run: for t in tests/*.sh; do bash "$t" || exit 1; done
138 changes: 136 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ Inside a repo clone, a bare number works: `gh pr-review 42`.
| `--instructions <text>` | none | Extra guidance for both passes, for example `"Focus on db/; skip style nits"`. For a file: `--instructions "$(cat notes.md)"`. The tool does not post them, and the reviewer is told not to quote them, but the review can still reflect them: use `--no-post` to preview a review shaped by sensitive notes |
| `--skip-approach` | off | Skip the maintainer's approach pass and run the code review only, for example when the approach is already agreed |
| `--decision <d>` | from verdict | `comment`, `approve`, `request-changes`. Unset: an approach verdict of Rethink → request-changes. Otherwise the last "Ready to merge?" line decides: No → request-changes, a bare Yes → approve, anything else (Yes with fixes, Yes, with fixes, …) → comment. On your own PR it is always comment. `-y` submits the decision without asking |
| `-y`, `--yes` | off | Skip the post confirmation |
| `-y`, `--yes` | off | Skip the confirmations. A loop-check stop then exits with code 3, and no new commits with code 5, instead of asking |
| `--check` | off | Run only the loop check (see below) and exit 0, 3 or 5. No clone, no model call |
| `--json` | off | With `--check`: print the decision as JSON on stdout |
| `--force-round` | off | Run a round even when the loop check stops it or nothing changed |
| `--doctor` | — | Check prerequisites and exit |

Environment variables: `GH_PR_REVIEW_MODEL` (default model),
Expand Down Expand Up @@ -109,12 +112,143 @@ Each run writes its files to `./pr-review-sessions/pr-review-XXXXX/` in
your current directory, so you can inspect or re-post later:

- `owner-prompt.md` and `approach.md`: the approach pass
- `prompt.md` and `review.md`: the code review (absent after a Rethink)
- `prompt.md` and `review.md`: the code review (absent after a Rethink); `review-body.md` is the reply
without its findings block, and `findings.json` the block itself
- `round.json`: the round record (see below); `posted.md`: the exact body posted
- `context/`: the PR description, the discussion and the inline review threads both passes read
- `repo/`: the checkout

Add `pr-review-sessions/` to `.gitignore` if you run it inside a repo.

## Round history

Every review this tool posts on a PR is one round. Each round carries a hidden
record on GitHub, in an HTML comment right below the
`<!-- gh-pr-review generated -->` line: the round number, the commits reviewed,
the approach and "Ready to merge?" verdicts, and the findings (severity,
`file:line`, a short title, an ID such as `F4` that later rounds keep). The same
record is saved as `round.json`. The record on GitHub holds only what the
review already says: a title or path the posted review does not show is left
out of the marker, and the `--instructions` text and the prompts are never in
it. `round.json` in the session folder is not filtered: it keeps everything the
model returned, so inspect it before sharing it.

Not every review that looks generated is a round. Anyone who can comment on
a PR can post a review that starts with the `<!-- gh-pr-review generated -->`
line, and a round can stop the next one, so only trusted reviews count: those
whose author GitHub reports as an owner, member or collaborator of the repo
(the review's `author_association`), and your own, so your rounds count where
you are only a contributor. Everything that reads the history uses the same
rule (the loop check, `--check`, `rounds`, the re-read before posting, finding
IDs). Rounds by owners, members and collaborators are shared by everyone; a
contributor's own rounds count only for that contributor, so two contributors
(neither a member nor a collaborator) each count their own rounds and not the
other's, and their round numbers can differ. If the account running the tool
can't be read, the history can't be checked, and nothing runs. The reviews
left out are named once, for example
`ignored: 1 generated review by @x (not a member or collaborator of the repo)`.
GitHub can report a member of an organization whose membership is private as
a contributor, to a token that cannot see that membership: their rounds are
then left out. `--force-round` still runs a round the loop check would not.

`gh pr-review rounds <PR-URL | PR-number>` prints that history, one row per
round. Reviews posted before the records existed are read back from their
Markdown (`backfill`):

```
ROUND DATE COMMIT +COMMITS APPROACH READY CRIT IMP MINOR LABEL SOURCE
3 11-25 08:37 e55e68d 2 questionable no 2 6 2 churning backfill
4 11-25 09:14 09b6b7c 1 questionable no 1 9 1 churning backfill
next round: stop · churning · approach-stuck too-big · Settle the approach before the next round: …
```

`+COMMITS` counts the PR's commits whose commit date falls between the
previous round's review and this one's. It is a date window, not the commits
between the two reviewed heads: a commit pushed while a review runs can be
counted toward that review instead of the next one.

The label says whether the loop converges: `early` (fewer than 3 rounds),
`converging`, `ready`, `nit-loop` (a few Important findings that keep coming
back) or `churning`; `unknown` when a round's record has no blocking count and
neither its findings nor its Markdown can rebuild one (never read as 0, so
never `ready`). `--json` prints the records and the decision; `-u <login>`
picks the gh account, as for a review.

## Loop check

Before a round, the tool reads the PR's earlier rounds and decides whether
another one is worth running. It counts the blocking findings (Critical and
Important) of each round:

- **Converging:** the count drops (to 1 or less, or by 30% over two rounds).
The round runs.
- **Nit loop** (3 or fewer, no Critical) or **Churning** (anything else) after
the first 3 rounds: a warning. The round runs, and the posted review starts
with a line such as
`**Loop:** Churning · blocking 9, 12, 8 · Split the PR: each part converges on its own`.
- **Two such rounds in a row:** the round stops before any clone or model
call. In a terminal it asks first; with `-y` (scripts and agents) it exits
with code 3. The suggested move comes from the history: settle the approach,
split the PR, or approve and file the rest as follow-ups.
- **No new commits** since the last round: nothing to review. In a terminal it
asks "Run round K anyway?" (a second opinion on the same commit); with `-y` it
exits with code 5. A round that only judged the approach (a Rethink) leaves
the code unreviewed, so a `--skip-approach` run on that commit still runs.

A stop lifts when a person other than the PR author reviews or comments after
the last round. The author's own replies do not count, so a fix agent posting
as the author cannot lift its own stop. Comments without an identified user
(a deleted account, shown as `ghost`) do not count either. `--force-round` runs a round anyway,
without asking, and the record says so (`forced`).

Rounds are numbered in the order GitHub received them. Just before posting,
the tool reads the rounds again and compares them, by GitHub review ID, with
the rounds it started from: if someone posted one while this review ran (or a
round was deleted, or edited so it is no longer one), it says who, posts
nothing, keeps the session folder, and exits with code 6, in a terminal too:
run the review again to review on top of the rounds as they are now. If
the rounds can't be read again (one retry), it posts nothing either, keeps
the session, and exits with code 1. Two runs that post at the very same
moment both land; reading the history then gives the later one the next
round number and finding IDs.

The review is posted on the commit it read (the review API's `commit_id`), so
its round covers that commit only. If the PR moved while the review ran, the
review says so ("the PR moved to … during the review; this review covers …")
and is never an approval, even with `--decision approve`: it posts as a
comment. The new commits stay unreviewed, and `--check` runs on them.

Pinning the commit is guaranteed; detecting a push is not. The head is read
once more right before posting, but that read and the post are two separate
requests: a push that lands between them still leaves the review (an approval,
if that was the decision) on the old commit, without the note. GitHub shows
it as a review of an outdated commit. Teams that need a fresh approval after
every push should turn on "Dismiss stale pull request approvals when new
commits are pushed" in the branch protection rules (or rulesets).

If the post request fails, the review may still have landed (the answer can
be lost after GitHub took it). The tool then reads the reviews once and looks
for this run's review: one that was not there at the last read before the
post, by this account, on the reviewed commit, in the state the decision
gives (approved, changes requested, commented), with exactly the body it sent.
Exactly one such review: it reports it posted. None, several, or a failed
read: it says it could not confirm whether the review was posted, keeps the
record a preview, and exits with code 1. Another run's review on the same
commit, by the same account, does not count. Run
`gh pr-review rounds <PR>` before retrying, so the round is not posted twice.

`gh pr-review <PR> --check` runs the check alone and exits 0 (run), 3 (stop)
or 5 (no new commits); `--check --json` prints the decision as JSON for
scripts. `gh pr-review rounds <PR>` shows the same decision under the history.

| Exit code | Meaning |
| --- | --- |
| 0 | Done |
| 1 | Error |
| 3 | Stopped by the loop check |
| 5 | No new commits since the last round |
| 6 | History changed while the review ran (someone posted another round, or a round went away); nothing posted, the session is kept |

## Troubleshooting

- **Empty review** — pi may have failed or timed out; retry with
Expand Down
Loading