feat: add scripts/codex-review.sh reviewer harness + document the in-session review loop - #8
Conversation
…session review loop Wrap Codex's built-in PR review (`codex exec review`) in a thin harness that posts the verdict to a PR verbatim, and reconcile the docs (which implied a hand-written rubric) to match how the reviewer actually works. - scripts/codex-review.sh: derive base, gh pr checkout, run `codex exec review --base <base> -o <tmpfile>` (read-only default), post verbatim via `gh pr comment` with a cross-vendor header. mktemp + trap cleanup; only side effect is one PR comment. Optional -m model passthrough; shellcheck-clean, executable. - reviewer/codex-review.md: repurposed from a paste-able rubric into documentation of the real mechanism + the synchronous in-session loop, invariants, and the GitHub-integration (autonomous) / codex-plugin-cc (interactive) alternatives. - README: Reviewer row + Layout entry for the new script. - RESTORE.md: reviewer recreate step now references scripts/codex-review.sh and the GitHub-integration option. Closes #7 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codex reviewer (cross-vendor, read-only)Posted verbatim by The new reviewer harness does not ensure Codex runs inside the repository being reviewed, so its advertised target-repo workflow can produce failed or incorrect reviews. This is a blocking correctness issue for the script's primary purpose. Review comment:
|
…> arg Codex P1: the <owner>/<repo> arg implied codex-review.sh worked for any repo, but codex exec review always ran in the launching dir — so running it from the wrong dir reviewed the wrong code and posted to the wrong PR. Make the contract honest: signature is now [-m <model>] <PR#>, gh infers owner/repo from the cwd, and a guard rejects running outside a git repo with a gh-recognized remote. Docs updated to the run-from-the-clone model. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Resolved the Codex P1 (round-1). The footgun was real: Fix — made the contract honest instead of just guarding it:
|
Codex reviewer (cross-vendor, read-only)Posted verbatim by The new review harness can operate on stale checkout refs in the intended repeated-review loop, does not enforce its stated read-only safety invariant, and the documented invocation path does not work from separate target repos. These issues should be addressed before considering the patch correct. Full review comments:
|
…te-path invocation Address the round-1 Codex review on PR #8 (three findings): - [P1] Stale refs on re-run: fetch origin and `gh pr checkout --force` to reset the local PR branch to the latest head, and review against the qualified remote base `origin/<base>` so re-runs always see the current head against a current base instead of a stale leftover branch. - [P2] Enforce read-only: pin the review sandbox with `-c sandbox_mode="read-only"` on `codex exec review` so it can't inherit a writable default from the operator's Codex config. `codex exec review` has no -s/--sandbox flag, and we avoid --ignore-user-config so the operator's model/effort defaults still apply. - [P2] Docs invocation: document invoking the script by absolute path (or via a PATH alias) from within the target repo's clone, since the script lives only in this control-plane repo — not copied per repo. Updated reviewer/codex-review.md and RESTORE.md. Invariants preserved: cross-vendor, read-only, comments-only, verbatim post, mktemp+trap cleanup, cwd guard, set -euo pipefail. shellcheck clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Resolved all three round-1 Codex findings (round-2). Commit 9ebe7e5. [P1] Stale refs on re-run (
[P2] Enforce read-only (
[P2] Script path fails from a target repo (docs)
Invariants intact: cross-vendor, read-only (now forced), comments-only, verbatim post + cross-vendor header, mktemp+trap cleanup, cwd guard, |
Codex reviewer (cross-vendor, read-only)Posted verbatim by The new review harness can target the wrong GitHub repository when gh is configured via GH_REPO, and it can destructively reset local PR branches despite being presented as read-only/comments-only. These should be addressed before relying on the script. Full review comments:
|
…ce checkout Resolves two P2 Codex findings on the codex-review.sh harness: - Pin gh to the checkout's repo: `unset GH_REPO` and derive `repo` from the cwd (`gh repo view --json nameWithOwner`), then pass an explicit `--repo "$repo"` to every gh pr view/checkout/comment call. A GH_REPO in the environment can no longer redirect the review comment to a different repo's PR; Codex still reviews the cwd checkout. - Guard a clean worktree before `gh pr checkout --force`: abort with a clear stderr error if `git status --porcelain` is non-empty, so the read-only/comments-only reviewer never discards local-only commits or uncommitted work. Docs (reviewer/codex-review.md) updated to describe both behaviors. Invariants intact (cross-vendor, forced read-only sandbox, comments-only, verbatim+header, mktemp+trap, cwd guard, qualified origin/<base>, set -euo pipefail). shellcheck clean; structure check passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Resolved both round-2 Codex P2 findings (round-3). Commit f0225b5. [P2] Pin gh to the checkout's repo (GH_REPO) (
[P2] Don't clobber local work on force-checkout (
Docs — Invariants intact: cross-vendor, read-only forced via |
Codex reviewer (cross-vendor, read-only)Posted verbatim by The new harness can discard unpublished local commits in a documented read-only workflow. That data-loss risk should be fixed before considering the patch correct. Review comment:
|
Closes #7
What
scripts/codex-review.sh— the Codex cross-vendor reviewer harness. Usagescripts/codex-review.sh [-m <model>] <owner>/<repo> <PR#>. It derives the PR base,gh pr checkouts it, runscodex exec review --base <base> -o <tmpfile>, and posts Codex's review to the PR verbatim viagh pr comment, under a short header marking it the cross-vendor reviewer.reviewer/codex-review.md— from a paste-able rubric into documentation of the real mechanism, the invariants, the synchronous in-session loop, and the alternatives (Codex GitHub integration = autonomous upgrade; codex-plugin-cc = interactive).scripts/codex-review.sh(in-session) / GitHub integration (autonomous)"; added the script to the Layout block.scripts/codex-review.shand the GitHub-integration option instead of "paste the reviewer prompt".Why
The reviewer is Codex (cross-vendor), but posting its review was ad-hoc and the docs still implied a hand-written rubric was used. This encapsulates the real flow (Codex's built-in
codex exec review, not a custom prompt —--basecan't take one) and reconciles the docs.How verified
shellcheck scripts/codex-review.sh(v0.11.0) — clean (both tracked scripts clean).bash -nsyntax check — OK.structure ok(all required files present, including the keptreviewer/codex-review.md).codex-cli 0.129.0:codex exec reviewexposes--base,-o/--output-last-message,-m/--model;gh pr comment -F -reads from stdin.Invariants preserved
Cross-vendor (coder=Claude, reviewer=Codex), reviewer read-only (no
--dangerously-bypass-*), comments-only (only side effect is onegh pr comment), and verbatim posting (no Claude session edits the review). Per CLAUDE.md: this is docs/tooling — no live-routine prompt changed.🤖 Generated with Claude Code