carlos / platform Public

region HA: join the take test's detached wake before its fixture closes

TestTakeWithinTheWakeBound leaves the take's wake running detached: the
take answers at its bound while the wake holds the lease it acquired at
generation 7. The test released the blocked start at cleanup and went
on, so the wake ended later and gave the lease back, writing its release
marker through whichever fixture CARLOS_S3_ENDPOINT named by then. Under
load that was TestTakeoverLiveOwnerDiagnostic/proof_cache's, whose first
request was a stray "PUT shop.example.com/lock.json" (generation 7,
owner released/v1;ref=a, the shop host's lifetime): 22 of 90 runs of
-run TestTake -count=30 beside other suites; 0 of 30 in isolation.

The cleanup now shuts the Service down after releasing the start, which
cancels the waking entry and joins it, and checks through the wakeEnded
hook that the wake goroutine has returned. The other take tests' wakes
finish inside the take or are fake entries. Test-only change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev cb2477c5e2d6ded92f75f8fdacf3c5856686e413 parent 68b459f
1 file changed, +21 −0
  • internal/activator/hatake_test.go +21 −0

Intent

Human

<task-notification> <task-id>a7ec0599d0dc94f63</task-id> <tool-use-id>toolu_01BLYXrcZUByCerRZk86GR3B</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/283be278-5c6a-4a71-a8d6-b3d32c668985/tasks/a7ec0599d0dc94f63.output</output-file> <status>completed</status> <summary>Agent "Fix two CI failures" 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: failure 1 is fixed with a test-only commit. Failure 2 is not fixed: I couldn't reproduce it on this branch or on main, and I found no root cause, so I left it alone. Nothing pushed. Commits: 68b459f1 "region HA: take test counts the take's lock requests, not replication's" Root causes: - **TestTakeTheNamedMarker:** timing, not the take. The LISTs are litestream's level monitors (not a restore) and land whenever scheduled (9 of 20 local runs failed). The test now drops them as harelease_test.go's `wakePathRequests` already does, leaving the take at 1 GET + 1 PUT (§25.10); 90/90 passed afterwards. - **TestDBForwardLongRequestThroughTheEdge:** passed 20/20 on the branch, 20/20 on origin/main, 6/6 with GOMAXPROCS=1, 3/3 full root@2 shard runs and 10/10 under load. Task 3's early-answer code never runs here (plain service route, no HA, no backhaul), and none of the branch code on this path closes connections. It has flaked on main before (plans-6b-followups.md:26). Concerns: main's TestTakeoverLiveOwnerDiagnostic/proof_cache gets a stray `PUT lock.json` (22 of 90) only when it runs after this branch's take tests under load; 0/30 alone on the branch and main. Probably a detached wake from an earlier test, unconfirmed and not fixed; it could flake the activator CI shard. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/region-ha-held-build/.superpowers/sdd/2026-11-08-region-ha-held-requests/ci-fix-report.md</result> <usage><subagent_tokens>200757</subagent_tokens><tool_uses>100</tool_uses><duration_ms>2910851</duration_ms></usage> </task-notification>

Attributed to this commit: 16.8 g CO₂e (2,172,791 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-held-build, 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/activator/hatake_test.go b/internal/activator/hatake_test.go
index 0a5ee7532..25ea29ad0 100644
--- a/internal/activator/hatake_test.go
+++ b/internal/activator/hatake_test.go
@@ -339,6 +339,27 @@ func TestTakeWithinTheWakeBound(t *testing.T) {
old := wakeWaitBound
wakeWaitBound = 200 * time.Millisecond
t.Cleanup(func() { wakeWaitBound = old })
+ // The take's wake runs on, detached, after the take answers, holding
+ // the lease it acquired; ended, it gives the lease back (a release
+ // marker). It must end inside this test. Left running, it wrote that
+ // marker through whichever fixture CARLOS_S3_ENDPOINT named by then: a
+ // later test's (TestTakeoverLiveOwnerDiagnostic/proof_cache, 22 of 90
+ // under load). Cleanups run last registered first: the start is
+ // released, then Shutdown cancels the wake and joins it, then haService
+ // abandons and the fixture closes.
+ ended := make(chan struct{})
+ var endOnce sync.Once
+ s.a.wakeEnded = func(string) { endOnce.Do(func() { close(ended) }) }
+ t.Cleanup(func() {
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ s.a.Shutdown(ctx)
+ select {
+ case <-ended:
+ case <-time.After(5 * time.Second):
+ t.Error("the take's detached wake outlived the service's shutdown")
+ }
+ })
release := make(chan struct{})
t.Cleanup(func() { close(release) })
s.ctl.onStart = func() { <-release }