carlos / platform Public

moves: offline run counts only big rounds towards OR23's cap

Astra branch review round 1, finding 9 (P2). The five-round cap whose
sentence (OR23) says each round copied over 1 MB now counts only
answered rounds over 1 MiB, one per request. Every other restage (a
small round not watched or gone stale, a restage refused or that wrote
nothing) is bounded on its own at 10 (MaxStageAttempts) and ends with
its own reason and new OR76 (pending). Both abandon the stage, exit 3.
OR23's deck context now says exit 3 (context only).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 60e371bb5606effdc4ed0c0f9d885841d67f90f6 parent 9ed898a
8 files changed, +176 −24
  • approved_moves_copy_test.go +1 −1
  • docs/drafts/offline-move-run/copy-review/strings-fix.json +8 −0
  • docs/drafts/offline-move-run/copy-review/strings.json +1 −1
  • docs/superpowers/plans/2026-10-06-moves-phase1-copy.md +1 −0
  • internal/moves/offlinerun/decide.go +48 −20
  • internal/moves/offlinerun/decide_test.go +70 −1
  • move_offline_run.go +3 −0
  • move_offline_run_test.go +44 −1
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go
index 3ea293157..696c1b093 100644
--- a/approved_moves_copy_test.go
+++ b/approved_moves_copy_test.go
@@ -129,7 +129,7 @@ var movesCopyIDs = []string{
"OR60", "OR61", "OR62", "OR63", "OR65", "OR66",
// The fixes for Astra's branch review, round 1 (deck
// strings-fix.json beside strings.json; pending).
- "OR70", "OR71", "OR72", "OR73", "OR74", "OR75",
+ "OR70", "OR71", "OR72", "OR73", "OR74", "OR75", "OR76",
}
// 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 4539673df..4a152184d 100644
--- a/docs/drafts/offline-move-run/copy-review/strings-fix.json
+++ b/docs/drafts/offline-move-run/copy-review/strings-fix.json
@@ -46,5 +46,13 @@
"text": "Copy failed",
"context": "First line of carlos move offline status for a landed move a box reports failed (the landing's checks did not pass). The failure sentence and the abort command follow under the block. Astra branch review round 1, finding 8.",
"status": "pending"
+ },
+ {
+ "id": "OR76",
+ "section": "run lines",
+ "label": "Staging gave up for other reasons",
+ "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"
}
]
diff --git a/docs/drafts/offline-move-run/copy-review/strings.json b/docs/drafts/offline-move-run/copy-review/strings.json
index ae3936ad7..17273b913 100644
--- a/docs/drafts/offline-move-run/copy-review/strings.json
+++ b/docs/drafts/offline-move-run/copy-review/strings.json
@@ -165,7 +165,7 @@
"section": "run lines",
"label": "Staging never settles",
"text": "Stopped staging after %d rounds: each still copied over 1 MB. %s keeps serving and nothing went offline.",
- "context": "Exit 4. Writes keep arriving faster than staging catches up.",
+ "context": "Step column reads 'limit'. Writes keep arriving faster than staging catches up: five answered rounds each copied over 1 MB (only such rounds count). run then abandons the stage (abort, then finish), so it exits 3.",
"status": "approved (Luna, by Paul's delegation)"
},
{
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 7e677cdae..cc47464e2 100644
--- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
+++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
@@ -824,3 +824,4 @@ Sentences the fixes for Astra's whole-branch review of `offline-move-run` (round
| OR73 | move_offline_run.go | The last staging round failed: <reason>. <host> keeps serving and nothing went offline. | pending |
| 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 |
diff --git a/internal/moves/offlinerun/decide.go b/internal/moves/offlinerun/decide.go
index 6584d8804..3aae7254e 100644
--- a/internal/moves/offlinerun/decide.go
+++ b/internal/moves/offlinerun/decide.go
@@ -74,6 +74,11 @@ const (
ReasonProbeFailed = "probe-failed"
ReasonFailed = "failed"
ReasonStageRounds = "stage-rounds"
+ // ReasonStageAttempts: MaxStageAttempts restages left no round ready
+ // to start (each small round went stale first, or the console refused
+ // the restage or it wrote nothing). Not ReasonStageRounds: no round
+ // need have been big.
+ ReasonStageAttempts = "stage-attempts"
ReasonBudgetStop = "budget-stop"
ReasonBudgetSeal = "budget-seal"
ReasonBudgetLanding = "budget-landing"
@@ -131,9 +136,15 @@ type Policy struct {
// StageRoundBytes: a round that copied more than this is big, and
// another round runs before start.
StageRoundBytes int64
- // MaxStageRounds caps the stage POSTs this process makes. Past it a
- // round that is still big aborts (staging never went offline).
+ // MaxStageRounds caps the answered rounds over StageRoundBytes this
+ // process sees: the one that reaches it aborts (staging never went
+ // offline) with ReasonStageRounds. Only big rounds count.
MaxStageRounds int
+ // MaxStageAttempts caps the other restages: for a small round not
+ // watched or gone stale, and again for a big round already counted
+ // (the restage after it was refused or wrote nothing). Past it the run
+ // aborts with ReasonStageAttempts.
+ MaxStageAttempts int
// SmallRoundFresh: start only within this long of watching a small
// round finish; later, stage again.
SmallRoundFresh time.Duration
@@ -147,17 +158,18 @@ type Policy struct {
// Draft budgets (plan §3). Task 0's rehearsal on dev sets the real ones.
const (
- DefaultStop = 3 * time.Minute
- DefaultSeal = 10 * time.Minute
- DefaultLanding = 5 * time.Minute
- DefaultOpenCheck = 2 * time.Minute
- DefaultOffline = 15 * time.Minute
- DefaultProbe = 2 * time.Minute
- DefaultStageRoundBytes = 1 << 20
- DefaultMaxStageRounds = 5
- DefaultSmallRoundFresh = 60 * time.Second
- DefaultNudgeAfter = 30 * time.Second
- DefaultNudgeEvery = 60 * time.Second
+ DefaultStop = 3 * time.Minute
+ DefaultSeal = 10 * time.Minute
+ DefaultLanding = 5 * time.Minute
+ DefaultOpenCheck = 2 * time.Minute
+ DefaultOffline = 15 * time.Minute
+ DefaultProbe = 2 * time.Minute
+ DefaultStageRoundBytes = 1 << 20
+ DefaultMaxStageRounds = 5
+ DefaultMaxStageAttempts = 10
+ DefaultSmallRoundFresh = 60 * time.Second
+ DefaultNudgeAfter = 30 * time.Second
+ DefaultNudgeEvery = 60 * time.Second
)
// DefaultPolicy is the draft budgets, finishing after open.
@@ -166,8 +178,9 @@ func DefaultPolicy() Policy {
Stop: DefaultStop, Seal: DefaultSeal, Landing: DefaultLanding,
OpenCheck: DefaultOpenCheck, Offline: DefaultOffline, Probe: DefaultProbe,
StageRoundBytes: DefaultStageRoundBytes, MaxStageRounds: DefaultMaxStageRounds,
- SmallRoundFresh: DefaultSmallRoundFresh,
- NudgeAfter: DefaultNudgeAfter, NudgeEvery: DefaultNudgeEvery,
+ MaxStageAttempts: DefaultMaxStageAttempts,
+ SmallRoundFresh: DefaultSmallRoundFresh,
+ NudgeAfter: DefaultNudgeAfter, NudgeEvery: DefaultNudgeEvery,
}
}
@@ -208,6 +221,9 @@ func (Done) isAction() {}
type Memory struct {
id string // the bound move id; "" until bound
stagePosts int // stage POSTs this process decided
+ bigRounds int // answered rounds over StageRoundBytes seen, one per request
+ bigReq int64 // the staged_at of the last big round counted
+ restages int // stage POSTs for any other reason (MaxStageAttempts)
seen bool // a view has been read
state string // the state last read
@@ -476,11 +492,23 @@ func (m Memory) staging(v View, p Policy, now time.Duration) (Action, Memory) {
}
return m.wait(p, now)
}
- // A big round, a small one this process did not watch finish (a
- // resume), or one watched too long ago: run another round.
- if m.stagePosts >= p.MaxStageRounds {
- m = m.Abort(ReasonStageRounds)
- return Post{Verb: VerbAbort, Reason: ReasonStageRounds}, m
+ // A big round newly answered counts towards MaxStageRounds; anything
+ // else that runs another round (a small one this process did not watch
+ // finish, one watched too long ago, a big round already counted whose
+ // restage came to nothing) towards MaxStageAttempts.
+ if !small && m.bigReq != v.StagedAt {
+ m.bigReq = v.StagedAt
+ m.bigRounds++
+ if m.bigRounds >= p.MaxStageRounds {
+ m = m.Abort(ReasonStageRounds)
+ return Post{Verb: VerbAbort, Reason: ReasonStageRounds}, m
+ }
+ } else {
+ if m.restages >= p.MaxStageAttempts {
+ m = m.Abort(ReasonStageAttempts)
+ return Post{Verb: VerbAbort, Reason: ReasonStageAttempts}, m
+ }
+ m.restages++
}
m.stagePosts++
m.stageSent = true
diff --git a/internal/moves/offlinerun/decide_test.go b/internal/moves/offlinerun/decide_test.go
index f4229baff..d558a4595 100644
--- a/internal/moves/offlinerun/decide_test.go
+++ b/internal/moves/offlinerun/decide_test.go
@@ -68,7 +68,8 @@ func TestDecideTable(t *testing.T) {
{"staging, round not answered: wait", bound(StateStaging, 0), staging(5, false, 0), at(1), Wait{}},
{"staging, no stager report yet: wait", bound(StateStaging, 0), staging(1, false, 0), at(1), Wait{}},
{"staging, answered, over 1 MiB, under 5 rounds: stage", bound(StateStaging, 0), staging(5, true, mib+1), at(1), Post{Verb: VerbStage}},
- {"staging, answered, over 1 MiB, 5 rounds spent: abort", func() Memory { m := bound(StateStaging, 0); m.stagePosts = 5; return m }(), staging(5, true, mib+1), at(1), Post{Verb: VerbAbort, Reason: ReasonStageRounds}},
+ {"staging, answered, over 1 MiB, the fifth big round: abort", func() Memory { m := bound(StateStaging, 0); m.bigRounds = 4; return m }(), staging(5, true, mib+1), at(1), Post{Verb: VerbAbort, Reason: ReasonStageRounds}},
+ {"staging, a small round not watched, 10 tries spent: abort", func() Memory { m := bound(StateStaging, 0); m.restages = 10; return m }(), withNext(staging(5, true, 10), VerbStart), at(1), Post{Verb: VerbAbort, Reason: ReasonStageAttempts}},
{"staging, small round watched under 60 s ago, next start: start", smallWatched, withNext(staging(5, true, mib), VerbStart), at(69), Post{Verb: VerbStart}},
{"staging, small round watched, next not yet start: wait", smallWatched, staging(5, true, mib), at(20), Wait{}},
{"staging, small round watched 60 s ago: stage again", smallWatched, withNext(staging(5, true, 10), VerbStart), at(70), Post{Verb: VerbStage}},
@@ -485,3 +486,71 @@ func TestDecideNeverAdoptsAfterItsStage(t *testing.T) {
}
}
}
+
+// TestDecideStageCapsCountWhatTheyName (finding 9): only answered rounds
+// over 1 MiB count towards the five-round cap whose sentence (OR23) says
+// "each still copied over 1 MB". Restages for any other reason (a small
+// round that went stale before start, a restage the console refused or
+// that wrote nothing) are bounded on their own, by MaxStageAttempts, with
+// their own reason.
+func TestDecideStageCapsCountWhatTheyName(t *testing.T) {
+ p := DefaultPolicy()
+ // Small rounds that each go stale before start: never OR23's reason.
+ m := NewMemory(tID)
+ steps := []step{}
+ now := 0.0
+ for r := int64(1); r <= int64(p.MaxStageAttempts); r++ {
+ steps = append(steps,
+ step{at(now), staging(r, false, 10), Wait{}},
+ step{at(now + 2), staging(r, true, 10), Wait{}},
+ step{at(now + 70), withNext(staging(r, true, 10), VerbStart), Post{Verb: VerbStage}},
+ )
+ now += 72
+ }
+ r := int64(p.MaxStageAttempts) + 1
+ steps = append(steps,
+ step{at(now), staging(r, false, 10), Wait{}},
+ step{at(now + 2), staging(r, true, 10), Wait{}},
+ step{at(now + 70), withNext(staging(r, true, 10), VerbStart), Post{Verb: VerbAbort, Reason: ReasonStageAttempts}},
+ )
+ play(t, p, m, steps)
+
+ // A big round, then restages the console refuses (the request never
+ // moves): one big round counted, the rest are tries.
+ m = play(t, p, NewMemory(tID), []step{
+ {0, staging(5, false, 0), Wait{}},
+ {at(2), staging(5, true, 2*mib), Post{Verb: VerbStage}},
+ })
+ steps = nil
+ for i := 1; i <= p.MaxStageAttempts; i++ {
+ steps = append(steps, step{at(float64(2 + 2*i)), staging(5, true, 2*mib), Post{Verb: VerbStage}})
+ }
+ steps = append(steps, step{at(float64(4 + 2*p.MaxStageAttempts)), staging(5, true, 2*mib), Post{Verb: VerbAbort, Reason: ReasonStageAttempts}})
+ play(t, p, m, steps)
+
+ // Four big rounds and nine stale small ones: neither cap is reached.
+ m = NewMemory(tID)
+ now = 0
+ req := int64(1)
+ for i := 0; i < 4; i++ {
+ m = play(t, p, m, []step{
+ {at(now), staging(req, false, 0), Wait{}},
+ {at(now + 2), staging(req, true, 2*mib), Post{Verb: VerbStage}},
+ })
+ req++
+ now += 4
+ }
+ for i := 0; i < 9; i++ {
+ m = play(t, p, m, []step{
+ {at(now), staging(req, false, 10), Wait{}},
+ {at(now + 2), staging(req, true, 10), Wait{}},
+ {at(now + 70), withNext(staging(req, true, 10), VerbStart), Post{Verb: VerbStage}},
+ })
+ req++
+ now += 72
+ }
+ play(t, p, m, []step{
+ {at(now), staging(req, false, 10), Wait{}},
+ {at(now + 2), withNext(staging(req, true, 10), VerbStart), Post{Verb: VerbStart}},
+ })
+}
diff --git a/move_offline_run.go b/move_offline_run.go
index 96c0210a7..cd55de89c 100644
--- a/move_offline_run.go
+++ b/move_offline_run.go
@@ -594,6 +594,9 @@ func (rw *runWatcher) sayWhy(reason string) {
case offlinerun.ReasonStageRounds:
rw.column("limit")
moveSay(rw.out(), fmt.Sprintf("Stopped staging after %d rounds: each still copied over 1 MB. %s keeps serving and nothing went offline.", p.MaxStageRounds, host))
+ case offlinerun.ReasonStageAttempts:
+ rw.column("limit")
+ moveSay(rw.out(), fmt.Sprintf("Stopped staging after %d tries that left no round ready to start. %s keeps serving and nothing went offline.", p.MaxStageAttempts, host))
case offlinerun.ReasonBudgetOffline:
rw.column("limit")
moveSay(rw.out(), fmt.Sprintf("offline for %s, over the limit. Moving it back to %s.", runDuration(p.Offline), from))
diff --git a/move_offline_run_test.go b/move_offline_run_test.go
index 45bab9389..27f710d2d 100644
--- a/move_offline_run_test.go
+++ b/move_offline_run_test.go
@@ -31,6 +31,7 @@ type offlineSim struct {
failIn string // the state whose box work fails
failBy string // the role whose report says it failed: "target" (the default) or "sealer"
+ round int64 // each staging round's round_bytes (10 when 0)
stallIn string // a state whose box work waits for a nudge
holdIn string // a state whose box work never ends
drop string // the verb whose reply is lost (once), after it commits
@@ -97,7 +98,10 @@ func (s *offlineSim) view() frame {
extra["staged_at"] = s.stagedAt
if s.answered != 0 {
st := frame{"box": "ie-box", "phase": "staged", "at": simEpoch, "replica_objects": 1204, "replica_bytes": 48200000,
- "staged_objects": 1204, "staged_bytes": 48200000, "round_bytes": 10, "request": s.answered}
+ "staged_objects": 1204, "staged_bytes": 48200000, "round_bytes": int64(10), "request": s.answered}
+ if s.round != 0 {
+ st["round_bytes"] = s.round
+ }
if s.failIn == s.state {
st["phase"], st["error"] = "failed", "the staging bucket refused a write"
}
@@ -1060,3 +1064,42 @@ func TestMoveOfflineRunStatusOutageNotice(t *testing.T) {
t.Fatalf("a passing failure was said:\n%s", out)
}
}
+
+// TestMoveOfflineRunStagingCaps (finding 9): five answered rounds over
+// 1 MiB end staging with OR23, which says each copied over 1 MB; restages
+// that come to nothing (here the console refuses each one) are bounded on
+// their own and end with OR76. Both abandon the stage: exit 3, the
+// instance never went offline.
+func TestMoveOfflineRunStagingCaps(t *testing.T) {
+ c := &fakeOfflineConsole{sim: &offlineSim{round: 2 << 20}}
+ code, out := runOfflineRun(t, c, runSeams{}, "--to", "uk")
+ if code != 3 {
+ t.Fatalf("exit %d:\n%s", code, out)
+ }
+ if got := doorsOf(c.postsSent()); got != "stage,stage,stage,stage,stage,abort,finish" {
+ t.Fatalf("doors %s:\n%s", got, out)
+ }
+ wantLines(t, out, "limit Stopped staging after 5 rounds: each still copied over 1 MB. acme.shop.example.com keeps serving and nothing went offline.")
+
+ sim := &offlineSim{round: 2 << 20}
+ sim.beforePost = func(s *offlineSim, verb string) {
+ if verb == "stage" && s.recordID() != "" {
+ s.refuse = map[string]string{"stage": "the target publishes another data bucket"}
+ }
+ if verb == "abort" {
+ s.refuse = nil
+ }
+ }
+ c = &fakeOfflineConsole{sim: sim}
+ code, out = runOfflineRun(t, c, runSeams{}, "--to", "uk")
+ if code != 3 {
+ t.Fatalf("exit %d:\n%s", code, out)
+ }
+ if got := doorsOf(c.postsSent()); got != "stage,"+strings.Repeat("stage,", 11)+"abort,finish" {
+ t.Fatalf("doors %s:\n%s", got, out)
+ }
+ wantLines(t, out, "limit Stopped staging after 10 tries that left no round ready to start. acme.shop.example.com keeps serving and nothing went offline.")
+ if strings.Contains(out, "each still copied over 1 MB") {
+ t.Fatalf("said OR23 for refused restages:\n%s", out)
+ }
+}