fix(sdk): populate TierCounts in built-in store Stats implementations#481
Conversation
|
Warning Review limit reached
More reviews will be available in 30 minutes and 16 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughGo and Python store stats now return tier counts for in-memory and SQLite stores, and the conformance suites assert the new field for empty and populated stores. ChangesStore stats tier counts
Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
The StoreStats TierCounts field was left nil by the built-in SqliteStore
and InMemoryStore in both SDKs. The Client compensated by setting
{Local: TotalCount} after the fact, but callers using a Store directly
got incomplete stats, and behavior diverged from the PostgreSQL adapter
which already populates it.
Populate TierCounts as {Local: total} in all four built-in Stats methods
(Go and Python, sqlite and memory), matching the PostgreSQL adapter. Add
the assertion to the shared store conformance suites so every store,
including postgres, is held to it going forward.
Fixes #465
d07c71b to
f9bd376
Compare
There was a problem hiding this comment.
Pull request overview
Fixes a stats contract inconsistency across built-in Store implementations in both Go and Python SDKs by ensuring tier breakdowns are always populated (matching the PostgreSQL adapter behavior), and enforces this via shared conformance suites.
Changes:
- Populate
TierCounts/tier_countsin built-in SQLite and in-memory stores as{Local: total}(including{Local: 0}for empty stores). - Extend Go and Python store conformance suites to assert tier counts for both empty and populated stores.
- Align behavior across built-ins and the PostgreSQL adapter so direct Store consumers get complete stats without relying on Client-side compensation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/go/store_sqlite.go | Populate StoreStats.TierCounts with {Local: totalCount} in SQLite store stats. |
| sdk/go/store_memory.go | Populate StoreStats.TierCounts with {Local: len(...)} in in-memory store stats. |
| sdk/go/storetest/storetest.go | Add conformance assertions for tier counts (populated + empty store). |
| sdk/python/src/cq/store.py | Populate StoreStats.tier_counts with {Tier.LOCAL: total} in SQLite store stats. |
| sdk/python/src/cq/stores/memory.py | Populate StoreStats.tier_counts with {Tier.LOCAL: len(units)} in in-memory store stats. |
| sdk/python/tests/conformance.py | Add conformance assertions for tier counts (populated + empty store). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
StoreStats.TierCounts(Go) /tier_counts(Python) was returned nil by the built-inSqliteStoreandInMemoryStorein both SDKs. TheClientcompensated by setting{Local: TotalCount}after reading store stats, so callers going through the client were unaffected — but anyone using aStoredirectly got incomplete stats, and the built-ins diverged from the PostgreSQL adapter (added in #462) which already populates it.This sets
TierCountsto{Local: total}in all four built-inStatsmethods, matching the PostgreSQL reference exactly (including{Local: 0}for an empty store).Changes
sdk/go/store_sqlite.go,sdk/go/store_memory.go— populateTierCounts: {Local: total}sdk/python/src/cq/store.py,sdk/python/src/cq/stores/memory.py— populatetier_counts={Tier.LOCAL: total}sdk/go/storetest/storetest.go,sdk/python/tests/conformance.py— assert tier counts for populated and empty stores; these suites run against every store (sqlite, memory, postgres), so the contract is now enforced uniformlyTesting
make -C sdk/go testandmake -C sdk/go lintpassmake -C sdk/python test(461 passed) andrufflint/format passTierCounts = map[]/ emptytier_counts), then implemented to greenFixes #465
Summary by CodeRabbit
Bug Fixes
Tests