Skip to content

Push channel, API quota ledger, recurring invoices and DR promotion drill - #1601

Merged
github-actions[bot] merged 11 commits into
Smartdevs17:mainfrom
kingdiggydoe-lab:feat/push-quota-recurring-invoices-dr
Nov 24, 2026
Merged

github-actions[bot] merged 11 commits into
Smartdevs17:mainfrom
kingdiggydoe-lab:feat/push-quota-recurring-invoices-dr

Conversation

@kingdiggydoe-lab

Copy link
Copy Markdown
Contributor

Closes #1344
Closes #1346
Closes #1340
Closes #1348

What this adds

  • Implement push-first notification channel with silent-retry policy #1344 push channel (backend/src/services/pushChannel.ts). Pushes to every registered device of a user, retrying transient transport failures in the background with capped exponential backoff and jitter. The user is told only the final outcome. Permanent failures are not retried. A token the provider reports as unregistered is removed, and the other devices still get the message. no_devices is reported separately from failed, so the caller can fall back to another channel. Tokens never appear in observability events; only a hash hint does.
  • Build consumption-based API quota ledger with weekly caps #1346 quota ledger (backend/src/services/quotaLedger.ts). Charges units per API key against a weekly cap. Weeks run Monday 00:00 UTC to the next Monday. A request that would exceed the cap is rejected and charges nothing. A replayed idempotency key returns the original result and charges nothing more. The check and the write are one atomic store call.
  • Implement recurring invoice generation with FX-adjusted amounts #1340 recurring invoices (backend/src/services/recurringInvoices.ts). Issues one invoice per due period, in the invoice currency, converted at the rate for that issue date, with an optional FX spread in basis points. The rate and its date are stored on each invoice. The key <templateId>:<issueDate> makes runs idempotent. If no usable rate is available, the period is left for the next run; it is never issued at a zero or stale rate.
  • Implement warm-standby disaster-recovery replica with promotion drill #1348 warm-standby promotion drill (scripts/dr-drill.sh, infra/dr/). Checks that the standby is in recovery and within a replay-lag budget. With --execute and an explicit confirmation, promotes it, checks that it accepts a write, and checks the time against an RTO budget. It refuses identical primary and standby URLs. The runbook is in infra/dr/README.md, and docs/DISASTER_RECOVERY.md links to it. It is separate from the existing restore-from-backup drill.

Tests: Vitest suites for the three services (*.test.ts), and scripts/dr-drill.test.mjs for the drill's refusal guards, which run without Postgres.

Not done or not verified

  • Nothing was run. Vitest, the TypeScript build and node --test have not been executed on this branch.
  • Not wired into the running app. The push channel is not registered with the notification dispatcher or channel registry. The quota ledger is not in any API middleware. The recurring invoice generator is not scheduled and has no store implementation against Prisma. The new modules are used only through their own tests.
  • No database implementations. The quota store and invoice store interfaces need database implementations. The quota store's atomicity guarantee depends on a conditional insert, which the in-memory store has but a database store must provide.
  • Observability. Push events go to the shared logger by default. No metrics or traces are emitted.
  • DR drill has not been run against Postgres. The promotion path needs a drill on a disposable replica before it is relied on. The script is committed without its executable bit, because the API cannot set file modes; run it with bash.
  • The guard test is not in a package script. scripts/dr-drill.test.mjs runs with node --test scripts/dr-drill.test.mjs. It is not added to package.json.
  • Drips Wave labels from the issues were not applied.

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@kingdiggydoe-lab is attempting to deploy a commit to the smartdevs17's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 24, 2026

Copy link
Copy Markdown

@kingdiggydoe-lab Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@github-actions
github-actions Bot merged commit 405aa72 into Smartdevs17:main Nov 24, 2026
2 of 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

1 participant