carlos / platform Public

plan+spec: account subdomains rev 3, choice B after round 2

Paul chose B: the label under the apps domain is platform-owned, so a
new host there needs the label to be the creator's sqid or subdomain.
Folds in every Astra and Fable round-2 finding (remote registry, fleet
404s, HA eligibility, infra descendants, census tip, parity rows,
per-request namespace view, DNS status of derived rows).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 35394c39e4e0131069db3b146abedd1e5bb9a2c0 parent 1438d9a
3 files changed, +202 −100
  • docs/superpowers/plans/2026-11-11-account-subdomains.md +113 −60
  • docs/superpowers/plans/FABLE-RECOMMENDATION-account-subdomains-R2.md +22 −0
  • docs/superpowers/specs/2026-11-11-account-subdomains-design.md +67 −40

Intent

Human

What’s fable 5.2 recommendation?

Human

<task-notification> <task-id>bkc55l7gd</task-id> <tool-use-id>toolu_01RrphD9tmNKu1UUrP7hh5ZN</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/bkc55l7gd.output</output-file> <status>completed</status> <summary>Background command "Ask Fable 5.2 to recommend A, B or C" completed (exit code 0)</summary> </task-notification>

Human

Yes. Go

diff --git a/docs/superpowers/plans/2026-11-11-account-subdomains.md b/docs/superpowers/plans/2026-11-11-account-subdomains.md
index df7d02d27..98f422311 100644
--- a/docs/superpowers/plans/2026-11-11-account-subdomains.md
+++ b/docs/superpowers/plans/2026-11-11-account-subdomains.md
@@ -1,4 +1,4 @@
-# Account Subdomains Implementation Plan (rev 2)
+# Account Subdomains Implementation Plan (rev 3)
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
@@ -10,20 +10,27 @@ platform shows that URL as the app's URL.
`AccountNamespace: true`) is the only new record. Boxes derive alias rows
from it in `ReconcileAliasesReport` and publish held names to a small
registry table (part of the registry fingerprint) that the edge reads for
-wildcard parents. The console owns namespace enforcement: one ownership
-predicate used by every door that mints a host under the apps domain, an
-operator-only door with a re-read after writing, and `canonicalHost` on
-every display site.
+wildcard parents. The console owns namespace enforcement: the label
+directly under the apps domain is platform-owned, so one predicate at every
+host-creating door refuses a new host unless that label is the creator's
+sqid or held subdomain. An operator-only door assigns names (with a strict
+walk for pre-existing hosts and a re-read after writing), and display sites
+rewrite app URLs from one per-request namespace view.
**Tech Stack:** Go, SQLite registry, bucket (`release.Store`), console
templates.
**Spec:** `docs/superpowers/specs/2026-11-11-account-subdomains-design.md`
-rev 2 (approved 2026-11-11). Section numbers (§4.2 and so on) are the spec's.
+rev 3 (approved 2026-11-11; §4.2 is Paul's choice B after round 2). Section
+numbers (§4.2 and so on) are the spec's.
-**Review history:** Astra round 1 on a3261cd4, NOT READY (9 P1, 6 P2),
-findings in `CODEX-FINDINGS-account-subdomains-plan-R1.md`; resolutions at
-the end of this plan. This is round 2 of 3.
+**Review history:** round 1 (Astra, a3261cd4) NOT READY, 9 P1 / 6 P2:
+`CODEX-FINDINGS-account-subdomains-plan-R1.md`. Round 2 (Astra and Fable
+5.2, 29e9de4a) NOT READY: `CODEX-FINDINGS-account-subdomains-plan-R2.md`,
+`FABLE-FINDINGS-account-subdomains-plan-R2.md`. Astra called stopping rule 2
+on the namespace-ownership family; Paul chose option B
+(`FABLE-RECOMMENDATION-account-subdomains-R2.md` has Fable's reasoning).
+Resolutions for both rounds are at the end. This is round 3 of 3.
## Global Constraints
@@ -61,8 +68,12 @@ the end of this plan. This is round 2 of 3.
4. **Box without `PLATFORM_APPS_DOMAIN`.** The namespace pass derives
nothing and does not fail the alias pass. (Task 3 test.)
5. **Subdomain removed.** Console pages and API answers flip back to the
- sqid host on the next read: the door resets the claim cache, which has
- no TTL, so nothing else refreshes it. (Task 6 test.)
+ sqid host on the next read (the claim cache re-lists on every call; the
+ door also resets it). (Task 6 test.)
+6. **Self-hosted operator adds `blog.team.<apps>` where `team` is no
+ one's subdomain.** Refused with the approved reason naming the fix
+ (assign `team`); an existing `x.team.<apps>` claim keeps working and can
+ still be changed. (Task 5 test.)
---
@@ -83,8 +94,12 @@ the end of this plan. This is round 2 of 3.
again); set rolled back after the re-read (lists what it found);
remove refused while hand-attached names remain (lists them); not a
platform operator; host claims are on.
- - Attach refusal for a host under another account's subdomain (domain
- attach, first-route attach, instance create).
+ - Create refusal for a host under a label that is not the creator's
+ (domain attach, first-route attach, catch-alls, placements, instance
+ create, platform door): one string, naming the fix (assign the label).
+ - Inventory output (`carlos accounts subdomain inventory`): header, one
+ line per label with its account and hosts, empty state.
+ - Rollback failure: the name is still held, run `remove`.
- Console: account settings row label and its two states (read-only);
app/instance page label for the sqid URL ("permanent address" wording);
the canary success message (`server.go` ~:6597) if its wording changes.
@@ -102,9 +117,11 @@ the end of this plan. This is round 2 of 3.
- Modify: `internal/domains/claims.go` (Claim field, attach/detach)
- Create: `internal/domains/namespace.go`
- Test: `internal/domains/namespace_test.go`
-- Create: `internal/provision/account_subdomains_census_test.go` (a census
- overlay chained after `regional_domains_447_census_test.go`, adding each
- new writer ONCE; follow how that file re-pins and appends)
+- Create: `internal/provision/account_subdomains_census_test.go`: a write
+ census overlay appended to the CURRENT tip (today
+ `linkedDeploymentsSlice1WriteCensusInventory`, consumed at
+ `plan9_b8_census_test.go:369`), adding each new writer once, and the
+ test rewired to the new tip
- Modify: `internal/host/group_names_test.go` (name-producer inventory:
the `Claim` field list ~:259 and producer bodies ~:238)
- Create: `docs/superpowers/notes/census-proposal-account-subdomains.md`
@@ -114,9 +131,9 @@ the end of this plan. This is round 2 of 3.
- Produces:
- `Claim.AccountNamespace bool` with tag `json:"account_namespace,omitempty"`.
- `func NamespaceHost(name, appsDomain string) string` → `"*." + name + "." + appsDomain`.
- - `func ParseNamespaceKey(key, appsDomain string) (name string, ok bool)`
- (inverse of `ClaimKey(NamespaceHost(...))`; used to treat unread keys
- as held).
+ - `func ParseNamespaceHost(host, appsDomain string) (name string, ok bool)`
+ (inverse of `NamespaceHost`). Claim listings are keyed by host
+ (`claimcache.go:103`, `:138`), so every caller passes hosts.
- `func NormalizeSubdomain(raw string) (string, bool)` (trim, lowercase, shape).
- `type SubdomainRefusal string`, constants `SubdomainShape`,
`SubdomainSqidShaped`, `SubdomainReserved` (used here) and
@@ -136,10 +153,10 @@ the end of this plan. This is round 2 of 3.
- `TestAttachAccountNamespaceIsCreateOnly`: attach `harbour` by `bdq` then by `bcd` on `release.NewDirStore(t.TempDir())`: first `created=true`, second `created=false, err=nil`, `GetClaim` still `bdq`; body `Host "*.harbour.apps.test"`, `AccountNamespace true`, empty `App` and `Route`.
- `TestDetachAccountNamespaceNeedsEtagAndAccount`: wrong account → false; stale etag → false; right → true, claim gone.
- `TestAccountNamespacesSkipsPendingAndOtherKinds`: an instance catch-all and a pending namespace claim are in neither map.
- - `TestParseNamespaceKey`: round-trips `ClaimKey(NamespaceHost("harbour","apps.test"))`; an instance catch-all key on a two-label parent and an ordinary claim key → not ok.
-- [ ] **Step 2: Run** `go test ./internal/domains -run 'Subdomain|AccountNamespace|ParseNamespaceKey'` — FAIL (undefined).
+ - `TestParseNamespaceHost`: round-trips `NamespaceHost("harbour","apps.test")`; `*.team.bdq.apps.test` (instance catch-all two labels deep) and `shop.apps.test` → not ok.
+- [ ] **Step 2: Run** `go test ./internal/domains -run 'Subdomain|AccountNamespace|ParseNamespaceHost'` — FAIL (undefined).
- [ ] **Step 3: Implement.** Attach models `claimRawAttachInstanceCatchall` (`claims.go:448`): `getClaimETag`, then `s.Put(ctx, ClaimKey(host), body, "")`. Detach models `claimRawDetachClaimAt` (`claims.go:840`) with `release.DeleteIfMatch`. **Do not wrap in `release.WithAppMutation`**: the record is account-level, the host-claim mutation boundary refuses an empty app (`hostops/app_mutation_runner.go:58`, `mutation_classifier.go:118`), and the console door refuses while host claims are on (Task 6). Say so in a comment on the exported functions.
-- [ ] **Step 4: Censuses.** Run `go test ./internal/provision -run 'TestPlan9B8RecordWriteCensus|TestPlan14RootReadCensus'` and `go test ./internal/host -run 'TestGroupNameClassCensus|TestGroupNameProducerCensusScope'`. Add the two writers once in the new overlay, update the name-producer inventory for the new `Claim` field, and if the root-read census reports changed envelopes write the census proposal note. The reviewer for Task 2 rules on it (not Paul).
+- [ ] **Step 4: Censuses.** The guard tests are the authority on what to change; follow their failure output rather than this plan where they differ. Run `go test ./internal/provision -run 'TestPlan9B8RecordWriteCensus|TestPlan14RootReadCensus'` and `go test ./internal/host -run 'TestGroupNameClassCensus|TestGroupNameProducerCensusScope'`. Write census: the new overlay above. Name producers: update the inventory for the new `Claim` field and producer bodies. Root reads: follow the census tooling (`make census-propose` and the claims file it reads, per AGENTS.md's census section), which generates the overlay; an independent reviewer approves it (not Paul). Task 8 Step 1 re-runs all three after Tasks 3-7, since later tasks change in-scope source too.
- [ ] **Step 5: Run** Steps 2 and 4 — PASS.
- [ ] **Step 6: Commit** `domains: account namespace claim (subdomains T2)`.
@@ -148,12 +165,12 @@ the end of this plan. This is round 2 of 3.
**Files:**
- Modify: `internal/domains/aliases.go` (`AliasReport` input, `ReconcileAliasesReport`)
- Create: `internal/domains/namespacealiases.go`
-- Modify: `internal/registry/registry.go` (table `account_namespaces`, `Fingerprint` ~:3977)
+- Modify: `internal/registry/registry.go` (table `account_namespaces`, `Fingerprint` ~:3977), `internal/registry/remote.go` and `remote_dispatch.go` (remote branches, request/response fields, dispatch cases; add `ListAccountNamespaces` to the read-only worker's allow-list at `remote.go:298` if the edge reads through it)
- Modify: `internal/host/agent.go` (`aliasPassReportingComplete` ~:1480: set `AliasReport.AppsDomain` from the same source `domainsTickConfig` uses ~:3835)
- Test: `internal/domains/namespacealiases_test.go`, `internal/registry/registry_test.go`, `internal/edge/storedoor_test.go`
**Interfaces:**
-- Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceKey`.
+- Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceHost`.
- Produces:
- `AliasReport.AppsDomain string` (input).
- registry table `account_namespaces(name TEXT PRIMARY KEY, account TEXT NOT NULL)` following `wildcard_domains` (`registry.go:837-861`); `func (r *Registry) SetAccountNamespaces(m map[string]string) error` (replace whole set), `func (r *Registry) ListAccountNamespaces() (map[string]string, error)` (name → sqid). Its contents are part of `Registry.Fingerprint`, so a change reloads the edge.
@@ -162,27 +179,30 @@ the end of this plan. This is round 2 of 3.
Rules (§4.4):
1. After `deriveInstanceAliases` (~:782-789), before the removal sweep (~:790). Eligible route: `(rt.Provisioned || rt.Platform) && !rt.IsSidecar() && !rt.Replica && release.RouteAccount(rt) == sqid`, host ends `"." + sqid + "." + appsDomain`, non-empty prefix. Derived name: prefix + `"." + name + "." + appsDomain`.
2. Skip a derived name that has an exact claim key in `listed` (any holder), a local route, or a deployment route.
-3. HA: for each HA route in `rep.HAIngressRoutes` that is eligible, set `rep.AliasIngress[derived] = rt` unless taken (the checks in `deriveHAIngressAliases`'s `add`, `aliases.go:1045`).
+3. HA has its own eligibility, because `HAIngressRoutesFromRecords` entries carry neither `Provisioned` nor `Platform` (`provision/haingress.go:64`): for each key under `.<sqid>.<appsDomain>` with `rt.HA && rt.Host != "" && rt.Account == sqid`, set `rep.AliasIngress[derived] = rt` unless taken (the checks in `deriveHAIngressAliases`'s `add`, `aliases.go:1045`) or already in `rep.AliasIngress`. A zeroed entry (evidence refuses forwarding, `haingress.go:46`) keeps the derived name present but unavailable, as `aliases.go:1038-1041` does.
4. Cap: one budget of `maxInstanceAliases` shared with `deriveInstanceAliases` (change it to take and decrement `*int`); overflow logged once.
-5. Unread namespace bodies: a listed key that `ParseNamespaceKey` accepts but whose claim is not in `claims` (dropped/unread) keeps that name's existing alias rows (mark them desired) and its existing `account_namespaces` row; the pass returns incomplete.
-6. `SetAccountNamespaces` once per pass with `held` plus the kept unread rows.
+5. Unread namespace bodies: a listed host that `ParseNamespaceHost` accepts but whose claim is not in `claims` keeps that name's existing derived rows (only rows whose `Account` matches the kept table row and whose target is the sqid twin) and its existing `account_namespaces` row, and the pass returns incomplete. **Except** a `notFound` drop (the fleet store door answers 404 for another account's body, `storedoor.go:962-965`, `claimcache.go:139-142`) when this box holds no table row for that name: that is not a failure, keeps nothing and leaves the pass complete (as `relevantDropped`, `aliases.go:341-354`, does for other claims).
+6. `SetAccountNamespaces` once per pass with `held` plus the kept unread rows. Under `StartupNoRemoval` the table does not shrink, matching the alias rows it retains.
7. Empty `appsDomain`: derive nothing, write nothing, not incomplete.
+8. A derived row is written with its sqid twin's DNS status (the twin route's stamp if it carries one, otherwise `pointing`, since the apps wildcard answers both, spec §4.4), so the edges file publishes it on the first pass. Check this against `StampHealth` (`domains/reconcile.go:454`) and make the stamp pass keep it.
- [ ] **Step 1: Write failing tests.** Add a helper in the test file, `reconcileNS(t *testing.T, s release.Store, reg *registry.Registry, appsDomain string) *AliasReport`, that calls `ReconcileAliasesReport` with a report carrying `AppsDomain` (the existing `reconcile` helper passes no report). For read failures, wrap the store and fail the method the claim cache actually calls (`ListMod` when the store has it, then the per-key `Get`), not only `List`.
- `TestNamespaceDerivesEveryAccountRoute`: `shop.bdq.apps.test` (Provisioned), `site.bdq.apps.test` (Platform only), `team1.bdq.apps.test` (instance) → `shop/site/team1.harbour.apps.test` aliases to their sqid hosts.
- `TestNamespaceSkipsOtherAccountsSidecarsReplicas`.
- `TestNamespaceExactClaimAndRoutesWin`.
- `TestNamespaceNoRoutesThenFirstRoute` (Review Focus 1).
- - `TestNamespaceHAIngress` (Review Focus 2).
+ - `TestNamespaceHAIngress` (Review Focus 2), built through `HAIngressRoutesFromRecords`, not a hand-set fixture; plus a zeroed entry → name present, unavailable.
- `TestNamespaceWithoutAppsDomain` (Review Focus 4).
- `TestNamespaceRemovedDropsRows`: rows and table row gone.
- `TestNamespaceKeepsRowsWhenListingFails`.
- `TestNamespaceKeepsRowsWhenClaimBodyUnread`: listing has the key, `Get` fails → rows and table row kept, report incomplete.
+ - `TestForeignNamespaceOnFleetBoxIsComplete`: through the fleet store door, a foreign namespace key lists and its body 404s → nothing kept, pass complete.
+ - `TestDerivedRowPublishedAtOnce`: the derived row's DNS status equals the twin's, and the edges file includes it on the first pass.
- `TestNamespaceSharesInstanceCap`: instance aliases plus namespace aliases never exceed `maxInstanceAliases` (set via a test hook).
- `TestCanaryHostIsMirrored`: `c1.shop.bdq.apps.test` → `c1.shop.harbour.apps.test`.
- - registry: `TestAccountNamespacesRoundTrip`, `TestAccountNamespacesChangeFingerprint`.
+ - registry: `TestAccountNamespacesRoundTrip`, `TestAccountNamespacesChangeFingerprint`, `TestRemoteAccountNamespacesRoundTrip` (style of `TestRemoteRegistryRoundTrip`).
- storedoor: `TestStoreDoorReturnsOwnNamespaceClaim`: through the fleet store door, account `bdq`'s fleet reads `domains/*.harbour.<apps>.json` held by `bdq`; `bcd`'s fleet does not get its body.
-- [ ] **Step 2: Run** `go test ./internal/domains -run 'Namespace|CanaryHostIsMirrored'`, `go test ./internal/registry -run 'AccountNamespaces'`, `go test ./internal/edge -run 'StoreDoorReturnsOwnNamespaceClaim'` — FAIL.
+- [ ] **Step 2: Run** `go test ./internal/domains -run 'Namespace|CanaryHostIsMirrored|DerivedRowPublishedAtOnce'`, `go test ./internal/registry -run 'AccountNamespaces'`, `go test ./internal/edge -run 'StoreDoorReturnsOwnNamespaceClaim'` — FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** Step 2 plus `go test ./internal/domains -run 'InstanceCatchall|Alias'` — PASS.
- [ ] **Step 5: Commit** `domains: boxes derive account subdomain aliases (T3)`.
@@ -210,44 +230,50 @@ Rules (§4.4):
- [ ] **Step 4: Run** Step 2 plus `go test ./internal/edge -run 'Wildcard'` — PASS.
- [ ] **Step 5: Commit** `edge: wildcard certificate for account subdomains (T4)`.
-### Task 5: Console namespace enforcement
+### Task 5: Console namespace enforcement (choice B)
**Files:**
- Create: `internal/console/subdomains.go`
-- Modify: `internal/console/domainpolicy.go` (`appsNamespace`, `otherAccountsNamespace`, `domainProofExempt`, `firstRouteOutsideNamespace`), and every host-minting door found in Step 1
-- Test: `internal/console/subdomains_test.go`, `internal/console/domainproof_test.go`
+- Modify: `internal/console/domainpolicy.go` (`appsNamespace`, `otherAccountsNamespace`, `domainProofExempt`, `firstRouteOutsideNamespace`, `domainHostPolicy`: these take no context today and gain a `namespaceView` argument at every call site, about 11) and every door listed in Step 1
+- Modify: `internal/provision/recordhost.go` (a descendant form of `RecordHostDeclared`)
+- Test: `internal/console/subdomains_test.go`, `internal/console/domainproof_test.go`, `internal/provision/recordhost_test.go`
**Interfaces:**
-- Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceKey`, `SubdomainRuleRefusal`.
+- Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceHost`, `SubdomainRuleRefusal`.
- Produces:
- - `func (s *Server) namespaceOwner(ctx context.Context, label string) (owner string, held bool, err error)`: sqid label → the sqid; a held name → its account; a listed-but-unread namespace key → `held=true, owner=""`; read error → `err`. Reads `s.claims.ListWithUnread`.
- - `appsNamespace` / `otherAccountsNamespace` use it. `otherAccountsNamespace` returns true (refuse) when `err != nil`, when `held && owner == ""`, or when `held && owner != account`.
- - `func (s *Server) subdomainInfrastructure(name string) bool`: true when `<name>.<apps>` or `probe.<name>.<apps>` is denied by `reservedDomains` with only the synthetic apps-domain entry removed (not `denyEntries(…, true)`), or by `platformDomains(false)` (operator deny entries give `hostPlatform`).
- - `func (s *Server) subdomainRefusal(ctx context.Context, account, name string) (domains.SubdomainRefusal, []string)` covering every §4.2 rule: `SubdomainRuleRefusal`; `SubdomainHeld` (`AccountAnyBySqid(name)`, or another account's namespace claim); `SubdomainUnreadable`; `SubdomainInfrastructure`; `SubdomainOccupied` with the hosts of other accounts' claims and any deployment routes at or under `<name>.<apps>`; `SubdomainAccountHasOne`.
-
-- [ ] **Step 1: List the doors.** From the callers of `appsNamespace`, `otherAccountsNamespace`, `firstRouteOutsideNamespace` and `domainHostPolicy`, plus `handleAPIInstanceCreate` and the route-create doors, list every door that can put a host under the apps domain. Write the list into the commit body. Each must refuse a host under another account's subdomain.
+ - `type namespaceView struct` (name → sqid, sqid → name, unread names) and `func (s *Server) loadNamespaces(ctx context.Context) (namespaceView, error)`: one `s.claims.ListWithUnread` per request; an unread namespace host counts as held by an unknown account.
+ - `func (v namespaceView) labelOwner(label string) (owner string, known bool)`: a sqid label → itself; a held name → its account; unread → `("", false)`.
+ - `func (s *Server) createRefusal(v namespaceView, host, account string) bool`: for a NEW host two or more labels under the apps domain, true unless the label directly under the apps domain is `account`'s sqid or a name `account` holds. Also true for a one-label host `L.<apps>` whose claim would serve below it (Wildcard+Catchall, or an instance catch-all `*.L.<apps>`) unless `L` is the account's. Existing sqid-shaped-label rules (`firstRouteOutsideNamespace`) keep their behaviour. Changing or re-attaching a claim the account already holds is never refused.
+ - `func (s *Server) subdomainInfrastructure(name string) bool`: true when `<name>.<apps>` or anything at or below it is denied by `reservedDomains` with only the synthetic apps-domain entry removed, or by `platformDomains(false)`; or when any reserved/deny entry, console host (`consoleHosts`, exact) or demo-reserved host sits at or below `<name>.<apps>`.
+ - `func provision.RecordHostDeclaredUnder(ctx, s release.Store, suffix string) (hosts []string, err error)`: every declared instance record host equal to or under `suffix`, with its account; strict like `RecordHostDeclared` (any failed read is an error).
+ - `func (s *Server) subdomainRefusal(ctx context.Context, v namespaceView, account, name string) (domains.SubdomainRefusal, []string)`: every §4.2 rule. `SubdomainOccupied` lists other accounts' claims (from `ListWithUnread`, hosts at or under `<name>.<apps>`, including a one-label claim at `<name>.<apps>`) and other accounts' records (`RecordHostDeclaredUnder`). Any unread claim under the name or a strict-walk error → `SubdomainUnreadable`. No route fold: under choice B a foreign route can only come from a record or claim, which the walk sees.
+
+- [ ] **Step 1: List the doors** and wire `createRefusal` into each: domain attach (`domainattach.go:146`), the API attach (`apidomains.go:424`), placements (`apiplacements.go:480`), catch-alls (`domaincatchall.go:60`), first-route attach (`domainattach.go:208`), instance create (`apiinstances.go:1675`, checking the host's own label, not the manifest domain), the platform door, and any other caller of `domainHostPolicy` that creates. Write the list into the commit body.
- [ ] **Step 2: Write failing tests** (use `attachFixture` for store-backed cases, `platformFixture` for policy):
- `TestSubdomainRefusalRules`: one row per reason plus allowed `harbour`.
- - `TestSubdomainInfrastructure`: steering host label `edge` → true; `ReservePlatformDomains: true` alone → `harbour` false; a `DenyDomains` entry `harbour.oncarlos.com` → true; a `DenyDomains` entry naming the apps domain itself → true for every name (operator chose to deny it).
- - `TestOtherAccountsNamespaceCoversHeldName`: `bdq` holds `harbour`; attach of `x.harbour.oncarlos.com` by another account → `hostReserved`; by `bdq` → allowed and proof-exempt.
- - `TestUnreadNamespaceRefusesEveryone`: the key is listed, its body fails to read → attach under `marketx` refused for `bdq` and for others; assignment of `marketx` → `SubdomainUnreadable`.
+ - `TestSubdomainInfrastructure`: steering label `edge` → true; `ReservePlatformDomains: true` alone → `harbour` false; deny `harbour.oncarlos.com` → true; deny `admin.harbour.oncarlos.com` (below the name) → true; console host `console.oncarlos.com` with `ReservePlatformDomains` off → `console` true; deny naming the apps domain itself → true for every name.
+ - `TestCreateUnderUnassignedLabelRefused` (Review Focus 6): `blog.team.oncarlos.com` by `bdq` → refused; after `bdq` holds `team` → allowed; an existing claim `x.team.oncarlos.com` held by `bdq` can still be re-attached and changed while `team` is unassigned.
+ - `TestCreateUnderOtherAccountsNameRefused`: every door from Step 1, `x.harbour.oncarlos.com` by `bcd` while `bdq` holds `harbour` → refused, operator platform door included.
+ - `TestCatchallUnderUnassignedLabelRefused`: Wildcard+Catchall on `team.oncarlos.com`, and `*.team.oncarlos.com` instance catch-all, by `bdq` without `team` → refused.
+ - `TestInstanceCreateChecksHostLabel`: an app whose manifest domain is `team.oncarlos.com` (store-mode) cannot create `a.team.oncarlos.com` unless `team` is the account's.
+ - `TestUnreadNamespaceRefusesEveryone`: the namespace host is listed, its body fails → creates under `marketx` refused for `bdq` and others; assigning `marketx` → `SubdomainUnreadable`.
+ - `TestSubdomainOccupiedByUnmaterializedRecord`: `bcd` holds a record at `shop.harbour.oncarlos.com` with no claim and no route → assigning `harbour` to `bdq` → `SubdomainOccupied` listing it. A record walk failure → `SubdomainUnreadable`.
- `TestRemovedNameStopsProtecting`.
- - `TestFirstRouteUnderHeldName`.
- - `TestInstanceCreateUnderHeldName`: instance host under another account's name refused.
-- [ ] **Step 3: Run** `go test ./internal/console -run 'SubdomainRefusalRules|SubdomainInfrastructure|OtherAccountsNamespaceCoversHeldName|UnreadNamespaceRefusesEveryone|RemovedNameStopsProtecting|FirstRouteUnderHeldName|InstanceCreateUnderHeldName|AppsDomainNamespaces|DeletedAccountsNamespace|DomainHostPolicyMatrix'` — new ones FAIL.
+ - `provision`: `TestRecordHostDeclaredUnder` (finds descendants across accounts; strict on a failed listing).
+- [ ] **Step 3: Run** `go test ./internal/console -run 'SubdomainRefusalRules|SubdomainInfrastructure|CreateUnder|CatchallUnderUnassignedLabel|InstanceCreateChecksHostLabel|UnreadNamespaceRefusesEveryone|SubdomainOccupiedByUnmaterializedRecord|RemovedNameStopsProtecting|AppsDomainNamespaces|DeletedAccountsNamespace|DomainHostPolicyMatrix'` and `go test ./internal/provision -run 'RecordHostDeclared'` — new ones FAIL.
- [ ] **Step 4: Implement.**
- [ ] **Step 5: Run** Step 3 — all PASS.
-- [ ] **Step 6: Commit** `console: account subdomains are the account's namespace (T5)`.
+- [ ] **Step 6: Commit** `console: the label under the apps domain is platform-owned (T5)`.
### Task 6: Console door and canonical URLs
**Files:**
- Create: `internal/console/apisubdomain.go`, `internal/console/canonical.go`
-- Modify: `internal/console/routedecls.go` (three entries beside `POST /api/cli/accounts/{account}/plan` ~:982, `Kind: kindCLI, Allow: svcrole.Set{}`)
+- Modify: `internal/console/routedecls.go` (three subdomain entries beside `POST /api/cli/accounts/{account}/plan` ~:982 plus the system inventory door, all `Kind: kindCLI, Allow: svcrole.Set{}`)
- Modify route fixtures: `internal/console/testdata/claim-routes.txt`, `claim_invariant_fixtures_test.go`, `claim_invariant_probes_{read,nonapp}_test.go`, `svcroutes_test.go`
-- Modify display sites (each through `canonicalHost`): `server.go` ~:6860 (`appRow.URL`) and ~:6597 (canary success message), `ladder.go` :154/:252, `flow.go` :203, `instancepage.go` :293-314, `templates/app_instances.html` :85 and its handler, `app_instance.html`, `app_overview.html`, `apilinks.go` :126 (`linkPublicationURL`), `homelink.go` :152, `demo_claim_page.go` :179, `demo_claim_auth.go` :502, `demo_claim_status_page.go` :42, `templates/account_settings.html` (read-only Identity row)
+- Modify display sites (each through `canonicalHostIn`): `server.go` ~:6860 (`appRow.URL`) and ~:6597 (canary success message), `ladder.go` :154/:252, `flow.go` :203, `instancepage.go` :293-314, `templates/app_instances.html` :85 and its handler, `view.go` :809 (`CanaryView.Hosts`, rendered at `app_releases.html:165`), `app_instance.html`, `app_overview.html`, `apilinks.go` :126 (`linkPublicationURL`, which the serving console returns to linking consoles), `demo_claim_page.go` :179, `demo_claim_auth.go` :502, `demo_claim_status_page.go` :42, `templates/account_settings.html` (read-only Identity row). Not `homelink.go:152`: it runs on the linking console with no view of the serving deployment's claims; it keeps preferring the URL the serving console returns and its fallback stays as is.
- Modify API answers: add `PublicHost string json:"public_host,omitempty"` to `instanceListRecord` (`apiinstances.go` ~:181), `instanceGetRecord`, `apiRecordView` (~:1430) and the route answer at `apiroutes.go` ~:53. Not the create request at ~:1575.
-- Create: `internal/console/approved_account_subdomains_copy_test.go`
+- Create: `approved_account_subdomains_copy_test.go` at the repo root (package `main`, where `checkApprovedCopy` lives, `approved_copy_test.go:71`), covering CLI and console files
- Test: `internal/console/apisubdomain_test.go`, `internal/console/canonical_test.go`
**Interfaces:**
@@ -258,7 +284,10 @@ Rules (§4.4):
- GET: `{"name","host","foreign":[hosts of other accounts' claims or routes under the name]}`.
- DELETE: refuse with the list while the account holds exact claims or routes under the name; else detach.
- After every effective POST or DELETE: `s.claims.Reset()` and `s.bumpSerial(ctx)` (as `domaincatchall.go:163`). Refused and no-op requests do neither.
- - `func (s *Server) canonicalHost(ctx context.Context, host string) string` (§4.8; unchanged host on any error).
+ - `func canonicalHostIn(v namespaceView, appsDomain, host string) string` (pure; §4.8). Each handler loads the view once (`loadNamespaces`) and rewrites every row from it; a load error leaves hosts unchanged.
+ - POST when `AttachAccountNamespace` returns `created=false`: if the key holds this account's namespace claim, report it (idempotent); anything else at that key (an instance catch-all on `harbour.<apps>`) → `SubdomainOccupied`.
+ - If the rollback detach itself fails: 500 with a body saying the name is still held and to run `remove` (approved copy), and `show` reports it.
+ - `GET /api/cli/system/subdomain-inventory` (operator-only, same gate) listing every existing host two or more labels under the apps domain whose label is neither a sqid nor a held name, grouped by label with the holding account (claims via `ListWithUnread`, records via `RecordHostDeclaredUnder(appsDomain)`; strict).
- [ ] **Step 1: Write failing tests:**
- `TestSubdomainDoorOperatorOnly`: owner of `bdq` who is not an operator → 404; app token → refused; ops owner → 200; `SystemOperators` address → 200.
@@ -274,8 +303,10 @@ Rules (§4.4):
- `TestAppsPageLinksToName`, `TestInstanceListLinksToName`.
- `TestInstanceAnswersCarryPublicHost`: list, get and record view; `host` unchanged.
- `TestRemovedNameFlipsDisplayBack` (Review Focus 5).
- - `TestApprovedAccountSubdomainsCopy`.
-- [ ] **Step 2: Run** `go test ./internal/console -run 'SubdomainDoor|SubdomainShow|SubdomainRemove|SubdomainWritesBumpSerial|CanonicalHost|LinksToName|CarryPublicHost|FlipsDisplayBack|ApprovedAccountSubdomainsCopy|TestClaimConsoleMutationInvariant|TestEveryCLIDoorNamesItsRoles'` — FAIL.
+ - `TestSubdomainSetIdempotent`, `TestSubdomainSetRefusedOverCatchallKey`, `TestSubdomainRollbackFailureReportsHeld`.
+ - `TestSubdomainInventory`: legacy `x.team.oncarlos.com` by `bdq` listed under `team`; sqid labels and held names not listed; a failed walk → error, not an empty list.
+ - `TestCanaryLinksUseName`, `TestCanonicalPageLoadsNamespacesOnce` (one listing per request).
+- [ ] **Step 2: Run** `go test ./internal/console -run 'SubdomainDoor|SubdomainSet|SubdomainShow|SubdomainRemove|SubdomainRollback|SubdomainWritesBumpSerial|SubdomainInventory|CanonicalHost|CanonicalPage|LinksToName|LinksUseName|CarryPublicHost|FlipsDisplayBack|TestClaimConsoleMutationInvariant|TestEveryCLIDoorNamesItsRoles'` and `go test . -run 'TestApprovedAccountSubdomainsCopy'` — FAIL.
- [ ] **Step 3: Implement**, using approved copy IDs from Task 1.
- [ ] **Step 4: Run** Step 2 — PASS.
- [ ] **Step 5: Commit** `console: subdomain door; name URL is canonical (T6)`.
@@ -285,24 +316,24 @@ Rules (§4.4):
**Files:**
- Create: `accounts_subdomain.go`, `accounts_subdomain_test.go` (repo root)
- Modify: `accounts.go` :85-88: `subdomain` as a branch node with `set`, `remove`, `show` children (not a raw leaf), operator-scoped like `plan`
-- Modify: `testdata/clireg-golden.jsonl` (`go test . -run TestCLIGolden -record`), `parity/cli.tsv` plus its documentation, then `make parity-doc`
-- Modify: `apimode.go` ~:3387 (`apiInstanceRecord.PublicHost`), and display sites that print a host: `instances_cli.go` ~:751 (table), `deploywatch.go` :584-595 (printed lines only), `canary.go` :661, `deploy.go` :1752 if it prints. `watchOrigin` (`deploy.go:1684`) and `importVerifyTarget` (`instances_import.go:460`) stay probes on `host`.
+- Modify: `testdata/clireg-golden.jsonl` (`go test . -run TestCLIGolden -record`); `parity/parity.tsv` (rows for each runnable path: `accounts subdomain set|remove|show|inventory`, operator scope) and `docs/site/cli.md`; then `make parity-doc` (regenerates `parity/cli.tsv` and the rendered docs; it does not add table rows)
+- Modify: `apimode.go` ~:3387 (`apiInstanceRecord.PublicHost`), and display sites that print a host: `instances_cli.go` ~:751 (table), `deploywatch.go` :584-595 (printed lines only), `canary.go` :661, `deploy.go` :647 (single-instance deploy announcement) and :1752 if it prints. `watchOrigin` (`deploy.go:1684`) and `importVerifyTarget` (`instances_import.go:460`) stay probes on `host`.
**Interfaces:**
- Consumes: Task 6 doors and `public_host`.
-- Produces: `carlos accounts subdomain set --account <sqid> <name>`, `remove --account <sqid>`, `show --account <sqid>`, modelled on `accounts_plan.go` (`requirePlanAPISession`, `sess.getJSON`/`postJSON`/`deleteJSON`). `set` then polls one derived host with a TLS handshake every 5 s for up to 120 s and prints the approved success or still-issuing line (exit 0 either way). Watch targets carry `display` and `probe` hosts separately.
+- Produces: `carlos accounts subdomain set --account <sqid> <name>`, `remove --account <sqid>`, `show --account <sqid>`, `inventory` (calls the system inventory door), modelled on `accounts_plan.go` (`requirePlanAPISession`, `sess.getJSON`/`postJSON`/`deleteJSON`). `set` then polls one derived host with a TLS handshake every 5 s for up to 120 s and prints the approved success or still-issuing line (exit 0 either way). Watch targets carry `display` and `probe` hosts separately.
-- [ ] **Step 1: Write failing tests** with an `httptest` console: `TestAccountsSubdomainSet`, `TestAccountsSubdomainSetRefusalPrintsReason`, `TestAccountsSubdomainRemoveListsConflicts`, `TestAccountsSubdomainShowListsForeign`, `TestInstancesTablePrintsPublicHost`, `TestDeployWatchPrintsPublicHostProbesHost`.
-- [ ] **Step 2: Run** `go test . -run 'AccountsSubdomain|PrintsPublicHost|TestCLIGolden|TestCLIProjection'` — FAIL.
+- [ ] **Step 1: Write failing tests** with an `httptest` console: `TestAccountsSubdomainSet`, `TestAccountsSubdomainSetRefusalPrintsReason`, `TestAccountsSubdomainRemoveListsConflicts`, `TestAccountsSubdomainShowListsForeign`, `TestAccountsSubdomainInventory`, `TestInstancesTablePrintsPublicHost`, `TestDeployWatchPrintsPublicHostProbesHost`, `TestDeployAnnouncementPrintsPublicHost`.
+- [ ] **Step 2: Run** `go test . -run 'AccountsSubdomain|PrintsPublicHost|TestCLIGolden|TestCLIProjection'` and `go test ./internal/parity -run 'TestParityCLIPaths'` — FAIL.
- [ ] **Step 3: Implement**; record the golden file; update `parity/cli.tsv`; `make parity-doc`.
- [ ] **Step 4: Run** Step 2 — PASS. Then `GOOS=darwin go vet .` and `GOOS=windows go vet .` (cross-compile gate).
- [ ] **Step 5: Commit** `cli: carlos accounts subdomain (T7)`.
### Task 8: Review, merge, dev witness
-- [ ] **Step 1:** Whole-branch review by Astra and Fable (namespace trust boundary, census), round budget per AGENTS.md stopping rules.
+- [ ] **Step 1:** Re-run the census guards from Task 2 Step 4 against the final diff and settle any new proposals. Then the whole-branch review by Astra and Fable (namespace trust boundary, census), round budget per AGENTS.md stopping rules.
- [ ] **Step 2:** Push, CI green on amadan, squash merge with `-message` and `-expect`.
-- [ ] **Step 3:** Release and dev roll only with Paul's go. Witness on dev (§6): set a name on a test account; load an existing app and an instance through it; create a new app and load it through the name; confirm the `*.<name>` certificate; a second account's attach of `x.<name>…` refused; console and `carlos instances` show the name URL; remove; names stop serving and pages flip back.
+- [ ] **Step 3:** Before release, run `carlos accounts subdomain inventory` against dev and flagship and post the output on the branch discussion, so operators know which labels to assign. Release and dev roll only with Paul's go. Witness on dev (§6): set a name on a test account; load an existing app and an instance through it; create a new app and load it through the name; confirm the `*.<name>` certificate; a second account's attach of `x.<name>…` refused; console and `carlos instances` show the name URL; remove; names stop serving and pages flip back.
- [ ] **Step 4:** Record the witness on the branch discussion; update memory.
---
@@ -326,3 +357,25 @@ Rules (§4.4):
| 13 | P2 | Accepted: re-read after write rolls back a second name (T6). |
| 14 | P2 | Cut: settings page is read-only in this slice; set/remove via CLI (spec rev 2 §4.8). |
| 15 | P2 | Accepted: `bumpSerial` on effective writes; cache has no TTL, the door resets it (T6, Review Focus 5). |
+
+## Round 2 resolutions (Astra `CODEX-FINDINGS-…-R2.md`, Fable `FABLE-FINDINGS-…-R2.md`)
+
+| Finding | Resolution |
+|---------|-----------|
+| Astra 1 (P1, namespace family, rule 2) | Paul chose B: the label under the apps domain is platform-owned (spec rev 3 §4.2, T5 `createRefusal`). The assignment walk uses strict record and claim keys (`RecordHostDeclaredUnder`), so unmaterialized records are seen. |
+| Astra 2 / Fable P3-5 | `ParseNamespaceHost` takes hosts; both cache boundaries pass hosts (T2, T3, T5). |
+| Astra 3 / Fable P1-3 | HA has its own eligibility and a zeroed-entry rule; witness built through `HAIngressRoutesFromRecords` (T3 rule 3). |
+| Astra 4 / Fable P2-1 | `subdomainInfrastructure` covers descendants, console hosts and demo hosts (T5). |
+| Astra 5 | Census overlay appends to the current tip; root reads via the census tooling and an independent reviewer; re-run at T8 (T2 Step 4). The guard tests are the authority. |
+| Astra 6 | `parity/parity.tsv` rows, `docs/site/cli.md`, `TestParityCLIPaths` (T7). |
+| Astra 7 / Fable P3-1 | Canary links (`view.go:809`) and `deploy.go:647` added (T6, T7). |
+| Astra 8 / Fable P3-1 | `homelink.go:152` is not rewritten locally; the serving console's URL is canonical (T6). |
+| Astra 9 / Fable P3-2 | Review Focus 5 corrected. |
+| Fable P1-1 | Remote registry branches, dispatch, worker allow-list, remote round-trip test (T3). |
+| Fable P1-2 | `notFound` drops of foreign namespace keys keep nothing and leave the pass complete (T3 rule 5). |
+| Fable P2-2 | No route fold; strict record walk; `created=false` handled (T5, T6). |
+| Fable P2-3 | One `namespaceView` per request; pure `canonicalHostIn`; signatures change at every call site (T5, T6). |
+| Fable P2-4 | Derived rows carry the twin's DNS status and publish at once (T3 rule 8). |
+| Fable P2-5 | Approved-copy test at the repo root (T6). |
+| Fable P3-3, P3-4, P3-6 | Kept rows scoped; table does not shrink under `StartupNoRemoval`; rollback failure reported (T3, T6). |
+
diff --git a/docs/superpowers/plans/FABLE-RECOMMENDATION-account-subdomains-R2.md b/docs/superpowers/plans/FABLE-RECOMMENDATION-account-subdomains-R2.md
new file mode 100644
index 000000000..b01a2d1aa
--- /dev/null
+++ b/docs/superpowers/plans/FABLE-RECOMMENDATION-account-subdomains-R2.md
@@ -0,0 +1,22 @@
+**Recommendation: B**, with two additions: the instance-create door must check the host's label itself, not trust the manifest domain, and the release inventory must be a strict walk of record keys and claim keys.
+
+Each review round has found another evidence source the scan missed (routes, then unread claims, now records and pending operations), and A continues that enumeration. B replaces it with one rule at the doors, and `firstRouteOutsideNamespace` already applies that rule to sqid-shaped labels, so B widens an existing check rather than adding a gate.
+
+**Astra's finding 1 is real on self-hosted and operator-only on shared.**
+
+Shared platform (`ReservePlatformDomains` on):
+- The apps domain is in `reservedDomains` (`internal/console/apidomains.go:160`), so `domainHostPolicy` answers reserved (`domainpolicy.go:92`).
+- Every attach door asks that policy: `domainattach.go:146`, `apidomains.go:424`, `apiplacements.go:480`, `domaincatchall.go:60`.
+- Instance create only accepts one label plus the manifest domain (`apiinstances.go:1675`), and the console pins that domain to the account's own sqid (`apiinstances.go:3545`, `:3581`).
+- The one hole is an operator's store-mode manifest, which takes any `-domain` (`instances_cli.go:148-181`). Instance create never calls `domainHostPolicy`, so members of that app could then write records under `<name>.<apps-domain>` with no claim (`hostsused.go:728`).
+
+Self-hosted (`ReservePlatformDomains` off):
+- `otherAccountsNamespace` only guards labels that are a held sqid (`domainpolicy.go:186-203`), so `shop.harbour.<apps-domain>` is open to any member.
+- First-route attach refuses only sqid-shaped labels (`domainpolicy.go:219-229`, `domainattach.go:208`), then writes an instance record (`domainattach.go:269-282`).
+- That record can outlive its claim: the code comment at `domainattach.go:284-287` describes a record whose claim was released.
+- A record with no claim and no live route is invisible to a scan of claims and routes. That is Astra's scenario, and it needs no race.
+- The store-mode manifest door applies here too.
+
+I did not re-verify Astra's `fold.go:189` citation (routes exclude boxes without fresh snapshots), and I took the plan's scan scope from the two findings files rather than re-reading Task 5.
+
+**Main risk of B:** it is a behaviour change on self-hosted, which is the deployment the spec says this feature is for. Where the apps domain is the operator's general zone, a new hand-attached host two or more labels deep (`blog.team.<apps-domain>`) is refused unless `team` is an assigned subdomain. Store-mode writes also bypass every console door, so the "no door creates anything else" rule holds only for console doors; `show` should still report anything foreign it finds.
diff --git a/docs/superpowers/specs/2026-11-11-account-subdomains-design.md b/docs/superpowers/specs/2026-11-11-account-subdomains-design.md
index 7ac7fe60e..cf5f53f46 100644
--- a/docs/superpowers/specs/2026-11-11-account-subdomains-design.md
+++ b/docs/superpowers/specs/2026-11-11-account-subdomains-design.md
@@ -1,7 +1,7 @@
# Account subdomains: `<app>.<name>.<apps-domain>` beside `<app>.<sqid>.<apps-domain>`
**Date:** 2026-11-11
-**Status:** approved by Paul 2026-11-11 (with the canonical-URL change in §2 and §4.8), branch `design-account-name-hosts`. Rev 2 (same day): namespace enforcement moved from the boxes to the console after Astra's plan review round 1 (§4.2).
+**Status:** approved by Paul 2026-11-11 (with the canonical-URL change in §2 and §4.8), branch `design-account-name-hosts`. Rev 2: enforcement moved to the console (Astra plan review round 1). Rev 3: the label under the apps domain is platform-owned (Paul's choice B after round 2, §4.2).
Astra builder check done (`CODEX-FINDINGS-account-subdomains-builder-check.md`;
all five questions answered in this revision).
@@ -128,45 +128,65 @@ A name is one DNS label: the account-name shape in `slugname.go`
`hostReserved` for `<name>.<apps-domain>` or for a probe host under it
(covers the steering host, tunnel host, console hosts and demo hosts).
`CONSOLE_DENY_DOMAINS` entries covering it refuse it too (those give
- `hostPlatform`, not `hostReserved`, so the check reads both tiers). With
+ `hostPlatform`, not `hostReserved`, so the check reads both tiers), and
+ so does any reserved or deny entry, console host or demo host that
+ sits at or below `<name>.<apps-domain>`. With
`ReservePlatformDomains` on, `reservedDomains` lists the whole apps
domain, which would refuse every name. This door drops exactly that one
synthetic entry and keeps every other one, including an operator deny
entry that names the apps domain or an ancestor. (It cannot reuse
`denyEntries(…, true)`, which drops every covering entry.)
-5. **Something already lives there.** Any claim held by another account,
- or any route in the deployment, at `<name>.<apps-domain>` or under it.
+5. **Something already lives there.** Any claim or instance record held
+ by another account at `<name>.<apps-domain>` or under it (the walk
+ below), or a one-label claim at `<name>.<apps-domain>` held by
+ another account.
Same-account claims are fine (they become exact names inside the
account's own namespace, §4.4).
-**Where the namespace is enforced: the console, not the boxes.** Every
-console door that can put a host under the apps domain (domain attach,
-first-route attach, instance create, the operator's platform door) asks
-one predicate, "who owns the label under the apps domain?", and refuses a
-host under a name another account holds. Boxes do not judge ownership.
-(Rev 2: the first draft enforced it on the boxes. Astra's plan review
-showed that boxes on a customer fleet cannot read other accounts' claims,
-that an incomplete claim read would drop the protection, and that direct
-routes and retained rows bypass the alias pass. Console enforcement has
-none of those gaps.)
-
-- **Reads that fail refuse.** The predicate reads claims with
- `ListWithUnread`. A claim key `domains/*.<label>.<apps-domain>.json`
- whose body could not be read counts as held by an unknown account:
- attaches under that label are refused for everyone, and assigning that
- name is refused, until the read succeeds.
-- **The race.** Rule 5 is checked before the namespace claim is written,
- and a foreign attach of `x.<name>...` is a different bucket key, so both
- can pass their checks at once. The assignment door therefore re-reads
- after its write: if a foreign claim or route now sits under the name, or
- the account now holds two names, it deletes its own claim and refuses
- (listing what it found). What remains is an ordinary attach whose write
- lands after that re-read, a window of one request's duration. On a
- shared platform it cannot happen at all, because with
- `ReservePlatformDomains` on no tenant can attach anything under the apps
- domain. On a self-hosted deployment it is a race between the operator
- and their own tenant, and it is visible: `show` lists any foreign name
- under the subdomain, and the operator detaches it.
+**Where the namespace is enforced: the label under the apps domain is
+platform-owned (rev 3, Paul's choice B, 2026-11-11).** For any host two or
+more labels under the apps domain, the label directly under it (`bdq` in
+`shop.bdq.<apps>`, `harbour` in `shop.harbour.<apps>`) must belong to the
+account creating the host: its own sqid, or a subdomain it holds. Nothing
+else can be created there, by any console door, operators' platform door
+included. The same holds for a claim on a one-label host `L.<apps>` that
+would serve names below it (Wildcard+Catchall, or an instance catch-all on
+`*.L.<apps>`).
+
+- **One predicate, every door.** Domain attach, first-route attach,
+ regional placements, catch-alls, the platform door and instance create
+ all ask it. Instance create checks the host's own label, not the app's
+ manifest domain.
+- **Only new hosts.** The rule refuses creating a claim, record or route.
+ Changing or re-attaching something an account already holds is
+ unaffected, so existing hosts under unassigned labels keep working.
+- **Reads that fail refuse.** A namespace claim that is listed but cannot
+ be read counts as held by an unknown account: creating under that label
+ is refused for everyone, and assigning that name is refused, until the
+ read succeeds.
+- **What existed before.** At assignment, the door walks the claim keys
+ and instance record keys under `<name>.<apps>` and refuses if any
+ belongs to another account, or if any read fails. That is the only
+ scan, and after release it can only find hosts made before the rule
+ (or by direct bucket writes, below). A release inventory lists every
+ existing host under an unassigned non-sqid label, with the account that
+ holds it, so an operator can assign that label to that account and keep
+ adding hosts under it.
+- **The race.** Assignment and a create under the same label can both
+ pass their checks at once. The assignment door re-reads after its write
+ and rolls back if anything foreign appeared or the account now holds two
+ names. Because a create needs the label to be the account's already,
+ the only create that can race an assignment is the owner's own.
+- **Direct bucket writes** (an operator's store-mode CLI) skip the console
+ and every rule in it. `show` reports any foreign host it finds under the
+ name.
+
+History: rev 1 enforced ownership on the boxes, which leaked (fleet boxes
+cannot read other accounts' claims; failed reads; direct routes). Rev 2
+enforced it at assignment with a scan, and each review found another
+source the scan missed (instance records whose claim was released,
+pending operations). Rev 3 makes foreign hosts under a name impossible to
+create instead of trying to find them.
The console suggests the account's name when it fits these rules. The
subdomain is a separate value from the account name, because account names
@@ -221,9 +241,14 @@ The precedence rules are the instance catch-all's:
- An exact claim on the derived name wins. That lets the account attach
`blog.harbour...` to a different app if it wants.
- A real route on this box, or one any live box publishes, wins.
-- A listing failure, or an unread namespace claim body, keeps the
- existing derived rows and held-name table for that pass instead of
- dropping them.
+- A listing failure, or a namespace claim body that failed to read,
+ keeps the existing derived rows and held-name table for that pass
+ instead of dropping them. A body the store door refuses because it
+ belongs to another account (a fleet box seeing a foreign namespace key)
+ is not a failure and keeps nothing.
+- A derived row starts with its sqid twin's DNS status, since the apps
+ wildcard answers both (§4.7). The edges file then publishes it at once,
+ so the canonical URL works on every edge as soon as the app's does.
A box on a customer fleet reads its own account's claims through the
store door, so it sees its own namespace claim and needs nothing else.
@@ -338,9 +363,9 @@ unprotected.
- **A member tries to take a name:** no door. Only the operator door
writes namespace claims.
-- **Another account attaches `x.harbour...`:** refused by §4.5. If it
- races the assignment, the assignment rolls back, or (a write landing
- after the re-read) it is listed by `show` for the operator (§4.2).
+- **Another account attaches `x.harbour...`:** refused by §4.2: the label
+ is not theirs. No race is possible, because creating under a label
+ needs the label to be the creator's already.
- **A claim body fails to read:** its label counts as held; attaches
under it are refused until the read succeeds (§4.2).
- **An app token sets a subdomain:** refused; the door needs a person.
@@ -383,8 +408,10 @@ it ships in; there is no switch (§4.3).
shared platforms included, is Paul's decision (§3).
- Remove frees the name at once; no tombstone. It refuses while the
account still has hand-attached names under it (§4.3).
-- The namespace is enforced in the console doors, with a re-read after
- assignment; the residual race is stated and visible (§4.2, rev 2).
+- The label under the apps domain is platform-owned: only its sqid owner
+ or subdomain holder can create hosts under it (§4.2, rev 3, Paul's
+ choice B). New hosts under unassigned non-sqid labels are refused on
+ every deployment; existing ones keep working.
- Console controls for set/remove wait; the CLI does it in this slice
(§4.8).
- Names get the sqid's DNS and certificate behaviour exactly, including