Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

chore: block merges while Codex reviews are unfinished - #2

Open
aletty wants to merge 6 commits into
masterfrom
codex/wait-for-review-v2
Open

chore: block merges while Codex reviews are unfinished#2
aletty wants to merge 6 commits into
masterfrom
codex/wait-for-review-v2

Conversation

@aletty

@aletty aletty commented Sep 9, 2026

Copy link
Copy Markdown
Owner

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

@aletty
aletty marked this pull request as ready for review September 9, 2026 01:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-09-09T02:08:15.218506Z 4732d78 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d372733d0

ℹ️ 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".

const codex = {};
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});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fetch reactions from the requesting comment

When Codex acknowledges a review request by reacting to its PR comment, listForIssue cannot see that reaction because it only enumerates reactions attached directly to the PR issue; comment reactions require the issue-comment reactions endpoint. Consequently, the documented legacy reaction-only case produces eyes=[], and even a manual dispatch can publish a successful check while that review remains active if no matching request or summary remains.

AGENTS.md reference: AGENTS.md:L12-L12

Useful? React with 👍 / 👎.

Comment thread .github/workflows/stack-policy.yml Outdated
Comment on lines +165 to +169
const codex = {};
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid refetching every review for every check

For N open PRs, each snapshot() now performs 2N serial comment/reaction requests, while the publication loop calls snapshot() again for each of the roughly N head SHAs. A single reconciliation therefore makes O(N²) GitHub API calls—for example, about 1,000 requests around 20 open PRs before pagination—which can exhaust the workflow token quota or the 10-minute timeout and leave every required Stack policy check failing.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b00f0762ca

ℹ️ 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".

Comment thread .github/workflows/stack-policy.yml Outdated
Comment on lines +60 to +63
const completedAt = Math.max(0, ...summaries.map(c => Date.parse(c.updated_at) || 0));
const requests = comments.filter(c => c.authorizedRequest === true && isReviewRequest(c.body));
if (requests.some(c => (Date.parse(c.updated_at || c.created_at) || Infinity) >= completedAt))
return {ok:false, message:'A Codex review was requested; waiting for the bot completion summary.'};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Correlate completion summaries with their review requests

When reviews overlap, an older review can complete after a newer @codex request was posted; because completedAt is the maximum timestamp across every summary, that unrelated completion makes the newer request appear satisfied before its review emits a status or reaction. codexReview then returns success, and since reaction creation is not among this workflow's triggers, the successful required check can remain mergeable throughout the newer review. Track completion by review type/request rather than treating any later completed summary as completing every request.

AGENTS.md reference: AGENTS.md:L12-L12

Useful? React with 👍 / 👎.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant