carlos / platform Public

docs, tests: offline run's exit 5 as the code has it; simulation clock

Astra branch review round 1, finding 10 (P3).

The CLI page's exit-5 cell and the runbook now say every way run exits
5: refused before anything was written, by the console at the first
status read or stage (--resume included) or by carlos itself. The page
carries the draft as OR77 (pending), which replaces OR61 (withdrawn in
the record). The runbook's exit 1 also names a status refused for good.

The seeded simulation is deterministic: the boxes write their reports on
the run's virtual clock, and the console judges their freshness on the
same one (Server.UseOfflineClockForTest, a test-only seam). Two runs of
the 50 seeds now end identically.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev a09c738f5cf7f3d5be668279db6a8b74779200f9 parent 60e371b
8 files changed, +59 −14
  • approved_moves_copy_test.go +3 −2
  • docs/drafts/offline-move-run/copy-review/strings-fix.json +8 −0
  • docs/site/cli.md +1 −1
  • docs/superpowers/plans/2026-10-06-moves-phase1-copy.md +3 −3
  • docs/superpowers/plans/2026-10-21-offline-move-runbook.md +1 −1
  • internal/console/apiinstancemove_offline.go +23 −2
  • internal/console/server.go +3 −0
  • internal/host/movesoffline_e2e_test.go +17 −5
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go
index 696c1b093..4e7ab1e93 100644
--- a/approved_moves_copy_test.go
+++ b/approved_moves_copy_test.go
@@ -126,10 +126,11 @@ var movesCopyIDs = []string{
// The CLI page and the usage line (the same plan, Task 8; deck
// strings-task8.json beside strings.json). OR66 replaced MV-O181.
"OR50", "OR51", "OR53", "OR54", "OR55", "OR56", "OR57", "OR58", "OR59",
- "OR60", "OR61", "OR62", "OR63", "OR65", "OR66",
+ "OR60", "OR62", "OR63", "OR65", "OR66", // OR61 withdrawn: OR77 replaces it
+
// The fixes for Astra's branch review, round 1 (deck
// strings-fix.json beside strings.json; pending).
- "OR70", "OR71", "OR72", "OR73", "OR74", "OR75", "OR76",
+ "OR70", "OR71", "OR72", "OR73", "OR74", "OR75", "OR76", "OR77",
}
// copyRow is one row of the record. The File cell is the file the sentence is
diff --git a/docs/drafts/offline-move-run/copy-review/strings-fix.json b/docs/drafts/offline-move-run/copy-review/strings-fix.json
index 4a152184d..028b565aa 100644
--- a/docs/drafts/offline-move-run/copy-review/strings-fix.json
+++ b/docs/drafts/offline-move-run/copy-review/strings-fix.json
@@ -54,5 +54,13 @@
"text": "Stopped staging after %d tries that left no round ready to start. %s keeps serving and nothing went offline.",
"context": "carlos move offline run, step column 'limit'. %d is 10, %s the host. Said when run has asked for 10 more staging rounds for reasons other than a round over 1 MB: each small round went stale before start could be sent, or the console refused the request or it wrote nothing. run then abandons the stage (abort, then finish; exit 3). OR23 stays for five rounds that each copied over 1 MB, which are now the only ones it counts. Astra branch review round 1, finding 9.",
"status": "pending"
+ },
+ {
+ "id": "OR77",
+ "section": "CLI page",
+ "label": "Exit 5",
+ "text": "refused before anything was written: by the console, at the first status read or the first stage (`--resume` included), or by `carlos` itself (run as root, or with no console)",
+ "context": "docs/site/cli.md, under ### carlos move, the offline-moves part. Exit table, row `5`. Replaces OR61 ('the console refused the first stage, and nothing was written'), which named only one of the ways run exits 5: the console also answers the first status read with a refusal (a 4xx, --resume included), and carlos refuses by itself when run as root or with no console. Approving OR77 withdraws OR61. Astra branch review round 1, finding 10.",
+ "status": "pending"
}
]
diff --git a/docs/site/cli.md b/docs/site/cli.md
index a46d1ede4..1723fb05f 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -3504,7 +3504,7 @@ On Linux and macOS a dropped SSH connection does not stop `run`. If `run` stops
| `0` | the move finished, or is open with `--no-finish` |
| `3` | the instance was moved back |
| `4` | `run` stopped, and you decide what comes next |
-| `5` | the console refused the first stage, and nothing was written |
+| `5` | refused before anything was written: by the console, at the first status read or the first stage (`--resume` included), or by `carlos` itself (run as root, or with no console) |
| `1` | the console could not be reached or answered with an error, or the `--log` file could not be written |
`status` leads with the state, then shows the move, how long the instance has been offline when that applies, how long it has been in this step, and the one command forward and the one back:
diff --git a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
index cc47464e2..f75df897d 100644
--- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
+++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
@@ -792,7 +792,7 @@ Approved by Luna on 2026-11-15 under Paul's 2026-10-25 delegation (deck `docs/dr
## Offline move run: the CLI page and the usage line (Task 8)
-Task 8 of the offline move run plan (deck `docs/drafts/offline-move-run/copy-review/strings-task8.json`). Approved by Luna on 2026-11-15 under Paul's 2026-10-25 delegation; OR50, OR62 and OR63 as Luna changed them. OR50 replaces MV-O32, whose “never acts on its own” stopped being true with `run`; MV-O32 is withdrawn. The page's two examples are deck rows OR52 (`run`) and OR64 (`status`) and have no rows here: they are fenced output whose lines are approved rows already (M-C1, OR10 to OR18, OR35, OR41 to OR43, MovedLine) and the console's own waiting sentence. OR58 to OR62 are the meaning cells of `run`'s exit-code table, for `0`, `3`, `4`, `5` and `1`. OR66 is `moveOfflineUsage` with `run` added. It replaces MV-O181, which is withdrawn.
+Task 8 of the offline move run plan (deck `docs/drafts/offline-move-run/copy-review/strings-task8.json`). Approved by Luna on 2026-11-15 under Paul's 2026-10-25 delegation; OR50, OR62 and OR63 as Luna changed them. OR50 replaces MV-O32, whose “never acts on its own” stopped being true with `run`; MV-O32 is withdrawn. The page's two examples are deck rows OR52 (`run`) and OR64 (`status`) and have no rows here: they are fenced output whose lines are approved rows already (M-C1, OR10 to OR18, OR35, OR41 to OR43, MovedLine) and the console's own waiting sentence. OR58 to OR62 are the meaning cells of `run`'s exit-code table, for `0`, `3`, `4`, `5` and `1`; OR61, the `5` cell, was withdrawn for OR77 (the branch review's fixes, below). OR66 is `moveOfflineUsage` with `run` added. It replaces MV-O181, which is withdrawn.
| id | file | text | status |
|---|---|---|---|
@@ -806,7 +806,6 @@ Task 8 of the offline move run plan (deck `docs/drafts/offline-move-run/copy-rev
| OR58 | docs/site/cli.md | the move finished, or is open with `--no-finish` | approved |
| OR59 | docs/site/cli.md | the instance was moved back | approved |
| OR60 | docs/site/cli.md | `run` stopped, and you decide what comes next | approved |
-| OR61 | docs/site/cli.md | the console refused the first stage, and nothing was written | approved |
| OR62 | docs/site/cli.md | the console could not be reached or answered with an error, or the `--log` file could not be written | approved |
| OR63 | docs/site/cli.md | `status` leads with the state, then shows the move, how long the instance has been offline when that applies, how long it has been in this step, and the one command forward and the one back: | approved |
| OR65 | docs/site/cli.md | While the console waits on a box, a `waiting` row says what for, and the forward command ends with “when ready”. Under the block, `status` lists each item the move checks and each box’s report. | approved |
@@ -814,7 +813,7 @@ Task 8 of the offline move run plan (deck `docs/drafts/offline-move-run/copy-rev
## Offline move run: the branch review's fixes (Astra round 1)
-Sentences the fixes for Astra's whole-branch review of `offline-move-run` (round 1) need. Pending: deck `docs/drafts/offline-move-run/copy-review/strings-fix.json`, for Luna under Paul's 2026-10-25 delegation. The code is written against the deck's text; an approval that changes a row is applied verbatim.
+Sentences the fixes for Astra's whole-branch review of `offline-move-run` (round 1) need. OR77 is the CLI page's exit-5 cell; it replaces OR61, withdrawn here (the page carries OR77's draft). Pending: deck `docs/drafts/offline-move-run/copy-review/strings-fix.json`, for Luna under Paul's 2026-10-25 delegation. The code is written against the deck's text; an approval that changes a row is applied verbatim.
| id | file | text | status |
|---|---|---|---|
@@ -825,3 +824,4 @@ Sentences the fixes for Astra's whole-branch review of `offline-move-run` (round
| OR74 | move.go | Checking the copy | pending |
| OR75 | move.go | Copy failed | pending |
| OR76 | move_offline_run.go | Stopped staging after <tries> tries that left no round ready to start. <host> keeps serving and nothing went offline. | pending |
+| OR77 | docs/site/cli.md | refused before anything was written: by the console, at the first status read or the first stage (`--resume` included), or by `carlos` itself (run as root, or with no console) | pending |
diff --git a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
index d452f766c..3f7b11e2d 100644
--- a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
+++ b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
@@ -294,7 +294,7 @@ MV run "--resume $ID --no-finish --probe-path $PROBE_PATH --log $LOG"; echo "run
Lines that read like trouble and are not: `no answer, checking where the move stands` (a door's reply was lost; `run` reads `status` and never posts the same door blind), and `no change for 30 s, woke the boxes` (it asked the console to wake the boxes; the `nudge` door bumps the serial and leaves the record alone).
-**Exit codes**, as for every `carlos move` verb: `0` open (with `--no-finish`) or finished, `3` moved back, `4` stopped for you to decide, `5` the console refused the first stage and nothing was written, `1` the console could not be reached or the log could not be opened.
+**Exit codes**, as for every `carlos move` verb: `0` open (with `--no-finish`) or finished, `3` moved back, `4` stopped for you to decide, `5` refused before anything was written (by the console at the first status read or the first stage, `--resume` included, or by `carlos` itself: run as root, or with no console), `1` the console could not be reached, refused a status read for good once the move was under way (a revoked token, a host it does not know: read `status`), or the log could not be opened.
**After a dead terminal or a lost session:**
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index d3dd80ab0..53bf81cf2 100644
--- a/internal/console/apiinstancemove_offline.go
+++ b/internal/console/apiinstancemove_offline.go
@@ -16,6 +16,7 @@ import (
"slices"
"sort"
"strings"
+ "testing"
"time"
"github.com/carlosframework/platform/internal/domains"
@@ -376,6 +377,26 @@ func offlineEligibleTargets(ev offlineEvidence, eligible []edgesFilePlacementVie
// complete because the edges files could not all be read.
var offlineFleetUnread = &offlineRefusal{status: http.StatusConflict, msg: "the fleet's edges files could not all be read. try again"}
+// offlineNow is the clock the offline doors judge box reports' freshness
+// by: time.Now, or a test's (UseOfflineClockForTest).
+func (s *Server) offlineNow() time.Time {
+ if s.offlineClock != nil {
+ return s.offlineClock()
+ }
+ return time.Now()
+}
+
+// UseOfflineClockForTest sets the clock this server's offline doors judge
+// box reports' freshness by, for a test whose boxes write their reports on
+// a clock of its own (the seeded simulation of offline run, Astra branch
+// round 1, finding 10). Production binaries panic here.
+func (s *Server) UseOfflineClockForTest(now func() time.Time) {
+ if !testing.Testing() {
+ panic("console: UseOfflineClockForTest outside a test binary")
+ }
+ s.offlineClock = now
+}
+
func offlineFresh(r moves.OfflineReport, now time.Time) bool {
age := now.Sub(r.At)
return !r.At.IsZero() && age <= offlineReportFresh && age >= -time.Minute
@@ -1353,7 +1374,7 @@ func (s *Server) offlineVerbDoor(verb string) http.HandlerFunc {
jsonError(w, http.StatusBadGateway, "could not read the move's reports. try again")
return
}
- step, ref := s.offlineStepFor(ctx, d, mv, ev, time.Now())
+ step, ref := s.offlineStepFor(ctx, d, mv, ev, s.offlineNow())
if ref != nil {
writeRefusal(w, ref)
return
@@ -1522,7 +1543,7 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli
if mv == nil || !mv.Offline() {
return v
}
- now := time.Now()
+ now := s.offlineNow()
v.State, v.ID = mv.State, mv.ID
v.From, v.To = s.offlineName(mv.From), s.offlineName(mv.To)
v.FromName, v.ToName = s.offlinePlace(mv.From), s.offlinePlace(mv.To)
diff --git a/internal/console/server.go b/internal/console/server.go
index 0d19a143c..a613bf511 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1172,6 +1172,9 @@ type Server struct {
movesClock func() time.Time
moveCloseMu sync.Mutex
moveCloseSeen map[string]time.Time
+ // offlineClock is the offline doors' clock for report freshness (nil
+ // is time.Now; a TEST SEAM, UseOfflineClockForTest).
+ offlineClock func() time.Time
// moveReleaseFault, when set, fails the pass's claim release just before
// it is made (a TEST SEAM: a release that fails after its log entry is
// queued, movesrecovery.go).
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go
index e7f7de403..9c606148b 100644
--- a/internal/host/movesoffline_e2e_test.go
+++ b/internal/host/movesoffline_e2e_test.go
@@ -202,6 +202,7 @@ type e2eView struct {
type e2eWorld struct {
*landWorld
t *testing.T
+ srv *console.Server
rs *recordingStore
base string // the doors' base URL
token string
@@ -358,7 +359,7 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld {
lw.bundle(landStore)
lw.ukEB = &activator.ExecBackend{ServedPools: testSharedPoolEvidence, DataDir: lw.uk.dd, OptDir: lw.uk.opt, Region: "uk"}
lw.arm(lw.uk)
- w := &e2eWorld{landWorld: lw, t: t, rs: rs, base: ts.URL + "/api/cli/apps/" + wd.acct + "/app/instances/" + offHost + "/move/offline", token: token}
+ w := &e2eWorld{landWorld: lw, t: t, srv: srv, rs: rs, base: ts.URL + "/api/cli/apps/" + wd.acct + "/app/instances/" + offHost + "/move/offline", token: token}
w.mint = func() string {
t.Helper()
at := time.Now()
@@ -2131,6 +2132,7 @@ func (e2eQuiet) Interrupted(offlinerun.Interrupt, offlinerun.Memory) {
type e2eSerialOnly struct {
w *e2eWorld
fast map[*offBox]*fastDeps
+ clock func() time.Time // the boxes' clock, which their reports are written by
tickAt time.Time
deaf func(b *offBox) bool
passes int
@@ -2138,8 +2140,8 @@ type e2eSerialOnly struct {
rendered string // the move whose source config was rendered
}
-func (w *e2eWorld) serialOnly(deaf func(b *offBox) bool) *e2eSerialOnly {
- s := &e2eSerialOnly{w: w, fast: map[*offBox]*fastDeps{}, tickAt: time.Now(), deaf: deaf}
+func (w *e2eWorld) serialOnly(deaf func(b *offBox) bool, clock func() time.Time) *e2eSerialOnly {
+ s := &e2eSerialOnly{w: w, fast: map[*offBox]*fastDeps{}, clock: clock, tickAt: clock(), deaf: deaf}
for _, b := range w.boxes() {
s.fast[b] = &fastDeps{reg: restartTestRegistry(w.t), store: w.rs, fullPass: func(context.Context) {
if s.deaf != nil && s.deaf(b) {
@@ -2147,7 +2149,7 @@ func (w *e2eWorld) serialOnly(deaf func(b *offBox) bool) *e2eSerialOnly {
return
}
s.passes++
- w.tickAt(b, time.Now())
+ w.tickAt(b, s.clock())
}}
}
s.round() // the boot read seeds each box's serial
@@ -2245,7 +2247,17 @@ func (w *e2eWorld) newRun(deaf func(b *offBox) bool) *e2eRun {
for _, tm := range timers {
w.srcTimers[tm.Name] = tm
}
- return &e2eRun{w: w, doors: &e2eRunDoors{w: w}, boxes: w.serialOnly(deaf), policy: offlinerun.DefaultPolicy()}
+ // One clock for the run, the boxes' reports and the doors' judgement
+ // of their freshness: the run's virtual time from now. Without it the
+ // boxes wrote reports on the wall clock while the run's budgets ran on
+ // its own, and a seed's outcome could hang on how fast the machine was
+ // (Astra branch round 1, finding 10).
+ r := &e2eRun{w: w, doors: &e2eRunDoors{w: w}, policy: offlinerun.DefaultPolicy()}
+ base := time.Now()
+ clock := func() time.Time { return base.Add(r.now) }
+ w.srv.UseOfflineClockForTest(clock)
+ r.boxes = w.serialOnly(deaf, clock)
+ return r
}
// e2eRunHappy is the run's POSTs on a move nothing goes wrong with. The