Repository navigation
ci: add the codex-review reusable workflow - #8
Conversation
Codex ignores review requests from bots and charges repository-wide reviews to credits, so request the review with the owner's token and gate on the codex-review-state of the head commit. Refs #7 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
| | sed -n 's/.*<!-- codex-review-state:v1 \(.*\) -->.*/\1/p' | tail -n 1)" | ||
| sha="$(jq -r '.code_review.commit_sha // empty' <<<"$state" 2>/dev/null || true)" | ||
| status="$(jq -r '.code_review.status // empty' <<<"$state" 2>/dev/null || true)" | ||
| if [[ "$sha" == "$HEAD_SHA" && ( "$status" == "completed" || "$status" == "failed" ) ]]; then |
There was a problem hiding this comment.
P2: A stale state for the same HEAD_SHA is accepted right away on a re-run.
The loop accepts any codex-review-state whose commit_sha == HEAD_SHA with status completed/failed. It doesn't check that the state is newer than the @codex review comment posted in the previous step. Re-running the job without a new push therefore reads the old result on the first poll, before Codex has picked up the new request:
- After a
failedresult (for example, usage limits), re-running once the quota resets fails again immediately with the oldfailedstate. - After you resolve a refuted finding, which the error message tells you to do, a re-run reads the old
has_unresolved_findings: trueand fails again.
The only way out is a new push. One fix: record the timestamp or ID of the comment you just posted, and only accept a summary comment whose updated_at is later than it. Another: first wait until the status leaves the terminal state.
| run: | | ||
| deadline=$((SECONDS + 20 * 60)) | ||
| while ((SECONDS < deadline)); do | ||
| state="$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \ |
There was a problem hiding this comment.
P2: One transient API error ends the whole 20-minute wait.
Steps run with bash -eo pipefail. If gh api fails once during the polling (a 5xx error, a secondary rate limit or a network blip), the pipeline fails. The state="$(...)" assignment then exits the step under -e. status is never written, so the job fails with a raw error. The step summary never gets the friendly timeout or failure message, because the next step has no if: always(). Polling every 30 s for up to 20 min gives roughly 40 API calls per run, so this will cause occasional false failures. Add || true (or || continue after a sleep) to the fetch.
Review summaryNothing blocks the merge (no P0 or P1 findings). There are two P2 findings, both in the wait loop of
The rest looks sound: the caller wiring, the |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d60dfdb09
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [[ "$sha" == "$HEAD_SHA" && ( "$status" == "completed" || "$status" == "failed" ) ]]; then | ||
| echo "status=$status" >>"$GITHUB_OUTPUT" | ||
| echo "unresolved=$(jq -r '.code_review.has_unresolved_findings' <<<"$state")" >>"$GITHUB_OUTPUT" | ||
| exit 0 |
There was a problem hiding this comment.
Wait for the newly requested review result
When this workflow is rerun for a commit that Codex has already reviewed, the existing summary still contains a completed state for HEAD_SHA when the new @codex review comment is posted, so this condition can succeed on the first poll and gate on the old verdict without waiting for the newly requested review. Correlate the state with this request, or otherwise require evidence that the state changed after the request, so a later review cannot introduce findings after the check has already passed.
Useful? React with 👍 / 👎.
…ry failed polls A re-run on an already reviewed commit read the old verdict at once, and one failed API call ended the whole wait without the summary message. Refs #7 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
| uses: ./.github/workflows/codex-review.yml | ||
| permissions: {} | ||
| secrets: | ||
| codex_review_token: ${{ secrets.CODEX_REVIEW_TOKEN }} |
There was a problem hiding this comment.
P2 (security): This gives the owner's personal token to every same-repo pull_request run, and that includes PRs opened by furedea-agent[bot]. On pull_request events, GitHub runs the workflow files from the PR head. So any PR that changes ci.yml or codex-review.yml can read CODEX_REVIEW_TOKEN (for example, by echoing it base64-encoded or sending it out), and its author can then act as the owner. A token with "Pull requests: write" can approve PRs. Because the bot, not the owner, authored the PR, an approval made with that token counts toward branch protection. The bot could then get its own PRs approved by "the owner" and also post @codex/@claude commands under the owner's name.
The OAuth token was already exposed this way, but this new token lets the bot act as the owner, which is a bigger step. Possible mitigations:
- Restrict the token to this single repository.
- Make sure branch protection doesn't rely on the owner's approval.
- Require approval before workflows run on bot-authored PRs.
- Document the trade-off in the README.
There was a problem hiding this comment.
Not changing this, with evidence: the token is only readable by changing a workflow file, and furedea-agent cannot push .github/workflows/ (the App has no workflows permission; its pushes of workflow files were rejected in #3 and #5, so the owner pushes them). The review job does no checkout and runs no PR code, and the secret is passed only to codex-review. Callers pin this workflow to a full commit SHA. This is the same exposure as CLAUDE_CODE_OAUTH_TOKEN. If the App ever gets workflows, this must be revisited.
Review summaryBlocking findings: none (no P0 or P1).
I also checked the polling logic and found nothing to flag:
One part I couldn't check: whether Codex writes 🤖 Generated with Claude Code |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
## 概要 `repo review-token rotate` で Codex レビュー用の PAT(`CODEX_REVIEW_TOKEN`)も発行・保存・登録できるようにします.`codex-review` workflow(furedea/reusable-workflows#8)が `@codex review` をオーナー名義で投稿するために使います. | コマンド | 変更前 | 変更後 | | --- | --- | --- | | `repo review-token rotate` | Claude の token だけ | Claude → Codex の順に両方 | | `repo review-token rotate claude` | なし | Claude だけ(`claude setup-token`) | | `repo review-token rotate codex` | なし | fine-grained PAT の作り方を表示し,貼られた PAT を保存して全 repo に登録 | | `repo configure` | `CLAUDE_CODE_OAUTH_TOKEN` を登録 | 保存済みの token をそれぞれ登録.無いものだけ警告 | ## 確認 - [x] 1Password と Keychain で,token ごとに別の項目へ保存する(互いに上書きしない) - [x] 各 token は stdin だけで渡し,引数や出力に出さない - [x] 未知の種類は usage を返し,何も実行しない - [x] ruff,ruff format,ty,pytest(155 件) Refs furedea/reusable-workflows#7 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
概要
App が開いた PR も Codex にサブスクの枠でレビューさせる reusable workflow
codex-review.ymlを追加します.CI がオーナーの PAT で@codex reviewとコメントし,Codex のcodex-review-stateを読んで判定します.この PR 自身が実験台です(App が開いた PR で,自身の CI が新しい workflow を呼ぶ).確認
@codex reviewから Codex のレビューが走るRefs #7
🤖 Generated with Claude Code