Repository navigation
Measure a review against a severity threshold like ci review --fail-on - #39
Open
kingsleytorlowei wants to merge 2 commits into
Open
kingsleytorlowei wants to merge 2 commits into
kingsleytorlowei wants to merge 2 commits into
Conversation
ReviewOutcome.gate(fail_on) reports REACHED, NOT_REACHED, NOT_COMPLETE or UNAVAILABLE with the CLI's rules: completeness decides first, the server's open-finding counts decide for a completed review, a complete CODE assessment of the review's own commits adds its unresolved findings, an unknown severity reaches every threshold, and missing counts are never a pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReviewOutcome.gate(fail_on)checks a review against aWARNINGorSERIOUSthreshold using the rules ofproofline ci review --fail-on. It returnsREACHED,NOT_REACHED,NOT_COMPLETEorUNAVAILABLE, which correspond to the CLI's exit codes 3, 0, 2 and 4.Who this helps, and the evidence
This is for Python pipelines and deploy tools that already call
wait_for_reviewand want to fail on findings.ci review --fail-onand in the Git hooks'failOnsetting. The comments onci_verdictandcode_reachesdefine it precisely. Add --fail-on to proofline review cli#46 is open and extends it toproofline review.ReviewOutcomeand has to rebuild the rule from the CLI source. Each part of it is easy to get wrong:ReviewOutcomein hand, though, it would have to start the CLI as a separate program and read its exit code. With this change it gets the same answer in one call.Decisions
ci_verdict,code_reaches,code_assessmentandSeverity::reached_by. A Python job and a CLI job therefore agree on the same review.boolwould merge them, and the shortest misuse would turn an incomplete review into a pass.open_items.open_findingsandserious_findingsalready exclude dismissed findings and unexpired risk acceptances, and they include earlier unresolved findings of the same pull request. Recounting fromassessments[].findingswould get decisions wrong.UNAVAILABLE. The generated model doesn't type-check them, so a string, bool or negative count is rejected here.UNAVAILABLE._code_assessmentin 3.3.0 now live in_recorded_code._code_assessmentkeeps its rule that a CODE result never stands in for an environment result, and calls_recorded_code. The gate calls_recorded_codedirectly, because the CLI measures a complete CODE assessment's findings even beside complete environments. There is one definition of a usable CODE record, andwait_for_review's behavior is unchanged.INCOMPLETE, so the gate givesNOT_COMPLETE.merge_gate.merge_gatein the contract is an opt-in server policy. It records a frozenALLOWorBLOCKdecision for a pull request head, with bypass receipts. The CLI's--fail-ondoesn't read it, and neither does this. Here the threshold is the caller's, and it works for any review, including organizations without a merge gate. The live review below hasmerge_gate: null. The README says which is which.ReviewOutcome, keywordfail_on. It sits where the review is already in hand, and the name matches--fail-onandfailOn. No new client method, soscripts/contracts.pyis unchanged. The names avoid the forbidden outcome words.ValueError. A typo like"HIGH"should fail loudly rather than gate on nothing.Verification
Against a real review. I installed Proofline on my fork and opened this branch there as Measure a review against a severity threshold like ci review --fail-on kingsleytorlowei/sdk-python#1. Proofline reviewed it: "no new findings".
wait_for_review(...).gate(...)on that review gaveNOT_REACHEDfor both thresholds, matching the console.open_itemson a completed code-only review.python3 scripts/check.pypasses end to end on Python 3.13: generation check, contracts,ruff check,ruff format --check,mypy,pytest(120 passed: 91 existing, 29 new), and both the wheel and sdist install smoke tests.tests/test_gate.pymirrors the CLI'sci_measures_only_a_complete_review_against_the_open_finding_countstable case for case. It adds:NEW,UNCHANGED,REINTRODUCED,RESOLVED, and the unknownCRITICAL), for both environment and code-only reviews;NOT_COMPLETEwhen code-only;wait_for_review(...).gate(...)against the loopback server, sync and async.Mutation check. I broke each rule in turn and confirmed a test fails every time:
RESOLVEDcounts;SERIOUSuses all findings;All 12 were caught.
🤖 Generated with Claude Code