refactor(usage): let a store answer precomputed [ING-586] - #6428
Conversation
|
Automated pre-review (advisory, not a required check) — verdict: HOLD · CI green HOLD — the new precomputed-store path is not connected to production.
|
e09c046 to
93fe0c3
Compare
05ea5d9 to
5000b01
Compare
93fe0c3 to
2c07c65
Compare
5000b01 to
4f0485c
Compare
4f0485c to
93de086
Compare
|
Automated pre-review (advisory, not a required check) — verdict: PASS · CI green PASS — The bucket reader/store, provider threading, aggregator reuse, and cache-bypass contract are consistent with the existing aggregation boundaries and have focused coverage for totals, grouping, fallbacks, delegation, and cache behavior. Non-blocking: the new store spec places several |
e6efaa0 to
68ee734
Compare
## Context A fee computed out of the pre-aggregated ClickHouse buckets is already fresh, so the fee cache has nothing to add to it: caching it would put back the staleness the buckets remove. Nothing can express that today, as neither a store nor the fee cache knows that some answers need no caching. ## Description Add `precomputed?` to the event stores, false everywhere but on the new `UsageBucketStore`, a decorator that answers a covered aggregation from a `UsageBucketSet` and delegates the rest to the store it wraps. An aggregation forwards the predicate to its store, and the charge cache middleware takes a per-filter `bypass` that skips the cache round-trip entirely. The charge service now holds one event store provider for the whole computation, passed by callers that run one of their own, and reuses a single aggregator per pricing bucket. The zero-units hydration used to build a second aggregator for the same bucket, so the aggregation factory is now called once where it was called twice. Nothing mints a `UsageBucketStore` yet, so `precomputed?` is false and the bypass is never taken: the routing that does comes next. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
68ee734 to
bd343d9
Compare
|
Automated pre-review (advisory, not a required check) — verdict: PASS · CI green PASS — The preparatory store decorator, provider reuse, cache bypass, and aggregator memoization are consistent with the existing interfaces, and the added specs cover their substantive behavior. Non-blocking: the guard-clause modifiers in |
Context
A fee computed out of the pre-aggregated ClickHouse buckets is already fresh, so the charge cache
has nothing to add to it: caching it would put back the staleness the buckets remove. Nothing can
express that today, as neither an event store nor the cache knows that some answers need no caching.
Description
precomputed?to the event stores, false everywhere but on the newUsageBucketStore, adecorator answering a covered aggregation from a
UsageBucketSetand delegating the rest.bypasson the charge cache middleware, skipping the cache round-trip.zero-units hydration used to build a second one for the same bucket.
Nothing mints a
UsageBucketStoreyet, soprecomputed?is false and the bypass is never taken.The routing that reaches for both is the next PR of the stack.