Mail relay: an inherited sending key that never leaves its holder

Design for #15872. Nothing here is built yet; the build is split below.

The problem

A new forge or app should send mail with no setup. Today mail is SMTP submission (src/kernel/mail.ts) from the forge-level secrets MAIL_SMTP_URL and MAIL_FROM (docs/OPERATING.md). Copying that key into a child would break CLAUDE.md rule 11 ("a child inherits nothing it was not handed"): one leaked child would leak every child's sending reputation.

Decision: the key is never copied; the parent sends

The holder of a key is the only process that opens it. A child asks its parent to send, over the door it already has (the signed call of src/spawn/signed_call.ts, as src/spawn/child_reach.ts does for egress), and the parent opens the key, sends, and answers sent, capped or failed.

app --(forge-signed call)--> its forge --(signed call)--> parent forge --> SMTP asks "send this" holds a key? yes: send platform key

Each hop either sends with a key it holds at its own scope or forwards one hop up. A child holds no key it was not given, so the chain is the fallback.

Scopes and fallback

Order of precedence, narrowest first: app > domain > forge > platform.

What may be sent on a key it does not own

A shared (inherited) key carries two limits, both counted by the holder in mail_sent (core/mail_log.ts, the pattern actions/mail.ts already uses):

  1. From-domain allowlist per scope. The holder keeps domains per child scope; a message whose from domain is not on it is refused from_domain. Default for an inheriting child: its own hostname only.
  2. Rate limit per scope: a daily count per requesting scope on top of the holder's per-recipient and whole-forge caps, so one noisy app spends its own allowance, not its siblings'.

The key never appears

Split (each part usable alone)

  1. Resolution: src/core/mail_key.ts, resolveMailKey over the existing secret scopes (app > domain > forge > platform), returning the scope without the key; the forge's own sends use it. Tests: inheritance, override, removal falls back.
  2. Relay call: the child's signed mail call and the parent's answer, with the from-domain allowlist and per-scope rate limit. Tests: refused domain, refused over the limit, the key absent from the call and the answer.
  3. Doors: admin page, API, MCP tool and terminal screen showing which scope's key is in effect, setting and removing an override, with the redaction test across all surfaces.
Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs