console: Task 6 CI fixes (perf budgets, route censuses, judged reads)
The branch was red since ad3a0f289; the full gate, run in Linux and compared with main 94a6471e2, found these, all from Task 6: - The serve doors' switch read is one GET: submissionSwitched reads the app sender object alone, as the agent's cache and the mailer do, instead of mail.GetSender, whose fallback to the legacy email.json made it two for an app with no sender object. Absent is off; an unreadable or unparsable object still refuses (502). - The one GET left is per write, with nothing a request memo could share, so the budgets name it: the perf session ceiling 418 -> 419 (its promote), and the write locks instance create 53 -> 54, promote 19 -> 20, instances-manifest put 7 -> 8, claim instance create 107 -> 108. Timing budgets unchanged. - POST .../email/submission joins the route censuses: a claim door fixture (switch off, set up switched; TestBuyDoorClaimBoundaries and the mutation invariant), testdata/claim-routes.txt, and linkedPolicies (linkedRefuse: a linked app's mail is managed at home; record-write census re-pinned). - The submission door, status and routes gate list records through the judged reader (s.listRecordsStrict), as TestNoUnjudgedRecordReads requires. - The mailer_unarmed alert's record decode is pinned in the copySince inventory: a read, not a copy change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
10 files changed,
+82
−18
internal/console/apimail.go+1 −2internal/console/apisubmission.go+1 −2internal/console/claim_invariant_fixtures_test.go+30 −0internal/console/copysince_paths_test.go+7 −3internal/console/linkedpolicy.go+1 −0internal/console/perfwrites_test.go+15 −5internal/console/submissiongate.go+21 −5internal/console/testdata/claim-routes.txt+1 −0internal/console/testdata/perf-session-s3.txt+1 −1internal/provision/platform_mail_submission_census_test.go+4 −0
CI failed — run details
diff --git a/internal/console/apimail.go b/internal/console/apimail.go| index 24b445145..2fee472a1 100644 |
| --- a/internal/console/apimail.go |
| +++ b/internal/console/apimail.go |
| @@ -61,7 +61,6 @@ import ( |
| "github.com/carlosframework/platform/internal/appconfig" |
| "github.com/carlosframework/platform/internal/dnsrec" |
| "github.com/carlosframework/platform/internal/mail" |
| - "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/schedule" |
| ) |
| @@ -524,7 +523,7 @@ func (s *Server) submissionStatus(ctx context.Context, acct, app string, sn *mai |
| if !st.On { |
| return st |
| } |
| - recs, unreadable, err := provision.ListRecordsStrict(ctx, s.cfg.Releases, acct, app, submissionRecordMax) |
| + recs, unreadable, err := s.listRecordsStrict(ctx, acct, app, submissionRecordMax) |
| boxes, berr := s.submissionBoxes(ctx, acct) |
| if err != nil || len(unreadable) > 0 || berr != nil { |
| st.BoxesUnknown = true |
diff --git a/internal/console/apisubmission.go b/internal/console/apisubmission.go| index eac3d8176..0be866dd1 100644 |
| --- a/internal/console/apisubmission.go |
| +++ b/internal/console/apisubmission.go |
| @@ -29,7 +29,6 @@ import ( |
| "github.com/carlosframework/platform/internal/mail" |
| "github.com/carlosframework/platform/internal/mailwire" |
| - "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| "github.com/carlosframework/platform/internal/status" |
| ) |
| @@ -237,7 +236,7 @@ func (s *Server) submissionPreconditions(ctx context.Context, acct, app string, |
| // 2. Every route runs a build that declares the transport, read from |
| // the boxes' fresh reports; a route no fresh box reports is refused, |
| // by name, as unconfirmed. |
| - recs, unreadable, err := provision.ListRecordsStrict(ctx, s.cfg.Releases, acct, app, submissionRecordMax) |
| + recs, unreadable, err := s.listRecordsStrict(ctx, acct, app, submissionRecordMax) |
| if err != nil || len(unreadable) > 0 { |
| if err != nil { |
| log.Printf("console: email submission %s/%s: records: %v", acct, app, err) |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index d0aa2cd44..c0d28a129 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -36,6 +36,7 @@ import ( |
| "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/hostclaim" |
| "github.com/carlosframework/platform/internal/hostops" |
| + "github.com/carlosframework/platform/internal/mail" |
| "github.com/carlosframework/platform/internal/objstore" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/registry" |
| @@ -1737,6 +1738,35 @@ var claimFixtures = map[string]claimFixture{ |
| }, |
| do: claimAPI(http.MethodPost, "/api/cli/apps/bab/titogo/email/rotate", `{}`), |
| }}, |
| + // The submission switch (platform mail submission Task 6). The door |
| + // switches off: on needs fresh box reports, records and declared |
| + // builds this world does not stage, and both directions write the same |
| + // app sender through the same claim mail store. Setup switches on |
| + // directly, through that store. |
| + "route POST /api/cli/apps/{account}/{app}/email/submission": {door: &claimDoor{ |
| + apps: claimRefs("bab/titogo"), |
| + setup: func(t *testing.T, cx *claimCase) { |
| + cx.emailProvisioned(t) |
| + if _, err := mail.SwitchOn(context.Background(), cx.srv.claimMailStore(), cx.srv.cfg.MailProvisioner, |
| + "bab", "titogo", nil, "setup@example.com", time.Now()); err != nil { |
| + t.Fatalf("switch on: %v", err) |
| + } |
| + }, |
| + do: claimAPI(http.MethodPost, "/api/cli/apps/bab/titogo/email/submission", `{"on":false}`), |
| + check: func(t *testing.T, cx *claimCase, open bool) string { |
| + sn, _, err := mail.GetSender(context.Background(), cx.rel, "bab", "titogo", mail.SenderAppID) |
| + if err != nil { |
| + return err.Error() |
| + } |
| + switch switched := mail.Switched(sn); { |
| + case open && switched: |
| + return "the open run did not switch submission off" |
| + case !open && !switched: |
| + return "a refused run switched submission off" |
| + } |
| + return "" |
| + }, |
| + }}, |
| "route POST /api/cli/apps/{account}/{app}/features": {door: &claimDoor{ |
| apps: claimRefs("bab/titogo"), |
| do: claimAPI(http.MethodPost, "/api/cli/apps/bab/titogo/features", `{"set":{"sandbox":"on"}}`), |
diff --git a/internal/console/copysince_paths_test.go b/internal/console/copysince_paths_test.go| index bd126c9a3..9ff13bdc9 100644 |
| --- a/internal/console/copysince_paths_test.go |
| +++ b/internal/console/copysince_paths_test.go |
| @@ -449,9 +449,13 @@ var copyInventory = map[string]map[string]int{ |
| // none: the stateless-replica deploy worker's in-memory queue, the |
| // record as noted (Note) and as taken off the queue (Pass); it |
| // writes no record. |
| - "(*internal/host.replicaDeployWorker).Note": 1, |
| - "(*internal/host.replicaDeployWorker).Pass": 1, |
| - "(*internal/console.ClaimPlacementCoordinator).Resume": 2, |
| + "(*internal/host.replicaDeployWorker).Note": 1, |
| + "(*internal/host.replicaDeployWorker).Pass": 1, |
| + "(*internal/console.ClaimPlacementCoordinator).Resume": 2, |
| + // none: the mailer_unarmed alert decodes a switched app's instance |
| + // records for their hosts (platform mail submission Task 6); it |
| + // writes nothing. |
| + "(*internal/console.engineReads).switchedRecordHosts": 1, |
| "(*internal/console.Server).migrationFinishLocked": 1, |
| "(*internal/console.Server).movesRecovery": 1, |
| "(*internal/console.Server).restoreProof": 1, |
diff --git a/internal/console/linkedpolicy.go b/internal/console/linkedpolicy.go| index c6880667f..dd254ac8e 100644 |
| --- a/internal/console/linkedpolicy.go |
| +++ b/internal/console/linkedpolicy.go |
| @@ -276,6 +276,7 @@ var linkedPolicies = map[string]linkedPolicy{ |
| "POST /api/cli/apps/{account}/{app}/email/credentials": linkedRefuse, |
| "DELETE /api/cli/apps/{account}/{app}/email/credentials/{name}": linkedRefuse, |
| "POST /api/cli/apps/{account}/{app}/email/pause": linkedRefuse, |
| + "POST /api/cli/apps/{account}/{app}/email/submission": linkedRefuse, |
| "POST /api/cli/apps/{account}/{app}/email/domains": linkedRefuse, |
| "POST /api/cli/apps/{account}/{app}/email/domains/{domain}/verify": linkedRefuse, |
| "DELETE /api/cli/apps/{account}/{app}/email/domains/{domain}": linkedRefuse, |
diff --git a/internal/console/perfwrites_test.go b/internal/console/perfwrites_test.go| index a8e3162df..30fa389e3 100644 |
| --- a/internal/console/perfwrites_test.go |
| +++ b/internal/console/perfwrites_test.go |
| @@ -331,14 +331,20 @@ type perfWriteLimit struct { |
| // one for instance create, promote and instances-manifest put; other |
| // request caps and every timing budget remain unchanged. |
| // P8: binary/non-hibernating ships again read no copies config. |
| +// Platform mail submission Task 6 (2026-11-14) adds one GET to instance |
| +// create, promote and instances-manifest put: the serve doors' submission |
| +// gate (decision 10) reads the app sender object once, so a switched app |
| +// cannot be made to serve a build that does not declare --mail submit. |
| +// One object, one GET (the gate reads it as the agent does, never the |
| +// legacy email.json fallback); every timing budget is unchanged. |
| func perfWriteLimits() map[string]perfWriteLimit { |
| return map[string]perfWriteLimit{ |
| "ship": {Calls: 32, Budget: perfWriteBudget}, |
| - "instance create": {Calls: 53, Budget: 700 * time.Millisecond, Over: "24 requests one after another: the manifest, the host holder (record then slot), the channel head (pointer then manifest), the plan cap's listings, then under the record lock the regional recheck's claim read (#447), the app's tombstone, this key's record and slot, every other app's, three writes in the lifetime protocol's order, the change index and the serial"}, |
| + "instance create": {Calls: 54, Budget: 700 * time.Millisecond, Over: "24 requests one after another: the manifest, the host holder (record then slot), the channel head (pointer then manifest), the plan cap's listings, then under the record lock the regional recheck's claim read (#447), the app's tombstone, this key's record and slot, every other app's, three writes in the lifetime protocol's order, the change index and the serial"}, |
| "app create": {Calls: 50, Budget: perfWriteBudget}, |
| - "promote": {Calls: 19, Budget: 600 * time.Millisecond, Over: "the signed promote's own reads and writes, one after another, inside release.PromoteOnLadder: on flagship 470 ms before this branch, one read fewer after it"}, |
| + "promote": {Calls: 20, Budget: 600 * time.Millisecond, Over: "the signed promote's own reads and writes, one after another, inside release.PromoteOnLadder: on flagship 470 ms before this branch, one read fewer after it"}, |
| "config put": {Calls: 10, Budget: perfWriteBudget}, |
| - "instances-manifest put": {Calls: 7, Budget: perfWriteBudget}, |
| + "instances-manifest put": {Calls: 8, Budget: perfWriteBudget}, |
| } |
| } |
| @@ -433,8 +439,8 @@ func perfClaimInstanceCreate(t *testing.T) { |
| } |
| requests := recorder.all() |
| most = max(most, len(requests)) |
| - if len(requests) > 107 { |
| - t.Errorf("claim create #%d: %d S3 requests, budget 107", n, len(requests)) |
| + if len(requests) > 108 { |
| + t.Errorf("claim create #%d: %d S3 requests, budget 108", n, len(requests)) |
| } |
| configReads := 0 |
| for _, q := range requests { |
| @@ -453,6 +459,10 @@ func perfClaimInstanceCreate(t *testing.T) { |
| // P9 baseline: 107 requests and 3.50s at 25ms/S3, including claim |
| // registration, ownership/record effects and completion. This is a |
| // separate protocol budget; the claims-off limits above stay unchanged. |
| + // 108 after platform mail submission Task 6 (2026-11-14): the create |
| + // door's submission gate (submissionChannelRefusal, decision 10) reads |
| + // the app sender object once, one GET, so a switched app cannot be |
| + // put on a channel heading an undeclared build. |
| median := times[len(times)/2] |
| budget := 4 * time.Second |
| if median > budget { |
diff --git a/internal/console/submissiongate.go b/internal/console/submissiongate.go| index 8b3a5a8d8..172237f55 100644 |
| --- a/internal/console/submissiongate.go |
| +++ b/internal/console/submissiongate.go |
| @@ -2,13 +2,14 @@ package console |
| import ( |
| "context" |
| + "encoding/json" |
| "errors" |
| "fmt" |
| "log" |
| "net/http" |
| "os" |
| - "github.com/carlosframework/platform/internal/mail" |
| + "github.com/carlosframework/platform/internal/mailwire" |
| "github.com/carlosframework/platform/internal/provision" |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| @@ -107,16 +108,31 @@ func submissionUnreadable() *doorRefusal { |
| // submissionSwitched reads whether acct/app's email submission is on. A |
| // read error is a refusal, never "off". |
| +// |
| +// It reads the app sender object alone, as the agent's switch cache and |
| +// the mailer do (mailwire.SenderKey, decoded as mailwire.SenderView): the |
| +// switch is only ever written there, so an absent object is off. That is |
| +// one GET a serve door, not mail.GetSender's two for an app with no |
| +// sender object (its fallback to the legacy email.json; perf budget, |
| +// Task 6 review). |
| func (s *Server) submissionSwitched(ctx context.Context, acct, app string) (bool, *doorRefusal) { |
| if s.cfg.Releases == nil { |
| return false, nil |
| } |
| - sn, _, err := mail.GetSender(ctx, s.cfg.Releases, acct, app, mail.SenderAppID) |
| + key := mailwire.SenderKey(acct, app, mailwire.SenderAppID) |
| + body, _, err := s.cfg.Releases.Get(ctx, key) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return false, nil |
| + } |
| + var v mailwire.SenderView |
| + if err == nil { |
| + err = json.Unmarshal(body, &v) |
| + } |
| if err != nil { |
| - log.Printf("console: submission gate %s/%s: read sender: %v", acct, app, err) |
| + log.Printf("console: submission gate %s/%s: read %s: %v", acct, app, key, err) |
| return false, submissionUnreadable() |
| } |
| - return mail.Switched(sn), nil |
| + return v.Submission != nil && v.Submission.On, nil |
| } |
| // submissionBuildRefusal is nil when acct/app's email submission is off, or |
| @@ -223,7 +239,7 @@ func (s *Server) submissionRoutesRefusal(ctx context.Context, acct, app string) |
| if ref != nil || !switched { |
| return ref |
| } |
| - recs, unreadable, err := provision.ListRecordsStrict(ctx, s.cfg.Releases, acct, app, submissionRecordMax) |
| + recs, unreadable, err := s.listRecordsStrict(ctx, acct, app, submissionRecordMax) |
| if err != nil || len(unreadable) > 0 { |
| if err != nil { |
| log.Printf("console: submission gate %s/%s: records: %v", acct, app, err) |
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt| index c4e11c8ef..78dbe3e71 100644 |
| --- a/internal/console/testdata/claim-routes.txt |
| +++ b/internal/console/testdata/claim-routes.txt |
| @@ -283,6 +283,7 @@ route POST /api/cli/apps/{account}/{app}/email/domains/{domain}/verify |
| route POST /api/cli/apps/{account}/{app}/email/enable |
| route POST /api/cli/apps/{account}/{app}/email/pause |
| route POST /api/cli/apps/{account}/{app}/email/rotate |
| +route POST /api/cli/apps/{account}/{app}/email/submission |
| route POST /api/cli/apps/{account}/{app}/environments/fork |
| route POST /api/cli/apps/{account}/{app}/environments/{name}/adopt |
| route POST /api/cli/apps/{account}/{app}/environments/{name}/release |
diff --git a/internal/console/testdata/perf-session-s3.txt b/internal/console/testdata/perf-session-s3.txt| index c8d8a14e8..33b33ad84 100644 |
| --- a/internal/console/testdata/perf-session-s3.txt |
| +++ b/internal/console/testdata/perf-session-s3.txt |
| @@ -1 +1 @@ |
| -418 after design-console-secrets, 2026-11-09: the settings Environments section reads the default bundle once per view (spec 2026-11-08-console-secrets-design.md, "Read budget (codex 9)"), and the session views it twice (6 S3 per view, 5 before; 416 before); all other GET-page costs and timing budgets are unchanged |
| +419 after platform mail submission Task 6, 2026-11-14: the session's single promote reads the app sender once, through the serve doors' submission gate (submissionBuildRefusal, decision 10: an undeclared build is refused while the app is switched), one GET per write and nothing a request memo could share (418 before); all GET-page costs and timing budgets are unchanged |
diff --git a/internal/provision/platform_mail_submission_census_test.go b/internal/provision/platform_mail_submission_census_test.go| index a7e609843..e2a1d80fb 100644 |
| --- a/internal/provision/platform_mail_submission_census_test.go |
| +++ b/internal/provision/platform_mail_submission_census_test.go |
| @@ -63,6 +63,10 @@ func platformMailSubmissionWriteCensusInventory() []censusEntry { |
| // default bundle (writeMailFromIn), as a re-declare may change it. |
| {"internal/mail/walk.go", "claimUnserializedDeclare", "reference", "id:Put", "0c93e8131cd554b46ba2cc6bf69689bdd766d552e72d42c3ff309d7f335be802"}, |
| {"internal/mail/walk.go", "claimUnserializedEnable", "reference", "id:Put", "c1bc29aebbe3d9577b2ca6cd9e6766143876a574a8273854919377dddc2b834b"}, |
| + // Task 6 CI fix: linkedPolicies classifies the new route, |
| + // POST .../email/submission, as linkedRefuse (a linked app's mail |
| + // is managed at home). A route-pattern literal; no store access. |
| + {"internal/console/linkedpolicy.go", "var linkedPolicies", "key-site", "lit:instances,lit:sidecars", "2c35594af28a461ba65ef59e9943b3e710d63f458bab0ecd4de729909c1d0cd7"}, |
| } |
| for _, r := range repins { |
| found := false |