Skip to content

The review session API returns the checks the review ran, its model cost, and whether it goes on in parts - #961

Merged
coderhelm[bot] merged 1 commit into
plan-builds-every-repofrom
reviewer-session-checks-cost
Dec 3, 2026
Merged

coderhelm[bot] merged 1 commit into
plan-builds-every-repofrom
reviewer-session-checks-cost

Conversation

@nambok

@nambok nambok commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The review session API now returns what its page needs to say what a review checked and what it cost: the checks the review ran on the change (each command, its result and why it didn't pass), the review's model cost, and whether a session is one part of a review read in parts.

Pairs with the dashboard change: CoderHelm/coderhelm#539. Based on #956 (plan-builds-every-repo), because the dashboard's API field list already names #956's fields; GitHub moves this onto main when #956 merges.

Changes

  • common::review_session: the verification run as data (VerificationRecord, one CheckRun per command with passed, failed, couldnt_run or skipped and a reason), the model cost in whole millionths of a dollar (ADD, so every invocation of a job adds to it), and goes_on for a session that read one part of a large pull request. Reads and writes are bounded and tested.
  • common::usage: a SpendTally task-local. Every model call that already counts against a run's allowance also adds to the tally, whatever allowance it runs under, so a review job can read what it spent.
  • Worker: the review dispatch runs each job under a tally. review_verify::judge and Verification::not_run keep the run as data next to the markdown they already wrote. The review records it on its session, records off when the repository's reviews don't run checks, adds its spend before the session closes (and anything spent after, such as a reply), and marks a part that goes on. The last step of such a part now reads "Read this part; the review goes on in its next part: …".
  • Gateway: GET /api/reviewer/session returns verification (SessionVerification with SessionCheck rows), cost_usd and goes_on. Older sessions return null, null and false. docs/api/openapi.json is regenerated.

Verification

  • cargo fmt --all --check, rustfmt --check --edition 2021 worker/src/passes/incidents/*.rs
  • cargo clippy --all-targets -p common -p worker -p gateway -- -D warnings
  • cargo test -p common -p worker -p gateway
  • python3 .github/scripts/brand_spelling.py, python3 .github/scripts/domain_examples.py
  • New tests: the verification record round-trips and is bounded, spend is kept in whole millionths, a part says so, the tally counts spend inside any allowance and nothing outside it, and the session API returns all three (and null on older sessions).

…ost, and whether it goes on in parts

A review's session page could say what was decided but not what was
verified or what it cost. The verification run existed only as markdown
in the review body, and per-review spend wasn't kept anywhere.

- common::review_session keeps the verification run as data (one row per
  command: passed, failed, couldnt_run or skipped, with a reason), the
  model cost in whole millionths of a dollar, and goes_on for a session
  that read one part of a large pull request.
- common::usage gains a SpendTally task-local; every model call adds to
  it, whatever allowance it runs under.
- The review dispatch runs each job under the tally. The worker records the run (or "off" when checks are turned off), adds
  the job's spend before its session closes, and marks a part that goes on.
- GET /api/reviewer/session returns verification, cost_usd and goes_on;
  older sessions return null, null and false. openapi.json regenerated.

@coderhelm coderhelm Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved with notes c60727a (merged)


/// Dollars the current tally counted since this was last asked, and zero
/// outside one: a review job adds it to its session as it ends.
pub fn take_spend_tally() -> f64 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: A parallel structure next to an existing one (scope, not verified)

services/common/src/usage.rs adds take_spend_tally next to the existing take_run_spend. Extend the existing one (add the entries or the parameter there) and remove the new one. If the ticket truly needs it, say why on a line Wider than the ticket: services/common/src/usage.rs: <why>.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

pub const GOES_ON: &str = "goes_on";

/// Mark `job`'s session as one part of a review that goes on in its next job.
pub async fn note_goes_on(dynamo: &DynamoClient, table: &str, team_id: &str, job: &str) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 FYI: Near-identical helpers added together (scope, not verified)

services/common/src/review_session.rs adds note_goes_on next to note_verification, added in the same change. Keep one helper with the shared logic (a parameter for what differs) and call it from both places. If the ticket truly needs it, say why on a line Wider than the ticket: services/common/src/review_session.rs: <why>.

FYI, not a block: on the whole picture this is not a named correctness, security or data-loss problem to hold the merge on.

@coderhelm
coderhelm Bot merged commit d9adde3 into plan-builds-every-repo Dec 3, 2026
2 checks passed
@coderhelm

coderhelm Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Auto-merge

  • ✅ CoderHelm approved
  • ✅ CI green
  • ✅ Merged into plan-builds-every-repo
    The rest is in the pull request description.

coderhelm Bot added a commit that referenced this pull request Dec 4, 2026
#961 merged into `plan-builds-every-repo` after #956 had merged that branch into `main`, so its change never reached `main`. This is that change, picked onto `main`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ch-review CoderHelm reviews this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant