| new file mode 100644 |
| index 000000000..cdcd711a8 |
| --- /dev/null |
| +++ b/docs/superpowers/specs/2026-11-01-domain-registration-design.md |
| @@ -0,0 +1,362 @@ |
| +# Domain registration: buy a domain and have it just work |
| + |
| +Status: revision 1, DRAFT for Paul's read. Branch `design-domain-registration`. |
| +Review budget: at most three cross-model rounds (AGENTS.md stopping rules); |
| +the builder check below is round 1. |
| + |
| +Builds on: the custom-domain attach door (#82, #151, |
| +`2026-08-27-managed-custom-domains-design.md`), latency steering |
| +(`2026-08-20-multi-region-ingress-design.md` Part 4, `internal/steering`), |
| +durable DNS records (`internal/dnsrec`, tenant email spec §7) and the |
| +provider-neutral billing seam (`internal/billing`, |
| +`2026-10-20-plans-caps-packs-design.md` §10). |
| + |
| +## 1. What this is for |
| + |
| +Paul, 2026-11-01, after comparing registrars: Carloku customers should be |
| +able to buy a domain from the console or the command line, and "the domain |
| +should just start working for whatever app they're hooking it up to |
| +immediately". They should only ever see the Carloku name, never a |
| +registrar's or a DNS host's. And a customer who wants to leave should be |
| +able to take the domain with them "easily", with DNSimple recommended as |
| +where to take it. |
| + |
| +Today a customer buys a domain somewhere else, points its DNS at us by |
| +hand, and waits for `carlos domains list` to read `live`. Every step of |
| +that is a place to get it wrong (`pending-dns`, `misdirected`). |
| + |
| +## 2. Goals, non-goals, anti-goals |
| + |
| +Goals: |
| +1. One action, in the console or `carlos`, takes a domain name and an app |
| + and ends with the domain serving that app over HTTPS. |
| +2. The customer pays a one-off charge at the moment they buy, separate |
| + from their plan. |
| +3. Each domain has an auto-renew flag. With it on, Carloku charges the |
| + card on file and renews before expiry. |
| +4. The domain's nameservers carry the Carloku name, never `awsdns`. |
| +5. Visitors to a bought domain get the same latency steering and failover |
| + as every other steered Carloku host. |
| +6. A customer can take the domain to another registrar, with its records, |
| + from one button or command, without contacting support. |
| + |
| +Non-goals (v1): |
| +- Transfers into Carloku from another registrar. Paul: "moving would be |
| + fine, but it's not a priority". A later revision. |
| +- Premium domains (registry-priced names). Refused at the check step. |
| +- DNSSEC. Route 53 can sign zones, but it adds a KMS key and a DS record |
| + at the registrar to every purchase and every transfer out. Later. |
| +- Fixed apex IPs for customers on their own DNS (Global Accelerator). |
| + Discussed and set aside on 2026-11-01; the setting in §5.4 leaves room. |
| +- Reselling DNS hosting on its own, without a registration. |
| + |
| +Anti-goals (failure even if it technically works): |
| +- A customer who cannot get their domain out without asking us. |
| +- Carloku paying a registry for a domain the customer has not paid for. |
| +- A domain that renews at the registrar when the customer has not paid |
| + for the renewal (or the reverse: paid, but not renewed). |
| +- A registrar or DNS host name visible anywhere the customer looks: the |
| + nameservers, the console, the CLI, emails. |
| +- Platform core code that only works on AWS or only with Openprovider. |
| + |
| +## 3. Rulings so far (Paul, 2026-10-31 and 2026-11-01) |
| + |
| +R1. Registrar: Openprovider, on a membership plan (domains at cost). |
| + DNSimple stays the platform's ACME DNS-01 backend, untouched, and could |
| + be a second registrar adapter later. |
| +R2. DNS: Route 53 hosted zones on one reusable delegation set, with |
| + white-label nameserver names, so customers only see the Carloku name. |
| +R3. Apex routing: steering's latency records with their health checks, |
| + written into each bought zone. Not Global Accelerator, not DNSimple |
| + ALIAS. |
| +R4. Payment: a separate one-off charge when the customer buys. |
| +R5. Renewal: automatic, governed by a per-domain flag. |
| +R6. Leaving: easy, self-serve; recommend DNSimple. |
| +R7. Transfers in: allowed later, not a priority. |
| + |
| +## 4. What the customer sees |
| + |
| +### 4.1 Buying |
| + |
| +Command line (exact verbs and flags are the builder's, within the |
| +existing `carlos domains` family): |
| + |
| + carlos domains check shop.example |
| + carlos domains buy shop.example --app shop |
| + |
| +Console: a "Buy a domain" action beside "Add a domain" on the app's |
| +Domains tab, with a name search, the price, and a confirm step. |
| + |
| +Sequence: |
| +1. **Check.** Availability and price for the name. Premium names and TLDs |
| + outside the operator's list (§6.2) are refused here, with the reason. |
| +2. **Contact details.** On an account's first purchase, the registrant's |
| + name, postal address, email and phone. The customer is the registrant |
| + (§4.4). Later purchases reuse them; the customer can edit them. |
| +3. **Confirm and pay.** The price, in the account's currency with VAT as |
| + the billing seam already handles it, and an explicit confirm. In the |
| + console this is a payment page that handles card authentication (SCA). |
| + From the CLI it charges the card on file, or prints a link to finish in |
| + the browser when the card needs authentication or there is none. |
| +4. **Register and wire up** (§5.1). The CLI waits and shows progress; the |
| + console shows the same steps live. |
| +5. **Done** when the existing status reads `live`: DNS points and a |
| + certificate covers the name. Expected: one to five minutes. A brand-new |
| + domain has nothing cached anywhere, so there is no propagation wait |
| + beyond the registry publishing its nameservers. |
| + |
| +`www.<domain>` is wired to the same app by default. |
| + |
| +A purchase needs a paid plan, the same rule as attaching a custom domain |
| +today (plans Plan 3a: custom domains are paid-only). |
| + |
| +### 4.2 Renewal |
| + |
| +- Every registration has an auto-renew flag, on by default (my call), |
| + switchable in the console and the CLI. |
| +- With it on, Carloku charges the card on file 30 days before expiry (my |
| + call) and renews at the registrar only once the charge succeeds. A |
| + failed charge retries and emails the owner; the domain is not renewed |
| + until it is paid. |
| +- With it off, the owner gets reminder emails at 30, 7 and 1 days before |
| + expiry (my call) and can renew by hand. |
| +- At expiry with no renewal, Carloku does nothing to the zone or the |
| + claim. What the domain does now is the registry's and registrar's |
| + lifecycle (grace, then redemption, then release). Carloku emails at |
| + expiry and during grace. Once the registrar reports the domain gone, the |
| + zone and the claim are removed. |
| + |
| +### 4.3 Taking the domain away |
| + |
| +One button or command: |
| +- unlocks the domain at the registrar and shows the transfer (EPP) code, |
| +- offers the zone as a standard zone file, and |
| +- says, in reviewed copy, that DNSimple is a good place to take it, with a |
| + link and the short steps, and that it can import the zone file. |
| + |
| +The zone keeps answering on Carloku's nameservers until the registrar |
| +reports the transfer complete and the domain's nameservers no longer name |
| +ours, then it is deleted. A customer leaving Carloku altogether is told to |
| +change their records before their apps go, or the domain will point at |
| +nothing. |
| + |
| +The registry's 60-day lock after a registration or transfer is shown |
| +plainly, with the date it lifts, instead of failing at the registrar. |
| + |
| +Deleting a Carloku account that still holds registrations is refused up |
| +front, naming the domains, until each is transferred out or released (my |
| +call: a paid-for domain is the customer's property, and silently dropping |
| +it is the anti-goal in §2). |
| + |
| +### 4.4 Ownership and privacy |
| + |
| +The registrant is the customer, with their own contact details, so the |
| +domain is theirs in the registry's records. Public WHOIS shows the |
| +registrar's privacy or redaction, never the customer's details. |
| +Registrant email verification (an ICANN rule the registrar enforces) is |
| +surfaced in the console and the CLI as an action the customer must take, |
| +with the deadline. |
| + |
| +## 5. How it works |
| + |
| +### 5.1 The purchase sequence |
| + |
| +The order is chosen so no failure leaves money, a registration and a zone |
| +out of step in a way nobody notices: |
| + |
| +1. Check availability and price at the registrar. Check the operator's |
| + prepaid registrar balance covers it; refuse up front if not, and alert |
| + the operator (§6.3). |
| +2. **Authorise** the payment, capture later (my call: authorise-then- |
| + capture, so a registration that fails cancels an authorisation instead |
| + of issuing a refund). |
| +3. Create the hosted zone on the delegation set and write the managed |
| + records (§5.3). |
| +4. Register the domain at the registrar, naming the white-label |
| + nameservers, the registrant handle and registrar-side auto-renew OFF |
| + (§5.5). |
| +5. On success: capture the payment, record the registration, and call the |
| + existing attach (`internal/console/domainattach.go`) for the domain and |
| + `www`, naming the app. From here the existing path does the rest: the |
| + claim reaches the boxes, the status moves through `issuing-cert` to |
| + `live`, and the certificate warm (#386) orders the certificate as soon |
| + as DNS points. |
| +6. On registrar failure: cancel the authorisation and delete the zone. |
| + On an ambiguous registrar answer (timeout), do NOT cancel: record the |
| + purchase as pending and reconcile it against the registrar before |
| + either capturing or cancelling (the builder decides the mechanism; the |
| + rule is that an ambiguous answer is never read as a failure). |
| + |
| +Renewal is the same shape: charge, then renew, then record; an ambiguous |
| +renew is reconciled, never retried blind. |
| + |
| +### 5.2 Branded nameservers (operator setup, once per deployment) |
| + |
| +AWS's documented white-label procedure, done once by the operator: |
| +- a reusable delegation set, |
| +- four names under a nameserver domain the operator chooses, each with A |
| + and AAAA records to the delegation set's servers, |
| +- glue records for those names at the nameserver domain's registrar. |
| + |
| +The nameserver domain should be separate from the console and apps |
| +domains, so a mistake in one does not take out the other (my call; the |
| +operator picks it). The setup is a runbook plus a `carlos` check that |
| +verifies the glue, the A/AAAA answers and the delegation set, not |
| +automation: it happens once. |
| + |
| +AWS also suggests telling the large public resolvers about white-label |
| +names when using location-based routing, so they keep sending the |
| +client-subnet hint latency routing uses. That is an operator step in the |
| +runbook. |
| + |
| +### 5.3 What each bought zone holds |
| + |
| +Created on the delegation set, so it answers from the branded servers: |
| +- SOA and NS rewritten to the branded names (Route 53 creates them with |
| + `awsdns` names; AWS's procedure rewrites both). |
| +- The apex: steering's latency A records, one per armed edge, each bound |
| + to that edge's existing health check (§5.4). |
| +- `www`: an ALIAS to the apex (same zone, so Route 53 allows it). |
| +- Any records the attach status asks for that are not covered above (for |
| + example a wildcard's `_acme-challenge` CNAME). |
| +- Tenant email (#147/#148): `dnsrec` already finds the zone by parent |
| + suffix, so a sender identity on a bought domain gets its DKIM, MAIL FROM |
| + and SPF/DMARC records written automatically. |
| + |
| +Everything above is "managed": Carloku writes it and owns it. |
| + |
| +### 5.4 Keeping the apex steered |
| + |
| +The apex record set is a copy of the steered set for the deployment's |
| +steering host (`edge.<apps-domain>`): same edges, same regions, same health |
| +check IDs. Route 53 health checks are account-wide, so a new zone adds no |
| +new checks, and failover is the health checks' job on every query; no |
| +record is rewritten when an edge fails. |
| + |
| +Records change only when an edge is armed or disarmed. Then every bought |
| +zone's apex must follow. Route 53's change API allows about five requests |
| +per second per account; the converger batches one change per zone and |
| +paces itself, and states the time to converge N zones in its log. |
| + |
| +Which component converges, and when (the builder decides, within these |
| +rules): |
| +- One writer for bought zones. Today the console writes `dnsrec` records |
| + and the box-side steering converger owns the steering zone and the |
| + health checks. Pick one owner for bought-zone apex sets and say why. |
| +- Converge on an edge-set change, plus a slow backstop that compares and |
| + repairs drift. No new per-box or per-pass bucket polling: ride what is |
| + already read, or the #336 change index (§7.2). |
| +- A deployment with no steering (no `CARLOS_STEERING_ZONE_ID`) writes |
| + plain A records to its edge IPs instead, the same alternative the attach |
| + guidance offers today. |
| + |
| +Leave room for one more source of apex addresses: a deployment setting |
| +naming fixed apex IPs (for example a Global Accelerator) that, when set, |
| +replaces the latency set. Not built in v1; the code should not make it |
| +hard. |
| + |
| +### 5.5 The registrar never acts alone |
| + |
| +Registrar-side auto-renew is OFF on every registration Carloku makes. |
| +Carloku's own renewal (§4.2) is the only thing that renews, and only after |
| +payment. A daily reconcile compares Carloku's record of each registration |
| +(expiry, nameservers, lock, status) with the registrar's, and reports any |
| +difference to the operator rather than silently "fixing" it either way. |
| + |
| +## 6. Money and operations |
| + |
| +### 6.1 Charging |
| + |
| +The billing seam today models subscriptions and Checkout. Domains need |
| +one-off charges: an authorise-and-capture for purchases and renewals, with |
| +off-session charges against a saved card for renewals, and a browser link |
| +when the card needs authentication. That is new surface on |
| +`billing.Provider`, with the Stripe adapter implementing it. The console |
| +imports only `internal/billing`. |
| + |
| +### 6.2 Prices |
| + |
| +An operator catalog lists the TLDs offered and the price per TLD in each |
| +supported currency (my call: fixed catalog prices, like the plan catalog, |
| +rather than live conversion). At the check step the registrar's current |
| +cost must stay below the catalog price by an operator-set margin; |
| +otherwise the TLD is refused with "not available right now" and the |
| +operator is alerted. That protects against a registry price rise (the |
| +.com fee rose on 2026-11-01) silently selling at a loss. |
| + |
| +### 6.3 Registrar balance |
| + |
| +Openprovider debits a prepaid balance. The operator gets an alert through |
| +the existing fleet alert path when the balance falls below a threshold, |
| +and purchases are refused up front (§5.1 step 1) when it cannot cover one. |
| + |
| +### 6.4 Abuse |
| + |
| +Registration is an abuse and fraud vector (phishing names, stolen cards). |
| +v1 limits: paid plan required, a per-account cap on purchases per day (an |
| +operator setting), and the registrar's abuse reports routed to the |
| +operator. Takedown policy is the operator's, outside this spec. |
| + |
| +## 7. Constraints |
| + |
| +### 7.1 Provider boundary |
| + |
| +- Core: the purchase sequence, the registration record, renewal, |
| + transfer-out, the reconcile, the catalog, the doors. No AWS SDK, no |
| + Openprovider types. |
| +- `Registrar` interface, Openprovider the first adapter (REST, |
| + `api.openprovider.eu/v1`, bearer token; the `/v1beta` paths retire on |
| + 2027-06-30, so build on `/v1`). Openprovider has a sandbox; tests and the |
| + dev deployment use it. |
| +- `ZoneHost` interface (create/delete zone on the branded delegation set, |
| + write managed records, export a zone file), Route 53 the first adapter, |
| + loaded through `internal/rootaws` like every other AWS client. |
| +- Payment through `internal/billing`. |
| +- A deployment without a registrar adapter, a zone host adapter or a |
| + billing provider has no buy door, and the capability block in the |
| + domains list answer (managed custom domains spec §2c) says so. Nothing |
| + else changes for it. A self-hoster without AWS can still add a zone host |
| + adapter for their own DNS later. |
| + |
| +### 7.2 Request budget |
| + |
| +- S3: zero new steady-state requests per box per day. Bought domains reach |
| + boxes as ordinary claims, through the existing path. Any new bucket |
| + object a reader polls maps to a change-index scope. |
| +- Route 53 API: a purchase is a handful of calls; edge-set changes cost |
| + one change per bought zone, paced under the account rate limit; the |
| + backstop compare costs one read per zone per run. State the figures in |
| + the plan. |
| +- Registrar API: one reconcile read per registration per day, plus the |
| + calls a purchase, renewal or transfer makes. |
| + |
| +### 7.3 Copy |
| + |
| +Every customer-facing string (console, CLI, emails, the DNSimple |
| +recommendation) goes through copy review before it ships. No registrar or |
| +DNS host name appears in any of it. |
| + |
| +### 7.4 Secrets |
| + |
| +Openprovider credentials and the zone host's write access live only where |
| +the component that uses them runs, never in a log line (the |
| +`billingstripe` redaction pattern). |
| + |
| +## 8. Left to the builder |
| + |
| +- Exact CLI verbs and flags, console layout, and table shapes. |
| +- Which component owns bought-zone apex convergence (§5.4), with the |
| + reason. |
| +- The pending-purchase reconcile mechanism (§5.1 step 6). |
| +- How the registrant handle maps to Openprovider customers and which |
| + TLD-specific extra fields v1's TLD list needs. |
| +- Plan ordering, with something Paul can see first (stopping rule 6): |
| + for example, buying a domain on dev against the Openprovider sandbox. |
| + |
| +## 9. Switch-on |
| + |
| +Who is asking: Paul, for Carloku. Switch-on: the first plan merges with |
| +the buy door on dev (Openprovider sandbox), and flagship switches on once |
| +the operator has the Openprovider membership, a funded balance, the |
| +nameserver domain and the delegation set (the §5.2 runbook). Nothing |
| +merges dormant without that date being set in the plan. |