- Shipped
- August 9, 2026 at 5:23 AM UTC
- Author
- Kamo
- Commit
- 38fc56d
EMAIL was sourced from email_metadata.search_index, which was wrong in both directions. It missed KamoMail entirely — an org on KAMO_MAIL has its messages and attachments in the cluster's own Dovecot maildir, 62 MB of it in production, counted as zero. And it would have charged an org on Microsoft 365 or Google Workspace for mail sitting on that provider's disks, where Kamo holds nothing but a search index of its own. **************** replaces it: per mailbox, per arrival day, total RFC822 bytes — headers, body and encoded attachments, which is what occupies the maildir. Bucketing by day rather than per message keeps the table proportional to days-with-mail while still letting an arbitrary billing window be summed exactly instead of rounded to whole months. Attribution is per mailbox via its own org_id, never per domain and never per maildir. KamoMail is not a single tenant: production already has 18 mailboxes under one org and 41 under another, intermixed across four domains in one table. Summing a domain, or the maildir as a whole, would bill one org for another's mail. Schema verified in production before this landed: email_provider .mailbox_storage_days exists with its uniqueness constraint after a KI run.