mail: send through CARLOS mail submission (BLOCKED: the re-pin is red)
CARLOS platform mail submission (carlos plan Task 9). When the agent sets CARLOS_MAIL=submit and its control socket, Docs builds its sender with rastrillo's mail.FromCarlos (platformMailer in cmd/docs, From DOCS_MAIL_FROM) and holds no SMTP credential. SMTP alone still boots; neither is still the existing refusal outside development, now naming both ways to fix it. A half-configured submission refuses to start. Tests cover the three boots, and a submit send reaching POST /v1/mail on the socket. Deploy notes name carlos ship --mail submit, then promote: carlos deploy has no --mail flag yet (carlos main 9eec0236). NOT READY: mail.FromCarlos needs rastrillo at or after 11044699, and that re-pin (here to main 96812bea) brings every rastrillo change since this app's old pin. make ci is red on those, not on the mail change: the chromedp v0.21 port of the browser tests (the gate vets -tags browser), and the theme-asset fingerprint and busy.js tests (rastrillo's static assets changed). See the Task 9 report.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+222
−66
AGENTS.md+9 −0cmd/docs/mail_test.go+107 −0cmd/docs/main.go+33 −15go.mod+13 −14go.sum+28 −32internal/docs/app.go+4 −4internal/docs/auth.go+1 −1internal/docs/mail_refusal_test.go+27 −0
CI failed — run details
diff --git a/AGENTS.md b/AGENTS.md| index 1cfdbef..5b3dfeb 100644 |
| --- a/AGENTS.md |
| +++ b/AGENTS.md |
| @@ -394,6 +394,15 @@ time in a single afternoon: |
| "serving it" from "pointed at it". |
| *(Recorded from the live-sync deploy; not re-verified since, so the |
| timer's exact behaviour is one observation rather than a measurement.)* |
| +- **Ship with `--mail submit`.** It declares that the build sends through |
| + CARLOS mail submission (`mail.FromCarlos`, `platformMailer` in |
| + `cmd/docs`, From `$DOCS_MAIL_FROM`). Until `carlos email submission on |
| + --app docs` runs Docs keeps sending over `DOCS_SMTP_*`; after it the |
| + agent sets `CARLOS_MAIL=submit`, Docs holds no SMTP credential, and |
| + every instance must run a build shipped with the flag. `carlos deploy` |
| + has no `--mail` flag yet (carlos main 9eec0236), so until it does use |
| + `carlos ship --app docs --mail submit <binary>`, then `carlos promote`, |
| + and check `x-carlos-version` on the real host as above. |
| - **A library function that ignores its own "dry run" argument.** |
| `y-prosemirror`'s exported `undo` is `state => ...undoManager?.undo()` |
diff --git a/cmd/docs/mail_test.go b/cmd/docs/mail_test.go| new file mode 100644 |
| index 0000000..107ca16 |
| --- /dev/null |
| +++ b/cmd/docs/mail_test.go |
| @@ -0,0 +1,107 @@ |
| +package main |
| + |
| +import ( |
| + "context" |
| + "log/slog" |
| + "net" |
| + "net/http" |
| + "os" |
| + "path/filepath" |
| + "testing" |
| + |
| + "amadan.net/rastrillo/rastrillo/mail" |
| +) |
| + |
| +// The three boots CARLOS platform mail submission needs (carlos plan |
| +// Task 9): on submission with the agent's socket, on SMTP alone, and |
| +// with neither, which leaves Mailer nil for docs.New to refuse outside |
| +// development (TestNoMailRefusesOutsideDevelopment, internal/docs). |
| + |
| +// mailVars is every variable platformMailer and mail.FromCarlos read, |
| +// so each case starts from none of them. |
| +var mailVars = []string{"CARLOS_MAIL", "CARLOS_CONTROL_SOCKET", |
| + "CARLOS_ADMIN_TOKEN", "DOCS_MAIL_FROM", "DOCS_SMTP_HOST", |
| + "DOCS_SMTP_PORT", "DOCS_SMTP_FROM", "DOCS_SMTP_USER", "DOCS_SMTP_PASS"} |
| + |
| +func mailerWith(t *testing.T, env map[string]string) (mail.Sender, error) { |
| + t.Helper() |
| + for _, k := range mailVars { |
| + t.Setenv(k, "") |
| + } |
| + for k, v := range env { |
| + t.Setenv(k, v) |
| + } |
| + return platformMailer(slog.New(slog.DiscardHandler)) |
| +} |
| + |
| +// controlSocket stands in for the agent's socket: it answers POST |
| +// /v1/mail and reports each request's method and path. |
| +func controlSocket(t *testing.T) (string, chan string) { |
| + t.Helper() |
| + dir, err := os.MkdirTemp("/tmp", "docs-mail") // unix paths are short |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { os.RemoveAll(dir) }) |
| + socket := filepath.Join(dir, "control.sock") |
| + ln, err := net.Listen("unix", socket) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + seen := make(chan string, 1) |
| + srv := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + seen <- r.Method + " " + r.URL.Path |
| + w.Write([]byte(`{"message_id":"m-1"}`)) |
| + })} |
| + go srv.Serve(ln) |
| + t.Cleanup(func() { srv.Close() }) |
| + return socket, seen |
| +} |
| + |
| +func TestPlatformMailerSubmits(t *testing.T) { |
| + socket, seen := controlSocket(t) |
| + sender, err := mailerWith(t, map[string]string{ |
| + "CARLOS_MAIL": "submit", "CARLOS_CONTROL_SOCKET": socket, |
| + "CARLOS_ADMIN_TOKEN": "token", "DOCS_MAIL_FROM": "noreply@docs.oficina.works"}) |
| + if err != nil || sender == nil { |
| + t.Fatalf("sender %v, err %v", sender, err) |
| + } |
| + if err := sender.Send(context.Background(), "ana@example.com", "Sign in", "link"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got := <-seen; got != "POST /v1/mail" { |
| + t.Fatalf("the link went to %s, not the platform's mail verb", got) |
| + } |
| +} |
| + |
| +func TestPlatformMailerUsesSMTPAlone(t *testing.T) { |
| + sender, err := mailerWith(t, map[string]string{ |
| + "DOCS_SMTP_HOST": "email-smtp.eu-west-1.amazonaws.com", |
| + "DOCS_SMTP_FROM": "noreply@docs.oficina.works"}) |
| + if err != nil || sender == nil || !mail.IsConfigured(sender) { |
| + t.Fatalf("sender %v, err %v", sender, err) |
| + } |
| +} |
| + |
| +func TestPlatformMailerWithNeitherLeavesItToNew(t *testing.T) { |
| + sender, err := mailerWith(t, nil) |
| + if err != nil || sender != nil { |
| + t.Fatalf("sender %v, err %v: with no channel docs.New must decide", sender, err) |
| + } |
| +} |
| + |
| +func TestPlatformMailerRefusesHalfASubmission(t *testing.T) { |
| + // No socket: only the agent sets CARLOS_MAIL, and it sets both. |
| + if _, err := mailerWith(t, map[string]string{"CARLOS_MAIL": "submit", |
| + "DOCS_MAIL_FROM": "noreply@docs.oficina.works"}); err == nil { |
| + t.Fatal("built a submit sender with no control socket") |
| + } |
| + // The From is DOCS_MAIL_FROM, not CARLOS_MAIL_FROM: the platform |
| + // names it from Docs' DOCS_SMTP declaration. |
| + socket, _ := controlSocket(t) |
| + if _, err := mailerWith(t, map[string]string{"CARLOS_MAIL": "submit", |
| + "CARLOS_CONTROL_SOCKET": socket, "CARLOS_ADMIN_TOKEN": "token", |
| + "CARLOS_MAIL_FROM": "noreply@docs.oficina.works"}); err == nil { |
| + t.Fatal("built a submit sender with no DOCS_MAIL_FROM") |
| + } |
| +} |
diff --git a/cmd/docs/main.go b/cmd/docs/main.go| index 3d2805b..770fc92 100644 |
| --- a/cmd/docs/main.go |
| +++ b/cmd/docs/main.go |
| @@ -138,6 +138,32 @@ func checkSeedGate(seed bool, env string) error { |
| return fmt.Errorf("-seed requires -env development; refusing to seed a database that might not be a throwaway one (env=%q)", env) |
| } |
| +// platformMailer builds the magic-link sender from what the platform |
| +// configured, through rastrillo's mail.FromCarlos: CARLOS mail |
| +// submission when the agent set $CARLOS_MAIL=submit (the From is |
| +// $DOCS_MAIL_FROM, the control socket the agent's), else SMTP from |
| +// $DOCS_SMTP_HOST/$DOCS_SMTP_FROM and their siblings. A half-configured |
| +// channel is an error, so the process refuses to start rather than |
| +// failing the first sign-in. |
| +// |
| +// With neither channel it returns nil, and the decision is docs.New's |
| +// (Config.Mailer's own doc comment): rastrillo's logging sender in |
| +// development, a startup refusal anywhere else. mail.FromEnv would |
| +// instead fall back to logging a live credential silently. |
| +// |
| +// main calls it only on the serving path, never for docs-seal: a |
| +// CARLOS seed or one-shot has no control socket and the agent strips |
| +// $CARLOS_MAIL from it, so FromCarlos there would refuse a switched |
| +// app. |
| +func platformMailer(logger *slog.Logger) (mail.Sender, error) { |
| + smtp := strings.TrimSpace(os.Getenv("DOCS_SMTP_HOST")) != "" && |
| + strings.TrimSpace(os.Getenv("DOCS_SMTP_FROM")) != "" |
| + if os.Getenv("CARLOS_MAIL") != "submit" && !smtp { |
| + return nil, nil |
| + } |
| + return mail.FromCarlos("DOCS", logger) |
| +} |
| + |
| func main() { |
| logger := slog.Default() |
| if len(os.Args) > 1 && os.Args[1] == "docs-seal" { |
| @@ -213,21 +239,13 @@ func main() { |
| // development, the same fail-closed shape as an empty Origin. |
| instanceKey := os.Getenv("DOCS_INSTANCE_KEY") |
| - // $DOCS_SMTP_HOST/$DOCS_SMTP_FROM (and the sibling |
| - // $DOCS_SMTP_PORT/$DOCS_SMTP_USER/$DOCS_SMTP_PASS |
| - // rastrillo/mail.FromEnv also reads) configure real magic-link |
| - // delivery. Only built when both of the two values with no sane |
| - // default are actually set — mail.FromEnv itself falls back to a |
| - // silent warning-and-log Sender when they're missing, which is |
| - // the wrong answer outside development, so that decision is left |
| - // to docs.New (Config.Mailer's own doc comment): a nil Mailer |
| - // here is what lets it refuse to start rather than silently |
| - // logging a live credential in a real deployment's log. |
| - var mailer mail.Sender |
| - if host := strings.TrimSpace(os.Getenv("DOCS_SMTP_HOST")); host != "" { |
| - if from := strings.TrimSpace(os.Getenv("DOCS_SMTP_FROM")); from != "" { |
| - mailer = mail.FromEnv("DOCS", logger) |
| - } |
| + // The sign-in sender (platformMailer below): CARLOS mail submission |
| + // or $DOCS_SMTP_*, and nil with neither, which docs.New turns into |
| + // a refusal outside development. |
| + mailer, err := platformMailer(logger) |
| + if err != nil { |
| + logger.Error("docs: mail", "err", err) |
| + os.Exit(1) |
| } |
| // $DOCS_ALLOWED_ADDRESSES is the comma-separated allowlist |
diff --git a/go.mod b/go.mod| index 5c00a2c..89c7b50 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -12,32 +12,29 @@ require ( |
| amadan.net/oficina/home/teammode v0.0.0-20261030153823-602f5136f9af |
| amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4 |
| amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 |
| - amadan.net/rastrillo/rastrillo v0.29.1-0.20261027164201-054787952dd2 |
| + amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc |
| github.com/carlosframework/rastrillo v0.23.0 |
| - github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327 |
| - github.com/chromedp/chromedp v0.14.2 |
| + github.com/chromedp/cdproto v0.158.6 |
| + github.com/chromedp/chromedp v0.21.0 |
| github.com/go-chi/chi/v5 v5.3.2 |
| - github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 |
| + github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3 |
| github.com/go-text/typesetting v0.3.6-0.20261020210405-a4cf8f401e16 |
| github.com/google/uuid v1.6.0 |
| github.com/keymaildev/signin v0.1.1 |
| - github.com/modelcontextprotocol/go-sdk v1.7.0 |
| + github.com/modelcontextprotocol/go-sdk v1.8.0 |
| github.com/tetratelabs/wazero v1.12.0 |
| golang.org/x/image v0.23.0 |
| golang.org/x/oauth2 v0.35.0 |
| - golang.org/x/text v0.39.0 |
| + golang.org/x/text v0.41.0 |
| gorm.io/gorm v1.31.2 |
| ) |
| require ( |
| + amadan.net/rastrillo/fiesta v1.3.0 // indirect |
| amadan.net/rastrillo/rastrillo/money v0.1.0 // indirect |
| github.com/BurntSushi/toml v1.6.0 // indirect |
| - github.com/chromedp/sysutil v1.1.0 // indirect |
| github.com/danieljoos/wincred v1.2.3 // indirect |
| github.com/dustin/go-humanize v1.0.1 // indirect |
| - github.com/gobwas/httphead v0.1.0 // indirect |
| - github.com/gobwas/pool v0.2.1 // indirect |
| - github.com/gobwas/ws v1.4.0 // indirect |
| github.com/godbus/dbus/v5 v5.2.2 // indirect |
| github.com/gofrs/flock v0.12.1 // indirect |
| github.com/google/jsonschema-go v0.4.3 // indirect |
| @@ -49,13 +46,15 @@ require ( |
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 // indirect |
| github.com/segmentio/asm v1.1.3 // indirect |
| github.com/segmentio/encoding v0.5.4 // indirect |
| + github.com/tdewolff/minify/v2 v2.24.19 // indirect |
| + github.com/tdewolff/parse/v2 v2.8.16 // indirect |
| github.com/yosida95/uritemplate/v3 v3.0.2 // indirect |
| github.com/zalando/go-keyring v0.2.8 // indirect |
| - golang.org/x/mod v0.37.0 // indirect |
| - golang.org/x/sync v0.21.0 // indirect |
| - golang.org/x/sys v0.46.0 // indirect |
| + golang.org/x/mod v0.38.0 // indirect |
| + golang.org/x/sync v0.22.0 // indirect |
| + golang.org/x/sys v0.47.0 // indirect |
| golang.org/x/time v0.15.0 // indirect |
| - golang.org/x/tools v0.47.0 // indirect |
| + golang.org/x/tools v0.48.0 // indirect |
| gorm.io/plugin/dbresolver v1.6.2 // indirect |
| modernc.org/libc v1.74.1 // indirect |
| modernc.org/mathutil v1.7.1 // indirect |
diff --git a/go.sum b/go.sum| index 32f9010..f4422b1 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -14,22 +14,22 @@ amadan.net/oficina/home/teammode v0.0.0-20261030153823-602f5136f9af h1:QsC+WKvYx |
| amadan.net/oficina/home/teammode v0.0.0-20261030153823-602f5136f9af/go.mod h1:dXBZeB2ic33SIZiGUCzafmviUT8TYWgzSYZvo2rM6zA= |
| amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4 h1:BP+KHZTSgL7HDCz9IL/gxKXmbmXQpclUlJIyQEY/N2E= |
| amadan.net/oficina/suite v0.0.0-20261102002704-91affa14eae4/go.mod h1:Xgw0N+DBiDzkhQHm/nIhgumfaiMElDg/KIFD1OxTm5w= |
| +amadan.net/rastrillo/fiesta v1.3.0 h1:7SsHw4aeWPLStR3RHFEEtX4CwqKu+Ig3PgNX8FvD8WM= |
| +amadan.net/rastrillo/fiesta v1.3.0/go.mod h1:LpO391W1dIRUxOIKklHm+bGyWXtlFyBRRPQCysb9LjY= |
| amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3 h1:5EFx7BLJj/+G/rt8bTmeyMWVfF5s5Sns7ajTvX4w/I8= |
| amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3/go.mod h1:ZaaxeE278dJltdrLwmwpxUjQ5wuKzqDAVSNRet+WupY= |
| -amadan.net/rastrillo/rastrillo v0.29.1-0.20261027164201-054787952dd2 h1:ybFov1+wRduFtkxTn44QnzCKTDhyjfFWxWsW+cKaAyk= |
| -amadan.net/rastrillo/rastrillo v0.29.1-0.20261027164201-054787952dd2/go.mod h1:jSSeydqEvlm/fU3hhWoXFnyEaDgroR8LPRZSo9ZhhIM= |
| +amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc h1:QakboVkj9nqA6ZaKXeDVXWLPobQSVvd80ic521aA8/U= |
| +amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc/go.mod h1:y45ucMD+Al4tN47mmnm7h6pGDw7N20k0CMg6IwB9vfc= |
| amadan.net/rastrillo/rastrillo/money v0.1.0 h1:MxU4oqNrW8abxRTkgZBv24OYNpFnvonajNqeLIzmmaM= |
| amadan.net/rastrillo/rastrillo/money v0.1.0/go.mod h1:cmgkjBEIQh1pFSYvQk0UU6oPYS8kSDypdT9+t4Flx0U= |
| github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= |
| github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= |
| github.com/carlosframework/rastrillo v0.23.0 h1:tKAAlwPt4Pg/rkqk7o6jvV12bbZ0r34oEVpuOlKfX7w= |
| github.com/carlosframework/rastrillo v0.23.0/go.mod h1:pZlrE5F5OhspvZFzef0DrfjHAjA8FXycb9J5/8vc8Tw= |
| -github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327 h1:UQ4AU+BGti3Sy/aLU8KVseYKNALcX9UXY6DfpwQ6J8E= |
| -github.com/chromedp/cdproto v0.0.0-20250724212937-08a3db8b4327/go.mod h1:NItd7aLkcfOA/dcMXvl8p1u+lQqioRMq/SqDp71Pb/k= |
| -github.com/chromedp/chromedp v0.14.2 h1:r3b/WtwM50RsBZHMUm9fsNhhzRStTHrKdr2zmwbZSzM= |
| -github.com/chromedp/chromedp v0.14.2/go.mod h1:rHzAv60xDE7VNy/MYtTUrYreSc0ujt2O1/C3bzctYBo= |
| -github.com/chromedp/sysutil v1.1.0 h1:PUFNv5EcprjqXZD9nJb9b/c9ibAbxiYo4exNWZyipwM= |
| -github.com/chromedp/sysutil v1.1.0/go.mod h1:WiThHUdltqCNKGc4gaU50XgYjwjYIhKWoHGPTUfWTJ8= |
| +github.com/chromedp/cdproto v0.158.6 h1:jaKiXWuhcxbvKbSe8U6Dp5U4Hcj2w6lETYgZqBD5n34= |
| +github.com/chromedp/cdproto v0.158.6/go.mod h1:h68JaIuFr9o3yiayxEYhBdvaxgYO3shDrPSYhNlyfu0= |
| +github.com/chromedp/chromedp v0.21.0 h1:nVHgS2LHyhZJ1l3BWRbG2eFIFYiJMnvkJbELbd8WBoQ= |
| +github.com/chromedp/chromedp v0.21.0/go.mod h1:6z1Y5FdKUxRzxx2qcC5h1xjaBJrSWrZp1mjgITfNZig= |
| github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ= |
| github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs= |
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
| @@ -40,20 +40,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp |
| github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= |
| github.com/go-chi/chi/v5 v5.3.2 h1:5YQkICvTCSZ25hoRsyJazN0scjzKGiu4VAUc7H1o1nY= |
| github.com/go-chi/chi/v5 v5.3.2/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto= |
| -github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2 h1:iizUGZ9pEquQS5jTGkh4AqeeHCMbfbjeb0zMt0aEFzs= |
| -github.com/go-json-experiment/json v0.0.0-20250725192818-e39067aee2d2/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M= |
| +github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3 h1:UADEEmDKgfXbtnGJZ97beY5XLo9ZechG1nlU4KnRrkE= |
| +github.com/go-json-experiment/json v0.0.0-20260820222146-c27c302e5fc3/go.mod h1:tphK2c80bpPhMOI4v6bIc2xWywPfbqi1Z06+RcrMkDg= |
| github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= |
| github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
| github.com/go-text/typesetting v0.3.6-0.20261020210405-a4cf8f401e16 h1:Y+spgzS5aYmWDN24nN4UYamN2vFBJ/HzUJRsGcFS2KY= |
| github.com/go-text/typesetting v0.3.6-0.20261020210405-a4cf8f401e16/go.mod h1:4xCar1jOQWppRqQHqtLTUghn73m8dsbk9tUFioaHdHU= |
| github.com/go-text/typesetting-utils v0.0.0-20260922124329-7d4869a3934e h1:ARqqlg1JI1oiFHTGKXqh08omHnZuPrMcwtrEGELOW/E= |
| github.com/go-text/typesetting-utils v0.0.0-20260922124329-7d4869a3934e/go.mod h1:3/62I4La/HBRX9TcTpBj4eipLiwzf+vhI+7whTc9V7o= |
| -github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= |
| -github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= |
| -github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= |
| -github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= |
| -github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs= |
| -github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc= |
| github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ= |
| github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c= |
| github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= |
| @@ -76,18 +70,14 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= |
| github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= |
| github.com/keymaildev/signin v0.1.1 h1:gO+1IAM99sqUkBtCezkgGxab+/DOrqwDxd5H32N1s9Q= |
| github.com/keymaildev/signin v0.1.1/go.mod h1:Eb/sCmEel1jlcdkgPOrNeMn5jvxzoFvJrdjDUxOBHls= |
| -github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80 h1:6Yzfa6GP0rIo/kULo2bwGEkFvCePZ3qHDDTC3/J9Swo= |
| -github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= |
| github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
| github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
| github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= |
| github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= |
| -github.com/modelcontextprotocol/go-sdk v1.7.0 h1:yqjY2dsbKAC0LSuWZVBMrHgiG8ukXv6NRo0JiALay44= |
| -github.com/modelcontextprotocol/go-sdk v1.7.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= |
| +github.com/modelcontextprotocol/go-sdk v1.8.0 h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4= |
| +github.com/modelcontextprotocol/go-sdk v1.8.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= |
| github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= |
| github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= |
| -github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= |
| -github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= |
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
| github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= |
| @@ -104,6 +94,12 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= |
| github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= |
| github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= |
| github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= |
| +github.com/tdewolff/minify/v2 v2.24.19 h1:j2exx54gvrCFN9UiFm0Z5vbNWBFcuY5Ql1VmaM2Dkeo= |
| +github.com/tdewolff/minify/v2 v2.24.19/go.mod h1:HVgQO08FJeDxQx+lcFOVDi1IySi/77WlN/dDckCkZoA= |
| +github.com/tdewolff/parse/v2 v2.8.16 h1:bLk5svUOQRkW/Y2SJ+DeENSIkZBcTIkq+Atyv5D8feI= |
| +github.com/tdewolff/parse/v2 v2.8.16/go.mod h1:XdsoSFThlVIRIajAuqz1evNY7bagZS8LBOPA3aVopwQ= |
| +github.com/tdewolff/test v1.0.12 h1:7F21DqIajswxuche0geHdrUZRCWE4oko4b7bcmkkrxk= |
| +github.com/tdewolff/test v1.0.12/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= |
| github.com/tetratelabs/wazero v1.12.0 h1:DuWcpNu/FzgEXgGBDp8J1Spc+CWOvvtvVyjKlaZopYU= |
| github.com/tetratelabs/wazero v1.12.0/go.mod h1:LvKtzl2RqO4gyF27BiXU+nKAjcV8f38U+kP/q2vgxh0= |
| github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= |
| @@ -112,21 +108,21 @@ github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPc |
| github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0= |
| golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= |
| golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= |
| -golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= |
| -golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= |
| +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= |
| +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= |
| golang.org/x/oauth2 v0.35.0 h1:Mv2mzuHuZuY2+bkyWXIHMfhNdJAdwW3FuWeCPYN5GVQ= |
| golang.org/x/oauth2 v0.35.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= |
| -golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= |
| -golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= |
| +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= |
| +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= |
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| -golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= |
| -golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= |
| -golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus= |
| -golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM= |
| +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= |
| +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= |
| +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= |
| +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= |
| golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= |
| golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= |
| -golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q= |
| -golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA= |
| +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= |
| +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= |
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
| gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= |
diff --git a/internal/docs/app.go b/internal/docs/app.go| index a700867..2a5c8d4 100644 |
| --- a/internal/docs/app.go |
| +++ b/internal/docs/app.go |
| @@ -153,10 +153,10 @@ type Config struct { |
| // startup refusal: a sign-in that cannot send its link is not |
| // sign-in, and silently falling back to logging a live credential |
| // in a real deployment's log is exactly the mistake that fallback |
| - // exists to flag, not absorb. cmd/docs/main.go builds this from |
| - // $DOCS_SMTP_HOST/$DOCS_SMTP_FROM (and the other |
| - // $DOCS_SMTP_* vars rastrillo/mail.FromEnv reads) when both are |
| - // set, and leaves it nil otherwise — New.buildMailer (auth.go) is |
| + // exists to flag, not absorb. cmd/docs/main.go builds this with |
| + // rastrillo/mail.FromCarlos (platformMailer) when CARLOS mail |
| + // submission is on ($CARLOS_MAIL=submit) or $DOCS_SMTP_HOST and |
| + // $DOCS_SMTP_FROM are both set, and leaves it nil otherwise — New.buildMailer (auth.go) is |
| // what turns "nil outside development" into the refusal, the same |
| // split Origin/InstanceKey use. |
| Mailer mail.Sender |
diff --git a/internal/docs/auth.go b/internal/docs/auth.go| index e6d31f5..11989b6 100644 |
| --- a/internal/docs/auth.go |
| +++ b/internal/docs/auth.go |
| @@ -75,7 +75,7 @@ func buildMailer(cfg Config, logger *slog.Logger) (mail.Sender, *recordingMailer |
| sender := cfg.Mailer |
| if sender == nil { |
| if cfg.Env != "development" { |
| - return nil, nil, fmt.Errorf("docs: mail is not configured (set $DOCS_SMTP_HOST and $DOCS_SMTP_FROM) and Env is %q, not %q — refusing to start: a sign-in that cannot send its link is not sign-in", cfg.Env, "development") |
| + return nil, nil, fmt.Errorf("docs: mail is not configured (CARLOS mail submission sets $CARLOS_MAIL=submit; otherwise set $DOCS_SMTP_HOST and $DOCS_SMTP_FROM) and Env is %q, not %q — refusing to start: a sign-in that cannot send its link is not sign-in", cfg.Env, "development") |
| } |
| // Loudly labelled by mail.Logged itself on every send — see |
| // its own doc comment; this is the dev/test-only fallback, |
diff --git a/internal/docs/mail_refusal_test.go b/internal/docs/mail_refusal_test.go| new file mode 100644 |
| index 0000000..ccb5d10 |
| --- /dev/null |
| +++ b/internal/docs/mail_refusal_test.go |
| @@ -0,0 +1,27 @@ |
| +package docs |
| + |
| +import ( |
| + "log/slog" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +// TestNoMailRefusesOutsideDevelopment is the third boot of CARLOS mail |
| +// submission (cmd/docs mail_test.go has the other two): with neither |
| +// channel, cmd/docs leaves Mailer nil, and that is a refusal anywhere |
| +// but development, naming both ways to fix it. |
| +func TestNoMailRefusesOutsideDevelopment(t *testing.T) { |
| + logger := slog.New(slog.DiscardHandler) |
| + _, _, err := buildMailer(Config{Env: "production"}, logger) |
| + if err == nil { |
| + t.Fatal("started with no mail in production") |
| + } |
| + for _, want := range []string{"CARLOS_MAIL=submit", "DOCS_SMTP_HOST"} { |
| + if !strings.Contains(err.Error(), want) { |
| + t.Errorf("refusal %q does not name %s", err, want) |
| + } |
| + } |
| + if sender, _, err := buildMailer(Config{Env: "development"}, logger); err != nil || sender == nil { |
| + t.Fatalf("development: sender %v, err %v", sender, err) |
| + } |
| +} |