edge: wait on the watcher's record in the namespace parents test (T4)
TestNamespaceChangeRefreshesParentsOnRemoteOnlyEdge flaked on hosted CI: it sent one tick per phase and polled the parents for 2 s, so a slow or failed reload missed the deadline with no tick left to retry. It now records each fingerprint Watch handles (afterRecord hook) and ticks until the fingerprint of the state it just wrote is recorded; Reload has run the wildcard refresh by then, so the parent assertions are strict one-shot checks. 30 s backstop only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/edge/wildcard_parents_test.go+53 −5
CI passed — run details
Intent
<task-notification> <task-id>a0b449ae6ab46e7ca</task-id> <tool-use-id>toolu_019MTw7PYT2n3zUWqaKrG8Qw</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/a0b449ae6ab46e7ca.output</output-file> <status>completed</status> <summary>Agent "Final-review fix wave" 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. Both CI failures at `dd16273a` are fixed; nothing is pushed. A note with the pasted test output is appended to `final-fix-report.md`. **Commit:** `a627b21c` console: judged record reads for subdomains; count the new closed doors **What changed:** 1. **`TestNoUnjudgedRecordReads`:** the two raw instance-record reads were `subdomainCheckRecord` (set's check host) and `channelFlashHost` (the canary flash in `canonical.go`). Both now use `s.readRecord`, the console's judged reader. Nothing was added to the permitted list. - With no judge, this is the same read as before. - Under a judge, a record it doesn't vouch for now reads as absent. The check host skips it, and the canary flash shows the host as it is. 2. **`TestEveryClosedDoorRefusesAServiceCredential`:** the four subdomain doors added in T6 were already in `closedDoors`, but the pinned count stayed at 97. It is now 101, and the door list text names "three account subdomain doors, the subdomain inventory". **Tests:** All pass: - the two guard tests; - the `Subdomain|Canonical|Canary|TestEveryCLIDoorNamesItsRoles|TestClaimConsoleMutationInvariant` run (71 pass, 0 fail); - both provision censuses; - build, gofmt and vet on `internal/console`. **Census items needing a ruling:** none new. Neither changed function is a census unit, so nothing was re-proposed. The round-2 pins stand: `93653b4a…` and `de037943…`, seal `bc306a42…`. **Concerns:** none new. The stale `.git/packed-refs.lock` (not mine) is still there.</result> <usage><subagent_tokens>438267</subagent_tokens><tool_uses>9</tool_uses><duration_ms>276675</duration_ms></usage> </task-notification>
<task-notification> <task-id>bzwsduczh</task-id> <tool-use-id>toolu_0131HQrEPhmk3N8pt8WVSEk6</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/709ac745-ee81-4971-97b8-321e18b19cf6/tasks/bzwsduczh.output</output-file> <status>completed</status> <summary>Background command "Run the scoped re-review and wait for CI together" completed (exit code 0)</summary> </task-notification>
Attributed to this commit: 30.8 g CO₂e (4,055,910 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/edge/wildcard_parents_test.go b/internal/edge/wildcard_parents_test.go| index bace9c619..7a495bcdb 100644 |
| --- a/internal/edge/wildcard_parents_test.go |
| +++ b/internal/edge/wildcard_parents_test.go |
| @@ -640,6 +640,19 @@ func TestNamespaceChangeRefreshesParentsOnRemoteOnlyEdge(t *testing.T) { |
| t.Fatalf("seed parents = %v", got) |
| } |
| + // Watch records a fingerprint only after a successful Reload, and |
| + // Reload runs the hooks (w.refresh) before it returns, so a recorded |
| + // fingerprint means the parents for that registry state are in place. |
| + // The test ticks until the fingerprint of the state it just wrote is |
| + // recorded: no wall-clock wait on the refresh, and a reload that fails |
| + // once is retried on the next tick, as in production. |
| + recorded := make(chan string, 64) |
| + e.hooks = &reloadHooks{afterRecord: func(fp string) { |
| + select { |
| + case recorded <- fp: |
| + default: |
| + } |
| + }} |
| tick := make(chan time.Time) |
| e.watchTick = tick |
| stop, done := make(chan struct{}), make(chan struct{}) |
| @@ -651,17 +664,52 @@ func TestNamespaceChangeRefreshesParentsOnRemoteOnlyEdge(t *testing.T) { |
| close(stop) |
| <-done |
| }) |
| - sendTick(t, tick) // the first poll baselines with a reload |
| + settle := func(what string) { |
| + t.Helper() |
| + want, err := reg.Fingerprint() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + deadline := time.Now().Add(30 * time.Second) |
| + for { |
| + // The tick channel is unbuffered: a second send returns only |
| + // once the first tick is wholly handled, Reload included. |
| + sendTick(t, tick) |
| + sendTick(t, tick) |
| + for drained := false; !drained; { |
| + select { |
| + case fp := <-recorded: |
| + if fp == want { |
| + return |
| + } |
| + default: |
| + drained = true |
| + } |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatalf("%s: the watcher never recorded fingerprint %s", what, want) |
| + } |
| + } |
| + } |
| + settle("baseline") |
| if err := reg.SetAccountNamespaces(map[string]string{"harbour": "bdq"}); err != nil { |
| t.Fatal(err) |
| } |
| - sendTick(t, tick) |
| - waitParents(t, w, []string{"bdq.apps.test", "harbour.apps.test"}) |
| + settle("name held") |
| + if got, want := w.currentParents(), []string{"bdq.apps.test", "harbour.apps.test"}; !reflect.DeepEqual(got, want) { |
| + t.Fatalf("after the name was held: parents = %v; want %v", got, want) |
| + } |
| + // The emptied table fingerprints as the baseline did. The baseline's |
| + // one record of it was consumed above, and Watch records a fingerprint |
| + // only when it differs from the last, so a match now is a reload that |
| + // read the registry after the removal. |
| if err := reg.SetAccountNamespaces(map[string]string{}); err != nil { |
| t.Fatal(err) |
| } |
| - sendTick(t, tick) |
| - waitParents(t, w, []string{"bdq.apps.test"}) |
| + settle("name released") |
| + if got, want := w.currentParents(), []string{"bdq.apps.test"}; !reflect.DeepEqual(got, want) { |
| + t.Fatalf("after the name was released: parents = %v; want %v", got, want) |
| + } |
| } |