plan: account subdomains, apply round-3 fixes (Paul approved)
Pending allocations join one strict occupancy walk; catch-all expansion is a create; StampHealth keeps derived rows published; notFound namespace bodies always drop; routes CLI, homelink fallback, DeclaredHost ownership, inventory ordering and copy-test placement.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+65
−26
docs/superpowers/plans/2026-11-11-account-subdomains.md+65 −26
CI passed — run details
diff --git a/docs/superpowers/plans/2026-11-11-account-subdomains.md b/docs/superpowers/plans/2026-11-11-account-subdomains.md| index 98f422311..9e2a89a9b 100644 |
| --- a/docs/superpowers/plans/2026-11-11-account-subdomains.md |
| +++ b/docs/superpowers/plans/2026-11-11-account-subdomains.md |
| @@ -30,7 +30,9 @@ numbers (§4.2 and so on) are the spec's. |
| `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. |
| +Round 3 (Astra and Fable, 35394c39): Astra NOT READY (2 P1), Fable READY AFTER |
| +FIXES; Paul approved applying every round-3 fix without a fourth round |
| +(2026-11-11). Resolutions for all rounds are at the end. |
| ## Global Constraints |
| @@ -167,7 +169,8 @@ Resolutions for both rounds are at the end. This is round 3 of 3. |
| - Create: `internal/domains/namespacealiases.go` |
| - 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` |
| +- Modify: `internal/domains/reconcile.go` (`StampHealth`, rule 8) |
| +- Test: `internal/domains/namespacealiases_test.go`, `internal/registry/registry_test.go`, `internal/edge/storedoor_test.go`, `internal/host/edgesfile_test.go` |
| **Interfaces:** |
| - Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceHost`. |
| @@ -179,12 +182,12 @@ Resolutions for both rounds are at the end. This is round 3 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 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. |
| +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 an exact claim on the derived name is in `listed` (rule 2), it is taken (the checks in `deriveHAIngressAliases`'s `add`, `aliases.go:1045`), or it is 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 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). |
| +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 only as a decision (missing, foreign or pending body, `storedoor.go:943-964`; store errors are separate), so a `notFound` namespace body always drops that name's derived rows and table row and leaves the pass complete (as `relevantDropped`, `aliases.go:341-354`, does for other claims). This also clears a name reassigned away from this box's account. |
| 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. |
| +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. `UpsertAlias` never rewrites `dns_status` after insert (`registry.go:3609-3611`) and `StampHealth` stamps an authoritative not-found as `""` (`reconcile.go:536-543`), which would unpublish derived rows while `_acme-challenge.<name>` exists (spec §4.7). So `StampHealth` skips alias rows whose label under the apps domain is in `ListAccountNamespaces`; they keep the twin's status, the same as the sqid host they mirror. |
| - [ ] **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. |
| @@ -196,13 +199,14 @@ Rules (§4.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. |
| + - `TestForeignNamespaceOnFleetBoxIsComplete`: with a store wrapper whose `Get` answers not-found for the namespace body while the listing has it → nothing kept, pass complete; and the reassignment case (this box holds a table row for the name) → rows and table row dropped, pass complete. |
| + - `TestDerivedRowStatusSurvivesStamp`: the derived row starts with the twin's DNS status, and a second pass with a not-found resolver leaves it unchanged. |
| + - In `internal/host`: `TestEdgesFilePublishesDerivedRowAtOnce` (the edges file writer lives there). |
| - `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`, `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|DerivedRowPublishedAtOnce'`, `go test ./internal/registry -run 'AccountNamespaces'`, `go test ./internal/edge -run 'StoreDoorReturnsOwnNamespaceClaim'` — FAIL. |
| +- [ ] **Step 2: Run** `go test ./internal/domains -run 'Namespace|CanaryHostIsMirrored|DerivedRowStatusSurvivesStamp'`, `go test ./internal/registry -run 'AccountNamespaces'`, `go test ./internal/edge -run 'StoreDoorReturnsOwnNamespaceClaim'`, `go test ./internal/host -run 'EdgesFilePublishesDerivedRowAtOnce'` — 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)`. |
| @@ -241,26 +245,32 @@ Rules (§4.4): |
| **Interfaces:** |
| - Consumes: Task 2's `AccountNamespaces`, `ParseNamespaceHost`, `SubdomainRuleRefusal`. |
| - Produces: |
| - - `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. |
| + - `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. At a door, a load error refuses every attach or create under the apps domain with the retryable `SubdomainUnreadable` answer. On a display site it leaves hosts unchanged. |
| - `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. |
| + - `type createKind int` with `createNewHost` (a new claim, record or route) and `createExpandsCoverage` (a false-to-true Catchall or Wildcard+Catchall on a claim, so new names below it would serve). |
| + - `func (s *Server) createRefusal(v namespaceView, host, account string, kind createKind) bool`: true unless the label directly under the apps domain is `account`'s sqid or a name `account` holds. Applies to a new host two or more labels under the apps domain, and to a one-label host `L.<apps>` whose claim gains coverage below it (`createExpandsCoverage`, or a new instance catch-all `*.L.<apps>`). Existing sqid-shaped-label rules (`firstRouteOutsideNamespace`) keep their behaviour. The door decides `kind` from the claim it already reads under its lock: re-attaching or changing a claim without new coverage is not a create and is never refused; a failed claim read refuses. |
| + - `type occupant struct{ Host, Account, App, Source string }` (`Source`: claim, record or pending allocation) and `func (s *Server) namespaceOccupants(ctx context.Context, name string) ([]occupant, error)`: claims at or under `<name>.<apps>` (one-label apex included, from `ListWithUnread`; any unread one under the name is an error), declared records (`RecordHostDeclaredUnder`), and pending allocations (`PendingAllocationsUnder`). Strict: any failed read is an error. Assignment, the post-write re-read, `show` and remove all use this one walk. |
| - `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. |
| + - `type provision.DeclaredHost struct{ Host, Account, App string }` and `func provision.RecordHostDeclaredUnder(ctx, s release.Store, suffix string) ([]DeclaredHost, error)`: every instance record key whose host is equal to or under `suffix`, ownership from the key (`ParseRecordKey`, `provision.go:434`), duplicates kept; strict like `RecordHostDeclared`. |
| + - `func (st *Store) PendingAllocationsUnder(suffix string) ([]PendingAllocation, error)` in `internal/console/lifetimes_store.go`, beside `PendingAllocations` (:196): allocations whose host is equal to or under `suffix`. Console create persists an allocation before its record (`lifetimes_create.go:197`) and recovery writes the record later without a door (`lifetimes_recovery.go:233`, `lifetimes_create.go:484`), so the walk must see allocations too. |
| + - `func (s *Server) subdomainRefusal(ctx context.Context, v namespaceView, account, name string) (domains.SubdomainRefusal, []occupant)`: every §4.2 rule. `SubdomainOccupied` lists the other accounts' occupants from `namespaceOccupants`; its error → `SubdomainUnreadable`. No route fold: under choice B a console-made route comes from a claim, record or allocation, 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 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), capability changes (`setDomainCapabilities`, `apidomains.go:740-776`, on a false-to-true Catchall), 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 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. |
| + - `TestCatchallUnderUnassignedLabelRefused`: Wildcard+Catchall on `team.oncarlos.com`, and `*.team.oncarlos.com` instance catch-all, by `bdq` without `team` → refused; and an existing `team.oncarlos.com` claim with `Wildcard=true, Catchall=false` turned to `Catchall=true` → refused, while re-attaching it unchanged passes. |
| + - `TestDoorRefusesWhenNamespacesUnreadable`: `loadNamespaces` fails → attach under the apps domain refused with `SubdomainUnreadable`; a one-label `harbour.oncarlos.com` attach by `bcd` while `bdq` holds `harbour` → 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`. |
| + - `TestSubdomainOccupiedByPendingAllocation`: pause a create after its allocation and before its record write (the allocation is stored, no record), assign → `SubdomainOccupied`; resume recovery → the record lands and assignment stays refused. |
| - `TestRemovedNameStopsProtecting`. |
| - - `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. |
| + - `provision`: `TestRecordHostDeclaredUnder` (descendants across accounts with their account and app; duplicates kept; strict on a failed listing). |
| + - `TestPendingAllocationsUnder`. |
| +- [ ] **Step 3: Run** `go test ./internal/console -run 'SubdomainRefusalRules|SubdomainInfrastructure|CreateUnder|CatchallUnderUnassignedLabel|DoorRefusesWhenNamespacesUnreadable|InstanceCreateChecksHostLabel|UnreadNamespaceRefusesEveryone|SubdomainOccupiedBy|PendingAllocationsUnder|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: the label under the apps domain is platform-owned (T5)`. |
| @@ -271,18 +281,17 @@ Rules (§4.4): |
| - Create: `internal/console/apisubdomain.go`, `internal/console/canonical.go` |
| - 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 `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 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; when that status request fails, it omits the public link and shows the existing serving-error state instead of falling back to a sqid URL (`homelink.go:467`, `:488`). |
| - 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: `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:** |
| - Consumes: Task 2 attach/detach, Task 5 `subdomainRefusal`, `namespaceOwner`. |
| - Produces: |
| - `GET|POST|DELETE /api/cli/accounts/{account}/subdomain`. Gate: `cliUser` (person), `platformOperator(addr)` (not `store.IsOperator`), then the account: `AccountBySqid` for POST, `AccountAnyBySqid` for GET and DELETE (tombstoned accounts). Refuse every method while `cfg.HostClaim` is on. |
| - - POST `{"name": "..."}`: `subdomainRefusal`, attach, then re-read; if a foreign claim or route is now under the name or the account holds two names, detach its own claim and refuse with `SubdomainRolledBack` and the list. On success `{"name","host","foreign":[]}`. |
| - - 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. |
| + - POST `{"name": "..."}`: `subdomainRefusal`, attach, then re-read with `namespaceOccupants`; if another account's occupant is now under the name, the account holds two names, or the re-read fails, detach its own claim and refuse with `SubdomainRolledBack` and the list. On success `{"name","host","foreign":[]}`. |
| + - GET: `{"name","host","foreign":[other accounts' occupants]}`; a walk error answers `SubdomainUnreadable` rather than an empty list. |
| + - DELETE: refuse with the list while the account itself has any occupant under the name (claims, records or pending allocations), or when the walk fails; 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 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`. |
| @@ -306,7 +315,9 @@ Rules (§4.4): |
| - `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. |
| + - `TestSubdomainShowUnreadableIsNotEmpty`, `TestSubdomainRemoveRefusedOverOwnRecordOrAllocation`. |
| + - `TestHomeLinkOmitsURLWhenServingStatusFails` (different home and serving apps domains). |
| +- [ ] **Step 2: Run** `go test ./internal/console -run 'SubdomainDoor|SubdomainSet|SubdomainShow|SubdomainRemove|SubdomainRollback|SubdomainWritesBumpSerial|SubdomainInventory|CanonicalHost|CanonicalPage|LinksToName|LinksUseName|CarryPublicHost|FlipsDisplayBack|TestClaimConsoleMutationInvariant|TestEveryCLIDoorNamesItsRoles'` — 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)`. |
| @@ -317,14 +328,15 @@ Rules (§4.4): |
| - 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/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`. |
| +- 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; it belongs here because it reads `accounts_subdomain.go` |
| +- Modify: `apimode.go` ~:3387 (`apiInstanceRecord.PublicHost`) and ~:4001 (`apiRouteRow.PublicHost`), `routes_cli.go` :67 (print the public host, keep `Host` for matching), 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>`, `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`, `TestAccountsSubdomainInventory`, `TestInstancesTablePrintsPublicHost`, `TestDeployWatchPrintsPublicHostProbesHost`, `TestDeployAnnouncementPrintsPublicHost`. |
| -- [ ] **Step 2: Run** `go test . -run 'AccountsSubdomain|PrintsPublicHost|TestCLIGolden|TestCLIProjection'` and `go test ./internal/parity -run 'TestParityCLIPaths'` — FAIL. |
| +- [ ] **Step 1: Write failing tests** with an `httptest` console: `TestAccountsSubdomainSet`, `TestAccountsSubdomainSetRefusalPrintsReason`, `TestAccountsSubdomainRemoveListsConflicts`, `TestAccountsSubdomainShowListsForeign`, `TestAccountsSubdomainInventory`, `TestInstancesTablePrintsPublicHost`, `TestDeployWatchPrintsPublicHostProbesHost`, `TestDeployAnnouncementPrintsPublicHost`, `TestRoutesPrintsPublicHost`, `TestApprovedAccountSubdomainsCopy`. |
| +- [ ] **Step 2: Run** `go test . -run 'AccountsSubdomain|PrintsPublicHost|TestCLIGolden|TestCLIProjection|TestApprovedAccountSubdomainsCopy'` 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)`. |
| @@ -333,7 +345,7 @@ Rules (§4.4): |
| - [ ] **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:** 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 3:** Release and dev roll only with Paul's go. After the console that serves the inventory door is rolled on a deployment, and before any name is assigned there, run `carlos accounts subdomain inventory` and post the output on the branch discussion, so operators know which labels to assign. 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. |
| --- |
| @@ -379,3 +391,30 @@ Rules (§4.4): |
| | 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). | |
| +## Round 3 resolutions (Astra `CODEX-FINDINGS-…-R3.md`, Fable `FABLE-FINDINGS-…-R3.md`) |
| + |
| +Paul approved applying these without a fourth plan round (2026-11-11). The |
| +build's per-task reviews of Tasks 2, 5 and 6 and the whole-branch review |
| +check them in code. |
| + |
| +| Finding | Resolution | |
| +|---------|-----------| |
| +| Astra P1-1 / Fable P2-3 (pending allocations) | `PendingAllocationsUnder` joins the one strict walk, `namespaceOccupants`, used by assignment, re-read, `show` and remove (T5, T6). | |
| +| Astra P1-2 / Fable P3-1 (catch-all expansion) | `createRefusal` takes a `createKind`; false-to-true Catchall in `setDomainCapabilities` is a create (T5). | |
| +| Astra P2-3 (routes CLI) | `apiRouteRow.PublicHost`, `routes_cli.go` (T7). | |
| +| Astra P2-4 (homelink fallback) | Omit the link and show the serving-error state when status fails (T6). | |
| +| Astra P2-5 / Fable P2-4 (ownership) | `DeclaredHost{Host, Account, App}` (T5). | |
| +| Astra P2-6 (inventory before release) | Run after the console rolls, before any assignment (T8). | |
| +| Fable P2-1 (stamp unpublishes) | `StampHealth` skips derived rows; second-pass test; edges-file test in `internal/host` (T3). | |
| +| Fable P2-2 (reassignment sticks) | `notFound` always drops rows and table row (T3 rule 5). | |
| +| Fable P2-4 (door read errors) | Load error at a door refuses, retryable; door passes `createKind` from its claim read; failed read refuses (T5). | |
| +| Fable P2-5 (copy test order) | Copy test moves to Task 7. | |
| +| Fable P3-3 (HA vs exact claim) | HA rule applies rule 2's `listed` check (T3). | |
| +| Fable P3-4 (test placement) | Store wrapper in `internal/domains` (T3). | |
| + |
| +**Follow-up list (P3, no round):** |
| +- Placements under a held name: `regionalOverlapRefusal` refuses the holder too, because the namespace claim sits at `domains/*.P.json`. Exempt `AccountNamespace` claims or document it (Fable R3 P3-2). |
| +- Past `maxInstanceAliases` the console still shows a name URL with no alias row; log per account or have `show` report it (Fable R3 P3-5). |
| +- `loadNamespaces` adds one bucket LIST per display request, deploy-watch polls included; cache if it shows up (Fable R3 P3-6). |
| +- `wildcardManager.refresh` is at `wildcard.go:244` (Fable R3 P3-7). |
| + |