mail submission follow-ups: deploy and canary take --mail; the From is platform-managed
Paul approved both on 2026-11-17, following platform mail submission (9eec0236). carlos deploy and carlos canary [deploy] take --mail submit, the declaration only carlos ship had. They reuse ship's path: validShipMail before the first read or write, and apiSession.shipMail, so the console door's checks (a rootfs release refused, a re-ship of a version with a different declaration refused) and checkMailEcho apply unchanged. The deploy usage moves to a const (runDeploy stays under its func-lines record, lowered 331 -> 329). <stem>_MAIL_FROM (mail.MailFromName of the declared prefix) and CARLOS_MAIL join platformManagedKeys: a team's config write refuses them, and adopt and fork leave them out. The switch's own delivery (DeliverMailFromIn, after adopt and fork) still writes the From. Copy: mail-submission-followups-copy.json, reviewed by Luna under Paul's delegation; MSF-C3 and MSF-C4 applied as Luna rewrote them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 files changed,
+394
−28
.amadan/code-health.tsv+1 −1apimode.go+2 −1approved_mail_submission_followups_copy_test.go+35 −0canary.go+6 −2deploy.go+12 −6deploy_mail_test.go+93 −0deploy_region_e2e_test.go+14 −1docs/site/cli.md+6 −1docs/superpowers/notes/LUNA-COPY-BRIEF-mail-submission-followups.md+69 −0docs/superpowers/notes/LUNA-COPY-RESULT-mail-submission-followups.md+10 −0docs/superpowers/plans/mail-submission-followups-copy.json+41 −0internal/console/apienv_test.go+9 −4internal/console/apisubmission_test.go+58 −0internal/console/teamdoors_test.go+12 −5internal/console/teamenv.go+21 −7ship_mail.go+5 −0
diff --git a/.amadan/code-health.tsv b/.amadan/code-health.tsv| index f7870e1d4..aab439f50 100644 |
| --- a/.amadan/code-health.tsv |
| +++ b/.amadan/code-health.tsv |
| @@ -2166,7 +2166,7 @@ host-context internal/host validateServingParkRecord context.Background 2 |
| host-context internal/host wireRawSecretPages context.Background 1 |
| host-context internal/host withEffectiveMovesFloorLock context.Background 2 |
| func-lines . TestFleetAppServesThroughTheHub - 408 |
| -func-lines . runDeploy - 331 |
| +func-lines . runDeploy - 329 |
| func-lines . runRoute - 519 |
| func-lines cmd/console serve - 370 |
| func-lines internal/activator (*Service).doWakeOnce - 567 |
diff --git a/apimode.go b/apimode.go| index 2e3373dc1..e7048ac17 100644 |
| --- a/apimode.go |
| +++ b/apimode.go |
| @@ -91,7 +91,8 @@ type apiSession struct { |
| shipSwap string |
| shipStateless bool |
| // shipMail is the release's mail declaration for ship (--mail), set by |
| - // runShip and carried exactly as shipSwap is. "" sends no mail key. |
| + // runShip, runDeploy and runCanaryDeploy and carried exactly as |
| + // shipSwap is. "" sends no mail key. |
| shipMail string |
| // shipAssets is the release's asset folders for ship (--assets), set by |
| // runShip, carried exactly as shipSwap is. nil sends no assets key. |
diff --git a/approved_mail_submission_followups_copy_test.go b/approved_mail_submission_followups_copy_test.go| new file mode 100644 |
| index 000000000..8053dfe3b |
| --- /dev/null |
| +++ b/approved_mail_submission_followups_copy_test.go |
| @@ -0,0 +1,35 @@ |
| +package main |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + "testing" |
| +) |
| + |
| +// mailSubmissionFollowupsCopyIDs is the copy inventory of the mail |
| +// submission follow-ups (carlos deploy and carlos canary take --mail |
| +// submit): the two usage lines and the docs page's three passages. |
| +var mailSubmissionFollowupsCopyIDs = []string{"MSF-C1", "MSF-C2", "MSF-C3", "MSF-C4", "MSF-C5"} |
| + |
| +// Every string of the follow-ups' copy record is in the file it names, |
| +// byte for byte. A draft record (no approved_by) is checked the same way, |
| +// so the record and the code cannot drift apart while its review is |
| +// pending, and the test says it is pending. |
| +func TestApprovedMailSubmissionFollowupsCopy(t *testing.T) { |
| + raw, err := os.ReadFile("docs/superpowers/plans/mail-submission-followups-copy.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var rec map[string]any |
| + if err := json.Unmarshal(raw, &rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if rec["approved_by"] == "" { |
| + t.Log("mail submission follow-ups copy: DRAFT, awaiting its copy review") |
| + rec["approved_by"], rec["approved_on"] = "draft", "draft" |
| + if raw, err = json.Marshal(rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + checkApprovedCopy(t, raw, ".", mailSubmissionFollowupsCopyIDs, nil) |
| +} |
diff --git a/canary.go b/canary.go| index 4f4ba3091..862b8f965 100644 |
| --- a/canary.go |
| +++ b/canary.go |
| @@ -38,7 +38,7 @@ import ( |
| const canaryUsage = `usage: carlos canary [deploy] --app <a> [--name <n>] [--version <sha>] [--kind binary|static] |
| [--region <code>] [--environment <e>] [--target <goos-goarch>] [--label <l>] |
| - [--timeout 120s] <files-or-site-dir> |
| + [--mail submit] [--timeout 120s] <files-or-site-dir> |
| carlos canary ls --app <a> |
| carlos canary rm --app <a> --name <n> |
| @@ -503,6 +503,7 @@ func runCanaryDeploy(args []string) { |
| target := fs.String("target", "linux-arm64", "GOOS-GOARCH the binary was built for (binary kind, single file)") |
| label := fs.String("label", "", "one line for humans — shows up in carlos releases and in the console") |
| timeout := fs.Duration("timeout", defaultDeployTimeout, "how long to watch the canary URL before failing") |
| + mail := fs.String("mail", "", shipMailFlagHelp) |
| fs.Usage = flagUsage(fs, canaryUsage) |
| fs.Parse(args) |
| @@ -516,8 +517,10 @@ func runCanaryDeploy(args []string) { |
| if *ver == "" { |
| *ver = gitShortHead() |
| } |
| + // --mail is ship's declaration, refused as ship refuses it, with the |
| + // name and before the first read. |
| canary, err := canaryNameFrom(strings.TrimSpace(*name), gitBranch()) |
| - if err != nil { |
| + if err = errors.Join(err, validShipMail(*mail)); err != nil { |
| log.Fatal(err) |
| } |
| @@ -648,6 +651,7 @@ func runCanaryDeploy(args []string) { |
| } |
| // printBanner false: printUsing above already said it once. |
| + sess.shipMail = *mail |
| if _, err = runShipAPI(sess, acct, fs, app2, *ver, *kind, *target, *label, "", nil, false, false); err != nil { |
| log.Fatalf("canary: ship: %v", err) |
| } |
diff --git a/deploy.go b/deploy.go| index 31238df62..801f188f7 100644 |
| --- a/deploy.go |
| +++ b/deploy.go |
| @@ -125,6 +125,12 @@ func deployAssetsToSave(flagSet bool, paths, saved []string) ([]string, bool) { |
| return paths, true |
| } |
| +// deployUsage is runDeploy's usage line (C11.23). |
| +const deployUsage = "usage: carlos deploy --app <a> [--version <sha>] [--kind binary|static] [--target linux-arm64] " + |
| + "[--account <sqid-or-name>] [--account-id <sqid>] [--console <origin> | -d <destination>] [--capabilities <file.json>] " + |
| + "[--channel <ch>] [--host <host>] [--region <code>] [--label <text>] [--notes <text>] [--swap hold] [--mail submit] [--assets <folder>]... [--no-assets] [--temporary] [--ttl 7d] [--timeout 120s] <files-or-site-dir>\n" + |
| + "or, in a project with saved defaults (or at a terminal, to create them): carlos deploy [-d <destination>]" |
| + |
| // runDeploy is `carlos deploy`. API-mode only (spec §6): direct-bucket |
| // operators keep ship + promote as separate acts; deploy is the member path |
| // that ships, promotes to the channel the app's instances already follow, |
| @@ -157,6 +163,7 @@ func runDeploy(args []string) { |
| ttlFlag := fs.String("ttl", "", "how long a temporary app lives, 1h to 30d (default 7d); implies --temporary") // C11.22 |
| regionFlag := fs.String("region", "", flagRegionDeploy) |
| swap := fs.String("swap", "", shipSwapFlagHelp) |
| + mail := fs.String("mail", "", shipMailFlagHelp) |
| var assets assetPathsFlag |
| fs.Var(&assets, "assets", shipAssetsFlagHelp) |
| var envValues deployEnvFlag |
| @@ -168,10 +175,7 @@ func runDeploy(args []string) { |
| if envErr != nil { |
| log.Fatalf("deploy: %v", envErr) |
| } |
| - usage := "usage: carlos deploy --app <a> [--version <sha>] [--kind binary|static] [--target linux-arm64] " + |
| - "[--account <sqid-or-name>] [--account-id <sqid>] [--console <origin> | -d <destination>] [--capabilities <file.json>] " + |
| - "[--channel <ch>] [--host <host>] [--region <code>] [--label <text>] [--notes <text>] [--swap hold] [--assets <folder>]... [--no-assets] [--temporary] [--ttl 7d] [--timeout 120s] <files-or-site-dir>\n" + // C11.23 |
| - "or, in a project with saved defaults (or at a terminal, to create them): carlos deploy [-d <destination>]" |
| + usage := deployUsage |
| temp, ttl, terr := temporaryDeployFlags(*temporary, flagWasSet(fs, "ttl"), *ttlFlag, *hostFlag, flagWasSet(fs, "kind"), *kind, fs.NArg()) |
| if terr != nil { |
| log.Fatalf("deploy: %v", terr) |
| @@ -197,7 +201,9 @@ func runDeploy(args []string) { |
| if err := deployPreflight(".", flagWasSet(fs, "version")); err != nil { |
| log.Fatal(err) |
| } |
| - if err := validSwapFlag(*swap); err != nil { |
| + // --swap and --mail are ship's declarations, refused here as ship |
| + // refuses them, before the console is asked anything. |
| + if err := errors.Join(validSwapFlag(*swap), validShipMail(*mail)); err != nil { |
| log.Fatal(err) |
| } |
| // A bad capability file is still refused before anything ships — but the |
| @@ -214,7 +220,7 @@ func runDeploy(args []string) { |
| sess := requireDeployAPISession(*consoleFlag) // API-mode only: member verb |
| sess.deferSaves = true // deploy makes ONE combined save offer, below |
| printUsing(stdout, sess) // printed HERE, once: runShipAPI's own banner is suppressed below |
| - sess.shipSwap = *swap |
| + sess.shipSwap, sess.shipMail = *swap, *mail |
| acct := resolvedAccount(sess, acctRaw, acctIDRaw) |
| ctx := context.Background() |
diff --git a/deploy_mail_test.go b/deploy_mail_test.go| new file mode 100644 |
| index 000000000..f4d13655d |
| --- /dev/null |
| +++ b/deploy_mail_test.go |
| @@ -0,0 +1,93 @@ |
| +package main |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "strings" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// TestDeployAndCanaryCarryTheMailDeclaration: `carlos deploy --mail submit` |
| +// and `carlos canary deploy --mail submit` declare the build's mail |
| +// transport exactly as `carlos ship --mail submit` does, through the same |
| +// ship (apiSession.shipMail), against a real console: a value but submit |
| +// is refused in ship's words before anything is written; the manifest |
| +// carries the declaration; a re-deploy of the version with a different |
| +// declaration is the console's conflict; and a console that does not echo |
| +// it stops the deploy before the promote. A rootfs release has no door |
| +// here: deploy and canary ship binaries and sites only, and the console |
| +// refuses a rootfs release that declares --mail (PMS-C38). |
| +// |
| +// Each subtest has its own console because the ship door allows a token |
| +// two uploads a minute (cliShipBurst). |
| +func TestDeployAndCanaryCarryTheMailDeclaration(t *testing.T) { |
| + if testing.Short() { |
| + t.Skip("runs the carlos binary") |
| + } |
| + ctx := context.Background() |
| + deploy := func(e *regionE2E, version string, extra ...string) []string { |
| + args := []string{"deploy", "--app", "titogo", "--console", e.url, "--channel", "canary/e2e", |
| + "--version", version, "--timeout", "1s"} |
| + return append(append(args, extra...), artifact(t)) |
| + } |
| + canary := func(e *regionE2E, version string, extra ...string) []string { |
| + args := []string{"canary", "deploy", "--app", "titogo", "--name", "probe", "--console", e.url, |
| + "--version", version, "--timeout", "1s"} |
| + return append(append(args, extra...), artifact(t)) |
| + } |
| + mailOf := func(t *testing.T, e *regionE2E, version string) string { |
| + t.Helper() |
| + m, err := release.GetManifest(ctx, e.store, release.OpsAccount, "titogo", version) |
| + if err != nil { |
| + t.Fatalf("manifest %s: %v", version, err) |
| + } |
| + return m.Mail |
| + } |
| + |
| + t.Run("deploy", func(t *testing.T) { |
| + e := regionE2EConsole(t, "") |
| + for _, args := range [][]string{deploy(e, "v0", "--mail", "smtp"), canary(e, "v0", "--mail", "smtp")} { |
| + out, err := e.run(t, args...) |
| + if err == nil || !strings.Contains(out, fmt.Sprintf(shipBadMail, "smtp")) { |
| + t.Fatalf("%s --mail smtp: %v\n%s", args[0], err, out) |
| + } |
| + } |
| + if n := e.writes.Load(); n != 0 || e.releases(t) != 0 { |
| + t.Fatalf("a refused --mail wrote %d time(s) and stored %d release(s)", n, e.releases(t)) |
| + } |
| + if out, _ := e.run(t, deploy(e, "v1", "--mail", "submit")...); mailOf(t, e, "v1") != release.MailSubmit { |
| + t.Fatalf("deploy --mail submit stored v1 without it:\n%s", out) |
| + } |
| + out, err := e.run(t, deploy(e, "v1")...) |
| + if err == nil || !strings.Contains(out, "version v1 was already shipped with a different mail declaration") { |
| + t.Fatalf("re-deploy of v1 with no declaration: %v\n%s", err, out) |
| + } |
| + }) |
| + |
| + t.Run("canary", func(t *testing.T) { |
| + e := regionE2EConsole(t, "") |
| + if out, _ := e.run(t, canary(e, "v1", "--mail", "submit")...); mailOf(t, e, "v1") != release.MailSubmit { |
| + t.Fatalf("canary deploy --mail submit stored v1 without it:\n%s", out) |
| + } |
| + if out, _ := e.run(t, deploy(e, "v2")...); mailOf(t, e, "v2") != "" { |
| + t.Fatalf("deploy with no --mail stored a declaration:\n%s", out) |
| + } |
| + }) |
| + |
| + t.Run("no echo", func(t *testing.T) { |
| + e := regionE2EConsole(t, "") |
| + e.mode.Store("no-mail-echo") |
| + for _, args := range [][]string{deploy(e, "v1", "--mail", "submit"), canary(e, "v2", "--mail", "submit")} { |
| + out, err := e.run(t, args...) |
| + if err == nil || !strings.Contains(out, shipMailNoEcho) { |
| + t.Fatalf("%s against a console that does not echo --mail: %v\n%s", args[0], err, out) |
| + } |
| + } |
| + keys, err := e.store.List(ctx, release.ChannelsPrefix(release.OpsAccount, "titogo")) |
| + if err != nil || len(keys) != 0 { |
| + t.Fatalf("a ship the console did not confirm was promoted: %v %v", keys, err) |
| + } |
| + }) |
| +} |
diff --git a/deploy_region_e2e_test.go b/deploy_region_e2e_test.go| index 038905a2f..8423eec41 100644 |
| --- a/deploy_region_e2e_test.go |
| +++ b/deploy_region_e2e_test.go |
| @@ -26,7 +26,7 @@ type regionE2E struct { |
| creds string |
| url string |
| store release.Store |
| - mode atomic.Value // "", "fail", "legacy", "region-unknown", "placement-unknown" |
| + mode atomic.Value // "", "fail", "legacy", "region-unknown", "placement-unknown", "no-mail-echo" |
| writes atomic.Int64 |
| // creates counts instance-create requests (POST …/instances), so a |
| // test can tell a duplicate create from the other writes (Task 22). |
| @@ -122,6 +122,19 @@ func regionE2EConsole(t *testing.T, appRegion string) *regionE2E { |
| return |
| } |
| } |
| + if r.Method == http.MethodPost && strings.HasSuffix(r.URL.Path, "/releases") && e.mode.Load().(string) == "no-mail-echo" { |
| + // A console from before --mail: it stores the release and |
| + // answers without the declaration. |
| + rec := httptest.NewRecorder() |
| + srv.ServeHTTP(rec, r) |
| + var m map[string]any |
| + json.Unmarshal(rec.Body.Bytes(), &m) |
| + delete(m, "mail") |
| + w.Header().Set("Content-Type", "application/json") |
| + w.WriteHeader(rec.Code) |
| + json.NewEncoder(w).Encode(m) |
| + return |
| + } |
| srv.ServeHTTP(w, r) |
| })) |
| t.Cleanup(ts.Close) |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index 6dd60f1d6..cb96d300b 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -384,6 +384,8 @@ having no instances to resolve a channel from. |
| carlos deploy --app website --kind static --host www.example.com ./dist |
| ``` |
| +`--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos ship](/docs/cli#carlos-ship). Once email submission is on for the app, deploy every build with it. A build without it is shipped but not promoted. |
| + |
| `--swap hold` ships a release that stops each instance before starting the |
| new build, for a migration the previous build cannot share the database |
| with. It applies to that release only; `carlos apps set --swap hold` makes it |
| @@ -618,6 +620,8 @@ dashes. The name and the app share one hostname label, so together they can be a |
| region). It is refused for an existing canary in another region, and for an |
| app that runs on one of your fleets. |
| +`--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos deploy](/docs/cli#carlos-deploy). |
| + |
| Promotion into a canary is never refused, on any app, from any rung. Nor |
| does a canary cost you a rung: canary channels sit outside every pipeline, so |
| a build that has been on one still enters the pipeline as a fresh build. |
| @@ -2493,7 +2497,8 @@ sends it, and no instance holds an SMTP credential. Each bundle gets one |
| variable instead, `<P>_MAIL_FROM` (the prefix with its `_SMTP` cut off, so |
| `CARLOS_MAIL_FROM` by default), which the app's mail library reads. The |
| switch refuses until every instance runs a build shipped with |
| -`--mail submit`, every channel they follow heads one, every box hosting the |
| +`--mail submit` (`carlos ship`, `carlos deploy` and `carlos canary` all take |
| +it), every channel they follow heads one, every box hosting the |
| app has its mailer armed, and the deployment counts sends through SES |
| events; each refusal says what to do. A route with no instance record can't |
| send mail once it is on, and its app refuses to start, so check |
diff --git a/docs/superpowers/notes/LUNA-COPY-BRIEF-mail-submission-followups.md b/docs/superpowers/notes/LUNA-COPY-BRIEF-mail-submission-followups.md| new file mode 100644 |
| index 000000000..a265ceeed |
| --- /dev/null |
| +++ b/docs/superpowers/notes/LUNA-COPY-BRIEF-mail-submission-followups.md |
| @@ -0,0 +1,69 @@ |
| +# Copy pass: mail submission follow-ups, rows pending review |
| + |
| +You are the copy-review gate itself for this set. Paul delegated copy review |
| +of platform CLI, UI and docs copy to you on 2026-10-25, so your verdicts are |
| +the review. Do NOT run the copy-review skill and do NOT start any server. You |
| +are writing a review report into a scratch file. |
| + |
| +CARLOS is a hosting platform. An app can send email through the platform in |
| +two ways: with an SMTP credential the platform delivers into its |
| +environment, or, once the app owner switches "email submission" on, by |
| +posting each message to a socket on its own box, so the app holds no |
| +credential. A build has to declare that it can do the second: it is |
| +shipped with `--mail submit`. Until this change only `carlos ship` took the |
| +flag, but app owners are told to use `carlos deploy` (ship, promote and |
| +wait until the URL serves the build) and `carlos canary` (the same onto a |
| +throwaway host for a branch). This change gives both of them `--mail |
| +submit`, with the same meaning and the same refusals as ship. While email |
| +submission is on, the console refuses to promote a build that does not |
| +declare it. |
| + |
| +The readers are app owners and their developers. They read these strings in |
| +`carlos` CLI usage lines and in the docs page. They are technical but not |
| +platform operators. |
| + |
| +## What to review |
| + |
| +`docs/superpowers/plans/mail-submission-followups-copy.json`: every entry |
| +(MSF-C1 to MSF-C5). The `note` says where each one appears. MSF-C1 and |
| +MSF-C2 are usage lines: only the `[--mail submit]` part is new, and the |
| +rest of each line must stay as it is. MSF-C3 to MSF-C5 are in |
| +`docs/site/cli.md` (sections "carlos deploy", "carlos canary" and |
| +"carlos email"); read the paragraphs around them for tone and facts. |
| + |
| +The record's `reused` field lists strings that are already approved and are |
| +not changing, but now appear in more places. Do not rewrite them. Flag one |
| +only if it reads wrongly in its new place. |
| + |
| +You may read the code to check a fact (the branch is |
| +`feat/mail-submission-followups`, checked out in this directory; see |
| +`deploy.go`, `canary.go`, `ship_mail.go`). Change nothing on disk. |
| + |
| +## House rules (Paul's) |
| + |
| +- Plain, direct voice. Say what happened, then what to do. No marketing |
| + tone, no exclamation marks, no "simply", no throat-clearing. |
| +- No em or en dashes used as dashes. Use a full stop and a new sentence. |
| +- Human text only. Leave error fragments, log keys, JSON keys and flag names |
| + alone. |
| +- No tenant or customer names. Examples use neutral names (shop, |
| + example.com, box-a). |
| +- Keep every placeholder (`%s`, `%d`, `%v`, `{{...}}`) in the same order. If |
| + you must reorder one, say so in "why". |
| +- CLI refusals are lower case, like the rest of the CLI's errors, and end |
| + without a full stop where the existing rows do. |
| +- Never tell the user to run a command on a box. Point to a `carlos` command |
| + or the console. |
| +- Undefined jargon is not fine. "Build", "release", "box", "deploy", |
| + "promote", "channel" and "email submission" are the product's words. |
| + |
| +## What to return |
| + |
| +Write `/Users/paulcampbell/.cache/tmp/claude-mailfollowups/luna-review.md` with: |
| + |
| +1. A table `key | new | why`, with only the rows you change. Rows you leave |
| + alone are approved as they are. |
| +2. A `## Flags` section with only what needs a person: a fact in the copy |
| + that conflicts with the code, a placeholder you can't make work, or a |
| + string that needs splitting or a product decision. Keep it short. Write |
| + "none" if there are none. |
diff --git a/docs/superpowers/notes/LUNA-COPY-RESULT-mail-submission-followups.md b/docs/superpowers/notes/LUNA-COPY-RESULT-mail-submission-followups.md| new file mode 100644 |
| index 000000000..7b4f9be73 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/LUNA-COPY-RESULT-mail-submission-followups.md |
| @@ -0,0 +1,10 @@ |
| +# Luna copy review |
| + |
| +| key | new | why | |
| +| --- | --- | --- | |
| +| MSF-C3 | `--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos ship](/docs/cli#carlos-ship). Once email submission is on for the app, deploy every build with it. A build without it is shipped but not promoted. | Separates the declaration from the cross-reference, so the sentence does not make `carlos ship` sound like the transport. Keeps the existing behavior and refusal clear. | |
| +| MSF-C4 | `--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos deploy](/docs/cli#carlos-deploy). | Reuses the defined “submission socket” wording and removes the undefined term “mail transport.” | |
| + |
| +## Flags |
| + |
| +none |
diff --git a/docs/superpowers/plans/mail-submission-followups-copy.json b/docs/superpowers/plans/mail-submission-followups-copy.json| new file mode 100644 |
| index 000000000..db2a3b0df |
| --- /dev/null |
| +++ b/docs/superpowers/plans/mail-submission-followups-copy.json |
| @@ -0,0 +1,41 @@ |
| +{ |
| + "approved_by": "Luna copy pass (gpt-5.6-luna), delegated under Paul's standing rule of 2026-10-25 for platform copy; MSF-C3 and MSF-C4 applied verbatim as Luna rewrote them, MSF-C1, MSF-C2 and MSF-C5 approved as drafted; no flags", |
| + "approved_on": "2026-11-17", |
| + "status": "APPROVED by Luna under Paul's delegation (2026-10-25).", |
| + "change": "Mail submission follow-ups (branch feat/mail-submission-followups, approved by Paul 2026-11-17): carlos deploy and carlos canary take --mail submit; <stem>_MAIL_FROM and CARLOS_MAIL are platform-managed.", |
| + "reused": "Unchanged approved strings this change shows in more places, for context only: PMS-C35 (the --mail flag help, now in deploy -h and canary -h), PMS-C36 (the bad-value refusal), PMS-C37 (the no-echo refusal, printed by deploy as 'deploy: ship: <text>' and by canary as 'canary: ship: <text>'), PMS-C39 (the re-ship conflict), and the team config door's refusal 'cannot set or unset a platform-managed key (%s): the platform delivers those into its environments itself' (internal/console/apiconfig.go), which can now name <stem>_MAIL_FROM and CARLOS_MAIL.", |
| + "entries": [ |
| + { |
| + "id": "MSF-C1", |
| + "file": "deploy.go", |
| + "text": "[--swap hold] [--mail submit] [--assets <folder>]...", |
| + "note": "deployUsage: carlos deploy's usage line gains [--mail submit]" |
| + }, |
| + { |
| + "id": "MSF-C2", |
| + "file": "canary.go", |
| + "text": "[--mail submit] [--timeout 120s] <files-or-site-dir>", |
| + "note": "canaryUsage: carlos canary [deploy]'s usage gains [--mail submit]" |
| + }, |
| + { |
| + "id": "MSF-C3", |
| + "file": "docs/site/cli.md", |
| + "text": "`--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos ship](/docs/cli#carlos-ship). Once email submission is on for the app, deploy every build with it. A build without it is shipped but not promoted.", |
| + "note": "docs: carlos deploy section, before --swap hold" |
| + }, |
| + { |
| + "id": "MSF-C4", |
| + "file": "docs/site/cli.md", |
| + "text": "`--mail submit` declares that the build can send mail through Carlos's submission socket. It has the same meaning as [carlos deploy](/docs/cli#carlos-deploy).", |
| + "note": "docs: carlos canary section, after --region" |
| + }, |
| + { |
| + "id": "MSF-C5", |
| + "file": "docs/site/cli.md", |
| + "text": "`--mail submit` (`carlos ship`, `carlos deploy` and `carlos canary` all take\nit), every channel", |
| + "note": "docs: carlos email section, the submission on paragraph's precondition" |
| + } |
| + ], |
| + "brief": "docs/superpowers/notes/LUNA-COPY-BRIEF-mail-submission-followups.md", |
| + "result": "docs/superpowers/notes/LUNA-COPY-RESULT-mail-submission-followups.md" |
| +} |
diff --git a/internal/console/apienv_test.go b/internal/console/apienv_test.go| index 85a1573f6..5c6797970 100644 |
| --- a/internal/console/apienv_test.go |
| +++ b/internal/console/apienv_test.go |
| @@ -52,6 +52,8 @@ func TestEnvironmentAdoptAndRelease(t *testing.T) { |
| "OWN": {Kind: "env", Value: "1"}, |
| "TITO_SMTP_PASS": {Kind: "secret", Envelope: "x"}, |
| "TITO_SMTP_HOST": {Kind: "env", Value: "h"}, |
| + "TITO_MAIL_FROM": {Kind: "env", Value: "someone@example.com"}, |
| + "CARLOS_MAIL": {Kind: "env", Value: "submit"}, |
| relayVar: {Kind: "secret", Envelope: "y"}, |
| }, nil); err != nil { |
| t.Fatal(err) |
| @@ -86,7 +88,7 @@ func TestEnvironmentAdoptAndRelease(t *testing.T) { |
| if err := json.Unmarshal([]byte(out), &res); err != nil { |
| t.Fatal(err) |
| } |
| - if res.Scope != "alta" || strings.Join(res.Stripped, ",") != "CARLOS_RELAY,TITO_SMTP_HOST,TITO_SMTP_PASS" { |
| + if res.Scope != "alta" || strings.Join(res.Stripped, ",") != "CARLOS_MAIL,CARLOS_RELAY,TITO_MAIL_FROM,TITO_SMTP_HOST,TITO_SMTP_PASS" { |
| t.Fatalf("adopt answer = %+v", res) |
| } |
| m, _, _, err := appconfig.GetEnvironment(ctx, fx.rel, "bab", "titogo", "lagged") |
| @@ -140,6 +142,7 @@ func TestEnvironmentFork(t *testing.T) { |
| _, _, envelope := sealedFor(t, "s") |
| if err := appconfig.SaveEnvironment(ctx, fx.rel, "bab", "titogo", "lagged", map[string]appconfig.Var{ |
| "OWN": {Kind: "env", Value: "1"}, "S": {Kind: "secret", Envelope: envelope}, relayVar: {Kind: "secret", Envelope: "y"}, |
| + mailTransportVar: {Kind: "env", Value: "submit"}, |
| }, nil); err != nil { |
| t.Fatal(err) |
| } |
| @@ -176,8 +179,10 @@ func TestEnvironmentFork(t *testing.T) { |
| if err != nil || m.OwnerScope != "alta" || m.Schema != 2 { |
| t.Fatalf("forked = %+v, %v", m, err) |
| } |
| - if _, ok := m.Vars[relayVar]; ok { |
| - t.Error("fork carried CARLOS_RELAY") |
| + for _, k := range []string{relayVar, mailTransportVar} { |
| + if _, ok := m.Vars[k]; ok { |
| + t.Errorf("fork carried %s", k) |
| + } |
| } |
| if _, ok := m.Vars["OWNER_CANARY"]; ok { |
| t.Error("fork carried a default-bundle key") |
| @@ -190,7 +195,7 @@ func TestEnvironmentFork(t *testing.T) { |
| } |
| // The source is untouched, and a team credential now reaches the fork. |
| src, _, _, _ := appconfig.GetEnvironment(ctx, fx.rel, "bab", "titogo", "lagged") |
| - if src.OwnerScope != "" || len(src.Vars) != 3 { |
| + if src.OwnerScope != "" || len(src.Vars) != 4 { |
| t.Errorf("source after fork = %+v", src) |
| } |
| team := teamToken(t, fx.st, OpsAccountID, "alta-titogo", "titogo", "alta") |
diff --git a/internal/console/apisubmission_test.go b/internal/console/apisubmission_test.go| index d6e695c61..4dd19216b 100644 |
| --- a/internal/console/apisubmission_test.go |
| +++ b/internal/console/apisubmission_test.go |
| @@ -664,3 +664,61 @@ func TestRotateRefusesASwitchedApp(t *testing.T) { |
| t.Fatalf("rotate while switched: %d %s, want 409 naming the switch", status, out) |
| } |
| } |
| + |
| +// Mail submission follow-ups: <stem>_MAIL_FROM and CARLOS_MAIL are |
| +// platform-managed, so adopt and fork leave a bundle's own copies out, and |
| +// the platform's delivery still puts the switched app's From into the |
| +// environment each door makes owned. The copies a person planted (a From |
| +// that is not the app's, a transport the box decides) never reach a scope. |
| +func TestSwitchedAdoptAndForkLeaveTheFromToThePlatform(t *testing.T) { |
| + w := newSubmissionWorld(t, "code-submission-adopt-from") |
| + w.switchOn(t) |
| + ctx := context.Background() |
| + const from = "noreply@titogo.bab.oncarlos.com" |
| + if err := appconfig.SaveEnvironment(ctx, w.fx.rel, "bab", "titogo", "loose", map[string]appconfig.Var{ |
| + "OWN": {Kind: "env", Value: "1"}, |
| + "TITO_MAIL_FROM": {Kind: "env", Value: "someone@example.com"}, |
| + mailTransportVar: {Kind: "env", Value: "submit"}, |
| + }, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + // The owned environment the world made: its From is the platform's; |
| + // a CARLOS_MAIL written beside it directly is what a fork must drop. |
| + if _, err := appconfig.ApplyEnvironment(ctx, w.fx.rel, "bab", "titogo", "team", |
| + map[string]appconfig.Var{mailTransportVar: {Kind: "env", Value: "submit"}}, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + check := func(what, env, out string) { |
| + t.Helper() |
| + var res struct { |
| + Stripped []string `json:"stripped"` |
| + } |
| + if err := json.Unmarshal([]byte(out), &res); err != nil { |
| + t.Fatalf("%s: %v %s", what, err, out) |
| + } |
| + stripped := strings.Join(res.Stripped, ",") |
| + if !strings.Contains(stripped, "TITO_MAIL_FROM") || !strings.Contains(stripped, mailTransportVar) { |
| + t.Errorf("%s left out %q, want TITO_MAIL_FROM and %s", what, stripped, mailTransportVar) |
| + } |
| + vars := w.vars(t, env) |
| + if got := vars["TITO_MAIL_FROM"].Value; got != from { |
| + t.Errorf("%s: %s holds TITO_MAIL_FROM %q, want the platform's %q", what, env, got, from) |
| + } |
| + if _, ok := vars[mailTransportVar]; ok { |
| + t.Errorf("%s: %s holds %s", what, env, mailTransportVar) |
| + } |
| + } |
| + status, _, out := rawReq(t, http.MethodPost, w.fx.ts.URL+"/api/cli/apps/bab/titogo/environments/loose/adopt", w.owner, `{"scope":"alta"}`) |
| + if status != http.StatusOK { |
| + t.Fatalf("adopt = %d %s", status, out) |
| + } |
| + check("adopt", "loose", out) |
| + if w.vars(t, "loose")["OWN"].Value != "1" { |
| + t.Error("adopt dropped the environment's own key") |
| + } |
| + status, _, out = rawReq(t, http.MethodPost, w.fx.ts.URL+"/api/cli/apps/bab/titogo/environments/fork", w.owner, `{"from":"team","to":"crew","scope":"alta"}`) |
| + if status != http.StatusOK { |
| + t.Fatalf("fork = %d %s", status, out) |
| + } |
| + check("fork", "crew", out) |
| +} |
diff --git a/internal/console/teamdoors_test.go b/internal/console/teamdoors_test.go| index 5a0958687..5a044df84 100644 |
| --- a/internal/console/teamdoors_test.go |
| +++ b/internal/console/teamdoors_test.go |
| @@ -737,8 +737,10 @@ func TestTeamFloorBarrier(t *testing.T) { |
| // TestTeamPlatformManagedKeysRefused is §8.20: a team's PUT /config cannot |
| // set or unset a key the delivery walks own, computed from the app's mail |
| -// and store records (the prefixes are the member's), nor the two fixed |
| -// names. |
| +// and store records (the prefixes are the member's), nor the three fixed |
| +// names. The mail record's keys include the submit transport's From |
| +// (<stem>_MAIL_FROM), and the fixed names CARLOS_MAIL, which the box |
| +// composes at every spawn (mail submission follow-ups). |
| func TestTeamPlatformManagedKeysRefused(t *testing.T) { |
| w := newTeamWorld(t, "code-team-managed") |
| ctx := context.Background() |
| @@ -752,6 +754,7 @@ func TestTeamPlatformManagedKeysRefused(t *testing.T) { |
| t.Fatal(err) |
| } |
| for _, k := range []string{"TITO_SMTP_PASS", "TITO_SMTP_HOST", "TITO_SMTP_FROM", MailEventsKeyEnv, relayVar, |
| + "TITO_MAIL_FROM", "CARLOS_MAIL", |
| "TITO_S3_ACCESS_KEY", "TITO_S3_SCAN_CALLBACK_SECRET", "TEAM_S3_BUCKET", "TEAM_S3_SCAN_CALLBACK_SECRET"} { |
| set := fmt.Sprintf(`{"environment":"team","set":{%q:{"kind":"env","value":"x"}}}`, k) |
| if status, _, out := rawReq(t, http.MethodPut, w.url("/config"), w.team, set); status != http.StatusBadRequest || !strings.Contains(out, k) { |
| @@ -763,9 +766,13 @@ func TestTeamPlatformManagedKeysRefused(t *testing.T) { |
| } |
| } |
| // A key with the prefix's shape but not one of the five is the |
| - // team's own. |
| - if status, _, out := rawReq(t, http.MethodPut, w.url("/config"), w.team, `{"environment":"team","set":{"TITO_SMTP_REPLY_TO":{"kind":"env","value":"x"}}}`); status != http.StatusOK { |
| - t.Errorf("set a team's own key = %d %s", status, out) |
| + // team's own, and so is a From named with the _SMTP kept: the submit |
| + // transport's From is mail.MailFromName's, the stem plus _MAIL_FROM. |
| + for _, k := range []string{"TITO_SMTP_REPLY_TO", "TITO_SMTP_MAIL_FROM"} { |
| + set := fmt.Sprintf(`{"environment":"team","set":{%q:{"kind":"env","value":"x"}}}`, k) |
| + if status, _, out := rawReq(t, http.MethodPut, w.url("/config"), w.team, set); status != http.StatusOK { |
| + t.Errorf("set a team's own key %s = %d %s", k, status, out) |
| + } |
| } |
| // A person is not bound by this: the walks overwrite what they own. |
| if status, _, out := rawReq(t, http.MethodPut, w.url("/config"), w.member, `{"environment":"plain","set":{"TITO_SMTP_PASS":{"kind":"env","value":"x"}}}`); status != http.StatusOK { |
diff --git a/internal/console/teamenv.go b/internal/console/teamenv.go| index 3d4001b44..c3dde2ac6 100644 |
| --- a/internal/console/teamenv.go |
| +++ b/internal/console/teamenv.go |
| @@ -23,14 +23,16 @@ import ( |
| // platformManagedKeys is the set of var names the delivery walks own in |
| // app's bundles (§3a), computed from the app's records rather than a |
| // constant list (round 3, P3-2): the SMTP five from the mail record's |
| -// prefix (mail.EnvNames), the object-store five and the scan callback |
| -// secret from each store record's prefix (the app store and env's own |
| -// store), plus the two fixed names, the mail-events key and CARLOS_RELAY. |
| -// A team's PUT /config refuses any of them; adopt and fork never copy |
| -// them. An app with no mail or store record contributes only the fixed |
| -// names: a prefix the member has not chosen yet protects nothing. |
| +// prefix (mail.EnvNames) and the submit transport's From the switch |
| +// delivers in their place (mail.MailFromName, <stem>_MAIL_FROM), the |
| +// object-store five and the scan callback secret from each store record's |
| +// prefix (the app store and env's own store), plus the three fixed names: |
| +// the mail-events key, CARLOS_RELAY and CARLOS_MAIL. A team's PUT /config |
| +// refuses any of them; adopt and fork never copy them. An app with no mail |
| +// or store record contributes only the fixed names: a prefix the member |
| +// has not chosen yet protects nothing. |
| func (s *Server) platformManagedKeys(ctx context.Context, acct, app, env string) (map[string]bool, error) { |
| - keys := map[string]bool{MailEventsKeyEnv: true, relayVar: true} |
| + keys := map[string]bool{MailEventsKeyEnv: true, relayVar: true, mailTransportVar: true} |
| if rec, _, err := mail.Get(ctx, s.cfg.Releases, acct, app); err != nil { |
| return nil, fmt.Errorf("mail record: %w", err) |
| } else if rec != nil && rec.Declared != nil && rec.Declared.EnvPrefix != "" { |
| @@ -38,6 +40,12 @@ func (s *Server) platformManagedKeys(ctx context.Context, acct, app, env string) |
| for _, k := range []string{h, p, u, pw, f} { |
| keys[k] = true |
| } |
| + // The From is managed whether or not the app is switched now: the |
| + // switch writes it and switch-off takes it out. A prefix with no |
| + // _SMTP stem names no From and is never delivered one. |
| + if mf, err := mail.MailFromName(rec.Declared.EnvPrefix); err == nil { |
| + keys[mf] = true |
| + } |
| } |
| stores := []string{""} |
| if env != "" { |
| @@ -59,6 +67,12 @@ func (s *Server) platformManagedKeys(ctx context.Context, acct, app, env string) |
| return keys, nil |
| } |
| +// mailTransportVar is the variable a box composes for each instance from |
| +// the app's submission switch (CARLOS_MAIL=submit, decision 11): the |
| +// agent sets or strips it at every spawn, so a bundle's copy is never |
| +// read, and a team has no business writing one. |
| +const mailTransportVar = "CARLOS_MAIL" |
| + |
| // platformManagedList is the keys of m that are platform-managed, sorted: |
| // what adopt and fork strip (§5), and what a team write is refused for. |
| func platformManagedList(managed map[string]bool, names []string) []string { |
diff --git a/ship_mail.go b/ship_mail.go| index 1b4d282fe..25cc31ee0 100644 |
| --- a/ship_mail.go |
| +++ b/ship_mail.go |
| @@ -11,12 +11,17 @@ import ( |
| // carlos ship --mail submit: the build's mail transport declaration |
| // (release.Manifest.Mail, platform mail submission decision 10). The apps |
| // have no manifest file to hold it, so the declaration is a ship flag. |
| +// deploy and canary deploy take the same flag and carry it to the same |
| +// ship (apiSession.shipMail), so the console's checks and the echo below |
| +// hold for all three: a rootfs release is refused at the console's door, |
| +// and a re-ship of a version with a different declaration is its 409. |
| const shipMailFlagHelp = "declare this build's mail transport. the one value is submit: the build sends through carlos's submission socket when CARLOS_MAIL=submit is set" |
| const shipBadMail = "--mail %q: the one value is submit" |
| const shipMailNoEcho = "ship: this console predates --mail and stored the release without it. Nothing was promoted. Upgrade the console, then ship under a new version" |
| // validShipMail refuses any --mail value but "" and release.MailSubmit, in |
| // one line, before the mode split, so both doors refuse the same value. |
| +// deploy and canary deploy call it before their first read or write. |
| func validShipMail(mail string) error { |
| if release.ValidateMail(mail) != nil { |
| return fmt.Errorf(shipBadMail, mail) |