mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-13 00:36:02 +00:00
A seat that exhausts its allowance is refused and cannot fix it itself — only the team owner can add capacity. Something has to tell the owner, and that something lives in prod, so OSS's job is to say when it happened. `MeteringService` emits `metering.credit-state` from `rememberRemainingCredits`, the single point where the verdict is computed, at 90% of the allowance and again on exhaustion. Emitted on a transition, never per request. A blocked account keeps trying and every retry recomputes the verdict, so without that a retry loop would announce hundreds of times. The state is tracked per uuid in process, under the same FIFO bound as the credit cache, and dropped in `#dropCachedCredits` — so added capacity re-arms the alert for the rest of the month. The dedup that turns this into exactly one notice per member per month belongs with whoever sends the mail, and needs a cross-region marker rather than a per-cluster one. Part of PUT-1750; the notification half is prod's.