oficina / equipo Public

thintest: a Mac back online runs waiting checks once

TestContractMacRecheckBackOnline covers the heartbeat hook: a worker
connected with no capability report (no tags, nothing runs), goes quiet
past the online window (store clock) and says hello as a Mac; the
waiting needs_macos checks are dispatched once on the exact candidate.
After they end not run again, coming back again or reconnecting
dispatches nothing. Mutations: dropping the heartbeat call fails it (no
dispatch); dropping the recheck_by guard fails it (a second dispatch).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 0b1b6461caa8ab2821d5b20a164bcaa3dd757fe7 parent 72d48ab
1 file changed, +50 −0
  • internal/thintest/macrecheck_contract_test.go +50 −0

CI passed — run details

diff --git a/internal/thintest/macrecheck_contract_test.go b/internal/thintest/macrecheck_contract_test.go
index 7e06f974..4f5d8b4a 100644
--- a/internal/thintest/macrecheck_contract_test.go
+++ b/internal/thintest/macrecheck_contract_test.go
@@ -210,3 +210,53 @@ func TestContractMacRecheckOutcomes(t *testing.T) {
t.Fatalf("fix round %+v", e)
}
}
+
+// A Mac that comes back online (a heartbeat after it was offline) runs
+// the waiting checks too, once: it connected before its capability report
+// was in (no tags, so nothing then), went quiet, and says hello as a Mac.
+// Even with those checks ended not run again, its coming back again, or
+// reconnecting, runs nothing more.
+func TestContractMacRecheckBackOnline(t *testing.T) {
+ r := newRunnersRig(t)
+ task, sha, _ := r.waitingForMac("Swipe back on iOS")
+ token := r.inst.EnrolRunner(t).Token
+ bare := WorkerHello(0)
+ bare.Capabilities = nil
+ fr, err := DialRunnerHello(r.ctx, r.inst.URL, token, bare)
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(fr.Close)
+ w := &peer{t: t, r: r.toolRig, fr: fr}
+ w.none(wire.FrameDispatch, 200*time.Millisecond)
+ if runs := r.checksRuns(task); len(runs) != 1 {
+ t.Fatalf("a runner with no tags re-ran the checks: %+v", runs)
+ }
+ clock := time.Now().UTC()
+ r.inst.Store.Chat().SetClock(func() time.Time { return clock })
+ back := func() {
+ clock = clock.Add(2 * time.Minute)
+ w.heartbeat(WorkerHello(0))
+ }
+ back()
+ d := macRecheck(t, w, task, sha)
+ r.relay(w, []byte("PACK swipe back"))
+ if !w.lease(d.StepID, 1) {
+ t.Fatal("start refused")
+ }
+ w.send(wire.FrameStep, wire.StepReport{TaskID: task, StepID: d.StepID, Attempt: 1, State: wire.StepDone, Reason: "needs_macos", CandidateSHA: sha, Checks: wire.ChecksCannotRun, Termination: true, TerminationKind: wire.TerminationProcessGroup, Findings: []wire.Finding{}})
+ r.wait("ready again", func(c *Conversation) bool { return c.Tasks[task].Stage == wire.StageReadyToMerge })
+ back()
+ w.none(wire.FrameDispatch, 200*time.Millisecond)
+ fr.Close()
+ time.Sleep(100 * time.Millisecond)
+ again, err := DialRunnerHello(r.ctx, r.inst.URL, token, WorkerHello(fr.Welcome.Generation))
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(again.Close)
+ (&peer{t: t, r: r.toolRig, fr: again}).none(wire.FrameDispatch, 200*time.Millisecond)
+ if runs := r.checksRuns(task); len(runs) != 2 {
+ t.Fatalf("coming back again re-ran the checks: %+v", runs)
+ }
+}