Make Codex review dispositions deterministic#95
Conversation
Co-Authored-By: Codex <noreply@openai.com>
🤖 Codex PR Review🚫 Merge blocked: 2 serious issue(s) found in high-risk files 🚫 Blocking IssuesThese issues must be fixed before this PR can be merged: 1. 🟠 [HIGH] Logic in
|
There was a problem hiding this comment.
💡 Codex Review
AIAuditBridge/scripts/run_codex_pr_review.py
Lines 2192 to 2196 in 5f3f01b
When next_action becomes authenticated_disposition, the only trusted clear path is an anchored record containing the exact review_finding_id and head SHA, but the PR comment formats active findings without either those values or any marker/instructions. In a false-positive or stale-active-finding case, maintainers cannot produce the required disposition from the normal review output, so the gate can remain blocked unless someone manually decodes the hidden machine state.
ℹ️ 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".
| invalid.append( | ||
| { | ||
| **enriched, | ||
| "validation_error": str(exc), | ||
| } |
There was a problem hiding this comment.
Surface invalid blocking findings in comments
When a high/critical finding fails deterministic validation (for example because the model reports a removed line, missing evidence, or a non-Python boundary), this path appends the sanitized finding only to invalid_findings. The decision still blocks the merge, but build_pr_comment renders only blocking_findings and non_blocking_findings, so authors see a generic metadata-validation failure with no reported finding or validation_error to act on. Include these invalid findings in a rendered blocking section or otherwise surface their sanitized details.
Useful? React with 👍 / 👎.
| "race_condition", | ||
| } | ||
| ) | ||
| EVIDENCE_SYMBOL_PATTERN = re.compile(r"[A-Za-z_][A-Za-z0-9_]{2,127}") |
There was a problem hiding this comment.
Allow valid short callable names in evidence
This pattern requires at least three identifier characters, so legitimate Python callables named f, go, or up are rejected before an active finding can be computed. For high/critical findings inside such functions, otherwise valid evidence becomes invalid metadata and forces a contract-arbitration block instead of a normal dispositionable finding; the regex should allow Python's valid one-character identifiers.
Useful? React with 👍 / 👎.
| if not path.endswith(".py"): | ||
| return None |
There was a problem hiding this comment.
Support blocker evidence outside Python files
For a high/critical finding in a workflow, shell script, JS/TS file, Dockerfile, or other non-Python file, _python_enclosing_callable() returns None here, so _canonical_finding_evidence() rejects the finding before it can receive a deterministic ID. The gate still fails closed, but the finding is treated as invalid metadata and cannot use the new authenticated-disposition flow even though this review workflow is used on non-Python paths such as .github/workflows/* and scripts.
Useful? React with 👍 / 👎.
| history_valid = bool( | ||
| history_source_valid | ||
| and review_state_valid | ||
| and previous_state["status"] == "normal" | ||
| ) |
There was a problem hiding this comment.
Provide a recovery path for invalid review state
Once the bot publishes a v2 state with status: invalid (for example after malformed legacy history or a state serialization failure), every later run hits this check and blocks before fetching the diff or running review. Because invalid states contain no active finding IDs to disposition, a normal follow-up commit or contract/documentation fix cannot clear the gate; it requires out-of-band comment deletion/editing despite next_action=contract_arbitration.
Useful? React with 👍 / 👎.
Summary
review_finding_id.v1only after exact head, right-side patch line, repository source, category/severity, evidence, description, and impact validationreview_finding_disposition.v1record is read from authenticated repository review metadataTests
7 passedpython3 -m unittest -q tests.test_run_codex_pr_review— 70 passedpython3 -m pytest tests ops/quant-monitor/tests -q— 668 passed, 1 skipped, 54 subtests passedpython3 -m ruff check .python3 -m compileall -q service scriptsactionlintgit diff --checkCompatibility / risk