Skip to content

feat(billing): add metered usage accumulator (#1329 #1330 #1331 #1332) - #1602

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
opascal221-design:fix/1329-1330-1331-1332
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
opascal221-design:fix/1329-1330-1331-1332

Conversation

@opascal221-design

Copy link
Copy Markdown
Contributor

Closes #1329
Closes #1330
Closes #1331
Closes #1332

#1330 — Implement usage-metered billing with per-second settlement accumulator

  • Adds backend/src/services/meteredBilling.ts: pure functions (no clock, DB or network) for a per-second accumulator. Amounts are bigint in the smallest unit.
  • Whole seconds are charged and leftover milliseconds are carried forward, so many small ticks bill exactly the same as one long tick. Stopped meters and backwards clocks charge nothing.
  • Plans support a free-seconds allowance and a per-period cap. Settlement batches are taken at a threshold (or forced when a period closes) and get a deterministic id, so a retried settlement is recognisable as a duplicate.
  • Adds backend/src/services/__tests__/meteredBilling.test.ts covering accrual, carry, free seconds, the cap, start/stop, settlement and period rollover.

#1329, #1331, #1332 — not implemented in this PR

  • The work-proof challenger (workProofChallenger.ts), collaboration log (collabLog.ts) and travel-rule exchange (compliance/travelRule.ts) are not included. Their issues are linked above because the branch covers the batch, but each still needs its own implementation.

Not done / caveats

  • The accumulator is not yet wired to a route, storage or an observability hook; it is the pure core those would call.
  • No install, build or tests were run here, so CI is the first run. I checked the test expectations by hand against the code.

@vercel

vercel Bot commented Nov 24, 2026

Copy link
Copy Markdown

@opascal221-design 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

@opascal221-design 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 08de2e1 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