Skip to content

sdk/summary: surface unpriced turns instead of silently reporting them as $0#474

Merged
willwashburn merged 4 commits into
mainfrom
advisor/002-unpriced-turn-visibility
Jun 10, 2026
Merged

sdk/summary: surface unpriced turns instead of silently reporting them as $0#474
willwashburn merged 4 commits into
mainfrom
advisor/002-unpriced-turn-visibility

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Summary

When a turn's model has no entry in the vendored models.dev pricing snapshot, cost_for_turn returns None and every summary aggregation counts the turn at $0 — with no signal anywhere. This happens on every new model release until the manual snapshot bump lands (#469, #472), so burn under-reports spend exactly when users adopt a new model. This PR makes the gap visible without inventing numbers:

  • tally_unpriced() in analyze/cost.rs: counts turns whose model has no pricing entry and collects the distinct model names. lookup_model_rate semantics are deliberately unchanged — no fallback rates; estimated-but-wrong totals would be worse than a visible gap.
  • unpricedTurns / unpricedModels on Summary and SummaryGroupedReport (additive, backward-compatible serde). The grouped tally runs over the same turn slice that feeds the table rows, so the count always agrees with what's displayed.
  • CLI warning footer on burn summary (stderr, human mode only) when unpriced turns exist, pointing at pnpm run pricing:update or the $RELAYBURN_HOME/models.dev.json override. JSON output carries the fields automatically.
  • Node facade type declarations + changelog bullet.

Merge order

Merge after #473 — this branch carries an identical-content copy of its rustfmt fix (started from the same base before #473 existed); git merges it cleanly.

Verification

  • 4 new tests: tally_unpriced unit tests (dedup, all-priced), compute_summary field population, and an end-to-end summary_report grouped test through a real SQLite ledger with an unknown model.
  • Full gates green: fmt, clippy -D warnings, 815 SDK tests + full workspace, npm suites (MCP 21/21).

Plan: plans/002-unpriced-turn-visibility.md (advisor-generated, executor-implemented, independently reviewed).

🤖 Generated with Claude Code

willwashburn and others added 2 commits June 10, 2026 11:03
Add `tally_unpriced` helper in cost.rs that counts turns with no pricing
table entry and collects their model names. Wire the tally into both
`compute_summary` (slim verb) and `SummaryGroupedReport` (grouped report),
adding `unpriced_turns`/`unpriced_models` fields to each. Render a warning
footer to stderr in `burn summary` human output so users know when cost
totals are incomplete. New fields are additive/optional in JSON output; four
new SDK tests and two updated CLI fixture constructors.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07a1f7fd01

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// TS uses `process.stdout.write(lines.join('\n'))` — no trailing newline.
print!("{}", out);

if report.unpriced_turns > 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include unpriced fields in CLI JSON output

When burn summary --json is used with turns from an unknown model, this new warning path is skipped because emit_grouped returns through emit_json, and grouped_json_value manually builds the payload without inserting unpricedTurns or unpricedModels. That leaves JSON callers with the same silent $0 under-reporting this change is intended to surface; add the two fields to the grouped JSON payload when present.

Useful? React with 👍 / 👎.

Comment on lines +118 to +120
unpricedTurns?: number;
/** Distinct model names (first-seen order) that had no pricing entry. */
unpricedModels?: string[];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Propagate unpriced fields through the Node binding

For @relayburn/sdk callers with unknown-model turns, these declarations promise unpricedTurns/unpricedModels, but the napi Summary object in crates/relayburn-sdk-node/src/lib.rs still has no such fields and its From<sdk::Summary> conversion drops them. The runtime result from summary() therefore omits the new signal while TypeScript suggests it may exist; extend the binding struct and conversion as well.

Useful? React with 👍 / 👎.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@willwashburn, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 9 minutes and 10 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1830cdde-cc7a-4e6f-a8ae-bd86cf1a17f5

📥 Commits

Reviewing files that changed from the base of the PR and between 6e29a1f and 53bf81a.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • crates/relayburn-cli/src/commands/summary.rs
  • crates/relayburn-sdk/src/analyze.rs
  • crates/relayburn-sdk/src/analyze/cost.rs
  • crates/relayburn-sdk/src/query_verbs.rs
  • memory/workspace/.relay/state.json
  • packages/sdk-node/src/index.d.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch advisor/002-unpriced-turn-visibility

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@willwashburn willwashburn merged commit 4539941 into main Jun 10, 2026
1 of 2 checks passed
@willwashburn willwashburn deleted the advisor/002-unpriced-turn-visibility branch June 10, 2026 16:25
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