console, host: D2 witnesses use bindings valid by construction
TestFirstLabellingIsOff created its records at wall-clock time and bound them at a base captured earlier, so a slow setup could leave a binding older than its record. The removed first labelling refuses such a binding, and the witness could then pass without D2. Records are now created at base and each binding is bound a second after the persisted CreatedAt. TestTwoBoxFleetEndToEnd_RealNoAutomaticFirstLabel now checks that each wake's binding names this fleet, this host and its serving box, bound no earlier than the record, before it asserts that nothing is labelled. Both witnesses fail against the pre-D2 worker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/console/fleetrelabel_test.go+10 −3internal/host/fleettwobox_e2e_test.go+18 −0
CI cancelled — superseded by a newer push — run details
Intent
<task-notification> <task-id>a9cea1b3a0e810011</task-id> <tool-use-id>toolu_018WgAXrcB7QSQpoRHFcnN25</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/ac77363b-5830-422c-9f38-d7f2540dd398/tasks/a9cea1b3a0e810011.output</output-file> <status>completed</status> <summary>Agent "Implement Task 6 Part B: D2 off" 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. Part B only; Part A was not touched (no changes to `apiinstances.go`, `labelActive` or `fleetbox.go`). - **Commit:** `82613996` `console: the relabel worker no longer writes first labels (D2)` - **Tests:** `TestFirstLabellingIsOff` and the host test `TestTwoBoxFleetEndToEnd_RealNoAutomaticFirstLabel` failed first as expected (the worker labelled from bindings). All of the brief's commands now pass, as do `-run 'TestLostBox|TestDrain|TestFleetRelabel'` and the wider relabel and detach set. `GOOS=darwin go build` works and `go vet` is clean. - **Concerns:** - `readFleetBinding` and the binding type are kept but nothing calls them now. `go vet` does not flag them and the repo has no unused-code linter, but one would flag them until the next merge's labelling door uses them. - The sandbox made the default Go cache read-only, so I ran the console and host tests outside it with `GOCACHE` left at its default. The host e2e tests ran and passed there, with no socket refusals. - Six tests used the worker only to get a labelled record; they now label it directly through a new `labelOn` helper. Two race tests now test a move instead of a first label. I removed `TestFirstLabellingSkipsAnUnboundRecord` because its last step expected a label from a binding. That was my call, and the reviewer may want its first half kept. - **Report:** `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/design-fleet-record-labels/.superpowers/sdd/2026-11-14-fleet-record-labels/task-6b-report.md`</result> <usage><subagent_tokens>107413</subagent_tokens><tool_uses>34</tool_uses><duration_ms>988559</duration_ms></usage> </task-notification>
diff --git a/internal/console/fleetrelabel_test.go b/internal/console/fleetrelabel_test.go| index 9ebe0ea13..4a67b0431 100644 |
| --- a/internal/console/fleetrelabel_test.go |
| +++ b/internal/console/fleetrelabel_test.go |
| @@ -108,13 +108,20 @@ func beat(t *testing.T, fx *consoleFixture, box string, at time.Time, mut func(* |
| // record has a binding a box wrote for it after it was created, which is |
| // what the removed first labelling followed; the records stay unlabelled |
| // across three passes at explicit times, and no box is marked labelled. |
| +// Each binding is valid by construction: the record is created at base, |
| +// and its binding is bound a second after the persisted creation time, so |
| +// the test can pass only because the first labelling is off. |
| func TestFirstLabellingIsOff(t *testing.T) { |
| fx, _, reg := fleetBoxWorld(t, "code-rl-first-off", "pi-1", "pi-2") |
| - base := time.Now() |
| + base := time.Now().UTC() |
| hosts := map[string]string{"a.example.com": "pi-1", "b.example.com": "pi-1", "c.example.com": "pi-2"} |
| for h, box := range hosts { |
| - putFleetRecord(t, fx, "shop", h, nil) |
| - bindTo(t, fx, h, box, base.Add(time.Second)) |
| + putFleetRecord(t, fx, "shop", h, func(r *provision.Record) { r.CreatedAt = base }) |
| + created := shopRec(t, fx, h).CreatedAt |
| + if !created.Equal(base) { |
| + t.Fatalf("%s persisted created at %v; want %v", h, created, base) |
| + } |
| + bindTo(t, fx, h, box, created.Add(time.Second)) |
| } |
| v, err := fx.srv.loadFleetViewAt(context.Background(), "pi", base) |
| if err != nil { |
diff --git a/internal/host/fleettwobox_e2e_test.go b/internal/host/fleettwobox_e2e_test.go| index 3327fa3fa..d8c98ac07 100644 |
| --- a/internal/host/fleettwobox_e2e_test.go |
| +++ b/internal/host/fleettwobox_e2e_test.go |
| @@ -924,6 +924,24 @@ func TestTwoBoxFleetEndToEnd_RealNoAutomaticFirstLabel(t *testing.T) { |
| pi2.write(fleetB, "b1") |
| pi2.mustStop(fleetB) |
| + // Each wake's binding is one the removed first labelling would have |
| + // followed: this fleet, this host, the box that served it, bound no |
| + // earlier than the record was created. Checked, so the witness below |
| + // cannot pass on a binding that the old code would have refused. |
| + for _, c := range []struct{ host, box string }{{fleetA, "pi-1"}, {fleetB, "pi-2"}} { |
| + body, _, err := w.store.Get(context.Background(), fleetBindingKey(fleetName, c.host)) |
| + if err != nil { |
| + t.Fatalf("binding of %s: %v", c.host, err) |
| + } |
| + var b FleetBinding |
| + if err := json.Unmarshal(body, &b); err != nil { |
| + t.Fatal(err) |
| + } |
| + if b.Fleet != fleetName || b.Host != c.host || b.Box != c.box || b.BoundAt < w.record(c.host).CreatedAt.UnixMilli() { |
| + t.Fatalf("binding of %s %+v is not one the first labelling would follow to %s", c.host, b, c.box) |
| + } |
| + } |
| + |
| // While the boxes run an older release the pass labels nothing. |
| pi1.heartbeatRel(w.now, "v0.32.9") |
| pi2.heartbeatRel(w.now, "v0.32.9") |