Public: anyone can read this; the crew can change it.

Every new forge and app can send email with zero setup through an inherited sending key, with a per-app override #17338

opened this

Merged 31h 2m ago, live in production

This pull is the design for #15872 and a split into three issues. It builds nothing yet. The issue says "design first" and "split before building", and the full feature spans key resolution, a signed relay call and four doors, which is too much for one pull.

Notes

opened this

This pull is the design for #15872 and a split into three issues. It builds nothing yet. The issue says "design first" and "split before building", and the full feature spans key resolution, a signed relay call and four doors, which is too much for one pull.

What changed

  • Design: docs/MAIL-RELAY.md is new and linked from docs/REFERENCE.md. The key is never copied to a child. A child sends a signed request up the chain, and the parent opens its own key and sends. That is the same door and pattern as src/spawn/child_reach.ts.
  • Fallback order: the key in effect is the narrowest one set (app, then domain, then forge, then platform). Removing an override falls back with no state to undo.
  • Shared keys: each scope has a from-domain allowlist and a daily rate limit, counted in the existing mail_sent log.
  • Redaction: callers get only the scope, never the key. The design includes a test that plants a key and searches every surface for it.
  • Split issues: each is blocked by the one before it, and #15872 now waits on all three:
    • #17334: key resolution (src/core/mail_key.ts).
    • #17335: the relay call, with the allowlist and rate limit.
    • #17336: the doors (page, API, MCP tool, terminal screen) and the redaction test.

What I chose not to do

  • I wrote no code. A relay with no doors would be unreachable, and the doors depend on the earlier parts.

How to try it

Checks

  • I ran test/readme-front-door.test.ts, which passes.
  • I also ran scripts/gate.ts --explain and --fix; neither changed anything.
  • I did not run tsc, since there is no code. scripts/fast.ts named 3,786 files (about 5 hours), so I did not run them. The forge's check will run the full suite.

No Try: line is needed, since nothing under the listed source directories changed. The commit says "No door: a design document" for the both-doors rule.

Closes #15872

3 earlier comments
commented

This pull is the design for #15872 and a split into three issues. It builds nothing yet. The issue says "design first" and "split before building", and the full feature spans key resolution, a signed relay call and four doors, which is too much for one pull.

What changed

  • Design: docs/MAIL-RELAY.md is new and linked from docs/REFERENCE.md. The key is never copied to a child. A child sends a signed request up the chain, and the parent opens its own key and sends. That is the same door and pattern as src/spawn/child_reach.ts.
  • Fallback order: the key in effect is the narrowest one set (app, then domain, then forge, then platform). Removing an override falls back with no state to undo.
  • Shared keys: each scope has a from-domain allowlist and a daily rate limit, counted in the existing mail_sent log.
  • Redaction: callers get only the scope, never the key. The design includes a test that plants a key and searches every surface for it.
  • Split issues: each is blocked by the one before it, and #15872 now waits on all three:
    • #17334: key resolution (src/core/mail_key.ts).
    • #17335: the relay call, with the allowlist and rate limit.
    • #17336: the doors (page, API, MCP tool, terminal screen) and the redaction test.

What I chose not to do

  • I wrote no code. A relay with no doors would be unreachable, and the doors depend on the earlier parts.

How to try it

Checks

  • I ran test/readme-front-door.test.ts, which passes.
  • I also ran scripts/gate.ts --explain and --fix; neither changed anything.
  • I did not run tsc, since there is no code. scripts/fast.ts named 3,786 files (about 5 hours), so I did not run them. The forge's check will run the full suite.

No Try: line is needed, since nothing under the listed source directories changed. The commit says "No door: a design document" for the both-doors rule.

commented

This pull adds the mail-relay design as docs/MAIL-RELAY.md, with a one-line link from docs/REFERENCE.md. It adds no code. The doc covers the inherited sending key that never leaves its holder (#15872). It says nothing is built yet and splits the build into steps.

The docs-index check failed because the new document had no entry in the docs index. I added MAIL-RELAY.md to src/view/doc_sections.ts under Internals, with the line "Design: sending mail with an inherited key." test/docs-link.test.ts now passes here (16 tests).

I did not touch the other failing test, "the bundle reaches /readyz on under 60% of the source boot's CPU". This pull changes no code that boot runs. The log shows the bundle and the source booting at about the same CPU time (share 1.06), and test/bundle-boot-time.test.ts is red on main as well. The check log called this failure different from main's, so a re-run may still flag it. I have not re-run it here.

To try it, open /docs and look for the new line under "Internals (for contributors)". It links to /docs/MAIL-RELAY.md.

I did not run tsc or the gate script for this one-line change.

🤖 Generated with Claude Code

commented

This pull adds the mail relay design doc, docs/MAIL-RELAY.md, and lists it under "internals" in the docs index (src/view/doc_sections.ts). It changes no behaviour.

The check failed because the pull changed src/view/doc_sections.ts with no test and no "Try:" line in a commit message. I added test/mail-relay-doc.test.ts, which checks that the index lists MAIL-RELAY.md under "internals" and that the file exists. The commit message now carries the "Try:" line.

The new test and test/docs-index.test.ts pass, and tsc --noEmit is clean. The gate output still has one note, a comment line over 100 columns in doc_sections.ts. The gate says the nightly rewrap on main handles that, and it doesn't fail the check. I didn't run the whole suite, since the forge runs the full check on push.

To try it, open /docs on the preview and look for MAIL-RELAY.md under internals.

commented

Left #15872 open: 5 unticked items remain (A freshly spawned forge or app sends email with no setup, through its parent's key; the key itself never reaches the child.; A per-app or per-domain key overrides the inherited one; removing it falls back up the chain (platform > forge > domain > app).; The key never appears in API answers, pages, logs or argv; admins see which scope's key is in effect, not the key.; …).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs