Skip to content

fix(eval): cost readout counts zero-usage cases as $0 + follow-up ledger capture#1050

Merged
BigSimmo merged 3 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb
Jul 22, 2026
Merged

fix(eval): cost readout counts zero-usage cases as $0 + follow-up ledger capture#1050
BigSimmo merged 3 commits into
mainfrom
claude/clinical-kb-pwa-review-asi3wb

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

Two small post-program items:

Cost readout fix (issue #14). Every 44-case canary printed Estimated cost USD: n/a despite the pricing rates being set since PR #1017. Root cause: extractive/unsupported cases make no provider call, their per-case estimate was null, and the all-or-nothing total nulled on any null case — so one extractive answer hid the whole run's spend. A no-usage case costs exactly $0 when rates are configured; null now stays reserved for rates-unconfigured, so the total keeps meaning "cannot estimate". One-line change in scripts/eval-quality.ts plus an aggregation pin test (priced + zero-cost cases sum; a genuinely unpriced case still yields n/a).

Outstanding-issues capture (#12#17). The post-program follow-up queue is now durable ledger memory: the monitoring retrieval-depth trio, comparison-class coverage, this cost fix, the parked E-3d residual, the operator metadata-refresh task, and the Sunday 2026-07-26 scheduled-artifact read.

RAG impact: no retrieval behaviour change — eval reporting + docs only; no src/lib/rag/** edit.

Verification

  • tests/eval-quality.test.ts — 28/28 including the new aggregation pin
  • typecheck, prettier clean

Risk and rollout

  • Risk: low — eval report arithmetic only; gates and thresholds untouched.
  • Rollback: plain revert.
  • Provider or production effects: none (the fix changes how already-collected usage is summed).

🤖 Generated with Claude Code

https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved evaluation cost reporting: cases with configured cost rates now show $0 when no provider activity is recorded, while other missing-usage scenarios remain unavailable to avoid incorrect totals.
    • Updated total cost aggregation to stay unavailable when any case has an unpriceable (null) estimate.
  • Tests

    • Added coverage for summing priced, zero-cost, and unpriceable evaluation cases in quality reports.
  • Documentation

    • Refreshed the outstanding-issues tracker with new open items covering monitoring, comparison, evaluation readouts, governance metadata, and scheduled-run artifact handling.

claude added 2 commits July 21, 2026 23:58
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
…ed (#14)

The 44-case eval:quality report printed 'Estimated cost USD: n/a' even with
the RAG_EVAL_*_USD_PER_MILLION rates set (PR #1017): every extractive or
unsupported case makes no provider call, its per-case estimate was null, and
the all-or-nothing total nulled on any null case. A no-usage case costs
exactly $0 when rates are configured — null stays reserved for
rates-unconfigured, so the total keeps meaning 'cannot estimate'. Aggregation
pin added.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@supabase

supabase Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b5614d68-2c72-4017-875d-b13365c81d44

📥 Commits

Reviewing files that changed from the base of the PR and between 2ed9ce1 and eb1046b.

📒 Files selected for processing (2)
  • docs/outstanding-issues.md
  • scripts/eval-quality.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/eval-quality.ts

📝 Walkthrough

Walkthrough

The RAG evaluation report now distinguishes zero-cost cases that never contacted the provider from attempted cases with missing usage data. The outstanding-issues tracker advances its identifier and adds six open items.

Changes

RAG evaluation cost handling

Layer / File(s) Summary
Configured-rate cost aggregation and validation
scripts/eval-quality.ts, tests/eval-quality.test.ts
estimatedCostUsd returns 0 for cases that never used the provider when rates are configured, while attempted but unmeasured cases remain null; tests verify priced, zero-cost, and unpriceable aggregation.

Outstanding-issues ledger

Layer / File(s) Summary
Issue tracker metadata and entries
docs/outstanding-issues.md
The issues:next-id pointer changes from 018 to 024, and open items #018#023 are added.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the two main changes: eval cost readout fix and outstanding-issues ledger capture.
Description check ✅ Passed The description covers Summary, Verification, and Risk/Rollback, and includes the key implementation details; only the Notes/clinical preflight sections are light or omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/clinical-kb-pwa-review-asi3wb

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

@BigSimmo
BigSimmo marked this pull request as ready for review July 22, 2026 01:18

@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: 2ed9ce125d

ℹ️ 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".

Comment thread scripts/eval-quality.ts Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/outstanding-issues.md`:
- Line 48: Fix the unbalanced Markdown strikethrough markers in issue `#015` by
removing or correctly balancing the ~~ delimiters around “6 generation attempts”
and “$2-4”. Ensure only the intended text is struck through and the remaining
description renders normally.
- Line 47: Update issue `#014` in the outstanding-issues document to reflect that
the PR resolves configured-rate and zero-cost eval cost reporting. Move it to
the resolved archive or rewrite the row to describe only any remaining
validation work, ensuring the outstanding-issues report no longer presents the
completed estimator fix as open.

In `@scripts/eval-quality.ts`:
- Around line 1141-1145: Update the estimatedCostUsd calculation in the
evaluation result to distinguish provider calls from cases with no provider
call. Use openAIRequestIds or modelUsed together with an explicit usage-present
signal, rather than hasOpenAIUsage alone, so generated answers with missing
token metadata return null while confirmed no-call cases return $0 and
usage-bearing calls still use estimateCostUsd.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 209d5a86-8960-477e-9b76-80c8a462760f

📥 Commits

Reviewing files that changed from the base of the PR and between ce32fe1 and 2ed9ce1.

📒 Files selected for processing (3)
  • docs/outstanding-issues.md
  • scripts/eval-quality.ts
  • tests/eval-quality.test.ts

Comment thread docs/outstanding-issues.md Outdated
Comment thread docs/outstanding-issues.md Outdated
Comment thread scripts/eval-quality.ts Outdated
@BigSimmo
BigSimmo enabled auto-merge (squash) July 22, 2026 01:23
…cile issue IDs

Review findings on PR #1050 (Codex P2 + CodeRabbit major, converged): a case
that attempted generation but lost the provider response (timeout, missing
output) has real-but-unrecorded token spend — keying $0 off hasOpenAIUsage
alone would report those as fully priced. $0 now applies only when no request
id, no model, and no generation time were recorded; provider-attempted cases
without usage metadata stay null (n/a total). Also resolves the ledger merge
conflict against #1049's concurrent ID allocation: main's #12-#17 stand, this
session's six items renumber to #18-#23 (next-id 024), the cost-readout row
is rewritten as post-fix validation only (CodeRabbit), and the unbalanced
strikethrough tildes in the E-3d row are fixed (CodeRabbit).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
@BigSimmo
BigSimmo merged commit 9fb9bc7 into main Jul 22, 2026
74 checks passed
@BigSimmo
BigSimmo deleted the claude/clinical-kb-pwa-review-asi3wb branch July 22, 2026 01:26
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