fix: refresh demo moved capability after readers arm
internal/host/demo_moved_test.go+29 −23internal/host/edgesfile.go+11 −4
Intent
<task-notification> <task-id>biomy00ht</task-id> <tool-use-id>toolu_01JJaPqsvAujbmwByD1YzWfc</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/biomy00ht.output</output-file> <status>completed</status> <summary>Background command "cat > $TMPDIR/diag.txt <<'EOF' From agent-start-demo-3 controller. Diagnosis of "no edge advertises demo-moved-v1". Everything was read-only. I read host.env and journals over SSM on sophie, leo and demo box-1, and control/edges/* and status/boxes/* from the dev bucket. Nothing was changed. There are two causes. One is a code fault (A). The other is a missing setting, but setting it changes edge behaviour (B). A third item is env the group members will need. A. CODE FAULT, edges file (sophie, leo). The moved capability can never get in. - internal/host/edgesfile.go:1211 computes edgesFileCapabilities(os.Getenv) once, when the loop starts. :1226 freezes it as baseCaps. Each pass (:1289) re-adds only the offline and db-read capabilities to baseCaps. - edgesfile.go:211 adds demo-moved-v1 only if armedDemoMovedReader is already true. - That flag is set later, inside fastConvergeLoop (agent.go:3538), after its deploy store and key setup. edgesFileLoop starts concurrently (agent.go:1053 vs 1025). - The journals show "edges file loop armed" in the same second as "change index armed" (sophie 02:08:33, leo 02:16:11). The edges loop wins the race, so the capability stays out for the life of the process. - control/edges/sophie-knitting.json and leo-climbing.json carry demo-claim-seed-v1 but not demo-moved-v1. Their CARLOS_CHANGE_INDEX=read and CARLOS_DEMO_DOMAIN=dev.trycarlos.com are both fine. - Fix: recompute the moved capability on every pass. Add `if movedCapable(os.Getenv) { caps = append(caps, MovedCapability) }` beside :1289, the same way withOfflineCapability is applied, and drop it from the frozen baseCaps. Needs a test where the reader arms after the loop starts. This is a release change (v0.34.11). A restart alone will not reliably fix it, because the race is lost each time. B. HEARTBEAT (status/boxes metrics). The edge readiness check needs PLATFORM_APPS_DOMAIN. - internal/edge/demo_moved.go:16-18: DemoMovedReady requires staticPub, a valid Demo.Domain AND a valid e.appsDomain. e.appsDomain comes from PLATFORM_APPS_DOMAIN (edge/cookiescope.go:69-70). - No dev box sets it. sophie's status metrics capabilities are ['demo-claim-seed-v1'] only. - The console requires both the heartbeat and the edges-file capability (console/demo_claim_moved.go:45-48). - Option B1, config: set PLATFORM_APPS_DOMAIN=<the dev console's apps domain> in host.env on every edge (sophie, leo, dennis) and in the group SSM env. It can ride a restart. But on the edge it also turns on apps-domain wildcard cert handling and warming (edge.go:4713, :4726) and cookie scoping (cookiescope.go:132). Check that with 8a3d302 first. - Option B2, code, which I recommend: drop the e.appsDomain requirement from DemoMovedReady, and make the edge's MovedDomains check (demo_moved.go:31) accept any valid one-label app host. The console already derives and signs the target from its own AppsDomain (demo_claim_moved.go). A small change that can ride with A in v0.34.11. C. HA group members (g-f848…, g-ffc9…). They also publish edges files, and readiness checks every edges file. - They currently lack demo-claim-seed-v1, and after A they would also lack demo-moved-v1. - Their group SSM env needs CARLOS_DEMO_CLAIM=1, CARLOS_DEMO_DOMAIN=dev.trycarlos.com, CARLOS_CHANGE_INDEX=read, plus PLATFORM_APPS_DOMAIN if you take B1. Not a fault: demo box-1 has CARLOS_FLEET=demo. A fleet box never arms the change index (changeindex.go:57-60) and publishes no edges file (edgesfile.go:1172), so it is correctly absent from the edges snapshot. It reports the moved capability on the demo stream instead (demo_serving.go:76-79, which needs only the registry and release key). Summary: claims cannot turn on until A is released. With B2 in the same release, no new env is needed on the platform boxes. The group members still need the env in C. I can build A+B2 on a short branch the same way as the last one if you say go. EOF paseo send 39e7acfa "$(cat $TMPDIR/diag.txt)" 2>&1 | tail -1; rm $TMPDIR/diag.txt" completed (exit code 0)</summary> </task-notification>
<paseo-system version="1" kind="agent-message" source-agent-id="39e7acfa-a56a-470b-8ef5-70de5c57a6f2" message-id="18465c40-0186-40e0-a29f-8facfa4faf2d" source-agent-title="agent /start demo program controller"> From 39e7acfa: one addition to demo-moved-capability (8a3d302's ruling). HA group members serve only their named pool (hapair on dev, ha on the US flagship), never shared or demo traffic, and they get no demo env. So claim readiness must count only edges that can serve demo traffic: shared-pool, public-ingress edges. Group/named-pool members are excluded from the claim-seed, moved and seeds-protocol/prev-slot checks (demoClaimSeedReady, demo_claim_moved.go, and wherever else every edges file is required). Use the existing signal that marks an edge as named-pool or group-only. Don't invent a new one. If there's none in the edges file, tell me before adding one. Tests: a named-pool edge without the capabilities doesn't block readiness, and a shared edge without them still does. Ask the reviewer to check that no edge that can actually serve a demo or claimed destination is excluded. Same landing rules; send me the sha. </paseo-system>
<task-notification> <task-id>bdos188nw</task-id> <tool-use-id>toolu_01AS9ucHPe2HsoR7H7mCpRb8</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/22215d20-2b53-4378-8426-ae55e2362d13/tasks/bdos188nw.output</output-file> <status>completed</status> <summary>Background command "paseo send 39e7acfa "demo-moved-capability: building A + B2 + the shared-pool scope now (Astra). Signal used for scope: edgesfile ServesSharedPool (json serves_shared_pool, internal/edgesfile/snapshot.go:64-69). Dev publishes false on the group members and true on sophie. My ruling: exclude an edge from the claim checks only when serves_shared_pool is explicitly false. Absent (an older writer) still counts, so it fails closed. I am NOT using accepts_inbound, because a shared-pool box without public ingress can still host a claimed destination. Readiness also requires at least one counted edge. Will send the sha after review and green CI." 2>&1 | tail -1" completed (exit code 0)</summary> </task-notification>
diff --git a/internal/host/demo_moved_test.go b/internal/host/demo_moved_test.go| index 12089ed1d..545cc7c01 100644 |
| --- a/internal/host/demo_moved_test.go |
| +++ b/internal/host/demo_moved_test.go |
| @@ -9,6 +9,7 @@ import ( |
| "errors" |
| "fmt" |
| "net/http/httptest" |
| + "slices" |
| "testing" |
| "time" |
| @@ -99,22 +100,11 @@ func TestDemoMovedRequiresWatch(t *testing.T) { |
| oldReady := armedDemoMovedReader.Swap(false) |
| defer armedChangeWatch.Store(oldWatch) |
| defer armedDemoMovedReader.Store(oldReady) |
| - env := func(k string) string { |
| - if k == "CARLOS_DEMO_DOMAIN" { |
| - return "demo.example.com" |
| - } |
| - if k == "CARLOS_CHANGE_INDEX" { |
| - return "read" |
| - } |
| - return "" |
| - } |
| + env := map[string]string{"CARLOS_DEMO_DOMAIN": "demo.example.com", "CARLOS_CHANGE_INDEX": "read"} |
| + getenv := func(k string) string { return env[k] } |
| + baseCaps := edgesFileCapabilities(getenv) |
| has := func() bool { |
| - for _, c := range edgesFileCapabilities(env) { |
| - if c == democlaim.MovedCapability { |
| - return true |
| - } |
| - } |
| - return false |
| + return slices.Contains(withDemoMovedCapability(baseCaps, getenv), democlaim.MovedCapability) |
| } |
| if has() { |
| t.Fatal("unarmed capability") |
| @@ -125,18 +115,34 @@ func TestDemoMovedRequiresWatch(t *testing.T) { |
| } |
| armedDemoMovedReader.Store(true) |
| if !has() { |
| - t.Fatal("armed capability absent") |
| + t.Fatal("first pass after arming did not publish capability") |
| + } |
| + if slices.Contains(baseCaps, democlaim.MovedCapability) || slices.Contains(edgesFileCapabilities(getenv), democlaim.MovedCapability) { |
| + t.Fatal("dynamic capability frozen into startup configuration") |
| } |
| - for _, c := range edgesFileCapabilities(func(k string) string { |
| - if k == "CARLOS_DEMO_DOMAIN" { |
| - return "" |
| + for _, domain := range []string{"", "bad_domain.example.com", "DEMO.example.com", "demo.example.com:443", "demo.example.com/path"} { |
| + env["CARLOS_DEMO_DOMAIN"] = domain |
| + if has() { |
| + t.Fatalf("invalid demo domain %q advertised capability", domain) |
| } |
| - return env(k) |
| - }) { |
| - if c == democlaim.MovedCapability { |
| - t.Fatal("unconfigured demo domain advertised moved capability") |
| + } |
| + env["CARLOS_DEMO_DOMAIN"] = "demo.example.com" |
| + for _, mode := range []string{"", "0", "write"} { |
| + env["CARLOS_CHANGE_INDEX"] = mode |
| + if has() { |
| + t.Fatalf("change index mode %q advertised capability", mode) |
| } |
| } |
| + env["CARLOS_CHANGE_INDEX"] = "read" |
| + armedChangeWatch.Store(nil) |
| + if has() { |
| + t.Fatal("reader without watch advertised capability") |
| + } |
| + armedChangeWatch.Store(release.NewChangeWatch(cs)) |
| + armedDemoMovedReader.Store(false) |
| + if has() { |
| + t.Fatal("stopped reader retained capability") |
| + } |
| } |
| func TestDemoMovedDeliveryStream(t *testing.T) { |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index 6924db709..07ade9382 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -198,7 +198,7 @@ const capLifetimes1 = "lifetimes-1" |
| // edgesFileCapabilities publishes lifetimes-1 always, and region-ha-1 only |
| // when CARLOS_REGION_HA is set to something other than "" or "0". |
| -// offline-move-1 is added per pass by withOfflineCapability. |
| +// Worker capabilities are added per pass after their readers arm. |
| func edgesFileCapabilities(getenv func(string) string) []string { |
| caps := []string{capLifetimes1} |
| if regionHAEnabled(getenv) { |
| @@ -208,8 +208,14 @@ func edgesFileCapabilities(getenv func(string) string) []string { |
| if getenv("CARLOS_DEMO_CLAIM") == "1" { |
| caps = append(caps, seeds.DemoClaimCapability) |
| } |
| + return caps |
| +} |
| + |
| +// withDemoMovedCapability observes readers that may arm after the edges loop starts. |
| +// caps is not modified. |
| +func withDemoMovedCapability(caps []string, getenv func(string) string) []string { |
| if demo.ValidDomain(getenv("CARLOS_DEMO_DOMAIN")) && changeIndexArmed(getenv) && armedChangeWatch.Load() != nil && armedDemoMovedReader.Load() { |
| - caps = append(caps, democlaim.MovedCapability) |
| + return append(slices.Clone(caps), democlaim.MovedCapability) |
| } |
| return caps |
| } |
| @@ -1217,7 +1223,8 @@ func edgesFileLoop(reg *registry.Registry, lifetimes bool, assets *assetPolicy) |
| } |
| // The total is read once at arm; the disk half is not needed. |
| ident.BoxMemTotalMiB, _ = capacityMiB(readMemBytes, func() (uint64, uint64, error) { return 0, 0, errors.ErrUnsupported }) |
| - // The flag-derived capabilities; offline-move-1 joins them on each pass |
| + // The flag-derived capabilities; demo-moved-v1 joins them after its |
| + // watch and reader arm. offline-move-1 joins them on each pass |
| // once the moves worker is armed and capable, and db-read-1 joins them |
| // on each pass while the armed db-reads loop's last readiness probe |
| // passed (db region forward spec §7.1). The db-reads agent's draining |
| @@ -1286,7 +1293,7 @@ func edgesFileLoop(reg *registry.Registry, lifetimes bool, assets *assetPolicy) |
| if state.timed() { |
| eip = readPublicIP() |
| } |
| - ident.Capabilities = withDBReadCapability(withOfflineCapability(baseCaps, armedOfflineCapable()), dbReadsCapable()) |
| + ident.Capabilities = withDemoMovedCapability(withDBReadCapability(withOfflineCapability(baseCaps, armedOfflineCapable()), dbReadsCapable()), os.Getenv) |
| dbReadsDraining.Store(ident.Draining) |
| ident.Headroom = headroomFor(headroomCapabilities(ident.Capabilities), dataDir, reg) |
| ident = withMovesFields(ident, dataDir, optDir) |