carlos / platform Public

platform accounts: platforms create and run customer accounts (slice 1)

An operator grants an account platform status (carlos accounts platform).
Its platform credential creates ownerless customer accounts linked to it,
lists and updates them, and mints short-lived per-customer credentials
(one account, at most 24 h, checked against the grant generation on every
request). A Publish service credential can now give a static app its
first host, so carlos deploy --kind static works from CI. Linked accounts
skip billing and the free-account cap; plan notices go to the platform's
owners. Dormant until an operator grants an account.

Spec docs/superpowers/specs/2026-11-19-platform-accounts-design.md
(approved by Paul 2026-11-19); plan
docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md.
Built task by task (Opus), reviewed by Astra and Fable; copy by Luna
with Paul's four rulings; census approved by Astra (#280). Customer
delete, claim and leave are slice 2; the Customers page is slice 3
(#1289).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Prompts:

  <task-notification>
  <task-id>ae030a425373d7a37</task-id>
  <tool-use-id>toolu_01Rc6h5Amr4vpqWNdaCg5nNU</tool-use-id>
  <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/9284fe97-c7c7-4e03-80f2-87c51eb0406d/tasks/ae030a425373d7a37.output</output-file>
  <status>completed</status>
  <summary>Agent "Map accounts, creds, billing" finished</summary>
  <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note>
  <result>I've mapped all seven areas. The short answer: there are no managed accounts today. Every place an account is created, every invite, the billing setup and every credential assumes one human owner per account. No credential except a person's own login token can act in more than one account.
  
  Note: the sandbox kept failing because git worktrees were being created and removed while I searched, so I ran the remaining read-only `grep`/`sed` commands outside it.
  
  ## 1. Accounts
  
  **Schema.** The `accounts` table has `id` (an integer it is given, never autoincrement), `sqid` (unique), `name` (not unique) and `created_at` (`internal/console/store.go:216`). Later additions are `deleted_at` (`store.go:566`) and `tier` (`store.go:582`). There is no column for kind, platform, parent or payer.
  
  **How an id is made.** `domains.MintAccount` (`internal/domains/mint.go:219`) takes the highest id in any bucket manifest plus one, then claims it with a create-only write of `accounts/&lt;sqid&gt;/account.json` (`mint.go:92`). The manifest holds `{id, sqid, name, created_at, owner?, deleted_at?}` (`mint.go:26`). The sqid is `id + 23²` written in base 23 over the frozen alphabet `abcdefghjkmnpqrstuvwxyz` (`internal/domains/sqid.go:15,32`). Id 1 is the ops account (`mint.go:97`).
  
  **Every path that creates an account:**
  - **Signing in with no account:** `currentAccount` mints a personal account named after the person's address (`server.go:3169`).
  - **Browser "New account":** `POST /accounts/new` → `handleNewAccount` (`server.go:3392`). Session only, with the free-account cap.
  - **CLI while logged in:** `POST /auth/cli/accounts` → `handleCLINewAccount` (`authcli.go:2061`). It authenticates through `cliUser`, which only accepts a person, so a service credential gets a 401.
  - **Demo claim:** `demo_claim_target.go:78`.
  - All three console paths go through `mintAccount` (`server.go:3223`) → `Store.CreateAccount` (`store.go:1177`). That writes the account row, the owner membership and the sponsorship row in one transaction. `ownerAddress` is used only for that first owner membership, the last-account record and the audit line.
  - **CLI with `--owner` and no console** (`accounts.go:158`): writes the manifest straight to the bucket with `owner`, then a registry row. MintAccount accepts an empty owner and treats it as "ownerless" (`mint.go:212-223`), but the CLI refuses to run without an owner (`accounts.go:128`).
  - **Copying from the bucket:** `MaterializeAccounts` (`materialize.go:41`) runs on console start (`server.go:2254`) and on every `console member` command (`cmd/console/member.go:106`). It calls `EnsureAccount` (`store.go:1222`), which deliberately creates no membership. The manifest's owner is applied only the first time an account is seen (`materialize.go:175,186`; `AdoptManifestOwner` `store.go:1279`).
  
  **Can an account have zero owners?** Yes, in the data. `EnsureAccount` creates one on purpose, and an older manifest with no owner stays ownerless (`store.go:1202-1207`). But the code treats this as broken, not as a state to keep:
  - The comments call it "unadministrable" (`store.go:1174`).
  - With no membership there is no access at all; the `/a/{sqid}` gate resolves only through the viewer's memberships (`server.go:3290`).
  - `lastOwnerGuard` (`store.go:1582`) stops an account that has owners from ever dropping to zero.
  
  **Deletion.** Owners delete from the browser: `POST /a/{sqid}/delete` → `Store.DeleteAccount` (`ownership.go:819`). It refuses while ...

  … and 15 more, on the branch's Prompts tab.

Squashed from design-platform-accounts into main.
claude agent, operated by paul@keymail.dev 3f3ef7b0c6933ab72c5639efaa369f310a7fcb35 parent f359ec1
99 files changed, +15,635 −283
  • .amadan/code-health.tsv +3 −8
  • AGENTS.md +13 −0
  • accounts.go +19 −3
  • accounts_plan.go +2 −0
  • accounts_plan_copy.go +2 −0
  • accounts_plan_test.go +20 −0
  • accounts_platform.go +234 −0
  • accounts_platform_test.go +205 −0
  • approved_platform_accounts_copy_test.go +195 −0
  • commands.go +1 −0
  • commands_test.go +3 −0
  • deploy.go +27 −8
  • deploy_platformhost.go +46 −0
  • deploy_test.go +88 −0
  • docs/parity.md +19 −3
  • docs/site/cli.md +86 −0
  • docs/superpowers/notes/CENSUS-REVIEW-BRIEF-design-platform-accounts.md +9 −0
  • docs/superpowers/notes/CENSUS-REVIEW-RESULT-design-platform-accounts.md +25 −0
  • docs/superpowers/notes/census-proposal-design-platform-accounts.md +11 −0
  • docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md +1,460 −0
  • docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r1.md +23 −0
  • docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r2.md +23 −0
  • docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md +21 −0
  • docs/superpowers/plans/ASTRA-REVIEW-BRIEF-platform-accounts-1.md +15 −0
  • docs/superpowers/plans/LUNA-COPY-BRIEF-PLATFORM-ACCOUNTS-1.md +22 −0
  • docs/superpowers/plans/LUNA-COPY-RESULT-PLATFORM-ACCOUNTS-1.md +149 −0
  • docs/superpowers/specs/2026-11-19-platform-accounts-design.md +417 −0
  • internal/console/accountplans.go +3 −0
  • internal/console/apibackups_test.go +6 −1
  • internal/console/apicli.go +11 −1
  • internal/console/apiinstances.go +11 −1
  • internal/console/apiplatformcredentials.go +169 −0
  • internal/console/apiplatformcustomers.go +977 −0
  • internal/console/apiplatformcustomers_test.go +1,832 −0
  • internal/console/apiplatformgrant.go +269 −0
  • internal/console/apiplatformgrant_test.go +424 −0
  • internal/console/apiplatformhost.go +169 −0
  • internal/console/apiplatformhost_test.go +397 −0
  • internal/console/apiruns_key_test.go +7 −1
  • internal/console/apiruns_service_test.go +7 −1
  • internal/console/apiservices.go +27 −7
  • internal/console/applocks.go +45 −5
  • internal/console/authstore.go +33 −10
  • internal/console/billinghold.go +42 −4
  • internal/console/billingpage_copy.go +5 −0
  • internal/console/claim_app_identity.go +3 −1
  • internal/console/claim_invariant_fixtures_test.go +34 −0
  • internal/console/claim_invariant_probes_nonapp_test.go +100 −0
  • internal/console/claim_invariant_probes_read_test.go +6 −0
  • internal/console/claim_invariant_test.go +4 −1
  • internal/console/domainbuy.go +25 −0
  • internal/console/domainbuy_copy.go +2 −0
  • internal/console/hapool.go +4 −1
  • internal/console/lifetimes_create_test.go +34 −8
  • internal/console/lifetimes_migrate_test.go +1 −1
  • internal/console/linkedpolicy.go +1 −0
  • internal/console/links_auth_test.go +11 −1
  • internal/console/materialize.go +34 −6
  • internal/console/materialize_test.go +228 −0
  • internal/console/ownership.go +84 −3
  • internal/console/plancaps.go +11 −2
  • internal/console/plancaps_copy.go +10 −0
  • internal/console/planexempt.go +5 −0
  • internal/console/plangracepass.go +17 −13
  • internal/console/planlapse.go +25 −15
  • internal/console/platform_copy.go +71 −0
  • internal/console/platform_credentials.go +318 −0
  • internal/console/platform_credentials_test.go +1,277 −0
  • internal/console/platform_seams.go +53 −0
  • internal/console/platform_store.go +749 −0
  • internal/console/platform_store_test.go +888 −0
  • internal/console/platformlinked.go +108 −0
  • internal/console/platformlinked_test.go +1,039 −0
  • internal/console/routedecls.go +46 −3
  • internal/console/server.go +1 −0
  • internal/console/store.go +105 −85
  • internal/console/store_gate.go +35 −2
  • internal/console/submissiongate.go +4 −0
  • internal/console/svcpage.go +5 −0
  • internal/console/svcprincipal.go +135 −36
  • internal/console/svcroutes_test.go +16 −3
  • internal/console/testdata/claim-routes.txt +9 −0
  • internal/domains/mint.go +176 −18
  • internal/domains/mint_test.go +278 −0
  • internal/provision/plan9_b8_census_test.go +1 −1
  • internal/provision/platform_accounts_1_census_test.go +95 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-design-platform-accounts.tsv +5 −0
  • internal/svcrole/svcrole.go +23 −8
  • internal/svcrole/svcrole_test.go +62 −4
  • main.go +1 −0
  • parity/cli.tsv +6 −0
  • parity/packages.tsv +1 −0
  • parity/parity.tsv +3 −0
  • platform_cli.go +731 −0
  • platform_cli_test.go +590 −0
  • platform_copy.go +132 −0
  • platform_e2e_test.go +412 −0
  • testdata/clireg-golden.jsonl +48 −18

CI passed — run details

landed from design-platform-accounts

.amadan/code-health.tsv

Loading diff…

AGENTS.md

Loading diff…

accounts.go

Loading diff…

accounts_plan.go

Loading diff…

accounts_plan_copy.go

Loading diff…

accounts_plan_test.go

Loading diff…

accounts_platform.go

Loading diff…

accounts_platform_test.go

Loading diff…

approved_platform_accounts_copy_test.go

Loading diff…

commands.go

Loading diff…

commands_test.go

Loading diff…

deploy.go

Loading diff…

deploy_platformhost.go

Loading diff…

deploy_test.go

Loading diff…

docs/parity.md

Loading diff…

docs/site/cli.md

Loading diff…

docs/superpowers/notes/CENSUS-REVIEW-BRIEF-design-platform-accounts.md

Loading diff…

docs/superpowers/notes/CENSUS-REVIEW-RESULT-design-platform-accounts.md

Loading diff…

docs/superpowers/notes/census-proposal-design-platform-accounts.md

Loading diff…

docs/superpowers/plans/2026-11-19-platform-accounts-1-platform-layer.md

Loading diff…

docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r1.md

Loading diff…

docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r2.md

Loading diff…

docs/superpowers/plans/ASTRA-FINDINGS-platform-accounts-1-r3.md

Loading diff…

docs/superpowers/plans/ASTRA-REVIEW-BRIEF-platform-accounts-1.md

Loading diff…

docs/superpowers/plans/LUNA-COPY-BRIEF-PLATFORM-ACCOUNTS-1.md

Loading diff…

docs/superpowers/plans/LUNA-COPY-RESULT-PLATFORM-ACCOUNTS-1.md

Loading diff…

docs/superpowers/specs/2026-11-19-platform-accounts-design.md

Loading diff…

internal/console/accountplans.go

Loading diff…

internal/console/apibackups_test.go

Loading diff…

internal/console/apicli.go

Loading diff…

internal/console/apiinstances.go

Loading diff…

internal/console/apiplatformcredentials.go

Loading diff…

internal/console/apiplatformcustomers.go

Loading diff…

internal/console/apiplatformcustomers_test.go

Loading diff…

internal/console/apiplatformgrant.go

Loading diff…

internal/console/apiplatformgrant_test.go

Loading diff…

internal/console/apiplatformhost.go

Loading diff…

internal/console/apiplatformhost_test.go

Loading diff…

internal/console/apiruns_key_test.go

Loading diff…

internal/console/apiruns_service_test.go

Loading diff…

internal/console/apiservices.go

Loading diff…

internal/console/applocks.go

Loading diff…

internal/console/authstore.go

Loading diff…

internal/console/billinghold.go

Loading diff…

internal/console/billingpage_copy.go

Loading diff…

internal/console/claim_app_identity.go

Loading diff…

internal/console/claim_invariant_fixtures_test.go

Loading diff…

internal/console/claim_invariant_probes_nonapp_test.go

Loading diff…

internal/console/claim_invariant_probes_read_test.go

Loading diff…

internal/console/claim_invariant_test.go

Loading diff…

internal/console/domainbuy.go

Loading diff…

internal/console/domainbuy_copy.go

Loading diff…

internal/console/hapool.go

Loading diff…

internal/console/lifetimes_create_test.go

Loading diff…

internal/console/lifetimes_migrate_test.go

Loading diff…

internal/console/linkedpolicy.go

Loading diff…

internal/console/links_auth_test.go

Loading diff…

internal/console/materialize.go

Loading diff…

internal/console/materialize_test.go

Loading diff…

internal/console/ownership.go

Loading diff…

internal/console/plancaps.go

Loading diff…

internal/console/plancaps_copy.go

Loading diff…

internal/console/planexempt.go

Loading diff…

internal/console/plangracepass.go

Loading diff…

internal/console/planlapse.go

Loading diff…

internal/console/platform_copy.go

Loading diff…

internal/console/platform_credentials.go

Loading diff…

internal/console/platform_credentials_test.go

Loading diff…

internal/console/platform_seams.go

Loading diff…

internal/console/platform_store.go

Loading diff…

internal/console/platform_store_test.go

Loading diff…

internal/console/platformlinked.go

Loading diff…

internal/console/platformlinked_test.go

Loading diff…

internal/console/routedecls.go

Loading diff…

internal/console/server.go

Loading diff…

internal/console/store.go

Loading diff…

internal/console/store_gate.go

Loading diff…

internal/console/submissiongate.go

Loading diff…

internal/console/svcpage.go

Loading diff…

internal/console/svcprincipal.go

Loading diff…

internal/console/svcroutes_test.go

Loading diff…

internal/console/testdata/claim-routes.txt

Loading diff…

internal/domains/mint.go

Loading diff…

internal/domains/mint_test.go

Loading diff…

internal/provision/plan9_b8_census_test.go

Loading diff…

internal/provision/platform_accounts_1_census_test.go

Loading diff…

internal/provision/testdata/plan14-root-reads-chain.tsv

Loading diff…

internal/provision/testdata/plan14-root-reads-design-platform-accounts.tsv

Loading diff…

internal/svcrole/svcrole.go

Loading diff…

internal/svcrole/svcrole_test.go

Loading diff…

main.go

Loading diff…

parity/cli.tsv

Loading diff…

parity/packages.tsv

Loading diff…

parity/parity.tsv

Loading diff…

platform_cli.go

Loading diff…

platform_cli_test.go

Loading diff…

platform_copy.go

Loading diff…

platform_e2e_test.go

Loading diff…

testdata/clireg-golden.jsonl

Loading diff…