Skip to content

🤖 tests: characterize consumer breakdown cache hydration in WorkspaceStore - #6308

Merged
ThomasK33 merged 1 commit into
mainfrom
tests/workspace-store-consumer-cache
Oct 13, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
tests/workspace-store-consumer-cache

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

Adds characterization tests for the Costs tab consumer breakdown in WorkspaceStore: when the store shows the token-stats cache persisted in session-usage.json, and when it recounts instead. Test-only change, no production code changes.

Background

This PR is part of the CRAP code-quality campaign. No test called getWorkspaceConsumers (CC 8, CRAP 72) or getMaxHistorySequence (CC 6, CRAP 42) in src/browser/stores/WorkspaceStore.ts. With these tests, merged CI coverage plus a local run scores both at 100% coverage (CRAP 8 and 6).

Implementation

Each test loads a session usage with a tokenStatsCache, then replays a two-message history (sequences 3 and 7) and reads getWorkspaceConsumers. The chat script holds the replay until the session usage is in memory, so catch-up sees the cache. The tests cover:

  • a matching cache (count, newest sequence, model, provider fingerprint) is shown as is, with no recount;
  • a different newest history sequence or message count starts a recount;
  • a cache without maxHistorySequence falls back to the message count;
  • after a provider config change drops the cache, the next getWorkspaceConsumers read schedules the recount.

Validation

  • Mutants (newest sequence computed as the minimum, newest sequence always unknown, the sequence check or the count check dropped, the lazy trigger in getWorkspaceConsumers removed): each fails at least one new test.
  • One mutant survives: dropping the caughtUp condition in getWorkspaceConsumers. Before catch-up the aggregator holds no messages in these flows, so the condition changes nothing a test can see here. I did not add a test for it.

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:36:29.933860Z dc3cfae PR opened
🔒 Security Review ✅ Completed 2026-10-13T08:39:59.510714Z dc3cfae 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 b86af9f Oct 13, 2026
33 checks passed
@ThomasK33
ThomasK33 deleted the tests/workspace-store-consumer-cache branch October 13, 2026 08:59
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