console: offline doors wait only on the pinned target box (#413)
On dev 2026-10-26 a flip never finished: the target region also held a box serving only cohort1. Reconcile never gives such a box the row, so its target report could never be ready, and open wanted exactly one target report. Start (direct and staged) now pins the one eligible target box, and open, finish, the item list and the failed flag read that box's report alone. A move from before the pin reads every target report, as before. Stage and start refuse a region with no box that hibernates and serves the shared pool with a sentence of its own (MV-O194, pending copy), instead of "has 0 boxes". Two eligible boxes still refuse with MV-O22.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+157
−10
approved_moves_copy_test.go+1 −0docs/superpowers/plans/2026-10-06-moves-phase1-copy.md+6 −0internal/console/apiinstancemove_offline.go+44 −9internal/console/apiinstancemove_offline_stage_test.go+27 −0internal/console/apiinstancemove_offline_test.go+79 −1
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go| index af7993a5d..824922974 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -110,6 +110,7 @@ var movesCopyIDs = []string{ |
| "MV-O179", "MV-O180", "MV-O181", "MV-O182", "MV-O183", "MV-O184", "MV-O185", "MV-O186", "MV-O187", "MV-O188", "MV-O189", |
| "MV-O190", "MV-O191", "MV-O192", |
| "MV-O193", |
| + "MV-O194", |
| } |
| // copyRow is one row of the record. The File cell is the file the sentence is |
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 28adb242c..d255cf537 100644 |
| --- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| +++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| @@ -718,3 +718,9 @@ Three more console door refusals for a staged move (`internal/console/apiinstanc |
| | MV-O191 | internal/console/apiinstancemove_offline.go | <to> publishes the same data bucket as <from>. a staged copy there would replace the serving one | approved | |
| | MV-O192 | internal/console/apiinstancemove_offline.go | <to> now publishes a different data bucket or region from what was recorded when <host> was staged. abort the move and stage it again | approved | |
| | MV-O193 | internal/console/seedmove.go (haMoveSentence; RHA-P1a-C1 approved verbatim; emitted at apiinstancemove.go:450,631 and apiinstancemove_offline.go:538) | %s has high availability turned on. offline moves into or out of it are not available yet | approved | |
| + |
| +The start and stage doors' refusal of a region with no box that can hold the instance's row (`internal/console/apiinstancemove_offline.go`, amadan #413). Only a box that hibernates and serves the shared pool counts: a box that serves only a named pool (`CARLOS_POOLS=cohort1`) or a fleet never gets the row, so a move there would wait on it forever. Before this row such a region was refused with MV-O22 and a count of 0. MV-O22 keeps its text and still answers two or more such boxes. `<region>` is the region's name, `<host>` the instance. Pending until reviewed. |
| + |
| +| id | file | text | status | |
| +|---|---|---|---| |
| +| MV-O194 | internal/console/apiinstancemove_offline.go | <region> has no box that can take <host>. an offline move needs one box there that hibernates and serves the shared pool | pending | |
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index 862501c3b..229408fde 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -214,6 +214,21 @@ func (e offlineEvidence) get(role, box string) (offlineReport, bool) { |
| return offlineReport{}, false |
| } |
| +// targets are the target reports the doors read: the pinned target box's |
| +// alone when the move names one (amadan #413). A box beside it that serves |
| +// only another pool can write a target report that is never ready, and no |
| +// door waits on it or shows its items. A move started before the pin reads |
| +// every target report, as it always has. |
| +func (e offlineEvidence) targets(mv *provision.MoveState) []offlineReport { |
| + if mv.TargetBox == "" { |
| + return e.byRole(moves.OfflineRoleTarget) |
| + } |
| + if r, ok := e.get(moves.OfflineRoleTarget, mv.TargetBox); ok { |
| + return []offlineReport{r} |
| + } |
| + return nil |
| +} |
| + |
| func (e offlineEvidence) byRole(role string) []offlineReport { |
| var out []offlineReport |
| for _, r := range e.reports { |
| @@ -377,8 +392,10 @@ func (b offlineClaimsOnBox) ok() bool { |
| // adds none, so every claims-on box fails this condition until one does. |
| func offlineCensusReported(*status.BoxMetrics) *bool { return nil } |
| -// offlineSourceBoxes are the edges files of the record's source placement |
| -// that could hold the host, in box order. |
| +// boxesAt are the edges files of placement code whose boxes could hold the |
| +// host (offlineCanHold), in box order. A box that serves only named pools is |
| +// never one, since reconcile never gives it the row, and nor is one with |
| +// hibernation off. |
| func (f offlineFleet) boxesAt(code string) []edgesFilePlacementView { |
| var out []edgesFilePlacementView |
| for _, b := range f.snap.Files { |
| @@ -399,6 +416,9 @@ func (f offlineFleet) boxesAt(code string) []edgesFilePlacementView { |
| func (s *Server) offlineSelect(ctx context.Context, f offlineFleet, host, from, to string) *offlineRefusal { |
| fromName, toName := s.offlinePlace(from), s.offlinePlace(to) |
| src, tgt := f.boxesAt(from), f.boxesAt(to) |
| + if len(tgt) == 0 { |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s has no box that can take %s. an offline move needs one box there that hibernates and serves the shared pool", toName, host)} |
| + } |
| if len(tgt) != 1 { |
| return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s has %d boxes. an offline move needs exactly one box in the region it moves to", toName, len(tgt))} |
| } |
| @@ -575,6 +595,16 @@ func (s *Server) offlineBeginChecks(w http.ResponseWriter, r *http.Request, d of |
| return to, fleet, true |
| } |
| +// targetBox is the one box at placement to that can hold the row, which |
| +// offlineSelect has already required ("" when there is not exactly one). |
| +// The start pins it on the move (provision.OfflineTargeted). |
| +func (f offlineFleet) targetBox(to string) string { |
| + if tgt := f.boxesAt(to); len(tgt) == 1 { |
| + return tgt[0].Box |
| + } |
| + return "" |
| +} |
| + |
| // offlineStagedFor is the refusal of a start or a stage that names another |
| // region than the one the instance is staged for (MV-O179). |
| func (s *Server) offlineStagedFor(host, to string) *offlineRefusal { |
| @@ -650,11 +680,11 @@ func (s *Server) handleAPIInstanceOfflineStart(w http.ResponseWriter, r *http.Re |
| writeRefusal(w, ref) |
| return |
| } |
| - s.offlineAdvance(w, r, d, provision.OfflineStartStaged(mv.ID, d.addr, time.Now())) |
| + s.offlineAdvance(w, r, d, provision.OfflineTargeted(fleet.targetBox(to), provision.OfflineStartStaged(mv.ID, d.addr, time.Now()))) |
| return |
| } |
| s.offlineBegin(w, r, d, func(id string) func(*provision.Record) error { |
| - return provision.OfflineStart(id, d.rec.Region, to, d.addr, time.Now()) |
| + return provision.OfflineTargeted(fleet.targetBox(to), provision.OfflineStart(id, d.rec.Region, to, d.addr, time.Now())) |
| }) |
| } |
| @@ -947,7 +977,7 @@ func (s *Server) offlineStepFor(ctx context.Context, d offlineDoor, mv *provisio |
| if ref := s.offlineStageCoords(fleet, mv, host); ref != nil { |
| return offlineStep{}, ref |
| } |
| - return offlineStep{mut: provision.OfflineStartStaged(mv.ID, d.addr, now)}, nil |
| + return offlineStep{mut: provision.OfflineTargeted(fleet.targetBox(mv.To), provision.OfflineStartStaged(mv.ID, d.addr, now))}, nil |
| case provision.OfflineStopping: |
| fleet, ok := s.readOfflineFleet(ctx) |
| if !ok { |
| @@ -1114,7 +1144,7 @@ func processRefusal(box, host string) *offlineRefusal { |
| // sealer's living report is from this pass and holds the tombstone for this |
| // move, and every source box is still held, fenced and quiesced. |
| func (s *Server) offlineOpenCheck(ev offlineEvidence, mv *provision.MoveState, host, from string, now time.Time) *offlineRefusal { |
| - tgt := ev.byRole(moves.OfflineRoleTarget) |
| + tgt := ev.targets(mv) |
| if len(tgt) != 1 { |
| return offlineStateRefusal(mv.State, host) |
| } |
| @@ -1153,7 +1183,7 @@ func (s *Server) offlineOpenCheck(ev offlineEvidence, mv *provision.MoveState, h |
| func offlineFinishCheck(ev offlineEvidence, mv *provision.MoveState, host, targetPhase, sealerPhase, sourcePhase string, boxes []string) *offlineRefusal { |
| refuse := offlineStateRefusal(mv.State, host) |
| if targetPhase != "" { |
| - tgt := ev.byRole(moves.OfflineRoleTarget) |
| + tgt := ev.targets(mv) |
| if len(tgt) != 1 || tgt[0].Phase != targetPhase { |
| return refuse |
| } |
| @@ -1418,7 +1448,12 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli |
| // land) means abort is the way on. The CLI says it with MV-O6. |
| if v.CanAbort { |
| for _, r := range ev.reports { |
| - if r.Phase == moves.OfflinePhaseFailed && (r.Role == moves.OfflineRoleSealer || r.Role == moves.OfflineRoleTarget) { |
| + if r.Phase == moves.OfflinePhaseFailed && r.Role == moves.OfflineRoleSealer { |
| + v.Failed = true |
| + } |
| + } |
| + for _, r := range ev.targets(mv) { |
| + if r.Phase == moves.OfflinePhaseFailed { |
| v.Failed = true |
| } |
| } |
| @@ -1433,7 +1468,7 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli |
| // retries it). An item no report decides is unchecked, and a door-owned one |
| // was decided at start. |
| func offlineItems(ev offlineEvidence, mv *provision.MoveState) []offlineItemView { |
| - owners := map[string][]offlineReport{moves.OfflineOwnerLanding: ev.byRole(moves.OfflineRoleTarget)} |
| + owners := map[string][]offlineReport{moves.OfflineOwnerLanding: ev.targets(mv)} |
| if r, ok := ev.get(moves.OfflineRoleSealer, mv.Sealer); ok { |
| owners[moves.OfflineOwnerSeal] = []offlineReport{r} |
| } |
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go| index a22255413..1a58be930 100644 |
| --- a/internal/console/apiinstancemove_offline_stage_test.go |
| +++ b/internal/console/apiinstancemove_offline_stage_test.go |
| @@ -154,6 +154,33 @@ func TestOfflineStageRefusesABoxThatCannotStage(t *testing.T) { |
| w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgO21("uk-box")) |
| } |
| +// amadan #413: a box that serves only a named pool is never where a move |
| +// goes. A region holding nothing else is refused at stage, before anything |
| +// is written or locked; beside a box that serves the shared pool it is |
| +// stepped over (it need not even be able to stage), and the staged start |
| +// pins the shared box as the target. |
| +func TestOfflineStageCountsOnlyBoxesThatCanHoldTheRow(t *testing.T) { |
| + poolOnly := func() offlineBox { b := poolOff(ukOff("uk-pool")); b.NoStageCap = true; return b } |
| + w := newOfflineWorld(t, ieOff("ie-box"), poolOnly()) |
| + w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgNoTarget("uk")) |
| + if rec := w.record(); rec.Move != nil { |
| + t.Fatalf("a refused stage wrote %+v", rec.Move) |
| + } |
| + if _, ok := w.lock(); ok { |
| + t.Fatal("a refused stage took the lock") |
| + } |
| + |
| + w = newOfflineWorld(t, ieOff("ie-box"), ukOff("uk-box"), poolOnly()) |
| + w.stage() |
| + if rec := w.record(); rec.Move.StageBucket != "data-uk" { |
| + t.Fatalf("staged to %q", rec.Move.StageBucket) |
| + } |
| + w.ok("", `{"region":"uk"}`, provision.OfflineStopping) |
| + if rec := w.record(); rec.Move.TargetBox != "uk-box" { |
| + t.Fatalf("the staged start pinned target %q, want uk-box", rec.Move.TargetBox) |
| + } |
| +} |
| + |
| // Abort from staging: reverting, the region untouched; finish waits for |
| // every source box's reverted (the stager's comes after it has deleted the |
| // staged copy), then ends a move that was never offline and frees the lock. |
diff --git a/internal/console/apiinstancemove_offline_test.go b/internal/console/apiinstancemove_offline_test.go| index 7b6d0c144..4c9379c56 100644 |
| --- a/internal/console/apiinstancemove_offline_test.go |
| +++ b/internal/console/apiinstancemove_offline_test.go |
| @@ -435,6 +435,17 @@ func msgMC10(box string) string { |
| func msgO178(box string) string { |
| return "the report from " + box + " is not current. it reports again within a minute. try again then" |
| } |
| + |
| +// msgNoTarget is the start and stage doors' refusal of a region with no |
| +// box that can hold the row (amadan #413). |
| +func msgNoTarget(region string) string { |
| + return region + " has no box that can take " + offlineHost + ". an offline move needs one box there that hibernates and serves the shared pool" |
| +} |
| + |
| +// poolOff is b serving only a named pool: serves_shared_pool false, as a |
| +// CARLOS_POOLS=cohort1 box publishes it. |
| +func poolOff(b offlineBox) offlineBox { b.NotSharedPool = true; return b } |
| + |
| func msgO31(box string) string { |
| return box + " still runs a process for " + offlineHost + ". wait for it to stop, then flip" |
| } |
| @@ -577,7 +588,15 @@ func TestOfflineStartRefusals(t *testing.T) { |
| {name: "an unreadable edges file", boxes: oneEach, body: body, code: 409, msg: "the fleet's edges files could not all be read. try again", |
| setup: func(w *offlineWorld) { offlinePut(t, w.fx.rel, edgesFilePrefix+"broken.json", []byte("{")) }}, |
| {name: "no source box", boxes: []offlineBox{ukOff("uk-box")}, body: body, code: 400, msg: "no eligible box in ie publishes an edges file"}, |
| - {name: "no target box", boxes: []offlineBox{ieOff("ie-box")}, body: body, code: 409, msg: "uk has 0 boxes. an offline move needs exactly one box in the region it moves to"}, |
| + {name: "no target box", boxes: []offlineBox{ieOff("ie-box")}, body: body, code: 409, msg: msgNoTarget("uk")}, |
| + // amadan #413: a box that serves only a named pool, or does not |
| + // hibernate, can never hold the row, so it is not a box the move can |
| + // go to; a region of nothing else has none. |
| + {name: "only a pool box in the target region", boxes: []offlineBox{ieOff("ie-box"), poolOff(ukOff("uk-pool"))}, body: body, code: 409, msg: msgNoTarget("uk")}, |
| + {name: "only a box that does not hibernate in the target region", boxes: []offlineBox{ieOff("ie-box"), func() offlineBox { b := ukOff("uk-cold"); b.NoHibernation = true; return b }()}, |
| + body: body, code: 409, msg: msgNoTarget("uk")}, |
| + {name: "two shared target boxes beside a pool box", boxes: []offlineBox{ieOff("ie-box"), ukOff("uk-a"), ukOff("uk-b"), poolOff(ukOff("uk-pool"))}, body: body, code: 409, |
| + msg: "uk has 2 boxes. an offline move needs exactly one box in the region it moves to"}, |
| {name: "two target boxes", boxes: []offlineBox{ieOff("ie-box"), ukOff("uk-a"), ukOff("uk-b")}, body: body, code: 409, |
| msg: "uk has 2 boxes. an offline move needs exactly one box in the region it moves to"}, |
| {name: "a source box without the capability", boxes: []offlineBox{func() offlineBox { b := ieOff("ie-box"); b.NoCap = true; return b }(), ukOff("uk-box")}, |
| @@ -1008,6 +1027,65 @@ func TestOfflineFinishDoor(t *testing.T) { |
| } |
| } |
| +// amadan #413, seen on dev 2026-10-26: the region a move goes to holds the |
| +// box that can take the row and, beside it, a box that serves only a named |
| +// pool (CARLOS_POOLS=cohort1). Reconcile never gives that box the row, so its |
| +// target report says row_present false with every item not checked, and it |
| +// can never be ready. The start pins the one box that can hold the row, and |
| +// open, finish, the items and the failed flag read that box's report alone. |
| +func TestOfflineWaitsOnlyForThePinnedTarget(t *testing.T) { |
| + w := newOfflineWorld(t, ieOff("ie-box"), ukOff("uk-box"), poolOff(ukOff("uk-a-pool"))) |
| + w.start() |
| + if rec := w.record(); rec.Move.TargetBox != "uk-box" { |
| + t.Fatalf("start pinned target %q, want uk-box", rec.Move.TargetBox) |
| + } |
| + // The pool box (named to sort before the target, so a reader of every |
| + // target report would meet it first) reports as a box from before the |
| + // fix did: no row, every landing item waiting on it, and once failed. |
| + pool := func(phase string) { |
| + w.report(moves.OfflineRoleTarget, "uk-a-pool", phase, func(r *moves.OfflineReport) { |
| + r.Held, r.Fenced, r.Quiesced = false, false, false |
| + r.Items = map[string]moves.Check{} |
| + for _, it := range moves.OfflineOwned(moves.OfflineOwnerLanding) { |
| + r.Items[it.ID] = moves.Check{Reason: "not checked: the row is not held for this move"} |
| + } |
| + }) |
| + } |
| + w.stopped(nil, "ie-box") |
| + w.ok("/seal", "", provision.OfflineSealing) |
| + w.sealed("ie-box") |
| + w.sealerFresh("ie-box") |
| + w.stopped(nil, "ie-box") |
| + w.ok("/flip", "", provision.OfflineLanding) |
| + pool(moves.OfflinePhaseLanded) |
| + w.landed("uk-box") |
| + w.stopped(nil, "ie-box") |
| + w.sealerFresh("ie-box") |
| + v := w.status() |
| + if v.Next != offlineVerbOpen { |
| + t.Fatalf("landed with a pool box beside the target: next %q, waiting %q", v.Next, v.Waiting) |
| + } |
| + for _, it := range v.Items { |
| + if it.Owner == moves.OfflineOwnerLanding && it.Status != "ok" { |
| + t.Fatalf("landing item %s reads %s (%s) from a box that is not the target", it.ID, it.Status, it.Detail) |
| + } |
| + } |
| + pool(moves.OfflinePhaseFailed) |
| + v = w.status() |
| + if v.Failed || v.Next != offlineVerbOpen { |
| + t.Fatalf("a failed report from the pool box: failed %v, next %q", v.Failed, v.Next) |
| + } |
| + for _, it := range v.Items { |
| + if it.Owner == moves.OfflineOwnerLanding && (it.Status != "ok" || it.Detail != "ok") { |
| + t.Fatalf("landing item %s reads %s (%s) from the pool box's failed report", it.ID, it.Status, it.Detail) |
| + } |
| + } |
| + w.ok("/open", "", provision.OfflineOpen) |
| + w.report(moves.OfflineRoleTarget, "uk-box", moves.OfflinePhaseOpened, func(r *moves.OfflineReport) { r.Items = okChecks(moves.OfflineOwnerLanding) }) |
| + w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseParked, nil) |
| + w.ok("/finish", "", provision.OfflineFinishing) |
| +} |
| + |
| func TestOfflineAbortDoor(t *testing.T) { |
| // Before the flip: the region is untouched. |
| w := newOfflineWorld(t, oneEach...) |