carlos / platform Public

console: account subdomain review fixes, round 2 (T6)

- The canary flash names a name host only when the console box's
  registry row, or with none the app's instance record, is one a box
  derives a name for: a replica record, a sidecar or an unread record
  keeps the sqid host.
- TestSubdomainRollbackResetsClaimCache pins the claim cache reset after
  a rolled-back set over a caching (ListMod) store, beside the serial.
- TestCanaryFlashFromRecords: replica record and ordinary record with no
  local row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 4bd708702418fea38d67f5e39beccad63047ed1c parent 026994a
4 files changed, +120 −8
  • internal/console/apisubdomain_test.go +70 −0
  • internal/console/canonical.go +21 −7
  • internal/console/canonical_test.go +28 −0
  • internal/console/server.go +1 −1

CI failed — run details

Intent

Human

<task-notification> <task-id>a43e438c6ef448f9e</task-id> <tool-use-id>toolu_01RCdJPzNef5eohkqiYRuHbv</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/a43e438c6ef448f9e.output</output-file> <status>completed</status> <summary>Agent "Implement Task 6: door + canonical URLs" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE. All eight fixes from round 1 are in, and the console and provision census tests pass. Commit: `026994a4` console: account subdomain review fixes, round 1 (T6), on top of `e990eebb` and `db268270`. Tests: - Provision census guards (`TestPlan9B8RecordWriteCensus`, `TestPlan14RootReadCensus`): pass. - Console run (Step 2 selector, Task 5 tests, claim invariant, touched pages and APIs): passes in 395s. vet and gofmt are clean. - RED for the two unread-claim fixes: with the new checks switched off, both new tests failed (the second name was set and the serial bumped); with them back, they pass. Concerns: 1. **Census:** the guard flags five units, not the six Fable listed: list, update, channel move, `handleAppInstance` (changed this round) and `routeDecls`. All five are re-pinned with notes. The census doesn't count create, `beginImport` or `beginFrom` as units, so they need no pin. 2. **Service tokens get 403, not 401.** The shared gate answers 403 ("this door is closed to service credentials") for any service role at a `Set{}` door; 401 is only for an unknown or expired bearer. The tests assert 403 for both Service and Admin tokens on all three methods and the inventory. 3. **Rollback bump:** as you ruled, a rolled-back set still resets the cache and bumps the serial. It's pinned by a test and noted in the report as an exception to the brief. 4. **Not done:** - an "unknown" state in the settings cell (needs new copy) - a cached namespace view - rollback using its own Put's etag - the instance-list API filter matching `public_host` - the em dash in the canary flash, which is existing copy Report (fix section appended): `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-account-name-hosts/.superpowers/sdd/2026-11-11-account-subdomains/task-6-report.md`</result> <usage><subagent_tokens>461197</subagent_tokens><tool_uses>37</tool_uses><duration_ms>855586</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>bdx49oy3e</task-id> <tool-use-id>toolu_01FpuNirirT1NBstmpRrTvRp</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/bdx49oy3e.output</output-file> <status>completed</status> <summary>Background command "Run Astra re-review of T6 fix round 1" completed (exit code 0)</summary> </task-notification>

