Skip to content

Navigation Menu

Sign in
Sign up

feat: cache sidecar with optimistic balance enforcement - #333

Draft
kdhillon-stripe wants to merge 1 commit into
stripe:dev from
kdhillon-stripe:feat/metronome-net-balance-refactor
Draft

feat: cache sidecar with optimistic balance enforcement #333
kdhillon-stripe wants to merge 1 commit into
stripe:dev from
kdhillon-stripe:feat/metronome-net-balance-refactor

Conversation

@kdhillon-stripe

@kdhillon-stripe kdhillon-stripe commented May 11, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Summary

  • source-metronome refactor: switch to net_balance endpoint, remove credit_grants/invoices streams, add async webhook support, add skipLimit for rate_cards
  • cache-sidecar (apps/cache-sidecar): standalone HTTP process for optimistic balance enforcement — reads sync engine checkpoints from Redis, tracks pending usage events, returns merged balance in <50ms
  • pixel-app: rewired to call sidecar instead of Redis/Metronome directly

Architecture

Two Redis namespaces with strict ownership:

  • sync:* — checkpoint data written by sync engine (read-only to sidecar)
  • optimistic:* — pending events + derived balance (sidecar-owned)

Three HTTP endpoints: GET /v1/health, GET /v1/balance/:cid, POST /v1/events

Test plan

  • pnpm --filter @stripe/sync-cache-sidecar test (25 integration tests passing)
  • Start sync engine + sidecar + pixel-app, draw pixels, verify optimistic decrement
  • Verify reconciliation: after sync cycle, pending events pruned, balance converges
  • Verify dedup: same idempotency_key returns duplicate: true

🤖 Generated with Claude Code

kdhillon-stripe force-pushed the feat/metronome-net-balance-refactor branch 2 times, most recently from 4747a87 to 1852a72 Compare May 11, 2026 20:52
Adds a speculative balance cache sidecar (apps/cache-sidecar) and a
Metronome source connector (packages/source-metronome) for real-time
usage-based entitlement enforcement.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
kdhillon-stripe force-pushed the feat/metronome-net-balance-refactor branch from fa1f8cb to 48d8a4f Compare May 12, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /