Skip to content

Add --fail-on to proofline findings - #114

Open
jcatalaamat wants to merge 3 commits into
prooflinedev:mainfrom
jcatalaamat:feat/findings-fail-on
Open

jcatalaamat wants to merge 3 commits into
prooflinedev:mainfrom
jcatalaamat:feat/findings-fail-on

Conversation

@jcatalaamat

Copy link
Copy Markdown

Add --fail-on to proofline findings

Who it helps

Anyone who wants to gate a script on a review that already exists: a merge-queue or release step, a local pre-merge check, or a coding agent deciding whether a branch is ready. Today they have two options, and neither fits:

  • review --pr N --fail-on serious gates, but it may request a review: it needs reviews:request, can start work, and can spend credits.
  • findings --pr N only reads, but ignores any threshold, so the script has to parse --json itself. That means reimplementing the open_items rules (dismissed and accepted findings don't count; PR reviews count both lanes) and getting them subtly wrong.

What it does

proofline findings --fail-on warning|serious measures the review that findings reads, using the same review_verdict that review --fail-on already uses. It does not request a review.

Review read Exit
Complete, nothing open at or above the threshold 0
Complete, an open finding at or above the threshold 3
Not finished (without --wait), incomplete, or failed 2, as today
Complete PR review whose answer has no open_items 4: the threshold can't be measured, so it isn't a pass

It works with every selector (--pr, --head, --review, or the checkout's HEAD by default), and with --json, --sarif and --wait. It changes only the exit code and one stderr line. stdout keeps exactly the same shape, so existing parsers are unaffected.

# Block a release if the newest review of this PR has an open SERIOUS finding.
proofline findings --pr 42 --fail-on serious

# Same gate for the commit you're about to ship, waiting for its review.
proofline findings --head "$(git rev-parse HEAD)" --wait --fail-on warning

# Upload SARIF and gate in one read.
proofline findings --review "$REVIEW_ID" --sarif --fail-on serious > proofline.sarif

Decisions

  • Reuse, don't re-derive. The flag passes through to the existing show(…, fail_on) path, so findings, review and ci review can't drift apart on what counts. This PR adds no new verdict logic.
  • Not finished is never a pass. Unlike review --fail-on, I didn't make the flag require --wait. A one-shot read of a running review already exits 2, which is the safe answer for a gate, and a script that wants to block can add --wait. Both behaviours are tested.
  • No new conflicts. --fail-on is compatible with --sarif and --json because reading and gating are independent; the output is unchanged.
  • Out of scope: explaining which finding the verdict counted. Show what the --fail-on verdict counted in review output #104 covers that across every --fail-on command, and this flag picks it up for free.

Changes

  • src/lib.rs: FindingsArgs gains --fail-on <SEVERITY>, passed to show.
  • tests/http.rs:
    • The existing --fail-on matrix (dismissed, warning-only, serious, missing open_items, incomplete, CODE-lane, partial and other-head cases) now also runs findings --review and findings --head, beside ci review and review --pr, and asserts that findings sends only GETs.
    • The ci_console fake now names acme/app in its review filters so --head resolves.
    • New findings_fail_on_never_passes_a_review_that_has_not_finished: without --wait the run exits 2; with --wait it exits 3 once the review completes.
  • README.md: one paragraph next to review --fail-on.

How I verified it

  • cargo fmt --check passes.
  • cargo clippy --locked --all-targets -- -D warnings passes.
  • cargo test --locked: every suite passes. That includes 68 unit tests and 41 in http.
  • I reverted only the src/lib.rs change and both new or extended tests fail, so they exercise the feature.
  • cargo deny check: advisories ok, bans ok, licenses ok, sources ok.
  • Ran the built binary against a local fake of the review API (three PRs: an open SERIOUS finding, a dismissed one, a running review):
$ proofline findings --repo acme/app --pr 12 --fail-on serious
PULL_REQUEST run 1 at 89abcdef0123: COMPLETED
http://127.0.0.1:18765/orgs/by-id/0190f3a0-…/reviews/0190f3a0-…-000000000012

production: COMPLETED, 1 findings
  SERIOUS  data_integrity  Orders are dropped when the payment webhook retries.
           impact: paid orders are lost
           id: 0190f3a0-0000-7000-8000-0000000000f2
The review has an open finding at or above the --fail-on severity.
[exit 3]

$ proofline findings --repo acme/app --pr 13 --fail-on warning   # finding dismissed
…
[exit 0]

$ proofline findings --repo acme/app --pr 14 --fail-on serious   # still running
PULL_REQUEST run 1 at 89abcdef0123: RUNNING
…
The review has not finished; pass --wait to wait for its result.
[exit 2]

$ proofline findings --review 0190f3a0-…-000000000012 --sarif --fail-on serious | wc -c
3157
[exit 3] The review has an open finding at or above the --fail-on severity.

This branch has not been deployed

No deployments
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