chore: block merges while Codex reviews are unfinished - #3
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7139418af0
ℹ️ 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".
| for (const p of open) { | ||
| const comments = await github.paginate(github.rest.issues.listComments, {...args, issue_number:p.number, per_page:100}); | ||
| const reactions = await github.paginate(github.rest.reactions.listForIssue, {...args, issue_number:p.number, per_page:100}); | ||
| codex[p.number] = codexReview(comments, reactions); |
There was a problem hiding this comment.
Avoid refetching every review for every check run
When a repository has N open PRs with distinct head SHAs, the publication loop calls snapshot() once for each of the N checks, and this newly added loop makes every snapshot fetch comments and reactions for all N PRs. The resulting O(N²) paginated API traffic can exhaust the workflow token's API quota or the 10-minute timeout with only tens of open PRs; the catch handler then publishes failures for every check and blocks all merges. Cache or batch the review metadata, or only refresh the PRs relevant to the check being published.
Useful? React with 👍 / 👎.
| const requests = comments.filter(c => /^\s*@codex\s+(?:security\s+)?review\b/im.test(c.body || '')); | ||
| if (requests.some(c => (Date.parse(c.created_at) || Infinity) > completedAt)) | ||
| return {ok:false, message:'A Codex review was requested; waiting for the bot completion summary.'}; |
There was a problem hiding this comment.
Treat equal-timestamp review requests as pending
When a new @codex review comment is created during the same timestamp second as the previous completion-summary update, created_at equals completedAt, so this strict > comparison treats the later request as already completed. The request-triggered run can therefore leave Stack policy green until the bot later emits a comment event, especially because adding an eyes reaction alone does not trigger this workflow. Resolve equal timestamps conservatively or use metadata that establishes event ordering so an active review cannot pass.
AGENTS.md reference: AGENTS.md:L12-L12
Useful? React with 👍 / 👎.
Codex can be reviewing while existing checks are green. Extend the required Stack policy check to block unfinished reviews using authenticated bot summary comments, authorized manual requests, and PR and comment eyes reactions. Completed findings remain advisory.
Reconcile on PR and comment events, with manual dispatch available for legacy reaction-only reviews. Preserve existing branch protection and the installed action pin. The controller reads metadata only; GitHub event delivery still leaves a brief detection window.
Validation: 44 policy/controller tests passed locally, including concurrent reviews, spoofed summaries, permission checks, repeat requests, linear API reads, deleted markers, head updates, separate review types, shared heads, and publication races. Tests are included under
.github/policy-tests/.Depends on: none