Skip to content

fix(tooling): read Codex's codex-review-state:v1 so the fork gate can pass - #326

Open
heavygee wants to merge 2 commits into
mainfrom
fix/hapi-pr-status-codex-review-state-v1
Open

heavygee wants to merge 2 commits into
mainfrom
fix/hapi-pr-status-codex-review-state-v1

Conversation

@heavygee

Copy link
Copy Markdown
Owner

Why

The ChatGPT Codex connector has switched comment formats. It no longer emits the
legacy Reviewed commit: `sha` prose — it posts a machine-readable summary
comment instead, edited in place as the review runs:

<!-- codex-review-state:v1 {"code_review":{"commit_sha":"…","has_any_findings":false,
     "has_unresolved_findings":false,"status":"completed"},…} -->

hapi-pr-status.sh matched only the old prose, so dimension 3 reported
UNKNOWN (no Reviewed-commit Codex event) for every fork PR. This wasn't new
— #309 and #311 (2026-11-08) were already in the new format, with zero legacy
hits, days before anyone noticed.

The failure mode is worse than noise. Because cold-review-clean deliberately
refuses to invent a tip-match, the fork-stage gate became un-passable: the
only way through was --skip-fork-stage. A gate that can only ever say "unknown"
trains everyone to bypass it, and then it isn't a gate. Found while promoting
#324 → tiann#2362, where Codex had in fact reviewed the exact tip and
returned clean.

What

  • Accept codex-review-state:v1 alongside the legacy prose when selecting the
    latest Codex event. The old parse stays as the fallback — this adds a format,
    it doesn't replace one.
  • Tip-match from code_review.commit_sha.
  • Clean iff status == "completed" and has_any_findings == false.
  • An in-flight review is explicitly not a verdict, and cold-review-clean
    does not rescue one.

Two traps worth naming, because both fail silently and both are covered by the test:

  • jq's // swallows false. .has_any_findings // empty returns empty for
    false — which is precisely the value meaning "reviewed, found nothing". Using
    the alternative operator here would have blanked the verdict it was reading.
  • The summary comment is edited in place. Its created_at stays at the moment
    the review started, so selecting on creation time ranks a finished review as
    stale. Keys on updated_at.

Testing

scripts/tooling/hapi-pr-status-codex-state.test.sh — offline, stubs gh,
auto-discovered by the existing scripts/**/*.test.sh sweep in
soup-redeploy.yml. 11 assertions across both directions: tip-matched clean,
completed-with-findings, in-flight, tip-ahead via the v1 sha, label-does-not-
override-in-flight, and legacy prose still working.

It fails 5 assertions against the unpatched script, reproducing the exact
UNKNOWN symptom — so it's a real probe, not a tautology.

Live, after the fix:

PR Before After
#324 UNKNOWN → NOT clean ✅ CLEAN (tip-matched, completed, no findings)
#309 UNKNOWN → NOT clean ✅ CLEAN
#311 UNKNOWN → NOT clean bot dimension PASS; still fails on an unrelated empty CI rollup — correct discrimination, not a rescue
tiann#2362 CLEAN ✅ CLEAN (upstream path untouched)

shellcheck -S warning clean on both files.

Note

I opened tiann#2362 with --skip-fork-stage while this was broken, having
verified the review independently (state JSON + the 👍 the bot only adds when all
reviews finish with no findings). With this change, #324 now passes the gate on
its own, which retroactively confirms that call — but the point of fixing it is
that nobody should have to make that call by hand again.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T07:13:26.601494Z b3642db 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: 0d89f28134

ℹ️ 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 scripts/tooling/hapi-pr-status.sh Resolved
heavygee added a commit that referenced this pull request Nov 11, 2026
Review finding on #326. When the v1 state said completed with
has_any_findings: true, the verdict fell through to the legacy clean-body regex,
which runs over the WHOLE summary comment — including its security-review row. A
"No findings" there matched `CLEAN_REGEX` and reported CLEAN on a PR with real
code-review findings.

Restrict prose matching to events carrying no machine-readable state. When the
state block is present it is the verdict; the operator `cold-review-clean`
override is untouched.

Regression test appends that exact security-review line to a
completed-with-findings fixture; it fails against the unguarded branch.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <[email protected]>
@heavygee

Copy link
Copy Markdown
Owner Author

@codex review

Tip moved to 6a26a7c56 after addressing the P2 on prose-vs-state precedence — requesting a fresh wave on the current tip.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 6a26a7c562

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

heavygee and others added 2 commits November 12, 2026 07:11
… pass

The ChatGPT Codex connector stopped emitting the legacy "Reviewed commit:
`sha`" prose and now posts a machine-readable summary comment instead, edited
in place as the review runs. hapi-pr-status matched only the old prose, so
dimension 3 reported UNKNOWN for every fork PR — #309 and #311 were already in
the new format days before this was noticed.

Because cold-review-clean deliberately refuses to invent a tip-match, that made
the fork-stage gate un-passable rather than noisy, which pushes agents toward
habitual --skip-fork-stage and quietly hollows out the gate.

Parse the v1 block: tip from code_review.commit_sha, clean iff status is
completed AND has_any_findings is false. An in-flight review is explicitly not
a verdict, and the label does not rescue one. The legacy prose parse stays as
the fallback for older waves.

Two traps worth naming, both covered by the test:
  - jq's `//` swallows `false`, which is exactly the value meaning "reviewed,
    found nothing" — `.has_any_findings // empty` would blank the verdict.
  - the summary comment is edited in place, so selecting on created_at ranks a
    finished review as stale; use updated_at.

The test asserts both directions (clean, findings, in-flight, tip-ahead,
label-does-not-override, legacy-still-works) and fails 5 assertions against the
unpatched script.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <[email protected]>
Review finding on #326. When the v1 state said completed with
has_any_findings: true, the verdict fell through to the legacy clean-body regex,
which runs over the WHOLE summary comment — including its security-review row. A
"No findings" there matched `CLEAN_REGEX` and reported CLEAN on a PR with real
code-review findings.

Restrict prose matching to events carrying no machine-readable state. When the
state block is present it is the verdict; the operator `cold-review-clean`
override is untouched.

Regression test appends that exact security-review line to a
completed-with-findings fixture; it fails against the unguarded branch.

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <[email protected]>
@heavygee
heavygee force-pushed the fix/hapi-pr-status-codex-review-state-v1 branch from 6a26a7c to b3642db Compare November 12, 2026 07:11
heavygee added a commit that referenced this pull request Nov 12, 2026
via HAPI

Co-Authored-By: HAPI <[email protected]>
Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant