Repository navigation
feat: add opt-in gate for saved review results - #1457
Qiyuanqiii wants to merge 2 commits into
Conversation
|
666,cla过期的来 |
|
🔍 OpenCodeReview found 2 issue(s) in this PR.
|
36f9629 to
06312c5
Compare
NanaseInori
left a comment
There was a problem hiding this comment.
Reviewed the current head (06312c5). I don't see a blocking issue in the implementation.
The opt-in boundary is clear: ocr gate evaluates an existing JSON artifact without changing ocr review behavior, rerunning the model, consulting Git, or pretending to attest the live PR head. The evaluator is conservative about evidence: unsupported/legacy manifests, malformed or inconsistent coverage, zero selected items, run/coverage failures, missing delivery evidence, failed code_comment calls, revision mismatches, and unknown severities all avoid a false pass. Established severity violations correctly take precedence over inconclusive checks while retaining the independent reasons.
The result contract is deterministic and machine-readable, policy validation happens before consuming input, the command keeps stdout suitable for CI decisions, and the integration tests exercise the actual emitRunResult output rather than only synthetic internal structs. I also appreciate that the documentation explicitly states the trust boundary: the artifact is assumed trusted, live-head freshness is opt-in via expected immutable revisions, and callers must preserve the original review exit status rather than using a gate pass to mask an execution failure.
Given those constraints are explicit and the feature is opt-in, this adds a useful deterministic CI layer without silently changing review semantics.
This review was conducted by NanaseInori's review bot, using the model GPT-5.6 Sol. If you need a human review, please manually @NanaseInori.
|
Thanks for the contribution. The CI workflow you describe is useful, but I think the decision to block a build belongs outside OCR. One team may want a high-severity finding to fail CI and require the author to fix it; another may want the same finding to trigger a notification. Both should be able to use the same review report. A team that switches review tools should also be able to keep its policy and change only how its CI script reads the findings. I'd like OCR to focus on producing a stable, machine-readable account of what it reviewed and what it found, and leave the pass/fail decision to an external script or CI integration. I'm closing this PR on that scope decision, not because the use case is invalid. If the report is missing information an external integration needs, that would be a useful issue to discuss separately. |
Description
Summary
ocr gatecommand that evaluates a saved review JSON result without running another review or calling a model.ocr.gate/v1decision withpass,fail, orinconclusive, ordered checks, and stable reason codes. Onlypassexits0.Motivation and Scope
A review process finishing successfully does not necessarily mean its result meets a team's merge requirements. For example, a budget-limited partial review can leave selected files unreviewed, while a complete review can report high-severity findings. CI needs a separate, explicit policy decision without spending model tokens again or embedding different interpretations in each platform integration.
This PR implements that decision as a standalone command over an existing artifact. Running
ocr gateopts into the policy; existingocr reviewbehavior is unchanged.This complements #1030, which addresses process exit status and SARIF execution metadata for operational partial failures. The gate has a different responsibility: budget-only partial coverage is also insufficient to pass, and findings can block an otherwise complete run when a severity threshold is enabled. This change does not depend on #1030 being merged and does not change its scope.
Usage
--inputis required. Text output is the default; severity and revision checks are disabled until their corresponding flags are supplied. Revision flags accept full lowercase 40- or 64-character object IDs, not mutable branch names. For a range review, the expected base is the resolved merge base, not the requested branch tip.Implementation
internal/gateevaluates the artifact through anio.Reader; it does not resolve Git refs, read a checkout, or call a model or hosting API.comments: nullfor an empty slice. Additional metadata fields are tolerated; missing evidence and unknown manifest versions cannot pass.code_commentfailure remains inconclusive even after a later success because the artifact does not establish that the same findings were resubmitted.Decision Rules
The following outcomes assume the other applicable checks pass:
pass0fail1inconclusive1inconclusive1inconclusive1code_commentfailureinconclusive1pass0inconclusive1inconclusive1A confirmed severity violation takes precedence over inconclusive coverage or delivery checks, but all evaluated checks remain in the output. Invalid arguments, input-file errors, and output-write errors also exit
1; these may produce only a stderr diagnostic rather than a complete decision document.Compatibility and CI Integration Boundary
Type of Change
How Has This Been Tested?
Validation Environment
go1.26.5 windows/amd64a003b9341a65130b024829101ea35494b56569e1Automated Validation
make license-addmake checktarget throughmingw32-makewith Git Bash: license headers, English-only source check, module tidying, formatting, andgo vetmake testtarget: complete Go test suite with the race detectormake coveragetarget: 91.4% total statement coverage, above the required 90%; 100.0% forinternal/gatemake buildtarget with a local executable namegit diff --checkand LF-only verification of changed filesRegression Coverage
emitRunResultoutput rather than relying only on handcrafted JSON fixtures.Manual Validation and Review
PATH: pass exited0; threshold failure and malformed-input inconclusive decisions exited1; stdout remained parseable JSON.The repository-required pre-commit review also completed successfully using
ocr review --audience agent --background ...:Known Limitations and Follow-up Scope
Checklist
go fmt,go vet)AI/LLM Disclosure
Codex (GPT-6-Astra Max) was used for tests, documentation
The required pre-commit model review used open-code-review CLI v1.11.9 with the configured
deepseek-v4-flashmodel.Related Issues
Related to #1027 and #1030. This PR adds a separate opt-in policy layer and does not change the timeout exit-code behavior tracked in #1027.