diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-12 13:47:49 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-12 16:36:54 +0200 |
| commit | e671b931fd594a39fc840916c81b5d4b1f1e3227 (patch) | |
| tree | 886b1e5eac7d178606510f330b1faa2b4b177892 /packages/meshbay-hub/src/meshbay_hub/tasks | |
| parent | 17c06bc23252929af13f4361c4a6300ee76a0c51 (diff) | |
| download | meshbay-e671b931fd594a39fc840916c81b5d4b1f1e3227.tar.gz | |
fix(hub): the mail allowance is written down, and recovery keeps a share
Two dicts in `mail.py` held the budget, so every deploy handed out a fresh
one — and this hub is deployed several times a day. A bound a restart forgets
is not a bound, for the reason the denylist is persisted rather than held in
memory (S3). It is a `mail_quota` table now, one row per counter, the
recipient hashed so the table does not become a list of plaintext addresses.
The counting moves with it, into an async `reserve` that has a session, and
`send_off_loop` is the one door it stands in. `_send` keeps the purpose
allow-list: that half needs no state, and it is what stops anything which
puts a message on the wire from naming a reason this hub does not send for.
The caller owns the commit, so a request that fails afterwards is not charged
for mail nobody received.
`hourly_reserved_for_recovery` is new. A flood of sign-ups used to be able to
spend the whole hour and lock out the person waiting on a passphrase reset;
registration and address changes may now spend only the unreserved share.
Values changed as agreed: 10 messages a day to one recipient, 300 s between
two reset codes. The address-change ceiling and its cooldown were two bounds
on one thing — 3 a day and 60 s apart — and collapse into one 48-hour delay.
Asking again for the address already pending is exempt: it reaches no new
recipient, that recipient is bounded anyway, and without the exemption a typo
locked the account out of correcting it for two days.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T4YmK41VsEURWFdop4EEeT
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/tasks')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/tasks/cleanup.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/tasks/cleanup.py b/packages/meshbay-hub/src/meshbay_hub/tasks/cleanup.py index 7f8a5f2..dfe7c78 100644 --- a/packages/meshbay-hub/src/meshbay_hub/tasks/cleanup.py +++ b/packages/meshbay-hub/src/meshbay_hub/tasks/cleanup.py @@ -57,6 +57,13 @@ async def cleanup_loop(get_session): stale = await purge_stale_pending_users(db) if stale: log.info("Purged %d stale pending users", stale) + # One row per recipient the hub has written to, and the + # window is a day: without this the table grows for the + # life of the instance and nothing ever reads the old rows. + from meshbay_hub import mail + quota = await mail.purge_expired_quota(db) + if quota: + log.info("Purged %d expired mail counters", quota) except asyncio.CancelledError: raise except Exception as e: |