fix(hub): bind email budget reserve to a bounded resend chain

The global reserve is claimed atomically with the budget check by deleting a live
attempt for the same address (under 5 failures, under 3 resends, chain under 30
minutes), so it cannot fund mail to other addresses, branch or race.
This commit is contained in:
Loki 2026-10-24 17:48:20 +02:00
parent 6ea14d0ec2
commit fea876654b
Signed by: boba
GPG key ID: 253067914055423B
5 changed files with 196 additions and 33 deletions

View file

@ -0,0 +1,5 @@
-- Resends from a browser with a live attempt may draw on a reserved global budget, but
-- only along a bounded chain: each attempt records how many resends led to it and when
-- the chain began.
ALTER TABLE email_attempts ADD COLUMN resends INTEGER NOT NULL DEFAULT 0;
ALTER TABLE email_attempts ADD COLUMN chain_started INTEGER NOT NULL DEFAULT 0;