carlos / platform Public

spec: platform mail submission, revision 4 — Paul's rulings (no layout precondition; per-box cap)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 7929892c0f40fe67168649fb2af7300f9992d171 parent e7deab9
1 file changed, +12 −9
  • docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md +12 −9
diff --git a/docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md b/docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md
index e0c65cdca..19670410a 100644
--- a/docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md
+++ b/docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md
@@ -1,6 +1,6 @@
# Platform mail submission: instances send without holding a credential
-**Date:** 2026-11-12 · **Status:** draft, revision 3, not approved ·
+**Date:** 2026-11-12 · **Status:** draft, revision 4, not approved ·
**Branch:** `design/platform-mail-submission` from `origin/main` `99df838cf`
· **Author:** Claude Opus 5.5, for Paul.
@@ -17,7 +17,10 @@ third fixes. For attribution it takes rule 2's third option: state the
invariant, enforce it in one place, and guard it with a test (decision
6). For the uid family it puts the choice to Paul (decision 7, §11).
Round 3 is limited to this revision's diff and Paul's rulings. A fourth
-round needs Paul's go.
+round needs Paul's go. **Paul ruled on 2026-11-12** ("Yes to all
+recommendations"): the layout precondition is cut, and the residual is
+stated (§11 item 1). The cap counter is per box (§4.1 (a)). Revision 4
+records both.
**Builds on:** `2026-09-15-tenant-email-senders-design.md` ("Extend the
IAM-per-sender model now, and iterate towards a platform SMTP relay", and
@@ -78,9 +81,9 @@ user's key is readable only by the mailer.
| 4 | **The mailer refuses any `(account, app, host)` that is not a route on its own box,** read from the box's registry | Trusting the agent's stamp for any route anywhere |
| 5 | **Every instance of a switched app sends as the app sender** (`SenderAppID`), as owned environments are counted today (`walk_environment.go`). Per-instance senders stay with #148, unbuilt | Inventing instance senders here (round 1, P1-3: nothing on main creates one) |
| 6 | **Attribution by SES `EmailTags`** (`account`, `app`, `sender`) on every send through the mailer. **Invariant: a tag is believed only from the mailer's own principal.** `SenderOfCaller` checks the caller first. Only when `ses:caller-identity` is `carlos-mailer-<region>` does it read the tags. Every other caller keeps today's path, and its tags are ignored. Any SMTP-credentialed tenant can set tags with an `X-SES-MESSAGE-TAGS` header (`sesv2/types/types.go:391`), so believing tags from anyone would let a tenant charge its bounces and complaints to another app. Enforced in that one function, with guard test 8.11. **Gated on the spike** (§9 item 1): that the tags arrive in `mail.tags` on Bounce, Complaint and Delivery events | Reading the tag before the caller (revision 2), which lets an unswitched app's sends be charged to a victim (round 2, P1-A). The caller identity alone, which is the same for every switched app (round 1, P1-3) |
-| 7 | **Proposed: no layout precondition.** Decisions 2–4 make submission no worse than today on either layout (round 2, P2-1), and §6 states the residual. **Paul's call** under stopping rule 2 (§11 item 1) | Revision 2's "switched apps nested only". It claimed nested tokens are invisible to flat siblings, but nested isolation is one-way: a flat child runs in the agent's unit with `ReadWritePaths=/data /run/carlos` (`carlos-edge.service:41,50`), and can read a nested instance's env file (`paths.go:43,56`) and dial its control socket (`paths.go:49`). As written, per app, it bought nothing and would have blocked on §9 item 2 |
+| 7 | **No layout precondition. Ruled by Paul, 2026-11-12.** Decisions 2–4 make submission no worse than today on either layout (round 2, P2-1), and §6 states the residual | Revision 2's "switched apps nested only". It claimed nested tokens are invisible to flat siblings, but nested isolation is one-way: a flat child runs in the agent's unit with `ReadWritePaths=/data /run/carlos` (`carlos-edge.service:41,50`), and can read a nested instance's env file (`paths.go:43,56`) and dial its control socket (`paths.go:49`). As written, per app, it bought nothing and would have blocked on §9 item 2 |
| 8 | **Pause becomes a field on the sender record**, independent of `Provisioned`, **keeping today's pause kinds** (cap, rate, plan, manual: `mail.go:65-88`). Cap pauses lift at the day roll (`resumeStaleCapPause`), and the others do not. The console writes it (`carlos email pause`, and the automatic pauses), and the mailer reads it by etag. **While the app-level key still exists (§7.4's week), a pause also deactivates that key**, as today | Pause as IAM key state, which does not exist once the user is reaped (`SetSenderPaused` returns `ErrNotProvisioned`; `enforceMailLimits` returns early) |
-| 9 | **The cap is enforced before the send. Where the counter lives is Paul's call** (§4.1) | Counting only from events, after the send |
+| 9 | **The cap is enforced before the send, with a per-box counter** (§4.1 (a), ruled by Paul, 2026-11-12) | Counting only from events, after the send |
| 10 | **The switch.** It is `carlos email submission on --app <a>`, with a `docs/site/cli.md` heading and a `parity/parity.tsv` row. It is **ordered**: the door refuses it unless every route of the app runs a build that has declared the `submit` transport (the app's manifest `mail = "submit"`). When on, no `<P>_SMTP_*` is delivered anywhere, `ReapEnvironment` runs for each existing owned environment's user, and `mintOwnedEnvironmentMail` checks the switch explicitly rather than relying on `Provisioned == nil`. **The precondition holds for as long as the switch is on, not only at the flip.** Adopting, rolling back to, or pinning a build whose manifest lacks the declaration is refused (`release.Manifest`, additive field, `release.go:55-60`). So is waking an older build. The build a route runs is read from its route record's live version. **Before §7.4's reap, `carlos email test --submit`** sends through the submit path per route, as proof rather than a declaration | Flipping before the apps can submit, which is an outage (round 1, P2-3) |
| 11 | **`CARLOS_MAIL=submit` follows the bind,** not the switch and not mailer health: set when the switch is on and the control socket is bound (`ctl != nil`). Mailer health is what `503 MAILER_UNAVAILABLE` is for. A health probe at spawn would leave an instance with neither channel for its whole lifetime (round 2, P2-5). rastrillo fails loudly at boot when a switched app has neither `CARLOS_MAIL` nor SMTP variables. It is added to both `agentOwnedNames` (`backend_exec.go:2749`) and `moves.AgentOwnedVars` (`envreport.go:62`), which a test pins as a pair | Setting it from the switch alone, which leaves an app with no SMTP variables and no channel when a bind fails |
@@ -101,7 +104,7 @@ instances are on many boxes. There are two options.
is bounded by outstanding leases. It costs a lease object, expiry, burst
contention, and **bucket-write authority on the mailer.**
-**Recommendation, changed in revision 3: (a).** The cap is an abuse brake,
+**Ruled by Paul, 2026-11-12: (a).** The cap is an abuse brake,
not a billing limit, and round 2 showed that (a)'s true bound is set by
rate × event latency. Revision 2 recommended (b) on a looser bound. (b)
stays the stated upgrade path, with no app change needed.
@@ -290,20 +293,20 @@ stays the stated upgrade path, with no app change needed.
decision-2 design needs no gate change, because the box role gains no
SES. Confirm.
-## 11. For Paul (stopping rule 2)
+## 11. Paul's rulings (stopping rule 2), 2026-11-12
1. **The uid family (decision 7).** Choose one:
- **Cut the layout precondition, and state the residual** (§6).
Submission is no worse than today on either layout, and better
- bounded. *Fable and the author recommend this.*
+ bounded. **← Ruled.**
- **Refuse at box level:** no switched app on a box with any flat row
(`FlatLayoutChosen`, `backend_exec.go:268-273`). This is the only form
that delivers "a flat sibling cannot submit as a switched app". It
waits on moving Oficina's boxes nested (§9 item 2).
- **Per-instance uids,** the real fix for this and the admin-token gap.
A separate design, and out of scope here.
-2. **The cap counter (§4.1).** (a) per box (recommended) or (b) leased
- from the bucket.
+2. **The cap counter (§4.1): (a) per box. ← Ruled.** (b) stays the
+ upgrade path.
## 10. Out of scope