spec: platform mail submission, revision 2 — round 1 answered
Dedicated mailer IAM user (no SES on the box role), instancectl peer rule, box-local routes, app sender with EmailTags attribution (spike-gated), pause on the sender record, cap counter for Paul, switched apps nested only, ordered switch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+244
−159
docs/superpowers/specs/2026-11-12-platform-mail-submission-design.md+244 −159
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 e9a354be6..a84055a52 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,195 +1,280 @@ |
| # Platform mail submission: instances send without holding a credential |
| -**Date:** 2026-11-12 · **Status:** draft, revision 1, not reviewed · |
| +**Date:** 2026-11-12 · **Status:** draft, revision 2, not approved · |
| **Branch:** `design/platform-mail-submission` from `origin/main` `99df838cf` |
| · **Author:** Claude Opus 5.5, for Paul. |
| -**Builds on:** `2026-09-15-tenant-email-senders-design.md` (senders, |
| -per-instance mode, and its §10, "What this leaves for the relay"), which |
| -decided: *"Extend the IAM-per-sender model now, and iterate towards a |
| -platform SMTP relay."* This is that iteration, in the shape the box |
| -already has. **Also:** `implementation/team-scoped-credentials.md` (owned |
| -environments, §3a's per-environment mail credentials, which this replaces |
| -for apps that switch), and the control channel |
| -(`internal/edge/purge.go`, `2026-08-23-scheduled-work-design.md` §7.2). |
| - |
| -**Stopping rule 5: who asks, what they get, when it switches on.** Paul, |
| -for Oficina. Alta creates one instance per app per team. Under §3a, each |
| -instance gets its own IAM user and SMTP key: 30 for Paul's first five |
| -teams, plus a relay identity per Calls instance. Paul, 2026-11-12: *"surely |
| -each instance doesn't need its own email sending credentials?"* He chose |
| -to **block Alta's team runs on this design** ("Happy to block"). So it |
| -switches on at Alta's first production run, and the Oficina apps are its |
| -first users. |
| +**Review history (stopping rules apply).** Round 1: Fable 5.2 on revision |
| +1 (`297b5a74a`) returned CHANGES REQUIRED, with 3 P1s, 6 P2s and 5 P3s. |
| +P1-1 and P1-2 are one fault family, **"uid `carlos` does not separate the |
| +agent (or the mailer's principal) from a tenant"**. P1-3 is "attribution, |
| +cap and pause need a home". Revision 2 answers all of them (Appendix A). |
| +Round 2 is due. If it finds another fault in the uid family, stopping rule |
| +2 sends the choice to Paul, and the simplest cut is §3 decision 7. |
| + |
| +**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 |
| +its §10). **Replaces, for switched apps:** `implementation/team-scoped-credentials.md` |
| +§3a's per-environment mail credentials. **Uses:** the control channel |
| +(`internal/edge/purge.go` `ListenControl`; `backend_exec.go` and |
| +`prepare.go` bind sites), the `instancectl` peer rule |
| +(`internal/instancectl/server.go`), and the isolated-exec layout |
| +(`internal/host/units/carlos-instance@.service`). |
| + |
| +**Stopping rule 5.** Who asks: Paul, for Oficina. What they get: Alta's |
| +team instances send mail with no IAM user or credential per instance. |
| +When it switches on: Paul blocked Alta's production team runs on this |
| +design (2026-11-12, "Happy to block"), so it switches on at the first |
| +such run. |
| --- |
| ## 1. The problem |
| -Today a sending credential lives **inside the instance**. That is true at |
| -the app level (`carlos-mail-<acct>-<app>`, delivered as `<P>_SMTP_*` into |
| -the default bundle) and, since §3a, per owned environment |
| -(`carlos-mail-<acct>-<app>+e+<env>`). This has three costs. |
| - |
| -1. **One AWS IAM user per sender.** The account ceiling is 5,000 and not |
| - adjustable (senders spec §12). A team of six apps is six users, and a |
| - per-customer app is one per customer. |
| -2. **The credential is the authority.** Whoever reads `<P>_SMTP_PASS` can |
| - send as that sender, from anywhere, until the key is rotated. The cap |
| - is counted after the fact (senders spec §10: the relay "enforces the |
| - cap before the send rather than after"). |
| -3. **Per-instance credentials isolate less than they appear to.** On an |
| - exec-backed box, every instance runs as the agent's uid |
| - (`internal/activator/admintoken.go`: "every exec child shares the |
| - agent's uid — a sibling can read this file"). So a compromised instance |
| - can read a sibling's `<P>_SMTP_PASS` from its env file, just as it can |
| - read the sibling's admin token. The per-instance IAM user buys |
| - attribution and revocation. It does not stop a neighbour sending as you. |
| - Per-instance uids are "the actual fix" for both. |
| +A sending credential lives **inside the instance**. That is true at the |
| +app level (`carlos-mail-<acct>-<app>`, delivered as `<P>_SMTP_*`) and, |
| +under §3a, per owned environment (`…+e+<env>`). This has three costs. |
| + |
| +1. **One IAM user per sender.** The ceiling is 5,000 per account and not |
| + adjustable (senders spec §12). Alta's first five teams of six apps |
| + would be 30. |
| +2. **The credential is the authority.** Whoever reads `<P>_SMTP_PASS` |
| + sends as that sender from anywhere. The cap is counted after the fact, |
| + from SES events. |
| +3. **On the flat layout, per-instance credentials isolate less than they |
| + appear to.** Exec children share uid `carlos` (`admintoken.go`), so a |
| + compromised flat instance can read a sibling's env file. **On the |
| + nested (isolated-exec) layout it cannot.** That instance sees "nothing |
| + but the instance's own two directories" (`carlos-instance@.service:4-6`), |
| + and IMDS is denied to it (`:162`). |
| ## 2. The design in one paragraph |
| -**An instance submits a message on its control socket, and the platform |
| -sends it.** The agent already binds a local-only control channel for |
| -every exec-backed instance, token-gated by that instance's |
| -`CARLOS_ADMIN_TOKEN` (`backend_exec.go`, `edge.ListenControl`), and |
| -mounts verbs on it (`schedule.MountGated`, `instanceupdates.Mount`). A new |
| -verb, `POST /v1/mail`, takes one message. The agent knows which instance |
| -owns that socket, so the instance's identity comes from **where it |
| -dialled, not from a secret it presents**. It hands the message to a |
| -**box-local mailer** running as its own uid. Only the mailer can reach the |
| -SES credential. The mailer checks the sender's policy (From, cap, pause) |
| -**before** sending, sends through SES, and counts the send against the |
| -instance. **No instance holds a sending credential, and no sender needs |
| -an IAM user.** |
| +**An instance submits a message on its own control socket, and the |
| +platform sends it.** The control socket is per instance, bound by the |
| +agent (`edge.ListenControl`), and gated by the instance's |
| +`CARLOS_ADMIN_TOKEN`. A new verb on it, `POST /v1/mail`, takes one |
| +message. The agent knows which route owns the socket. It forwards the |
| +message, stamped with that route, to a **box-local mailer**. The mailer |
| +accepts connections only from the agent's own main process, refuses any |
| +route that is not on its box, checks the sender's policy before sending, |
| +and sends through SES with **one dedicated IAM user for the fleet**. That |
| +user's key is readable only by the mailer. |
| ## 3. Decisions (proposed; none ruled) |
| | # | Decision | Rejected | |
| |---|---|---| |
| -| 1 | **Submission over the existing control socket**, as a token-gated verb beside the schedule and updates verbs | (a) A network SMTP relay with per-sender passwords (senders spec §10's sketch). It still puts a credential in every instance, and it needs its own listener, TLS and abuse surface. (b) A per-instance SMTP listener on the box. Every app would need to speak SMTP to a socket the agent vouches for, which is a second channel beside the one that already exists | |
| -| 2 | **The sending credential lives in a separate box unit, `carlos-mailer`, with its own uid.** The IMDS gate (`nft … meta skuid`, `scripts/harden-host.sh`, which `adopt_advice.go` reads) admits that uid, and the box role's SES permission is the only send authority | Giving the agent the credential. The agent shares its uid with every exec child, so any instance could read it (§1.3) | |
| -| 3 | **Policy is enforced before the send**: From must be an address the sender may use (the sender records of the senders spec §5), the daily cap is checked and decremented first, and a paused sender is refused | Counting after the fact, as today | |
| -| 4 | **Attribution per instance, without an IAM user.** Each submission is tagged with the instance's sender id (senders spec §5, `ScopeInstance`) and counted in `mail_sender_counts` | One IAM user per instance (§3a) | |
| -| 5 | **An app opts in per app, with a switch** (`carlos email submission on --app <a>`), mirroring per-instance mode (senders spec §6.3). When on, **no** `<P>_SMTP_*` is delivered to the default bundle or any owned environment, and the mail walk mints no per-environment users. The agent sets `CARLOS_MAIL=submit` in the instance's environment, agent-owned in both directions like `CARLOS_CONTROL_SOCKET` | Switching the fleet at once; inferring the mode from whether the socket exists | |
| -| 6 | **The app side is one library change.** rastrillo's `mail` package gains a `submit` transport, chosen when `CARLOS_MAIL=submit` is set, and used in place of SMTP. The Oficina apps get it from a rastrillo re-pin, with no app code changes | Each app learning a new API | |
| +| 1 | **Submission is a verb on the existing control socket,** mounted at both bind sites (flat `backend_exec.go:2557`, nested `prepare.go:298`) under its own condition, not under the `Timers`/`UpdatesReader` mount | A network SMTP relay with per-sender passwords, which still puts a credential in every instance. A second per-instance channel | |
| +| 2 | **The mailer's credential is a single dedicated IAM user (`carlos-mailer-<region>`), not the box role.** Its key is in a root-written file readable only by the static user `carlos-mailer` (precedent: `/etc/carlos/relay-masters`). The mailer unit has `IPAddressDeny` for IMDS. **The box role gains nothing** | SES on the instance role. Every uid the IMDS gate admits gets the whole role, and the gate admits uid `carlos` by construction (`group-init.sh.tftpl:110-111`), so every flat exec child could send as any identity (round 1, P1-1) | |
| +| 3 | **The mailer's peer rule is `instancectl`'s:** `SO_PEERCRED` uid `carlos` **and** pid equal to `carlos-edge.service`'s MainPID. The socket directory is in the instance units' `InaccessiblePaths`, as `/run/carlos-control` is | A uid-only check, which every flat exec child passes (round 1, P1-2) | |
| +| 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. `sesevents.go`'s `SenderOfCaller` learns to read the tag **before** the caller identity, because with one sending principal the caller identifies nobody. **This is gated on a spike** (§9 item 1): that the tags arrive in `mail.tags` on Bounce, Complaint and Delivery events | The caller identity, which becomes the same for every app (round 1, P1-3) | |
| +| 7 | **The switch is refused for an app with any flat-layout route,** at the door and again at the agent's mount. Switched apps are nested only | Allowing flat routes, whose residual is the uid family. Optional: round 2 may show decisions 2–4 make flat routes no worse than today, and then Paul can lift it | |
| +| 8 | **Pause becomes a field on the sender record** (`Paused`, with reason and time), independent of `Provisioned`. The console writes it (`carlos email pause`, and the automatic bounce and complaint pauses), and the mailer reads it by etag | 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 | |
| +| 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` | Flipping before the apps can submit, which is an outage (round 1, P2-3) | |
| +| 11 | **`CARLOS_MAIL=submit` follows the outcome,** not the switch: set only when the control socket is bound (`ctl != nil`) **and** the mailer answers a health probe. 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 | |
| + |
| +### 4.1 The cap counter — for Paul |
| + |
| +Every instance of a switched app is the app sender (decision 5), and the |
| +app's instances are on many boxes. So "before the send" needs a shared |
| +count. There are two options. |
| + |
| +- **(a) Per box, before the send; fleet-wide after event latency.** Each |
| + mailer keeps a durable daily counter per sender and refuses at the cap. |
| + Overshoot is bounded by **boxes holding the app × cap**, until SES |
| + events reach the console and it pauses the sender (decision 8). Simple, |
| + and needs no new coordination. |
| +- **(b) Leased from the bucket.** A per-sender, per-day counter object in |
| + the control-plane bucket, with CAS by etag (the senders spec's records |
| + already use one etag per object). A mailer leases an allowance (for |
| + example 20 sends), spends it locally, and returns what is left at |
| + expiry. Overshoot is bounded by **outstanding leases**, which is small. |
| + More work: a lease object, expiry, and contention under bursts. |
| + |
| +**Author's recommendation: (b).** The Oficina apps put every team's |
| +instances under one app sender, so (a)'s bound grows with the number of |
| +boxes. If Paul prefers to ship sooner, (a) with a low cap is acceptable, |
| +and (b) can replace it without an app change. |
| ## 4. The verb |
| -`POST /v1/mail` on the control socket. |
| -- **Headers:** `Authorization: Bearer <CARLOS_ADMIN_TOKEN>`. |
| -- **Body:** a JSON envelope `{ "from", "to": [..], "raw" }`, where `raw` |
| - is the RFC 5322 message, base64, at most 1 MiB. `from` must equal the |
| - message's `From:` header. |
| +`POST /v1/mail` on the control socket, with |
| +`Authorization: Bearer <CARLOS_ADMIN_TOKEN>`. |
| + |
| +- **Body:** a JSON envelope `{ "from", "to": [..], "raw" }`. |
| + - `raw` is the RFC 5322 message, base64, at most 10 MiB, the SES v2 raw |
| + limit (to be confirmed in the spike, §9 item 1). That allows the |
| + attachments Docs and Sheets send. |
| + - `from` must equal the `From:` header. |
| + - `to` is the envelope, at most 50 recipients (to be confirmed in the |
| + spike). |
| +- **Synchronous.** The agent forwards, the mailer sends, and the verb |
| + answers with SES's result. **The retry queue stays in the app** |
| + (rastrillo's existing mail queues). Nothing is queued on the box, so |
| + hibernation is simple: an instance sends only while awake, and its |
| + socket exists only then. |
| - **Answers:** |
| - - `202` with a submission id: accepted and handed to the mailer. |
| + - `200 {"message_id"}`: SES accepted it. |
| - `400`: malformed, or `from` ≠ `From:`. |
| - `403 {"code":"FROM_NOT_ALLOWED"}`. |
| - - `429 {"code":"CAP_REACHED"}` or `{"code":"PAUSED"}`. |
| - - `503 {"code":"MAILER_UNAVAILABLE"}`: the instance retries. rastrillo's |
| - existing mail queues (Docs' and Sheets' `mailqueue.go`) already |
| - retry. |
| -- **Recipients:** at most 50 per message, to fit SES limits. Bcc is |
| - stripped from `raw` by the mailer, never the app. |
| -- **Not on this verb:** reading mail, bounces, events. Bounces and |
| - complaints keep their existing path (`events.go`). |
| + - `429 {"code":"CAP_REACHED"|"PAUSED"|"RATE"}`, with `Retry-After`. |
| + The apps' queues must back off, never retry hot. |
| + - `503 {"code":"MAILER_UNAVAILABLE"}`: retry. |
| +- **Not available to** seeds, sidecars, or cmd/tty one-shots. They have |
| + no control socket (`prepare.go:166`, `seedVars`), so a switched app's |
| + seeds cannot send mail. That is stated, not worked around. |
| ## 5. The mailer |
| -- **A systemd unit on every box, `carlos-mailer.service`,** with its own |
| - static user `carlos-mailer`. It listens on a root-owned unix socket that |
| - only the agent's uid may dial (`SO_PEERCRED` check, the pattern in |
| - `pty_linux.go` and `rolelaunch_root_linux.go`). |
| -- **The agent passes `(account, app, host)` with each message.** The |
| - mailer trusts that, because only the agent can dial it. The same-uid gap |
| - in §6 is the honest limit of that trust. |
| -- **The mailer reads sender records from the bucket** (the control plane), |
| - caching each with its etag, and enforces decision 3. |
| -- **The mailer sends with SES `SendRawEmail`,** using the box role. It |
| - sets the configuration set and SES tenant the senders spec already |
| - assigns (§5, `TenantARN`), so SES-side attribution and the per-tenant |
| - pause keep working. |
| -- **The box role's SES statement** is scoped to the platform's verified |
| - identities (`ses:FromAddress`/identity ARNs), the same scope the walk |
| - writes into per-sender policies today, and is reachable only by |
| - `carlos-mailer`'s uid at IMDS. |
| - |
| -## 6. What this does and does not protect |
| - |
| -- **No instance can obtain a sending credential.** That is strictly better |
| - than today, where every instance holds one. |
| -- **No instance can exceed its sender's cap or send while paused,** |
| - because both are checked before the send. |
| -- **An instance cannot send as another app's sender.** The agent decides |
| - identity from the socket, and the From check binds it to that sender's |
| - identities. |
| -- **Unchanged and stated: on an exec box, a compromised instance can still |
| - read a same-uid sibling's admin token and submit as that sibling.** It |
| - could do exactly that today with the sibling's SMTP password. Per-instance |
| - uids close both gaps together. Unit-backed tenants (`DynamicUser`) already |
| - have their own uids, if they have a control socket (§9 item 2). |
| -- **A compromised agent can send as anyone on its box, within caps.** It |
| - could already do that by reading every env file. |
| - |
| -## 7. Migration and what retires |
| - |
| -1. Build the mailer, the verb, and rastrillo's `submit` transport, with the |
| - switch defaulting to off. |
| -2. Turn the switch on for the Oficina apps (Paul's account `oficina`), then |
| - re-pin rastrillo and deploy. |
| -3. **App-level IAM users** for switched apps are reaped by the walk |
| - (`Teardown` for the user only, never the identity: senders spec §1's |
| - #147 warning). |
| -4. **Owned environments** of switched apps never get a mail identity, so |
| - Alta's team runs create no IAM users at all. |
| -5. Calls' TURN relay identities (§3a's other per-environment mint) are a |
| - separate design, but the same shape could serve: short-lived TURN |
| - credentials minted by the agent per request on the control socket. That |
| - is listed as a follow-up, not designed here. |
| +- **The unit and its user.** `carlos-mailer.service` in |
| + `internal/host/units`, static user `carlos-mailer`, |
| + `IPAddressDeny=169.254.169.254/32 fd00:ec2::254/128`. |
| +- **Its socket.** A root-owned socket directory in every instance unit's |
| + `InaccessiblePaths`. |
| +- **The peer rule** is decision 3. |
| +- **Its credential.** A root-written file, `0640 root:carlos-mailer`, |
| + holding one IAM user's key per region. The infra repo writes it, as it |
| + writes `relay-masters`. |
| +- **The send.** SES v2 `SendEmail` with `Content.Raw`, an explicit |
| + `Destination` taken from the envelope, the sender's |
| + `ConfigurationSetName`, `TenantName` when the sender has one, and |
| + `EmailTags`. |
| +- **Header hygiene.** Before sending, the mailer strips `Bcc:` and every |
| + `X-SES-*` header from `raw`. SMTP honours `X-SES-TENANT` and |
| + `X-SES-CONFIGURATION-SET` (`internal/mail/aws.go:14-17`). Whether the v2 |
| + raw path does is unverified, so they are stripped regardless. |
| +- **The IAM policy:** `ses:SendEmail` and `ses:SendRawEmail` on |
| + `identity/*` and the account's configuration sets. It is conditioned on |
| + `ses:FromAddress` matching the platform's verified identities, or on |
| + `ses:TenantName` where the sender has a tenant, the key the senders spec |
| + §3 documents. The From check in the mailer is the real gate, and IAM is |
| + the backstop. |
| +- **Rate.** A per-sender token bucket, so one sender cannot spend the |
| + account-wide SES send rate (senders spec §3) and throttle everyone. |
| +- **Tenants.** If a sender's configuration set or identity is not |
| + associated with its tenant (senders spec §4.2.1 found existing domains |
| + unassociated), sending with `TenantName` fails. **The switch refuses an |
| + app whose sender would send with an unassociated tenant**, until the |
| + backfill (§9 item 3). |
| + |
| +## 6. What this protects, and what it does not |
| + |
| +- **No instance holds a sending credential,** on either layout. |
| +- **No instance exceeds its sender's cap or sends while paused,** within |
| + §4.1's bound. |
| +- **An instance can submit only as its own route.** The agent stamps the |
| + route from the socket, and the mailer accepts only the agent's main |
| + process and only routes on its box. |
| +- **Residual, stated.** On a box that also runs flat instances (any app, |
| + switched or not), a compromised flat instance can read a flat sibling's |
| + admin token and submit as that sibling, **on that box only**. That is |
| + the same reach it has today over that sibling's SMTP password. It cannot |
| + reach the mailer socket, the mailer's key, or IMDS's SES, because the |
| + box role has none. **Decision 7 keeps switched apps nested,** so their |
| + own tokens are invisible to flat siblings, and this residual covers |
| + unswitched apps only. |
| +- **A compromised agent** can send as any route on its box, within caps. |
| + It could already read every flat env file. |
| + |
| +## 7. Migration |
| + |
| +1. **Build:** the verb at both bind sites, the mailer unit and its infra, |
| + pause on the sender record, `EmailTags` attribution, the cap (§4.1), |
| + rastrillo's `submit` transport, and the manifest declaration. |
| + **Census cards** for `internal/host/units` and `infra/` (AGENTS.md). |
| +2. **Apps first:** re-pin rastrillo in the Oficina apps, declare |
| + `mail = "submit"`, deploy. They keep sending over SMTP until the switch. |
| +3. **Flip the switch per app.** Its preconditions (decisions 7, 10, §5 |
| + tenants) are checked by the door. |
| +4. **Reap:** per-environment users via `ReapEnvironment`. The app-level |
| + user is kept until a week of clean submission, then reaped by the walk |
| + (user only, never the identity: senders spec #147). |
| +5. **Standalone credentials** (`email credentials create`) are unaffected. |
| + They are explicit and separate. |
| +6. **Switching off** re-mints through `Enable` and restores `<P>_SMTP_*`. |
| +7. **Team-scoped guard tests 17 and 19** (`team-scoped-credentials.md:400-415`) |
| + gain a switched-app case: a switched app's owned environment holds no |
| + mail credential. |
| +8. **Calls' TURN relay identities** are a separate design (§10). |
| ## 8. Tests and gates |
| 1. **No credential reaches an instance.** For a switched app, a rendered |
| - instance environment (default and owned) holds no `<P>_SMTP_*` and no |
| - AWS key. This is a golden test across `RenderEnv`. |
| -2. **Identity from the socket.** A message submitted on host A's socket is |
| - attributed to A, whatever the body says. A body claiming another sender |
| - is refused. |
| -3. **Before-send policy.** A wrong From gets `403`. Cap minus one sends and |
| - the cap answers `429`. A paused sender gets `429` with no SES call |
| + environment (`appconfig.RenderEnv`, `materialize.go:37`), default and |
| + owned, holds no `<P>_SMTP_*` and no AWS key. Golden test. |
| +2. **Identity from the socket.** A message on host A's socket is stamped |
| + A, whatever its body says. |
| +3. **The peer rule.** A uid-`carlos` process that is not the agent's main |
| + pid is refused by the mailer. So is any other uid. |
| +4. **Box-local routes only.** A stamp naming a route not on this box is |
| + refused. |
| +5. **Before-send policy.** A wrong From gets `403`. The cap boundary gets |
| + `429 CAP_REACHED`. A paused sender gets `429 PAUSED`, with no SES call |
| (fake SES). |
| -4. **The mailer dial gate.** Any uid other than the agent's is refused. |
| -5. **The IMDS gate.** On a hardened box, an exec child cannot reach IMDS |
| - and `carlos-mailer` can. This extends `adopt_advice.go`'s check. |
| -6. **The switch is agent-owned.** A tenant-supplied `CARLOS_MAIL` in |
| - `<host>.config.env` is removed when submission is off, as |
| - `CARLOS_CONTROL_SOCKET` is. |
| -7. **rastrillo `submit` transport.** It chooses `submit` only on |
| - `CARLOS_MAIL=submit`, retries `503`, and surfaces `403`/`429` as send |
| - errors, which the apps' queues already log. |
| - |
| -## 9. Open: facts to verify before build |
| - |
| -1. **Does the exec-child uid reach IMDS on production boxes today?** If |
| - the nft gate admits the agent's uid (shared by every exec child), then |
| - any instance can already obtain the box role. Adding SES send to that |
| - role would widen the hole, so decision 2 needs the gate to admit only |
| - `carlos-mailer` and whatever already needs it. |
| -2. **Unit-backed tenants:** is a control socket bound for them, or only |
| - for exec children (`backend_exec.go` says "every exec child")? The |
| - Oficina apps run as `binary` runtime instances, which the build must |
| - confirm are exec-backed. If unit tenants have no channel, they keep |
| - IAM-per-sender until it exists. |
| -3. **Customer fleets** (boxes in another AWS account, outbound-only): out |
| - of scope. They keep IAM-per-sender unless the mailer can use a |
| - cross-account role. That is a later decision. |
| -4. **SES `SendRawEmail` with a tenant:** confirm that the SES v2 call |
| - carries `TenantName` the way the senders spec's spike recorded for |
| - SMTP (§4.1). |
| +6. **Header hygiene.** `Bcc:` and `X-SES-*` never reach SES. |
| +7. **Agent-owned variable.** A tenant-supplied `CARLOS_MAIL` is stripped. |
| + `CARLOS_MAIL` is set only when bound and the mailer is healthy. The |
| + `agentOwnedNames` and `AgentOwnedVars` pair is pinned. |
| +8. **The switch's preconditions.** A flat route, an undeclared build or an |
| + unassociated tenant each refuse the switch. |
| +9. **The IMDS gate.** The mailer unit cannot reach IMDS. The box role has |
| + no SES. `adopt_advice.go`'s parser cannot read negated sets |
| + (`parseNftSkuids`), so this is a unit-file and IAM assertion, not an |
| + nft-parse one. |
| +10. **rastrillo `submit` transport.** It is chosen only on |
| + `CARLOS_MAIL=submit`, backs off on `429` per `Retry-After`, and |
| + retries `503`. |
| + |
| +## 9. Open: facts to establish before build |
| + |
| +1. **SES spike** (blocking decisions 6 and 9, and the §4 limits): |
| + - `EmailTags` arrive on Bounce, Complaint and Delivery events, in the |
| + shape `sesevents.go` parses. |
| + - The SES v2 raw size limit and recipient limit. |
| + - Whether the v2 raw path honours `X-SES-*` headers. |
| + - The IAM action that v2 raw sends require. |
| +2. **Which layout the Oficina apps' instances run in.** Decision 7 needs |
| + every route of a switched app nested. Find out what moves a route |
| + nested ("the layout pass moves the row nested", `backend_exec.go:272`) |
| + and whether Oficina's are. |
| +3. **Has the tenant association backfill** (senders spec §4.2.1) landed? |
| +4. **Who changes the infra repo's IMDS gate, if anything.** The |
| + decision-2 design needs no gate change, because the box role gains no |
| + SES. Confirm. |
| ## 10. Out of scope |
| -- An SMTP listener for non-rastrillo apps. If a customer needs one, it is |
| - a shim in front of the same verb, designed when someone asks. |
| +- An SMTP shim for non-rastrillo apps. |
| - Inbound mail. |
| -- Calls' relay identities (§7.5). |
| +- Customer fleets in other AWS accounts. |
| +- Per-instance senders (#148). |
| +- **Calls' TURN relay identities.** A follow-up in the same shape: |
| + short-lived TURN credentials minted per request on the control socket. |
| + |
| +--- |
| + |
| +## Appendix A — round 1 (Fable 5.2, revision 1 `297b5a74a`) |
| + |
| +| Finding | Answer | |
| +|---|---| |
| +| P1-1 IMDS role reachable by uid carlos | Decision 2: a dedicated IAM user, key readable only by `carlos-mailer`, no SES on the box role, mailer `IPAddressDeny`; §9 item 4 | |
| +| P1-2 uid-only peer check | Decision 3 (`instancectl` rule plus `InaccessiblePaths`), decision 4 (box-local routes), §6 rewritten, test 8.3 | |
| +| P1-3 attribution, counts, cap, pause | Decision 5 (app sender), decision 6 (`EmailTags`, spike-gated), decision 8 (pause on the record), decision 9 and §4.1 (the cap, Paul's call) | |
| +| P2-1 SES call, headers, tenants, recipients, IAM scope | §5, §4, §9 item 1, §9 item 3 | |
| +| P2-2 the two bind sites, mount condition, outcome-following variable, agent-owned pair, seeds | Decisions 1 and 11, §4 "Not available to" | |
| +| P2-3 migration order, existing environment users, mint guard, standalone credentials, guard tests, switching off | Decision 10, §7 | |
| +| P2-4 unit and infra census, adopt parser, who changes the gate | §7.1, test 8.9, §9 item 4 | |
| +| P2-5 synchronous delivery, rate limit | §4 synchronous, §5 rate | |
| +| P2-6 layout | §1.3, decision 7, §9 item 2 | |
| + |
| +**P3 follow-up list** (not starting a round): |
| + |
| +- The raw size limit, now 10 MiB pending the spike. |
| +- `429` back-off in the apps' queues. |
| +- The CLI docs and parity row (decision 10). |
| +- Cite `instancectl` (done). |
| +- Name `RenderEnv`'s file (done). |