Regional domains (#447): a regional domain's state says regional, and a wildcard keeps its delegation record
Whole-branch R1 P2-2: no box reports a hostname reading for a regional apex, so the list, the per-host GET and the settings page said checking forever. claimState now gives a regional claim the state regional (reason per-region) with RD-46 as its detail, pointing at carlos domains placements; all three surfaces derive through it and nothing reads per row. regional joins the advertised state vocabulary. RD-46 is a new draft row (post-Luna; for the final copy pass) and the copy gate inventory grows to RD-46, with a check that the draft text is in the code. Whole-branch R1 P2-3: a regional claim still gets no pointing records, but a wildcard keeps its required _acme-challenge CNAME (delegationRecords, split out of domainRecords), so a missing delegation comes with the record to create.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 files changed,
+147
−29
approved_regional_domains_copy_test.go+35 −11docs/superpowers/plans/2026-10-28-regional-domains-447-copy.md+5 −0internal/console/apidomains.go+4 −1internal/console/apiplacements.go+6 −0internal/console/apiplacements_test.go+55 −2internal/console/domainstate.go+38 −15internal/console/domainstate_test.go+4 −0
diff --git a/approved_regional_domains_copy_test.go b/approved_regional_domains_copy_test.go| index 981a1cdc1..daf991b54 100644 |
| --- a/approved_regional_domains_copy_test.go |
| +++ b/approved_regional_domains_copy_test.go |
| @@ -27,19 +27,26 @@ const regionalDomainsCopyRecordPath = "docs/superpowers/plans/2026-10-28-regiona |
| var regionalDomainsCopyIDPattern = regexp.MustCompile(`^RD-[0-9]+$`) |
| -// regionalDomainsCopyIDs is the record's inventory, pinned: RD-1 to RD-45. |
| -var regionalDomainsCopyIDs = func() []string { |
| - ids := make([]string, 0, 45) |
| - for i := 1; i <= 45; i++ { |
| +// regionalDomainsCopyIDs is the record's inventory, pinned: RD-1 to RD-46. |
| +var regionalDomainsCopyIDs = regionalDomainsIDRange(46) |
| + |
| +// regionalDomainsCopyBuilt is every id whose approved text the code or docs |
| +// carry: RD-1 to RD-45. Luna's pass 3 approved those (2026-10-29, Paul's |
| +// delegation for large decks) and Task 11 applied them verbatim. RD-46 came |
| +// after (whole-branch R1 P2-2) and is a draft for the final copy pass. |
| +var regionalDomainsCopyBuilt = regionalDomainsIDRange(45) |
| + |
| +// regionalDomainsDraft is the status of a row written after Luna's pass 3, |
| +// waiting for the final copy pass. |
| +const regionalDomainsDraft = "draft (post-Luna; for the final copy pass)" |
| + |
| +func regionalDomainsIDRange(n int) []string { |
| + ids := make([]string, 0, n) |
| + for i := 1; i <= n; i++ { |
| ids = append(ids, "RD-"+strconv.Itoa(i)) |
| } |
| return ids |
| -}() |
| - |
| -// regionalDomainsCopyBuilt is every id whose approved text the code or docs |
| -// carry: all of them. Luna's pass 3 approved the deck (2026-10-29, Paul's |
| -// delegation for large decks) and Task 11 applied it verbatim. |
| -var regionalDomainsCopyBuilt = regionalDomainsCopyIDs |
| +} |
| func mustParseRegionalDomainsRecord(t *testing.T) []copyRow { |
| t.Helper() |
| @@ -47,7 +54,8 @@ func mustParseRegionalDomainsRecord(t *testing.T) []copyRow { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - rows, err := parseCopyTable(string(raw), regionalDomainsCopyRecordPath, regionalDomainsCopyIDPattern, "an RD-<n>") |
| + rows, err := parseCopyTableStatuses(string(raw), regionalDomainsCopyRecordPath, regionalDomainsCopyIDPattern, "an RD-<n>", |
| + "pending", "approved", regionalDomainsDraft) |
| if err != nil { |
| t.Fatal(err) |
| } |
| @@ -121,6 +129,22 @@ func TestRegionalDomainsBuiltCopyIsApplied(t *testing.T) { |
| reportAll(t, checkRegionalDomainsApplied(builtRows(mustParseRegionalDomainsRecord(t), regionalDomainsCopyBuilt), ".")) |
| } |
| +// A post-Luna draft row is in the code as drafted too, so the final copy |
| +// pass reviews exactly what ships. Checked as the approved rows are. |
| +func TestRegionalDomainsDraftCopyIsApplied(t *testing.T) { |
| + var drafts []copyRow |
| + for _, r := range mustParseRegionalDomainsRecord(t) { |
| + if r.Status == regionalDomainsDraft { |
| + r.Status = "approved" |
| + drafts = append(drafts, r) |
| + } |
| + } |
| + if len(drafts) == 0 { |
| + t.Fatal("no draft rows: once the final copy pass approves RD-46, add it to regionalDomainsCopyBuilt and drop this test") |
| + } |
| + reportAll(t, checkRegionalDomainsApplied(drafts, ".")) |
| +} |
| + |
| // The gate bites: a row whose text is not in its file, and a fragment that |
| // is only in a comment, are refused; a row inside a multi-line literal and a |
| // placeholder row are accepted. |
diff --git a/docs/superpowers/plans/2026-10-28-regional-domains-447-copy.md b/docs/superpowers/plans/2026-10-28-regional-domains-447-copy.md| index c985cd864..5af873ba6 100644 |
| --- a/docs/superpowers/plans/2026-10-28-regional-domains-447-copy.md |
| +++ b/docs/superpowers/plans/2026-10-28-regional-domains-447-copy.md |
| @@ -15,6 +15,10 @@ The rules: |
| Paul's delegation for large decks (`LUNA-COPY-REVIEW-REGIONAL-DOMAINS.md`, |
| pass 3, applied verbatim). A row that changes now goes back through the |
| review. |
| +- RD-46 came after that pass (whole-branch review R1 P2-2: the state |
| + detail of a regional domain on the domain list, the per-host GET and the |
| + settings page). It is `draft (post-Luna; for the final copy pass)`; the |
| + code carries the draft text until that pass approves it. |
| - Every row started `draft`. The implementing tasks write the draft text |
| into code so the branch works end to end. The copy task (plan Task 11) |
| runs the review: a Luna pass on Paul's house rules, then Paul's approval |
| @@ -91,6 +95,7 @@ count. |
| | RD-41 | internal/console/apiplacements.go | <box> does not say which release it runs. try again when every server runs <floor> or later. | approved | |
| | RD-44 | internal/console/apiplacements.go | <host> is a regional domain. carlos domains placements shows the addresses to point DNS at for each region. | approved | |
| | RD-45 | internal/console/apiplacements.go | servers on the <channel> channel are moving to <release>, which cannot serve regional domains. try again when they move to <floor> or later. | approved | |
| +| RD-46 | internal/console/apiplacements.go | a regional domain is ready region by region. carlos domains placements shows which regions are ready. | draft (post-Luna; for the final copy pass) | |
| ## Release floor (operators: internal/release, internal/console, system.go) |
diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go| index 2c2e3b425..ed625b000 100644 |
| --- a/internal/console/apidomains.go |
| +++ b/internal/console/apidomains.go |
| @@ -1451,8 +1451,11 @@ func (s *Server) domainItem(ctx context.Context, c domains.Claim, readings map[s |
| case c.Regional(): |
| // Each region has its own addresses, which the placements read |
| // gives: the single-edge advice and its records would send every |
| - // region's visitors to every edge. |
| + // region's visitors to every edge. A wildcard's delegation CNAME is |
| + // not a pointing record, and stays: without it the delegation check |
| + // below can say "missing" with nothing to create. |
| item.Guidance = regionalDNSGuidance(c.Host) |
| + item.Records = delegationRecords(c.Host, c.Wildcard, s.delegationZone) |
| case item.DNSStatus != "pointing" && item.DNSStatus != "unresolved": |
| item.Guidance = domainGuidance(c.Host, targets) |
| // The structured form of the SAME advice, emitted under exactly the |
diff --git a/internal/console/apiplacements.go b/internal/console/apiplacements.go| index e14f55a74..cb3287784 100644 |
| --- a/internal/console/apiplacements.go |
| +++ b/internal/console/apiplacements.go |
| @@ -395,6 +395,12 @@ func regionalDNSGuidance(host string) string { |
| return fmt.Sprintf("%s is a regional domain. carlos domains placements shows the addresses to point DNS at for each region.", host) |
| } |
| +// regionalStateDetail (RD-46) is the detail beside a regional domain's |
| +// state on the domain list, the per-host GET and the settings page |
| +// (claimState). Readiness is per region, and the placements read is the |
| +// only surface that judges it. |
| +const regionalStateDetail = "a regional domain is ready region by region. carlos domains placements shows which regions are ready." |
| + |
| // placementsControlPlaneVerb (RD-40) completes controlPlaneRefusal's |
| // sentence: "<app> is marked as the control plane, so it cannot be ...". |
| const placementsControlPlaneVerb = "given a regional domain" |
diff --git a/internal/console/apiplacements_test.go b/internal/console/apiplacements_test.go| index 4331acf81..2cf031e9e 100644 |
| --- a/internal/console/apiplacements_test.go |
| +++ b/internal/console/apiplacements_test.go |
| @@ -9,6 +9,7 @@ package console |
| import ( |
| "context" |
| "encoding/json" |
| + "errors" |
| "net/http" |
| "strings" |
| "testing" |
| @@ -469,6 +470,11 @@ func TestRegionalDomainGetsNoSingleEdgeDNSAdvice(t *testing.T) { |
| if row == nil || row["guidance"] != want || row["records"] != nil { |
| t.Errorf("%s row = %v, want guidance %q and no records", what, row, want) |
| } |
| + // Not "checking" forever (whole-branch R1 P2-2): no box ever |
| + // reports a regional apex, so its state says where readiness is. |
| + if row["state"] != StateRegional || row["reason"] != "per-region" || row["detail"] != regionalStateDetail { |
| + t.Errorf("%s row = %v, want state %q, reason per-region, detail %q", what, row, StateRegional, regionalStateDetail) |
| + } |
| } |
| if plain := rows["plain.example.com"]; plain == nil || plain["guidance"] == want || plain["records"] == nil { |
| t.Errorf("ordinary row = %v, want its own DNS advice and records", plain) |
| @@ -482,10 +488,57 @@ func TestRegionalDomainGetsNoSingleEdgeDNSAdvice(t *testing.T) { |
| for _, dv := range w.fx.srv.settingsDomains(context.Background(), acct, "shop", nil) { |
| views[dv.Domain] = dv |
| } |
| - if dv := views[rdHost]; dv.Guidance != want { |
| - t.Errorf("settings row = %+v, want guidance %q", dv, want) |
| + if dv := views[rdHost]; dv.Guidance != want || dv.State != StateRegional || dv.Detail != regionalStateDetail { |
| + t.Errorf("settings row = %+v, want guidance %q, state %q, detail %q", dv, want, StateRegional, regionalStateDetail) |
| } |
| if dv := views["plain.example.com"]; dv.Guidance == "" || dv.Guidance == want { |
| t.Errorf("ordinary settings row = %+v, want its own DNS advice", dv) |
| } |
| } |
| + |
| +// A regional wildcard keeps the one record its certificate needs |
| +// (whole-branch R1 P2-3): with the delegation missing, the list row and the |
| +// per-host GET say "missing" AND carry the _acme-challenge CNAME to create, |
| +// required, while still sending none of the single-edge pointing records. |
| +func TestRegionalWildcardKeepsTheDelegationRecord(t *testing.T) { |
| + const zone = "acme.example.org" |
| + w := newRegionalWorld(t, "code-rd-delegation") |
| + w.fx.srv.delegationZone = zone |
| + w.fx.srv.lookupCNAME = func(_ context.Context, name string) (string, error) { |
| + return name + "." + zone + ".", nil |
| + } |
| + both := rdBoth() |
| + both.Wildcard = boolp(true) |
| + w.mustPut(t, rdHost, both) |
| + // The delegation is removed after creation. |
| + w.fx.srv.lookupCNAME = func(context.Context, string) (string, error) { return "", errors.New("not found") } |
| + |
| + status, out := getJSON(t, domainsURL(w.fx, w.fx.sqid, "shop"), w.token) |
| + if status != http.StatusOK { |
| + t.Fatalf("list = %d %v", status, out) |
| + } |
| + var listed map[string]any |
| + for _, r := range out["domains"].([]any) { |
| + if row := r.(map[string]any); row["host"] == rdHost { |
| + listed = row |
| + } |
| + } |
| + status, got := getJSON(t, domainGetURL(w.fx, w.fx.sqid, "shop", rdHost), w.token) |
| + if status != http.StatusOK { |
| + t.Fatalf("GET %s = %d %v", rdHost, status, got) |
| + } |
| + for what, row := range map[string]map[string]any{"list": listed, "GET": got["domain"].(map[string]any)} { |
| + if row == nil || row["delegation_status"] != "missing" || row["state"] != StateRegional { |
| + t.Fatalf("%s row = %v, want delegation missing and state %q", what, row, StateRegional) |
| + } |
| + recs, _ := row["records"].([]any) |
| + if len(recs) != 1 { |
| + t.Fatalf("%s records = %v, want only the delegation CNAME", what, row["records"]) |
| + } |
| + rec := recs[0].(map[string]any) |
| + if rec["type"] != "CNAME" || rec["name"] != "_acme-challenge."+rdHost || |
| + rec["value"] != "_acme-challenge."+rdHost+"."+zone || rec["required"] != true || rec["set"] != "acme" { |
| + t.Fatalf("%s record = %v, want the required _acme-challenge CNAME into %s", what, rec, zone) |
| + } |
| + } |
| +} |
diff --git a/internal/console/domainstate.go b/internal/console/domainstate.go| index 11f89f532..d49b3c72d 100644 |
| --- a/internal/console/domainstate.go |
| +++ b/internal/console/domainstate.go |
| @@ -68,6 +68,14 @@ const ( |
| // state: a box never reports on a pending claim, so any reading for the |
| // host belongs to someone else's route, not to this claim. |
| StateUnverified = "unverified" |
| + // StateRegional — a regional domain (#447). Its readiness is a |
| + // per-region answer that only the placements read gives: no box |
| + // reports a hostname reading for it (regional derivation writes no |
| + // ordinary alias row, so the heartbeats never carry one), and without |
| + // this state it would read "checking" forever. The detail points at |
| + // carlos domains placements; nothing here reads per region, so the |
| + // list keeps its request budget. |
| + StateRegional = "regional" |
| ) |
| // domainStates is the vocabulary this build can actually produce, in |
| @@ -82,6 +90,7 @@ const ( |
| // them. |
| var domainStates = []string{ |
| StateUnverified, StateChecking, StatePendingDNS, StateMisdirected, StateIssuingCert, StateFailed, StateLive, StateUnknown, |
| + StateRegional, |
| } |
| // domainFailedAttempts is how many consecutive failed warm attempts it takes |
| @@ -155,13 +164,18 @@ func domainState(reading status.AliasReading, seen bool, warm *certwarm.Record, |
| } |
| // claimState is domainState for a claim: an unproven claim reads |
| -// "unverified" whatever the readings say (see StateUnverified), and every |
| -// other claim reads what its readings derive. |
| +// "unverified" whatever the readings say (see StateUnverified), a regional |
| +// claim reads "regional" (see StateRegional), and every other claim reads |
| +// what its readings derive. The list, the per-host GET and the settings |
| +// page all derive through here, so the three say the same thing. |
| func claimState(c domains.Claim, reading status.AliasReading, seen bool, warm *certwarm.Record, now time.Time) (state, reason, detail string) { |
| if c.Pending { |
| return StateUnverified, "ownership-unproven", |
| "Prove you control this hostname by adding the TXT record below. Nothing is served for it until then." |
| } |
| + if c.Regional() { |
| + return StateRegional, "per-region", regionalStateDetail |
| + } |
| return domainState(reading, seen, warm, now) |
| } |
| @@ -218,20 +232,29 @@ func domainRecords(host string, t DNSTargets, wildcard bool, delegationZone stri |
| TTL: domainRecordTTL, Set: "a", |
| }) |
| } |
| - // A wildcard-enabled claim also needs its delegation CNAME, and it is |
| - // required alongside EITHER alternative above — the platform already |
| - // instructs this at the attach door and stamps delegation_status from it, |
| - // so omitting it here would make "what you must create" incomplete |
| - // against our own surface. |
| - if wildcard && delegationZone != "" { |
| - out = append(out, dnsRecord{ |
| - Type: "CNAME", |
| - Name: "_acme-challenge." + host, |
| - Value: "_acme-challenge." + host + "." + delegationZone, |
| - TTL: domainRecordTTL, Set: "acme", Required: true, |
| - }) |
| + return append(out, delegationRecords(host, wildcard, delegationZone)...) |
| +} |
| + |
| +// delegationRecords is a wildcard-enabled claim's delegation CNAME, or |
| +// nothing. It is required alongside EITHER pointing alternative — the |
| +// platform already instructs this at the attach door and stamps |
| +// delegation_status from it, so omitting it would make "what you must |
| +// create" incomplete against our own surface. |
| +// |
| +// Split out of domainRecords for the regional domain (#447), which gets |
| +// this record and none of the pointing ones: where its traffic goes is per |
| +// region and the placements read says it, but its one certificate still |
| +// needs the delegation, wherever the traffic points. |
| +func delegationRecords(host string, wildcard bool, delegationZone string) []dnsRecord { |
| + if !wildcard || delegationZone == "" { |
| + return nil |
| } |
| - return out |
| + return []dnsRecord{{ |
| + Type: "CNAME", |
| + Name: "_acme-challenge." + host, |
| + Value: "_acme-challenge." + host + "." + delegationZone, |
| + TTL: domainRecordTTL, Set: "acme", Required: true, |
| + }} |
| } |
| // deploymentCapability is the self-describing block folded into the domains |
diff --git a/internal/console/domainstate_test.go b/internal/console/domainstate_test.go| index 8329a3e61..41bfbc2f6 100644 |
| --- a/internal/console/domainstate_test.go |
| +++ b/internal/console/domainstate_test.go |
| @@ -96,6 +96,10 @@ func TestAdvertisedStatesAreExactlyTheReachableOnes(t *testing.T) { |
| // stored pending is exactly what a member's unproven attach writes. |
| s, _, _ := claimState(domains.Claim{Pending: true}, status.AliasReading{DNSStatus: "pointing"}, true, nil, now) |
| produced[s] = true |
| + // "regional" comes from the claim too (#447): a claim with placements |
| + // is exactly what the placements PUT writes, and no box reports on it. |
| + s, _, _ = claimState(domains.Claim{Placements: []domains.Placement{{Host: "shop-ie.example.net"}}}, status.AliasReading{}, false, nil, now) |
| + produced[s] = true |
| for _, s := range domainStates { |
| if !produced[s] { |
| t.Errorf("state %q is advertised but nothing produces it", s) |