Attributed to this commit: 22.3 g CO₂e (2,869,412 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on design-account-name-hosts, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/console/apisubdomain_test.go b/internal/console/apisubdomain_test.go
index d96ca0532..c0f4b4318 100644
--- a/internal/console/apisubdomain_test.go
+++ b/internal/console/apisubdomain_test.go
@@ -14,6 +14,7 @@ import (
"fmt"
"net/http"
"os"
+ "path/filepath"
"reflect"
"strings"
"sync"
@@ -238,6 +239,75 @@ func TestSubdomainDoorRollsBackOnRace(t *testing.T) {
}
}
+// nsCachingRaceStore is nsRaceStore over a store that answers ListMod (the
+// fixture's DirStore under its deletableStore), so the claim cache caches as
+// it does in production, and it counts the reads of each key.
+type nsCachingRaceStore struct {
+ *nsRaceStore
+ dir *release.DirStore
+ mu sync.Mutex
+ gets map[string]int
+}
+
+func (s *nsCachingRaceStore) ListMod(ctx context.Context, prefix string) ([]release.KeyMod, error) {
+ return s.dir.ListMod(ctx, prefix)
+}
+
+func (s *nsCachingRaceStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ s.mu.Lock()
+ s.gets[key]++
+ s.mu.Unlock()
+ return s.nsRaceStore.Get(ctx, key)
+}
+
+// reads is how often key was read since the last call, and resets it.
+func (s *nsCachingRaceStore) reads(key string) int {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ n := s.gets[key]
+ s.gets = map[string]int{}
+ return n
+}
+
+// TestSubdomainRollbackResetsClaimCache (ruled exception, fix round 2): a
+// rolled-back set resets the claim cache. A settled claim the cache holds
+// is not read again by an ordinary listing; after the rolled-back set the
+// next listing reads it again, because the cache was reset.
+func TestSubdomainRollbackResetsClaimCache(t *testing.T) {
+ fx, operator, _ := sdFixture(t, "code-sd-race-cache")
+ nsAccount(t, fx, 49, "bcd")
+ settled := domains.Claim{Schema: 1, Host: "shop.example.com", Account: "bdq", App: "shop", CreatedAt: time.Now().UTC().Format(time.RFC3339)}
+ nsPutClaim(t, fx, settled)
+ ds := fx.rel.(*deletableStore)
+ old := time.Now().Add(-time.Hour)
+ if err := os.Chtimes(filepath.Join(ds.root, filepath.FromSlash(domains.ClaimKey(settled.Host))), old, old); err != nil {
+ t.Fatal(err)
+ }
+ foreign := domains.Claim{Schema: 1, Host: "x.harbour." + nsApps, Account: "bcd", App: "web", CreatedAt: time.Now().UTC().Format(time.RFC3339)}
+ store := &nsCachingRaceStore{dir: ds.Store.(*release.DirStore), gets: map[string]int{},
+ nsRaceStore: &nsRaceStore{Store: fx.rel, key: domains.ClaimKey(nsHarbourHost), after: func() { nsPutClaim(t, fx, foreign) }}}
+ fx.srv.cfg.Releases = store
+ fx.srv.claims.Reset()
+ key := domains.ClaimKey(settled.Host)
+ nsView(t, fx.srv)
+ store.reads(key)
+ nsView(t, fx.srv)
+ if n := store.reads(key); n != 0 {
+ t.Fatalf("a settled claim was read %d times by a cached listing; the cache is not caching here", n)
+ }
+ if code, a, out := sdReq(t, fx, http.MethodPost, "bdq", operator, `{"name":"harbour"}`); code != http.StatusConflict || a.Code != string(domains.SubdomainRolledBack) {
+ t.Fatalf("set under a race = %d %s, want 409 rolled_back", code, out)
+ }
+ store.reads(key)
+ nsView(t, fx.srv)
+ if n := store.reads(key); n != 1 {
+ t.Errorf("after a rolled-back set the settled claim was read %d times, want 1: the claim cache was not reset", n)
+ }
+ if got := serial(t, fx); got != 1 {
+ t.Errorf("serial after a rolled-back set = %d, want 1", got)
+ }
+}
+
// TestSubdomainDoorRollsBackUnreadSecondName: a second namespace claim for
// the account lands after the write and its read fails. Nobody can say
// whose it is, so one name per account is not established: rolled back.
diff --git a/internal/console/canonical.go b/internal/console/canonical.go
index b5debf5cf..45c497ffe 100644
--- a/internal/console/canonical.go
+++ b/internal/console/canonical.go
@@ -122,11 +122,15 @@ func routePublicHost(c *hostCanon, rt registry.Route) string {
return c.public(rt.Host)
}
-// channelFlashHost is host as the canary create flash names it: the name
-// host only when the console box's registry row at host is one a box
-// derives a name for, or when no row is there (a record: provisioned).
-// A registry that cannot be read leaves the host as it is.
-func (s *Server) channelFlashHost(c *hostCanon, host string) string {
+// channelFlashHost is host, one of acct/app's channelHosts, as the canary
+// create flash names it: the name host only when what is known about host
+// says a box derives a name for it (derivesName). That is the console box's
+// registry row at host, or, with no row there, the app's instance record
+// at host (records are provisioned; a replica record is not eligible).
+// Anything else (a sidecar record, which is not an instance record; a
+// registry or record that cannot be read) leaves the host as it is: the
+// flash never names an address no box derives.
+func (s *Server) channelFlashHost(ctx context.Context, c *hostCanon, acct, app, host string) string {
reg, err := openRegistry(s.cfg.Registry)
if err != nil {
return host
@@ -136,10 +140,20 @@ func (s *Server) channelFlashHost(c *hostCanon, host string) string {
return host
}
for _, rt := range routes {
- if rt.Host == host && !derivesName(rt.Provisioned, rt.Platform, rt.Replica, rt.Kind) {
- return host
+ if rt.Host == host {
+ if !derivesName(rt.Provisioned, rt.Platform, rt.Replica, rt.Kind) {
+ return host
+ }
+ return c.host(host)
}
}
+ if s.cfg.Releases == nil {
+ return host
+ }
+ rec, err := provision.GetRecord(ctx, s.cfg.Releases, acct, app, host)
+ if err != nil || rec == nil || !derivesName(true, false, rec.Role == "replica", rec.KindOrDefault()) {
+ return host
+ }
return c.host(host)
}
diff --git a/internal/console/canonical_test.go b/internal/console/canonical_test.go
index 423800960..901e7fc2e 100644
--- a/internal/console/canonical_test.go
+++ b/internal/console/canonical_test.go
@@ -16,6 +16,7 @@ import (
"testing"
"time"
+ "github.com/carlosframework/platform/internal/provision"
"github.com/carlosframework/platform/internal/registry"
"github.com/carlosframework/platform/internal/release"
)
@@ -152,6 +153,33 @@ func TestCanaryLinksUseName(t *testing.T) {
}
}
+// TestCanaryFlashFromRecords: a host following the canary with no row on
+// the console box comes from the app's instance record. A replica record
+// gets no derived name on any box, so the flash keeps its sqid host; an
+// ordinary record is provisioned and the flash names its name host.
+func TestCanaryFlashFromRecords(t *testing.T) {
+ for _, c := range []struct {
+ name, role, want string
+ }{
+ {"replica record", "replica", "rc.shop.bab." + nsApps},
+ {"record", "", "rc.shop.harbour." + nsApps},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ fx, b := canonFixture(t)
+ shipVersion(t, fx, "shop", "v1")
+ csrf := sessionToken(t, fx, b)
+ if err := provision.CreateRecord(context.Background(), fx.rel, provision.Record{Schema: 1, Host: "rc.shop.bab." + nsApps,
+ Slug: "rc", App: "shop", Account: "bab", Channel: "canary/rc", Role: c.role, Region: "ie",
+ CreatedAt: time.Now().UTC()}); err != nil {
+ t.Fatal(err)
+ }
+ postForm(t, b, fx.u("/apps/shop/canary"), url.Values{"csrf": {csrf}, "name": {"rc"}, "version": {"v1"}})
+ _, _, body := get(t, b, fx.u("/apps/shop"))
+ canonHas(t, "the canary flash", body, "live at https://"+c.want+" ")
+ })
+ }
+}
+
// TestReplicaRoutesKeepTheirHost: no box derives a name for a replica
// route (an edge-checkout shard), so neither the Running tab nor the routes
// read names one.
diff --git a/internal/console/server.go b/internal/console/server.go
index a87c35ed2..9f5f0f332 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -6609,7 +6609,7 @@ func (s *Server) handleNewCanary(w http.ResponseWriter, r *http.Request) {
if hosts, _ := s.channelHosts(ctx, acct.Sqid, app, channel); len(hosts) > 0 {
// Shown as the platform shows it: the name host where the account
// has a subdomain and a box derives it for this route (canonical.go).
- back("ok", "Created canary "+name+" — live at https://"+s.channelFlashHost(s.canon(ctx), hosts[0])+" serving "+version+" (test versions have no safety delay).")
+ back("ok", "Created canary "+name+" — live at https://"+s.channelFlashHost(ctx, s.canon(ctx), acct.Sqid, app, hosts[0])+" serving "+version+" (test versions have no safety delay).")
return
}
domain, absent := s.instanceDomainFor(ctx, acct.Sqid, app)