carlos / platform Public

Regional domains (#447): T10 round 2 P2 fixes (pointer GET budget, deterministic mutex test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 011004cb3c1f860d1fa1e4b46f7086dd3f3d2942 parent 9ef2e9a
3 files changed, +41 −1
  • docs/superpowers/specs/2026-10-28-regional-domains-447-design.md +1 −1
  • internal/console/apiplacements_put_test.go +34 −0
  • internal/console/regionalfloor_test.go +6 −0
diff --git a/docs/superpowers/specs/2026-10-28-regional-domains-447-design.md b/docs/superpowers/specs/2026-10-28-regional-domains-447-design.md
index 8a5b5713e..01579eef2 100644
--- a/docs/superpowers/specs/2026-10-28-regional-domains-447-design.md
+++ b/docs/superpowers/specs/2026-10-28-regional-domains-447-design.md
@@ -999,7 +999,7 @@ A the deployment's accounts and K their apps:
| Act | Reads | Writes |
|---|---|---|
-| PUT (rev 4, recounted for R3 P2-1 and P2-2) | (1) claim GET with ETag (step 4). (2) Overlap GETs (§6.7): `domains/*.X.json` always, plus `domains/P.json` and `domains/*.P.json` when P has an interior dot: 1 or 3. (3) Binding records (step 3): 1 LIST + R bodies, as `listRecords` makes them (plus each record's lifetime slot when lifetimes are on). (4) Declared-ownership walk (step 5): 1 LIST of `accounts/` + A manifest GETs, then 1 ListDirs of `apps/` + A ListDirs + K LISTs of `instances/`, keys only, no record bodies (on a store without bucket ListDirs, `listAppSubtree`'s fallback: the `apps/` listing). (5) One snapshot: edges 1 LIST + B GETs, heartbeats 1 ListMod (or LIST) + H GETs; collision, never-served, overlap, `aliases_read`, barrier and the response all read it. (6) On create, one DNS TXT lookup. (7) (rev 5, R4 P2-1) `PendingForHost`: one query on the console's own SQLite, no bucket request. (8) (rev 5, ruling 6) On create with `wildcard`: one DNS CNAME lookup (the enabling gate's); with `catchall`: the descendant scan, one `domains/` ListMod through `s.claims` plus a GET per key whose mod time moved (cold cache: one per claim). Nothing else: no `heldElsewhere`, so no `DeploymentRoutes` fold, no `ForeignInstanceCatchall` GET and no catch-all app's records; `customDomainRefusal` reads the console's own database. (9) (rev 5.3) The barrier's channel check: one system pointer GET per channel the fresh heartbeats follow (canary and stable: at most 2), under `regionalMu` | claim PUT and the existing serial bump, only when bytes change |
+| PUT (rev 4, recounted for R3 P2-1 and P2-2) | (1) claim GET with ETag (step 4). (2) Overlap GETs (§6.7): `domains/*.X.json` always, plus `domains/P.json` and `domains/*.P.json` when P has an interior dot: 1 or 3. (3) Binding records (step 3): 1 LIST + R bodies, as `listRecords` makes them (plus each record's lifetime slot when lifetimes are on). (4) Declared-ownership walk (step 5): 1 LIST of `accounts/` + A manifest GETs, then 1 ListDirs of `apps/` + A ListDirs + K LISTs of `instances/`, keys only, no record bodies (on a store without bucket ListDirs, `listAppSubtree`'s fallback: the `apps/` listing). (5) One snapshot: edges 1 LIST + B GETs, heartbeats 1 ListMod (or LIST) + H GETs; collision, never-served, overlap, `aliases_read`, barrier and the response all read it. (6) On create, one DNS TXT lookup. (7) (rev 5, R4 P2-1) `PendingForHost`: one query on the console's own SQLite, no bucket request. (8) (rev 5, ruling 6) On create with `wildcard`: one DNS CNAME lookup (the enabling gate's); with `catchall`: the descendant scan, one `domains/` ListMod through `s.claims` plus a GET per key whose mod time moved (cold cache: one per claim). Nothing else: no `heldElsewhere`, so no `DeploymentRoutes` fold, no `ForeignInstanceCatchall` GET and no catch-all app's records; `customDomainRefusal` reads the console's own database. (9) (rev 5.3) The barrier's channel check: one system pointer GET per distinct channel the fresh heartbeats follow (stable, canary, a sub-channel such as `canary/paul`): one per distinct channel fresh boxes follow, at most the number of fresh boxes, under `regionalMu` | claim PUT and the existing serial bump, only when bytes change |
| GET | claim GET; one snapshot as above | none |
| `Catchall` turned on; instance catch-all attach | as today, plus one `domains/` ListMod through `s.claims`, and a GET per key whose mod time moved (cold cache: one per claim in the deployment) | as today |
| (rev 5) A capability write on a regional claim | the claim GET the door already makes (`apidomains.go:669`), then `SetClaimCapabilities`' own claim GET only for the same values; refused changes make no DNS lookup | none |
diff --git a/internal/console/apiplacements_put_test.go b/internal/console/apiplacements_put_test.go
index a99715d9e..33863a1b1 100644
--- a/internal/console/apiplacements_put_test.go
+++ b/internal/console/apiplacements_put_test.go
@@ -921,6 +921,40 @@ func TestPlacementsRefusesBelowAPublishedChannel(t *testing.T) {
requireRefusal(t, "canary published at v0.30.2", code, out, http.StatusConflict, placementsChannelBelowFloorMsg("canary", "v0.30.2", floor))
w.requireNoClaim(t, rdHost, "canary below the floor")
})
+ // [T10 R2 P2-1] The request budget: one pointer GET per distinct channel
+ // the fresh heartbeats follow, however many boxes follow it, so three
+ // channels with repeated followers cost exactly three GETs (stable,
+ // canary and a sub-channel), and nothing else reads a pointer.
+ t.Run("three channels, repeated followers", func(t *testing.T) {
+ w := regionalWorldOnStable(t, "code-rdput-chan-count")
+ for _, b := range []regionalBox{
+ rdBox("carol", "uk", "203.0.113.30", rdUK),
+ rdBox("dave", "uk", "203.0.113.40", rdUK),
+ rdBox("erin", "uk", "203.0.113.50", rdUK),
+ rdBox("frank", "uk", "203.0.113.60", rdUK),
+ rdBox("grace", "uk", "203.0.113.70", rdUK),
+ } {
+ b.Channel = map[string]string{"carol": "canary", "dave": "canary", "erin": "canary/paul", "frank": "stable", "grace": "canary/paul"}[b.Label]
+ w.putBox(t, b)
+ }
+ st := w.wrap()
+ w.mustPut(t, rdHost, rdBoth())
+ var pointers []string
+ for _, k := range st.gets {
+ if strings.HasPrefix(k, "control/system/") {
+ pointers = append(pointers, k)
+ }
+ }
+ slices.Sort(pointers)
+ want := []string{
+ release.SystemPointerKey("router", "canary"),
+ release.SystemPointerKey("router", "canary/paul"),
+ release.SystemPointerKey("router", "stable"),
+ }
+ if !slices.Equal(pointers, want) {
+ t.Fatalf("pointer GETs = %v, want exactly one each of %v", pointers, want)
+ }
+ })
t.Run("no pointer at all", func(t *testing.T) {
w := newRegionalWorld(t, "code-rdput-chan-none")
w.mustPut(t, rdHost, rdBoth())
diff --git a/internal/console/regionalfloor_test.go b/internal/console/regionalfloor_test.go
index 96f913255..653aff278 100644
--- a/internal/console/regionalfloor_test.go
+++ b/internal/console/regionalfloor_test.go
@@ -473,6 +473,12 @@ func TestRegionalFloorPublicationHoldsRegionalMu(t *testing.T) {
w := regionalWorldOnStable(t, "code-rdfloor-mutex")
var put <-chan rdAnswer
w.fx.srv.regionalFloorHooks.locked = func() {
+ // [T10 R2 P2-2] Deterministic: the hook runs inside the critical
+ // section, so regionalMu must be held here whatever the scheduling.
+ if w.fx.srv.regionalMu.TryLock() {
+ w.fx.srv.regionalMu.Unlock()
+ t.Error("the publication hook ran without regionalMu held")
+ }
put = w.putAsync(rdHost)
select {
case r := <-put: