carlos / platform Public

console: declare apimail.go routes in routeDecls

The email API's 14 doors become declarations, and the role table that
explained them moves with them to routedecls.go, so the words still sit
next to the Allow values they argue for. registerEmailRoutes and its
call in NewServer are deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 82d76a69130200a418cfb06aa2f7ffc8c183c1f8 parent 53931f9
3 files changed, +72 −82
  • internal/console/apimail.go +0 −78
  • internal/console/routedecls.go +72 −0
  • internal/console/server.go +0 −4

Intent

Human

<task-notification> <task-id>b8irxa405</task-id> <summary>Monitor event: "Task 2 commits landing on design-parity-guard"</summary> <event>53931f92 console: declare apiinstancemove.go routes in routeDecls</event> </task-notification>

Attributed to this commit: 4.17 g CO₂e (553,391 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-parity-guard, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/apimail.go b/internal/console/apimail.go
index c0f585f7a..18b4ec152 100644
--- a/internal/console/apimail.go
+++ b/internal/console/apimail.go
@@ -63,7 +63,6 @@ import (
"github.com/carlosframework/platform/internal/mail"
"github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/schedule"
- "github.com/carlosframework/platform/internal/svcrole"
)
// mailTimeout bounds a single round trip: declare, status, and a domain
@@ -495,83 +494,6 @@ func (s *Server) mailWalkReply(ctx context.Context, w http.ResponseWriter, acct
writeJSON(w, http.StatusOK, out)
}
-// registerEmailRoutes wires this file's ten doors onto s.mux, through the
-// role gate (cliRoute) like every other /api/cli/ door. It stays a separate
-// function from registerCLIRoutes only so the email family's reasoning lives
-// beside the handlers it describes; svcroutes_test's AST pass is
-// package-wide precisely so a second registration site is still covered.
-//
-// THE ROLE TABLE, and why each door reads as it does.
-//
-// The seven OPEN doors take Allow(Admin), matching the store family verb
-// for verb — declare, ensure, verify, REMOVE, enable, rotate all move an
-// account's backend estate, and `enable` mints a path-scoped IAM user
-// exactly as `store grant` does. Admin is the union role, so
-// Publish/Instance/Operate are refused: a credential that may deploy an app
-// must not thereby be able to give it a sending identity on a domain the
-// account owns.
-//
-// `domains rm` is Admin because `domains add` is: the same authority, run
-// backwards. It is deliberately NOT closed or operator-gated — the whole
-// defect it exists to fix is that releasing a claim required an authority
-// (permanent app deletion) far larger than claiming one ever did, which is
-// what left real deployments with a domain nobody could ever free.
-//
-// GET .../email is Admin rather than a read role for the same reason GET
-// .../store is: the status reply names the IAM user, the key id and the
-// verified domains — the estate, not just the app.
-//
-// GET .../email/events is Admin too, and for a different reason: it names
-// the people the app wrote to. A credential that may read an app's routes
-// or deploy it has no need of its recipients' addresses.
-//
-// The three .../email/events/push doors are Admin for the same reason: turning
-// the push on is what starts recipients' addresses leaving the console, and
-// the status names them in its last failure. The addresses only ever go to
-// the app's own platform host (mailpush.go), so this is not a grant to send
-// them anywhere — but it is a decision about them, and Admin makes it.
-//
-// The three CLOSED doors (svcrole.Set{} — closed to every role, admin
-// included) are each closed for their own reason:
-//
-// - credentials create is the ONLY door in either family that hands a
-// plaintext sending secret back to its caller. Store never does: its
-// secret goes into sealed config and the console keeps no key to open
-// it. This one must, because the whole point of a standalone credential
-// is a human copying it into an off-platform MTA (spec §6b). An
-// on-platform app never needs this door — it is delivered its own
-// credentials as env by `enable`. So the one caller this door exists
-// for is a person, and a service credential reaching it would turn
-// "may deploy" into "may send as this domain, indefinitely".
-// - credentials revoke is closed with it. Nothing a service could have
-// minted here exists for it to clean up, and the services family closes
-// create and revoke together for the same symmetry.
-// - pause already resolves an ADDRESS against CARLOS_MAIL_OPERATORS
-// (mailOperator), which no service principal can ever hold. Naming a
-// role here would be a registration that lies about who gets in — the
-// objection authcli.go raises against exactly that shape. It also
-// RAISES THE CAP, which is an authority grant, not a runtime toggle.
-//
-// All three are pinned at the intent level too (mintDoors, policyDoors in
-// svcroutes_test.go), so reopening one takes an edit that argues with the
-// words next to it, not just a line moved in closedDoors.
-func (s *Server) registerEmailRoutes() {
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email", svcrole.Allow(svcrole.Admin), s.handleAPIEmailDeclare)
- s.cliRoute("GET /api/cli/apps/{account}/{app}/email", svcrole.Allow(svcrole.Admin), s.handleAPIEmailStatus)
- s.cliRoute("GET /api/cli/apps/{account}/{app}/email/events", svcrole.Allow(svcrole.Admin), s.handleAPIEmailEvents)
- s.cliRoute("GET /api/cli/apps/{account}/{app}/email/events/push", svcrole.Allow(svcrole.Admin), s.handleAPIEmailPushStatus)
- s.cliRoute("PUT /api/cli/apps/{account}/{app}/email/events/push", svcrole.Allow(svcrole.Admin), s.handleAPIEmailPushSet)
- s.cliRoute("DELETE /api/cli/apps/{account}/{app}/email/events/push", svcrole.Allow(svcrole.Admin), s.handleAPIEmailPushOff)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/domains", svcrole.Allow(svcrole.Admin), s.handleAPIEmailDomainEnsure)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/domains/{domain}/verify", svcrole.Allow(svcrole.Admin), s.handleAPIEmailDomainVerify)
- s.cliRoute("DELETE /api/cli/apps/{account}/{app}/email/domains/{domain}", svcrole.Allow(svcrole.Admin), s.handleAPIEmailDomainRemove)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/enable", svcrole.Allow(svcrole.Admin), s.handleAPIEmailEnable)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/rotate", svcrole.Allow(svcrole.Admin), s.handleAPIEmailRotate)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/credentials", svcrole.Set{}, s.handleAPIEmailCredentialsCreate)
- s.cliRoute("DELETE /api/cli/apps/{account}/{app}/email/credentials/{name}", svcrole.Set{}, s.handleAPIEmailCredentialsRevoke)
- s.cliRoute("POST /api/cli/apps/{account}/{app}/email/pause", svcrole.Set{}, s.handleAPIEmailPause)
-}
-
// ---- declare ------------------------------------------------------------
// handleAPIEmailDeclare answers the member's first step: record the env
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go
index 624893c73..9d7245717 100644
--- a/internal/console/routedecls.go
+++ b/internal/console/routedecls.go
@@ -1089,6 +1089,78 @@ var routeDecls = []routeDecl{
// stays on resolve only so a service token meets the family's 404 rather
// than the role gate's 403.
{Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/resolve", Kind: kindCLI, Gate: gateMoves, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceMoveResolve},
+
+ // The email API's doors (apimail.go, tenant-email task 17), through the
+ // role gate like every other /api/cli/ door.
+ //
+ // THE ROLE TABLE, and why each door reads as it does.
+ //
+ // The seven OPEN doors take Allow(Admin), matching the store family verb
+ // for verb — declare, ensure, verify, REMOVE, enable, rotate all move an
+ // account's backend estate, and `enable` mints a path-scoped IAM user
+ // exactly as `store grant` does. Admin is the union role, so
+ // Publish/Instance/Operate are refused: a credential that may deploy an app
+ // must not thereby be able to give it a sending identity on a domain the
+ // account owns.
+ //
+ // `domains rm` is Admin because `domains add` is: the same authority, run
+ // backwards. It is deliberately NOT closed or operator-gated — the whole
+ // defect it exists to fix is that releasing a claim required an authority
+ // (permanent app deletion) far larger than claiming one ever did, which is
+ // what left real deployments with a domain nobody could ever free.
+ //
+ // GET .../email is Admin rather than a read role for the same reason GET
+ // .../store is: the status reply names the IAM user, the key id and the
+ // verified domains — the estate, not just the app.
+ //
+ // GET .../email/events is Admin too, and for a different reason: it names
+ // the people the app wrote to. A credential that may read an app's routes
+ // or deploy it has no need of its recipients' addresses.
+ //
+ // The three .../email/events/push doors are Admin for the same reason: turning
+ // the push on is what starts recipients' addresses leaving the console, and
+ // the status names them in its last failure. The addresses only ever go to
+ // the app's own platform host (mailpush.go), so this is not a grant to send
+ // them anywhere — but it is a decision about them, and Admin makes it.
+ //
+ // The three CLOSED doors (svcrole.Set{} — closed to every role, admin
+ // included) are each closed for their own reason:
+ //
+ // - credentials create is the ONLY door in either family that hands a
+ // plaintext sending secret back to its caller. Store never does: its
+ // secret goes into sealed config and the console keeps no key to open
+ // it. This one must, because the whole point of a standalone credential
+ // is a human copying it into an off-platform MTA (spec §6b). An
+ // on-platform app never needs this door — it is delivered its own
+ // credentials as env by `enable`. So the one caller this door exists
+ // for is a person, and a service credential reaching it would turn
+ // "may deploy" into "may send as this domain, indefinitely".
+ // - credentials revoke is closed with it. Nothing a service could have
+ // minted here exists for it to clean up, and the services family closes
+ // create and revoke together for the same symmetry.
+ // - pause already resolves an ADDRESS against CARLOS_MAIL_OPERATORS
+ // (mailOperator), which no service principal can ever hold. Naming a
+ // role here would be a registration that lies about who gets in — the
+ // objection authcli.go raises against exactly that shape. It also
+ // RAISES THE CAP, which is an authority grant, not a runtime toggle.
+ //
+ // All three are pinned at the intent level too (mintDoors, policyDoors in
+ // svcroutes_test.go), so reopening one takes an edit that argues with the
+ // words next to it, not just a line moved in closedDoors.
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailDeclare},
+ {Pattern: "GET /api/cli/apps/{account}/{app}/email", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailStatus},
+ {Pattern: "GET /api/cli/apps/{account}/{app}/email/events", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailEvents},
+ {Pattern: "GET /api/cli/apps/{account}/{app}/email/events/push", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailPushStatus},
+ {Pattern: "PUT /api/cli/apps/{account}/{app}/email/events/push", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailPushSet},
+ {Pattern: "DELETE /api/cli/apps/{account}/{app}/email/events/push", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailPushOff},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/domains", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailDomainEnsure},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/domains/{domain}/verify", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailDomainVerify},
+ {Pattern: "DELETE /api/cli/apps/{account}/{app}/email/domains/{domain}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailDomainRemove},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/enable", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailEnable},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/rotate", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIEmailRotate},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/credentials", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIEmailCredentialsCreate},
+ {Pattern: "DELETE /api/cli/apps/{account}/{app}/email/credentials/{name}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIEmailCredentialsRevoke},
+ {Pattern: "POST /api/cli/apps/{account}/{app}/email/pause", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIEmailPause},
}
// registerDecls is THE loop: every declaration match accepts and whose gate
diff --git a/internal/console/server.go b/internal/console/server.go
index 50eb7ce40..b24bc8003 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1942,10 +1942,6 @@ func NewServer(cfg Config, st *Store) (*Server, error) {
// after every piece of state above, each declaration whose gate holds
// for this configuration.
s.registerDecls(func(routeDecl) bool { return true })
- // The email API's ten doors (apimail.go, tenant-email task 17) —
- // registered separately from registerCLIRoutes because this task's file
- // scope is server.go and apimail.go only.
- s.registerEmailRoutes()
// Catch up on accounts minted outside this database — `carlos accounts
// create` writes the bucket manifest and the registry row and never opens