| new file mode 100644 |
| index 000000000..1d0724b20 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-28-domain-resale-design.md |
| @@ -0,0 +1,963 @@ |
| +# Domain resale: an app sells domains to its own customers |
| + |
| +Status: revision 4, 2026-11-29. Draft for Paul's review. Branch |
| +`design-domain-resale`, off `main` at `60f0dc35`. Discussion: |
| +carlos/platform #1483 (the request and Paul's rulings); patrix/patrix |
| +discussion 23. Review budget: at most three rounds (AGENTS.md stopping |
| +rules). Round 1 (Astra, `38cf6052`): five P1, three P2, resolved in |
| +revision 2. Round 2 (Astra, `55b1c805`): two P1, two P2, resolved in |
| +revision 3. Round 3 (Astra, `a5cb7fa0`): one P1, resolved in this revision |
| +by Paul's ruling P8. The budget is spent; a scoped fourth check of this |
| +revision's diff runs only with Paul's go (§14). |
| + |
| +Builds on `2026-11-01-domain-registration-design.md` (revision 5, |
| +approved; "registration spec" below), `2026-11-19-platform-accounts-design.md` |
| +("platform accounts spec") and `2026-08-18-service-principals-design.md`. |
| +Depends on renewals, which are being planned as their own slice from |
| +registration spec §4.2 (branch `domain-renewals`). This spec does not |
| +redesign renewal: it uses renewal's off-session charge and auto-renew |
| +flag, and says who else may switch that flag. Code references are to |
| +`60f0dc35` and are starting points; re-check each. |
| + |
| +## 1. Why |
| + |
| +Farshad asked for domain registration in Patrix's hosted product. Patrix's |
| +root, dashboard.patrix.cc (`patrix-home`, on the `patrix` account), wants a |
| +"Get a domain" step in a site's settings: the site owner searches for a |
| +name, buys it, and the site serves at it. Any multi-tenant app on Carloku |
| +wants the same, so it belongs in the platform. |
| + |
| +Today every purchase door is person-only (`routedecls.go` around lines |
| +900-931, `Allow: svcrole.Set{}`; `domainBuyAPIGate` calls `apiPerson`), |
| +and payment is a Checkout page a person completes (`purchaseCheckout`). A |
| +root's credential can attach a hostname but not check, buy or renew one. |
| + |
| +## 2. Paul's rulings (2026-11-28, #1483) |
| + |
| +P1. **The app is the merchant.** Carloku bills the consumer's own account |
| + the catalog price (registration spec §6.2). The consumer charges its |
| + customer however it likes. The end customer is the legal registrant: |
| + an inline contact per purchase, frozen on the purchase as every |
| + purchase's contact already is (registration spec §11.7). |
| +P2. **Saved card, off-session.** Purchases and renewals made through the |
| + service credential charge the account's card on file with no person |
| + present, within the credential's spend caps. No prepaid balance. |
| +P3. **Renewals first.** Auto-renewal ships first, as its own slice. The |
| + consumer can switch auto-renew off per domain through the service role |
| + (its customer stopped paying) and on again. |
| + |
| +Second reply on #1483, the same day, settling revision 1's open questions: |
| + |
| +P4. **Caps never refuse a renewal.** Renewals count toward the |
| + credential's totals, but a cap never refuses one, so a paid-for domain |
| + never lapses for that reason. Caps limit new purchases only (§5.2). |
| +P5. **Transfer out first.** Transfer out (registration spec §4.3) is built |
| + before resale switches on for any account. |
| +P6. **Switch-on date.** The `patrix` account on flagship, 2026-12-15, after |
| + renewals and transfer out are live there. |
| + |
| +After round 2, when the attachment-authority findings reached stopping |
| +rule 2 (posted on #1483): |
| + |
| +P7. **Refuse cross-app takeover up front.** A `domains` credential refuses |
| + to point a domain that still has claims on any app other than its |
| + bound one, including the retained claims of a purged app (the |
| + `takeOverPurgedClaim` path), before any DNS or claim change, with a |
| + stable code. A person on the account does that recovery (§6.6). |
| + |
| +After round 3, when the authorisation-lifetime findings reached stopping |
| +rule 2 (2026-11-29, posted on #1483): |
| + |
| +P8. **No verified capture deadline, no registration.** For a direct |
| + purchase, an authorisation with no `CaptureBefore` verified from the |
| + provider gets no zone and no registrar call: it is cancelled through |
| + the existing reconciliation path and the purchase fails with a stable |
| + reason. There is no fallback deadline (§6.3). |
| + |
| +This spec **reverses platform accounts spec §6.3 ("Buying domains stays |
| +person-only") for the new `domains` role only**, by Paul's request in |
| +#1483. Every other role, and every person-only door this spec does not |
| +name, stays as it is. |
| + |
| +## 3. Requirements |
| + |
| +R1. A new service role, `domains`, minted only by an owner, reaches the |
| + doors of §4.2 and nothing else. |
| +R2. It reaches only registrations a `domains` credential of the same |
| + account bought. A domain a person bought is invisible to it. |
| +R3. Each credential carries money caps per day and per month and a count |
| + cap per day, set at mint and changed by an owner, enforced by the |
| + console under the billing hold against the account's resale ledger, |
| + which no rotation, revocation or renewal escapes (§5.2). The account's |
| + daily purchase cap still applies on top. |
| +R4. A refusal for a cap is a 429 that names the cap, its value, what is |
| + used and when it resets. |
| +R5. A service purchase charges the account's saved card off-session, |
| + authorised before anything is registered and captured after, as |
| + registration spec §5.1 orders it for a person. |
| +R6. A card that cannot be charged ends the purchase before anything is |
| + registered, with a stable code the consumer can act on, and the |
| + account's owners are told what to do. |
| +R7. A retried purchase never charges twice and never starts a second |
| + purchase. |
| +R8. The registrant is the end customer, from an inline contact that is |
| + never saved to the account's contacts and never read back by the role. |
| +R9. Every act of a `domains` credential is audited with the credential. |
| +R10. The feature is off for every account until an operator grants it |
| + resale. |
| + |
| +Non-goals (v1): premium names; the consumer setting its own retail price |
| +at Carloku; Carloku billing the end customer; transfers in by the role; |
| +changing a registrant through the role; webhooks to the consumer (it |
| +polls). |
| + |
| +Anti-goals: spending past a cap by any route (concurrent starts, retries, |
| +rotation); a credential that can lose the account a domain (transfer out, |
| +unlock, the transfer code, zone deletion, or ending renewal of a domain a |
| +person bought); a registration before its money is authorised; any |
| +existing credential, Admin included, gaining the power to spend. |
| + |
| +## 4. The `domains` role |
| + |
| +### 4.1 Shape (my calls) |
| + |
| +- **Outside Admin's union.** `Allow` panics on `Domains`; a door admits it |
| + only through `Exactly(Domains)`, as for `Run` and `Platform`. No |
| + credential minted before this spec gains spending power, and Admin has |
| + no caps. |
| +- **One role per credential, as today.** A root that also provisions |
| + instances holds two credentials: its existing `instance` or `publish` |
| + one, and a `domains` one. A leak of either does not give the other's |
| + reach, and `doorsFor` stays truthful. |
| +- **Account-scoped, optionally bound to one app** (`--app`). Check, |
| + purchase, status and list are the account's (registrations live at the |
| + account, registration spec §11). Bound to an app, every way the role |
| + attaches or detaches reaches only that app: point, detach, and the `app` |
| + a purchase names in its body (§4.5). Patrix mints it with |
| + `--app patrix-sites`. |
| +- **Held to its minter.** Every role door is owner-level, and a named |
| + service credential is held to its minter's role now (`apiOwnerOnly`, |
| + `stepUpOwnerAuthority`). A minter who stops being an owner takes the |
| + credential's reach with them. |
| +- **Service-bought only (R2).** The purchase and the registration it |
| + becomes record the credential that started it (§7). Any `domains` |
| + credential of the account reaches those registrations, not only the one |
| + that bought: an owner who revokes a leaked credential and mints a new one |
| + keeps the consumer's customers reachable. Everything else answers the |
| + neutral 404. Without this a leaked credential could switch off renewal |
| + of patrix.cc. |
| + |
| +### 4.2 Doors it reaches |
| + |
| +The person doors' paths where one exists, so there is one purchase engine |
| +and one set of refusals. Each door admits persons exactly as today: the |
| +account list (`domainListAPIGate`) any member of the account, every other |
| +door an owner. A `domains` principal is admitted only on an account with a |
| +live resale grant (§9) and, on every door the list included, only while |
| +it is held to an owner (§4.1). |
| + |
| +Role Sets. Every door below but detach is person-only today (the zero |
| +Set), and its Set becomes `Exactly(Domains)`: a person still passes, since |
| +persons are not role-gated, and no other role gains it. **Detach is the |
| +exception**: it already admits Publish, Instance and Admin through `Allow` |
| +and Team through its scoped registration (`routedecls.go`, the detach |
| +line; Instance is pinned by `TestInstanceRoleMatchesTodaysAppTokenReach`). |
| +It keeps all of them and its scoped registration, and adds `Domains` |
| +explicitly (the builder adds the Set constructor this needs, since `Allow` |
| +cannot carry Domains and `Exactly` drops Admin). The restriction of the |
| +table's right-hand column applies only to a Domains caller; every existing |
| +caller detaches exactly as today. |
| + |
| +| Door | For the role | |
| +|---|---| |
| +| `POST /api/cli/accounts/{account}/domains/check` | As for a person, inside the check budget (`domainCheckLimiter`) | |
| +| `POST /api/cli/accounts/{account}/domains/purchases` | The service shape (§6.1) | |
| +| `GET /api/cli/accounts/{account}/domains/purchases/{id}` | Only purchases a `domains` credential started | |
| +| `GET /api/cli/accounts/{account}/domains` | Only service-bought entries, with the fields of §6.4 | |
| +| The renewals slice's auto-renew door | Service-bought only (§6.5) | |
| +| `POST /api/cli/apps/{account}/{app}/domains/point` | Service-bought, bound app only; gains `route` (§6.6) | |
| +| `DELETE /api/cli/apps/{account}/{app}/domains/{host}` | Hosts under a service-bought registration, bound app only; the door's control-plane fuse and owner check stay first | |
| + |
| +If the renewals slice adds no API door for the flag, this spec adds |
| +`PUT /api/cli/accounts/{account}/domains/auto-renew/{domain}`. |
| +`/domains/{domain}/auto-renew` would collide with |
| +`PUT /domains/contacts/{id}` in the mux; `/domains/transfer/{domain}` is the |
| +precedent. |
| + |
| +### 4.3 Doors it never reaches |
| + |
| +- Saved contacts (the four `.../domains/contacts` doors): the owners' |
| + address book (§6.2). |
| +- Transfers in (`.../domains/transfers/check`, `.../transfers`). |
| +- Transfer out, unlock and the transfer (EPP) code (registration spec |
| + §4.3, Plan 4, not built): a person on the consumer account only (§8). |
| +- Customer DNS records (registration spec §5.3a) and zone deletion. |
| +- The general attach (`POST .../apps/{account}/{app}/domains`): the role |
| + points bought domains and attaches nothing else. The consumer's |
| + `instance` or `publish` credential still attaches as today. |
| +- Placements, certificate import, path maps, features, billing pages, |
| + card setup, plan changes. |
| +- Every services, instance-token, door-key, email-credential and platform |
| + door. A credential never mints a credential (AGENTS.md), and this role is |
| + no exception. |
| + |
| +`svcroutes_test.go`'s intent lists pin exactly §4.2's doors for the role, |
| +`closedDoors` loses the five zero-Set patterns that gain it (the auto-renew |
| +door is new), the detach door's existing roles stay pinned, and a test |
| +asserts that no `Allow` set carries `Domains`. |
| + |
| +### 4.4 Minting |
| + |
| +Owner-only and person-only, through the existing services doors |
| +(`POST /api/cli/services/{account}` and the browser's services form), which |
| +no credential reaches. Refused, each with a 409 naming the fix (my calls): |
| +- without the account's resale grant (§9), as `ErrNotPlatform` is; |
| +- on a linked account: it never gets a Stripe customer (platform accounts |
| + spec §8), so there is no card to charge; |
| +- while the account has no billing currency and the mint names none: the |
| + caps are money in that currency. Saving a card does not fix a currency |
| + (`cardSetupLocked` passes `fixCurrency=false`, and |
| + `billingcard_test.go` holds it), so the mint itself is the owner's way to |
| + choose one: `--currency eur`, confirmed by the owner, fixes the account's |
| + billing currency under the billing hold, through the same rule |
| + `paymentCustomerLocked` uses (`ChooseCurrency`, refused with |
| + `errCheckoutUncertain` when a Checkout in flight could fix another), and |
| + the answer says it is now fixed. On an account with a currency, |
| + `--currency` must match it or is refused; |
| +- without both money caps (§5.1), as a 400. |
| + |
| +The platform's per-customer credential door keeps minting only Publish and |
| +Deploy, so a linked account cannot hold the role either way. |
| + |
| +### 4.5 One attachment authority |
| + |
| +Today the attach door refuses a service credential on a control-plane app |
| +(`refuseServiceControlPlane`, `apidomains.go`) and holds it to the URL's |
| +app, while the point door, person-only so far, calls the shared attach |
| +core without either check (`domainpoint.go`), and purchase admission |
| +checks only that the body's app exists and is not linked |
| +(`startDomainPurchase`). Opening point and purchase to a service would make |
| +two routes round those checks. |
| + |
| +So one function, the service attachment check, decides for every service |
| +caller of every attaching path: the attach door, point, and the attach a |
| +purchase makes when it is captured. It refuses, before any effect: |
| +- an app other than the credential's bound app (the neutral 404, as a URL |
| + mismatch answers); |
| +- a control-plane app (`refuseServiceControlPlane`'s refusal); |
| +- a linked app (`linkedRefusalFor`, as today). |
| + |
| +Point also refuses a service caller any takeover of another app's claims |
| +(P7, §6.6). |
| + |
| +A purchase runs it at start, on the body's `app`, and again in the captured |
| +step before the deferred attach, because the app's flags can change in |
| +between. Refused then, the purchase finishes unpointed, as for an app that |
| +went away (registration spec §11.7), with reason `app_refused`, and the |
| +domain is still registered and paid. A test drives each attaching path with |
| +a bound credential at another app and at a control-plane app. |
| + |
| +## 5. Spend limits (R3, R4) |
| + |
| +### 5.1 The caps |
| + |
| +| Cap | Meaning | Default | |
| +|---|---|---| |
| +| `spend_day` | Money committed per UTC day: purchases and auto-renew switch-ons (§5.2) | none, required | |
| +| `spend_month` | The same per UTC calendar month | none, required | |
| +| `purchases_day` | Purchases started per UTC day | 5 | |
| + |
| +My calls: |
| +- **Money caps have no default.** An owner types the figure; a default |
| + would be a number nobody chose, charged to their card. |
| +- **Money is the catalog price before tax**, in the account's billing |
| + currency, minor units on the wire. Tax depends on the address and is |
| + added by the charge (§6.3); the cap stays a number the owner can check |
| + against the price list. |
| +- **A purchase counts from the moment it starts**, unless it ends with |
| + nothing charged (declined, authorisation cancelled, failed before |
| + capture). One in flight counts, so the money in flight never exceeds |
| + the caps. |
| +- **UTC days and months**, as `PurchasesToday` counts the account's day. |
| +- **Checked and counted under the billing hold**, where |
| + `startPurchaseCheckout` checks `DailyCap`, so two concurrent starts |
| + cannot both take a cap's last unit. |
| +- **Counted on the account's resale ledger** (§5.2), never on the listing |
| + id, which is the hash of the current secret and changes on rotation. |
| +- **The account's daily cap applies on top**: the catalog's `daily_cap`, |
| + or the grant's (§9), counting every purchase on the account, person and |
| + service alike. |
| + |
| +### 5.2 The ledger and renewals (P4) |
| + |
| +Renewals run under registration spec §4.2: the card on file is charged and |
| +then the registrar renews. The renewals slice charges the price in the |
| +renewal notice (its choice 1). Paul's P4: renewals count toward the |
| +totals, and a cap never refuses one. The hole to close is a credential |
| +spending through renewals after its cap is gone, for example by switching |
| +auto-renew back on across many domains. The rule: **spend is admitted when |
| +it is committed, not when it is charged.** |
| + |
| +- **A purchase** commits its price, admitted at start (§5.1), and with it |
| + the domain's renewals while auto-renew stays on as the purchase left it. |
| + That renewal authority is already admitted; it needs no second check. |
| +- **Switching auto-renew on through the role** is a new commitment. It is |
| + admitted like a purchase: refused with §5.3's 429 when the next |
| + renewal's price (the notice price once the notice is sent, else the |
| + catalog's renewal price now) would exceed what remains of the day or |
| + month cap. It does not count against `purchases_day`. Admitted, it is |
| + booked at that price in the window it was admitted in. |
| +- **Switching it off** is always allowed and books nothing. |
| +- **A renewal charge is never refused by a cap.** It is booked once: if a |
| + switch-on committed it, it settles that booking at the amount charged, |
| + in the switch-on's window; otherwise it is booked in the window it is |
| + charged in. So a month with renewals leaves less room for purchases. |
| + |
| +**The invariant, stated once:** every amount a `domains` credential |
| +commits, and every renewal of a service-bought domain, is booked exactly |
| +once on the account's resale ledger, and no purchase or switch-on is |
| +admitted unless the ledger's total for the day and the month, plus its |
| +amount, stays within the acting credential's caps. It is enforced in one |
| +place: one admission function, called under the billing hold by the |
| +purchase start and the auto-renew door, is the only writer of purchase and |
| +switch-on bookings, and the renewal pass's charge step is the only writer |
| +of renewal bookings. A guard test fails any other writer of the ledger |
| +table and any service money path that skips admission. |
| + |
| +**Bound to the account, not the credential.** The ledger is the |
| +account's: each booking names the credential that committed it, but a |
| +credential's caps are checked against the account's whole resale total for |
| +the window. Rotating keeps the credential row; revoking one and minting |
| +another starts no fresh total; a revoked credential's domains keep |
| +renewing and keep being booked. So neither rotation nor revocation resets |
| +or escapes the totals. Two `domains` credentials share one total, each |
| +bounded by its own caps (my call: the conservative reading, and a |
| +consumer needs one). |
| + |
| +The services listing shows the day's and month's totals with renewals |
| +apart. |
| + |
| +### 5.3 When a cap is reached |
| + |
| +Refused before anything is written or charged: 429, `Retry-After` set to |
| +the seconds until the cap resets, and a body naming it: |
| + |
| +```json |
| +{"error": "This credential has reached its daily spending limit for domains.", |
| + "code": "limit", "limit": "spend_day", "currency": "eur", |
| + "cap": 5000, "used": 4200, "price": 1500, "resets_at": "2026-11-29T00:00:00Z"} |
| +``` |
| + |
| +`limit` is `spend_day`, `spend_month`, `purchases_day` or |
| +`account_daily_cap`. For the money caps `cap`, `used` and `price` are minor |
| +units of `currency`; for the count caps `cap` and `used` are counts, and |
| +`price` and `currency` are left out. The same 429, with `limit` |
| +`spend_day` or `spend_month` and `price` the renewal's, refuses a |
| +switch-on. The check budget's 429 keeps its own code, `rate`. The first |
| +cap refusal of a UTC day emails the owners, once per credential, naming |
| +the cap and how to change it (my call: they should know customers are |
| +being turned away). |
| + |
| +### 5.4 Setting and changing them |
| + |
| +At mint (§10), and later by an owner as a person through a new services |
| +door, `POST /api/cli/services/{account}/{name}/limits` (zero role Set, |
| +owner-gated, like rotate and revoke) and its browser form. A raise applies |
| +to the next purchase. A cut below what is used refuses the next purchase |
| +and touches nothing in flight. Every change is audited. |
| + |
| +## 6. Buying, following and pointing |
| + |
| +### 6.1 The purchase request |
| + |
| +`POST /api/cli/accounts/{account}/domains/purchases` from the role, with an |
| +`Idempotency-Key` header: |
| + |
| +```json |
| +{"name": "shop.example", "currency": "eur", "price": 1500, |
| + "contact": {"first_name": "Ana", "last_name": "Ruiz", "email": "ana@shop.example", ...}, |
| + "reference": "site-4812", "app": "patrix-sites", "route": "shop-4812.patrix.cc"} |
| +``` |
| + |
| +`contact` has `registrar.Contact`'s fields, as the person door takes. |
| + |
| +- `contact` is required and `contact_id` refused (§6.2). |
| +- `currency` and `price` confirm the check's quote; a change is 409 |
| + `price_changed` with the new price, as for a person. |
| +- `reference` is the consumer's own id for its customer or site: |
| + optional, 1-64 characters of `A-Za-z0-9._:-`, else 422 `reference`. It |
| + is stored on the purchase and the registration and returned by status |
| + and list, so the consumer maps a domain to its customer without storing |
| + our ids. Not unique. |
| +- `app`, with an optional `route`, points the domain once it is registered |
| + (the captured step's attach, §6.6). The service attachment check (§4.5) |
| + runs on it at start and again before that attach. Without `app` the |
| + domain is registered and not pointed (registration spec §11.4's "Not |
| + yet"); the role does not send `not_yet`. |
| +- `Idempotency-Key` (R7): required from the role, 1-64 printable ASCII |
| + characters, else 400 `idempotency_key`; unique per account for 30 days. |
| + The same key with the same body answers the same purchase as it now |
| + stands, with `"replayed": true`. The same key with another body is 422 |
| + `idempotency_mismatch` and starts nothing. A new key for a name the |
| + account already has a live purchase of is 409 `purchase_in_progress` |
| + with that purchase's id only when a `domains` credential started it (a |
| + person resumes instead; a server should poll). |
| +- **A person's live purchase stays invisible (R2).** Today a live purchase |
| + of the name lets its owner resume at its stored price |
| + (`ownLivePurchaseOfKind`, filtered by account and kind only), and the |
| + check answers that purchase's frozen quote (`admitDomainBuy`). For a |
| + `domains` caller, both the check and the purchase admission filter that |
| + lookup by service provenance first: a live purchase a person started is |
| + the neutral refusal (`claimRefusal`, as for a name held elsewhere), with |
| + no id and no quote. |
| + |
| +The answer is 201 `{"id", "state", "domain", "reference"}`, with no |
| +`checkout_url`. |
| + |
| +### 6.2 The registrant (R8) |
| + |
| +- The end customer is the registrant. The contact is checked with |
| + `registrar.Contact.Validate`, plus an address check on `email` (which |
| + `Validate` only requires to be present), plus any fields the catalog's |
| + TLDs need (registration spec §8). |
| +- **My call: a service purchase's contact is never saved to the account's |
| + saved contacts.** `insertDomainPurchaseLocked` saves a new contact or |
| + reuses an equal saved one; the service path does neither. It freezes the |
| + contact on the purchase alone, with a fresh registrar handle |
| + (`EnsureContact` with no existing handle). The saved list is the owners' |
| + address book: filled with customers, it would offer them to the next |
| + purchase made by hand. |
| +- **No contact data in diagnostics.** The Openprovider adapter keeps the |
| + provider's description in a refusal (it scrubs only its own credentials, |
| + `client.go`), and the purchase pass logs the errors it returns, so a |
| + validation answer that echoes an email, phone or address would reach the |
| + logs. The contact operations, `EnsureContact` and `Register` (which names |
| + the handle), therefore return errors without provider text: only the |
| + adapter's classification and the provider's numeric codes, through |
| + `trusted`, as transfer errors already do. This is the adapter's |
| + behaviour for every caller, since it cannot tell a service purchase from |
| + a person's. A fixture whose error description echoes the contact's |
| + email, phone and street shows that none of them reaches the returned |
| + error, the purchase pass's log lines or any audit detail. |
| +- WHOIS privacy stays on, as registration spec §4.4 says for every domain. |
| + The registrar's registrant verification email goes to the end customer; |
| + the list door shows its state and deadline (§6.4) so the consumer can |
| + tell them. |
| +- **Who reads it back**: the account's people on the domain's page |
| + ("Registered to", registration spec §11.6), and the operator, as for any |
| + registration. **Not the role**: its answers carry `reference`, never the |
| + contact. The consumer already holds its customer's details, and a leaked |
| + credential should not read every customer's address. |
| +- A purchase that ends with no registration has its frozen contact cleared |
| + 30 days after it ends (my call). The row keeps its domain, reference, |
| + money and outcome. |
| +- The consumer is responsible for the details being its customer's real |
| + ones, as registries require. That is a term of the resale grant (§9), not |
| + something the console can check. |
| + |
| +### 6.3 Charging off-session (R5, R6) |
| + |
| +Registration spec §5.1 is unchanged from step 3 on (zone, register, |
| +capture, attach). Steps 1 and 2 change for the role: |
| + |
| +1. **Admission**, all before any money: the gate (grant live, credential |
| + live and held to an owner); every check a person's purchase makes |
| + (`admitDomainDoor`, `admitDomainBuy`); then, under the billing hold, the |
| + account's daily cap, the credential's caps, the registrar balance and |
| + the card (below). |
| +2. **Authorise off-session** instead of opening a Checkout: a PaymentIntent |
| + on the account's customer and saved card, confirmed at once, |
| + off-session, manual capture, for the price plus the tax the same address |
| + pays at Checkout (`PreparePaymentCheckout` uses automatic tax, exclusive |
| + prices), with metadata naming the account and the purchase. Its |
| + idempotency key is the purchase id with a fixed suffix. The prepared |
| + request is stored before its first send and resent only verbatim, as |
| + `CheckoutPrepared` is. A purchase records which way it pays (Checkout or |
| + direct), fixed at start. |
| + |
| +**Bounded resends (billinghold.go's rule).** The key only protects a |
| +resend while the provider still holds it, and a cached 5xx answers the |
| +same 5xx to every resend. So, as `resendLifetime` (22 hours) bounds every |
| +other stored billing request: |
| +- The first send's provider time (`FirstSentAt`, from `providerNow`, taken |
| + before the send) is stored with the prepared request. With no provider |
| + time nothing is sent. |
| +- The request is tried inside the purchase call, for at most the |
| + `handlerRetries` backoff, so a decline answers the call itself. An |
| + answer that is not definite (`ErrNoResponse`, `ErrInFlight`, |
| + `ErrNotExecuted`, `ErrIndeterminate`) returns 201 in state |
| + `authorising`, and the purchase pass carries on. |
| +- Before every resend, the pass reconciles by reading: the PaymentIntent by |
| + its stored id when an answer gave one, else the account customer's |
| + PaymentIntents created since `FirstSentAt` less a margin, matched by the |
| + purchase id in metadata (an exhaustive list, which is read-consistent). |
| + One found settles it, whatever the send's answer said: `requires_capture` |
| + is `authorised`; a decline is §6.3's code; `canceled` is `failed` with |
| + nothing held. More than one for one purchase (which the key should make |
| + impossible) alerts the operator and cancels all but the first. |
| +- A resend goes only while provider time is within `resendLifetime` of |
| + `FirstSentAt`, and never after a cached `ErrIndeterminate`, which a |
| + resend cannot change: that case waits on reads alone. |
| +- **Past the bound, the pass never sends again.** It keeps reading for the |
| + card authorisation's lifetime (about seven days). If none is ever found, |
| + the purchase ends `failed` with reason `authorisation_unknown`, nothing |
| + registered, and the operator alerted. One that appears later is |
| + cancelled, since nothing was registered against it. When unsure, the |
| + purchase fails; it never makes a second authorisation. |
| +- A definite authorisation enters the existing `authorised` state, and the |
| + authorisation's `CaptureBefore` is stored. It must be verified: read from |
| + the provider on an intent read that passes §6.3a's checks. There is no |
| + fallback when the provider gives none (P8, below). |
| + |
| +**Registration completes within the authorisation.** A recovered |
| +authorisation can arrive close to its `CaptureBefore`, and today's engine |
| +checks only the payment status before it registers and starts its |
| +deadlines from its own attempts (`registerPurchase`, |
| +`purchaseSetupDeadline`). For a direct purchase, every bound below is read |
| +in provider time (`providerNow`); with no provider time no registrar call |
| +is started. |
| +- **Margins.** `captureMargin`, 6 hours: the time kept for capture and its |
| + reconciliation. `registrationStartMargin`, 30 hours: Plan 1's 24-hour |
| + registering deadline plus `captureMargin`. |
| +- **No deadline (P8).** An authorisation with no verified `CaptureBefore` |
| + (the adapter accepts a missing `capture_before`, `billingstripe/payment.go`, |
| + and a card's real hold can be shorter than any assumed one: Visa |
| + merchant-initiated holds last 4 days 18 hours) gets no zone and no |
| + registrar call. It is cancelled through the existing cancellation and |
| + its reconciliation (`failPurchase`, read on the intent per §6.3a), and the |
| + purchase ends `failed` with reason `capture_deadline_unknown`, nothing |
| + registered. The check runs before the zone step and again before every |
| + registrar call. |
| +- **Start.** The zone step and the registrar's first call start only while |
| + `CaptureBefore` is at least `registrationStartMargin` away. An |
| + authorisation found with less (a late reconcile, a slow setup) is |
| + cancelled at once, and the purchase ends `failed` with reason |
| + `authorisation_late`, nothing registered. |
| +- **Setup.** The setup deadline is the earlier of today's (24 hours from |
| + `SetupStartedAt`) and `CaptureBefore` less `registrationStartMargin`. |
| +- **Registration reconciliation.** The registering deadline is the earlier |
| + of today's (24 hours from the first attempt) and `CaptureBefore` less |
| + `captureMargin`. At it, Plan 1's rule applies unchanged: a Lookup that |
| + does not find the domain cancels the authorisation and fails the |
| + purchase `unconfirmed`; one that finds it proceeds to capture. |
| +- **Capture** is attempted as soon as registration is recorded. A capture |
| + that still fails, the hold having lapsed, is §5.1 step 7's `unpaid`, |
| + bounded by one registration fee. |
| + |
| +Tests: an authorisation recovered one minute short of |
| +`registrationStartMargin` before `CaptureBefore` is cancelled and the |
| +registrar is never called; one a minute inside it registers; an |
| +indeterminate registration whose deadline is clipped by `CaptureBefore` is |
| +settled by Lookup and cancelled when not found, before the hold lapses; |
| +an authorisation whose intent read carries no `capture_before` (the |
| +adapter's `null_capture_before` case) ends `failed` with |
| +`capture_deadline_unknown`, with no zone created, no registrar call made |
| +and the hold cancelled. |
| + |
| +### 6.3a Payment state without a Checkout session |
| + |
| +Every payment read in the purchase engine today goes through the Checkout |
| +session: `PaymentCheckout(ctx, p.CheckoutSession)`, which the adapter |
| +refuses for an empty id (`billingstripe/payment.go`). A direct purchase has |
| +no session, so each read is replaced, for that path only, by one function |
| +that reads the purchase's payment by its way of paying: the session as |
| +today, or the PaymentIntent directly (a new provider read, with the |
| +intent's latest charge expanded for `CaptureBefore`). Every place: |
| + |
| +| Where (`domainbuy.go`) | Today | Direct path | |
| +|---|---|---| |
| +| `advancePurchaseStep`, awaiting payment | Reads the session for `Authorised` | Never reached: a direct purchase starts in `authorising` (above) | |
| +| `registerPurchase`, before the registrar call | Session read; needs `requires_capture` | Intent read; needs `requires_capture` | |
| +| `advancePurchaseEffects`, `registered`: capture reconciliation | Session read after an unclear capture | Intent read | |
| +| `failPurchase`: cancellation recovery | Session read after an unclear cancel | Intent read | |
| +| `purchaseCheckout`, `resumeDomainPurchase` | Open or reuse a session | Never called: a direct purchase is resumed by its state | |
| + |
| +Each intent read checks what the session read checks today and more: the |
| +intent id is the stored one, its metadata names this purchase and account, |
| +its customer is the account's, its currency is the purchase's, and its |
| +total is the stored total (the pre-tax price plus the tax the authorisation |
| +carried, both stored at authorisation). Any mismatch is |
| +`billing.ErrIndeterminate`, as today, and the purchase stays where it is. |
| +Crash recovery is unchanged in shape: each state's step is re-entered and |
| +reads before it writes. Transfers in are never direct (the role has no |
| +transfer doors), and the shared function refuses a direct transfer. A test |
| +walks every state of a direct purchase against the Fake with no session, |
| +including a crash after each send and an unclear capture and cancel. |
| + |
| +**New on `billing.Provider`**: an off-session charge with tax against the |
| +saved card, and a read of whether the customer has a usable card. The |
| +renewals slice needs both (registration spec §6.1), so this spec reuses its |
| +primitive and adds only manual capture, so that a failed registration |
| +cancels an authorisation instead of refunding a charge. The Stripe adapter |
| +implements it; the console still imports only `internal/billing`; the |
| +billingtest Fake scripts every outcome below. |
| + |
| +**When the card cannot be charged**, the call answers 402 and nothing is |
| +registered: |
| + |
| +| Code | When | The account owner | |
| +|---|---|---| |
| +| `no_card` | No saved card; refused before a purchase is created | Adds a card in Billing | |
| +| `card_authentication_required` | The bank asked for authentication (SCA); the purchase ends `failed` | Updates the card in Billing: saving it authenticates it once for off-session use | |
| +| `card_declined` | Any other definite decline; the purchase ends `failed` | Checks or replaces the card | |
| +| `card_needs_attention` | An off-session decline in the last 24 hours and no card saved since; refused before a purchase is created | As for that decline | |
| + |
| +The consumer tells its customer something like "We couldn't complete this |
| +purchase right now. Please try again later." Its words are its own; the |
| +codes are stable. |
| + |
| +My calls: |
| +- **After an off-session decline, the account's service purchases are |
| + refused up front** (`card_needs_attention`) until a card is saved or 24 |
| + hours pass. Issuers count repeated declined off-session attempts against |
| + the merchant, and a card the bank wants authenticated keeps refusing. |
| + Person purchases are unaffected: Checkout can authenticate. |
| +- **The owners get one email per decline episode**, naming the code, the |
| + credential, the domain and the reference, with a link to Billing. No |
| + payment link: the purchase has failed, and the consumer retries once the |
| + card works. |
| +- A capture that fails after registration is registration spec §5.1 step |
| + 7, unchanged: the domain is kept and marked unpaid, auto-renew goes off, |
| + the owners get a payment link, the operator an alert. The caps still |
| + count it. |
| + |
| +### 6.4 Status and list |
| + |
| +`GET .../purchases/{id}` answers today's `domainPurchaseReply`, plus |
| +`reference`, plus a §6.3 code in `reason` when the card ended it. The |
| +consumer polls until a terminal state, as `carlos domains buy` stops on |
| +them. For a direct purchase the terminal states are: |
| + |
| +| State | Registered | Paid | The consumer | |
| +|---|---|---|---| |
| +| `done` | yes | yes | Done. If pointed, it may wait on `domain_state` reaching `live`, as the CLI does | |
| +| `failed` | no | nothing taken | Shows `reason`; may retry with a new key | |
| +| `unpaid` | yes | no | The domain is the account's and stays usable, but auto-renew is off and the owners have a payment link (§6.3). Treat it as registered, not settled: tell the account owners, and do not switch auto-renew on (refused until paid) | |
| + |
| +`expired` is a Checkout session's expiry and is never reached by a direct |
| +purchase. |
| + |
| +`GET .../domains` for the role lists service-bought registrations and |
| +purchases in flight, with today's fields (`domain`, `bought`, `expires`, |
| +`purchase`, `addresses`) plus `reference`, `auto_renew`, the renewal |
| +slice's renewal state (for example a failed renewal charge and its next |
| +retry) and registrant verification (`pending` with its deadline, or |
| +`done`). No contact. |
| + |
| +### 6.5 Auto-renew (P3) |
| + |
| +The role switches a service-bought domain's auto-renew off and on: body |
| +`{"auto_renew": false}`, answer `{"domain", "auto_renew", "expires"}`. What |
| +each setting does (the charge 30 days before expiry, the reminders, the |
| +lifecycle at expiry) is the renewals slice's, unchanged, and its emails go |
| +to the account's owners (§8). Switching on is admitted against the caps |
| +(§5.2) and can be refused with §5.3's 429; switching off is always |
| +allowed. The role cannot switch on a domain marked unpaid until it is paid |
| +(my call: it would charge a card that already failed). |
| + |
| +### 6.6 Pointing and detaching |
| + |
| +The point door (`domainpoint.go`) writes the bought zone's managed set and |
| +attaches the apex and `www` to the app. A hosted Patrix site is an instance |
| +of `patrix-sites`, so the role's call carries `route`, the instance host, |
| +and the attach targets it as the attach door's `route` field does |
| +(`resolveAliasRoute`, `apidomains.go`). The door's other rules stand: the |
| +domain is the account's registration, has a zone here and no purchase in |
| +flight, and claims are the attach's. For a service caller the service |
| +attachment check (§4.5) runs first. Moving a domain to another site is |
| +detach, then point. |
| + |
| +**No takeover by a service (P7).** For a person, point first releases each |
| +apex or `www` claim of this account whose app no longer exists |
| +(`takeOverPurgedClaim`), which can also retire that app's first-route |
| +record. A `domains` caller never reaches that release. Before the zone |
| +write and before any claim read-and-release, point reads the claims on the |
| +apex and `www`, and refuses with 409 `claimed_elsewhere` (naming the host, |
| +not the app) when either is a claim of this account on any app other than |
| +the bound one (for an unbound credential, other than the app in the URL): |
| +a live app, one in Trash, or a purged app whose claims a purge retained. |
| +Another account's claim is refused at the same point with the attach's |
| +neutral refusal. Nothing in the zone, the claims or the route records |
| +changes. A person on the account recovers: detach from the other app, or |
| +point as a person, which takes over a purged app's claims as today. The |
| +attach a purchase makes when captured never takes over a claim (buying |
| +refuses every existing claim at start, and `attachDomain` refuses another |
| +app's), so it needs no change. |
| + |
| +Witness: an account holds a service-bought domain whose apex and `www` |
| +claims a purge of app B retained. A `domains` credential bound to app A |
| +points it at A: 409 `claimed_elsewhere`; the zone host records no write; |
| +B's claims and its first-route record are unchanged; no release is |
| +audited. The same with B in Trash, and with an unbound credential naming A. |
| +A person owner then points it at A and takes the claims over. Pointing uses the account's custom-domain entitlement, |
| +as any attach does. |
| + |
| +## 7. Audit (R9) |
| + |
| +Every act of a `domains` credential is an `s.audit` row on the account, |
| +actor `service:<sqid>/<name>` (`auditActor`), with the credential's stable |
| +id (its row, which rotation keeps), the domain and the reference in the |
| +detail: |
| + |
| +- `domain-purchase-start` (price, currency, reference), and the |
| + purchase's end (`done` or `failed`, with its reason); |
| +- `domain-purchase-refused` for a card code or a cap (naming it); |
| +- `domain-auto-renew` (on or off, and for on the booked price), |
| + `domain-point` and `domain-detach` (app and route); |
| +- `domain-renewal-booked` when a renewal of a service-bought domain is |
| + booked on the resale ledger (§5.2), naming the credential that holds its |
| + commitment; |
| +- `service-limits` when an owner changes caps, and `domain-resale-grant` |
| + when the operator grants, changes or revokes, with the person as actor. |
| + |
| +The purchase row and its registration carry the credential's stable id |
| +beside the existing `Principal` string, so the caps (§5) and the role's |
| +reach (§4.1) read one column, and the domain's page says "Bought by |
| +<credential>, reference <reference>". |
| + |
| +## 8. Ownership |
| + |
| +- **The registration is the consumer account's**, like any (registration |
| + spec §11). The end customer is the registrant, so in the registry the |
| + domain is the customer's; Carloku's customer is the consumer. |
| +- **A departing customer takes their domain** by transfer out (registration |
| + spec §4.3), done by a person on the consumer account: an owner unlocks |
| + it on the domain's page and gives the transfer code to the customer, who |
| + moves it where they like. The role never reaches this (§4.3). Transfer |
| + out is Plan 4, not built yet, and by Paul's P5 it is built before resale |
| + switches on for any account (§9, §12). |
| +- **The consumer account closing.** Deleting an account that holds |
| + registrations is refused, naming them (registration spec §4.3). The |
| + consumer hands each to its customer by transfer out, or switches |
| + auto-renew off and lets it lapse, before the account can go. |
| +- **The card failing at renewal.** Renewal retries and emails the owners |
| + (§4.2); the domain is not renewed until paid. A renewal email about a |
| + service-bought domain names its reference (my call). Telling the end |
| + customer is the consumer's job; Carloku never writes to an end |
| + customer, though the registrar writes to a registrant (verification, |
| + registry notices). |
| +- **The grant or the credential revoked.** Registrations stay, renewals go |
| + on by their flag, and the owners manage the domains by hand on the |
| + Domains page. |
| + |
| +**Linked accounts.** The consumer here is an ordinary account (Patrix's |
| +`patrix` account holds every hosted site's instance), so platform accounts |
| +spec §8 is untouched. My call: a linked account may not hold the role |
| +(§4.4), since it never has a Stripe customer, and `admitDomainDoor` already |
| +refuses it. |
| + |
| +## 9. The switch (R10, stopping rules 5 and 6) |
| + |
| +**Off for every account until an operator grants it.** Resale is an abuse |
| +vector (registration spec §6.4) and the operator's prepaid registrar |
| +balance carries each purchase until capture, so the operator decides who |
| +resells (my call). An operator door and command, as for the platform grant: |
| + |
| +``` |
| +carlos accounts domain-resale --account <sqid> --grant --daily-cap 20 --reason "..." |
| +carlos accounts domain-resale --account <sqid> --revoke |
| +``` |
| + |
| +The grant holds `daily_cap` (purchases per UTC day for this account, |
| +replacing the catalog's `daily_cap` for it alone, since a reseller buys for |
| +many people), `reason`, `granted_by` and `state`. Without a grant the role |
| +cannot be minted. Revoked, every `domains` credential on the account is |
| +refused at every door with 403 `resale_off` from the next request, and §8 |
| +applies. Buying itself must be on (`domainBuyReady`); where it is off the |
| +doors are not registered. |
| + |
| +**First user**: Patrix's hosted dashboard, dashboard.patrix.cc, for |
| +Farshad. |
| +**Switch-on** (P5, P6): transfer out is built first, for every account, |
| +dev included. On dev, the day the resale slice merges (after renewals and |
| +transfer out have merged), granted to the dev `patrix` account, on the |
| +Openprovider sandbox and Stripe test mode. On flagship, **2026-12-15**, for |
| +the `patrix` account only, after renewals and transfer out are live there. |
| +The plan carries this date, and the slice does not merge dormant. |
| + |
| +**What a user sees first.** On dev, in the console, before Patrix ships |
| +anything: the account's Services settings show the `domains` credential |
| +with its caps and what it has used today and this month, and the Domains |
| +page marks each service-bought domain "Bought by patrix-root, reference |
| +site-4812". Next, Patrix's own "Get a domain" step on its dev dashboard. |
| +Each new screen and string gets the UX pass in the mockup kit, then copy |
| +review, before it is built. |
| + |
| +## 10. CLI and API surface |
| + |
| +Owners mint and change caps within `carlos services`: |
| + |
| +``` |
| +carlos services create --role domains --spend-day 50 --spend-month 300 \ |
| + [--purchases-day 5] [--app patrix-sites] [--account <sqid|name>] [--json] patrix-root-domains |
| +carlos services limits [--spend-day N] [--spend-month N] [--purchases-day N] \ |
| + [--account <sqid|name>] <name> |
| +carlos services ls # a domains row shows its caps and today's and this month's use |
| +``` |
| + |
| +Money on the command line is a decimal in the account's billing currency |
| +("50", "49.99"), sent as minor units; the answer names the currency. The |
| +create answer's `doors`, from `doorsFor`, lists §4.2's patterns. |
| + |
| +The role's calls are API calls from the consumer's server. For testing, |
| +`carlos domains check`, `buy` and `list` work with a `domains` credential |
| +in `CARLOS_SERVICE_TOKEN`; `buy` gains `--contact-file`, `--reference` and |
| +`--route`, and makes an idempotency key per run. `carlos accounts |
| +domain-resale` is new (§9). Each new command, flag and route lands with its |
| +`parity/parity.tsv` row and `docs/site/cli.md` heading in the same branch. |
| + |
| +Wire conventions are today's: `{"error", "code"}`, `no-store`, the |
| +byte-identical 404 for an account the caller does not hold. |
| + |
| +## 11. Testing without spending money |
| + |
| +- **Package tests** use the fake registrar and the billingtest Fake, which |
| + scripts each off-session outcome: authorised, declined, authentication |
| + required, no card, and each indeterminate class followed by a definite |
| + answer. Witness tests at least: the role reaches exactly §4.2's doors and |
| + no `Allow` set carries it; concurrent starts cannot both take a cap's |
| + last unit; a retry with the same key charges once and answers the same |
| + purchase, and another body under that key starts nothing; a |
| + person-bought registration is the neutral 404 at every role door; |
| + rotation keeps the caps' counts and the reach; a service purchase saves |
| + no contact and no answer carries one; a decline sets |
| + `card_needs_attention` and a saved card clears it. And for round 1's |
| + findings: a credential whose month cap is used up cannot switch auto-renew |
| + on, while a renewal of a domain it bought still charges and is booked; |
| + revoking a credential and minting another starts no fresh total; the |
| + ledger has no writer but the two of §5.2; an authorisation whose answer |
| + is lost is found by the reconcile read, and one still unknown past |
| + `resendLifetime` is never resent (the Fake drops its key store to show |
| + it); every state of a direct purchase runs with no Checkout session; a |
| + bound credential cannot point or buy-and-attach to another app or to a |
| + control-plane app; an Instance and a Team credential still detach as |
| + today; a person's live purchase answers a `domains` check and purchase |
| + with the neutral refusal; the mint fixes the currency it is given. |
| +- **Dev** uses the Openprovider sandbox (registration spec §7.1) and Stripe |
| + test mode, whose test cards cover each path: one that authenticates once |
| + when saved and then charges off-session, one that needs authentication |
| + on every charge, one that declines. The plan names the exact cards. |
| +- **No live registration and no live charge without Paul's approval** |
| + (AGENTS.md, production infrastructure). The first flagship purchase is a |
| + witness Paul approves in scope: one domain on a cheap catalog TLD, the |
| + `patrix` account's real card, its cost, and what happens to it after. |
| + |
| +This touches billing and a security gate, so each task gets its own review |
| +(stopping rule 3). |
| + |
| +## 12. Slices |
| + |
| +0. **Renewals** (registration spec §4.2, branch `domain-renewals`): |
| + auto-renew, the off-session charge, the renewal emails. First (P3); not |
| + part of this spec. |
| +0b. **Transfer out** (registration spec §4.3, Plan 4): built before resale |
| + switches on for any account (P5); not part of this spec. |
| +1. **Resale**: the grant; the role, its mint with caps and the limits door; |
| + the service purchase with off-session authorise, idempotency and caps; |
| + status and list for the role; the auto-renew door for the role; point |
| + with `route`, and detach; audit; the console's Services and Domains |
| + additions. Witness on dev: a `domains` credential buys a sandbox domain |
| + for a made-up customer with nobody signed in, points it at an instance |
| + route, switches auto-renew off and on, is refused at its daily money |
| + cap with §5.3's 429, and a test card needing authentication fails a |
| + purchase with 402 `card_authentication_required` and nothing |
| + registered. |
| +2. **Patrix** (patrix/patrix, not this repo): "Get a domain" on the |
| + dashboard, the roster naming the new origin, and Patrix's own charge to |
| + its site owner. |
| + |
| +Left to the builder: storage, including the resale ledger's table; the |
| +provider method names, after reading what renewals added (the off-session |
| +charge with manual capture, the PaymentIntent read, the customer's |
| +PaymentIntent list); the Set constructor detach needs; how point passes |
| +`route` to `attachDomain`; the test cards; TLD-specific contact fields. |
| + |
| +## 13. Open questions for Paul |
| + |
| +None at revision 2. Paul's P4 to P6 settled revision 1's three. |
| + |
| +## 14. Review history |
| + |
| +**Round 1**, Astra, on `38cf6052` (revision 1): NOT READY, five P1 and |
| +three P2. Resolved in revision 2: |
| + |
| +1. P1, renewals bypass spending authority (bounded spending authority). |
| + Paul ruled P4 the same day. Spend is admitted when committed: a purchase |
| + carries its renewals; switching auto-renew on is admitted against the |
| + caps and booked; switching off is always allowed; renewal charges are |
| + never refused and are booked once. Caps are checked against the |
| + account's resale ledger, so rotation and revocation neither reset nor |
| + escape the totals. The invariant and its one enforcement point: §5.2. |
| +2. P1, authorisation retries can create several PaymentIntents (payment |
| + idempotency across outages). §6.3 now follows `billinghold.go`: the |
| + first send's provider time is stored, resends stop at |
| + `resendLifetime`, each is preceded by a reconcile read (by stored id, |
| + else by purchase metadata), never after a cached 5xx, and past the bound |
| + the purchase only reads and, when still unsure, fails rather than send. |
| +3. P1, the engine needs a Checkout session (payment-state continuity |
| + without Checkout). §6.3a names every session read in `domainbuy.go` |
| + and its direct replacement, the checks each read keeps (identity, |
| + metadata, customer, currency, total), and that the adapter's session |
| + read is never called for a direct purchase. |
| +4. P1, attachment paths skip service checks (consistent authority across |
| + attachment paths). §4.5: one service attachment check (binding, |
| + control-plane, linked) for the attach door, point and the purchase's |
| + attach, run at start and again before the deferred attach. |
| +5. P1, replacing every Set removes detach access (existing credential |
| + compatibility). §4.2: detach keeps Publish, Instance, Admin and its |
| + scoped Team registration and adds Domains; the other doors become |
| + `Exactly(Domains)`. |
| +6. P2, a card does not fix the billing currency (reseller onboarding |
| + prerequisites). §4.4: the mint takes `--currency` and fixes it under the |
| + billing hold by `paymentCustomerLocked`'s rule; the claim about card |
| + setup is corrected. |
| +7. P2, polling omits `unpaid` (purchase completion signalling). §6.4 lists |
| + the terminal states, what each means for registration and payment, and |
| + the consumer's action for `unpaid`. |
| +8. P2, a person's live purchase leaks (person/service purchase isolation). |
| + §6.1: the check and the purchase filter the live-purchase lookup by |
| + service provenance first; a person's is the neutral refusal, with no id |
| + and no quote. |
| + |
| +**Round 2**, Astra, on `55b1c805` (revision 2): NOT READY, two P1 and two |
| +P2. Round 1's findings resolved except point's takeover (R1 P1-4, partly). |
| +Resolved in revision 3: |
| + |
| +1. P1, point can still detach another app's retained claims (consistent |
| + authority across attachment paths, second round running: stopping rule |
| + 2). Paul ruled P7, refuse up front. §6.6: a `domains` caller is refused |
| + with 409 `claimed_elsewhere` before any zone or claim change when the |
| + apex or `www` has a claim of this account on any app but the bound one, |
| + purged apps' retained claims included; a person recovers. Witness with a |
| + retained claim of a purged app. |
| +2. P1, registration can start without enough authorisation left |
| + (registration within its payment authorisation). §6.3: named margins |
| + (`captureMargin` 6 hours, `registrationStartMargin` 30 hours), setup and |
| + registering deadlines clipped by `CaptureBefore` in provider time, an |
| + authorisation recovered too late cancelled (`authorisation_late`), and |
| + tests just either side of the margin. |
| +3. P2, the common gate would drop member access to the list (existing |
| + caller compatibility). §4.2: persons are admitted exactly as today, the |
| + list to any member; `domains` callers are held to an owner. |
| +4. P2, registrar error text could carry contact data (registrant data in |
| + diagnostics). §6.2: `EnsureContact` and `Register` return errors without |
| + provider descriptions, through `trusted`, with a fixture that echoes |
| + contact fields and checks logs and audit. |
| + |
| +Findings file: `docs/superpowers/reviews/CODEX-FINDINGS-domain-resale-spec-R2.md`. |
| + |
| +**Round 3**, Astra, on `a5cb7fa0` (revision 3): NOT READY, one P1. Every |
| +other finding of rounds 1 to 3 resolved (R2 P1-2 partly). Resolved in |
| +revision 4: |
| + |
| +1. P1, the six-day fallback can admit registration after the real hold |
| + expires (registration within its payment authorisation, second round |
| + running: stopping rule 2). Paul ruled P8, refuse up front. §6.3: the |
| + fallback is removed; with no verified `CaptureBefore` there is no zone |
| + and no registrar call, the hold is cancelled through the existing |
| + reconciliation path, and the purchase fails `capture_deadline_unknown`. |
| + Witness: an intent read with no `capture_before`. |
| + |
| +Findings file: `docs/superpowers/reviews/CODEX-FINDINGS-domain-resale-spec-R3.md`. |
| +The three-round budget is spent. A scoped fourth check, of revision 4's |
| +diff only, runs with Paul's go. |