console: declare authcli.go routes in routeDecls
registerCLIRoutes' 210 registrations become declarations, each with its comment. The host-claim pair carries gateHostClaim and the region HA pair gateRegionHA (host claims and CARLOS_REGION_HA both on, as the nested ifs required). registerCLIRoutes keeps only the group calls not yet migrated. The app-policy comment, which sat above the demo operator call, now sits above the policy doors it describes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/authcli.go+3 −643internal/console/routedecls.go+642 −0
Intent
<task-notification> <task-id>b8irxa405</task-id> <summary>Monitor event: "Task 2 commits landing on design-parity-guard"</summary> <event>6ba8172e console: declare server.go routes in routeDecls</event> </task-notification>
Attributed to this commit: 1.37 g CO₂e (182,143 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/authcli.go b/internal/console/authcli.go| index 6de2f2688..2f0117399 100644 |
| --- a/internal/console/authcli.go |
| +++ b/internal/console/authcli.go |
| @@ -532,278 +532,11 @@ func (s *Server) cliGateRefused(allow svcrole.Set, h http.HandlerFunc, refused f |
| } |
| } |
| -// registerCLIRoutes wires the CLI-identity surface. Called from NewServer. |
| -// |
| -// The /auth/cli/ family and GET /settings below stay on plain |
| -// mux.HandleFunc, deliberately: they are the OTHER half of default-deny. |
| -// Every one of them that reads a bearer at all gates on cliUser, which |
| -// answers only for a person, so a service credential meets there exactly the |
| -// 401 a fabricated token meets. Pinned by TestAuthCLIFamilyResolvesOnlyPersons. |
| -// |
| -// Every /api/cli/ door goes through cliRoute and names its roles. Pinned by |
| -// TestEveryCLIDoorNamesItsRoles. |
| +// registerCLIRoutes registers the route groups not yet declared in |
| +// routeDecls (routedecls.go, which now holds this file's doors). Called |
| +// from NewServer. |
| func (s *Server) registerCLIRoutes() { |
| s.registerDemoRoutes() |
| - s.registerRoute("POST /api/fleet/replicas/{account}/{app}/{host}/coordinator", s.handleReplicaCoordinator) |
| - s.registerRoute("POST /api/fleet/replicas/{account}/{app}/{host}/release", s.handleReplicaRelease) |
| - s.registerRoute("POST /auth/cli/start", s.handleCLIStart) |
| - s.registerRoute("POST /auth/cli/poll", s.handleCLIPoll) |
| - s.registerRoute("GET /auth/cli", s.handleCLIApprovePage) |
| - s.registerRoute("POST /auth/cli/approve", s.handleCLIApprove) |
| - s.registerRoute("GET /settings", s.handleCLITokens) |
| - s.registerRoute("GET /auth/cli/tokens", func(w http.ResponseWriter, r *http.Request) { |
| - http.Redirect(w, r, "/settings", http.StatusSeeOther) |
| - }) |
| - s.registerRoute("POST /auth/cli/tokens/revoke", s.handleCLITokenRevoke) |
| - s.registerRoute("GET /auth/cli/whoami", s.handleCLIWhoami) |
| - s.registerRoute("POST /auth/cli/revoke", s.handleCLIRevoke) |
| - s.registerRoute("POST /auth/cli/accounts", s.handleCLINewAccount) |
| - // The CLI's read-only API (apicli.go) — deliberately a different prefix |
| - // (/api/cli/) from the identity routes above (/auth/cli/), which must not |
| - // move now that CLIs depend on them. |
| - s.cliRoute("GET /api/cli/apps", svcrole.Allow(svcrole.Publish, svcrole.Deploy, svcrole.Instance, svcrole.Operate), s.handleAPIApps) |
| - // The fleet-wide live tenancy read (discussion #11). An EMPTY role set: |
| - // no service credential of any role reaches it, because the answer names |
| - // every account's instances on every box, and that is an operator's view |
| - // rather than any workload's. The operator check itself is inside the |
| - // handler, since cliRoute's role set can only narrow SERVICE principals |
| - // and a person always passes through it. |
| - s.cliRoute("GET /api/cli/status/instances", svcrole.Set{}, s.handleAPIStatusInstances) |
| - if s.cfg.HostClaim { |
| - // Host loss inspection and submission are person-only and repeat the |
| - // fleet-operator check in their handlers. Until the follow-on integration supplies the |
| - // ActorDirectory both routes stop at the same inert refusal. |
| - s.cliRoute("POST /api/cli/ops/hosts/{host}/resolve/inspect", svcrole.Set{}, s.handleAPIHostResolveInspect) |
| - s.cliRoute("POST /api/cli/ops/hosts/{host}/resolve", svcrole.Set{}, s.handleAPIHostResolve) |
| - // Box and group roles (region HA spec 2 §7, apiboxroles.go): |
| - // operator-only, and registered only with CARLOS_REGION_HA on too, |
| - // so with it off they answer as any unknown route, as on main. |
| - if s.cfg.RegionHA { |
| - s.cliRoute("POST /api/cli/system/boxes/{box}/role", svcrole.Set{}, s.handleAPISystemBoxRole) |
| - s.cliRoute("POST /api/cli/system/groups/{region}/role", svcrole.Set{}, s.handleAPISystemGroupRole) |
| - } |
| - } |
| - // carlos status --layout (plan 4, task 5): which layout each instance is |
| - // on, box by box. Same posture as the door above — an empty role set, the |
| - // operator check inside the handler. |
| - s.cliRoute("GET /api/cli/status/layout", svcrole.Set{}, s.handleAPIStatusLayout) |
| - // The literal `new` mirrors the browser door (/a/{sqid}/apps/new); no |
| - // bare POST .../{app} route exists to collide with, and the mux prefers |
| - // the literal if one ever does. |
| - s.cliRoute("POST /api/cli/apps/{account}/new", svcrole.Allow(svcrole.Publish), s.handleAPICreateApp) |
| - // Temporary apps (temporary static sites spec §3). A separate route, not a |
| - // field on /new: /new's decoder accepts unknown fields, so an older |
| - // console would take "temporary" silently and create a permanent app. An |
| - // older console answers this route 404 and the CLI stops there. |
| - s.cliRoute("POST /api/cli/apps/{account}/new-temporary", svcrole.Allow(svcrole.Publish), s.handleAPICreateTemporaryApp) |
| - s.cliRoute("GET /api/cli/apps/{account}/list", svcrole.Allow(svcrole.Publish), s.handleAPIAppList) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/ttl", svcrole.Allow(svcrole.Publish), s.handleAPIAppTTL) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/keep", svcrole.Allow(svcrole.Publish), s.handleAPIAppKeep) |
| - // The app's region, the default for its NEW instances (appregionset.go). |
| - // A person only: an account owner or a deployment operator may change |
| - // it, so no service role reaches either door. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/source", svcrole.Set{}, s.handleAPIAppSource) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/region", svcrole.Set{}, s.handleAPIAppRegionGet) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/region", svcrole.Set{}, s.handleAPIAppRegionSet) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/channels", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIChannels) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/promote", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIPromote) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/rollback", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIRollback) |
| - // `carlos channels resign` (#253, spec §4.6): a person confirms the |
| - // manifest digests the console then signs into the channel's pointer, so |
| - // no credential reaches it. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/channels/resign", svcrole.Set{}, s.handleAPIChannelResign) |
| - // `carlos releases authorize` (settings spec §4.1): GET shows a build's |
| - // digests, POST signs a promotion record for the digest a person |
| - // confirmed. A credential the app holds never vouches for a build. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/releases/{version}/authorize", svcrole.Set{}, s.handleAPIAuthorize) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/releases/{version}/authorize", svcrole.Set{}, s.handleAPIAuthorize) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/releases", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIShip) |
| - // `carlos restart` (issue #113): a member's "cycle this app's processes" |
| - // with no version and no config to push — the same write-door class as |
| - // promote and rollback, and the only one whose subject is a running |
| - // process rather than a pointer. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/restart", svcrole.Allow(svcrole.Operate), s.handleAPIRestart) |
| - // The NARROWED form (discussion #16): one route, or everything reading one |
| - // config environment, plus the dry run that shows the set first. A |
| - // SEPARATE path rather than a body on the door above, and deliberately so: |
| - // that one reads no body, so a console predating this would answer a |
| - // narrowed request by cycling the whole app. Here it answers 404 and the |
| - // CLI says why. Same role — the subject is still a running process. |
| - s.cliScopedRoute("POST /api/cli/apps/{account}/{app}/restart/scope", svcrole.Allow(svcrole.Operate), scopeRestartBody, s.handleAPIRestartScope) |
| - // `carlos schedule` (apischedule.go, scheduled-work spec §8): declare |
| - // recurring work, take it back, and make it fire now. The RESTART class, |
| - // not the publish one — operating a running app rather than moving a |
| - // version pointer — so the same Operate role reaches all four. `delete` |
| - // and `run` are literal segments after the {name} wildcard, so a schedule |
| - // named "delete" is still just a name; the mux prefers the literal |
| - // regardless of registration order. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/schedules", svcrole.Allow(svcrole.Operate), s.handleAPIScheduleList) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/schedules", svcrole.Allow(svcrole.Operate), s.handleAPIScheduleSet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/schedules/{name}/delete", svcrole.Allow(svcrole.Operate), s.handleAPIScheduleRemove) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/schedules/{name}/run", svcrole.Allow(svcrole.Operate), s.handleAPIScheduleRun) |
| - // `carlos releases retention` (issue #136): a member's ambient-prune |
| - // policy — read, set, clear, preview. Same identity gates as every |
| - // door here; the safety list in release.PruneEligible is what keeps a |
| - // policy from ever deleting anything promoted, tagged, or recent. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/retention", svcrole.Allow(svcrole.Publish), s.handleAPIRetentionGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/retention", svcrole.Allow(svcrole.Publish), s.handleAPIRetentionSet) |
| - // The version-target, tags and releases-list API (apiversion.go, |
| - // release versioning spec 2026-08-08). GET .../releases coexists with |
| - // the POST above on the SAME path — a distinct method route, not a |
| - // collision — for `carlos releases` to read what `carlos ship` writes. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/version-target", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIVersionTargetGet) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/version-target", svcrole.Allow(svcrole.Publish), s.handleAPIVersionTargetSet) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/tags", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPITagsList) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/tags/{version}", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPITagGet) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/releases", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIReleasesList) |
| - // The pipeline API (apipipeline.go, release pipelines v2). GET is |
| - // release metadata like channels/releases above — Publish reaches it. |
| - // PUT rewrites the policy governing every promotion into every channel |
| - // (bake, passkey, approval quorum), account authority in the same |
| - // register as ledgers and store grants below — Admin-only for a |
| - // SERVICE credential. svcrole.Allow() alone would be the WRONG way to |
| - // say that: the empty Set is fully closed, Admin included |
| - // (TestEmptySetPermitsNothingIncludingAdmin, internal/svcrole) — the |
| - // same zero value svcrole.Set{} spells for the person-only doors |
| - // below. Naming Admin explicitly is what actually opens the door to an |
| - // admin-role service and closes it to every other role, exactly like |
| - // the ledgers and store families. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/pipeline", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIPipelineGet) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/pipeline", svcrole.Allow(svcrole.Admin), s.handleAPIPipelinePut) |
| - // What the app is waiting on: the proposals a gated promote, fast-track |
| - // or policy edit turned into (pendinghandlers.go). Read-only, and Publish |
| - // like channels and releases — a proposal names no secret, and the CLI |
| - // needs to see one precisely because it can never confirm one itself |
| - // (spec §4: confirming takes a passkey, in the console). |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/pending", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIPending) |
| - // Trash and restore (apicli.go). Delete resolves through the LIVE-apps |
| - // door and restore through the trashed-apps one, so each verb answers |
| - // only for an app in the state it can act on — and both give a stranger |
| - // the same 404. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/delete", svcrole.Allow(svcrole.Publish), s.handleAPITrashApp) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/restore", svcrole.Allow(svcrole.Publish), s.handleAPIRestoreApp) |
| - // The ledger API (apiledger.go) — the only write path to ledgers/ from |
| - // outside a box. The literal `publish` segment is kept adjacent to the |
| - // {ledger} wildcards for readability; the mux prefers it regardless of |
| - // registration order. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/ledgers", svcrole.Allow(svcrole.Admin), s.handleAPILedgerList) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/ledgers/publish", svcrole.Allow(svcrole.Admin), s.handleAPILedgerPublish) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/ledgers/{ledger}/head", svcrole.Allow(svcrole.Admin), s.handleAPILedgerHead) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/ledgers/{ledger}/append", svcrole.Allow(svcrole.Admin), s.handleAPILedgerAppend) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/ledgers/{ledger}/blobs", svcrole.Allow(svcrole.Admin), s.handleAPILedgerBlob) |
| - // The instance provisioning API (apiinstances.go) — the only door onto |
| - // instances/ and domains/ from outside a box. It was once the only |
| - // family a non-person could speak to; since the role gate landed that is |
| - // a property of each door's Allow set, not of this block. `instance-token` is a literal segment beside the |
| - // {host} wildcards; the mux prefers a literal regardless of |
| - // registration order, and it deliberately sits under a DIFFERENT |
| - // prefix from instances/{host} so a host can never be mistaken for the |
| - // mint verb. |
| - // `instances-manifest` is the member-facing half of `carlos instances |
| - // enable` (issue #66): a literal sibling of instances/, never under it, |
| - // so a host named "instances-manifest" could still never reach it. |
| - // |
| - // The zero Set, for the same escalation cut the mint door takes. This |
| - // door writes the MANIFEST — standing policy about which domain, pool, |
| - // regions and channel the app may ever be brought up on — and a |
| - // credential the app itself holds must not be able to rewrite the |
| - // bounds it runs inside. It takes no authority away: handleAPIInstanceEnable |
| - // has always gated on apiAccountApp, which could not see a non-person at |
| - // all, so no app token has ever reached it. The registration is where |
| - // that is now said, because a registration reading "instance may pass" |
| - // while the handler refuses is a registration that lies. As at the mint |
| - // door, the ANSWER a credential gets here moves from 401 to 403. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/instances-manifest", svcrole.Set{}, s.handleAPIInstanceEnable) |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/instances", svcrole.Allow(svcrole.Instance, svcrole.Deploy), scopeList, s.handleAPIInstanceList) |
| - // The armed-regions answer for consumer pickers (issue #346) — the |
| - // same gate and role as the list beside it; see handleAPIRegions. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/regions", svcrole.Allow(svcrole.Instance, svcrole.Deploy), s.handleAPIRegions) |
| - // The per-caller region guess (nearest-region spec §9.4): POST, so the |
| - // hints never ride a URL a redirect could echo. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/regions/guess", svcrole.Allow(svcrole.Instance), s.handleAPIRegionGuess) |
| - // Moving a route between channels (channelmove.go). The zero Set, for |
| - // the manifest door's reason: this decides what a route SERVES, and a |
| - // credential the app itself holds must not be able to walk its own route |
| - // onto a channel whose rules it never met. Widening it later is easy; |
| - // narrowing an authority already granted is not. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/channel", svcrole.Set{}, s.handleAPIInstanceChannel) |
| - // Update settings (instance update settings spec §5.1). Person-only until |
| - // #155 step 6 adds an instance-bound credential: svcrole.Instance is |
| - // app-wide, so it would let one instance's code set a sibling's pin. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/updates", svcrole.Set{}, s.handleAPIUpdatesGet) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/instances/{host}/updates", svcrole.Set{}, s.handleAPIUpdatesPut) |
| - // "Update now" asks root for the newest build the settings allow; the |
| - // same people-only gate, and fast_track only for an account owner. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/updates/install", svcrole.Set{}, s.handleAPIUpdatesInstall) |
| - // The app's instance update policy (spec §3.2) lives on the instances |
| - // manifest, so it is closed for the manifest door's reason: a credential |
| - // the app holds must not rewrite the bounds its instances run inside. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/updates", svcrole.Set{}, s.handleAPIUpdatesPolicy) |
| - // The logs read (`carlos logs`, apilogs.go) — same gate, same 404 |
| - // discipline, and an app token may read its own app's logs. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/logs", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPILogs) |
| - // The edge reference code read (apiedgeref.go): what the owner asks when |
| - // a visitor reads out the code from a block page. It reads the app's own |
| - // edge records, so it takes the logs door's gate and roles. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/edge-refs/{code}", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPIEdgeRef) |
| - // The errors read (`carlos errors`, apierrors.go) — the logs door's twin, |
| - // over the same window from the other end: the same gate, the same roles, |
| - // and an app token may read its own app's errors for the same reason it |
| - // may read its own logs. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/errors", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPIErrors) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/availability", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPIAvailability) |
| - // The analytics read (`carlos analytics`, apianalytics.go) — the third of |
| - // the same family, on the same footing: an app token that may read every |
| - // line of its own logs is not learning anything new from a count of its |
| - // own page views. The SETTING that decides whether those counts exist is |
| - // the telemetry PUT below, and that stays Operate-only. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/analytics", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPIAnalytics) |
| - // The platform's GeoIP answer for an arbitrary address (geoip spec |
| - // §11.1): the same holders as the analytics read. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/geo", svcrole.Allow(svcrole.Instance, svcrole.Operate), s.handleAPIGeo) |
| - // The telemetry SETTINGS write, Operate only and deliberately narrower |
| - // than the read beside it: this decides what counts as an error for the |
| - // app's owner, and a credential the app itself holds must not be able to |
| - // widen or narrow what its owner is shown. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/telemetry", svcrole.Allow(svcrole.Operate), s.handleAPITelemetryPut) |
| - // Its read (`carlos protection` with no flag): the stored settings under |
| - // the PUT's own gate, since they are the settings that PUT writes. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/telemetry", svcrole.Allow(svcrole.Operate), s.handleAPITelemetryGet) |
| - s.cliScopedRoute("POST /api/cli/apps/{account}/{app}/instances", svcrole.Allow(svcrole.Instance), scopeCreateBody, s.handleAPIInstanceCreate) |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/instances/{host}", svcrole.Allow(svcrole.Instance), scopeHost, s.handleAPIInstanceGet) |
| - // PATCH is the multi-upstream repoint (issue #152): the two fields of a |
| - // record — its addr set and its probe — that change while the instance |
| - // keeps serving. Same {host} wildcard, same gate, same byte-identical |
| - // 404 as its GET and DELETE siblings. |
| - s.cliScopedRoute("PATCH /api/cli/apps/{account}/{app}/instances/{host}", svcrole.Allow(svcrole.Instance), scopeHost, s.handleAPIInstanceUpdate) |
| - // The edge asset cache's purge and status (design §6, apiassets.go). |
| - // The purge draws a fresh asset generation for every instance of the |
| - // app: the deploy loop's and a deploy pipeline's act, beside the ship |
| - // that declared the folders. The status read is open to every app role: |
| - // it shows the app's own records and what their homes published. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/assets/purge", svcrole.Allow(svcrole.Publish, svcrole.Deploy), s.handleAPIAssetsPurge) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/assets", svcrole.Allow(svcrole.Publish, svcrole.Deploy, svcrole.Instance, svcrole.Operate), s.handleAPIAssetsStatus) |
| - // The deploy watch's gate pass (discussion #164). Instance, because an |
| - // Instance credential can already clear the gate through the PATCH |
| - // above, so a pass gives it nothing new. Deploy, because CI runs |
| - // `carlos deploy` with it, but per host: the handler refuses a host on a |
| - // channel the credential could not promote to. Publish is deliberately |
| - // NOT here: a Publish credential cannot always change what a host serves |
| - // (a passkey or approval rung turns its promote into a proposal), and it |
| - // cannot list instances, so `carlos deploy` never reaches this with one. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/gate-pass", svcrole.Allow(svcrole.Instance, svcrole.Deploy), s.handleAPIInstanceGatePass) |
| - // The residence-move doors (issue #331): requested by the tenant's |
| - // ROUTER with the app-held instance token (titogo's residence design — |
| - // never by an instance about itself... which the role system cannot yet |
| - // express; the Instance role is the same authority the create and |
| - // delete doors already grant this credential). |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/move", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceMoveStatus) |
| - // The rate-limit read (#358): the settings the PATCH above writes, with |
| - // the plan ceiling, what the edge applies, and the last day's refusals. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/rate-limit", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceRateLimitGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceMoveRequest) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/cut", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceMoveCut) |
| - s.cliRoute("DELETE /api/cli/apps/{account}/{app}/instances/{host}/move", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceMoveAbort) |
| // With CARLOS_MOVES_PHASE1 on, the three mutations above are |
| // operator-only (moveOperatorGate) and a resolve door joins them. Off, |
| // that route is never registered, so every request to it answers |
| @@ -811,383 +544,10 @@ func (s *Server) registerCLIRoutes() { |
| if s.cfg.MovesEnabled { |
| s.registerMovesPhase1Routes() |
| } |
| - // The offline operator move's doors: always registered, operator-only, |
| - // and refused with MV-O20 on a console with host claims or Phase 1 on. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/move/offline", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceOfflineStatus) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceOfflineStart) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/stage", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceOfflineStage) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/seal", svcrole.Allow(svcrole.Instance), s.offlineVerbDoor(offlineVerbSeal)) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/flip", svcrole.Allow(svcrole.Instance), s.offlineVerbDoor(offlineVerbFlip)) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/open", svcrole.Allow(svcrole.Instance), s.offlineVerbDoor(offlineVerbOpen)) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/finish", svcrole.Allow(svcrole.Instance), s.offlineVerbDoor(offlineVerbFinish)) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/abort", svcrole.Allow(svcrole.Instance), s.handleAPIInstanceOfflineAbort) |
| - s.cliScopedRoute("DELETE /api/cli/apps/{account}/{app}/instances/{host}", svcrole.Allow(svcrole.Instance), scopeHost, s.handleAPIInstanceDelete) |
| - // The import door (seeded-instances spec §5): the instance role, like |
| - // the create door that begins it. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/instances/{host}/import", svcrole.Allow(svcrole.Instance), s.handleAPIImportUpload) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/import/stopped", svcrole.Allow(svcrole.Instance), s.handleAPIImportStopped) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/import/commit", svcrole.Allow(svcrole.Instance), s.handleAPIImportCommit) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/import/abort", svcrole.Allow(svcrole.Instance), s.handleAPIImportAbort) |
| - // The run doors (service runs spec §1): a person on the member rule, or a |
| - // run service, and no other role. Exactly, not Allow, so Admin does not |
| - // join: a credential that may provision instances cannot run commands on |
| - // them unless it was minted for that. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/runs", svcrole.Exactly(svcrole.Run), s.handleAPIRunCreate) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/runs", svcrole.Exactly(svcrole.Run), s.handleAPIRunKeyLookup) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}", svcrole.Exactly(svcrole.Run), s.handleAPIRunGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/cancel", svcrole.Exactly(svcrole.Run), s.handleAPIRunCancel) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/expire", svcrole.Exactly(svcrole.Run), s.handleAPIRunExpire) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/ack", svcrole.Exactly(svcrole.Run), s.handleAPIRunAck) |
| - // The interactive session door (rootfs apps spec §5.10, apiinteractive.go): |
| - // a WebSocket for `carlos run -it` and `carlos console`. The ZERO Set: a |
| - // session is a live shell into production data, so no credential reaches |
| - // it, the run role included; the handler answers anything but a person |
| - // with the byte-identical 404. |
| - // A service credential the gate refuses gets the door's journal line |
| - // (journalUnplaced, once per caller per minute) beside its 403. |
| - s.cliRouteJournaled("GET /api/cli/apps/{account}/{app}/instances/{host}/interactive", svcrole.Set{}, s.handleAPIInteractive, s.journalUnplaced) |
| - // `carlos instances retry <host>` (apiretry.go): the operate family's, as |
| - // restart is. The {host} wildcard and the 404 are the instance family's. |
| - s.cliScopedRoute("POST /api/cli/apps/{account}/{app}/instances/{host}/retry", svcrole.Allow(svcrole.Operate), scopeHost, s.handleAPIInstanceRetry) |
| - // The `carlos db` replica door (apidb.go; spec 2026-09-02 §6): an |
| - // instance's replicated LTX files, by coordinate, for a member to |
| - // restore on their own machine. The zero Set, deliberately: the payload |
| - // is the whole customer database, and no legitimate credential needs it |
| - // (an app reads its own database live, and CI has no business pulling |
| - // production data). admin is refused with the rest. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/db/{host}/ltx/{level}", svcrole.Set{}, s.handleAPIDBList) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/db/{host}/ltx/{level}/{span}", svcrole.Set{}, s.handleAPIDBGet) |
| - // The forwarded read (db region forward spec §9.1): people only, the db |
| - // door's whole gate once, then the read inside the same request. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/db/{host}/reads", svcrole.Set{}, s.handleAPIDBRead) |
| - // The zero Set, deliberately: a credential may never mint a credential, |
| - // including itself. This is the escalation cut (spec §3). It takes no |
| - // authority away — handleAPIInstanceToken gates on apiAccountApp, which |
| - // has never been able to see a non-person at all — it moves the refusal |
| - // out to the wrapper, where it is structural, and changes the ANSWER a |
| - // credential gets here from 401 to 403. Pinned by |
| - // TestNoRoleReachesAMintFleetOrPolicyDoor and TestAdminIsRefusedAtAClosedDoor. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/instance-token", svcrole.Set{}, s.handleAPIInstanceToken) |
| - // Door keys (#175 P7): person-only, the instance-token rule. A door key |
| - // reaches every instance of the app through every box's edge-local door. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/door-keys", svcrole.Set{}, s.handleAPIDoorKeyList) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/door-keys", svcrole.Set{}, s.handleAPIDoorKeyMint) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/door-keys/{id}/revoke", svcrole.Set{}, s.handleAPIDoorKeyRevoke) |
| - // The sidecar API (apisidecars.go) — the only door onto sidecars/ from |
| - // outside a box, sharing the instance family's gate exactly |
| - // (instanceGate) and, since the role gate landed, its Allow sets too: |
| - // an app process provisions a sidecar per enrolled member with the |
| - // CARLOS_INSTANCE_TOKEN it already holds, which is the Instance role. |
| - // |
| - // `sidecars-manifest` is the member-facing half of `carlos sidecars |
| - // enable`: a literal sibling of sidecars/, never under it, so a sidecar |
| - // named "sidecars-manifest" could still never reach it. It takes the |
| - // ZERO Set for `instances-manifest`'s reason, and the reason is sharper |
| - // here: this manifest carries `args` — the argv the platform execs |
| - // after the release binary — plus the placement the workload is held |
| - // to. A credential the app holds must not be able to rewrite what its |
| - // own boxes will exec on its behalf. handleAPISidecarEnable has always |
| - // gated on apiAccountApp, which cannot see a non-person at all, so this |
| - // takes no authority away; it moves the refusal out to the registration |
| - // and the answer from 401 to 403. |
| - // |
| - // `wake` is a literal segment UNDER {name}; the mux prefers a literal |
| - // regardless of registration order, and provision.ValidSidecarName is |
| - // one DNS label, so no sidecar name can ever be "wake"'s path either. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/sidecars-manifest", svcrole.Set{}, s.handleAPISidecarEnable) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/sidecars", svcrole.Allow(svcrole.Instance), s.handleAPISidecarList) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/sidecars", svcrole.Allow(svcrole.Instance), s.handleAPISidecarCreate) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/sidecars/{name}", svcrole.Allow(svcrole.Instance), s.handleAPISidecarGet) |
| - s.cliRoute("DELETE /api/cli/apps/{account}/{app}/sidecars/{name}", svcrole.Allow(svcrole.Instance), s.handleAPISidecarDelete) |
| - // No PATCH: a sidecar has no upstream set to repoint, which is the one |
| - // thing an instance record's update verb exists for. The family is |
| - // create-only plus delete. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/sidecars/{name}/wake", svcrole.Allow(svcrole.Instance), s.handleAPISidecarWake) |
| - // The extra-hostname API (apidomains.go, issue #151) — the only door onto |
| - // domains/ from outside a box, sharing the instance family's gate exactly |
| - // (instanceGate), so titogo's router attaches its customers' hostnames |
| - // with the CARLOS_INSTANCE_TOKEN it already holds. |
| - // |
| - // Domains carries `Instance` for COMPATIBILITY, not because it belongs |
| - // there: that router re-attaches every hostname on every reload pass with |
| - // its CARLOS_INSTANCE_TOKEN, which is a kind='app' row and so holds role |
| - // instance. Dropping it here 403s that router on the next console deploy. |
| - // Same for logs, above. Pinned by |
| - // TestInstanceRoleMatchesTodaysAppTokenReach; spec §5. |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/domains", svcrole.Allow(svcrole.Publish, svcrole.Instance), scopeList, s.handleAPIDomainList) |
| - // The per-host read (#299): same roles as the list it narrows — it |
| - // discloses strictly less (one hostname the caller already owns), so it |
| - // cannot need a role the list does not. |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/domains/{host}", svcrole.Allow(svcrole.Publish, svcrole.Instance), scopeDomainHost, s.handleAPIDomainGet) |
| - // The placements read (#447, apiplacements.go): which boxes serve the |
| - // claim's target, where, and whether it is ready. The per-host read's |
| - // roles and team scope exactly; it discloses no more about the claim. |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/domains/{host}/placements", svcrole.Allow(svcrole.Publish, svcrole.Instance), scopeDomainHost, s.handleAPIDomainPlacementsGet) |
| - // The placements write (#447, spec §6.2): the only way into regional |
| - // mode. A person's act and no service role's: it fixes where a name is |
| - // served in every region and its capabilities for the claim's life, and |
| - // a team credential (no team set here) cannot reach it either. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/domains/{host}/placements", svcrole.Set{}, s.handleAPIDomainPlacementsPut) |
| - s.cliScopedRoute("POST /api/cli/apps/{account}/{app}/domains", svcrole.Allow(svcrole.Publish, svcrole.Instance), scopeDomainBody, s.handleAPIDomainAttach) |
| - s.cliRoute("POST /api/cli/accounts/{account}/domains/check", svcrole.Set{}, s.handleAPIDomainCheck) |
| - s.cliRoute("POST /api/cli/accounts/{account}/domains/purchases", svcrole.Set{}, s.handleAPIDomainPurchase) |
| - s.cliRoute("GET /api/cli/accounts/{account}/domains/purchases/{id}", svcrole.Set{}, s.handleAPIDomainPurchaseStatus) |
| - s.cliScopedRoute("DELETE /api/cli/apps/{account}/{app}/domains/{host}", svcrole.Allow(svcrole.Publish, svcrole.Instance), scopeDomainHost, s.handleAPIDomainDetach) |
| - // The prefix-map publish (path-based routing): replace the WHOLE map of |
| - // leading path segments a claimed hostname splits its traffic by. The |
| - // tenant's own platform is the writer and the source of truth — it |
| - // regenerates the map from its database and republishes it — which is |
| - // why there is no per-prefix verb and no CLI writer at all. |
| - // |
| - // `Publish` AND `Instance`, matching the READ of the same state on |
| - // handleAPIDomainGet above. An earlier revision made this Publish-only on |
| - // the reasoning that a flip is deployment-shaped; the objection that |
| - // carried is internal coherence — as Publish-only, an Instance credential |
| - // could read a hostname's published prefix map and not write it, and this |
| - // file's own header names titogo's router, calling the domains family |
| - // with its CARLOS_INSTANCE_TOKEN, as the caller this door exists for. |
| - // |
| - // Widening crosses no tenancy boundary. The door is already owner-gated |
| - // on account and app (domainsGate) and guarded by |
| - // refuseServiceControlPlane, so an Instance token can only ever publish |
| - // its OWN app's map, naming targets the reconcile pass then re-checks |
| - // against the same account (aliases.go). It is not in |
| - // TestInstanceRoleMatchesTodaysAppTokenReach's legacy map, because |
| - // nothing reached it before service principals existed — see |
| - // exemptFromLegacyPin, where the deliberate grant is recorded. Design |
| - // spec §7. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/domains/{host}/paths", svcrole.Allow(svcrole.Publish, svcrole.Instance), s.handleAPIDomainPaths) |
| - // App feature flags (apifeatures.go, #347). The read carries Instance |
| - // because the app IS the consumer — its router reads its own switches |
| - // with the CARLOS_INSTANCE_TOKEN, the same credential and the same |
| - // answer (the domains deployment block) it already uses. The write is |
| - // Admin only: these are production switches, and the register is |
| - // `pipeline` PUT's and `apps place`'s, not promote's. An app's own |
| - // credential must never reach the write — a switch an app could flip |
| - // on itself is a root env flag by another name. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/features", svcrole.Allow(svcrole.Publish, svcrole.Instance), s.handleAPIFeaturesGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/features", svcrole.Allow(svcrole.Admin), s.handleAPIFeaturesSet) |
| - // The config API (apiconfig.go) — `carlos env` and `carlos secrets` |
| - // through the same gate as ship/promote, so deploy access no longer |
| - // means bucket credentials (issue #43). Secrets arrive already sealed; |
| - // the console relays an opaque envelope and holds no key to open it. |
| - s.cliScopedRoute("GET /api/cli/apps/{account}/{app}/config", svcrole.Allow(svcrole.Operate), scopeEnvironmentQuery, s.handleAPIConfigGet) |
| - s.cliScopedRoute("PUT /api/cli/apps/{account}/{app}/config", svcrole.Allow(svcrole.Operate), scopeEnvironmentBody, s.handleAPIConfigPut) |
| // The owner's doors onto owned environments (apienv.go): adopt, release |
| // and fork. Closed to every service role, owner-gated inside. |
| s.registerEnvironmentRoutes() |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/config/sync", svcrole.Allow(svcrole.Operate), s.handleAPIConfigSync) |
| - // The routes read (apiroutes.go, issue #64) — the member-only door onto |
| - // this box's registry rows for one app, so a route's environment |
| - // binding can be read back without a box shell. |
| - // |
| - // The ZERO Set, and the reasoning is that file's own: "An app token is |
| - // a machine credential minted for one instance to register itself; this |
| - // answer describes every route of the app, with upstream addresses, |
| - // owning units and environment bindings, which is an operator's view |
| - // rather than a workload's." A service credential is the same kind of |
| - // caller an app token is, so the door that refuses one refuses all of |
| - // them. It joins policyDoors for that reason — person-only by intent, |
| - // not merely by bookkeeping. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/routes", svcrole.Set{}, s.handleAPIRoutes) |
| - // The customer fleets API (fleets.go) — account-owned remote-box groups |
| - // and where an app's routes/instances place onto them. `new` is a |
| - // literal beside the {fleet} wildcard for the same reason apps/new is: |
| - // the mux prefers a literal regardless of registration order, so there |
| - // is no ambiguity with a fleet that happened to be named "new". |
| - // |
| - // Every one of them is the zero Set, deliberately: enrolling a box into a |
| - // fleet, and rotating or detaching one, hands out a MACHINE's credentials |
| - // and changes where a whole account's apps can be placed. That is a human |
| - // act, and no service role reaches it — the same escalation cut as the |
| - // mint door above. Pinned by TestNoRoleReachesAMintFleetOrPolicyDoor. |
| - s.cliRoute("POST /api/cli/fleets/{account}/new", svcrole.Set{}, s.handleAPIFleetNew) |
| - s.cliRoute("POST /api/cli/fleets/{account}/managed-plan", svcrole.Set{}, s.handleAPIManagedFleetPlan) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/managed-boxes", svcrole.Set{}, s.handleAPIManagedFleetAdd) |
| - s.cliRoute("GET /api/cli/fleets/{account}", svcrole.Set{}, s.handleAPIFleetList) |
| - s.cliRoute("GET /api/cli/fleets/{account}/{fleet}", svcrole.Set{}, s.handleAPIFleetShow) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/boxes", svcrole.Set{}, s.handleAPIFleetAddBox) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/rotate", svcrole.Set{}, s.handleAPIFleetRotateBox) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/detach", svcrole.Set{}, s.handleAPIFleetDetachBox) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/drain", svcrole.Set{}, s.handleAPIFleetDrainBox) |
| - s.cliRoute("POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/tags", svcrole.Set{}, s.handleAPIFleetTagBox) |
| - // The fleet's secrets key (fleetsecretskey.go): whoever sets it decides |
| - // who can read the fleet's future secrets, so the zero Set here too, and |
| - // an owner check inside. |
| - s.cliRoute("PUT /api/cli/fleets/{account}/{fleet}/secrets-key", svcrole.Set{}, s.handleAPIFleetSecretsKey) |
| - // The service-credential API (apiservices.go, issue #220) — the |
| - // principal that is not an address. Every door here takes the ZERO role |
| - // set: a credential may never mint, rotate or revoke a credential, |
| - // including itself, which is what keeps a publish credential from |
| - // quietly becoming an admin one. Owner-gated inside, because minting is |
| - // an authority grant that outlives its minter. |
| - // |
| - // {name} is a wildcard with rotate and revoke as literal segments |
| - // beneath it — the mux prefers a literal regardless of registration |
| - // order, the same property the fleets and store families already rely |
| - // on, so a credential named "rotate" cannot shadow the verb. |
| - s.cliRoute("POST /api/cli/services/{account}", svcrole.Set{}, s.handleAPIServiceCreate) |
| - s.cliRoute("GET /api/cli/services/{account}", svcrole.Set{}, s.handleAPIServiceList) |
| - s.cliRoute("POST /api/cli/services/{account}/{name}/rotate", svcrole.Set{}, s.handleAPIServiceRotate) |
| - s.cliRoute("POST /api/cli/services/{account}/{name}/revoke", svcrole.Set{}, s.handleAPIServiceRevoke) |
| - // Placement lives under the apps family, not fleets: its subject is an |
| - // APP, and a target fleet name is only ever the request body's data. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/place", svcrole.Allow(svcrole.Admin), s.handleAPIPlace) |
| - // The build probe on an EXISTING app (discussion #13). An empty role set: |
| - // the probe is what the deploy watch trusts instead of the header, so a |
| - // credential that could rewrite it could make its own deploys report |
| - // success over a process that never restarted — which is the exact bug |
| - // the probe exists to prevent, handed to the wrong caller. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/build-probe", svcrole.Set{}, s.handleAPIBuildProbe) |
| - // The swap policy (zero-downtime spec §4.1, apiswap.go). The ZERO Set: |
| - // §11 says only app members change it, and a credential the app holds |
| - // must not choose what its own migrations run beside. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/copies", svcrole.Set{}, s.handleAPICopies) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/swap", svcrole.Set{}, s.handleAPISwapPut) |
| - // The interactive sessions setting (rootfs apps spec §5.10, |
| - // apiinteractivesetting.go). The ZERO Set: a session is a live shell |
| - // into production data, and a credential the app holds must not open |
| - // that door for itself. Turning it on is an owner's act, in the handler. |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/interactive", svcrole.Set{}, s.handleAPIInteractivePut) |
| - // The app policy (instance sizes and egress spec §6, apipolicy.go): the |
| - // private addresses an app's instances may reach and the sizes they run |
| - // at. The ZERO Set at the mux, so no service credential reaches either |
| - // door, an app's own included: a credential must not widen what its own |
| - // instances may reach. The operator gate (apiSystemRoller: an ops account |
| - // owner or CARLOS_SYSTEM_OPERATORS) is in the handlers, because a person |
| - // always passes cliRoute's Set. |
| s.registerDemoOperatorRoutes() |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/policy", svcrole.Set{}, s.handleAPIPolicyGet) |
| - s.cliRoute("PUT /api/cli/apps/{account}/{app}/policy", svcrole.Set{}, s.handleAPIPolicyPut) |
| - // The object-storage API (apistore.go, issue #55) — declare a store, read |
| - // what became of it, and drive the walks that make it real. Beside the |
| - // config routes on purpose: a store's credentials are DELIVERED as config, |
| - // so these doors are halves of the same story for whoever reads this list. |
| - // |
| - // `grant` is the deployment's first operator-identity door: same member |
| - // 404 as its siblings, then an address on CARLOS_STORE_OPERATORS. Rotate |
| - // and finish are MEMBER verbs (spec §8) — they cycle a credential inside an |
| - // estate a grant already paid for. All three are literal segments under |
| - // .../store, never {wildcards}, so no app or host name can reach them. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store", svcrole.Allow(svcrole.Admin), s.handleAPIStoreCreate) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/store", svcrole.Allow(svcrole.Admin), s.handleAPIStoreGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/provision", svcrole.Allow(svcrole.Admin), s.handleAPIStoreProvision) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/grant", svcrole.Allow(svcrole.Admin), s.handleAPIStoreGrant) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/rotate", svcrole.Allow(svcrole.Admin), s.handleAPIStoreRotate) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/rotate/finish", svcrole.Allow(svcrole.Admin), s.handleAPIStoreRotateFinish) |
| - // Account-level storage entitlement doors are person-only. Applying speaks |
| - // for an account owner; approvals spend deployment money and deliberately |
| - // resolve their target without requiring operator membership in it. |
| - s.cliRoute("POST /api/cli/accounts/{account}/store/apply", svcrole.Set{}, s.handleAPIStoreApply) |
| - s.cliRoute("POST /api/cli/accounts/{account}/store/approve", svcrole.Set{}, s.handleAPIStoreApprove) |
| - s.cliRoute("GET /api/cli/accounts/{account}/plan", svcrole.Set{}, s.handleAPIAccountPlanGet) |
| - s.cliRoute("POST /api/cli/accounts/{account}/plan", svcrole.Set{}, s.handleAPIAccountPlanSet) |
| - s.cliRoute("GET /api/cli/billing/problems", svcrole.Set{}, s.handleAPIBillingProblems) |
| - s.cliRoute("POST /api/cli/billing/problems/{id}/close", svcrole.Set{}, s.handleAPIBillingProblemClose) |
| - // Plans 6b (Task 14): an operator marks an account as a house account. |
| - s.cliRoute("POST /api/cli/billing/house", svcrole.Set{}, s.handleAPIBillingHouse) |
| - s.cliRoute("POST /api/cli/accounts/{account}/store/decline", svcrole.Set{}, s.handleAPIStoreDecline) |
| - s.cliRoute("GET /api/cli/store/approvals", svcrole.Set{}, s.handleAPIStoreApprovals) |
| - // The scan family (internal/console/apiscan.go). `scan` itself is the |
| - // member's request-and-status pair; grant, revoke, sweep and enforce are |
| - // operator verbs. Literal segments again, so no app or host name reaches |
| - // them. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan", svcrole.Allow(svcrole.Admin), s.handleAPIScanRequest) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/store/scan", svcrole.Allow(svcrole.Admin), s.handleAPIScanStatus) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/grant", svcrole.Allow(svcrole.Admin), s.handleAPIScanGrant) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/revoke", svcrole.Allow(svcrole.Admin), s.handleAPIScanRevoke) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/sweep", svcrole.Allow(svcrole.Admin), s.handleAPIScanSweep) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/enforce", svcrole.Allow(svcrole.Admin), s.handleAPIScanEnforce) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/callback-key/rotate", svcrole.Allow(svcrole.Admin), s.handleAPIScanCallbackRotate) |
| - // The ONE scan door an app's own credential reaches: "scan this object |
| - // now" (spec §5.1). Service, not Admin, and the difference is the point — |
| - // every verb above decides POLICY (who may scan, whether enforcement is |
| - // on) and belongs to a person, while this one asks for work inside a |
| - // policy somebody already set. It can add nothing an operator has not |
| - // already granted: the consent chain in the handler refuses unless the |
| - // store was requested, granted and enabled, so the worst a stolen service |
| - // token achieves is queueing scans of its own app's objects. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/store/scan/object", svcrole.Allow(svcrole.Service), s.handleAPIScanEnqueue) |
| - // And reading the answer back (spec §5.2), same role and same reasoning: |
| - // an app asking about its own object. |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/store/scan/object", svcrole.Allow(svcrole.Service), s.handleAPIScanObject) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/pdf/{route...}", svcrole.Allow(svcrole.Service), s.handleAPIPDF) |
| - // The relay family (internal/console/apirelay.go, relay spec §5): the |
| - // platform STUN/TURN relay's app-facing doors. enable/status/disable are |
| - // the member's own verbs — declaring, inspecting and ending the app's own |
| - // relay estate is not an authority over anything but that app, unlike the |
| - // object store's grant. adopted is the member's cutover ack for a |
| - // TCP-address route this platform cannot restart. Literal segments under |
| - // .../relay, same as store's, so no app or host name can reach them. |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/relay", svcrole.Allow(svcrole.Admin), s.handleAPIRelayEnable) |
| - s.cliRoute("GET /api/cli/apps/{account}/{app}/relay", svcrole.Allow(svcrole.Admin), s.handleAPIRelayGet) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/relay/disable", svcrole.Allow(svcrole.Admin), s.handleAPIRelayDisable) |
| - s.cliRoute("POST /api/cli/apps/{account}/{app}/relay/adopted", svcrole.Allow(svcrole.Admin), s.handleAPIRelayAdopted) |
| - // rotate is the ONE relay door with no {account} segment: it moves a |
| - // REGION's issuer pointer and re-issues every app enabled there, an |
| - // authority over the deployment's key material (RelayOperators, server.go) |
| - // rather than over any one tenant's app. apiRelayOperator is its whole |
| - // gate. |
| - s.cliRoute("POST /api/cli/relay/rotate", svcrole.Allow(svcrole.Admin), s.handleAPIRelayRotate) |
| - // `carlos system` (apisystemupdate.go and apisystem.go, spec §5) — the |
| - // deployment-wide doors. No {account} segment, so no service credential |
| - // can be scoped to them at all. Two families sit here: the operator's |
| - // promote of the PLATFORM's own binary (what is running where, roll the |
| - // fleet forward onto a signed public release or a local build, and roll |
| - // it back), and the deployment-wide antivirus policy. |
| - // |
| - // Every one of them is the ZERO Set, and for the sharpest version of the |
| - // escalation cut in this file: the subject is the substrate every tenant |
| - // runs inside. A credential that reached the update doors could point |
| - // every box in the deployment at a binary of its choosing, which is not a |
| - // widening of any workload's authority — it is the end of the boundary |
| - // the roles are drawn inside. An empty Set shuts them to every |
| - // credential, and closedDoors pins that shut. |
| - // |
| - // The person check itself is in the handlers, because cliRoute's Set can |
| - // only narrow SERVICE principals and a person always passes through it. |
| - // The update doors want an OWNER of the ops account or an address on |
| - // CARLOS_SYSTEM_OPERATORS, with upload the owner's alone |
| - // (apiSystemRoller); the antivirus doors want an address on |
| - // CARLOS_STORE_OPERATORS (apiSystemOperator). Managed fleet settings require |
| - // a configured system operator, without the ops-owner exception. |
| - s.cliRoute("GET /api/cli/system/managed-fleets", svcrole.Set{}, s.handleAPISystemManagedGet) |
| - s.cliRoute("PUT /api/cli/system/managed-fleets", svcrole.Set{}, s.handleAPISystemManagedSet) |
| - s.cliRoute("GET /api/cli/system/status", svcrole.Set{}, s.handleAPISystemStatus) |
| - s.cliRoute("POST /api/cli/system/update", svcrole.Set{}, s.handleAPISystemUpdate) |
| - s.cliRoute("GET /api/cli/system/jobs/{id}", svcrole.Set{}, s.handleAPISystemJob) |
| - s.cliRoute("PUT /api/cli/system/upload", svcrole.Set{}, s.handleAPISystemUpload) |
| - s.cliRoute("POST /api/cli/system/rollback", svcrole.Set{}, s.handleAPISystemRollback) |
| - // I-4: releasing an executable activation reservation that was never |
| - // published. The same person gate as rollback (apiSystemRoller). |
| - s.cliRoute("POST /api/cli/system/activation/cancel", svcrole.Set{}, s.handleAPISystemActivationCancel) |
| - s.cliRoute("GET /api/cli/system/layout", svcrole.Set{}, s.handleAPISystemLayoutGet) |
| - s.cliRoute("POST /api/cli/system/layout", svcrole.Set{}, s.handleAPISystemLayoutSet) |
| - s.cliRoute("GET /api/cli/system/antivirus", svcrole.Set{}, s.handleAPISystemAntivirusGet) |
| - s.cliRoute("GET /api/cli/system/pdf", svcrole.Set{}, s.handleAPISystemPDFGet) |
| - s.cliRoute("POST /api/cli/system/antivirus", svcrole.Set{}, s.handleAPISystemAntivirusSet) |
| - s.cliRoute("POST /api/cli/system/antivirus/rotate-webhook-key", svcrole.Set{}, s.handleAPISystemWebhookRotate) |
| - // Platform GeoIP (geoip spec §4.2): apiSystemRoller, like the update |
| - // doors, never CARLOS_STORE_OPERATORS. |
| - s.cliRoute("PUT /api/cli/system/geoip", svcrole.Set{}, s.handleAPISystemGeoipPut) |
| - s.cliRoute("GET /api/cli/system/geoip", svcrole.Set{}, s.handleAPISystemGeoipGet) |
| - s.cliRoute("DELETE /api/cli/system/geoip", svcrole.Set{}, s.handleAPISystemGeoipDelete) |
| - // The seeds floor (seeded-instances spec §3.3): apiSystemRoller. |
| - s.cliRoute("POST /api/cli/system/seeds-floor", svcrole.Set{}, s.handleAPISystemSeedsFloor) |
| - // Legacy route assignments (seeded-instances spec §6.4): apiSystemRoller. |
| - s.cliRoute("POST /api/cli/system/legacy-routes", svcrole.Set{}, s.handleAPISystemLegacyRoutes) |
| - // The lifetimes cutover (lifetimes_cutover.go): an operator's own CLI |
| - // token, else the move family's 404; closed to every service |
| - // credential. A host-claim console answers its 409. |
| - s.cliRoute("POST /api/cli/system/lifetimes/cutover", svcrole.Set{}, s.handleAPILifetimesCutover) |
| - // Pointer digests (#253, spec §4.6): each account's emission marker and |
| - // the channels still without digests. apiSystemRoller, like the update |
| - // doors. |
| - // The hostname history's status (nearest-region never-reuse, plan Task |
| - // 4, hostsused.go): apiSystemRoller, read-only. |
| - s.cliRoute("GET /api/cli/system/hosts-used/status", svcrole.Set{}, s.handleAPIHostsUsedStatus) |
| - s.cliRoute("GET /api/cli/system/pointer-digests", svcrole.Set{}, s.handleAPISystemPointerDigests) |
| - s.cliRoute("POST /api/cli/system/pointer-digests", svcrole.Set{}, s.handleAPISystemPointerDigests) |
| } |
| // clientIP is who the rate limiter counts against. |
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go| index e172662dd..d945b4cad 100644 |
| --- a/internal/console/routedecls.go |
| +++ b/internal/console/routedecls.go |
| @@ -395,6 +395,648 @@ var routeDecls = []routeDecl{ |
| // in the body is used, and the body only names what to re-read. Always |
| // registered: with billing off it answers 404. |
| {Pattern: "POST /billing/webhook", Handler: (*Server).handleBillingWebhook}, |
| + |
| + // The CLI-identity surface and the CLI API (authcli.go). |
| + // |
| + // The /auth/cli/ family and GET /settings below stay plain, deliberately: |
| + // they are the OTHER half of default-deny. Every one of them that reads a |
| + // bearer at all gates on cliUser, which answers only for a person, so a |
| + // service credential meets there exactly the 401 a fabricated token meets. |
| + // Pinned by TestAuthCLIFamilyResolvesOnlyPersons. |
| + // |
| + // Every /api/cli/ door is a cli kind and names its roles. Pinned by |
| + // TestEveryCLIDoorNamesItsRoles. |
| + {Pattern: "POST /api/fleet/replicas/{account}/{app}/{host}/coordinator", Handler: (*Server).handleReplicaCoordinator}, |
| + {Pattern: "POST /api/fleet/replicas/{account}/{app}/{host}/release", Handler: (*Server).handleReplicaRelease}, |
| + {Pattern: "POST /auth/cli/start", Handler: (*Server).handleCLIStart}, |
| + {Pattern: "POST /auth/cli/poll", Handler: (*Server).handleCLIPoll}, |
| + {Pattern: "GET /auth/cli", Handler: (*Server).handleCLIApprovePage}, |
| + {Pattern: "POST /auth/cli/approve", Handler: (*Server).handleCLIApprove}, |
| + {Pattern: "GET /settings", Handler: (*Server).handleCLITokens}, |
| + {Pattern: "GET /auth/cli/tokens", Build: func(s *Server) http.HandlerFunc { |
| + return func(w http.ResponseWriter, r *http.Request) { |
| + http.Redirect(w, r, "/settings", http.StatusSeeOther) |
| + } |
| + }}, |
| + {Pattern: "POST /auth/cli/tokens/revoke", Handler: (*Server).handleCLITokenRevoke}, |
| + {Pattern: "GET /auth/cli/whoami", Handler: (*Server).handleCLIWhoami}, |
| + {Pattern: "POST /auth/cli/revoke", Handler: (*Server).handleCLIRevoke}, |
| + {Pattern: "POST /auth/cli/accounts", Handler: (*Server).handleCLINewAccount}, |
| + // The CLI's read-only API (apicli.go) — deliberately a different prefix |
| + // (/api/cli/) from the identity routes above (/auth/cli/), which must not |
| + // move now that CLIs depend on them. |
| + {Pattern: "GET /api/cli/apps", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy, svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIApps}, |
| + // The fleet-wide live tenancy read (discussion #11). An EMPTY role set: |
| + // no service credential of any role reaches it, because the answer names |
| + // every account's instances on every box, and that is an operator's view |
| + // rather than any workload's. The operator check itself is inside the |
| + // handler, since cliRoute's role set can only narrow SERVICE principals |
| + // and a person always passes through it. |
| + {Pattern: "GET /api/cli/status/instances", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStatusInstances}, |
| + // Host loss inspection and submission are person-only and repeat the |
| + // fleet-operator check in their handlers. Until the follow-on integration supplies the |
| + // ActorDirectory both routes stop at the same inert refusal. |
| + {Pattern: "POST /api/cli/ops/hosts/{host}/resolve/inspect", Kind: kindCLI, Gate: gateHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIHostResolveInspect}, |
| + {Pattern: "POST /api/cli/ops/hosts/{host}/resolve", Kind: kindCLI, Gate: gateHostClaim, Allow: svcrole.Set{}, Handler: (*Server).handleAPIHostResolve}, |
| + // Box and group roles (region HA spec 2 §7, apiboxroles.go): |
| + // operator-only, and registered only with CARLOS_REGION_HA on too, |
| + // so with it off they answer as any unknown route, as on main. |
| + {Pattern: "POST /api/cli/system/boxes/{box}/role", Kind: kindCLI, Gate: gateRegionHA, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemBoxRole}, |
| + {Pattern: "POST /api/cli/system/groups/{region}/role", Kind: kindCLI, Gate: gateRegionHA, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemGroupRole}, |
| + // carlos status --layout (plan 4, task 5): which layout each instance is |
| + // on, box by box. Same posture as the door above — an empty role set, the |
| + // operator check inside the handler. |
| + {Pattern: "GET /api/cli/status/layout", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStatusLayout}, |
| + // The literal `new` mirrors the browser door (/a/{sqid}/apps/new); no |
| + // bare POST .../{app} route exists to collide with, and the mux prefers |
| + // the literal if one ever does. |
| + {Pattern: "POST /api/cli/apps/{account}/new", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPICreateApp}, |
| + // Temporary apps (temporary static sites spec §3). A separate route, not a |
| + // field on /new: /new's decoder accepts unknown fields, so an older |
| + // console would take "temporary" silently and create a permanent app. An |
| + // older console answers this route 404 and the CLI stops there. |
| + {Pattern: "POST /api/cli/apps/{account}/new-temporary", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPICreateTemporaryApp}, |
| + {Pattern: "GET /api/cli/apps/{account}/list", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIAppList}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/ttl", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIAppTTL}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/keep", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIAppKeep}, |
| + // The app's region, the default for its NEW instances (appregionset.go). |
| + // A person only: an account owner or a deployment operator may change |
| + // it, so no service role reaches either door. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/source", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAppSource}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/region", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAppRegionGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/region", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAppRegionSet}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/channels", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIChannels}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/promote", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIPromote}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/rollback", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIRollback}, |
| + // `carlos channels resign` (#253, spec §4.6): a person confirms the |
| + // manifest digests the console then signs into the channel's pointer, so |
| + // no credential reaches it. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/channels/resign", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIChannelResign}, |
| + // `carlos releases authorize` (settings spec §4.1): GET shows a build's |
| + // digests, POST signs a promotion record for the digest a person |
| + // confirmed. A credential the app holds never vouches for a build. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/releases/{version}/authorize", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAuthorize}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/releases/{version}/authorize", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAuthorize}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/releases", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIShip}, |
| + // `carlos restart` (issue #113): a member's "cycle this app's processes" |
| + // with no version and no config to push — the same write-door class as |
| + // promote and rollback, and the only one whose subject is a running |
| + // process rather than a pointer. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/restart", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIRestart}, |
| + // The NARROWED form (discussion #16): one route, or everything reading one |
| + // config environment, plus the dry run that shows the set first. A |
| + // SEPARATE path rather than a body on the door above, and deliberately so: |
| + // that one reads no body, so a console predating this would answer a |
| + // narrowed request by cycling the whole app. Here it answers 404 and the |
| + // CLI says why. Same role — the subject is still a running process. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/restart/scope", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Operate), Target: scopeRestartBody, Handler: (*Server).handleAPIRestartScope}, |
| + // `carlos schedule` (apischedule.go, scheduled-work spec §8): declare |
| + // recurring work, take it back, and make it fire now. The RESTART class, |
| + // not the publish one — operating a running app rather than moving a |
| + // version pointer — so the same Operate role reaches all four. `delete` |
| + // and `run` are literal segments after the {name} wildcard, so a schedule |
| + // named "delete" is still just a name; the mux prefers the literal |
| + // regardless of registration order. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/schedules", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIScheduleList}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/schedules", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIScheduleSet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/schedules/{name}/delete", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIScheduleRemove}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/schedules/{name}/run", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIScheduleRun}, |
| + // `carlos releases retention` (issue #136): a member's ambient-prune |
| + // policy — read, set, clear, preview. Same identity gates as every |
| + // door here; the safety list in release.PruneEligible is what keeps a |
| + // policy from ever deleting anything promoted, tagged, or recent. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/retention", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIRetentionGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/retention", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIRetentionSet}, |
| + // The version-target, tags and releases-list API (apiversion.go, |
| + // release versioning spec 2026-08-08). GET .../releases coexists with |
| + // the POST above on the SAME path — a distinct method route, not a |
| + // collision — for `carlos releases` to read what `carlos ship` writes. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/version-target", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIVersionTargetGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/version-target", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIVersionTargetSet}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/tags", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPITagsList}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/tags/{version}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPITagGet}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/releases", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIReleasesList}, |
| + // The pipeline API (apipipeline.go, release pipelines v2). GET is |
| + // release metadata like channels/releases above — Publish reaches it. |
| + // PUT rewrites the policy governing every promotion into every channel |
| + // (bake, passkey, approval quorum), account authority in the same |
| + // register as ledgers and store grants below — Admin-only for a |
| + // SERVICE credential. svcrole.Allow() alone would be the WRONG way to |
| + // say that: the empty Set is fully closed, Admin included |
| + // (TestEmptySetPermitsNothingIncludingAdmin, internal/svcrole) — the |
| + // same zero value svcrole.Set{} spells for the person-only doors |
| + // below. Naming Admin explicitly is what actually opens the door to an |
| + // admin-role service and closes it to every other role, exactly like |
| + // the ledgers and store families. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/pipeline", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIPipelineGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/pipeline", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIPipelinePut}, |
| + // What the app is waiting on: the proposals a gated promote, fast-track |
| + // or policy edit turned into (pendinghandlers.go). Read-only, and Publish |
| + // like channels and releases — a proposal names no secret, and the CLI |
| + // needs to see one precisely because it can never confirm one itself |
| + // (spec §4: confirming takes a passkey, in the console). |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/pending", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIPending}, |
| + // Trash and restore (apicli.go). Delete resolves through the LIVE-apps |
| + // door and restore through the trashed-apps one, so each verb answers |
| + // only for an app in the state it can act on — and both give a stranger |
| + // the same 404. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/delete", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPITrashApp}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/restore", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish), Handler: (*Server).handleAPIRestoreApp}, |
| + // The ledger API (apiledger.go) — the only write path to ledgers/ from |
| + // outside a box. The literal `publish` segment is kept adjacent to the |
| + // {ledger} wildcards for readability; the mux prefers it regardless of |
| + // registration order. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/ledgers", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPILedgerList}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/ledgers/publish", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPILedgerPublish}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/ledgers/{ledger}/head", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPILedgerHead}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/ledgers/{ledger}/append", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPILedgerAppend}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/ledgers/{ledger}/blobs", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPILedgerBlob}, |
| + // The instance provisioning API (apiinstances.go) — the only door onto |
| + // instances/ and domains/ from outside a box. It was once the only |
| + // family a non-person could speak to; since the role gate landed that is |
| + // a property of each door's Allow set, not of this block. `instance-token` is a literal segment beside the |
| + // {host} wildcards; the mux prefers a literal regardless of |
| + // registration order, and it deliberately sits under a DIFFERENT |
| + // prefix from instances/{host} so a host can never be mistaken for the |
| + // mint verb. |
| + // `instances-manifest` is the member-facing half of `carlos instances |
| + // enable` (issue #66): a literal sibling of instances/, never under it, |
| + // so a host named "instances-manifest" could still never reach it. |
| + // |
| + // The zero Set, for the same escalation cut the mint door takes. This |
| + // door writes the MANIFEST — standing policy about which domain, pool, |
| + // regions and channel the app may ever be brought up on — and a |
| + // credential the app itself holds must not be able to rewrite the |
| + // bounds it runs inside. It takes no authority away: handleAPIInstanceEnable |
| + // has always gated on apiAccountApp, which could not see a non-person at |
| + // all, so no app token has ever reached it. The registration is where |
| + // that is now said, because a registration reading "instance may pass" |
| + // while the handler refuses is a registration that lies. As at the mint |
| + // door, the ANSWER a credential gets here moves from 401 to 403. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/instances-manifest", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIInstanceEnable}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Instance, svcrole.Deploy), Target: scopeList, Handler: (*Server).handleAPIInstanceList}, |
| + // The armed-regions answer for consumer pickers (issue #346) — the |
| + // same gate and role as the list beside it; see handleAPIRegions. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/regions", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Deploy), Handler: (*Server).handleAPIRegions}, |
| + // The per-caller region guess (nearest-region spec §9.4): POST, so the |
| + // hints never ride a URL a redirect could echo. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/regions/guess", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIRegionGuess}, |
| + // Moving a route between channels (channelmove.go). The zero Set, for |
| + // the manifest door's reason: this decides what a route SERVES, and a |
| + // credential the app itself holds must not be able to walk its own route |
| + // onto a channel whose rules it never met. Widening it later is easy; |
| + // narrowing an authority already granted is not. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/channel", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIInstanceChannel}, |
| + // Update settings (instance update settings spec §5.1). Person-only until |
| + // #155 step 6 adds an instance-bound credential: svcrole.Instance is |
| + // app-wide, so it would let one instance's code set a sibling's pin. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/updates", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIUpdatesGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/instances/{host}/updates", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIUpdatesPut}, |
| + // "Update now" asks root for the newest build the settings allow; the |
| + // same people-only gate, and fast_track only for an account owner. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/updates/install", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIUpdatesInstall}, |
| + // The app's instance update policy (spec §3.2) lives on the instances |
| + // manifest, so it is closed for the manifest door's reason: a credential |
| + // the app holds must not rewrite the bounds its instances run inside. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/updates", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIUpdatesPolicy}, |
| + // The logs read (`carlos logs`, apilogs.go) — same gate, same 404 |
| + // discipline, and an app token may read its own app's logs. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/logs", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPILogs}, |
| + // The edge reference code read (apiedgeref.go): what the owner asks when |
| + // a visitor reads out the code from a block page. It reads the app's own |
| + // edge records, so it takes the logs door's gate and roles. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/edge-refs/{code}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIEdgeRef}, |
| + // The errors read (`carlos errors`, apierrors.go) — the logs door's twin, |
| + // over the same window from the other end: the same gate, the same roles, |
| + // and an app token may read its own app's errors for the same reason it |
| + // may read its own logs. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/errors", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIErrors}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/availability", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIAvailability}, |
| + // The analytics read (`carlos analytics`, apianalytics.go) — the third of |
| + // the same family, on the same footing: an app token that may read every |
| + // line of its own logs is not learning anything new from a count of its |
| + // own page views. The SETTING that decides whether those counts exist is |
| + // the telemetry PUT below, and that stays Operate-only. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/analytics", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIAnalytics}, |
| + // The platform's GeoIP answer for an arbitrary address (geoip spec |
| + // §11.1): the same holders as the analytics read. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/geo", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIGeo}, |
| + // The telemetry SETTINGS write, Operate only and deliberately narrower |
| + // than the read beside it: this decides what counts as an error for the |
| + // app's owner, and a credential the app itself holds must not be able to |
| + // widen or narrow what its owner is shown. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/telemetry", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPITelemetryPut}, |
| + // Its read (`carlos protection` with no flag): the stored settings under |
| + // the PUT's own gate, since they are the settings that PUT writes. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/telemetry", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPITelemetryGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Instance), Target: scopeCreateBody, Handler: (*Server).handleAPIInstanceCreate}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Instance), Target: scopeHost, Handler: (*Server).handleAPIInstanceGet}, |
| + // PATCH is the multi-upstream repoint (issue #152): the two fields of a |
| + // record — its addr set and its probe — that change while the instance |
| + // keeps serving. Same {host} wildcard, same gate, same byte-identical |
| + // 404 as its GET and DELETE siblings. |
| + {Pattern: "PATCH /api/cli/apps/{account}/{app}/instances/{host}", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Instance), Target: scopeHost, Handler: (*Server).handleAPIInstanceUpdate}, |
| + // The edge asset cache's purge and status (design §6, apiassets.go). |
| + // The purge draws a fresh asset generation for every instance of the |
| + // app: the deploy loop's and a deploy pipeline's act, beside the ship |
| + // that declared the folders. The status read is open to every app role: |
| + // it shows the app's own records and what their homes published. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/assets/purge", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy), Handler: (*Server).handleAPIAssetsPurge}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/assets", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Deploy, svcrole.Instance, svcrole.Operate), Handler: (*Server).handleAPIAssetsStatus}, |
| + // The deploy watch's gate pass (discussion #164). Instance, because an |
| + // Instance credential can already clear the gate through the PATCH |
| + // above, so a pass gives it nothing new. Deploy, because CI runs |
| + // `carlos deploy` with it, but per host: the handler refuses a host on a |
| + // channel the credential could not promote to. Publish is deliberately |
| + // NOT here: a Publish credential cannot always change what a host serves |
| + // (a passkey or approval rung turns its promote into a proposal), and it |
| + // cannot list instances, so `carlos deploy` never reaches this with one. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/gate-pass", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance, svcrole.Deploy), Handler: (*Server).handleAPIInstanceGatePass}, |
| + // The residence-move doors (issue #331): requested by the tenant's |
| + // ROUTER with the app-held instance token (titogo's residence design — |
| + // never by an instance about itself... which the role system cannot yet |
| + // express; the Instance role is the same authority the create and |
| + // delete doors already grant this credential). |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/move", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceMoveStatus}, |
| + // The rate-limit read (#358): the settings the PATCH above writes, with |
| + // the plan ceiling, what the edge applies, and the last day's refusals. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/rate-limit", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceRateLimitGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceMoveRequest}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/cut", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceMoveCut}, |
| + {Pattern: "DELETE /api/cli/apps/{account}/{app}/instances/{host}/move", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceMoveAbort}, |
| + // The offline operator move's doors: always registered, operator-only, |
| + // and refused with MV-O20 on a console with host claims or Phase 1 on. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/move/offline", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceOfflineStatus}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceOfflineStart}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/stage", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceOfflineStage}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/seal", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Build: func(s *Server) http.HandlerFunc { return s.offlineVerbDoor(offlineVerbSeal) }}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/flip", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Build: func(s *Server) http.HandlerFunc { return s.offlineVerbDoor(offlineVerbFlip) }}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/open", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Build: func(s *Server) http.HandlerFunc { return s.offlineVerbDoor(offlineVerbOpen) }}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/finish", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Build: func(s *Server) http.HandlerFunc { return s.offlineVerbDoor(offlineVerbFinish) }}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/abort", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIInstanceOfflineAbort}, |
| + {Pattern: "DELETE /api/cli/apps/{account}/{app}/instances/{host}", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Instance), Target: scopeHost, Handler: (*Server).handleAPIInstanceDelete}, |
| + // The import door (seeded-instances spec §5): the instance role, like |
| + // the create door that begins it. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/instances/{host}/import", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIImportUpload}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/import/stopped", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIImportStopped}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/import/commit", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIImportCommit}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/import/abort", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPIImportAbort}, |
| + // The run doors (service runs spec §1): a person on the member rule, or a |
| + // run service, and no other role. Exactly, not Allow, so Admin does not |
| + // join: a credential that may provision instances cannot run commands on |
| + // them unless it was minted for that. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/runs", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunCreate}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/runs", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunKeyLookup}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/cancel", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunCancel}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/expire", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunExpire}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/runs/{id}/ack", Kind: kindCLI, Allow: svcrole.Exactly(svcrole.Run), Handler: (*Server).handleAPIRunAck}, |
| + // The interactive session door (rootfs apps spec §5.10, apiinteractive.go): |
| + // a WebSocket for `carlos run -it` and `carlos console`. The ZERO Set: a |
| + // session is a live shell into production data, so no credential reaches |
| + // it, the run role included; the handler answers anything but a person |
| + // with the byte-identical 404. |
| + // A service credential the gate refuses gets the door's journal line |
| + // (journalUnplaced, once per caller per minute) beside its 403. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/instances/{host}/interactive", Kind: kindCLIJournaled, Allow: svcrole.Set{}, Refused: (*Server).journalUnplaced, Handler: (*Server).handleAPIInteractive}, |
| + // `carlos instances retry <host>` (apiretry.go): the operate family's, as |
| + // restart is. The {host} wildcard and the 404 are the instance family's. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instances/{host}/retry", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Operate), Target: scopeHost, Handler: (*Server).handleAPIInstanceRetry}, |
| + // The `carlos db` replica door (apidb.go; spec 2026-09-02 §6): an |
| + // instance's replicated LTX files, by coordinate, for a member to |
| + // restore on their own machine. The zero Set, deliberately: the payload |
| + // is the whole customer database, and no legitimate credential needs it |
| + // (an app reads its own database live, and CI has no business pulling |
| + // production data). admin is refused with the rest. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/db/{host}/ltx/{level}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDBList}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/db/{host}/ltx/{level}/{span}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDBGet}, |
| + // The forwarded read (db region forward spec §9.1): people only, the db |
| + // door's whole gate once, then the read inside the same request. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/db/{host}/reads", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDBRead}, |
| + // The zero Set, deliberately: a credential may never mint a credential, |
| + // including itself. This is the escalation cut (spec §3). It takes no |
| + // authority away — handleAPIInstanceToken gates on apiAccountApp, which |
| + // has never been able to see a non-person at all — it moves the refusal |
| + // out to the wrapper, where it is structural, and changes the ANSWER a |
| + // credential gets here from 401 to 403. Pinned by |
| + // TestNoRoleReachesAMintFleetOrPolicyDoor and TestAdminIsRefusedAtAClosedDoor. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/instance-token", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIInstanceToken}, |
| + // Door keys (#175 P7): person-only, the instance-token rule. A door key |
| + // reaches every instance of the app through every box's edge-local door. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/door-keys", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDoorKeyList}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/door-keys", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDoorKeyMint}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/door-keys/{id}/revoke", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDoorKeyRevoke}, |
| + // The sidecar API (apisidecars.go) — the only door onto sidecars/ from |
| + // outside a box, sharing the instance family's gate exactly |
| + // (instanceGate) and, since the role gate landed, its Allow sets too: |
| + // an app process provisions a sidecar per enrolled member with the |
| + // CARLOS_INSTANCE_TOKEN it already holds, which is the Instance role. |
| + // |
| + // `sidecars-manifest` is the member-facing half of `carlos sidecars |
| + // enable`: a literal sibling of sidecars/, never under it, so a sidecar |
| + // named "sidecars-manifest" could still never reach it. It takes the |
| + // ZERO Set for `instances-manifest`'s reason, and the reason is sharper |
| + // here: this manifest carries `args` — the argv the platform execs |
| + // after the release binary — plus the placement the workload is held |
| + // to. A credential the app holds must not be able to rewrite what its |
| + // own boxes will exec on its behalf. handleAPISidecarEnable has always |
| + // gated on apiAccountApp, which cannot see a non-person at all, so this |
| + // takes no authority away; it moves the refusal out to the registration |
| + // and the answer from 401 to 403. |
| + // |
| + // `wake` is a literal segment UNDER {name}; the mux prefers a literal |
| + // regardless of registration order, and provision.ValidSidecarName is |
| + // one DNS label, so no sidecar name can ever be "wake"'s path either. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/sidecars-manifest", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISidecarEnable}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/sidecars", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPISidecarList}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/sidecars", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPISidecarCreate}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/sidecars/{name}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPISidecarGet}, |
| + {Pattern: "DELETE /api/cli/apps/{account}/{app}/sidecars/{name}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPISidecarDelete}, |
| + // No PATCH: a sidecar has no upstream set to repoint, which is the one |
| + // thing an instance record's update verb exists for. The family is |
| + // create-only plus delete. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/sidecars/{name}/wake", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance), Handler: (*Server).handleAPISidecarWake}, |
| + // The extra-hostname API (apidomains.go, issue #151) — the only door onto |
| + // domains/ from outside a box, sharing the instance family's gate exactly |
| + // (instanceGate), so titogo's router attaches its customers' hostnames |
| + // with the CARLOS_INSTANCE_TOKEN it already holds. |
| + // |
| + // Domains carries `Instance` for COMPATIBILITY, not because it belongs |
| + // there: that router re-attaches every hostname on every reload pass with |
| + // its CARLOS_INSTANCE_TOKEN, which is a kind='app' row and so holds role |
| + // instance. Dropping it here 403s that router on the next console deploy. |
| + // Same for logs, above. Pinned by |
| + // TestInstanceRoleMatchesTodaysAppTokenReach; spec §5. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/domains", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Target: scopeList, Handler: (*Server).handleAPIDomainList}, |
| + // The per-host read (#299): same roles as the list it narrows — it |
| + // discloses strictly less (one hostname the caller already owns), so it |
| + // cannot need a role the list does not. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/domains/{host}", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Target: scopeDomainHost, Handler: (*Server).handleAPIDomainGet}, |
| + // The placements read (#447, apiplacements.go): which boxes serve the |
| + // claim's target, where, and whether it is ready. The per-host read's |
| + // roles and team scope exactly; it discloses no more about the claim. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/domains/{host}/placements", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Target: scopeDomainHost, Handler: (*Server).handleAPIDomainPlacementsGet}, |
| + // The placements write (#447, spec §6.2): the only way into regional |
| + // mode. A person's act and no service role's: it fixes where a name is |
| + // served in every region and its capabilities for the claim's life, and |
| + // a team credential (no team set here) cannot reach it either. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/domains/{host}/placements", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPlacementsPut}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/domains", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Target: scopeDomainBody, Handler: (*Server).handleAPIDomainAttach}, |
| + {Pattern: "POST /api/cli/accounts/{account}/domains/check", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainCheck}, |
| + {Pattern: "POST /api/cli/accounts/{account}/domains/purchases", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPurchase}, |
| + {Pattern: "GET /api/cli/accounts/{account}/domains/purchases/{id}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIDomainPurchaseStatus}, |
| + {Pattern: "DELETE /api/cli/apps/{account}/{app}/domains/{host}", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Target: scopeDomainHost, Handler: (*Server).handleAPIDomainDetach}, |
| + // The prefix-map publish (path-based routing): replace the WHOLE map of |
| + // leading path segments a claimed hostname splits its traffic by. The |
| + // tenant's own platform is the writer and the source of truth — it |
| + // regenerates the map from its database and republishes it — which is |
| + // why there is no per-prefix verb and no CLI writer at all. |
| + // |
| + // `Publish` AND `Instance`, matching the READ of the same state on |
| + // handleAPIDomainGet above. An earlier revision made this Publish-only on |
| + // the reasoning that a flip is deployment-shaped; the objection that |
| + // carried is internal coherence — as Publish-only, an Instance credential |
| + // could read a hostname's published prefix map and not write it, and this |
| + // file's own header names titogo's router, calling the domains family |
| + // with its CARLOS_INSTANCE_TOKEN, as the caller this door exists for. |
| + // |
| + // Widening crosses no tenancy boundary. The door is already owner-gated |
| + // on account and app (domainsGate) and guarded by |
| + // refuseServiceControlPlane, so an Instance token can only ever publish |
| + // its OWN app's map, naming targets the reconcile pass then re-checks |
| + // against the same account (aliases.go). It is not in |
| + // TestInstanceRoleMatchesTodaysAppTokenReach's legacy map, because |
| + // nothing reached it before service principals existed — see |
| + // exemptFromLegacyPin, where the deliberate grant is recorded. Design |
| + // spec §7. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/domains/{host}/paths", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Handler: (*Server).handleAPIDomainPaths}, |
| + // App feature flags (apifeatures.go, #347). The read carries Instance |
| + // because the app IS the consumer — its router reads its own switches |
| + // with the CARLOS_INSTANCE_TOKEN, the same credential and the same |
| + // answer (the domains deployment block) it already uses. The write is |
| + // Admin only: these are production switches, and the register is |
| + // `pipeline` PUT's and `apps place`'s, not promote's. An app's own |
| + // credential must never reach the write — a switch an app could flip |
| + // on itself is a root env flag by another name. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/features", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Publish, svcrole.Instance), Handler: (*Server).handleAPIFeaturesGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/features", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIFeaturesSet}, |
| + // The config API (apiconfig.go) — `carlos env` and `carlos secrets` |
| + // through the same gate as ship/promote, so deploy access no longer |
| + // means bucket credentials (issue #43). Secrets arrive already sealed; |
| + // the console relays an opaque envelope and holds no key to open it. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/config", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Operate), Target: scopeEnvironmentQuery, Handler: (*Server).handleAPIConfigGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/config", Kind: kindCLIScoped, Allow: svcrole.Allow(svcrole.Operate), Target: scopeEnvironmentBody, Handler: (*Server).handleAPIConfigPut}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/config/sync", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Operate), Handler: (*Server).handleAPIConfigSync}, |
| + // The routes read (apiroutes.go, issue #64) — the member-only door onto |
| + // this box's registry rows for one app, so a route's environment |
| + // binding can be read back without a box shell. |
| + // |
| + // The ZERO Set, and the reasoning is that file's own: "An app token is |
| + // a machine credential minted for one instance to register itself; this |
| + // answer describes every route of the app, with upstream addresses, |
| + // owning units and environment bindings, which is an operator's view |
| + // rather than a workload's." A service credential is the same kind of |
| + // caller an app token is, so the door that refuses one refuses all of |
| + // them. It joins policyDoors for that reason — person-only by intent, |
| + // not merely by bookkeeping. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/routes", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIRoutes}, |
| + // The customer fleets API (fleets.go) — account-owned remote-box groups |
| + // and where an app's routes/instances place onto them. `new` is a |
| + // literal beside the {fleet} wildcard for the same reason apps/new is: |
| + // the mux prefers a literal regardless of registration order, so there |
| + // is no ambiguity with a fleet that happened to be named "new". |
| + // |
| + // Every one of them is the zero Set, deliberately: enrolling a box into a |
| + // fleet, and rotating or detaching one, hands out a MACHINE's credentials |
| + // and changes where a whole account's apps can be placed. That is a human |
| + // act, and no service role reaches it — the same escalation cut as the |
| + // mint door above. Pinned by TestNoRoleReachesAMintFleetOrPolicyDoor. |
| + {Pattern: "POST /api/cli/fleets/{account}/new", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetNew}, |
| + {Pattern: "POST /api/cli/fleets/{account}/managed-plan", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIManagedFleetPlan}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/managed-boxes", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIManagedFleetAdd}, |
| + {Pattern: "GET /api/cli/fleets/{account}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetList}, |
| + {Pattern: "GET /api/cli/fleets/{account}/{fleet}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetShow}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/boxes", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetAddBox}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/rotate", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetRotateBox}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/detach", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetDetachBox}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/drain", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetDrainBox}, |
| + {Pattern: "POST /api/cli/fleets/{account}/{fleet}/boxes/{label}/tags", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetTagBox}, |
| + // The fleet's secrets key (fleetsecretskey.go): whoever sets it decides |
| + // who can read the fleet's future secrets, so the zero Set here too, and |
| + // an owner check inside. |
| + {Pattern: "PUT /api/cli/fleets/{account}/{fleet}/secrets-key", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIFleetSecretsKey}, |
| + // The service-credential API (apiservices.go, issue #220) — the |
| + // principal that is not an address. Every door here takes the ZERO role |
| + // set: a credential may never mint, rotate or revoke a credential, |
| + // including itself, which is what keeps a publish credential from |
| + // quietly becoming an admin one. Owner-gated inside, because minting is |
| + // an authority grant that outlives its minter. |
| + // |
| + // {name} is a wildcard with rotate and revoke as literal segments |
| + // beneath it — the mux prefers a literal regardless of registration |
| + // order, the same property the fleets and store families already rely |
| + // on, so a credential named "rotate" cannot shadow the verb. |
| + {Pattern: "POST /api/cli/services/{account}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIServiceCreate}, |
| + {Pattern: "GET /api/cli/services/{account}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIServiceList}, |
| + {Pattern: "POST /api/cli/services/{account}/{name}/rotate", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIServiceRotate}, |
| + {Pattern: "POST /api/cli/services/{account}/{name}/revoke", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIServiceRevoke}, |
| + // Placement lives under the apps family, not fleets: its subject is an |
| + // APP, and a target fleet name is only ever the request body's data. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/place", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIPlace}, |
| + // The build probe on an EXISTING app (discussion #13). An empty role set: |
| + // the probe is what the deploy watch trusts instead of the header, so a |
| + // credential that could rewrite it could make its own deploys report |
| + // success over a process that never restarted — which is the exact bug |
| + // the probe exists to prevent, handed to the wrong caller. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/build-probe", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIBuildProbe}, |
| + // The swap policy (zero-downtime spec §4.1, apiswap.go). The ZERO Set: |
| + // §11 says only app members change it, and a credential the app holds |
| + // must not choose what its own migrations run beside. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/copies", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPICopies}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/swap", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISwapPut}, |
| + // The interactive sessions setting (rootfs apps spec §5.10, |
| + // apiinteractivesetting.go). The ZERO Set: a session is a live shell |
| + // into production data, and a credential the app holds must not open |
| + // that door for itself. Turning it on is an owner's act, in the handler. |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/interactive", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIInteractivePut}, |
| + // The app policy (instance sizes and egress spec §6, apipolicy.go): the |
| + // private addresses an app's instances may reach and the sizes they run |
| + // at. The ZERO Set at the mux, so no service credential reaches either |
| + // door, an app's own included: a credential must not widen what its own |
| + // instances may reach. The operator gate (apiSystemRoller: an ops account |
| + // owner or CARLOS_SYSTEM_OPERATORS) is in the handlers, because a person |
| + // always passes cliRoute's Set. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/policy", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIPolicyGet}, |
| + {Pattern: "PUT /api/cli/apps/{account}/{app}/policy", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIPolicyPut}, |
| + // The object-storage API (apistore.go, issue #55) — declare a store, read |
| + // what became of it, and drive the walks that make it real. Beside the |
| + // config routes on purpose: a store's credentials are DELIVERED as config, |
| + // so these doors are halves of the same story for whoever reads this list. |
| + // |
| + // `grant` is the deployment's first operator-identity door: same member |
| + // 404 as its siblings, then an address on CARLOS_STORE_OPERATORS. Rotate |
| + // and finish are MEMBER verbs (spec §8) — they cycle a credential inside an |
| + // estate a grant already paid for. All three are literal segments under |
| + // .../store, never {wildcards}, so no app or host name can reach them. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreCreate}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/store", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/provision", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreProvision}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/grant", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreGrant}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/rotate", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreRotate}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/rotate/finish", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIStoreRotateFinish}, |
| + // Account-level storage entitlement doors are person-only. Applying speaks |
| + // for an account owner; approvals spend deployment money and deliberately |
| + // resolve their target without requiring operator membership in it. |
| + {Pattern: "POST /api/cli/accounts/{account}/store/apply", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStoreApply}, |
| + {Pattern: "POST /api/cli/accounts/{account}/store/approve", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStoreApprove}, |
| + {Pattern: "GET /api/cli/accounts/{account}/plan", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAccountPlanGet}, |
| + {Pattern: "POST /api/cli/accounts/{account}/plan", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIAccountPlanSet}, |
| + {Pattern: "GET /api/cli/billing/problems", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIBillingProblems}, |
| + {Pattern: "POST /api/cli/billing/problems/{id}/close", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIBillingProblemClose}, |
| + // Plans 6b (Task 14): an operator marks an account as a house account. |
| + {Pattern: "POST /api/cli/billing/house", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIBillingHouse}, |
| + {Pattern: "POST /api/cli/accounts/{account}/store/decline", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStoreDecline}, |
| + {Pattern: "GET /api/cli/store/approvals", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIStoreApprovals}, |
| + // The scan family (internal/console/apiscan.go). `scan` itself is the |
| + // member's request-and-status pair; grant, revoke, sweep and enforce are |
| + // operator verbs. Literal segments again, so no app or host name reaches |
| + // them. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanRequest}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/store/scan", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanStatus}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/grant", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanGrant}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/revoke", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanRevoke}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/sweep", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanSweep}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/enforce", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanEnforce}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/callback-key/rotate", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIScanCallbackRotate}, |
| + // The ONE scan door an app's own credential reaches: "scan this object |
| + // now" (spec §5.1). Service, not Admin, and the difference is the point — |
| + // every verb above decides POLICY (who may scan, whether enforcement is |
| + // on) and belongs to a person, while this one asks for work inside a |
| + // policy somebody already set. It can add nothing an operator has not |
| + // already granted: the consent chain in the handler refuses unless the |
| + // store was requested, granted and enabled, so the worst a stolen service |
| + // token achieves is queueing scans of its own app's objects. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/store/scan/object", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Service), Handler: (*Server).handleAPIScanEnqueue}, |
| + // And reading the answer back (spec §5.2), same role and same reasoning: |
| + // an app asking about its own object. |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/store/scan/object", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Service), Handler: (*Server).handleAPIScanObject}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/pdf/{route...}", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Service), Handler: (*Server).handleAPIPDF}, |
| + // The relay family (internal/console/apirelay.go, relay spec §5): the |
| + // platform STUN/TURN relay's app-facing doors. enable/status/disable are |
| + // the member's own verbs — declaring, inspecting and ending the app's own |
| + // relay estate is not an authority over anything but that app, unlike the |
| + // object store's grant. adopted is the member's cutover ack for a |
| + // TCP-address route this platform cannot restart. Literal segments under |
| + // .../relay, same as store's, so no app or host name can reach them. |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/relay", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIRelayEnable}, |
| + {Pattern: "GET /api/cli/apps/{account}/{app}/relay", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIRelayGet}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/relay/disable", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIRelayDisable}, |
| + {Pattern: "POST /api/cli/apps/{account}/{app}/relay/adopted", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIRelayAdopted}, |
| + // rotate is the ONE relay door with no {account} segment: it moves a |
| + // REGION's issuer pointer and re-issues every app enabled there, an |
| + // authority over the deployment's key material (RelayOperators, server.go) |
| + // rather than over any one tenant's app. apiRelayOperator is its whole |
| + // gate. |
| + {Pattern: "POST /api/cli/relay/rotate", Kind: kindCLI, Allow: svcrole.Allow(svcrole.Admin), Handler: (*Server).handleAPIRelayRotate}, |
| + // `carlos system` (apisystemupdate.go and apisystem.go, spec §5) — the |
| + // deployment-wide doors. No {account} segment, so no service credential |
| + // can be scoped to them at all. Two families sit here: the operator's |
| + // promote of the PLATFORM's own binary (what is running where, roll the |
| + // fleet forward onto a signed public release or a local build, and roll |
| + // it back), and the deployment-wide antivirus policy. |
| + // |
| + // Every one of them is the ZERO Set, and for the sharpest version of the |
| + // escalation cut in this file: the subject is the substrate every tenant |
| + // runs inside. A credential that reached the update doors could point |
| + // every box in the deployment at a binary of its choosing, which is not a |
| + // widening of any workload's authority — it is the end of the boundary |
| + // the roles are drawn inside. An empty Set shuts them to every |
| + // credential, and closedDoors pins that shut. |
| + // |
| + // The person check itself is in the handlers, because cliRoute's Set can |
| + // only narrow SERVICE principals and a person always passes through it. |
| + // The update doors want an OWNER of the ops account or an address on |
| + // CARLOS_SYSTEM_OPERATORS, with upload the owner's alone |
| + // (apiSystemRoller); the antivirus doors want an address on |
| + // CARLOS_STORE_OPERATORS (apiSystemOperator). Managed fleet settings require |
| + // a configured system operator, without the ops-owner exception. |
| + {Pattern: "GET /api/cli/system/managed-fleets", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemManagedGet}, |
| + {Pattern: "PUT /api/cli/system/managed-fleets", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemManagedSet}, |
| + {Pattern: "GET /api/cli/system/status", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemStatus}, |
| + {Pattern: "POST /api/cli/system/update", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemUpdate}, |
| + {Pattern: "GET /api/cli/system/jobs/{id}", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemJob}, |
| + {Pattern: "PUT /api/cli/system/upload", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemUpload}, |
| + {Pattern: "POST /api/cli/system/rollback", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemRollback}, |
| + // I-4: releasing an executable activation reservation that was never |
| + // published. The same person gate as rollback (apiSystemRoller). |
| + {Pattern: "POST /api/cli/system/activation/cancel", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemActivationCancel}, |
| + {Pattern: "GET /api/cli/system/layout", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemLayoutGet}, |
| + {Pattern: "POST /api/cli/system/layout", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemLayoutSet}, |
| + {Pattern: "GET /api/cli/system/antivirus", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemAntivirusGet}, |
| + {Pattern: "GET /api/cli/system/pdf", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemPDFGet}, |
| + {Pattern: "POST /api/cli/system/antivirus", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemAntivirusSet}, |
| + {Pattern: "POST /api/cli/system/antivirus/rotate-webhook-key", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemWebhookRotate}, |
| + // Platform GeoIP (geoip spec §4.2): apiSystemRoller, like the update |
| + // doors, never CARLOS_STORE_OPERATORS. |
| + {Pattern: "PUT /api/cli/system/geoip", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemGeoipPut}, |
| + {Pattern: "GET /api/cli/system/geoip", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemGeoipGet}, |
| + {Pattern: "DELETE /api/cli/system/geoip", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemGeoipDelete}, |
| + // The seeds floor (seeded-instances spec §3.3): apiSystemRoller. |
| + {Pattern: "POST /api/cli/system/seeds-floor", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemSeedsFloor}, |
| + // Legacy route assignments (seeded-instances spec §6.4): apiSystemRoller. |
| + {Pattern: "POST /api/cli/system/legacy-routes", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemLegacyRoutes}, |
| + // The lifetimes cutover (lifetimes_cutover.go): an operator's own CLI |
| + // token, else the move family's 404; closed to every service |
| + // credential. A host-claim console answers its 409. |
| + {Pattern: "POST /api/cli/system/lifetimes/cutover", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPILifetimesCutover}, |
| + // Pointer digests (#253, spec §4.6): each account's emission marker and |
| + // the channels still without digests. apiSystemRoller, like the update |
| + // doors. |
| + // The hostname history's status (nearest-region never-reuse, plan Task |
| + // 4, hostsused.go): apiSystemRoller, read-only. |
| + {Pattern: "GET /api/cli/system/hosts-used/status", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIHostsUsedStatus}, |
| + {Pattern: "GET /api/cli/system/pointer-digests", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemPointerDigests}, |
| + {Pattern: "POST /api/cli/system/pointer-digests", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPISystemPointerDigests}, |
| } |
| // registerDecls is THE loop: every declaration match accepts and whose gate |