Skip to content

Show what a review run cost in review text output - #119

Open
HarshitSharma14 wants to merge 2 commits into
prooflinedev:mainfrom
HarshitSharma14:review-text-cost
Open

HarshitSharma14 wants to merge 2 commits into
prooflinedev:mainfrom
HarshitSharma14:review-text-cost

Conversation

@HarshitSharma14

@HarshitSharma14 HarshitSharma14 commented Nov 29, 2026 •

Copy link
Copy Markdown

Who this helps

Anyone who reads reviews in a terminal or a CI log and pays for them in credits: a team on the free review month watching how fast it is spending, an organization on capped credits, and anyone choosing a proofline scan --budget, which is required and has no default.

The review API already returns each run's charge to organization members (cost_microcredits), the share for review work (review_cost_microcredits) and what paid for it (cost_funding). The CLI's text output dropped all three, so the only way to see what a review cost was to read raw --json.

What changes

review, findings, rerun, scan and ci review text output now prints one line under the review link:

acme/web #42 run 2 at 89abcdef0123: COMPLETED
https://proofline.sh/orgs/.../reviews/...
Cost: 2.75 credits (review 2.5, walkthrough 0.25); paid by: free review month 2.75

Screenshots

The main and branch binaries, run against a local stand-in for the review API that serves the same pull-request review to three kinds of caller.

Completed review, organization member

Completed review: main prints no cost, the branch prints the cost line

Review still running: the cost so far

Running review: the branch prints the cost so far

Caller who is not an organization member: no line, same output as main

Hidden cost: output identical to main

Decisions

  • Exact amounts. Microcredits are converted with integer arithmetic and printed as exact decimals (1250000 -> 1.25, 3 -> 0.000003), never rounded or passed through a float.
  • "so far" while running. The API describes the total as the charge so far, so a PENDING or RUNNING review says so far.
  • Split only when it says something. The review/walkthrough split appears only when the review share lies within the total (at least zero and below it). Funding parts that paid nothing are left out, and a free run prints Cost: 0 credits with no payer.
  • No line when hidden. A caller who is not an organization member reads nulls, and an older server omits the fields. Both get no line, not a misleading 0.
  • A cost can never break a review. The fields are display-only, so a value the CLI cannot read is treated as absent instead of failing the review read, in the same spirit as CodeAssessmentRead. --json is unchanged and keeps the API's raw value.
  • ReviewCostFunding is checked against the public contract in tests/contract.rs, like the other model types.

Not in this PR

  • Remaining credits. The public API returns no credit balance, so the CLI has none to show. Organization-wide spend stays with proofline export spend.
  • Other output formats. --json already carries the raw fields. SARIF and workflow annotations describe findings, not billing, so they are unchanged.

Proofline review

I ran Proofline on this change in my fork (HarshitSharma14#1).

  • Finding (warning): a negative review_cost_microcredits would print a negative review cost and a walkthrough cost larger than the total. The guard rejected a share at or above the total, but not one below zero.
  • What I changed: agreed and fixed in 7ba7458. The split now prints only when the review share lies within the total, and the unit test covers negative shares, including i64::MIN.
  • Re-review: no new findings on the updated commit.

How I verified it

  • Unit tests in src/render.rs: exact formatting (zero, sub-credit, whole, negative, i64::MIN), split, payer list, so far, singular 1 credit, a free run, an inconsistent review share and a hidden cost.
  • An end-to-end test in tests/http.rs runs the real binary against the fake API for a charged review, a hidden cost (nulls), an older server (fields absent), unreadable cost values and a partly unreadable funding object, in both text and --json output.
  • Every step of the Checks workflow passes locally: cargo fmt --check, cargo clippy --locked --all-targets -- -D warnings, cargo test --locked and cargo deny check (cargo-deny 0.20.2). A release build prints a valid review --schema. The one failure on macOS, unattended_registration_preserves_settings_and_uses_the_installed_binary, also fails on main (unattended_registration_preserves_settings_and_uses_the_installed_binary fails on macOS (/var vs /private/var) #112, fixed by test(agent): resolve recorded executable path before comparing #116).
  • I have not run it against the live API.

The review API returns each run's charge (cost_microcredits), the share
for review work (review_cost_microcredits) and what paid for it
(cost_funding) to organization members, but the text output dropped all
three. Only --json carried them, so a person on the free review month or
a capped plan could not see what a review spent without reading raw JSON,
and had nothing to size `scan --budget` against.

Review text now prints one line below the review link, for example:

  Cost: 2.75 credits (review 2.5, walkthrough 0.25); paid by: free review month 2.75

- Amounts are exact decimal credits from integer microcredits, never
  rounded or converted through floats.
- A pending or running review reports its cost "so far".
- The walkthrough share appears only when it is positive; parts that
  paid nothing are left out.
- A caller the server hides the cost from, or an older server, gets no
  line. A cost value the CLI cannot read is treated as absent, so it
  never fails the review read; --json keeps the API's value unchanged.
The split guard dropped a review share at or above the total, but not
one below zero. A negative review_cost_microcredits then printed a
negative review cost and a walkthrough cost larger than the total.
Show the split only when the review share lies within the total; the
total itself still prints.
@mohsen1

mohsen1 commented Dec 3, 2026

Copy link
Copy Markdown
Member

I like this, but no need to make it so bold and colorful, also too much for just cost. make it just say the review cost after status, COMPLETED that is

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.

2 participants