feat: define typed billable meters - #1554
Conversation
|
Warning Review limit reached
Next review available in: 25 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review 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 refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (43)
✨ 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 |
📊 Benchmark Results✅ All benchmarks passed
Updated: 2026-07-25T21:25:49.812Z · Commit: a5e90f9 |
|
Superseded by #1555, which carries typed usage envelopes through Redis and Drizzle and includes the required migrations. |
Outcome
@croco/metering-corenow provides definition-firstdefineMeter()contracts with brandedMeterRefvalues, deterministic serializable descriptors, inferred enum dimensions, explicit aggregation and unit, and local or billing-required intent.Typed
MeteringService.record(meter, input)calls require exact declared dimensions, finite SUM values, COUNT default values, and stable event IDs for billing-required meters at both compile time and runtime. Application metadata remains separate from billing dimensions. Bare@Metered({ meter })is limited to dimensionless local COUNT meters, while the existing string-based record and decorator APIs remain source-compatible.Stable validation Problems, negative compile fixtures, runtime regression coverage, generated API docs, public snapshots, README guidance, and changesets for metering-core and the shared Problem registry are included.
Fixes #1515
Verification
@croco/metering-core— 191/191 tests; lint, typecheck, and ESM/CJS/declaration build passedpnpm public-api:check— 111 package snapshots matchpnpm problem-registry:check— 456 codes from 456 discoveriespnpm docs:api:check— 112/112 build tasks; generated API docs matchpnpm check— repository profile passed; 21/22 applicable gates passed and one was not applicable before commitReview gates
Residual risk
Provider delivery and durable financial storage remain separate integration concerns. Billing-required callers must supply an event ID that is stable across retries; this API validates presence and shape but cannot prove business-level identity stability. The legacy string path intentionally retains its existing generated-id and open-metadata behavior.