accounts platform: operator grants and revokes platform status
Three operator-only doors on /api/cli/accounts/{account}/platform (show,
grant or re-grant, revoke), closed to every service credential, and
carlos accounts platform to drive them. A grant names plans from the
console's catalog, or none where there is no catalog. Revoke reports
how many working credentials it ended.
The closed-door pin rises from 103 to 106; the claim census, fixtures
and probes cover the three new routes; the CLI golden corpus is
re-recorded for the new verb. The plan's copy table gains the CLI's
ReasonRequired and Usage rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 files changed,
+1,198
−10
accounts.go+10 −1accounts_platform.go+230 −0accounts_platform_test.go+187 −0docs/parity.md+1 −0docs/site/cli.md+12 −0docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md+5 −1internal/console/apiplatformgrant.go+262 −0internal/console/apiplatformgrant_test.go+347 −0internal/console/claim_invariant_fixtures_test.go+3 −0internal/console/claim_invariant_probes_nonapp_test.go+35 −0internal/console/claim_invariant_probes_read_test.go+2 −0internal/console/platform_copy.go+27 −0internal/console/routedecls.go+7 −0internal/console/svcroutes_test.go+6 −2internal/console/testdata/claim-routes.txt+3 −0parity/cli.tsv+1 −0parity/parity.tsv+1 −0platform_copy.go+51 −0testdata/clireg-golden.jsonl+8 −6
diff --git a/accounts.go b/accounts.go| index 39eb93e82..fba761871 100644 |
| --- a/accounts.go |
| +++ b/accounts.go |
| @@ -30,7 +30,7 @@ import ( |
| "github.com/carlosframework/platform/internal/release" |
| ) |
| -const accountsUsage = `usage: carlos accounts <create|list|migrate|plan|subdomain> |
| +const accountsUsage = `usage: carlos accounts <create|list|migrate|plan|platform|subdomain> |
| create --name <name> mint an account: the next free id, its |
| frozen sqid, and the bucket manifest every |
| @@ -60,6 +60,14 @@ const accountsUsage = `usage: carlos accounts <create|list|migrate|plan|subdomai |
| they are more generous than the plan's |
| [--reason <text>] why the plan is changing |
| [--console <url>] which logged-in console to use |
| + platform --account <sqid> ` + cliPlatformCopyUsage + ` |
| + [--grant] ` + cliPlatformCopyFlagGrant + ` |
| + [--max-customers <n>] ` + cliPlatformCopyFlagMaxCustomers + ` |
| + [--plans <a,b>] ` + cliPlatformCopyFlagPlans + ` |
| + [--default-plan <plan>] ` + cliPlatformCopyFlagDefaultPlan + ` |
| + [--revoke] ` + cliPlatformCopyFlagRevoke + ` |
| + [--reason <text>] ` + cliPlatformCopyFlagReason + ` |
| + [--console <url>] which logged-in console to use |
| subdomain <set|remove|show|inventory> |
| ` + cliSubdomainCopyShort + ` |
| @@ -88,6 +96,7 @@ func accountsCommand() *clireg.Node { |
| raw("list", cust, runAccountsList), |
| raw("migrate", op, runAccountsMigrate), |
| raw("plan", op, runAccountsPlan), |
| + raw("platform", op, runAccountsPlatform), |
| accountsSubdomainCommand(), |
| }, |
| Fallback: func(args, consumed []string) { |
diff --git a/accounts_platform.go b/accounts_platform.go| new file mode 100644 |
| index 000000000..e15ed2646 |
| --- /dev/null |
| +++ b/accounts_platform.go |
| @@ -0,0 +1,230 @@ |
| +package main |
| + |
| +// `carlos accounts platform`: a deployment operator shows, grants, re-grants |
| +// and revokes an account's platform status through the console's grant door |
| +// (internal/console/apiplatformgrant.go; platform accounts spec §5.1, §9.3). |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "flag" |
| + "fmt" |
| + "io" |
| + "log" |
| + "net/http" |
| + "net/url" |
| + "strings" |
| + "time" |
| +) |
| + |
| +// platformGrantReply, putPlatformGrantRequest and platformRevokeReply mirror |
| +// the console door's wire shapes. A GET on an account with no grant answers |
| +// {"platform": false}, which decodes as a reply with Platform false. |
| +type platformGrantReply struct { |
| + Account string `json:"account"` |
| + Platform bool `json:"platform"` |
| + State string `json:"state"` |
| + Generation int64 `json:"generation"` |
| + MaxCustomers int `json:"max_customers"` |
| + Customers int `json:"customers"` |
| + Plans []string `json:"plans,omitempty"` |
| + DefaultPlan string `json:"default_plan,omitempty"` |
| + Reason string `json:"reason"` |
| + GrantedBy string `json:"granted_by"` |
| + GrantedAt *time.Time `json:"granted_at,omitempty"` |
| + RevokedBy string `json:"revoked_by,omitempty"` |
| + RevokeReason string `json:"revoke_reason,omitempty"` |
| + RevokedAt *time.Time `json:"revoked_at,omitempty"` |
| +} |
| + |
| +type platformRevokeReply struct { |
| + platformGrantReply |
| + CredentialsEnded int `json:"credentials_ended"` |
| +} |
| + |
| +// putPlatformGrantRequest leaves plans and the default out when they are |
| +// empty: a console with no plan catalog refuses a grant that names any. |
| +type putPlatformGrantRequest struct { |
| + MaxCustomers int `json:"max_customers"` |
| + Plans []string `json:"plans,omitempty"` |
| + DefaultPlan string `json:"default_plan,omitempty"` |
| + Reason string `json:"reason"` |
| +} |
| + |
| +func runAccountsPlatform(args []string) { |
| + if err := runAccountsPlatformWithSession(context.Background(), nil, args, stdout); err != nil { |
| + if errors.Is(err, flag.ErrHelp) { |
| + return |
| + } |
| + log.Fatalf("accounts platform: %v", err) |
| + } |
| +} |
| + |
| +func runAccountsPlatformWithSession(ctx context.Context, sess *apiSession, args []string, out io.Writer) error { |
| + fs := flag.NewFlagSet("accounts platform", flag.ContinueOnError) |
| + fs.SetOutput(out) |
| + account := fs.String("account", "", cliPlatformCopyFlagAccount) |
| + grant := fs.Bool("grant", false, cliPlatformCopyFlagGrant) |
| + revoke := fs.Bool("revoke", false, cliPlatformCopyFlagRevoke) |
| + maxCustomers := fs.Int("max-customers", 0, cliPlatformCopyFlagMaxCustomers) |
| + plansFlag := fs.String("plans", "", cliPlatformCopyFlagPlans) |
| + defaultPlan := fs.String("default-plan", "", cliPlatformCopyFlagDefaultPlan) |
| + reason := fs.String("reason", "", cliPlatformCopyFlagReason) |
| + consoleFlag := consoleOption(fs, "console origin to use") |
| + fs.Usage = flagUsage(fs, "") |
| + if err := fs.Parse(args); err != nil { |
| + return err |
| + } |
| + if fs.NArg() != 0 { |
| + return fmt.Errorf("unexpected argument %q", fs.Arg(0)) |
| + } |
| + acct, err := explicitStoreAccount(*account) |
| + if err != nil { |
| + return err |
| + } |
| + grantFlags := false |
| + fs.Visit(func(f *flag.Flag) { |
| + switch f.Name { |
| + case "max-customers", "plans", "default-plan": |
| + grantFlags = true |
| + } |
| + }) |
| + switch { |
| + case *grant && *revoke: |
| + return errors.New(cliPlatformCopyGrantAndRevoke) |
| + case grantFlags && !*grant: |
| + return errors.New(cliPlatformCopyGrantFlagsAlone) |
| + case (*grant || *revoke) && strings.TrimSpace(*reason) == "": |
| + return errors.New(cliPlatformCopyReasonRequired) |
| + } |
| + if sess == nil { |
| + sess = requirePlatformAPISession(*consoleFlag, "accounts platform") |
| + printUsing(out, sess) |
| + } |
| + switch { |
| + case *revoke: |
| + res, err := sess.revokePlatformGrant(ctx, acct, *reason) |
| + if err != nil { |
| + return err |
| + } |
| + fmt.Fprintf(out, cliPlatformCopyRevoked+"\n", acct, res.CredentialsEnded) |
| + case *grant: |
| + req := putPlatformGrantRequest{MaxCustomers: *maxCustomers, Plans: commaList(*plansFlag), |
| + DefaultPlan: strings.TrimSpace(*defaultPlan), Reason: *reason} |
| + res, err := sess.putPlatformGrant(ctx, acct, req) |
| + if err != nil { |
| + return err |
| + } |
| + fmt.Fprintf(out, cliPlatformCopyGranted+"\n", acct) |
| + printPlatformGrantBlock(out, res) |
| + default: |
| + res, err := sess.platformGrant(ctx, acct) |
| + if err != nil { |
| + return err |
| + } |
| + if !res.Platform { |
| + fmt.Fprintf(out, cliPlatformCopyNotPlatform+"\n", acct) |
| + return nil |
| + } |
| + fmt.Fprintf(out, cliPlatformCopyIsPlatform+"\n", acct) |
| + printPlatformGrantBlock(out, res) |
| + } |
| + return nil |
| +} |
| + |
| +// commaList splits a comma-separated flag value, dropping empty items. |
| +func commaList(v string) []string { |
| + var out []string |
| + for _, item := range strings.Split(v, ",") { |
| + if item = strings.TrimSpace(item); item != "" { |
| + out = append(out, item) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// printPlatformGrantBlock prints the grant's label block. The label column |
| +// is as wide as the longest label the block can show, so the block lines |
| +// up the same way on, off, and with or without plans (the Task 1 mocks). A |
| +// grant with no plans (a console with no plan catalog) has no plan lines. |
| +func printPlatformGrantBlock(w io.Writer, g platformGrantReply) { |
| + status, by, at, why := cliPlatformCopyValueOn, g.GrantedBy, g.GrantedAt, g.Reason |
| + byLabel := cliPlatformCopyLabelGrantedBy |
| + if g.State != "active" { |
| + status, by, at, why = cliPlatformCopyValueOff, g.RevokedBy, g.RevokedAt, g.RevokeReason |
| + byLabel = cliPlatformCopyLabelTurnedOffBy |
| + } |
| + rows := [][2]string{ |
| + {cliPlatformCopyLabelStatus, status}, |
| + {cliPlatformCopyLabelCustomers, fmt.Sprintf(cliPlatformCopyValueCustomers, g.Customers, g.MaxCustomers)}, |
| + } |
| + if len(g.Plans) > 0 { |
| + rows = append(rows, [2]string{cliPlatformCopyLabelPlans, strings.Join(g.Plans, ", ")}) |
| + } |
| + if g.DefaultPlan != "" { |
| + rows = append(rows, [2]string{cliPlatformCopyLabelDefault, g.DefaultPlan}) |
| + } |
| + when := by |
| + if at != nil { |
| + when = fmt.Sprintf(cliPlatformCopyValueByOn, by, at.UTC().Format("2 January 2006")) |
| + } |
| + rows = append(rows, [2]string{byLabel, when}, [2]string{cliPlatformCopyLabelReason, why}) |
| + width := 0 |
| + for _, label := range []string{cliPlatformCopyLabelStatus, cliPlatformCopyLabelCustomers, cliPlatformCopyLabelPlans, |
| + cliPlatformCopyLabelDefault, cliPlatformCopyLabelGrantedBy, cliPlatformCopyLabelTurnedOffBy, cliPlatformCopyLabelReason} { |
| + width = max(width, len(label)) |
| + } |
| + for _, row := range rows { |
| + fmt.Fprintf(w, " %-*s %s\n", width, row[0], row[1]) |
| + } |
| +} |
| + |
| +func platformGrantPath(account string) string { |
| + return "/api/cli/accounts/" + url.PathEscape(account) + "/platform" |
| +} |
| + |
| +func (s *apiSession) platformGrant(ctx context.Context, account string) (platformGrantReply, error) { |
| + status, body, err := s.getJSON(ctx, platformGrantPath(account)) |
| + var out platformGrantReply |
| + return out, decodePlatformReply(status, body, err, &out) |
| +} |
| + |
| +func (s *apiSession) putPlatformGrant(ctx context.Context, account string, req putPlatformGrantRequest) (platformGrantReply, error) { |
| + status, body, err := s.putJSON(ctx, platformGrantPath(account), req) |
| + var out platformGrantReply |
| + return out, decodePlatformReply(status, body, err, &out) |
| +} |
| + |
| +func (s *apiSession) revokePlatformGrant(ctx context.Context, account, reason string) (platformRevokeReply, error) { |
| + status, body, err := s.postJSON(ctx, platformGrantPath(account)+"/revoke", map[string]string{"reason": reason}) |
| + var out platformRevokeReply |
| + return out, decodePlatformReply(status, body, err, &out) |
| +} |
| + |
| +func decodePlatformReply(status int, body []byte, err error, out any) error { |
| + if err != nil { |
| + return err |
| + } |
| + if status != http.StatusOK { |
| + return apiErrorFromBody(status, body) |
| + } |
| + if err := json.Unmarshal(body, out); err != nil { |
| + return fmt.Errorf("unreadable response: %w", err) |
| + } |
| + return nil |
| +} |
| + |
| +// requirePlatformAPISession is the console session the platform doors |
| +// need. Grants and links live in the console's database, so direct bucket |
| +// mode has no equivalent. command names the verb in the refusal. |
| +func requirePlatformAPISession(consoleFlag, command string) *apiSession { |
| + sess, err := resolveMode(consoleFlag) |
| + if err != nil { |
| + log.Fatal(err) |
| + } |
| + if sess == nil { |
| + log.Fatalf(cliPlatformCopyNeedsConsole, command) |
| + } |
| + return sess |
| +} |
diff --git a/accounts_platform_test.go b/accounts_platform_test.go| new file mode 100644 |
| index 000000000..f2ad22277 |
| --- /dev/null |
| +++ b/accounts_platform_test.go |
| @@ -0,0 +1,187 @@ |
| +package main |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "flag" |
| + "io" |
| + "net/http" |
| + "net/http/httptest" |
| + "reflect" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +// platformGrantServer answers the grant doors with reply and records each |
| +// request: its method and path, and its body. |
| +func platformGrantServer(t *testing.T, reply any) (*httptest.Server, *[]string, *[]string) { |
| + t.Helper() |
| + var paths, bodies []string |
| + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + paths = append(paths, r.Method+" "+r.URL.RequestURI()) |
| + b, _ := io.ReadAll(r.Body) |
| + bodies = append(bodies, string(b)) |
| + json.NewEncoder(w).Encode(reply) |
| + })) |
| + t.Cleanup(ts.Close) |
| + return ts, &paths, &bodies |
| +} |
| + |
| +func platformDay(day int) *time.Time { |
| + t := time.Date(2026, time.November, day, 10, 4, 0, 0, time.UTC) |
| + return &t |
| +} |
| + |
| +// activeGrant is the Task 1 mock's grant: bcd, on, 3 of 50. |
| +func activeGrant() platformGrantReply { |
| + return platformGrantReply{Account: "bcd", Platform: true, State: "active", Generation: 1, MaxCustomers: 50, |
| + Customers: 3, Plans: []string{"free", "personal"}, DefaultPlan: "free", Reason: "agreed by email", |
| + GrantedBy: "ops@example.com", GrantedAt: platformDay(19)} |
| +} |
| + |
| +func runPlatform(t *testing.T, ts *httptest.Server, args ...string) string { |
| + t.Helper() |
| + var out bytes.Buffer |
| + if err := runAccountsPlatformWithSession(context.Background(), newTestSession(ts.URL), args, &out); err != nil { |
| + t.Fatalf("%v: %v", args, err) |
| + } |
| + return out.String() |
| +} |
| + |
| +func TestAccountsPlatformShowPrintsTheGrant(t *testing.T) { |
| + ts, paths, _ := platformGrantServer(t, activeGrant()) |
| + got := runPlatform(t, ts, "--account", "bcd") |
| + want := `bcd is a platform account |
| + status on |
| + customers 3 of 50 |
| + customer plans free, personal |
| + default plan free |
| + granted by ops@example.com on 19 November 2026 |
| + reason agreed by email |
| +` |
| + if got != want { |
| + t.Errorf("show:\n%s\nwant the Task 1 mock:\n%s", got, want) |
| + } |
| + if !reflect.DeepEqual(*paths, []string{"GET /api/cli/accounts/bcd/platform"}) { |
| + t.Fatalf("requests %v", *paths) |
| + } |
| + |
| + // Turned off: who turned it off and why, not who granted it. |
| + off := activeGrant() |
| + off.State, off.Generation = "revoked", 2 |
| + off.RevokedBy, off.RevokeReason, off.RevokedAt = "ops@example.com", "contract ended", platformDay(20) |
| + ts, _, _ = platformGrantServer(t, off) |
| + got = runPlatform(t, ts, "--account", "bcd") |
| + want = `bcd is a platform account |
| + status off |
| + customers 3 of 50 |
| + customer plans free, personal |
| + default plan free |
| + turned off by ops@example.com on 20 November 2026 |
| + reason contract ended |
| +` |
| + if got != want { |
| + t.Errorf("show when off:\n%s\nwant the Task 1 mock:\n%s", got, want) |
| + } |
| +} |
| + |
| +// TestAccountsPlatformShowWithoutPlans: a grant on a console with no plan |
| +// catalog has no plans, so it prints the Task 1 no-catalog mock, with no |
| +// "customer plans" or "default plan" line (pre-flight C17). |
| +func TestAccountsPlatformShowWithoutPlans(t *testing.T) { |
| + g := activeGrant() |
| + g.Plans, g.DefaultPlan = nil, "" |
| + ts, _, _ := platformGrantServer(t, g) |
| + got := runPlatform(t, ts, "--account", "bcd") |
| + want := `bcd is a platform account |
| + status on |
| + customers 3 of 50 |
| + granted by ops@example.com on 19 November 2026 |
| + reason agreed by email |
| +` |
| + if got != want { |
| + t.Errorf("show without plans:\n%s\nwant the Task 1 no-catalog mock:\n%s", got, want) |
| + } |
| +} |
| + |
| +func TestAccountsPlatformShowNotAPlatform(t *testing.T) { |
| + ts, _, _ := platformGrantServer(t, map[string]bool{"platform": false}) |
| + got := runPlatform(t, ts, "--account", "bcd") |
| + if want := "bcd isn’t a platform account\n"; got != want || !strings.HasPrefix(cliPlatformCopyNotPlatform, "%s ") { |
| + t.Fatalf("show = %q, want %q", got, want) |
| + } |
| +} |
| + |
| +func TestAccountsPlatformGrantSendsTheGrant(t *testing.T) { |
| + ts, paths, bodies := platformGrantServer(t, activeGrant()) |
| + got := runPlatform(t, ts, "--account", "bcd", "--grant", "--max-customers", "50", "--plans", "free, personal", |
| + "--default-plan", "free", "--reason", "r") |
| + var sent map[string]any |
| + if err := json.Unmarshal([]byte((*bodies)[0]), &sent); err != nil { |
| + t.Fatal(err) |
| + } |
| + want := map[string]any{"max_customers": float64(50), "plans": []any{"free", "personal"}, "default_plan": "free", "reason": "r"} |
| + if !reflect.DeepEqual(sent, want) { |
| + t.Fatalf("PUT body %v, want %v", sent, want) |
| + } |
| + if !reflect.DeepEqual(*paths, []string{"PUT /api/cli/accounts/bcd/platform"}) { |
| + t.Fatalf("requests %v", *paths) |
| + } |
| + if !strings.HasPrefix(got, "bcd is now a platform account\n status on\n") { |
| + t.Fatalf("grant output:\n%s", got) |
| + } |
| + |
| + // A grant on a console with no catalog sends no plans at all. |
| + ts, _, bodies = platformGrantServer(t, activeGrant()) |
| + runPlatform(t, ts, "--account", "bcd", "--grant", "--max-customers", "50", "--reason", "r") |
| + if want := `{"max_customers":50,"reason":"r"}`; strings.TrimSpace((*bodies)[0]) != want { |
| + t.Fatalf("PUT body %s, want %s", (*bodies)[0], want) |
| + } |
| + |
| + off := activeGrant() |
| + off.State = "revoked" |
| + ts, paths, bodies = platformGrantServer(t, platformRevokeReply{platformGrantReply: off, CredentialsEnded: 2}) |
| + got = runPlatform(t, ts, "--account", "bcd", "--revoke", "--reason", "contract ended") |
| + if want := "turned off platform access for bcd. credentials that stopped working: 2\n"; got != want { |
| + t.Fatalf("revoke output %q, want the Task 1 mock %q", got, want) |
| + } |
| + if !reflect.DeepEqual(*paths, []string{"POST /api/cli/accounts/bcd/platform/revoke"}) || |
| + strings.TrimSpace((*bodies)[0]) != `{"reason":"contract ended"}` { |
| + t.Fatalf("revoke sent %v %v", *paths, *bodies) |
| + } |
| +} |
| + |
| +func TestAccountsPlatformFlagRefusals(t *testing.T) { |
| + hits := 0 |
| + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { hits++ })) |
| + defer ts.Close() |
| + s := newTestSession(ts.URL) |
| + for _, c := range []struct { |
| + args []string |
| + want string |
| + }{ |
| + {[]string{"--account", "bcd", "--grant", "--revoke", "--reason", "r"}, cliPlatformCopyGrantAndRevoke}, |
| + {[]string{"--account", "bcd", "--plans", "free"}, cliPlatformCopyGrantFlagsAlone}, |
| + {[]string{"--account", "bcd", "--max-customers", "5"}, cliPlatformCopyGrantFlagsAlone}, |
| + {[]string{"--account", "bcd", "--revoke", "--default-plan", "free", "--reason", "r"}, cliPlatformCopyGrantFlagsAlone}, |
| + {[]string{"--account", "bcd", "--grant", "--max-customers", "50"}, cliPlatformCopyReasonRequired}, |
| + {[]string{"--account", "bcd", "--revoke", "--reason", " "}, cliPlatformCopyReasonRequired}, |
| + {[]string{"--grant", "--max-customers", "50", "--reason", "r"}, ""}, |
| + {[]string{"--account", "bcd", "extra"}, ""}, |
| + } { |
| + err := runAccountsPlatformWithSession(context.Background(), s, c.args, io.Discard) |
| + if err == nil || c.want != "" && err.Error() != c.want { |
| + t.Errorf("%v: %v, want %q", c.args, err, c.want) |
| + } |
| + } |
| + var help bytes.Buffer |
| + if err := runAccountsPlatformWithSession(context.Background(), s, []string{"--help"}, &help); !errors.Is(err, flag.ErrHelp) { |
| + t.Fatalf("--help: %v", err) |
| + } |
| + if hits != 0 { |
| + t.Fatalf("%d requests reached the console", hits) |
| + } |
| +} |
diff --git a/docs/parity.md b/docs/parity.md| index 1e117a830..947a7ca1e 100644 |
| --- a/docs/parity.md |
| +++ b/docs/parity.md |
| @@ -403,6 +403,7 @@ Discussion #742. |
| | op-store-grant | operator | `store grant` | | A per-app storage override; no ops page. | |
| | op-economics | operator | `economics bill`<br>`economics backhaul` | `GET /fleet/economics`<br>`/fleet/economics/bill`<br>`/api/economics/bill`<br>`/api/economics/backhaul`<br>`/fleet/economics/scenarios` | The bill and backhaul inputs; the CLI posts to the /api/economics doors. | |
| | op-accounts-plan | operator | `accounts plan` | `GET /fleet/economics/accounts`<br>`/fleet/economics/tier` | The console sets the pool tier only. | |
| +| op-accounts-platform | operator | `accounts platform` | | The operator account pages show grants in slice 3. | |
| | op-accounts-migrate | operator | `accounts migrate` | | A one-off migration of an app's objects. | |
| | op-accounts-subdomain | operator | `accounts subdomain set`<br>`accounts subdomain remove`<br>`accounts subdomain show`<br>`accounts subdomain inventory` | | Platform operators only. The account settings page shows the subdomain, read-only. | |
| | op-billing | operator | `billing problems`<br>`billing close`<br>`billing house` | | Billing problems and house accounts. | |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index 654fd9ec4..8cc1c0599 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -2628,6 +2628,18 @@ carlos accounts plan --account bac --set free --sponsored limits.json --reason " |
| Without `--set` it prints the plan, who set it and why, and every limit the account has. With `--set` it changes the plan and prints the result. `--reason` is required for a change. `--pack` can be repeated. `--sponsored` names a JSON file of limits; each one replaces the plan's limit where it is more generous. |
| +### carlos accounts platform |
| + |
| +Shows an account’s platform grant, or changes it. A platform account can create customer accounts and deploy into them for its own customers. It is a deployment-operator command. |
| + |
| +```sh |
| +carlos accounts platform --account bcd |
| +carlos accounts platform --account bcd --grant --max-customers 50 --plans free,personal --default-plan free --reason "agreed by email" |
| +carlos accounts platform --account bcd --revoke --reason "contract ended" |
| +``` |
| + |
| +Turning platform access off stops the platform’s credentials at once. Its customers’ sites keep serving. |
| + |
| ### carlos accounts subdomain |
| Assigns a readable name to an account's app addresses, so `shop.bdq.oncarlos.com` also works as `shop.harbour.oncarlos.com`. Only platform operators can use it. |
diff --git a/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md b/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md| index 58c5a9af2..8b9c33e72 100644 |
| --- a/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md |
| +++ b/docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md |
| @@ -590,7 +590,7 @@ func TestPlatformGrantDoorsAreClosedToEveryRole(t *testing.T) // serviceToken |
| ```go |
| func TestAccountsPlatformShowPrintsTheGrant(t *testing.T) // output lines equal the Task 1 mock with the copy constants |
| -func TestAccountsPlatformShowWithoutPlans(t *testing.T) // reply with no plans: the Task 1 no-catalog mock, no plans or "new accounts start on" line (pre-flight C17) |
| +func TestAccountsPlatformShowWithoutPlans(t *testing.T) // reply with no plans: the Task 1 no-catalog mock, no "customer plans" or "default plan" line (pre-flight C17) |
| func TestAccountsPlatformShowNotAPlatform(t *testing.T) // cliPlatformCopyNotPlatform |
| func TestAccountsPlatformGrantSendsTheGrant(t *testing.T) // PUT body {max_customers:50, plans:["free","personal"], default_plan:"free", reason:"r"} |
| func TestAccountsPlatformFlagRefusals(t *testing.T) // --grant with --revoke; --plans without --grant; --grant without --reason -> errors, nothing sent |
| @@ -1302,6 +1302,8 @@ Every row is pending copy review (Task 15). `%s`/`%d` are filled as named. CLI e |
| | FlagJSON | print JSON for scripts | |
| | GrantAndRevoke | --grant and --revoke can’t be used together | |
| | GrantFlagsAlone | --max-customers, --plans and --default-plan go with --grant | |
| +| ReasonRequired | --reason is required | |
| +| Usage | show or change an account’s platform grant (deployment operators) | |
| | OneHandle | pass --customer or --ref, not both | |
| | NoHandle | pass --customer or --ref | |
| | NoRef | no customer account has the reference %s | |
| @@ -1354,6 +1356,8 @@ A grant with no plans (no plan catalog) prints no `LabelPlans` or `LabelDefault` |
| Task 1's UX pass (2026-11-19) changed the text of `ValueByOn`, `LabelPlans`, `LabelDefault`, `Revoked`, `ListHeading`, `ColOwned`, `LabelOwned`, `UsageNear`, `UsageOver`, `UsageOverLimit`, `Minted`, `CreatedNoPlan` and `audit.grant_no_plans`, and added these rows: `LabelReason`, `ListOver`, `ListNear`, `ShowOK`, `ShowNear`, `ShowOver`, `LabelValidUntil`. The ids `ColOwned` and `LabelOwned` are kept although the words are now “claimed”. `ShowHeading` is used only for a customer with no plan. `ListOver` and `ListNear` are appended to `ListHeading` in that order, each only when its count is non-zero. |
| +Task 6 added `ReasonRequired` (the CLI's refusal of `--grant` or `--revoke` without `--reason`, before anything is sent; the text of the console's `grant.reason`) and `Usage` (the `platform` line in `carlos accounts`' usage). |
| + |
| Cap names in usage reuse the approved `cliPlanCopyLimit*` labels (apps and instances, object storage, emails a day, bandwidth a month, awake hours a month); `CapPDF` is the one new label. |
| **Docs** (`docs/site/cli.md`) |
diff --git a/internal/console/apiplatformgrant.go b/internal/console/apiplatformgrant.go| new file mode 100644 |
| index 000000000..70465dc40 |
| --- /dev/null |
| +++ b/internal/console/apiplatformgrant.go |
| @@ -0,0 +1,262 @@ |
| +package console |
| + |
| +import ( |
| + "errors" |
| + "fmt" |
| + "log" |
| + "net/http" |
| + "slices" |
| + "strings" |
| + "time" |
| +) |
| + |
| +// The platform grant door (platform accounts spec §5.1, §9.3): a fleet |
| +// operator shows, grants, re-grants and revokes an account's platform |
| +// status. Everyone else gets the stdlib 404, the plan door's convention, and |
| +// no service credential reaches it at all (the zero Set at the mux): granting |
| +// platform status is an operator's act. Unlike the plan door it works with no |
| +// plan catalog; a grant then names no plans. |
| + |
| +// Account-level audit actions for the grant, on the platform account's |
| +// history with app accountAuditSubject. |
| +const ( |
| + auditPlatformGrant = "platform-grant" |
| + auditPlatformRevoke = "platform-revoke" |
| +) |
| + |
| +// maxPlatformCustomers bounds a grant's max_customers (decision D8). |
| +const maxPlatformCustomers = 10000 |
| + |
| +// platformGrantReply is the grant as the door shows it. Generation is the |
| +// grant's current generation: a revoke moves it on, a re-grant keeps it. |
| +type platformGrantReply struct { |
| + Account string `json:"account"` |
| + Platform bool `json:"platform"` |
| + State string `json:"state"` |
| + Generation int64 `json:"generation"` |
| + MaxCustomers int `json:"max_customers"` |
| + Customers int `json:"customers"` |
| + Plans []string `json:"plans,omitempty"` |
| + DefaultPlan string `json:"default_plan,omitempty"` |
| + Reason string `json:"reason"` |
| + GrantedBy string `json:"granted_by"` |
| + GrantedAt *time.Time `json:"granted_at,omitempty"` |
| + RevokedBy string `json:"revoked_by,omitempty"` |
| + RevokeReason string `json:"revoke_reason,omitempty"` |
| + RevokedAt *time.Time `json:"revoked_at,omitempty"` |
| +} |
| + |
| +// platformRevokeReply is the revoke's answer: the grant, and how many |
| +// credentials that still worked the revoke ended. |
| +type platformRevokeReply struct { |
| + platformGrantReply |
| + CredentialsEnded int `json:"credentials_ended"` |
| +} |
| + |
| +type putPlatformGrantRequest struct { |
| + MaxCustomers int `json:"max_customers"` |
| + Plans []string `json:"plans"` |
| + DefaultPlan string `json:"default_plan"` |
| + Reason string `json:"reason"` |
| +} |
| + |
| +type revokePlatformGrantRequest struct { |
| + Reason string `json:"reason"` |
| +} |
| + |
| +// platformGrantDoor is the shared gate: an operator and a live account. It |
| +// is accountPlanDoor's gate without the catalog requirement, and it writes |
| +// the refusal itself. |
| +func (s *Server) platformGrantDoor(w http.ResponseWriter, r *http.Request) (addr string, acct *Account, ok bool) { |
| + addr, ok = s.cliUser(w, r) |
| + if !ok { |
| + return "", nil, false |
| + } |
| + isOperator, err := s.store.IsOperator(addr) |
| + if err != nil { |
| + log.Printf("console: api platform grant: is-operator: %v", err) |
| + http.NotFound(w, r) |
| + return "", nil, false |
| + } |
| + if !isOperator { |
| + http.NotFound(w, r) |
| + return "", nil, false |
| + } |
| + acct, err = s.store.AccountBySqid(r.PathValue("account")) |
| + if err != nil { |
| + log.Printf("console: api platform grant: account lookup: %v", err) |
| + http.NotFound(w, r) |
| + return "", nil, false |
| + } |
| + if acct == nil { |
| + http.NotFound(w, r) |
| + return "", nil, false |
| + } |
| + return addr, acct, true |
| +} |
| + |
| +func (s *Server) handleAPIPlatformGrantGet(w http.ResponseWriter, r *http.Request) { |
| + _, acct, ok := s.platformGrantDoor(w, r) |
| + if !ok { |
| + return |
| + } |
| + reply, found, err := s.platformGrantReplyFor(r, acct) |
| + if err != nil { |
| + log.Printf("console: api platform grant %s: %v", acct.Sqid, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + if !found { |
| + writeJSON(w, http.StatusOK, map[string]bool{"platform": false}) |
| + return |
| + } |
| + writeJSON(w, http.StatusOK, reply) |
| +} |
| + |
| +func (s *Server) handleAPIPlatformGrantPut(w http.ResponseWriter, r *http.Request) { |
| + addr, acct, ok := s.platformGrantDoor(w, r) |
| + if !ok { |
| + return |
| + } |
| + if !s.allowWrite(Principal{Address: addr}, time.Now()) { |
| + jsonError(w, http.StatusTooManyRequests, platformCopy["door.rate"]) |
| + return |
| + } |
| + var req putPlatformGrantRequest |
| + if !readJSONStrictLimit(w, r, &req, 8<<10) { |
| + return |
| + } |
| + reason := strings.TrimSpace(req.Reason) |
| + if reason == "" { |
| + jsonError(w, http.StatusBadRequest, platformCopy["grant.reason"]) |
| + return |
| + } |
| + if acct.ID == OpsAccountID { |
| + jsonError(w, http.StatusConflict, platformCopy["grant.ops"]) |
| + return |
| + } |
| + linkedTo, _, err := s.store.AccountPlatform(r.Context(), acct.ID) |
| + if err != nil { |
| + log.Printf("console: api platform grant %s: link: %v", acct.Sqid, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + if linkedTo != "" { |
| + jsonError(w, http.StatusConflict, platformCopy["grant.linked"]) |
| + return |
| + } |
| + if req.MaxCustomers < 1 || req.MaxCustomers > maxPlatformCustomers { |
| + jsonError(w, http.StatusBadRequest, platformCopy["grant.max"]) |
| + return |
| + } |
| + if id := s.grantPlansProblem(req); id != "" { |
| + jsonError(w, http.StatusBadRequest, platformCopy[id]) |
| + return |
| + } |
| + g := PlatformGrant{AccountID: acct.ID, MaxCustomers: req.MaxCustomers, Plans: req.Plans, |
| + DefaultPlan: req.DefaultPlan, Reason: reason, GrantedBy: addr} |
| + if err := s.store.PutPlatformGrant(r.Context(), g, time.Now()); err != nil { |
| + if errors.Is(err, ErrAccountGone) { |
| + http.NotFound(w, r) |
| + return |
| + } |
| + log.Printf("console: api platform grant %s: save: %v", acct.Sqid, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + reply, found, err := s.platformGrantReplyFor(r, acct) |
| + if err != nil || !found { |
| + log.Printf("console: api platform grant %s: read back: found %v, %v", acct.Sqid, found, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + detail := fmt.Sprintf(platformCopy["audit.grant_no_plans"], reply.MaxCustomers, reason) |
| + if len(reply.Plans) > 0 { |
| + detail = fmt.Sprintf(platformCopy["audit.grant"], reply.MaxCustomers, strings.Join(reply.Plans, ", "), |
| + reply.DefaultPlan, reason) |
| + } |
| + s.audit(acct, accountAuditSubject, addr, auditPlatformGrant, detail) |
| + writeJSON(w, http.StatusOK, reply) |
| +} |
| + |
| +// grantPlansProblem is the copy id that refuses req's plans, or "". With a |
| +// catalog a grant names at least one of its plans and a default among them; |
| +// without one it names none (decision D8, pre-flight C17). |
| +func (s *Server) grantPlansProblem(req putPlatformGrantRequest) string { |
| + cat := s.cfg.PlanCatalog |
| + if cat == nil { |
| + if len(req.Plans) > 0 || req.DefaultPlan != "" { |
| + return "grant.no_catalog" |
| + } |
| + return "" |
| + } |
| + if len(req.Plans) == 0 || !slices.Contains(req.Plans, req.DefaultPlan) { |
| + return "grant.plans" |
| + } |
| + for _, p := range req.Plans { |
| + if _, ok := cat.Plans[p]; !ok { |
| + return "grant.plans" |
| + } |
| + } |
| + return "" |
| +} |
| + |
| +func (s *Server) handleAPIPlatformGrantRevoke(w http.ResponseWriter, r *http.Request) { |
| + addr, acct, ok := s.platformGrantDoor(w, r) |
| + if !ok { |
| + return |
| + } |
| + var req revokePlatformGrantRequest |
| + if !readJSONStrictLimit(w, r, &req, 8<<10) { |
| + return |
| + } |
| + reason := strings.TrimSpace(req.Reason) |
| + if reason == "" { |
| + jsonError(w, http.StatusBadRequest, platformCopy["grant.reason"]) |
| + return |
| + } |
| + ended, err := s.store.RevokePlatformGrant(r.Context(), acct.ID, addr, reason, time.Now()) |
| + if errors.Is(err, ErrNotPlatform) { |
| + jsonError(w, http.StatusConflict, platformCopy["grant.not_platform"]) |
| + return |
| + } |
| + if err != nil { |
| + log.Printf("console: api platform revoke %s: %v", acct.Sqid, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + s.audit(acct, accountAuditSubject, addr, auditPlatformRevoke, fmt.Sprintf(platformCopy["audit.revoke"], ended, reason)) |
| + reply, found, err := s.platformGrantReplyFor(r, acct) |
| + if err != nil || !found { |
| + log.Printf("console: api platform revoke %s: read back: found %v, %v", acct.Sqid, found, err) |
| + jsonError(w, http.StatusInternalServerError, platformCopy["grant.failed"]) |
| + return |
| + } |
| + writeJSON(w, http.StatusOK, platformRevokeReply{platformGrantReply: reply, CredentialsEnded: ended}) |
| +} |
| + |
| +// platformGrantReplyFor reads acct's grant and its customer count. found is |
| +// false when the account has no grant row. The state is the row's, for an |
| +// operator to read: this door shows the grant and never authorizes on it. |
| +func (s *Server) platformGrantReplyFor(r *http.Request, acct *Account) (platformGrantReply, bool, error) { |
| + g, err := s.store.PlatformGrant(r.Context(), acct.ID) |
| + if err != nil || g == nil { |
| + return platformGrantReply{}, false, err |
| + } |
| + customers, err := s.store.LinkedCustomerCount(r.Context(), acct.Sqid) |
| + if err != nil { |
| + return platformGrantReply{}, false, err |
| + } |
| + granted := g.GrantedAt.UTC() |
| + reply := platformGrantReply{Account: acct.Sqid, Platform: true, State: g.State, Generation: g.Generation, |
| + MaxCustomers: g.MaxCustomers, Customers: customers, Plans: g.Plans, DefaultPlan: g.DefaultPlan, |
| + Reason: g.Reason, GrantedBy: g.GrantedBy, GrantedAt: &granted} |
| + if g.State == PlatformGrantRevoked { |
| + reply.RevokedBy, reply.RevokeReason = g.RevokedBy, g.RevokeReason |
| + if !g.RevokedAt.IsZero() { |
| + revoked := g.RevokedAt.UTC() |
| + reply.RevokedAt = &revoked |
| + } |
| + } |
| + return reply, true, nil |
| +} |
diff --git a/internal/console/apiplatformgrant_test.go b/internal/console/apiplatformgrant_test.go| new file mode 100644 |
| index 000000000..2188302eb |
| --- /dev/null |
| +++ b/internal/console/apiplatformgrant_test.go |
| @@ -0,0 +1,347 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/domains" |
| + "github.com/carlosframework/platform/internal/svcrole" |
| +) |
| + |
| +func platformGrantURL(fx *consoleFixture, sqid string) string { |
| + return fx.ts.URL + "/api/cli/accounts/" + sqid + "/platform" |
| +} |
| + |
| +// platformPut is the grant door's PUT, its reply decoded. |
| +func platformPut(t *testing.T, fx *consoleFixture, sqid string, body any, bearer string) (int, map[string]any) { |
| + t.Helper() |
| + status, raw := putRaw(t, platformGrantURL(fx, sqid), body, bearer) |
| + var out map[string]any |
| + if err := json.Unmarshal([]byte(raw), &out); err != nil { |
| + t.Fatalf("PUT %s = %d %q: %v", sqid, status, raw, err) |
| + } |
| + return status, out |
| +} |
| + |
| +func platformRevoke(t *testing.T, fx *consoleFixture, sqid string, body any, bearer string) (int, map[string]any) { |
| + t.Helper() |
| + return postJSON(t, platformGrantURL(fx, sqid)+"/revoke", body, bearer) |
| +} |
| + |
| +// wantPlatformError fails unless the reply is status with the copy row's |
| +// text as its error. |
| +func wantPlatformError(t *testing.T, what string, status int, out map[string]any, wantStatus int, id string) { |
| + t.Helper() |
| + if status != wantStatus || out["error"] != platformCopy[id] { |
| + t.Errorf("%s = %d %v, want %d %q", what, status, out, wantStatus, platformCopy[id]) |
| + } |
| +} |
| + |
| +// platformAudit is the account's audit rows for action, newest first. |
| +func platformAudit(t *testing.T, fx *consoleFixture, accountID int64, action string) []Event { |
| + t.Helper() |
| + events, err := fx.st.Events(accountID, accountAuditSubject, 50) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var out []Event |
| + for _, e := range events { |
| + if e.Action == action { |
| + out = append(out, e) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +func wantNoGrant(t *testing.T, fx *consoleFixture, accountID int64) { |
| + t.Helper() |
| + if g, err := fx.st.PlatformGrant(context.Background(), accountID); err != nil || g != nil { |
| + t.Fatalf("grant %+v %v, want none", g, err) |
| + } |
| +} |
| + |
| +func TestPlatformGrantDoorIsOperatorOnly(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.PlanCatalog = examplePlanCatalog(t) |
| + acct := planAccount(t, fx, 501) |
| + token := cliToken(t, fx, "owner"+acct.Sqid+"@example.com", "code-platform-owner") |
| + grant := map[string]any{"max_customers": 50, "plans": []string{"free"}, "default_plan": "free", "reason": "r"} |
| + for _, try := range []struct { |
| + method, path string |
| + body any |
| + }{ |
| + {http.MethodGet, "", nil}, |
| + {http.MethodPut, "", grant}, |
| + {http.MethodPost, "/revoke", map[string]any{"reason": "r"}}, |
| + } { |
| + var status int |
| + var out string |
| + u := platformGrantURL(fx, acct.Sqid) + try.path |
| + switch try.method { |
| + case http.MethodGet: |
| + status, out = getRaw(t, u, token) |
| + case http.MethodPut: |
| + status, out = putRaw(t, u, try.body, token) |
| + default: |
| + status, out = postRaw(t, u, try.body, token) |
| + } |
| + if status != http.StatusNotFound || out != "404 page not found\n" { |
| + t.Errorf("%s %s by the account's owner = %d %q, want the stdlib 404", try.method, try.path, status, out) |
| + } |
| + } |
| + wantNoGrant(t, fx, acct.ID) |
| + if rows := platformAudit(t, fx, acct.ID, auditPlatformGrant); len(rows) != 0 { |
| + t.Fatalf("refused PUT audited %+v", rows) |
| + } |
| + |
| + // An active grant the owner tries to revoke stays as it is. |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-op") |
| + if status, out := platformPut(t, fx, acct.Sqid, grant, op); status != http.StatusOK { |
| + t.Fatalf("operator PUT = %d %v", status, out) |
| + } |
| + if status, out := postRaw(t, platformGrantURL(fx, acct.Sqid)+"/revoke", map[string]any{"reason": "r"}, token); status != http.StatusNotFound || out != "404 page not found\n" { |
| + t.Fatalf("owner revoke = %d %q, want the stdlib 404", status, out) |
| + } |
| + if g, _ := fx.st.PlatformGrant(context.Background(), acct.ID); g == nil || g.State != PlatformGrantActive || g.Generation != 1 { |
| + t.Fatalf("grant after the owner's revoke %+v, want active at generation 1", g) |
| + } |
| + |
| + // An operator naming an account that is not there gets the same 404. |
| + if status, out := getRaw(t, platformGrantURL(fx, domains.Sqid(777)), op); status != http.StatusNotFound || out != "404 page not found\n" { |
| + t.Fatalf("unknown account = %d %q, want the stdlib 404", status, out) |
| + } |
| +} |
| + |
| +func TestPlatformGrantDoorRefusesOpsAndCustomerAccounts(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-ops") |
| + grant := map[string]any{"max_customers": 5, "reason": "r"} |
| + |
| + status, out := platformPut(t, fx, fx.sqid, grant, op) |
| + wantPlatformError(t, "PUT on the ops account", status, out, http.StatusConflict, "grant.ops") |
| + wantNoGrant(t, fx, OpsAccountID) |
| + |
| + platform := planAccount(t, fx, 501) |
| + ctx := context.Background() |
| + if err := fx.st.PutPlatformGrant(ctx, PlatformGrant{AccountID: platform.ID, MaxCustomers: 5, Reason: "r", |
| + GrantedBy: "ops@keymail.dev"}, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + const mint = "0123456789abcdef0123456789abcdef" |
| + if err := fx.st.ReservePlatformMint(ctx, PendingMint{MintID: mint, Platform: platform.Sqid, Ref: "4812", |
| + Name: "shop", By: "service:" + platform.Sqid + "/cms", CreatedAt: time.Now()}); err != nil { |
| + t.Fatal(err) |
| + } |
| + customer := NewLinkedAccount{ID: 502, Sqid: domains.Sqid(502), Name: "shop", Platform: platform.Sqid, Ref: "4812", |
| + MintID: mint, By: "service:" + platform.Sqid + "/cms"} |
| + if err := fx.st.CreateLinkedAccount(ctx, customer, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + status, out = platformPut(t, fx, customer.Sqid, grant, op) |
| + wantPlatformError(t, "PUT on a customer account", status, out, http.StatusConflict, "grant.linked") |
| + wantNoGrant(t, fx, customer.ID) |
| + for _, id := range []int64{OpsAccountID, customer.ID} { |
| + if rows := platformAudit(t, fx, id, auditPlatformGrant); len(rows) != 0 { |
| + t.Errorf("refused PUT audited %+v on account %d", rows, id) |
| + } |
| + } |
| +} |
| + |
| +func TestPlatformGrantValidatesPlansAgainstTheCatalog(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.PlanCatalog = examplePlanCatalog(t) |
| + acct := planAccount(t, fx, 501) |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-plans") |
| + for _, c := range []struct { |
| + name string |
| + body map[string]any |
| + id string |
| + }{ |
| + {"no reason", map[string]any{"max_customers": 50, "plans": []string{"free"}, "default_plan": "free", "reason": " "}, "grant.reason"}, |
| + {"max 0", map[string]any{"max_customers": 0, "plans": []string{"free"}, "default_plan": "free", "reason": "r"}, "grant.max"}, |
| + {"max 10001", map[string]any{"max_customers": 10001, "plans": []string{"free"}, "default_plan": "free", "reason": "r"}, "grant.max"}, |
| + {"unknown plan", map[string]any{"max_customers": 50, "plans": []string{"free", "gold"}, "default_plan": "free", "reason": "r"}, "grant.plans"}, |
| + {"default not in plans", map[string]any{"max_customers": 50, "plans": []string{"free"}, "default_plan": "personal", "reason": "r"}, "grant.plans"}, |
| + {"no plans", map[string]any{"max_customers": 50, "default_plan": "free", "reason": "r"}, "grant.plans"}, |
| + {"no default", map[string]any{"max_customers": 50, "plans": []string{"free"}, "reason": "r"}, "grant.plans"}, |
| + } { |
| + status, out := platformPut(t, fx, acct.Sqid, c.body, op) |
| + want := http.StatusBadRequest |
| + wantPlatformError(t, c.name, status, out, want, c.id) |
| + } |
| + wantNoGrant(t, fx, acct.ID) |
| + |
| + status, out := platformPut(t, fx, acct.Sqid, map[string]any{"max_customers": 50, |
| + "plans": []string{"personal", "free", "free"}, "default_plan": "free", "reason": "agreed by email"}, op) |
| + if status != http.StatusOK { |
| + t.Fatalf("PUT = %d %v", status, out) |
| + } |
| + if out["account"] != acct.Sqid || out["platform"] != true || out["state"] != PlatformGrantActive || |
| + out["generation"] != float64(1) || out["max_customers"] != float64(50) || out["customers"] != float64(0) || |
| + fmt.Sprint(out["plans"]) != "[free personal]" || out["default_plan"] != "free" || |
| + out["reason"] != "agreed by email" || out["granted_by"] != "ops@keymail.dev" || out["granted_at"] == nil { |
| + t.Fatalf("reply %v", out) |
| + } |
| + for _, key := range []string{"revoked_at", "revoked_by", "revoke_reason"} { |
| + if _, ok := out[key]; ok { |
| + t.Errorf("an active grant's reply carries %s: %v", key, out) |
| + } |
| + } |
| + rows := platformAudit(t, fx, acct.ID, auditPlatformGrant) |
| + want := fmt.Sprintf(platformCopy["audit.grant"], 50, "free, personal", "free", "agreed by email") |
| + if len(rows) != 1 || rows[0].Detail != want || rows[0].Address != "ops@keymail.dev" { |
| + t.Fatalf("audit %+v, want one row %q", rows, want) |
| + } |
| +} |
| + |
| +func TestPlatformGrantWithoutACatalog(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + acct := planAccount(t, fx, 501) |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-nocat") |
| + for _, body := range []map[string]any{ |
| + {"max_customers": 50, "plans": []string{"free"}, "reason": "r"}, |
| + {"max_customers": 50, "default_plan": "free", "reason": "r"}, |
| + } { |
| + status, out := platformPut(t, fx, acct.Sqid, body, op) |
| + wantPlatformError(t, fmt.Sprint(body), status, out, http.StatusBadRequest, "grant.no_catalog") |
| + } |
| + wantNoGrant(t, fx, acct.ID) |
| + |
| + status, out := platformPut(t, fx, acct.Sqid, map[string]any{"max_customers": 50, "reason": "agreed by email"}, op) |
| + if status != http.StatusOK || out["state"] != PlatformGrantActive || out["max_customers"] != float64(50) { |
| + t.Fatalf("PUT = %d %v", status, out) |
| + } |
| + if _, ok := out["plans"]; ok { |
| + t.Errorf("a grant with no plans replies plans: %v", out) |
| + } |
| + if _, ok := out["default_plan"]; ok { |
| + t.Errorf("a grant with no plans replies a default plan: %v", out) |
| + } |
| + rows := platformAudit(t, fx, acct.ID, auditPlatformGrant) |
| + want := fmt.Sprintf(platformCopy["audit.grant_no_plans"], 50, "agreed by email") |
| + if len(rows) != 1 || rows[0].Detail != want { |
| + t.Fatalf("audit %+v, want one row %q", rows, want) |
| + } |
| +} |
| + |
| +func TestPlatformRevokeAndRegrant(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + fx.srv.cfg.PlanCatalog = examplePlanCatalog(t) |
| + acct := planAccount(t, fx, 501) |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-revoke") |
| + |
| + status, out := platformRevoke(t, fx, acct.Sqid, map[string]any{"reason": "r"}, op) |
| + wantPlatformError(t, "revoke with no grant", status, out, http.StatusConflict, "grant.not_platform") |
| + |
| + grant := map[string]any{"max_customers": 50, "plans": []string{"free", "personal"}, "default_plan": "free", "reason": "agreed by email"} |
| + if status, out := platformPut(t, fx, acct.Sqid, grant, op); status != http.StatusOK || out["generation"] != float64(1) { |
| + t.Fatalf("grant = %d %v", status, out) |
| + } |
| + // Two credentials that work, one that has expired: the revoke ends all |
| + // three and counts the two. |
| + insertToken(t, fx.st, "platform-role", cliKindService, string(svcrole.Platform), acct.ID, 0, time.Time{}) |
| + insertToken(t, fx.st, "customer-live", "platform", string(svcrole.Publish), 502, acct.ID, time.Now().Add(time.Hour)) |
| + insertToken(t, fx.st, "customer-expired", "platform", string(svcrole.Publish), 502, acct.ID, time.Now().Add(-time.Hour)) |
| + |
| + status, out = platformRevoke(t, fx, acct.Sqid, map[string]any{"reason": " "}, op) |
| + wantPlatformError(t, "revoke with no reason", status, out, http.StatusBadRequest, "grant.reason") |
| + |
| + status, out = platformRevoke(t, fx, acct.Sqid, map[string]any{"reason": "contract ended"}, op) |
| + if status != http.StatusOK { |
| + t.Fatalf("revoke = %d %v", status, out) |
| + } |
| + if out["platform"] != true || out["state"] != PlatformGrantRevoked || out["generation"] != float64(2) || |
| + out["credentials_ended"] != float64(2) || out["revoked_by"] != "ops@keymail.dev" || |
| + out["revoke_reason"] != "contract ended" || out["revoked_at"] == nil { |
| + t.Fatalf("revoke reply %v", out) |
| + } |
| + for _, hash := range []string{"platform-role", "customer-live", "customer-expired"} { |
| + if tokenRevokedAt(t, fx.st, hash) == 0 { |
| + t.Errorf("credential %s is not revoked", hash) |
| + } |
| + } |
| + rows := platformAudit(t, fx, acct.ID, auditPlatformRevoke) |
| + if want := fmt.Sprintf(platformCopy["audit.revoke"], 2, "contract ended"); len(rows) != 1 || rows[0].Detail != want { |
| + t.Fatalf("revoke audit %+v, want one row %q", rows, want) |
| + } |
| + |
| + status, out = getJSON(t, platformGrantURL(fx, acct.Sqid), op) |
| + if status != http.StatusOK || out["state"] != PlatformGrantRevoked || out["revoke_reason"] != "contract ended" || |
| + out["reason"] != "agreed by email" || out["generation"] != float64(2) { |
| + t.Fatalf("GET after revoke = %d %v", status, out) |
| + } |
| + if _, ok := out["credentials_ended"]; ok { |
| + t.Errorf("GET carries credentials_ended: %v", out) |
| + } |
| + |
| + status, out = platformRevoke(t, fx, acct.Sqid, map[string]any{"reason": "again"}, op) |
| + wantPlatformError(t, "second revoke", status, out, http.StatusConflict, "grant.not_platform") |
| + |
| + grant["reason"] = "renewed" |
| + status, out = platformPut(t, fx, acct.Sqid, grant, op) |
| + if status != http.StatusOK || out["state"] != PlatformGrantActive || out["generation"] != float64(2) || |
| + out["reason"] != "renewed" { |
| + t.Fatalf("re-grant = %d %v, want active at the revoke's generation 2", status, out) |
| + } |
| + for _, key := range []string{"revoked_at", "revoked_by", "revoke_reason"} { |
| + if _, ok := out[key]; ok { |
| + t.Errorf("a re-grant's reply carries %s: %v", key, out) |
| + } |
| + } |
| + if rows := platformAudit(t, fx, acct.ID, auditPlatformGrant); len(rows) != 2 { |
| + t.Fatalf("grant audit rows %+v, want 2", rows) |
| + } |
| +} |
| + |
| +func TestPlatformGrantGetWithNoGrant(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + acct := planAccount(t, fx, 501) |
| + op := planOperatorToken(t, fx, "ops@keymail.dev", "code-platform-get") |
| + status, out := getRaw(t, platformGrantURL(fx, acct.Sqid), op) |
| + if status != http.StatusOK || out != `{"platform":false}`+"\n" { |
| + t.Fatalf("GET = %d %q, want 200 {\"platform\":false}", status, out) |
| + } |
| +} |
| + |
| +// TestPlatformGrantDoorsAreClosedToEveryRole: granting platform status is an |
| +// operator's act, so no credential reaches the three doors, the platform |
| +// account's own platform credential and Admin included. |
| +func TestPlatformGrantDoorsAreClosedToEveryRole(t *testing.T) { |
| + fx := newConsoleFixture(t) |
| + acct := planAccount(t, fx, 501) |
| + if err := fx.st.PutPlatformGrant(context.Background(), PlatformGrant{AccountID: acct.ID, MaxCustomers: 5, |
| + Reason: "r", GrantedBy: "ops@keymail.dev"}, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + first := "" |
| + for _, role := range svcrole.All() { |
| + var tok string |
| + if role == svcrole.Platform { |
| + tok = serviceToken(t, fx.st, acct.ID, "cms", "", role) |
| + } else { |
| + tok = backupsToken(t, fx.st, OpsAccountID, "svc-"+string(role), "kass", role) |
| + } |
| + for _, door := range []struct{ method, path, body string }{ |
| + {http.MethodGet, "", ""}, |
| + {http.MethodPut, "", `{"max_customers":10000,"reason":"r"}`}, |
| + {http.MethodPost, "/revoke", `{"reason":"r"}`}, |
| + } { |
| + status, _, body := rawReq(t, door.method, platformGrantURL(fx, acct.Sqid)+door.path, tok, door.body) |
| + if first == "" { |
| + first = body |
| + } |
| + if status != http.StatusForbidden || !strings.Contains(body, "closed to service credentials") || body != first { |
| + t.Errorf("%s at %s %s = %d %q, want the closed-door 403", role, door.method, door.path, status, body) |
| + } |
| + } |
| + } |
| + if g, _ := fx.st.PlatformGrant(context.Background(), acct.ID); g == nil || g.State != PlatformGrantActive || |
| + g.MaxCustomers != 5 || g.Generation != 1 { |
| + t.Fatalf("grant after refused credentials %+v, want it untouched", g) |
| + } |
| +} |
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go| index ffa1469a2..d41477ef6 100644 |
| --- a/internal/console/claim_invariant_fixtures_test.go |
| +++ b/internal/console/claim_invariant_fixtures_test.go |
| @@ -915,6 +915,7 @@ var claimFixtures = map[string]claimFixture{ |
| "route GET /api/cli/status/layout": claimRead("operator layout view"), |
| "route GET /api/cli/store/approvals": claimRead("operator entitlement queue"), |
| "route GET /api/cli/accounts/{account}/plan": claimRead("operator view of an account's plan and limits"), |
| + "route GET /api/cli/accounts/{account}/platform": claimRead("operator view of an account's platform grant and customer count; names no app"), |
| "route GET /api/cli/billing/problems": claimRead("operator view of billing problems; names no app"), |
| "route GET /api/cli/billing/revenue": claimRead("operator view of billing revenue; names no app"), |
| "route GET /api/cli/billing/payments": claimRead("operator view of billing payments; names no app"), |
| @@ -1544,6 +1545,8 @@ var claimFixtures = map[string]claimFixture{ |
| "route POST /api/cli/accounts/{account}/store/apply": claimNonApp("applies for the account's storage entitlement"), |
| "route POST /api/cli/accounts/{account}/store/approve": claimNonApp("operator approves an account's storage entitlement"), |
| "route POST /api/cli/accounts/{account}/plan": claimNonApp("operator sets an account's plan, packs and sponsored limits; names no app"), |
| + "route PUT /api/cli/accounts/{account}/platform": claimNonApp("operator grants or changes an account's platform grant, writing the grant row; names no app"), |
| + "route POST /api/cli/accounts/{account}/platform/revoke": claimNonApp("operator revokes an account's platform grant, ending its generation and its platform credentials; names no app"), |
| "route POST /api/cli/billing/house": claimNonApp("operator marks or clears an account's house flag, the account whose checkout carries the house coupon, writing the flag row; names no app"), |
| "route POST /api/cli/billing/problems/{id}/close": claimNonApp("operator closes a billing problem with a note after a fresh provider read; names no app"), |
| "route POST /api/cli/accounts/{account}/store/decline": claimNonApp("operator declines an account's storage entitlement"), |
diff --git a/internal/console/claim_invariant_probes_nonapp_test.go b/internal/console/claim_invariant_probes_nonapp_test.go| index 4d6417813..fd868e009 100644 |
| --- a/internal/console/claim_invariant_probes_nonapp_test.go |
| +++ b/internal/console/claim_invariant_probes_nonapp_test.go |
| @@ -1188,6 +1188,30 @@ var claimNonAppProbes = map[string]claimProbe{ |
| }, |
| // ---- the platform system doors ---- |
| + "route PUT /api/cli/accounts/{account}/platform": { |
| + setup: func(t *testing.T, cx *claimCase) { cx.secondAccount(t) }, |
| + do: claimAPIReply(http.MethodPut, "/api/cli/accounts/"+claimSecondSqid+"/platform", `{"max_customers":5,"reason":"census"}`), |
| + body: []string{`"state":"active"`}, |
| + effect: func(t *testing.T, cx *claimCase, r claimReply) string { |
| + if g, err := cx.st.PlatformGrant(context.Background(), 2); err != nil || g == nil || |
| + g.State != PlatformGrantActive || g.MaxCustomers != 5 || g.Reason != "census" { |
| + return fmt.Sprintf("the second account has no census grant: %+v %v", g, err) |
| + } |
| + return "" |
| + }, |
| + }, |
| + "route POST /api/cli/accounts/{account}/platform/revoke": { |
| + setup: claimPlatformGranted, |
| + do: claimAPIReply(http.MethodPost, "/api/cli/accounts/"+claimSecondSqid+"/platform/revoke", `{"reason":"census"}`), |
| + body: []string{`"state":"revoked"`, `"credentials_ended":0`}, |
| + effect: func(t *testing.T, cx *claimCase, r claimReply) string { |
| + if g, err := cx.st.PlatformGrant(context.Background(), 2); err != nil || g == nil || |
| + g.State != PlatformGrantRevoked || g.Generation != 2 || g.RevokeReason != "census" { |
| + return fmt.Sprintf("the second account's grant is not revoked: %+v %v", g, err) |
| + } |
| + return "" |
| + }, |
| + }, |
| "route PUT /api/cli/system/managed-fleets": { |
| do: claimAPIReply(http.MethodPut, "/api/cli/system/managed-fleets", `{"enabled":false,"ceiling":3}`), |
| body: []string{`"ceiling":3`}, |
| @@ -1575,3 +1599,14 @@ func claimGettingStartedProbe(action string, kv []string, mark gsMark, want bool |
| }, |
| } |
| } |
| + |
| +// claimPlatformGranted stages the second account with an active platform |
| +// grant, for the grant door's read and revoke probes. |
| +func claimPlatformGranted(t *testing.T, cx *claimCase) { |
| + t.Helper() |
| + cx.secondAccount(t) |
| + if err := cx.st.PutPlatformGrant(context.Background(), PlatformGrant{AccountID: 2, MaxCustomers: 5, |
| + Reason: "census", GrantedBy: claimFxOwner}, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
diff --git a/internal/console/claim_invariant_probes_read_test.go b/internal/console/claim_invariant_probes_read_test.go| index 4cc42ab6a..1a85b9de0 100644 |
| --- a/internal/console/claim_invariant_probes_read_test.go |
| +++ b/internal/console/claim_invariant_probes_read_test.go |
| @@ -365,6 +365,8 @@ var claimReadProbes = map[string]claimProbe{ |
| "route GET /api/cli/store/approvals": claimAPIRead(claimWorldApply, "/api/cli/store/approvals", `"applications"`, claimFxOwner), |
| "route GET /api/cli/accounts/{account}/plan": claimAPIRead(func(t *testing.T, cx *claimCase) { cx.srv.cfg.PlanCatalog = examplePlanCatalog(t) }, |
| "/api/cli/accounts/bab/plan", `"plan":"free"`), |
| + "route GET /api/cli/accounts/{account}/platform": claimAPIRead(claimPlatformGranted, |
| + "/api/cli/accounts/"+claimSecondSqid+"/platform", `"state":"active"`, `"max_customers":5`), |
| "route GET /api/cli/billing/problems": claimAPIRead(claimBillingProblemWorld, "/api/cli/billing/problems", `"reason":"unrecognised"`), |
| "route GET /api/cli/billing/revenue": claimAPIRead(claimBillingWorld, "/api/cli/billing/revenue", `"accounts":`, `"arr":`), |
| "route GET /api/cli/billing/payments": claimAPIRead(claimBillingWorld, "/api/cli/billing/payments", `"available":`, `"test_mode":`), |
diff --git a/internal/console/platform_copy.go b/internal/console/platform_copy.go| new file mode 100644 |
| index 000000000..5948111a9 |
| --- /dev/null |
| +++ b/internal/console/platform_copy.go |
| @@ -0,0 +1,27 @@ |
| +package console |
| + |
| +// Copy for platform accounts (docs/superpowers/plans/2026-11-19-platform- |
| +// accounts-1-platform-layer.md, "Copy table", pending copy review). Each key |
| +// is the table's id; each text is the table's, byte for byte. Each task of |
| +// that plan adds the rows it uses. |
| +// |
| +// The CLI prints the JSON errors as they come, so they are lowercase with no |
| +// closing full stop, as the existing cli copy is. The audit.* rows are the |
| +// account history's details. |
| + |
| +var platformCopy = map[string]string{ |
| + "grant.ops": "the ops account can’t be a platform account", |
| + "grant.linked": "a customer account can’t be a platform account", |
| + "grant.reason": "--reason is required", |
| + "grant.max": "--max-customers must be a whole number from 1 to 10000", |
| + "grant.plans": "--plans must name plans in this console’s catalog, and --default-plan must be one of them", |
| + "grant.no_catalog": "this console has no plan catalog, so a grant can’t name plans", |
| + "grant.not_platform": "this account isn’t a platform account", |
| + "grant.failed": "could not save the grant. try again", |
| + |
| + "door.rate": "too many requests. wait a minute and try again", |
| + |
| + "audit.grant": "made this a platform account: up to %d customer accounts, plans %s, new ones on %s. reason: %s", |
| + "audit.grant_no_plans": "made this a platform account: up to %d customer accounts. reason: %s", |
| + "audit.revoke": "turned off platform access, %d credentials stopped working. reason: %s", |
| +} |
diff --git a/internal/console/routedecls.go b/internal/console/routedecls.go| index 5c9de5fda..715be8f3e 100644 |
| --- a/internal/console/routedecls.go |
| +++ b/internal/console/routedecls.go |
| @@ -995,6 +995,13 @@ var routeDecls = []routeDecl{ |
| {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}, |
| + // The platform grant (apiplatformgrant.go, platform accounts spec §5.1): |
| + // a fleet operator, as a person, shows, grants and revokes an account's |
| + // platform status. Closed to every service credential, the platform |
| + // credential and Admin included; the handler admits operators only. |
| + {Pattern: "GET /api/cli/accounts/{account}/platform", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIPlatformGrantGet}, |
| + {Pattern: "PUT /api/cli/accounts/{account}/platform", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIPlatformGrantPut}, |
| + {Pattern: "POST /api/cli/accounts/{account}/platform/revoke", Kind: kindCLI, Allow: svcrole.Set{}, Handler: (*Server).handleAPIPlatformGrantRevoke}, |
| // Account subdomains (apisubdomain.go, spec §4.3): a platform operator, |
| // as a person, sets, shows and removes an account's subdomain, and |
| // lists the hosts under labels no account holds. Closed to every |
diff --git a/internal/console/svcroutes_test.go b/internal/console/svcroutes_test.go| index 7fd82b1bd..024122077 100644 |
| --- a/internal/console/svcroutes_test.go |
| +++ b/internal/console/svcroutes_test.go |
| @@ -240,6 +240,10 @@ var closedDoors = []string{ |
| "POST /api/cli/accounts/{account}/domains/purchases", |
| "GET /api/cli/accounts/{account}/plan", |
| "POST /api/cli/accounts/{account}/plan", |
| + // Granting platform status is an operator's act; no credential reaches it. |
| + "GET /api/cli/accounts/{account}/platform", |
| + "PUT /api/cli/accounts/{account}/platform", |
| + "POST /api/cli/accounts/{account}/platform/revoke", |
| // An account's subdomain, and the inventory of labels no account |
| // holds, are a platform operator's (account subdomains spec §4.3): a |
| // person, never a machine credential. The handler admits |
| @@ -1758,8 +1762,8 @@ func TestEveryClosedDoorRefusesAServiceCredential(t *testing.T) { |
| } |
| seen++ |
| } |
| - if seen != len(closedDoors) || seen != 103 { |
| - t.Errorf("walked %d closed doors, want all %d (and 103 today: three domain purchase doors, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, and the claimed source door)", |
| + if seen != len(closedDoors) || seen != 106 { |
| + t.Errorf("walked %d closed doors, want all %d (and 106 today: three domain purchase doors, two managed admission doors, the fleet show door, two managed configuration doors, three environment ownership doors, instance-token, three door-key doors, the routes door, the regional placements write, instances-manifest, the app update policy, sidecars-manifest, the route-channel move, three instance update settings doors, two db replica doors, the forwarded db read, seven fleets, the instance label door, the fleet secrets key door, the two person link doors (list and unlink), the six home link doors, four services, two email credentials, email pause, the build probe, the swap policy, the copy count, the interactive setting, the interactive session door, two app policy doors, two app region doors, the live tenancy read, the layout read, the activation-cancel door, eleven system doors, three deployment-wide antivirus, the PDF status door, three platform geoip doors, two pointer digest doors, the hostname history status, the channel resign, two release authorize doors, four store-entitlement doors, two account plan doors, three platform grant doors, two billing problem doors, the billing revenue and payments doors, the billing house door, three account subdomain doors, the subdomain inventory, and the claimed source door)", |
| seen, len(closedDoors)) |
| } |
| } |
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt| index eca795d4f..b8e2727e4 100644 |
| --- a/internal/console/testdata/claim-routes.txt |
| +++ b/internal/console/testdata/claim-routes.txt |
| @@ -76,6 +76,7 @@ route GET /api/box/interactive/{id} |
| route GET /api/box/runs/{id} |
| route GET /api/cli/accounts/{account}/domains/purchases/{id} |
| route GET /api/cli/accounts/{account}/plan |
| +route GET /api/cli/accounts/{account}/platform |
| route GET /api/cli/accounts/{account}/subdomain |
| route GET /api/cli/apps |
| route GET /api/cli/apps/{account}/list |
| @@ -261,6 +262,7 @@ route POST /alerts/unsubscribe/{token} |
| route POST /api/cli/accounts/{account}/domains/check |
| route POST /api/cli/accounts/{account}/domains/purchases |
| route POST /api/cli/accounts/{account}/plan |
| +route POST /api/cli/accounts/{account}/platform/revoke |
| route POST /api/cli/accounts/{account}/store/apply |
| route POST /api/cli/accounts/{account}/store/approve |
| route POST /api/cli/accounts/{account}/store/decline |
| @@ -398,6 +400,7 @@ route POST /auth/signout |
| route POST /billing/webhook |
| route POST /fleet/store/{account}/{decision} |
| route POST /invite/{token} |
| +route PUT /api/cli/accounts/{account}/platform |
| route PUT /api/cli/apps/{account}/{app}/config |
| route PUT /api/cli/apps/{account}/{app}/copies |
| route PUT /api/cli/apps/{account}/{app}/domains/{host}/paths |
diff --git a/parity/cli.tsv b/parity/cli.tsv| index cb32f4faf..a9186b8db 100644 |
| --- a/parity/cli.tsv |
| +++ b/parity/cli.tsv |
| @@ -13,6 +13,7 @@ accounts create customer - - - - - |
| accounts list customer - - - - - |
| accounts migrate operator - - - - - |
| accounts plan operator - - - - - |
| +accounts platform operator - - - - - |
| accounts subdomain inventory operator - - - - - |
| accounts subdomain remove operator - - - - - |
| accounts subdomain set operator - - - - - |
diff --git a/parity/parity.tsv b/parity/parity.tsv| index 7fcdde519..5dc3e7498 100644 |
| --- a/parity/parity.tsv |
| +++ b/parity/parity.tsv |
| @@ -201,6 +201,7 @@ op-store-approvals operator operator store approvals ; store approve ; store dec |
| op-store-grant operator operator store grant A per-app storage override; no ops page. |
| op-economics operator operator economics bill ; economics backhaul GET /fleet/economics ; /fleet/economics/bill ; /api/economics/bill ; /api/economics/backhaul ; /fleet/economics/scenarios The bill and backhaul inputs; the CLI posts to the /api/economics doors. |
| op-accounts-plan operator operator accounts plan GET /fleet/economics/accounts ; /fleet/economics/tier The console sets the pool tier only. |
| +op-accounts-platform operator operator accounts platform The operator account pages show grants in slice 3. |
| op-accounts-migrate operator operator accounts migrate A one-off migration of an app's objects. |
| op-accounts-subdomain operator operator accounts subdomain set ; accounts subdomain remove ; accounts subdomain show ; accounts subdomain inventory Platform operators only. The account settings page shows the subdomain, read-only. |
| op-billing operator operator billing problems ; billing close ; billing house Billing problems and house accounts. |
diff --git a/platform_copy.go b/platform_copy.go| new file mode 100644 |
| index 000000000..015cba1ad |
| --- /dev/null |
| +++ b/platform_copy.go |
| @@ -0,0 +1,51 @@ |
| +package main |
| + |
| +// Copy for platform accounts on the command line (docs/superpowers/plans/ |
| +// 2026-11-19-platform-accounts-1-platform-layer.md, "Copy table", the CLI |
| +// rows, pending copy review). Each constant is cliPlatformCopy plus the |
| +// table's id, and its text is the table's, byte for byte. Each task of that |
| +// plan adds the rows it uses. |
| +// |
| +// The console's refusals are not here: its JSON errors already carry their |
| +// sentences (internal/console/platform_copy.go), and the CLI prints them as |
| +// they come. |
| + |
| +const ( |
| + cliPlatformCopyNeedsConsole = "carlos %s works through a console, and this shell is in direct bucket mode\n(CARLOS_DEPLOYMENT_BUCKET/CARLOS_DEPLOYMENT_DIR is set).\nunset the store env, then run carlos auth login --console <url> or set CARLOS_SERVICE_TOKEN" |
| + |
| + // Usage is the line `carlos accounts` prints for platform (a row this |
| + // task adds). |
| + cliPlatformCopyUsage = "show or change an account’s platform grant (deployment operators)" |
| + |
| + cliPlatformCopyFlagAccount = "platform account sqid to show or change" |
| + cliPlatformCopyFlagGrant = "make the account a platform account, or change its grant" |
| + cliPlatformCopyFlagRevoke = "turn the account’s platform access off" |
| + cliPlatformCopyFlagMaxCustomers = "how many customer accounts it may have" |
| + cliPlatformCopyFlagPlans = "plans its customer accounts may be on, comma-separated" |
| + cliPlatformCopyFlagDefaultPlan = "the plan new customer accounts start on" |
| + cliPlatformCopyFlagReason = "why. it is kept with the change" |
| + |
| + cliPlatformCopyGrantAndRevoke = "--grant and --revoke can’t be used together" |
| + cliPlatformCopyGrantFlagsAlone = "--max-customers, --plans and --default-plan go with --grant" |
| + // ReasonRequired is the console's grant.reason, said before anything is |
| + // sent (a row this task adds). |
| + cliPlatformCopyReasonRequired = "--reason is required" |
| + |
| + cliPlatformCopyIsPlatform = "%s is a platform account" |
| + cliPlatformCopyNotPlatform = "%s isn’t a platform account" |
| + |
| + cliPlatformCopyLabelStatus = "status" |
| + cliPlatformCopyValueOn = "on" |
| + cliPlatformCopyValueOff = "off" |
| + cliPlatformCopyLabelCustomers = "customers" |
| + cliPlatformCopyValueCustomers = "%d of %d" |
| + cliPlatformCopyLabelPlans = "customer plans" |
| + cliPlatformCopyLabelDefault = "default plan" |
| + cliPlatformCopyLabelGrantedBy = "granted by" |
| + cliPlatformCopyLabelTurnedOffBy = "turned off by" |
| + cliPlatformCopyValueByOn = "%s on %s" |
| + cliPlatformCopyLabelReason = "reason" |
| + |
| + cliPlatformCopyGranted = "%s is now a platform account" |
| + cliPlatformCopyRevoked = "turned off platform access for %s. credentials that stopped working: %d" |
| +) |
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl| index 39e24f262..7b83423df 100644 |
| --- a/testdata/clireg-golden.jsonl |
| +++ b/testdata/clireg-golden.jsonl |
| @@ -24,6 +24,8 @@ |
| {"case":"accounts migrate | -h","argv":["accounts","migrate","-h"],"exit":0,"stdout":"","stderr":"usage: carlos accounts migrate [flags]\nflags:\n --app, -a <string> app to move\n --dry-run print the plan and touch nothing\n --from <string> source account sqid, or \"legacy\" for the pre-accounts keys (default: ops, then legacy)\n --registry <string> registry database (default: $DIR/data/registry.db)\n --to <string> destination account sqid\n"} |
| {"case":"accounts plan | --zz-unknown-flag","argv":["accounts","plan","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos accounts plan [flags]\nflags:\n --account <string> account sqid to show or change\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --pack <value> a pack and how many, as name=quantity. repeat it for more than one pack\n --reason <string> why the plan is changing. it is kept with the change\n --set <string> plan to put the account on. leave it out to show the current plan\n --sponsored <string> a JSON file of limits for a sponsored account. each one replaces the plan's where it is more generous\n","stderr":"accounts plan: flag provided but not defined: -zz-unknown-flag\n"} |
| {"case":"accounts plan | -h","argv":["accounts","plan","-h"],"exit":0,"stdout":"usage: carlos accounts plan [flags]\nflags:\n --account <string> account sqid to show or change\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --pack <value> a pack and how many, as name=quantity. repeat it for more than one pack\n --reason <string> why the plan is changing. it is kept with the change\n --set <string> plan to put the account on. leave it out to show the current plan\n --sponsored <string> a JSON file of limits for a sponsored account. each one replaces the plan's where it is more generous\n","stderr":""} |
| +{"case":"accounts platform | --zz-unknown-flag","argv":["accounts","platform","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos accounts platform [flags]\nflags:\n --account <string> platform account sqid to show or change\n --console <string> console origin to use\n --default-plan <string> the plan new customer accounts start on\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --grant make the account a platform account, or change its grant\n --max-customers <int> how many customer accounts it may have\n --plans <string> plans its customer accounts may be on, comma-separated\n --reason <string> why. it is kept with the change\n --revoke turn the account’s platform access off\n","stderr":"accounts platform: flag provided but not defined: -zz-unknown-flag\n"} |
| +{"case":"accounts platform | -h","argv":["accounts","platform","-h"],"exit":0,"stdout":"usage: carlos accounts platform [flags]\nflags:\n --account <string> platform account sqid to show or change\n --console <string> console origin to use\n --default-plan <string> the plan new customer accounts start on\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --grant make the account a platform account, or change its grant\n --max-customers <int> how many customer accounts it may have\n --plans <string> plans its customer accounts may be on, comma-separated\n --reason <string> why. it is kept with the change\n --revoke turn the account’s platform access off\n","stderr":""} |
| {"case":"accounts subdomain inventory | --zz-unknown-flag","argv":["accounts","subdomain","inventory","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos accounts subdomain inventory [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n","stderr":"accounts subdomain inventory: flag provided but not defined: -zz-unknown-flag\n"} |
| {"case":"accounts subdomain inventory | -h","argv":["accounts","subdomain","inventory","-h"],"exit":0,"stdout":"usage: carlos accounts subdomain inventory [flags]\nflags:\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n","stderr":""} |
| {"case":"accounts subdomain remove | --zz-unknown-flag","argv":["accounts","subdomain","remove","--zz-unknown-flag"],"exit":1,"stdout":"flag provided but not defined: -zz-unknown-flag\nusage: carlos accounts subdomain remove [flags]\nflags:\n --account <string> account sqid to change or show\n --console <string> console origin to use\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n","stderr":"accounts subdomain remove: flag provided but not defined: -zz-unknown-flag\n"} |
| @@ -38,12 +40,12 @@ |
| {"case":"accounts subdomain | bare","argv":["accounts","subdomain"],"exit":1,"stdout":"","stderr":"usage: carlos accounts subdomain <set|remove|show|inventory>\n\n set --account <sqid> <name> give the account a subdomain\n remove --account <sqid> take the account's subdomain away\n show --account <sqid> show the account's subdomain\n inventory list unused labels under the apps domain\n"} |
| {"case":"accounts subdomain | help","argv":["accounts","subdomain","help"],"exit":1,"stdout":"","stderr":"usage: carlos accounts subdomain <set|remove|show|inventory>\n\n set --account <sqid> <name> give the account a subdomain\n remove --account <sqid> take the account's subdomain away\n show --account <sqid> show the account's subdomain\n inventory list unused labels under the apps domain\n"} |
| {"case":"accounts subdomain | zz-unknown","argv":["accounts","subdomain","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos accounts subdomain <set|remove|show|inventory>\n\n set --account <sqid> <name> give the account a subdomain\n remove --account <sqid> take the account's subdomain away\n show --account <sqid> show the account's subdomain\n inventory list unused labels under the apps domain\n"} |
| -{"case":"accounts | --help","argv":["accounts","--help"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| -{"case":"accounts | --zz-unknown-flag","argv":["accounts","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| -{"case":"accounts | -h","argv":["accounts","-h"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| -{"case":"accounts | bare","argv":["accounts"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| -{"case":"accounts | help","argv":["accounts","help"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| -{"case":"accounts | zz-unknown","argv":["accounts","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | --help","argv":["accounts","--help"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | --zz-unknown-flag","argv":["accounts","--zz-unknown-flag"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | -h","argv":["accounts","-h"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | bare","argv":["accounts"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | help","argv":["accounts","help"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| +{"case":"accounts | zz-unknown","argv":["accounts","zz-unknown"],"exit":1,"stdout":"","stderr":"usage: carlos accounts <create|list|migrate|plan|platform|subdomain>\n\n create --name <name> mint an account: the next free id, its\n frozen sqid, and the bucket manifest every\n box materializes identity from\n [--owner <address>] who owns it. On a box or in CI — no browser,\n no login — this is the path: it needs no\n identity of its own and takes precedence\n over any logged-in one.\n [--console <url>] which logged-in console to mint through\n (only needed with several)\n list your accounts. Signed-in (the usual case):\n name, sqid and your role, from the console.\n On a box with a registry: sqid, name and\n app count from the registry itself.\n [--console <url>] list through a console even where a\n registry exists (or: which logged-in\n console, with several)\n migrate --app <a> --to <sqid> copy an app's objects to the account-\n qualified prefix and re-stamp its routes\n [--from <sqid>] source account (default: the legacy,\n account-less keys)\n [--dry-run] print the plan and touch nothing\n plan --account <sqid> show or change an account's plan (deployment operators)\n [--set <plan>] put the account on this plan. needs --reason\n [--pack <name=quantity>] add a pack. repeat it for more than one\n [--sponsored <file.json>] limits for a sponsored account, used where\n they are more generous than the plan's\n [--reason <text>] why the plan is changing\n [--console <url>] which logged-in console to use\n platform --account <sqid> show or change an account’s platform grant (deployment operators)\n [--grant] make the account a platform account, or change its grant\n [--max-customers <n>] how many customer accounts it may have\n [--plans <a,b>] plans its customer accounts may be on, comma-separated\n [--default-plan <plan>] the plan new customer accounts start on\n [--revoke] turn the account’s platform access off\n [--reason <text>] why. it is kept with the change\n [--console <url>] which logged-in console to use\n subdomain <set|remove|show|inventory>\n give an account a readable name in its app addresses\n\nplan only works where the console has a plan catalog (CARLOS_PLAN_CATALOG).\n\ncreate always names an owner, one way or the other: log this terminal in with\n\"carlos auth login\" and you become the owner, or pass --owner. It refuses\nrather than mint an account nobody can open in the console.\n\nmigrate never deletes a legacy object. Deleting them is a separate operator\nstep, behind the verification gate: every channel pointer must resolve from\nthe qualified keys with the fallback disabled, and one adopt pass must be a\nno-op, first.\n"} |
| {"case":"add | --zz-unknown-flag","argv":["add","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos add [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: ops)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --addr <string> TCP upstream host:port (whole-app tenants)\n --app, -a <string> app whose releases this route runs\n --backing <string> process backing: \"\" (agent exec child) | \"unit\" (carlos-app@<host> systemd unit)\n --channel, -c <string> release channel to follow (default: stable)\n --db <string> instance database path\n --hibernate hibernate when idle\n --kind <string> instance | service | static (default: instance)\n --registry <string> registry database (default: $DIR/data/registry.db)\n --slug <string> root-domain short name (optional)\n --socket <string> unix socket upstream\n --status-named opt this app into being named on the public status page\n --unit <string> systemd unit that owns this route's process when it is neither an exec child nor a carlos-app@ tenant (e.g. console.service)\n"} |
| {"case":"add | -h","argv":["add","-h"],"exit":0,"stdout":"","stderr":"usage: carlos add [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: ops)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --addr <string> TCP upstream host:port (whole-app tenants)\n --app, -a <string> app whose releases this route runs\n --backing <string> process backing: \"\" (agent exec child) | \"unit\" (carlos-app@<host> systemd unit)\n --channel, -c <string> release channel to follow (default: stable)\n --db <string> instance database path\n --hibernate hibernate when idle\n --kind <string> instance | service | static (default: instance)\n --registry <string> registry database (default: $DIR/data/registry.db)\n --slug <string> root-domain short name (optional)\n --socket <string> unix socket upstream\n --status-named opt this app into being named on the public status page\n --unit <string> systemd unit that owns this route's process when it is neither an exec child nor a carlos-app@ tenant (e.g. console.service)\n"} |
| {"case":"adopt | skipped","skipped":"opens root's release state and claims before reading its arguments, -h included"} |