carlos / platform Public

plan 2a: record Task 2 build rulings (ctx, RegistrarHandle)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 21692dda03403aedd98ec76ede514a8b5b423d6f parent cc53d8e
1 file changed, +2 −1
  • docs/superpowers/plans/2026-11-19-domain-registration-2a-account-domains.md +2 −1

CI failed — 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 a72964583..376668232 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
@@ -90,6 +90,7 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
ContactID string // "" on purchases made before this plan
ContactVersion int64
```
+ **Build ruling (Task 2):** every Store method above takes `ctx context.Context` first and uses the `*Context` database calls; the field is `RegistrarHandle`, not `Handle` (`TestClaimConsoleMuxHasOneRegistrar` refuses a non-test selector named `Handle`). Later tasks use these forms.
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.
@@ -142,7 +143,7 @@ The approved mockups (`docs/superpowers/mockups/domains-account/`) predate the k
// 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 (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.
+ - **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 `RegistrarHandle`. 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).