carlos / platform Public

plan 2a: fold in Astra round 3 (4 P1, 2 P2)

Release partial attaches on an app-gone finish; every purge branch
releases claims; domain_meta classified; purchaseContactSelection;
person-owner pointing API; account-path Checkout returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 40ca6f788706092df16c57890b4a7d95024d06e7 parent 1252e9d
2 files changed, +109 −15
  • docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md +16 −15
  • docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a-R3.md +93 −0

CI passed — run details

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 bc6467014..1c4cedfdc 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
@@ -14,7 +14,7 @@
**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; each change is marked **(r1 N)**. Astra round 2 on 6108a068 (`CODEX-FINDINGS-domains-plan-2a-R2.md`): NOT READY, 4 P1 and 3 P2; three fault families repeated (proofs for extra names, pointing admission and retry, armed-gate purchases), so stopping rule 2 applied. **Paul's cut, 2026-11-19:** (a) buying is off while `CARLOS_HOST_CLAIM` is on; (b) extra addresses under a bought domain move to Plan 4; (c) pointing writes the zone's canonical records and then runs the existing app attach door's own admission and attach, with no new pointing logic. Changes from round 2 are marked **(r2 N)**. Round 3 is the last.
+**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; each change is marked **(r1 N)**. Astra round 2 on 6108a068 (`CODEX-FINDINGS-domains-plan-2a-R2.md`): NOT READY, 4 P1 and 3 P2; three fault families repeated (proofs for extra names, pointing admission and retry, armed-gate purchases), so stopping rule 2 applied. **Paul's cut, 2026-11-19:** (a) buying is off while `CARLOS_HOST_CLAIM` is on; (b) extra addresses under a bought domain move to Plan 4; (c) pointing writes the zone's canonical records and then runs the existing app attach door's own admission and attach, with no new pointing logic. Changes from round 2 are marked **(r2 N)**. Astra round 3 on 1252e9db (`CODEX-FINDINGS-domains-plan-2a-R3.md`): NOT READY, 4 P1 (not one cause: two lifecycle cleanup gaps, one unclassified table, one name clash) and 2 P2, all accepted and fixed below as **(r3 N)**; one P3 (alias attach can race purge, an existing attach-door defect) goes on the follow-up list. The three-round budget is spent; a fourth round needs Paul's go.
## Global Constraints
@@ -90,13 +90,13 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
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, 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").
+ 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"), and so is `domain_meta` ("domain migration bookkeeping, keyed by name; names no account or app") (r3 3).
One-time backfills inside `migrateDomains`: each `domain_contacts` row becomes a saved contact (same handle, version 1, `last_used = updated_at`), in one transaction that also inserts the row `('saved_contacts_backfilled', '1')` into a new `domain_meta(key TEXT PRIMARY KEY, value TEXT NOT NULL)` table; the backfill runs only when that row is absent, so an edited or removed contact never comes back on restart (r2 7). 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), `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), `TestMigratedContactRemovalSurvivesReopen` (migrate, remove the saved contact, close and reopen the store: still gone), `TestDomainObligations`, `TestAppLessPurchaseRowAllowedByGate` (the gate's classification harness that covers `cli_tokens`' `FreeWhenNoApp`, found with `git grep -n FreeWhenNoApp -- '*_test.go'`, accepts an `app=''` purchase row).
- [ ] **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 4: Run**; expect PASS. Also `go test ./internal/console/ -run 'StoreGate|ClaimSQL'` (the gate's own classification tests, including `TestClaimSQLTableCensus`, which fails on any unclassified table).
- [ ] **Step 5: Commit** `console: versioned saved domain contacts, registrant snapshot, app-less purchases`.
### Task 3: Zone host: unpointed zones and one canonical pointed set
@@ -130,11 +130,11 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
- Consumes: Task 2 store methods; Task 3 `ManagedSet`, `ManagedFor`.
- Produces:
```go
- type purchaseContact struct {
+ type purchaseContactSelection struct {
ID string // a saved contact of the account
New *registrar.Contact // or a new one, saved by the purchase
- } // exactly one set
- func (s *Server) startDomainPurchase(ctx context.Context, acct *Account, app, name string, contact purchaseContact, principal string, confirmed domainreg.Quote) (*DomainPurchase, string, *domainreg.Quote, *doorRefusal)
+ } // exactly one set; not `purchaseContact`, already a test helper (`domainbuy_test.go:61`, r3 4)
+ func (s *Server) startDomainPurchase(ctx context.Context, acct *Account, app, name string, contact purchaseContactSelection, 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 ManagedFor(p.Domain, apex, proof when DomainProof).
@@ -144,14 +144,15 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
Behaviour changes, each its own CAS transition as in Plan 1:
- **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.
+ - **Checkout return URLs (r3 6):** `domainPurchaseURL` (`appdomainbuy.go:83`) becomes `domainPurchaseURL(account, id string)` returning `/a/{sqid}/domains/purchases/{id}`; every caller (Checkout's success and cancel URLs at `domainbuy.go:384`, the card links) switches. Checkouts prepared before this ship keep their old app path, which Task 9 redirects without needing the app.
- **`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): `SetManaged(zone, ManagedSet{})`, then `done` with `App = ""` and `Reason = "app_gone"`. Buying is off while the HostClaim gate is on (Global Constraints), so this never runs against an armed gate (r2 4).
+ - **`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): first release anything an earlier attempt attached (r3 1): for the apex and `www.` + domain, `s.detachDomainClaim(ctx, host, acct.Sqid, p.App)` (owner-checked, so another holder's claim is never touched; idempotent), and `provision` first-route records for those hosts under the old app if `attachDomainAs` wrote any (`domainattach.go:1-50`; the builder finds the matching removal the detach door uses). Any failure leaves the purchase `captured` for the next pass. Then `SetManaged(zone, ManagedSet{})`, then `done` with `App = ""` and `Reason = "app_gone"`. Buying is off while the HostClaim gate is on (Global Constraints), so this never runs against an armed gate (r2 4).
- **Switch (r2 4):** `domainBuyReady()` and `domainPurchaseReady()` return false when `s.cfg.HostClaim`; `cmd/console` logs one line at boot naming `CARLOS_HOST_CLAIM` as the reason.
- **`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), `TestBuyingOffWhileHostClaimOn` (doors absent, the pass advances nothing, a live purchase is unchanged), `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 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), `TestPurchasePartialAttachThenTrashReleasesClaim` (apex attach succeeds, `www` fails, the app goes to Trash; the next pass detaches the apex claim, a first detach failure keeps `captured` and the pass after finishes; a foreign `www` claim is untouched), `TestBuyingOffWhileHostClaimOn` (doors absent, the pass advances nothing, a live purchase is unchanged), `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 `purchaseContactSelection{New: &c}` in place of the old contact argument.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPurchase|TestStart|TestContact|TestLegacyPurchase|TestRegisteredRetry|TestStale|TestBuyingOff'`; expect the new tests to FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run** the same, plus `-run 'DomainBuy|APIDomain'`; expect PASS.
@@ -200,11 +201,11 @@ Today the claims-off purge (`purgeAppWithLifetimes`, `lifetimes_purge.go:40`) le
**Interfaces:**
- 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.
+ - **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. The release is one helper, `func (s *Server) releaseAppDomainClaims(ctx context.Context, sqid, app string) error`, called in every purge branch before the call that removes the trash marker (r3 2): inside `purgeAppWithLifetimes` before `release.PurgeAppExcept`; and on the lifetimes-off branches, before `release.PurgeApp` in the purge door (`ownership.go:568`), before `release.PurgeAppIfTrashedAt` in the trash sweep (`lifetimes_purge.go:244`) and in the expiry pass (`expirypass.go:247`). On error each branch stops before purging and reports as its existing purge errors do, so the next attempt retries with the marker and row intact.
- **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, 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 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), `TestLegacyPurgeBranchesReleaseClaims` (lifetimes off: the purge door, the trash sweep and the expiry pass each release the claims before the marker goes), `TestAccountDeletionRefusedWhileHoldingRegistrations` (flash names the domain; no tombstone written; account row present), `TestAccountDeletionRefusedWithLivePurchase`, `TestStoreDeleteAccountRechecksObligations`.
+- [ ] **Step 2: Run** `go test ./internal/console/ -run 'PurgeReleases|PurgeDomainDetach|LegacyPurgeBranches|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`.
@@ -230,9 +231,9 @@ Paul's cut (r2): pointing adds no admission or retry logic of its own. It is an
1. `domain` must be one of the account's registrations (`DomainRegistrationFor`), else the neutral not-found refusal; and 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 twice, so this check needs no lock shared with the purchase pass (r1 7).
2. `SetManaged(zone, ManagedFor(domain, apex, proof when DomainProof))`. The canonical pointed set, so a repeat is a no-op. If a later step refuses, the zone answers with the edge addresses for a name no app claims, which serves nothing (the same as any unclaimed host).
3. `attachDomain(ctx, acct, app, domain, "", "", principal)`, then the same for `www.` + domain, exactly as the purchase engine's `captured` step does. The first refusal is returned as the attach door returns it. A retry of the same call completes a partial or pending attach (r2 3).
- - CLI API twin: `POST /api/cli/apps/{account}/{app}/domains/point` `{"domain"}`, gated as the per-app attach API door (`postDomainAttachFull`'s server side, found from `apimode.go:4890-5206`'s path), calling `pointBoughtDomain`.
+ - CLI API twin (r3 5): `POST /api/cli/apps/{account}/{app}/domains/point` `{"domain"}`. Caller permissions are NOT the attach API's (that route admits service roles, `routedecls.go:830`): the route is registered service-closed (`svcrole.Set{}`), and the handler requires `apiPerson`, the account owner role, the app in this account (the same membership check `domainsGate` makes, `apidomains.go:267`) and `domainBuyReady`, then calls `pointBoughtDomain`, which reaches the same `attachDomain` destination admission as the browser door.
-- [ ] **Step 1: Write failing tests:** `TestPointUnpointedDomainWritesApexAndAttaches`, `TestPointOtherAppsClaimRefusedNothingDetached` (an own-account claim on app `b` for the apex, a foreign claim for `www`: the attach door's neutral refusal, both claims unchanged), `TestPointRetryCompletesPartialAttach` (the first call's `www` attach fails; the second call attaches `www`, the apex claim unchanged, one canonical `SetManaged` each time), `TestPointGateMatchesAttachDoor` (member 404, service token refused, missing app 404, linked app refused, no CSRF 403: the same answers as `POST .../domains/attach`), `TestPointRefusedWhilePurchaseLive` (purchase paused in `registered`), `TestPointAfterPurgeSucceeds` (with Task 6's purge), `TestPointNotOwnedDomainIsNeutralNotFound`.
+- [ ] **Step 1: Write failing tests:** `TestPointUnpointedDomainWritesApexAndAttaches`, `TestPointOtherAppsClaimRefusedNothingDetached` (an own-account claim on app `b` for the apex, a foreign claim for `www`: the attach door's neutral refusal, both claims unchanged), `TestPointRetryCompletesPartialAttach` (the first call's `www` attach fails; the second call attaches `www`, the apex claim unchanged, one canonical `SetManaged` each time), `TestPointGateMatchesAttachDoor` (member 404, service token refused, missing app 404, linked app refused, no CSRF 403: the same answers as `POST .../domains/attach`), `TestPointRefusedWhilePurchaseLive` (purchase paused in `registered`), `TestPointAfterPurgeSucceeds` (with Task 6's purge), `TestPointNotOwnedDomainIsNeutralNotFound`, `TestPointAPIPersonOwnerOnly` (publish and instance tokens refused, member refused, owner allowed).
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'TestPoint'`; expect FAIL.
- [ ] **Step 3: Implement.**
- [ ] **Step 4: Run**; expect PASS. Also `-run 'DomainAttach'`.
@@ -273,11 +274,11 @@ Waits on Paul's look at Task 1 (or his "go on" on the discussion).
- Produces routes (owners, CSRF on every POST):
- `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).
+ - 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). These redirect routes check only account membership and the purchase's account, never that `{app}` still exists, so a Checkout return after the app was purged still lands (r3 6); 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`.
- 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`, `TestOldBuyPostsRedirectAndStartNothing`, `TestPurchaseCardOtherAccount404`, `TestContactsEditRemoveOwnerOnly`.
+- [ ] **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` (including after the app is purged), `TestNotYetCheckoutReturnsToAccountPath`, `TestOldBuyPostsRedirectAndStartNothing`, `TestPurchaseCardOtherAccount404`, `TestContactsEditRemoveOwnerOnly`.
- [ ] **Step 2: Run** `go test ./internal/console/ -run 'AccountBuy|OldPurchaseURLs|OldBuyPosts|PurchaseCard|ContactsEdit'`; expect FAIL.
- [ ] **Step 3: Implement**; strings in `accountdomains_copy.go` (drafts).
- [ ] **Step 4: Run**; expect PASS. Also the registers: `go test ./internal/console/ -run 'SvcRoutes|APILinks|ClaimInvariant|LinkedPolicy|Parity'` and `go test ./internal/parity/`.
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a-R3.md b/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a-R3.md
new file mode 100644
index 000000000..9e03b5b85
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-domains-plan-2a-R3.md
@@ -0,0 +1,93 @@
+- R2-1 **P1: resolved** — `ManagedFor` now receives the domain.
+- R2-2 **P1: cut** — pointing inherits the existing attach door’s destination admission.
+- R2-3 **P1: resolved** — the new blanket claim refusal is removed; retries reach `attachDomain`.
+- R2-4 **P1: cut** — buying and purchase advancement stop while `HostClaim` is enabled.
+- R2-5 **P2: resolved** — the test now expects `1 + N` claim listings.
+- R2-6 **P2: cut** — extra names are deferred; the pointed set contains only apex and `www`.
+- R2-7 **P2: resolved** — backfill completion is recorded atomically and tested across reopening.
+- R1-5 **P1, previously partly: cut** — extra-name proofs are deferred; retained proofs have the required domain input.
+- R1-6 **P1, previously partly: cut** — no automatic detaching or separate destination/retry policy remains.
+- R1-8 **P1, previously partly: cut** — armed-gate recovery is removed; app-less revision checks are retained.
+- R1-13 **P2, previously partly: resolved** — implementation and request-budget test agree.
+
+Reviewed `1252e9dbc44c9ee80277cb602ff9eb80a1376faf`, round 3 of 3. Both authority commits are ancestors. No files changed, subagents spawned or tests run.
+
+1. **P1 — Task 4: an “app gone” completion can retain a partially attached claim.**
+
+ [Plan:149](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:149) clears the managed DNS set and finishes with an empty `App` when the original app is in Trash. It specifies no cleanup of attachment already completed.
+
+ **Failure:** apex attachment succeeds, `www` attachment fails, and the purchase remains `captured`. This is an existing supported intermediate state ([domainbuy.go:584](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:584)). The owner then trashes the app. Trash writes the marker and updates the app row without releasing its claims ([appsettings.go:1454](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/appsettings.go:1454)). On retry, Task 4 clears DNS and declares the purchase unpointed, but the apex remains claimed by the trashed app. Pointing at another app consequently refuses.
+
+ **Fix:** specify retryable cleanup of this purchase’s existing apex/`www` attachments, including any first-route records, before clearing `App` and declaring `done`. Preserve other holders’ claims. Test partial attach → Trash → completion, including cleanup failure and retry.
+
+ **Fault family:** an unpointed terminal purchase must have no remaining attachment effects.
+
+2. **P1 — Task 6: legacy purge paths bypass the new claim cleanup.**
+
+ [Plan:203](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:203) puts cleanup only inside `purgeAppWithLifetimes`. However, `HostClaim` being off does not imply lifetimes are on ([lifetimes.go:155](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/lifetimes.go:155)).
+
+ **Failure:** before lifetime cutover, the purge door calls `release.PurgeApp` directly ([ownership.go:568](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/ownership.go:568)); the trash sweep and expiry pass likewise take legacy branches ([lifetimes_purge.go:244](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/lifetimes_purge.go:244), [expirypass.go:247](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/expirypass.go:247)). They remove the marker and app row while leaving domain claims behind. C2 and “point after purge” still fail in that supported mode.
+
+ **Fix:** cover every supported purge branch with the same claim-cleanup-before-marker ordering, or explicitly refuse affected purges before destructive work when lifetimes are off. Test both modes.
+
+ **Fault family:** every completed purge must release its custom-domain claims before surrendering retry evidence.
+
+3. **P1 — Task 2: `domain_meta` is missing from the SQL gate classification.**
+
+ [Plan:93–94](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:93) classifies `domain_saved_contacts` and changes `domain_purchases`, then introduces another table, `domain_meta`, without classifying it.
+
+ **Failure:** implementing those instructions makes gate arming fail: `claimSQLCensus` rejects every unclassified table ([store_gate.go:401](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/store_gate.go:401)). `TestClaimSQLTableCensus` therefore fails as well ([store_gate_test.go:687](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/store_gate_test.go:687)). Disabling purchases under `HostClaim` does not remove this schema requirement.
+
+ **Fix:** explicitly classify `domain_meta` as NonApp migration bookkeeping and include it in the gated-store migration check.
+
+ **Fault family:** every migrated table must have an enforced SQL-gate classification.
+
+4. **P1 — Task 4: the proposed `purchaseContact` type conflicts with an existing test helper.**
+
+ The exact type introduced at [plan:133](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:133) already exists as a function name in the same package: [domainbuy_test.go:61](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy_test.go:61).
+
+ **Failure:** adding the prescribed type makes the console test package fail to compile with a redeclaration. Wrapping existing contact arguments in the new type does not remove the conflicting helper declaration.
+
+ **Fix:** name the new type `purchaseContactSelection`, or explicitly rename the existing helper and all its callers.
+
+ **Fault family:** planned interfaces must compile alongside the existing package and tests.
+
+5. **P2 — Tasks 7 and 10: the pointing API has contradictory permission instructions.**
+
+ [Plan:233](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:233) says to copy the attach API gate. Global Constraints require owner-only pointing, and Task 10 says its APIs are person-only.
+
+ The existing attach API deliberately accepts service credentials: its route permits `Publish` and `Instance` roles ([routedecls.go:830](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/routedecls.go:830)); `domainsGate` establishes app access and rate limits without requiring an owner/person ([apidomains.go:267](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/apidomains.go:267)).
+
+ **Failure:** copying that gate admits callers the plan elsewhere excludes. Implementing owner/person-only access instead contradicts the literal “same gate” instruction.
+
+ **Fix:** distinguish destination admission from caller permissions. Explicitly require `apiPerson`, account owner, app membership and `domainBuyReady` for pointing, with a service-closed route registration and API-specific permission tests.
+
+ **Fault family:** browser and API permissions for managing a bought zone must agree.
+
+6. **P2 — Tasks 4 and 9: explicitly migrate Checkout’s app-bound return URL.**
+
+ Task 9 specifies new pages and old-route redirects ([plan:275](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md:275)), but does not identify the URL producer embedded in prepared payment requests.
+
+ Checkout still builds both return URLs through `domainPurchaseURL` ([domainbuy.go:384](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/domainbuy.go:384)), whose path requires an app ([appdomainbuy.go:83](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/appdomainbuy.go:83)).
+
+ **Failure:** retaining that producer for `--not-yet` generates `/apps//domains/purchases/...`, which cannot match the promised old app-route redirect. Previously prepared Checkouts also retain their old app paths after the app disappears.
+
+ **Fix:** explicitly change new Checkout return URLs to the account purchase path. Require old purchase redirects to authenticate the account/purchase without requiring the original app to remain live. Test both app-less Checkout URLs and a legacy Checkout return after purge.
+
+ **Fault family:** purchase navigation must survive absence or deletion of the chosen app.
+
+7. **P3 — Follow-up only: the existing alias attach path can race purge.**
+
+ Alias attachment writes through `attachDomainClaim` without the app lifecycle lock ([claim_alias.go:42](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/claim_alias.go:42)); purge holds that lock ([ownership.go:426](/home/paulca/.cache/tmp/claude-1001/domains-plan-2/internal/console/ownership.go:426)).
+
+ **Failure:** purge can pass its cleanup while a previously admitted alias attach subsequently writes a claim.
+
+ **Fix:** track shared lifecycle exclusion and revalidation for the existing attach door separately. This does not block this plan under Paul’s cut.
+
+ **Fault family:** attachment authority must remain valid through the claim write.
+
+The P1s do **not** share one cause. Findings 1–2 concern incomplete lifecycle cleanup; findings 3–4 are independent schema and compilation failures. Refusing legacy-mode purges would remove finding 2’s case. Cutting purchase-time attachment and completing every purchase unpointed would remove finding 1’s case. Neither cut fixes the schema or naming defects.
+
+Round 3 is exhausted; a fourth review requires Paul’s go.
+
+**NOT READY**
\ No newline at end of file