Skip to content

🤖 tests: characterize session usage repricing in WorkspaceStore - #6306

Merged
ThomasK33 merged 1 commit into
mainfrom
tests/workspace-store-session-usage-pricing
Oct 13, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
tests/workspace-store-session-usage-pricing

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Adds characterization tests for how WorkspaceStore reprices loaded session usage. They pin which rows keep their recorded costs (gateway-billed rows) and which rows get the current model pricing. Test-only change, no production code changes.

Background

This PR is part of the CRAP code-quality campaign. isCostsIncludedEntry in src/browser/stores/WorkspaceStore.ts had CC 18 and no test reached it (CRAP 342, the highest score in the file). With these tests, merged CI coverage plus a local run scores it at 100% coverage, CRAP 18.

Implementation

The tests go through the public store surface: a getSessionUsage response, the provider config (providers.getConfig, onConfigChanged), and getWorkspaceUsage().sessionByModel / .lastRequest. They cover:

  • stale recorded costs are repriced (one non-zero component is enough);
  • costsIncluded: true keeps zero costs, and it wins over hasUnknownCosts;
  • legacy all-zero rows of a billable model stay zero (no unknown-cost flag);
  • hasUnknownCosts: true rows get priced;
  • all-zero rows of an unpriced model are repriced (they get flagged as unknown, not treated as gateway-billed);
  • a mapped custom model is classified by the pricing of its mapped model;
  • a provider config change that adds a mapping prices rows that were unknown before.

Each workspace gets a caught-up chat first. Before catch-up, getWorkspaceUsage serves the pre-replay snapshot, which would hide the repriced rows.

Validation

  • 8 mutants of isCostsIncludedEntry and its repriceSessionUsage call sites (drop each check, swap the marker order, use the raw model for pricing, check only the input cost, never set hasTokens, ignore the marker for lastRequest): every mutant fails at least one new test.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:24:43.421875Z 3b3287f PR opened
🔒 Security Review ✅ Completed 2026-10-13T08:25:05.810886Z 3b3287f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 6324f11 Oct 13, 2026
33 checks passed
@ThomasK33
ThomasK33 deleted the tests/workspace-store-session-usage-pricing branch October 13, 2026 08:53
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