feat/platform-mail-submission
Platform mail submission
An instance of a switched app sends mail by POST /v1/mail on its own control socket instead of holding SMTP credentials. The agent stamps each message with the socket's route and forwards it to a box-local mailer (carlos mailer serve, its own unit and uid). The mailer accepts only the agent's main process and refuses routes not on its box. Before the send it applies the sender's From, pause, daily cap and rate. It then sends through SES with one dedicated IAM user per region. No instance of a switched app holds a sending credential.
Why: Paul, 2026-11-12. Instances of every team environment each held their own IAM user and SMTP key, and exec children share the agent's uid, so per-instance passwords never stopped a sibling on the same box from sending as you. Alta's team runs were blocked on this.
Spec: docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md (rev 5 + §9.0, approved). Plan: docs/superpowers/plans/2026-11-13-platform-mail-submission.md. Runbook: docs/mailer-runbook.md.
What changes
- Sender record: pause moves onto the sender record (
pause), plus a per-appsubmissionswitch. Both are additiveomitemptyfields, and old records parse unchanged. - Attribution: SES
EmailTagsare believed only from the mailer's principal (guard test 8.11). Sends are counted by caller class (mail_caller_sends). - Mailer unit: user, socket,
.patharm, tmpfiles and sysusers. Tenant units getInaccessiblePaths=for the mailer's paths. The peer rule is the agent's MainPID and uid. Box status reportsMailerArmed, and amailer_unarmedalert fires for a box hosting a switched app. - The verb: at both control-socket bind sites.
CARLOS_MAILis agent-owned and set only for a bound, provisioned route of a switched app. An unreadable switch is decided from the instance's own bundle and never read as off. - Mailer send pipeline: header hygiene (
Bcc,X-SES-*, RFC 2231 parameters refused), From/domain, pause, cap, a rate of 2/s with a burst of 20, and SES v2 raw send with tags. - Per-app switch:
carlos email submission on|off --app <a>, with its preconditions. One serving judgement (judgeServing) under the app lock gates every serve, create and rebind door. Switch-on and switch-off are ordered so every instance keeps a working mail channel at every step. The app-level user is reaped once its key has been unused for a week. - Builds:
carlos ship --mail submitdeclares a build's mail transport. - Infra: the mailer IAM user and policy (
infra/modules/region-host/mailer.tf), tofu tests, and the runbook.
Tests, simulation, sweeps
- Full gate green on the tip, including the root-read census and the record-write census (
TestPlan9B8RecordWriteCensus). TestSubmissionChannelSimulationdrives the doors in random and scripted interleavings, with injected store and AWS faults. After every step it asserts the one-working-channel invariant, including that every SMTP key an instance would use is live in AWS. Its scripted steps cover each ruled case, and each case's fix was mutation-checked (watched to fail when removed).- Seed sweeps: - CI runs the default 60 seeds. - Run locally on the final code: seeds 5000–5119 and a fresh 9000–9199. All green.
Reviews
- Fable whole-branch review of
b0aba39b0: APPROVE, no P1. Its P2s are fixed. P2-1 to P2-3 are in the one-working-channel family: the agent marks the switch stale before a flip's restart; an unreadable switch is never off; the week-7 reap takes the switch door's locks. - Astra census approvals r1–r3, the last at
fd5c1d2cc: every root-read unit, envelope and record-write re-pin accepted, no findings. The merge of mainada520b6dchanged no disposition: it re-pinned envelopes for the packages main changed, and the two route tables both sides edited. - Copy: Paul approved the 56 strings unedited (
f578a857e). - Paul's rulings (2026-11-12 to 11-14): - Gaps G1–G10 as listed in the plan. - The RFC 2231 refusal. - "One working channel" as one invariant enforced in one place, plus the simulation. - The 65 MB binary ceiling; main has since raised it to 70 MB. - Fix P2-1 to P2-3 as named. - "Switch-off checks keys". - "Switch-on removes SMTP settings before deleting the user", with the week-7 reap extension kept. - "Replace first" as a standing rule for this family: any case where a working credential or channel is removed before its replacement is in place is fixed replacement-first. Case 1 was seed 5063.
Still to do (Paul's operator steps, docs/mailer-runbook.md and plan "Operator steps")
- Release and roll the platform.
- IAM user and key per region, with scoped approval: tofu
maileron eachregion-hostthat hosts Oficina instances, then create the key (runbook 1–2). - Before the first switch-on: - the tenant backfill /
ses:ListTenantResourcescheck; - the one-off tenant-attributed send proof (runbook 2b). - Arm each box that hosts the apps' routes (runbook 3). New or replaced group boxes are named by
mailer_unarmedand need arming too (runbook 4). - Before each switch-on: check that every route of the app has an instance record (hand-made routes would have neither channel).
- Per app:
carlos email submission on --app <a>, watch for 7 days, and abort withoffif needed. Each Oficina app needs its own branch shipping--mail submitfirst (Task 9). The rastrillosubmittransport is on its own branch. - After every later platform roll: restart
carlos-mailer.serviceon armed boxes (runbook 5b). - Before rolling the console back past this build: switch every app off (runbook 5c).
Nothing is deployed. This branch made no AWS write, no tofu apply, and no state-changing carlos command. Until an app is switched, everything is inert: no unit starts without a key, and no CARLOS_MAIL is set.
🤖 Generated with Claude Code
Discussions
- No discussions on this branch yet.
Tasks
- No tasks yet.
Activity
- paul@keymail.dev pushed 3db08dbd6 Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed fd5c1d2cc provision, docs: replace first recorded and re-pinned
- paul@keymail.dev pushed 15bd9eae6 console: scripted witnesses for replace first
- paul@keymail.dev pushed db3846eca mail: replace first: keep a bundle's key until its replacement lands
- paul@keymail.dev pushed 093fd344e docs: record the seed 5063 finding for Paul
- paul@keymail.dev pushed 9dcf3ebd0 provision: re-pin the record-write census for the key check and order
- paul@keymail.dev pushed ac1114871 docs, census: switch-off checks keys; SMTP settings out first
- paul@keymail.dev pushed 8ac038738 console: the simulation checks every SMTP key an instance would use
- paul@keymail.dev pushed 561ff743d mail: take SMTP settings out of a bundle before deleting its user
- paul@keymail.dev pushed bf7b3423f mail: a delivery walk checks the key before it skips a mint
- paul@keymail.dev pushed 76f4f582c docs, census: P2-1 to P2-3 fixed; census re-proposed
- paul@keymail.dev pushed a90e743d9 console: the submission reap takes the switch door's locks
- paul@keymail.dev pushed 81f68b1c3 agent: never spawn on a stale or unknown mail switch
- paul@keymail.dev pushed f578a857e copy: Paul approved the 56 mail-submission strings unedited
- paul@keymail.dev pushed c49e36351 docs, census: runbook and plan for this round; census re-proposed
- paul@keymail.dev pushed 99013525d console: reap without a catalog, report a switched app, fix the copy
- paul@keymail.dev pushed 2723f7981 mailer: wait for a sender slot, prove the key, unset AWS_ACCESS_KEY
- paul@keymail.dev pushed 1091ea9db mailsubmit: refuse an unswitched app before its body; bound in-flight sends
- paul@keymail.dev pushed b0aba39b0 Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed 1181689a0 email: Fable's P2-A and P2-B on 0655efe67 (ruled: fix both)
- paul@keymail.dev pushed a0e07a86b mailer: the * parameter rule reads unquoted parameter names only
- paul@keymail.dev pushed 0655efe67 Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed e6d865791 email: one serving judgement under the app lock (ruled, P2 of round 2)
- paul@keymail.dev pushed 3300bffd4 mailer: RFC 2231 parameters refused in MIME fields only, anywhere in them
- paul@keymail.dev pushed 85cadceaa Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed 6b5f9f845 Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed 0e5016ad9 email: one working mail channel for a switched app (P2-1 to P2-4, ruled)
- paul@keymail.dev pushed 33df1aa26 mailer: refuse RFC 2231 parameters up front; the family's P3s (ruled)
- paul@keymail.dev pushed 1de971f59 Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
- paul@keymail.dev pushed 05591a0ec mailer: SES client as a method value; binary ceiling 64 -> 65 MB