carlos / platform Public

plan 2a: fold in Astra round 1 (9 P1, 5 P2)

Frozen, versioned contacts per purchase; legacy purchase path; purge
releases claims before the trash marker goes; purchase creation under
the billing hold; proofs for extra names; point only fills an empty
binding; parity and census steps. Round 1 findings and round 2 brief.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 6108a068e22076244f8e437e87302c17d722a8db parent d635268
3 files changed, +336 −88
  • docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md +113 −88
  • docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md +133 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-domains-plan-2a-R2.md +90 −0
diff --git a/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md b/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
index 63e2ad7c0..99d8a0188 100644
--- a/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
+++ b/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md
@@ -2,9 +2,9 @@
> **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.
-**Goal:** An account gets a **Domains** page listing every domain it uses (bought here or registered elsewhere), buys a domain in three steps with or without an app, keeps saved contacts, and points a bought domain at an app later.
+**Goal:** An account gets a **Domains** page listing every domain it uses (bought here or registered elsewhere), buys a domain in three steps with or without an app, keeps saved contacts, and points an unpointed bought domain at an app later.
-**Architecture:** The purchase, registration and contact tables already live in console.db (`internal/console/domainstore.go`, migrated from `store.go:793`); what ties them to an app is the SQL gate classification (`store_gate.go:231`), the per-app mutation in `purchaseMutation` (`domainbuy.go:414`) and the app-scoped doors. This plan makes `app` optional on a purchase, adds saved contacts and a registrant snapshot per registration, derives "registered elsewhere" cards from the existing claims, and moves the doors to `/a/{sqid}/domains/...` with redirects from the old app-scoped URLs. No new storage location and no data move.
+**Architecture:** The purchase, registration and contact tables already live in console.db (`internal/console/domainstore.go`, migrated from `store.go:793`); what ties them to an app is the SQL gate classification (`store_gate.go:231`), the per-app mutation in `purchaseMutation` (`domainbuy.go:414`) and the app-scoped doors. This plan makes `app` optional on a purchase, freezes a versioned saved contact into each purchase, derives "registered elsewhere" cards from the existing claims, and moves the doors to `/a/{sqid}/domains/...` with redirects from the old app-scoped URLs. No new storage location and no data move.
**Tech Stack:** Go, modernc SQLite (console.db), `html/template` console pages built from the mockup kit, `golang.org/x/net/publicsuffix`, the existing `registrar`, `zonehost`, `billing` seams.
@@ -14,28 +14,32 @@
**Switch-on:** the Domains page and nav item are visible to every account on merge (no flag): "registered elsewhere" cards need nothing configured. Buying keeps Plan 1's switch (`domainBuyReady`), already on for dev and flagship. Roll dev first, then flagship with the next release.
+**Review history:** Astra round 1 on d6352683 (`docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md`): NOT READY, 9 P1 and 5 P2, all accepted and folded in below; each change is marked **(r1 N)**.
+
## Global Constraints
- Spec §11 wins over earlier sections where they disagree (spec status line).
-- Storage finding, recorded in the spec by Task 2: §11.1 says Plan 1 keeps purchases "in its app's own database"; they are in console.db. §11.7's "move to the account store" therefore means: reclassify, add columns and tables, backfill. Purchase IDs, states and URLs keep working (old URLs redirect, Task 9).
+- Storage finding, recorded in the spec by Task 2: §11.1 says Plan 1 keeps purchases "in its app's own database"; they are in console.db. §11.7's "move to the account store" therefore means: add columns and tables, backfill, keep the gate classification correct. Purchase IDs, states and URLs keep working (old URLs redirect, Task 9).
- Every money and registration rule from Plan 1 stands unchanged: no money without a registration, no registration without an authorised payment, an ambiguous answer is never a failure, registrar-side auto-renew OFF (spec §5.1, §5.5).
-- **Editing a saved contact never changes a registration (R12).** A saved contact's registrar handle is used as-is and never passed to `Registrar.EnsureContact` again: the Openprovider adapter updates an existing handle in place when the name matches (`internal/registrar/openprovider/client.go:136-155`). An edit clears the handle; the next purchase with that contact mints a new one with `EnsureContact(ctx, "", c)`.
-- Permissions (§11.7, my calls marked): every account member sees the Domains page and a domain's page. Owners only: buy, saved contacts (list, add, edit, remove), point a bought domain at an app, add an address under a bought domain (my call: these move or extend a paid domain), and the purchase card. "Add a domain you own" and its addresses use the existing attach door's own permission for the chosen app.
-- Every new route joins the route registers listed in Task 9's Files (the route-census tests fail otherwise).
+- **A purchase is bound to one frozen contact (R12, r1 1).** At start, the purchase copies the saved contact's `Contact`, `Version` and `Handle` into its `details`. Every later step reads only the purchase's frozen copy: the handle it registers with and the registrant snapshot both come from the purchase, never from the saved contact's current row. A saved contact's handle is never passed to `Registrar.EnsureContact` again (the Openprovider adapter updates an existing handle in place when the name matches, `internal/registrar/openprovider/client.go:136-155`). An edit bumps `Version` and clears the handle; a handle minted for a purchase is written back to the saved contact only when its `Version` still equals the purchase's frozen version and its handle is still empty.
+- **The HostClaim gate is shelved and inert in production** (`CARLOS_HOST_CLAIM`; claims shelved 2026-10-25). Code stays correct with it armed, but where armed behaviour would cost new machinery this plan refuses or parks the case instead (r1 8): see Task 4.
+- Permissions (§11.7, my calls marked): every account member sees the Domains page, a domain's page and the CLI list. Owners only: buy, saved contacts (list, add, edit, remove), point a bought domain at an app, add an address under a bought domain (my call: these move or extend a paid domain), and the purchase card. "Add a domain you own" uses the existing attach door's own permission for the chosen app.
+- Every new console route gets its `parity/parity.tsv` row and every new CLI word its `clireg` node and row, then `make parity-doc` regenerates `docs/parity.md` (never edited by hand); new routes also join the route registers in Task 9's Files (r1 9).
+- Root-package (CLI) changes go through the census (AGENTS.md "The census: the reviewer decides"): Task 12 carries the card, claims, proposal and Astra's approval (r1 9).
- No registrar or DNS host name in any customer-facing string. Every new string lives in a `*_copy.go` file as a draft, replaced by the copy pass (Task 11). Copy house rules: no em or en dashes, curly quotes in prose, `cli.`/`door.` keys lower case with no final full stop.
- Renewals do not exist until Plan 3. Nothing in this plan says or implies a domain "renews"; the Renewal card shows the expiry date and next year's price only, and the auto-renew switch ships with Plan 3 (my call: a switch that changes nothing would mislead).
-- Zero new steady-state S3 requests. The Domains page reads claims through the existing cache (`s.claims.ListWithUnread`, `claimcache.go:95`), never a fresh bucket list per request.
-- Writing Go here (AGENTS.md): every function with a `ctx` passes it on; no `time.Sleep` in tests; `errors.Is`/`As`; no function over 300 lines or file over 3,000 (`make code-health` before pushing).
-- Review budget (AGENTS.md stopping rules): Astra per-task review only on Tasks 4, 6, 7 and 9 (money flow, termination, claim ownership, security gates); Fable joins Astra on Task 6 and the whole-branch review. At most three rounds each; stop at the first round with no P1.
+- Request budget (r1 13): no new steady-state or per-box requests. The Domains overview, on a page view only, costs one `s.claims.ListWithUnread` (one bucket `ListMod`, as every claims page does today) plus, for each app that has addresses, the reads `settingsDomains` already does for that app's Domains tab. The domain's own page costs the same for the apps holding that domain's addresses. The CLI list costs the same as the overview.
+- Writing Go here (AGENTS.md): every function with a `ctx` passes it on; no `time.Sleep` in tests (pause with a seam or channel); `errors.Is`/`As`; no function over 300 lines or file over 3,000 (`make code-health` before pushing).
+- Review budget (AGENTS.md stopping rules): plan review round 2 of 3 next. Astra per-task review only on Tasks 4, 6, 7 and 9 (money flow, termination, claim ownership, security gates); Fable joins Astra on Task 6 and the whole-branch review. At most three rounds each; stop at the first round with no P1.
- Local verification: only the touched packages' tests with `-run` (AGENTS.md "Targeted local tests"; no full suites on docs-t1). CI runs everything.
## Review Focus
-1. **The chosen app is purged while the purchase is in flight** (spec C3). Expected: payment and registration finish, the purchase reaches `done` with `App` empty, no claim is written, the zone holds no apex or `www` records, and the purchase card says the domain is ready to point at an app. Test in Task 4: `TestPurchaseAppPurgedMidwayFinishesUnpointed`.
-2. **An app holding a bought domain's addresses is purged** (spec C2). Expected: the app's custom-domain claims are released, the card shows the domain with no addresses and "Point at an app", and pointing it at another app of the same account then succeeds. Tests in Task 6: `TestPurgeReleasesTheAppsDomainClaims` and Task 7: `TestPointAfterPurgeSucceeds`.
-3. **A saved contact is edited after a domain was registered with it.** Expected: the registration's registrant and handle are unchanged; the next purchase with the edited contact calls `EnsureContact` with an empty handle and stores the new handle on the contact. Test in Task 4: `TestEditedContactMintsNewHandleOldRegistrationUntouched`.
-4. **One domain's addresses sit on several apps, some in Trash, plus platform names.** Expected: one card for the registrable domain, one row per address naming its app, Trash shown as a state chip, the app's own `*.<apps-domain>` names absent, and `shop.example.co.uk` grouped under itself, never under `example.co.uk`. Test in Task 5: `TestAccountDomainsGroupsByRegistrableDomain`.
-5. **Pointing a bought domain at an app while another app of the same account holds `www`** (or a member of another account holds it). Expected: the same account's claim moves to the new app (detach, then attach); another account's claim refuses with the neutral `domains.ErrHostUnavailable` refusal and nothing is detached. Test in Task 7: `TestPointMovesOwnAccountClaimRefusesForeign`.
+1. **The chosen app is purged while the purchase is in flight** (spec C3). Expected (flag-off, production): payment and registration finish, the purchase reaches `done` with `App` empty, no claim is written, the zone holds no apex or `www` records, and the purchase card says the domain is ready to point at an app. Test in Task 4: `TestPurchaseAppPurgedMidwayFinishesUnpointed`.
+2. **An app holding a bought domain's addresses is purged** (spec C2). Expected: the app's custom-domain claims are released before the purge gives up its trash marker and row, the card shows the domain with no addresses and "Point at an app", and pointing it at another app of the same account then succeeds. Tests in Task 6: `TestPurgeReleasesTheAppsDomainClaims` and Task 7: `TestPointAfterPurgeSucceeds`.
+3. **A saved contact is edited or removed while a purchase using it is in flight.** Expected: the purchase registers with the contact and handle it froze at start, its registration's registrant is that frozen contact, and the edited contact's handle stays empty so the next purchase mints a new one. Test in Task 4: `TestContactEditDuringPurchaseKeepsFrozenContact`.
+4. **One domain's addresses sit on several apps, some in Trash, plus platform names.** Expected: one card per registrable domain, one row per address naming its app, Trash shown as a state chip, the app's own `*.<apps-domain>` names absent; `shop.example.co.uk` is an address on the `example.co.uk` card (r1 11). Test in Task 5: `TestAccountDomainsGroupsByRegistrableDomain`.
+5. **Pointing a bought domain whose apex or `www` is already attached somewhere.** Expected: refused up front, nothing detached and no DNS written, with a message to detach it from its current app first (r1 6); another account's claim gets the neutral `domains.ErrHostUnavailable` refusal. Test in Task 7: `TestPointRefusesAttachedDomainTouchesNothing`.
---
@@ -46,11 +50,11 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
**Files:**
- Create: `docs/superpowers/mockups/domains-account-kit/overview.html`, `buy-name.html`, `buy-app.html`, `buy-pay.html`, `domain-bought.html`, `domain-elsewhere.html`, `contacts.html`, `purchase-card.html` (each from `docs/console-mockup-kit/shell.html`, components from `docs/console-styleguide.md`)
-- [ ] **Step 1:** Draw each screen in the kit, following the approved layouts (overview option A; three buy steps; domain page cards in §11.6 order; the contacts view placed on the Domains page, my call: a "Saved contacts" section below the cards, owners only). The purchase card keeps Plan 1's step list (0c2ab2e) and adds the "ready to point at an app" end state.
+- [ ] **Step 1:** Draw each screen in the kit, following the approved layouts (overview option A; three buy steps; domain page cards in §11.6 order; the contacts view placed on the Domains page, my call: a "Saved contacts" section below the cards, owners only). The purchase card keeps Plan 1's step list (0c2ab2e) and adds the "ready to point at an app" end state. A bought domain whose apex is attached shows "Detach from <app>" beside the address, not a move button (r1 6).
- [ ] **Step 2:** UX pass: each screen at 390 px and desktop, light and dark; lead with state (chips for "Bought here", "Registered elsewhere", attach state, "In Trash"; expiry as a date tile). Run the `impeccable` critique and distill passes; fix what reads badly.
- [ ] **Step 3:** Commit `mockups: domains at the account level, redrawn in the kit`, push, and post the mockup paths on the branch's amadan discussion for Paul to look at. Tasks 2-7 do not wait on his look; Tasks 8-9 do.
-### Task 2: Store: saved contacts, registrant snapshot, app-less purchases
+### Task 2: Store: versioned saved contacts, registrant snapshot, app-less purchases
**Files:**
- Modify: `internal/console/domainstore.go`, `internal/console/domainstore_test.go`
@@ -64,55 +68,60 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
ID string // "dc_" + 12 random hex
AccountID int64
Contact registrar.Contact
- Handle string // registrar handle; "" until a purchase mints one, cleared by Edit
+ Version int64 // 1 on add, +1 on every edit
+ Handle string // registrar handle for this Version; "" until a purchase mints one
LastUsed, CreatedAt time.Time
}
func (s *Store) SavedContacts(accountID int64) ([]SavedContact, error) // LastUsed desc, then CreatedAt desc
func (s *Store) SavedContact(accountID int64, id string) (*SavedContact, error) // nil, nil when missing or another account's
func (s *Store) AddSavedContact(accountID int64, c registrar.Contact, now time.Time) (SavedContact, error) // c.Validate() first
- func (s *Store) EditSavedContact(accountID int64, id string, c registrar.Contact) error // replaces Contact, sets Handle ""
- func (s *Store) RemoveSavedContact(accountID int64, id string) error // list only; registrations keep their snapshot
- func (s *Store) UseSavedContact(accountID int64, id, handle string, now time.Time) error // sets Handle when empty, LastUsed = now
+ func (s *Store) EditSavedContact(accountID int64, id string, c registrar.Contact) error // replaces Contact, Version+1, Handle ""
+ func (s *Store) RemoveSavedContact(accountID int64, id string) error // list only; purchases and registrations keep their frozen copy
+ func (s *Store) SetSavedContactHandle(accountID int64, id string, version int64, handle string) (bool, error)
+ // UPDATE ... SET handle=? WHERE account_id=? AND id=? AND version=? AND handle='' ; false when nothing matched
+ func (s *Store) TouchSavedContact(accountID int64, id string, now time.Time) error // LastUsed only
func (s *Store) DomainRegistrations(accountID int64) ([]DomainRegistration, error) // by domain
func (s *Store) DomainRegistrationFor(accountID int64, domain string) (*DomainRegistration, error) // nil, nil when not this account's
func (s *Store) AccountDomainPurchases(accountID int64) ([]DomainPurchase, error) // non-terminal, newest first
- func (s *Store) RegistrationCount(accountID int64) (int, error)
+ func (s *Store) DomainObligations(accountID int64) ([]string, error) // domains with a registration or a non-terminal purchase, sorted
// DomainRegistration gains:
- Registrant registrar.Contact // snapshot at registration; never changed by a contact edit
+ Registrant registrar.Contact // the purchase's frozen contact; never changed by a contact edit
// purchaseDetails gains:
- ContactID string
+ ContactID string // "" on purchases made before this plan
+ ContactVersion int64
```
- Schema: `domain_saved_contacts(id TEXT PRIMARY KEY, account_id INTEGER NOT NULL, contact TEXT NOT NULL, handle TEXT NOT NULL DEFAULT '', last_used INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL)` with an index on `account_id`; `ALTER TABLE domain_registrations ADD COLUMN registrant TEXT NOT NULL DEFAULT '{}'` (the existing duplicate-column tolerant loop). Gate: `domain_purchases` gains `FreeWhenNoApp: true`; `domain_saved_contacts` is NonApp ("saved registrant contacts and handles, keyed by account; names no app").
- One-time backfills inside `migrateDomains`, idempotent: each `domain_contacts` row becomes a saved contact (same handle, `last_used = updated_at`) unless the account already has one with an equal contact; each registration with `registrant = '{}'` takes the `Contact` from the `details` of its account's purchase for that domain in state `done`, `captured` or `unpaid`. `domain_contacts` stays in place, no longer read or written after Task 4.
+ Schema: `domain_saved_contacts(id TEXT PRIMARY KEY, account_id INTEGER NOT NULL, contact TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 1, handle TEXT NOT NULL DEFAULT '', last_used INTEGER NOT NULL DEFAULT 0, created_at INTEGER NOT NULL)` with an index on `account_id`; `ALTER TABLE domain_registrations ADD COLUMN registrant TEXT NOT NULL DEFAULT '{}'` (the existing duplicate-column tolerant loop). Gate: `domain_purchases` gains `FreeWhenNoApp: true` (it keeps its `app` column, so it cannot be NonApp: `store_gate_test.go:719`); `domain_saved_contacts` is NonApp ("saved registrant contacts and handles, keyed by account; names no app").
+ One-time backfills inside `migrateDomains`, idempotent: each `domain_contacts` row becomes a saved contact (same handle, version 1, `last_used = updated_at`) unless the account already has one with an equal contact. Every registration with `registrant = '{}'` takes the `Contact` from the `details` of the newest purchase for the same account and domain whose details carry a contact, in any state (r1 2). Existing purchases are not rewritten: an empty `ContactID` marks a legacy purchase, which keeps using its own frozen `Contact` and `OwnerHandle` (Task 4). `domain_contacts` stays in place, no longer read or written after Task 4.
-- [ ] **Step 1: Write failing tests:** `TestSavedContactsOrderAndAccountScope` (two accounts; `SavedContact` with another account's ID returns nil; order by LastUsed then CreatedAt), `TestEditSavedContactClearsHandle`, `TestUseSavedContactKeepsExistingHandle` (a second `UseSavedContact` with a different handle leaves the first), `TestMigrateDomainsBackfillsContactsAndRegistrant` (seed a `domain_contacts` row, a done purchase with a contact and a registration with `'{}'`; migrate twice; one saved contact with the old handle; registrant equals the purchase contact), `TestAppLessPurchaseRowAllowedByGate` (with the gate armed in the test harness the other `FreeWhenNoApp` test uses, `cli_tokens`'s: find it with `git grep -n FreeWhenNoApp -- '*_test.go'`, an `app=''` purchase inserts).
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'SavedContact|MigrateDomains|AppLessPurchase'`; expect FAIL.
+- [ ] **Step 1: Write failing tests:** `TestSavedContactsOrderAndAccountScope` (two accounts; `SavedContact` with another account's ID returns nil; order by LastUsed then CreatedAt), `TestEditSavedContactBumpsVersionClearsHandle`, `TestSetSavedContactHandleIsConditional` (stale version → false and unchanged; existing handle → false; matching version and empty handle → true), `TestMigrateDomainsBackfillsContactsAndRegistrant` (seed a `domain_contacts` row; a registration with `'{}'` whose only purchase is in `registered`, and one in `done`; migrate twice; one saved contact with the old handle; both registrants equal their purchase's contact), `TestDomainObligations`, `TestAppLessPurchaseRowAllowedByGate` (with the gate armed in the harness `cli_tokens`' `FreeWhenNoApp` test uses, found with `git grep -n FreeWhenNoApp -- '*_test.go'`, an `app=''` purchase inserts and updates).
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'SavedContact|MigrateDomains|DomainObligations|AppLessPurchase'`; expect FAIL.
- [ ] **Step 3: Implement**, and the spec note.
- [ ] **Step 4: Run**; expect PASS. Also `go test ./internal/console/ -run 'StoreGate|ClaimSQL'` (the gate's own classification tests).
-- [ ] **Step 5: Commit** `console: saved domain contacts, registrant snapshot, app-less purchases`.
+- [ ] **Step 5: Commit** `console: versioned saved domain contacts, registrant snapshot, app-less purchases`.
-### Task 3: Zone host: empty managed sets and extra names
+### Task 3: Zone host: unpointed zones, extra names and their proofs
**Files:**
- Modify: `internal/zonehost/zonehost.go`, `internal/zonehost/zonehost_test.go`, `internal/zonehost/zonehosttest/fake.go`
- Modify: `internal/zonehost/route53zones/route53.go`, `internal/zonehost/route53zones/route53_test.go`
**Interfaces:**
-- Produces: `ManagedSet` gains `Names []string` (full hostnames strictly under the zone, each written as an ALIAS A to the apex, `EvaluateTargetHealth: true`). `Validate()` now accepts an empty set (no apex, `WWW` false, no `Names`, no TXT): that is an unpointed zone; `WWW` or any `Names` without apex targets is refused. `SetManaged` refuses a name not under `z.Domain` and deletes any managed record not in `m`. Managed, for the Route 53 adapter: apex A sets, any A record that is an ALIAS to the zone apex, and the challenge TXT names (customer records in Plan 4 are never ALIAS records, so the rule keeps them separate).
+- Produces: `ManagedSet` gains `Names []string` (full hostnames strictly under the zone, each written as an ALIAS A to the apex, `EvaluateTargetHealth: true`). `Validate()` now accepts an empty set (no apex, `WWW` false, no `Names`, no TXT): an unpointed zone. `WWW` or any `Names` without apex targets is refused. Challenge TXT is accepted for the apex, `www` and each entry of `Names`, and for nothing else (r1 5; today only apex and `www`, `zonehost.go:89`). `SetManaged` refuses a name not under `z.Domain` and deletes any managed record not in `m`. Managed, for the Route 53 adapter: apex A sets, any A record that is an ALIAS to the zone apex, and the challenge TXT names of the apex, `www` and every name currently aliased to the apex (customer records in Plan 4 are never ALIAS records, so the rule keeps them apart).
+ `func ManagedFor(apex []ApexTarget, names []string, proof func(host string) TXT) ManagedSet` builds the one canonical set for a pointed zone: apex targets, `WWW: true`, `Names`, and, when `proof` is non-nil, one challenge TXT per host (apex, `www`, each name). Every writer (Plan 1's `authorised` step, Task 4, Task 7) uses it, so a later write never drops an earlier name or proof.
-- [ ] **Step 1: Write failing tests:** `TestManagedSetValidateEmptyAndNames` (empty valid; `WWW` without apex refused; `Names` without apex refused), `TestFakeSetManagedEmptyClearsApex`, `TestSetManagedWritesNamesAsApexAlias` (`docs.shop.example` → ALIAS A to `shop.example.`), `TestSetManagedRefusesNameOutsideZone` (`docs.other.example`), `TestSetManagedEmptyDeletesApexWWWAndNames`.
-- [ ] **Step 2: Run** `go test ./internal/zonehost/... -run 'ManagedSet|SetManaged'`; expect FAIL.
+- [ ] **Step 1: Write failing tests:** `TestManagedSetValidateEmptyAndNames` (empty valid; `WWW` without apex refused; `Names` without apex refused; a challenge TXT for a name in `Names` accepted, for a name outside it refused), `TestManagedForIncludesEveryProof`, `TestFakeSetManagedEmptyClearsApex`, `TestSetManagedWritesNamesAsApexAlias` (`docs.shop.example` → ALIAS A to `shop.example.`), `TestSetManagedRefusesNameOutsideZone` (`docs.other.example`), `TestSetManagedEmptyDeletesApexWWWNamesAndProofs`.
+- [ ] **Step 2: Run** `go test ./internal/zonehost/... -run 'ManagedSet|ManagedFor|SetManaged'`; expect FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run**; expect PASS.
-- [ ] **Step 5: Commit** `zonehost: unpointed zones and extra names aliased to the apex`.
+- [ ] **Step 5: Commit** `zonehost: unpointed zones, extra names and their proofs`.
-### Task 4: Purchase engine: optional app, saved contacts, app gone (risky: per-task review)
+### Task 4: Purchase engine: optional app, frozen contacts, app gone, deletion exclusion (risky: per-task review)
**Files:**
-- Modify: `internal/console/domainbuy.go`, `internal/console/domainbuy_test.go`, `internal/console/apidomainbuy.go`, `internal/console/appdomainbuy.go` (callers of `startDomainPurchase` only; their doors move in Task 9)
+- Modify: `internal/console/domainbuy.go`, `internal/console/domainbuy_test.go`, `internal/console/apidomainbuy.go`, `internal/console/appdomainbuy.go` (callers of `startDomainPurchase` and readers of `DomainContact`; their doors move in Tasks 9 and 10)
**Interfaces:**
-- Consumes: Task 2 store methods; Task 3 `ManagedSet`.
+- Consumes: Task 2 store methods; Task 3 `ManagedSet`, `ManagedFor`.
- Produces:
```go
type purchaseContact struct {
@@ -122,22 +131,25 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
func (s *Server) startDomainPurchase(ctx context.Context, acct *Account, app, name string, contact purchaseContact, principal string, confirmed domainreg.Quote) (*DomainPurchase, string, *domainreg.Quote, *doorRefusal)
// app "" is "Not yet" (§11.4). A non-empty app must be one of AppsIn(acct.ID), as today.
func (s *Server) purchaseManagedSet(ctx context.Context, p *DomainPurchase) (zonehost.ManagedSet, error)
- // App "": the empty set. Otherwise today's apex/www/challenge set.
+ // App "": the empty set. Otherwise ManagedFor(apex, nil, proof when DomainProof).
+ func (s *Server) defaultQuoteCountry(acct *Account) string
+ // the most recently used saved contact's Country, else ""; replaces both DomainContact reads (r1 14)
```
Behaviour changes, each its own CAS transition as in Plan 1:
- - Start: `contact.New` → `AddSavedContact`, its ID goes in `details.ContactID`. `contact.ID` not the account's → 422 `code:"contact"`. The paid-plan rule and daily cap apply whether or not an app is chosen (§11.4).
- - Checkout step (`purchaseCheckoutStep`, replacing the `DomainContact`/`SetDomainContact` read and write): the saved contact has a handle → `OwnerHandle = handle`, no registrar call. No handle → `EnsureContact(ctx, "", c)`, then `UseSavedContact(id, handle, now)`. `UseSavedContact` also runs (LastUsed only) when the handle existed.
- - `authorised` step: `SetManaged(zone, purchaseManagedSet(p))`.
- - `registered` → `registeredPurchase` stores `Registrant` = the saved contact's `Contact` at that moment.
- - `captured` step: `App == ""` → `done`, no attach. App not in `AppsIn(acct.ID)` (purged or in Trash, my call: Trash counts as gone here because attaching to a trashed app would serve nothing) → `SetManaged(zone, ManagedSet{})`, then `done` with `App = ""` and `Reason = "app_gone"`.
- - `purchaseMutation`: `App == ""` runs `call` directly (no app mutation; the row is `FreeWhenNoApp`). With an app, unchanged. A purchase whose app is unset by the `captured` step does so inside that app's mutation, like every other step.
-
-- [ ] **Step 1: Write failing tests** on `newPurchaseFixture`: `TestPurchaseWithoutAppRegistersAndAttachesNothing` (reaches `done`; registration row with registrant; no claim for apex or `www`; zone's managed set empty), `TestPurchaseAppPurgedMidwayFinishesUnpointed` (remove the app from the store after `registered`; reaches `done`, `App` empty, `Reason` `app_gone`, managed set empty, payment captured once), `TestPurchaseSavedContactWithHandleSkipsRegistrar` (fake registrar `Calls` has no contact call), `TestEditedContactMintsNewHandleOldRegistrationUntouched` (buy with contact A, edit A, buy a second domain with A: the second purchase's `OwnerHandle` differs, the first registration's `Registrant` and the first purchase's `OwnerHandle` are unchanged, and the fake saw `EnsureContact` with an empty handle), `TestPurchaseOtherAccountsContactRefused`, `TestStartWithoutAppStillNeedsPaidPlanAndCap`. Existing Plan 1 engine tests must keep passing with `purchaseContact{New: &c}` in place of the old contact argument.
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPurchase|TestStart|TestEditedContact'`; expect the new tests to FAIL.
+ - **Start (r1 1, r1 4):** `contact.New` → `AddSavedContact`. `contact.ID` not the account's → 422 `code:"contact"`. The purchase's `details` take `ContactID`, `ContactVersion`, `Contact` and, when the saved contact has one, `OwnerHandle` = its `Handle`. The paid-plan rule and daily cap apply whether or not an app is chosen (§11.4). `CreateDomainPurchase` moves inside the billing hold (before `release()` at `domainbuy.go:207`), preceded under that hold by a re-read of the account that refuses (`domainBuyUnavailable`) when it is gone or retiring. Account deletion already holds the same hold from `retireForDeletion` through `DeleteAccount` (`ownership.go:139`), so a purchase row either exists before deletion's check (Task 6) or is never written.
+ - **Checkout step** (`purchaseCheckoutStep`, replacing the `DomainContact`/`SetDomainContact` read and write): `OwnerHandle` already set → no registrar call. Empty → `EnsureContact(ctx, "", details.Contact)`, store the handle in the purchase, then `SetSavedContactHandle(accountID, ContactID, ContactVersion, handle)` (a false result is fine: the contact was edited meanwhile). Legacy purchases (empty `ContactID`) keep Plan 1's behaviour on their own frozen `Contact`, without writing `domain_contacts`. `TouchSavedContact` on success.
+ - **`authorised` step:** `SetManaged(zone, purchaseManagedSet(p))`.
+ - **`registered`:** `registeredPurchase` stores `Registrant = details.Contact` (the frozen copy). When the registration row already exists (the insert-before-state-update crash window, `domainbuy.go:738`) and its registrant is `'{}'`, it updates it (r1 2).
+ - **`captured` step:** `App == ""` → `done`, no attach. App not in `AppsIn(acct.ID)` (purged or in Trash, my call: attaching to a trashed app would serve nothing): flag-off, `SetManaged(zone, ManagedSet{})`, then `done` with `App = ""` and `Reason = "app_gone"`. With the HostClaim gate armed, the purchase stays `captured` with `Reason = "app_gone"` and the existing attempts alert pages the operator (r1 8: clearing `app` on a gated row needs the gone app's permit, `store_gate.go:646`; the gate is not the production path).
+ - **`purchaseMutation` (r1 8):** `App == ""` runs the same closure (re-read the purchase, refuse with `ErrPurchaseStateMoved` unless `State` and `Revision` match, then `call`) without `claimAppMutation`. With an app, unchanged.
+ - **Legacy contact readers (r1 14):** `checkDomainBuy` (`apidomainbuy.go:43`) and the browser check (`appdomainbuy.go:157`) take their default country from `defaultQuoteCountry`; nothing reads `DomainContact` after this task (`git grep -n 'DomainContact(' -- '*.go'` lists only the store and its test).
+
+- [ ] **Step 1: Write failing tests** on `newPurchaseFixture`: `TestPurchaseWithoutAppRegistersAndAttachesNothing` (reaches `done`; registration row with registrant; no claim for apex or `www`; zone's managed set empty), `TestPurchaseAppPurgedMidwayFinishesUnpointed` (remove the app after `registered`; reaches `done`, `App` empty, `Reason` `app_gone`, managed set empty, payment captured once), `TestPurchaseAppGoneGateArmedParksAndAlerts`, `TestPurchaseSavedContactWithHandleSkipsRegistrar`, `TestContactEditDuringPurchaseKeepsFrozenContact` (pause the fake registrar inside `EnsureContact` on a channel; edit the contact; release; the purchase registers with the frozen contact's new handle, the registration's registrant is the frozen contact, and the saved contact's handle is still empty), `TestContactRemovedDuringPurchaseStillFinishes`, `TestLegacyPurchaseFinishesFromItsOwnContact` (a purchase row with no `ContactID` in `awaiting_payment` and one in `registering` both reach `done`), `TestRegisteredRetryBackfillsRegistrant`, `TestPurchaseOtherAccountsContactRefused`, `TestStartWithoutAppStillNeedsPaidPlanAndCap`, `TestStartRefusedOnceAccountRetiring` (retire the account while the start is paused just before the insert; no row is written), `TestStaleAppLessSnapshotHasNoEffects` (advance an app-less purchase with a stale revision; the fakes record no calls). Existing Plan 1 engine tests keep passing with `purchaseContact{New: &c}` in place of the old contact argument.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPurchase|TestStart|TestContact|TestLegacyPurchase|TestRegisteredRetry|TestStale'`; expect the new tests to FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the same, plus `-run 'DomainBuy|APIDomain'`; expect PASS.
-- [ ] **Step 5: Commit** `console: purchases with no app, saved contacts, unpointed finish`.
-- [ ] **Step 6: Astra task review** (money flow and termination). Brief from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, naming the R12 invariant and the Plan 1 money rules.
+- [ ] **Step 5: Commit** `console: purchases with no app, frozen contacts, unpointed finish`.
+- [ ] **Step 6: Astra task review** (money flow and termination). Brief from `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`, naming R12, the frozen-contact rule and the Plan 1 money rules.
### Task 5: The account's domains, assembled
@@ -154,7 +166,7 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
State string // the attach state (live, pending-dns, ...), as the app's Domains tab shows it
}
type domainCard struct {
- Domain string // registrable domain (eTLD+1), A-label
+ Domain string // registrable domain (publicsuffix.EffectiveTLDPlusOne), A-label
Registration *DomainRegistration // nil: registered elsewhere
Purchase *DomainPurchase // a non-terminal purchase for this domain, if any
Addresses []domainAddress // sorted: apex, www, then by host
@@ -162,52 +174,63 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
func (s *Server) accountDomains(ctx context.Context, acct *Account) ([]domainCard, error) // sorted by Domain
func (s *Server) accountDomain(ctx context.Context, acct *Account, domain string) (*domainCard, error) // nil, nil when the account has no such card
```
- Rules: addresses come from claims with `Account == acct.Sqid`, an app in `AppsIncludingTrashIn`, and `customDomain(strings.TrimPrefix(host, "*."), sqid)` true; the card key is `publicsuffix.EffectiveTLDPlusOne` of the host without `*.`. Registrations and live purchases add cards with no addresses when nothing is attached. Unread claims (the cache's `unread` set) make the call return an error rather than a short list. State is computed once per app that has addresses, never per address.
+ Rules: addresses come from one `ListWithUnread` snapshot, claims with `Account == acct.Sqid`, an app in `AppsIncludingTrashIn`, and `customDomain(strings.TrimPrefix(host, "*."), sqid)` true; the card key is `EffectiveTLDPlusOne` of the host without `*.`. Registrations and live purchases add cards with no addresses when nothing is attached. Unread claims (the snapshot's `unread` set) make the call return an error rather than a short list. State comes from one `settingsDomains` call per app that has addresses, never per address; `accountDomain` makes those calls only for the apps holding that domain's addresses.
-- [ ] **Step 1: Write failing tests:** `TestAccountDomainsGroupsByRegistrableDomain` (Review Focus 4: claims for `shop.example`, `www.shop.example` on app `a`, `docs.shop.example` on app `b` in Trash, `kass.<apps-domain>` platform name, `shop.example.co.uk`, another account's `other.example`; exactly two cards, rows and chips as stated), `TestAccountDomainsBoughtWithoutAddresses` (a registration with no claims is a card with `Registration` set and no addresses), `TestAccountDomainsShowsLivePurchase`, `TestAccountDomainsUnreadClaimsIsError`, `TestAccountDomainOtherAccountIsNil`.
+- [ ] **Step 1: Write failing tests:** `TestAccountDomainsGroupsByRegistrableDomain` (Review Focus 4: claims for `shop.example`, `www.shop.example` on app `a`, `docs.shop.example` on app `b` in Trash, `kass.<apps-domain>` platform name, `shop.example.co.uk` on app `a`, another account's `other.example`; exactly two cards, `shop.example` and `example.co.uk`, rows and chips as stated), `TestAccountDomainsBoughtWithoutAddresses`, `TestAccountDomainsShowsLivePurchase`, `TestAccountDomainsUnreadClaimsIsError`, `TestAccountDomainOtherAccountIsNil`, `TestAccountDomainsOneClaimsListPerCall` (a counting claims source sees one list).
- [ ] **Step 2: Run** `go test ./internal/console/ -run AccountDomain`; expect FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run**; expect PASS.
- [ ] **Step 5: Commit** `console: an account's domains, bought and registered elsewhere`.
-### Task 6: Purge releases domain claims; account deletion refused while holding registrations (risky: per-task review)
+### Task 6: Purge releases domain claims; accounts holding domains cannot be deleted (risky: per-task review)
Today the claims-off purge (`purgeAppWithLifetimes`, `lifetimes_purge.go:40`) leaves the app's custom-domain claims in the bucket, so the hosts stay held by an app that no longer exists and no other app of the account can attach them. Spec C2 needs them released at purge.
**Files:**
- Modify: `internal/console/lifetimes_purge.go`, its test file (`git grep -ln purgeAppWithLifetimes -- '*_test.go'`)
-- Modify: `internal/console/ownership.go:161` (`deletionRefused`) and `:790` (`Store.DeleteAccount`), plus any other account-deletion door (`git grep -n 'DeleteAccount(' -- '*.go'`), and `internal/console/ownership_test.go`
+- Modify: `internal/console/ownership.go` (`deleteAccountNow` before `tombstoneAccount` at `:202`; `Store.DeleteAccount` at `:790`), any other account-deletion door (`git grep -n 'DeleteAccount(' -- '*.go'`), and `internal/console/ownership_test.go`
**Interfaces:**
-- Consumes: `s.detachDomainClaim(ctx, host, account, app)` (`claim_alias.go:201`), `RegistrationCount` and `AccountDomainPurchases` (Task 2).
-- Produces: purge detaches every claim whose `Account` and `App` match the purged app (custom domains only; platform names follow their existing path), after the app's rows are gone and before the purge reports done; a detach error leaves the purge retryable, as its other steps do. Account deletion refuses, before anything is deleted, when `RegistrationCount > 0` or a non-terminal purchase exists, naming the domains in the flash (copy draft in `domainbuy_copy.go`), and `Store.DeleteAccount` re-checks inside its transaction.
+- Consumes: `s.detachDomainClaim(ctx, host, account, app)` (`claim_alias.go:201`), `DomainObligations` (Task 2), the billing hold Task 4 now takes around purchase creation.
+- Produces:
+ - **Purge order (r1 3):** in `purgeAppWithLifetimes`, after the per-host loop (`lifetimes_purge.go:86-93`) and **before** `release.PurgeAppExcept` (which removes the trash marker), detach every claim whose `Account` and `App` match the purged app and whose host is a custom domain (`customDomain` true; platform names, aliases and catch-alls of other apps are never touched; this app's catch-all claims are custom-domain claims and go too). A detach error returns from `purgeAppWithLifetimes` with the marker and the app row (`ownership.go:605`, deleted last by the caller) still in place, so the next purge retries from the same admission evidence. Every caller of `purgeAppWithLifetimes` (the purge door, `sweepTrashedApp`, expiry) gets the ordering for free because it lives inside the function.
+ - **Deletion (r1 4):** `deleteAccountNow` checks `DomainObligations` first, while holding the billing hold `retireForDeletion` took and before `tombstoneAccount`; non-empty → refuse, flash naming the domains (copy draft in `domainbuy_copy.go`), `endRetirement` as today. `Store.DeleteAccount` re-checks inside its transaction and returns an error naming the count. `deletionRefused` also shows the refusal early (before sign-in), as it does for apps.
-- [ ] **Step 1: Write failing tests:** `TestPurgeReleasesTheAppsDomainClaims` (claims for `shop.example` and `www.shop.example` on the purged app, `blog.example` on a live app of the same account: the first two gone, the third untouched), `TestPurgeDomainDetachIsRetryable` (fake store fails the first delete; a second purge pass finishes), `TestAccountDeletionRefusedWhileHoldingRegistrations` (flash names the domain; account row still present), `TestAccountDeletionRefusedWithLivePurchase`, `TestStoreDeleteAccountRechecksRegistrations`.
+- [ ] **Step 1: Write failing tests:** `TestPurgeReleasesTheAppsDomainClaims` (claims for `shop.example` and `www.shop.example` on the purged app, `blog.example` on a live app of the same account, a platform name of the purged app: the first two gone, the others untouched), `TestPurgeDomainDetachFailureKeepsMarkerAndRetries` (the fake bucket fails the second detach; marker and row remain; a second purge finishes and removes both), `TestAccountDeletionRefusedWhileHoldingRegistrations` (flash names the domain; no tombstone written; account row present), `TestAccountDeletionRefusedWithLivePurchase`, `TestStoreDeleteAccountRechecksObligations`.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'PurgeReleases|PurgeDomainDetach|AccountDeletionRefused|StoreDeleteAccount'`; expect FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run**; expect PASS. Also `-run 'Purge|Trash|DeleteAccount'` for the existing purge and deletion tests.
- [ ] **Step 5: Commit** `console: purge releases domain claims; accounts holding domains cannot be deleted`.
- [ ] **Step 6: Astra and Fable task review** (termination: purge and account deletion).
-### Task 7: Point a bought domain at an app; add an address (risky: per-task review)
+### Task 7: Point an unpointed bought domain at an app; add an address (risky: per-task review)
+
+Pointing only fills an empty binding; it never moves one (r1 6). Moving a domain between apps is "Detach" on its current app (the existing per-app detach door, linked from the domain page) followed by "Point".
**Files:**
- Create: `internal/console/domainpoint.go`, `internal/console/domainpoint_test.go`
**Interfaces:**
-- Consumes: Task 3 (`ManagedSet.Names`), Task 5 (`accountDomain`), `attachDomain` (`domainattach.go:112`), `detachDomain` (`domainattach.go:390`), `s.cfg.DomainApex` / static fallback as Plan 1's `authorised` step uses, `domainChallenge`.
+- Consumes: Task 3 (`ManagedFor`), Task 5 (`accountDomain`), `attachDomain` (`domainattach.go:112`), the attach door's destination checks (`domainattach.go:134`: linked and temporary apps refused), `s.cfg.DomainApex` / static fallback as Plan 1's `authorised` step uses, `domainChallenge`.
- Produces:
```go
func (s *Server) pointBoughtDomain(ctx context.Context, acct *Account, domain, app, principal string) *doorRefusal
func (s *Server) addBoughtAddress(ctx context.Context, acct *Account, domain, host, app, principal string) *doorRefusal
+ func (s *Server) pointDestinationRefusal(ctx context.Context, acct *Account, app string) *doorRefusal // the attach door's destination admission, factored out of attachDomainAs and used by both
```
- `pointBoughtDomain`: the domain must be one of the account's registrations (otherwise the neutral not-found refusal) and `app` one of `AppsIn`. For the apex and `www`: if a claim exists for the same account on another app, `detachDomain` it from that app first; another account's claim refuses with `domains.ErrHostUnavailable`'s neutral refusal before anything changes. Then `SetManaged` with the apex set, `WWW: true`, existing `Names`, and challenge TXT when `DomainProof`; then `attachDomain` for both. `addBoughtAddress`: `host` must be strictly under `domain` and not the apex or `www`; adds `host` to the zone's `Names`, then attaches it to `app`. Both run under the account's domain mutex (a `sync.Mutex` per account ID held in the Server, my call: two pointing calls for one domain must not interleave their SetManaged writes).
-
-- [ ] **Step 1: Write failing tests:** `TestPointUnpointedDomainWritesApexAndAttaches`, `TestPointMovesOwnAccountClaimRefusesForeign` (Review Focus 5), `TestPointAfterPurgeSucceeds` (with Task 6's purge), `TestPointNotOwnedDomainIsNeutralNotFound`, `TestAddAddressAliasesNameAndAttaches`, `TestAddAddressRefusesApexWWWAndOutsideDomain`.
+ Order for both, every refusal before any write (r1 6, r1 7):
+ 1. Under the per-account domain mutex (`s.domainPointLocks`, a `sync.Map` of `*sync.Mutex` by account ID, my call: two calls for one account must not interleave their `SetManaged` writes).
+ 2. The domain must be one of the account's registrations (else the neutral not-found refusal), with **no non-terminal purchase** for it (else refused "still being bought"). Terminal purchase states never become live again and a registered domain cannot be bought a second time, so this check needs no lock shared with the purchase pass (r1 7).
+ 3. `pointDestinationRefusal(app)`.
+ 4. Point: neither the apex nor `www` may have a claim (any account): an own-account claim → refused "detach it from <app> first"; another account's → the neutral `domains.ErrHostUnavailable` refusal. Add address: the domain must already be pointed (the apex claim exists and names an app of this account, else refused "point the domain at an app first", r1 5); `host` strictly under `domain`, not apex or `www`, and unclaimed.
+ 5. `SetManaged(zone, ManagedFor(apex, names, proof))` with the zone's current names plus the new one, so every existing name and proof survives, and the new name's challenge TXT is published before attach (r1 5).
+ 6. `attachDomain` for each new host. A failure here leaves DNS written and nothing detached; the caller retries the same call (attach is idempotent for the caller's own claim).
+
+- [ ] **Step 1: Write failing tests:** `TestPointUnpointedDomainWritesApexAndAttaches`, `TestPointRefusesAttachedDomainTouchesNothing` (Review Focus 5: own-account apex claim on another app, and a foreign claim on `www`; no SetManaged call, claims unchanged), `TestPointRefusesLinkedAndTemporaryDestinations` (no DNS write), `TestPointRefusedWhilePurchaseLive` (purchase paused in `registered`), `TestPointAfterPurgeSucceeds` (with Task 6's purge), `TestPointNotOwnedDomainIsNeutralNotFound`, `TestAddAddressPublishesProofThenAttaches` (with `DomainProof`: the new name's TXT is in the managed set before attach; the existing names and proofs remain), `TestAddAddressRefusedOnUnpointedDomain`, `TestAddAddressRefusesApexWWWAndOutsideDomain`.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPoint|TestAddAddress'`; expect FAIL.
- [ ] **Step 3: Implement.**
-- [ ] **Step 4: Run**; expect PASS.
-- [ ] **Step 5: Commit** `console: point a bought domain at an app; add an address under it`.
+- [ ] **Step 4: Run**; expect PASS. Also `-run 'DomainAttach'` (the factored destination check).
+- [ ] **Step 5: Commit** `console: point an unpointed bought domain at an app; add an address under it`.
- [ ] **Step 6: Astra task review** (claim ownership across apps and accounts).
### Task 8: Domains nav item, overview page and a domain's page
@@ -216,42 +239,43 @@ Waits on Paul's look at Task 1 (or his "go on" on the discussion).
**Files:**
- Create: `internal/console/accountdomainspage.go`, `internal/console/accountdomainspage_test.go`, `internal/console/templates/account_domains.html`, `internal/console/templates/account_domain.html`, `internal/console/accountdomains_copy.go`
-- Modify: `internal/console/mobilenav.go:37-54` (insert `{Key: "domains", Label: "Domains", Href: "/a/<sqid>/domains"}` between Apps and Fleet), `internal/console/templates/navindex.html` (`index_icon` branch for `domains`), `internal/console/routedecls.go`
+- Modify: `internal/console/mobilenav.go:37-54` (insert `{Key: "domains", Label: "Domains", Href: "/a/<sqid>/domains"}` between Apps and Fleet), `internal/console/templates/navindex.html` (`index_icon` branch for `domains`), `internal/console/routedecls.go`, `parity/parity.tsv` (two rows), then `make parity-doc`
- Modify: `internal/console/templates/app_settings.html:80-120` (link "All domains" to the account page; "Buy a domain" to `/a/{sqid}/domains/buy?app=<app>`)
**Interfaces:**
- Consumes: Task 5; `domainGuidance(host, s.dnsTargets(ctx))` (`view.go:182`) for registered-elsewhere records; the catalog's renew price for the account's currency (`DomainCatalog.TLDs[tld].Renew[currency]`).
-- Produces routes (members; `p.ActiveNav = "domains"`):
+- Produces routes (members; `p.ActiveNav = "domains"`; no `domainBuyReady` requirement):
- `GET /a/{sqid}/domains` → overview: one card per `domainCard`; header chip "Bought here" or "Registered elsewhere", an in-flight purchase links to its card; bought cards show the expiry date and next year's price; page actions "Buy a domain" (owners, when `domainBuyReady`) and "Add a domain you own" (asks for the app and host, posts to the existing app attach door). Owners also see the Saved contacts section (Task 9 builds its forms; this task renders the list).
- - `GET /a/{sqid}/domains/{domain}` → the domain's page in §11.6 order: Addresses (each with app and state, "Add address" for owners on bought domains); for bought domains Renewal (expiry, price, the card on file and "Change card" to the billing page, no switch) and Registered to (the registrant snapshot, no Change owner); DNS records shows the managed-records line only (customer records are Plan 4); no Transfer out card yet. Registered elsewhere: Addresses plus the records to set at the other registrar. An unknown or other account's domain → 404.
+ - `GET /a/{sqid}/domains/{domain}` → the domain's page in §11.6 order: Addresses (each with app, state, and a "Detach" form posting to that app's existing detach door for members it already allows; "Point at an app" when unpointed and "Add address" when pointed, owners only, bought domains only); for bought domains Renewal (expiry, price, the card on file and "Change card" to the billing page, no switch) and Registered to (the registrant snapshot, no Change owner); DNS records shows the managed-records line only (customer records are Plan 4); no Transfer out card yet. Registered elsewhere: Addresses plus the records to set at the other registrar. An unknown or other account's domain → 404.
- Accounts whose list is empty show an empty state with the two actions.
-- [ ] **Step 1: Write failing tests:** `TestDomainsNavBetweenAppsAndFleet`, `TestDomainsOverviewCards` (one bought card with expiry and price, one elsewhere card with two app rows and a Trash chip), `TestDomainsOverviewMemberSeesNoBuyOrContacts`, `TestDomainPageBoughtCardsInOrder`, `TestDomainPageElsewhereShowsRecordsToSet`, `TestDomainPageOtherAccount404`, `TestAppSettingsLinksToAccountDomains`.
+- [ ] **Step 1: Write failing tests:** `TestDomainsNavBetweenAppsAndFleet`, `TestDomainsOverviewCards` (one bought card with expiry and price, one elsewhere card with two app rows and a Trash chip), `TestDomainsOverviewWithoutBuyConfigured` (page renders, no Buy action), `TestDomainsOverviewMemberSeesNoBuyOrContacts`, `TestDomainPageBoughtCardsInOrder`, `TestDomainPageElsewhereShowsRecordsToSet`, `TestDomainPageOtherAccount404`, `TestAppSettingsLinksToAccountDomains`.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'DomainsNav|DomainsOverview|DomainPage|AppSettingsLinks'`; expect FAIL.
- [ ] **Step 3: Implement** against the Task 1 kit mockups; strings from `accountdomains_copy.go` (drafts).
-- [ ] **Step 4: Run**; expect PASS. Also `go test ./internal/console/ -run 'Styleguide|Nav'`.
+- [ ] **Step 4: Run**; expect PASS. Also `go test ./internal/console/ -run 'Styleguide|Nav|Parity'` and `go test ./internal/parity/`.
- [ ] **Step 5: Commit** `console: Domains page and a domain's own page`.
### Task 9: Three-step buy, saved contacts and pointing in the browser (risky: per-task review)
**Files:**
- Create: `internal/console/accountdomainbuy.go`, `internal/console/accountdomainbuy_test.go`, `internal/console/templates/account_domain_buy.html`
-- Modify: `internal/console/appdomainbuy.go` (old app-scoped GET routes redirect), `internal/console/routedecls.go`, `internal/console/accountdomains_copy.go`
-- Modify the route registers: `internal/console/linkedpolicy.go:73-80`, `claim_invariant_fixtures_test.go:2522-2528`, `claim_invariant_probes_read_test.go:256-258`, `svcroutes_test.go:238`, `apilinks_test.go:489`, `docs/parity.md:108`
+- Modify: `internal/console/appdomainbuy.go` (old app-scoped routes redirect), `internal/console/routedecls.go`, `internal/console/accountdomains_copy.go`
+- Modify the route registers: `parity/parity.tsv` (then `make parity-doc`), `internal/console/linkedpolicy.go:73-80`, `claim_invariant_fixtures_test.go:2522-2528`, `claim_invariant_probes_read_test.go:256-258`, `svcroutes_test.go:238`, `apilinks_test.go:489`
**Interfaces:**
- Consumes: Tasks 2, 4, 7; `domainBuyBrowserGate`'s checks (owner, CSRF on POST, `domainBuyReady`, `allowDomains`), generalised to the account (no app in the path).
- Produces routes (owners, CSRF on every POST):
- - `GET /a/{sqid}/domains/buy?step=name|app|pay&name=&app=` and `POST /a/{sqid}/domains/buy/check` (step 1 → quote → step 2), `POST /a/{sqid}/domains/buy` (step 3 → `startDomainPurchase` → Checkout). Step state travels in the query and hidden fields; the quote is re-checked at pay (Plan 1's `price_changed` path). `app=` preselects (from app Settings) and stays changeable; "Not yet" is `app=` empty with `notyet=1` so an empty value is never a silent default.
- - `GET /a/{sqid}/domains/purchases/{id}` and `.../status` (the Plan 1 card and JSON, account-scoped; another account's ID → 404 identical to unknown). Old `GET /a/{sqid}/apps/{app}/domains/purchases/{id}[/status]` and `GET .../apps/{app}/domains/buy` → 303 to the new paths (status keeps working for open pages: 303 is followed by `fetch`).
+ - `GET /a/{sqid}/domains/buy?step=name|app|pay&name=&app=&notyet=` and `POST /a/{sqid}/domains/buy/check` (step 1 → quote → step 2), `POST /a/{sqid}/domains/buy` (step 3 → `startDomainPurchase` → Checkout). Step state travels in the query and hidden fields; the quote is re-checked at pay (Plan 1's `price_changed` path). `app=` preselects (from app Settings) and stays changeable; "Not yet" is `notyet=1` with `app` empty, so an empty value is never a silent default.
+ - `GET /a/{sqid}/domains/purchases/{id}` and `.../status` (the Plan 1 card and JSON, account-scoped; another account's ID → 404 identical to unknown).
+ - Old app-scoped routes: `GET .../apps/{app}/domains/buy` → 303 to `/a/{sqid}/domains/buy?app=<app>`; `GET .../apps/{app}/domains/purchases/{id}[/status]` → 303 to the account paths (`fetch` follows a 303 for an open page); the old `POST .../domains/check` and `POST .../domains/buy` (stale forms only) → 303 to the new buy page with `app` preselected, starting nothing (r1 14).
- `POST /a/{sqid}/domains/contacts` (add), `POST /a/{sqid}/domains/contacts/{id}` (edit), `POST /a/{sqid}/domains/contacts/{id}/remove`.
- `POST /a/{sqid}/domains/{domain}/point` (`app`), `POST /a/{sqid}/domains/{domain}/addresses` (`host`, `app`).
- Step 3's "Registered to" is a searchable list of saved contacts with the most recently used preselected, ending with "Add a new contact" (fields in place, saved by the purchase).
-- [ ] **Step 1: Write failing tests:** `TestAccountBuyThreeStepsToCheckout` (name → app → pay; Checkout created with the chosen app), `TestAccountBuyNotYetNeedsExplicitChoice` (empty `app` without `notyet=1` re-shows step 2), `TestAccountBuyMemberAndServiceTokenRefused`, `TestAccountBuyCSRFRequired`, `TestOldPurchaseURLsRedirect`, `TestPurchaseCardOtherAccount404`, `TestContactsEditRemoveOwnerOnly`, `TestPointDoorOwnerOnlyAndCSRF`.
-- [ ] **Step 2: Run** `go test ./internal/console/ -run 'AccountBuy|OldPurchaseURLs|PurchaseCard|ContactsEdit|PointDoor'`; expect FAIL.
+- [ ] **Step 1: Write failing tests:** `TestAccountBuyThreeStepsToCheckout` (name → app → pay; Checkout created with the chosen app), `TestAccountBuyNotYetNeedsExplicitChoice` (empty `app` without `notyet=1` re-shows step 2), `TestAccountBuyMemberAndServiceTokenRefused`, `TestAccountBuyCSRFRequired`, `TestOldPurchaseURLsRedirect`, `TestOldBuyPostsRedirectAndStartNothing`, `TestPurchaseCardOtherAccount404`, `TestContactsEditRemoveOwnerOnly`, `TestPointDoorOwnerOnlyAndCSRF`.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'AccountBuy|OldPurchaseURLs|OldBuyPosts|PurchaseCard|ContactsEdit|PointDoor'`; expect FAIL.
- [ ] **Step 3: Implement**; strings in `accountdomains_copy.go` (drafts).
-- [ ] **Step 4: Run**; expect PASS. Also the register tests: `go test ./internal/console/ -run 'SvcRoutes|APILinks|ClaimInvariant|LinkedPolicy'`.
+- [ ] **Step 4: Run**; expect PASS. Also the registers: `go test ./internal/console/ -run 'SvcRoutes|APILinks|ClaimInvariant|LinkedPolicy|Parity'` and `go test ./internal/parity/`.
- [ ] **Step 5: Commit** `console: three-step buy, saved contacts and pointing at the account`.
- [ ] **Step 6: Astra task review** (security gates: owner checks, CSRF, neutral 404s, redirects).
@@ -261,24 +285,24 @@ Waits on Paul's look at Task 1 (or his "go on" on the discussion).
- Modify: `internal/console/apidomainbuy.go`, `internal/console/apidomainbuy_test.go`, `internal/console/routedecls.go` (+ the registers from Task 9)
- Modify: `domains_cli.go` (usage, `list` without `--app`), `domains_buy_cli.go`, `domains_buy_cli_test.go`, `domains_buy_copy.go`, `apimode.go` (beside `postDomainPurchase` at `:5011`)
- Create: `domains_account_cli.go`, `domains_account_cli_test.go`
+- Modify: `parity/parity.tsv` rows and the `clireg` nodes for `domains point` and `domains contacts` (the registry projection `parity/cli.tsv` regenerates from them; `parity/README.md` says how), then `make parity-doc`; the CLI reference page for `carlos domains` (find it with `git grep -ln 'carlos domains buy' -- docs/site`)
**Interfaces:**
- Consumes: Tasks 2, 4, 5, 7.
-- Produces API (persons only, `domainBuyAPIGate`'s checks; list is members, the rest owners):
- - `GET /api/cli/accounts/{account}/domains` → `{"domains":[{"domain","bought":bool,"expires"?,"purchase"?:{"id","state"},"addresses":[{"host","app","in_trash","state"}]}]}`.
- - `POST /api/cli/accounts/{account}/domains/purchases` body gains `"contact_id"`; `"app"` may be `""` only with `"not_yet": true`, else 422 `code:"app"`.
- - `POST /api/cli/accounts/{account}/domains/{domain}/point` `{"app"}`; `POST .../domains/{domain}/addresses` `{"host","app"}`.
- - `GET|POST /api/cli/accounts/{account}/domains/contacts`, `PUT|DELETE .../contacts/{id}`.
+- Produces API (persons only):
+ - **Read gate (r1 10):** `GET /api/cli/accounts/{account}/domains` uses a new `domainListAPIGate` (`apiPerson`, any member role, the domains rate limit), with no `domainBuyReady` requirement → `{"domains":[{"domain","bought":bool,"expires"?,"purchase"?:{"id","state"},"addresses":[{"host","app","in_trash","state"}]}]}`.
+ - Everything below keeps `domainBuyAPIGate` (owners, `domainBuyReady`): `POST .../domains/purchases` body gains `"contact_id"`; `"app"` may be `""` only with `"not_yet": true`, else 422 `code:"app"`. `POST .../domains/{domain}/point` `{"app"}`; `POST .../domains/{domain}/addresses` `{"host","app"}`; `GET|POST .../domains/contacts`, `PUT|DELETE .../contacts/{id}`. The purchase status answer gains `"pointed": bool` (false when `App` is empty).
- Produces CLI:
- `carlos domains buy <name> (--app <a> | --not-yet) [--contact <id> | --contact-file f]`: neither `--app` nor `--not-yet` is a usage error (my call: an unpointed domain is never a silent default). With neither contact flag, the most recently used saved contact is used and named in the confirm line; none saved falls back to Plan 1's prompt.
+ - **Waiting (r1 12):** `waitDomainPurchase` (`domains_buy_cli.go:271`) treats `done` with `pointed: false` as an immediate successful end: it prints the unpointed message (for `--not-yet`, and for `app_gone` naming that the app went away) and exits 0, without waiting for `domain_state`.
- `carlos domains list` without `--app`: the account overview, one block per domain, its addresses indented. With `--app`: unchanged.
- `carlos domains point <domain> --app <a>`; `carlos domains point <domain> --host docs.<domain> --app <a>` adds an address.
- `carlos domains contacts [list | add --file f | edit <id> --file f | remove <id>]`.
-- [ ] **Step 1: Write failing tests:** API: `TestAPIDomainsListGroups`, `TestAPIPurchaseNotYetExplicit`, `TestAPIContactsOwnerOnly`, `TestAPIPointOtherAccount404`. CLI (httptest + `newTestSession`): `TestDomainsBuyNeedsAppOrNotYet`, `TestDomainsBuyUsesLastContactAndNamesIt`, `TestDomainsListAccountOverview`, `TestDomainsPointPrintsState`, `TestDomainsContactsRoundTrip`.
+- [ ] **Step 1: Write failing tests:** API: `TestAPIDomainsListGroups`, `TestAPIDomainsListWithoutBuyConfigured` (members get the list when `domainBuyReady` is false), `TestAPIPurchaseNotYetExplicit`, `TestAPIContactsOwnerOnly`, `TestAPIPointOtherAccount404`. CLI (httptest + `newTestSession`): `TestDomainsBuyNeedsAppOrNotYet`, `TestDomainsBuyUsesLastContactAndNamesIt`, `TestDomainsBuyNotYetEndsAtDone`, `TestDomainsBuyAppGoneEndsAtDoneAndSaysSo`, `TestDomainsListAccountOverview`, `TestDomainsPointPrintsState`, `TestDomainsContactsRoundTrip`.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestAPIDomains|TestAPIPurchase|TestAPIContacts|TestAPIPoint'` and `go test . -run 'TestDomainsBuy|TestDomainsList|TestDomainsPoint|TestDomainsContacts'`; expect FAIL.
- [ ] **Step 3: Implement**; strings in `domains_buy_copy.go` (drafts).
-- [ ] **Step 4: Run**; expect PASS. `GOOS=darwin go build ./...` and `GOOS=windows go build ./...` (the CI cross-compile gate).
+- [ ] **Step 4: Run**; expect PASS. Also `go test ./internal/parity/ . -run 'Parity|CLIReg'`, `GOOS=darwin go build ./...` and `GOOS=windows go build ./...` (the CI cross-compile gate).
- [ ] **Step 5: Commit** `cli: account-wide domains list, buy without an app, point, contacts`.
### Task 11: Copy pass
@@ -287,14 +311,15 @@ Waits on Paul's look at Task 1 (or his "go on" on the discussion).
- Create: `docs/superpowers/specs/LUNA-COPY-BRIEF-DOMAINS-2A.md`, then `LUNA-COPY-RESULT-DOMAINS-2A.md`
- Modify: `internal/console/accountdomains_copy.go`, `internal/console/domainbuy_copy.go`, `domains_buy_copy.go`, `approved_domains_buy_copy_test.go`
-- [ ] **Step 1:** Write the brief: every new or changed key with where it appears (screen and kit mockup path), and the facts that must stay true: the customer is the registrant; editing a contact changes future purchases only; nothing renews yet (no "renews" wording); "Not yet" means paid and registered but not serving; no registrar or DNS host names.
+- [ ] **Step 1:** Write the brief: every new or changed key with where it appears (screen and kit mockup path), and the facts that must stay true: the customer is the registrant; editing a contact changes future purchases only; nothing renews yet (no "renews" wording); "Not yet" means paid and registered but not serving; moving a domain means detaching it first; no registrar or DNS host names.
- [ ] **Step 2:** Run the Luna pass (delegated copy review, as Plan 1's Task 11); apply the result table verbatim.
- [ ] **Step 3:** Pin approved strings; run `go test . ./internal/console/ -run Approved`; expect PASS.
- [ ] **Step 4: Commit** `domains: approved copy (Luna pass DOMAINS-2A)`.
-### Task 12: Merge, roll and witness
+### Task 12: Census, merge, roll and witness
-- [ ] **Step 1:** Whole-branch review: Astra and Fable on one brief (REVIEW-BRIEF-TEMPLATE, round history carried); `make code-health`; CI green on amadan.
-- [ ] **Step 2:** Merge (squash, subject under 80 characters), release and roll dev first per the release recipe; flagship with the next release, after its GO.
-- [ ] **Step 3: Witness on dev**, recorded on the discussion with timestamps: the Domains page for an account with a registered-elsewhere domain on two apps; a "Not yet" purchase (Stripe test card) reaching `done` with an empty zone; `carlos domains point` to `wakecheck` and the apex reaching `live`; a saved-contact edit followed by a second purchase showing a new handle and the first registrant unchanged.
-- [ ] **Step 4: Witness on flagship** after its roll: the Domains page for Paul's account and one existing bought domain's page (registrant shown, expiry and price, no switch).
+- [ ] **Step 1: Census (r1 9):** `make census-card`; write the CLAIMS file for every changed root-package unit (the CLI files of Task 10; no new reads of tenant-writable paths); `make census-propose NAME=plan-domains-2a CLAIMS=<file>`; Astra reviews the card per AGENTS.md "Getting a change approved"; record the verdict on #280 with the tip.
+- [ ] **Step 2:** Whole-branch review: Astra and Fable on one brief (REVIEW-BRIEF-TEMPLATE, round history carried); `make code-health`; CI green on amadan.
+- [ ] **Step 3:** Merge (squash, subject under 80 characters), release and roll dev first per the release recipe; flagship with the next release, after its GO.
+- [ ] **Step 4: Witness on dev**, recorded on the discussion with timestamps: the Domains page for an account with a registered-elsewhere domain on two apps; a "Not yet" purchase (Stripe test card) reaching `done` with an empty zone and the CLI exiting at `done`; `carlos domains point` to `wakecheck` and the apex reaching `live`; a saved-contact edit followed by a second purchase showing a new handle and the first registrant unchanged.
+- [ ] **Step 5: Witness on flagship** after its roll: the Domains page for Paul's account and one existing bought domain's page (registrant shown, expiry and price, no switch).
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md b/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md
new file mode 100644
index 000000000..a0d0652fb
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md
@@ -0,0 +1,133 @@
+Reviewed `d6352683aeb241bbd716327f0f2b06fad49272af`, round 1 of 3. Both authorities are ancestors of this commit. No files changed; no tests run.
+
+1. **P1 — Tasks 2 and 4: bind each purchase to an immutable contact version.**
+
+ Task 4, line 131 takes `Registrant` from the saved contact *at registration time*, although registration uses the previously stored `OwnerHandle` ([domainbuy.go:698](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:698)). Editing the contact between Checkout and registration therefore records a different registrant from the one submitted to the registrar. Removing it leaves no specified way to finish.
+
+ There is also a race: `EnsureContact` starts for contact A; an edit replaces A with B and clears its handle; `UseSavedContact` then installs A’s handle on B because the handle is empty. The next purchase silently registers using A.
+
+ **Fix:** freeze the contact and its version in the purchase before Checkout, persist the corresponding handle there, and build the registration snapshot from that purchase. Make handle writeback conditional on the saved contact still having the same version. Test edits and removals while registration or contact creation is paused.
+
+ **Fault family:** R12, contact data and registrar-handle identity must remain bound.
+
+2. **P1 — Tasks 2 and 4: existing purchases have no migration or fallback for `ContactID`.**
+
+ Task 2, line 86 migrates saved contacts and selected registration snapshots, but never populates existing purchases’ new `ContactID`. Existing journals contain `Contact` and `OwnerHandle` ([domainstore.go:36](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainstore.go:36)). Task 4 nevertheless requires saved-contact lookup during Checkout and registration.
+
+ A purchase awaiting contact creation or registration when this ships cannot follow that instruction. Existing registration rows in `registered` or crash-interrupted `registering` states are also excluded from the snapshot backfill; retrying `registeredPurchase` accepts the existing row without updating it ([domainbuy.go:738](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:738)).
+
+ **Fix:** specify a legacy-journal path using its frozen contact and handle, plus backfill for every existing registration with matching purchase evidence. Test migration and completion from each non-terminal state, including the insert-before-state-update crash window.
+
+ **Fault family:** persisted purchase compatibility across deployment.
+
+3. **P1 — Task 6: releasing claims after deleting the app’s rows is not retryable.**
+
+ Line 183 places claim cleanup after the app’s rows disappear. Today `purgeAppWithLifetimes` finishes by sweeping the bucket, including the trash marker ([lifetimes_purge.go:94](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/lifetimes_purge.go:94)); its caller deletes the app row afterwards ([ownership.go:605](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/ownership.go:605)). A subsequent purge requires that marker and returns `ErrNotTrashed` without it ([trash.go:178](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/release/trash.go:178)).
+
+ If claim deletion fails at the proposed point, the retry has lost its admission evidence and name reservation.
+
+ **Fix:** retire serving records first, release the matching custom-domain claims while retaining the trash marker and app row, then remove the marker and row. Specify the ordering for every caller and test failure after one successful claim deletion.
+
+ **Fault family:** purge must retain durable retry evidence until cleanup completes.
+
+4. **P1 — Tasks 4 and 6: account deletion can race purchase creation.**
+
+ The new refusal checks existing purchases, but `startDomainPurchase` releases the billing hold before inserting its purchase ([domainbuy.go:207](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:207)). Account deletion holds that billing lock through deletion ([ownership.go:139](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/ownership.go:139)) and writes the bucket tombstone before its final SQL check ([ownership.go:202](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/ownership.go:202)).
+
+ With app-less purchases, an otherwise deletable account can pass both count checks in the gap. The purchase can then be inserted after deletion, or make the final SQL refusal happen only after the account was tombstoned.
+
+ **Fix:** hold retirement exclusion through durable purchase creation, rechecking account validity under that exclusion. Keep the transaction-level refusal. Add an interleaving test paused immediately before purchase insertion.
+
+ **Fault family:** account retirement must exclude new financial obligations.
+
+5. **P1 — Tasks 3 and 7: added addresses cannot complete ownership proof.**
+
+ Task 7 adds an alias and calls attach, but does not specify publishing that address’s challenge TXT. Attach checks proof for the exact hostname ([domainpolicy.go:300](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainpolicy.go:300)). The current adapter explicitly rejects TXT records other than apex and `www` challenges ([zonehost.go:89](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/zonehost/zonehost.go:89)).
+
+ With `DomainProof` enabled, `docs.example.com` stays pending indefinitely. Merely adding its TXT to Task 7 would instead make `SetManaged` fail validation.
+
+ **Fix:** extend validation and managed-record ownership to the supported extra-name challenges, publish them before attach, and preserve existing names and proofs on subsequent replacements. Specify how adding an address to an unpointed zone obtains the apex targets required by Task 3. Test both cases with proof enabled.
+
+ **Fault family:** managed DNS must supply the proof required by attach.
+
+6. **P1 — Task 7: reject an unsuitable destination before detaching working addresses.**
+
+ Line 204 checks only that the target belongs to `AppsIn`, then detaches the old claims before invoking attach. `AppsIn` excludes Trash but includes linked and temporary apps ([store.go:2060](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/store.go:2060)); attach refuses those destinations ([domainattach.go:134](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainattach.go:134)).
+
+ Pointing a working domain at such an app therefore removes its working bindings and then returns a predictable refusal.
+
+ **Fix:** specify shared destination admission before any detach or DNS write, with lifecycle revalidation under the appropriate locks. Define recovery for failures after destructive work starts. Test that linked and temporary destinations leave existing claims and DNS untouched.
+
+ **Fault family:** a refused move must not destroy the current working binding.
+
+7. **P1 — Tasks 4 and 7: the proposed mutex excludes the purchase worker.**
+
+ A registration becomes visible before capture ([domainbuy.go:738](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:738)). Task 7 allows pointing any registration and locks only pointing/address calls. The purchase worker subsequently attaches using its stored app ([domainbuy.go:579](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:579)).
+
+ An owner can point the domain at B while its purchase still targets A. Completion then repeatedly conflicts with B. If A goes away, Task 4 instead clears the zone after the successful point to B.
+
+ **Fix:** define one authority for the desired binding. The smallest change is to refuse pointing/address changes while the purchase is non-terminal, checking that condition under exclusion shared with purchase completion. Test a paused `registered` purchase and a concurrent point request.
+
+ **Fault family:** purchase completion and manual pointing must not issue conflicting changes.
+
+8. **P1 — Task 4: the journal still depends on an app that may have disappeared.**
+
+ Line 133 retains the app mutation for non-empty `App`, including the transition that clears a gone app. That mutation requires the app’s identity before invoking its callback ([app_mutation_runner.go:64](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/hostops/app_mutation_runner.go:64)). A purged app cannot provide it. `FreeWhenNoApp` does not authorize updating the old non-empty row: the SQL gate checks both OLD and NEW ([store_gate.go:646](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/store_gate.go:646)).
+
+ The empty-app instruction also bypasses the current journal re-read and revision check ([domainbuy.go:424](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:424)), allowing stale work to reach external effects before its eventual CAS fails.
+
+ **Fix:** specify account-owned journal mutation authority independently of app admission, preserving the account and revision checks. Keep app authority around actual attachment. Test gone-app completion with the SQL gate armed and stale app-less snapshots producing no effects.
+
+ **Fault family:** purchase-journal authority must survive app lifecycle changes without weakening stale-work rejection.
+
+9. **P1 — Tasks 8–12: required parity and source-census updates are missing.**
+
+ Task 9 lists `docs/parity.md` as a register, but the authoritative input is `parity/parity.tsv`. New browser routes without rows fail [parity_test.go:48](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/parity_test.go:48); editing the generated page directly fails [repo_test.go:94](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/parity/repo_test.go:94).
+
+ Task 10 also changes root-package source, but Task 12 supplies no census proposal or approval step. The census rejects changed source envelopes ([plan14_root_reads_test.go:677](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/provision/plan14_root_reads_test.go:677)).
+
+ **Fix:** explicitly include parity rows, command projection generation, relevant CLI documentation, and their targeted checks. Add the census card, claims, proposal and independent approval to the landing sequence.
+
+ **Fault family:** implementation must satisfy the enforced route and source inventories.
+
+10. **P2 — Task 10: separate domain-list access from buying readiness.**
+
+ Line 267 imports `domainBuyAPIGate` checks while making listing available to members. That gate also requires `domainBuyReady` ([apidomainbuy.go:24](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/apidomainbuy.go:24)). Consequently, an account with domains registered elsewhere receives 404 from the new CLI overview on a deployment without buying configured.
+
+ **Fix:** define the member/person read gate separately; apply buying readiness to purchase operations. Test listing with buying disabled.
+
+ **Fault family:** account-domain visibility must not depend on registrar configuration.
+
+11. **P2 — Task 5 / Review Focus 4: the expected registrable domain is wrong.**
+
+ Line 37 requires `shop.example.co.uk` to remain its own card, while line 165 requires `EffectiveTLDPlusOne`. The pinned implementation returns one label above `co.uk`, namely `example.co.uk` ([list.go:173](/home/paulca/go/pkg/mod/golang.org/x/net@v0.62.0/publicsuffix/list.go:173)).
+
+ **Fix:** correct the example and test expectation to `example.co.uk`, retaining `shop.example.co.uk` as its address.
+
+ **Fault family:** grouping must follow the approved public-suffix rule.
+
+12. **P2 — Task 10: define immediate CLI completion for unpointed purchases.**
+
+ The current waiter remains active after `done` until `domain_state == live`, then eventually prints the background-completion message ([domains_buy_cli.go:291](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/domains_buy_cli.go:291)). A successful `--not-yet` purchase can never reach that state.
+
+ **Fix:** make `done` with empty `App` an immediate successful terminal result with the approved unpointed message. Test both explicit “Not yet” and `app_gone`.
+
+ **Fault family:** CLI completion must reflect the purchase’s intended terminal state.
+
+13. **P2 — Global Constraints / Task 5: the cache does not eliminate bucket listings.**
+
+ Line 27 promises no fresh bucket list per request. `ListWithUnread` performs `ListMod` on every call ([claimcache.go:147](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/domains/claimcache.go:147)). Calling `settingsDomains` once per app adds further claim listings and alias/warm reads ([appsettings.go:791](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/appsettings.go:791)).
+
+ **Fix:** specify a shared snapshot if zero additional requests is required. Otherwise correct the budget and fold claims, readings and warm records once per overview request.
+
+ **Fault family:** request-budget claims must match the actual cache contract.
+
+14. **P2 — Tasks 4, 9 and 10: explicitly replace the remaining legacy-contact readers.**
+
+ Task 2 promises no `domain_contacts` reads after Task 4, but Task 4 limits door edits to `startDomainPurchase` callers. `checkDomainBuy` still obtains its default country from `DomainContact` ([apidomainbuy.go:43](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/apidomainbuy.go:43)); the old browser check also reads it ([appdomainbuy.go:157](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/appdomainbuy.go:157)).
+
+ **Fix:** name every reader’s replacement or removal, including quote-country selection and old POST compatibility. Test that editing/removing the last contact cannot leave quote selection using the obsolete row.
+
+ **Fault family:** saved-contact selection must have one authoritative source.
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-domains-plan-2a-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-domains-plan-2a-R2.md
new file mode 100644
index 000000000..1e9749acd
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-domains-plan-2a-R2.md
@@ -0,0 +1,90 @@
+# Review brief: domain registration Plan 2a (domains at the account level), round 2 of 3
+
+Repo carlos/platform, branch `plan-domains-2b`, commit named in the reviewer's prompt.
+Under review: `docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md`.
+Authorities: `docs/superpowers/specs/2026-11-01-domain-registration-design.md`
+(revision 4, approved, merged 0b3098c; §11 is what this plan builds), Plan 1
+`docs/superpowers/plans/2026-11-01-domain-registration-1-buy.md` (merged
+20c867c), `AGENTS.md`. Do not review against unmerged branches; if this work
+needs one, say so as a P1 and stop.
+
+You are an independent reviewer. Read the plan, then the code it names, and
+check every claim against that code. You are reading it as the builder: an
+engineer who has not seen this codebase will implement each task from its
+text alone.
+
+## Fixed: do not re-argue
+
+- Paul's rulings R1-R12 in the spec (§3, §11.2) and the builder-check calls
+ B1-B4, C1-C3 (§10, §11.10). Report only mechanisms that fail to honour them.
+- The split of Plan 2 into 2a (this) and 2b (reconcile, apex reconverge,
+ alerts), and transfers in coming after Plan 3.
+- The host lifecycle claim work is shelved (`CARLOS_HOST_CLAIM` inert in
+ production); the SQL gate and `claimAppMutation` paths must still compile
+ and stay correct, but are not the production path.
+
+## What to check
+
+1. The plan's storage finding: purchases, registrations and contacts are
+ already in console.db, and only the gate (`store_gate.go:231`), the
+ per-app mutation (`domainbuy.go:414`) and the doors are app-bound. Is
+ anything else app-bound that the plan misses?
+2. R12: editing a saved contact must never change a registration. Check the
+ plan's rule against `internal/registrar/openprovider/client.go:136-155`
+ and every path that calls `EnsureContact` or reads `domain_contacts`.
+3. Task 4: optional app and "app gone" handling in the purchase state
+ machine. Can any path now take money without a registration, register
+ without an authorised payment, or attach to an app the account no longer
+ has? Is `purchaseMutation` with an empty app safe?
+4. Task 6: releasing a purged app's claims (`lifetimes_purge.go`), and the
+ account-deletion refusal. Is the purge change correct and retryable, does
+ it touch claims it should not (platform names, aliases, catch-alls,
+ another app's), and is every account-deletion door covered?
+5. Task 7: moving a claim between apps of one account; never touching
+ another account's claim; ordering of SetManaged and attach; the
+ per-account mutex.
+6. Task 9 and 10: owner and CSRF gates, neutral 404s, the old-URL
+ redirects, and the route registers (would a census test fail?).
+7. Task right-sizing, interface consistency between tasks, and whether each
+ step lets the builder write exactly one reasonable thing.
+
+## Round 2
+
+Earlier rounds: round 1, Astra, on d6352683:
+`docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a.md` (9 P1, 5 P2,
+all accepted; the plan marks each change **(r1 N)** and lists round 1 in its
+"Review history" line).
+
+First give one line per P1 and P2 from round 1: resolved, partly, or not.
+Carry every unresolved or partly resolved finding forward at its current
+severity, then add new findings. The verdict covers everything outstanding,
+earlier rounds included.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work.
+ Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The
+ census, and review of any newly changed security, root, termination
+ or production-storage behaviour, still check the fix; see AGENTS.md,
+ "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for
+ another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not
+raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem,
+the evidence (file:line, verified), the failure scenario, a concrete
+fix and the invariant or trust boundary it breaks (that is its fault
+family). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another
+ round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of
+your own. Do not run the full test suites.