Skip to content

feat: add dependency resilience policy, billing replay fallback, and hardening - #3

Merged
Arcoders merged 5 commits into
masterfrom
LASAGNA-300526/billing-resilience-hardening
Jun 1, 2026
Merged

feat: add dependency resilience policy, billing replay fallback, and hardening#3
Arcoders merged 5 commits into
masterfrom
LASAGNA-300526/billing-resilience-hardening

Conversation

@Arcoders

Copy link
Copy Markdown
Owner

Description

This PR closes a bunch of edge-case and failure-mode gaps, plus it adds one system-level improvement that felt worth doing while we were in there. No breaking changes: everything new is opt-in or defaults to the old behaviour.

What changed

We now have a small resilience helper that wraps calls to backing services. When Redis is unavailable, we used to either swallow the error silently or let it blow up in an ugly way. Now you can tell the package what to do per dependency: fail open and return a fallback, or fail closed with a clean exception that includes a Retry-After header. It logs the problem, marks the OpenTelemetry span, and emits a single event that ops can alert on, so any part of the system that relies on Redis will trigger the same signal. We applied this to quotas, rate limiting, cache, and metrics, so they degrade sensibly instead of breaking unpredictably.

Billing replay runs were fragile because Stripe drops events after about 30 days. If a tenant's replay job ran late, it would just fail to retrieve the event. We now keep a minimal, PII-free copy of each event locally, just enough to rebuild what the dispatcher needs, and fall back to that when Stripe can't give us the original. This makes late replays work again. While there, we also fixed some wrong JSDoc that claimed a UUID idempotency key when it was actually a deterministic minute bucket.

On the hardening side, the circuit breaker now reloads its state from Redis on startup, so if a tenant database was marked as down before a deploy, we won't waste time probing it again right away. The schema driver no longer silently swallows connection release errors. We dropped a dead cache key from the feature flag service and made a logger lazy-loaded so unit tests don't need a real one.

All of this is covered by new unit and integration specs, and we turned on coverage checks to keep it that way. We also added proper docs pages for configuration, exceptions, troubleshooting, and an API reference, because reading the source code to figure out how things work wasn't great.

@Arcoders
Arcoders merged commit de1984f into master Jun 1, 2026
3 checks passed
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