carlos / platform Public

host: caller-goes-away test waits for the drain's first read

TestIngressDrainCallerGoesAway waited only for a published report, which
start() sets before run() begins, so the "begin" assertion could race the
cancel. The gated fake reader now signals entry and the test waits for it
before cancelling (W6 final review F2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev db86b5b23386c776cc4c858b2b792f0d5969d0d5 parent 7815493
1 file changed, +11 −7
  • internal/host/ingressdrain_test.go +11 −7

Intent

Human

<task-notification> <task-id>a14f56a7ddada51be</task-id> <tool-use-id>toolu_0189Yom91rTNn4Uo7XToX4fc</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a373aecd-faa9-4b83-8736-ff726fb2d3af/tasks/a14f56a7ddada51be.output</output-file> <status>completed</status> <summary>Agent "Implement W6 Task 9 (root runner)" 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: NEEDS_DECISION. I found why the departure controller refuses, but the safe fix needs one production line in `internal/host/agent.go`. You asked me to stop and ask before any production change, so I have not made it. Commits: 78154933 "host: reproduce the fixture's departure controller refusal without root". It only adds the reproduction to the fixture test. Build/vet: `go vet -tags rootrunner` is clean, and `TestIngressRootDepartureSeam` passes locally without root. Cause: the departure controller refuses to start when the deployment bucket name is empty. The terminate fixture's agent runs from a deployment directory and sets `CARLOS_DEPLOYMENT_BUCKET=""` deliberately, so that check fails. Every other input the controller needs is present; run 3's identity line confirms the box reference and cloud identity are valid. A real fixed region HA box always has a bucket, so only the fixture hits this. The seam test now shows both sides: with no bucket the controller refuses at the same stage as on the runner, and with a bucket it is built and the consumer reaches its first receive. Options: 1. **One production line (my recommendation).** In the `departureArm` literal in `agent.go`, change `Getenv: os.Getenv` to `Getenv: fixtureDepartureGetenv()`. - The `!rootrunner` seam file returns `os.Getenv`, so production behaves exactly as now. - The rootrunner seam file returns `os.Getenv` with a stand-in bucket name (`deployment`) for the departure controller only. - The controller uses the bucket name only as a label in departure IDs. It still opens the store through `openDeployStore`, so the agent keeps its directory store. - `agent.go` is not on the other agent's list of files. 2. **Fixture only, no production change.** Set the bucket for the whole agent. That moves its entire deployment store onto S3 and needs: - an S3 front for the directory store that supports the change index's conditional reads and paginated listing (the existing `activationS3Fixture` has neither); - per-bucket routing on the agent's single S3 endpoint. No existing root fixture runs the full agent like that, so it would put a new, untested transport under the whole witness. Decision needed: whether I may make the `agent.go` change in option 1. If yes, I can add the tagged seam and the unit check, commit, and hand it back for a rerun in one short round. Report (round 3 section appended): /home/paulca/amadan.net/carlos/platform/.claude/worktrees/w6-build/.superpowers/sdd/2026-11-10-fixed-edge-ingress-drain/task-9-report.md</result> <usage><subagent_tokens>309647</subagent_tokens><tool_uses>7</tool_uses><duration_ms>154886</duration_ms></usage> </task-notification>

diff --git a/internal/host/ingressdrain_test.go b/internal/host/ingressdrain_test.go
index 987444ed2..532d71c25 100644
--- a/internal/host/ingressdrain_test.go
+++ b/internal/host/ingressdrain_test.go
@@ -76,8 +76,10 @@ type fakeTargetHealth struct {
script func(at time.Duration) (ingresshealth.Verdict, error)
retention []ingresshealth.Retention
retErr error
- // gate, when set, holds the first read until it is closed.
- gate chan struct{}
+ // gate, when set, holds the first read until it is closed; entered,
+ // when set, is closed as that read begins.
+ gate chan struct{}
+ entered chan struct{}
// delay, when set, is how long a read starting at at takes on the
// drain's clock.
delay func(at time.Duration) time.Duration
@@ -94,6 +96,9 @@ func (f *fakeTargetHealth) Withdrawn(_ context.Context, self ingresshealth.Self)
first := f.reads == 1
f.selves = append(f.selves, self)
f.mu.Unlock()
+ if first && f.entered != nil {
+ close(f.entered)
+ }
if first && f.gate != nil {
<-f.gate
}
@@ -736,7 +741,7 @@ func TestIngressDrainRouteNotArmed(t *testing.T) {
// the end on the agent, and the next ask gets its report.
func TestIngressDrainCallerGoesAway(t *testing.T) {
f := newIngressFixture(t, healthyUntil(6*time.Second, ingresshealth.StateUnhealthy, ingresshealth.StateUnhealthy))
- f.tg.gate = make(chan struct{})
+ f.tg.gate, f.tg.entered = make(chan struct{}), make(chan struct{})
h := f.d.handler()
ctx, cancel := context.WithCancel(context.Background())
answered := make(chan *httptest.ResponseRecorder, 1)
@@ -746,10 +751,9 @@ func TestIngressDrainCallerGoesAway(t *testing.T) {
h.ServeHTTP(rec, req)
answered <- rec
}()
- // The drain is in step 2, its first read held.
- for f.d.snapshot() == nil {
- time.Sleep(time.Millisecond)
- }
+ // The drain is in step 2, inside its first read, held there: step 1
+ // has run before the caller goes away.
+ <-f.tg.entered
cancel()
rec := <-answered
if rec.Body.Len() != 0 {