moves: offline run nudges while it probes an open move
The probe after open is a wait on the target. Decide probed every tick and never nudged, so a target that missed open's serial bump never opened and the run stopped at exit 4 with the instance still offline. Found by Task 7's two-box witness; the probe now nudges on the wait's clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 files changed,
+39
−2
internal/moves/offlinerun/decide.go+6 −0internal/moves/offlinerun/decide_test.go+29 −1move_offline_run_test.go+4 −1
diff --git a/internal/moves/offlinerun/decide.go b/internal/moves/offlinerun/decide.go| index e4bcc94b1..7b07ebbb7 100644 |
| --- a/internal/moves/offlinerun/decide.go |
| +++ b/internal/moves/offlinerun/decide.go |
| @@ -486,11 +486,17 @@ func (m Memory) overBudget(p Policy, now time.Duration) string { |
| } |
| // afterOpen decides in open and finishing: probe, then finish. Never abort. |
| +// Probing is a wait on the target, so it nudges on the wait's clock: a |
| +// target that missed open's bump answers only once the move is announced |
| +// again. |
| func (m Memory) afterOpen(v View, p Policy, now time.Duration) (Action, Memory) { |
| if v.State == StateOpen && !m.probeOK { |
| if now-m.stateSince >= p.Probe { |
| return Done{Exit: ExitStopped, Reason: ReasonProbeFailed}, m |
| } |
| + if a, nudged := m.wait(p, now); a == Action(Nudge{}) { |
| + return a, nudged |
| + } |
| return Probe{}, m |
| } |
| if v.State == StateOpen && p.NoFinish { |
diff --git a/internal/moves/offlinerun/decide_test.go b/internal/moves/offlinerun/decide_test.go| index 3bfb34a12..f8d2ed52b 100644 |
| --- a/internal/moves/offlinerun/decide_test.go |
| +++ b/internal/moves/offlinerun/decide_test.go |
| @@ -314,7 +314,7 @@ func TestDecideAfterOpenNeverAborts(t *testing.T) { |
| open.Failed = true |
| m := play(t, p, offline(StateLanded, 0), []step{ |
| {at(10), open, Probe{}}, |
| - {at(10) + p.Probe - time.Second, open, Probe{}}, |
| + {at(10) + p.Probe - time.Second, open, Nudge{}}, // a quiet wait nudges (TestDecideOpenWaitNudges) |
| }) |
| // Ctrl-C after open asks for an abort; it is not taken. |
| m = m.Abort(ReasonInterrupted) |
| @@ -385,6 +385,34 @@ func TestDecideNudge(t *testing.T) { |
| }) |
| } |
| +// TestDecideOpenWaitNudges: after open the run probes until the target |
| +// answers, and that is a wait on a box like any other. A target that missed |
| +// open's serial bump never opens, so the probe never answers; the nudge |
| +// re-announces the move on the same clock as every other wait (Task 7's |
| +// two-box witness found the run probing a stranded open to exit 4). |
| +func TestDecideOpenWaitNudges(t *testing.T) { |
| + p := DefaultPolicy() |
| + open := tv(StateOpen) |
| + m := play(t, p, offline(StateLanded, 0), []step{ |
| + {at(10), open, Probe{}}, |
| + {at(38), open, Probe{}}, |
| + {at(40), open, Nudge{}}, |
| + {at(42), open, Probe{}}, |
| + {at(98), open, Probe{}}, |
| + {at(100), open, Nudge{}}, |
| + {at(102), open, Probe{}}, |
| + }) |
| + // The probe's budget still ends it, never an abort. |
| + play(t, p, m, []step{ |
| + {at(10) + p.Probe, open, Done{Exit: ExitStopped, Reason: ReasonProbeFailed}}, |
| + }) |
| + // Once the probe answered, the wait for finish nudges as before. |
| + play(t, p, offline(StateLanded, 0).Probed(true), []step{ |
| + {at(10), open, Wait{}}, |
| + {at(40), open, Nudge{}}, |
| + }) |
| +} |
| + |
| // TestDecideNamesMatchProvision pins the state and outcome twins to the |
| // record's own names. |
| func TestDecideNamesMatchProvision(t *testing.T) { |
diff --git a/move_offline_run_test.go b/move_offline_run_test.go| index 80929f11d..e72eb911d 100644 |
| --- a/move_offline_run_test.go |
| +++ b/move_offline_run_test.go |
| @@ -397,11 +397,14 @@ func TestMoveOfflineRunFailedProbeStops(t *testing.T) { |
| if code != 4 { |
| t.Fatalf("exit %d:\n%s", code, out) |
| } |
| + // The probe's two minutes are a wait on the target: it is nudged at |
| + // 30 s and again at 90 s, and nothing is aborted or finished. |
| got := doorsOf(c.postsSent()) |
| - if got != "stage,start,seal,flip,open" { |
| + if got != "stage,start,seal,flip,open,nudge,nudge" { |
| t.Fatalf("doors %s:\n%s", got, out) |
| } |
| wantLines(t, out, |
| + "06:12:50Z waiting no change for 30 s, woke the boxes", |
| "check https://acme.shop.example.com/ did not answer within 2 min", |
| "acme.shop.example.com is open in uk but not finished. Check the site, then run:", |
| " carlos move offline finish --host acme.shop.example.com", |