carlos / platform Public

offline move: count targets by edges eligibility, drop the pin (#413)

Astra round 1. P1: an older writer decodes the record into the old
MoveState and drops move.target_box, so the hang could return mid-move.
P2: the status view still returned every target report, and the CLI's
failure scan aborted a good landing on a pool box's failed report.

The pin is gone (MoveState.TargetBox, provision.OfflineTargeted). The
console now keeps a target report only from a box the edges files say
can hold the row (boxesAt: in the target region, hibernating, serving
the shared pool), read fresh in one place, offlineMoveEvidence, which
every door and the status view read. Open, finish, the items, the failed
flag and the reports the view returns (so any CLI) see the same targets.
With the fleet unreadable no target report counts and open says so. The
box-side pool check and MV-O194 stay.

Tests: a record rewritten by an older writer still opens; the CLI's flip
through the real console follows a failed pool-box report to next ==
open and exits 0, and status agrees (exit 4 on the unfiltered view).
Census re-proposed: internal/host only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 79afb1d91ab289d342fd8a5d9db2785fd87c000a parent 529066b
13 files changed, +249 −197
  • docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md +1 −1
  • docs/superpowers/plans/2026-10-21-offline-move-runbook.md +1 −1
  • internal/console/apiinstancemove_offline.go +62 −39
  • internal/console/apiinstancemove_offline_stage_test.go +2 −5
  • internal/console/apiinstancemove_offline_test.go +53 −15
  • internal/host/movesoffline.go +6 −9
  • internal/host/movesoffline_e2e_test.go +0 −3
  • internal/host/movesoffline_test.go +13 −23
  • internal/provision/offline_move.go +0 −23
  • internal/provision/offline_move_test.go +0 −58
  • internal/provision/provision.go +0 −8
  • internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv +2 −3
  • offline_move_e2e_test.go +109 −9

CI cancelled — superseded by a newer push — run details

Intent

Human

<task-notification> <task-id>a5a8684b1f0a9b866</task-id> <tool-use-id>toolu_01WimFgMYXPFjxGpBKKEivxd</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a5a8684b1f0a9b866.output</output-file> <status>completed</status> <summary>Agent "Implement #339 stage refusals" is waiting on its own background work</summary> <note>This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does; the result below may be interim.</note> <result>Waiting for the mutation results before running the census and full targeted suites.</result> <usage><subagent_tokens>344963</subagent_tokens><tool_uses>21</tool_uses><duration_ms>416241</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a5a8684b1f0a9b866</task-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a5a8684b1f0a9b866.output</output-file> <status>completed</status> <summary>Agent "Implement #339 stage refusals" is waiting on its own background work</summary> <note>This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does; the result below may be interim.</note> <result>Waiting for the suite results before committing.</result> <usage><subagent_tokens>358174</subagent_tokens><tool_uses>33</tool_uses><duration_ms>1384450</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a5a8684b1f0a9b866</task-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a5a8684b1f0a9b866.output</output-file> <status>completed</status> <summary>Agent "Implement #339 stage refusals" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Round 1 fixes are pushed as 6b580cd6 on `offline-move-stage-refusals-339`. Tests and the census pass locally, and the census still needs a reviewer. **What changed:** - **Item 4 cut.** The app-directory report, its refusal (MV-O201), its tests and the `offlineFilesAt` split are gone. `movesoffline_seal.go` is back to main byte for byte; I reverted the split rather than keep it, because nothing else uses it now. - **P1-1.** The live-link probe returns nil under effective UID 0 before it touches the disk. Tested, and it is the first check in the function. - **P1-3.** The probe reads only the names in `/opt/carlos/live`, nothing else. That directory is root's (0755, only root writes it, and every name comes from root creating a host's link), so tenants cannot add names. It reads at most 4096 names and does not stat, follow or open any entry. The report carries at most 128 names and 8 KiB, plus an overflow flag. The doors refuse on overflow with a new pending row, MV-O204. Tested through `WriteBox` and `LoadBoxesComplete`. - **P2-4.** The staging status view runs the same check, so it no longer offers `start` while a link is reported. - **P2-5.** The refusals print only the record's validated host and the box name. Link names from the report are compared, never printed. - **P2-6 and P2-7.** Copy reworded as below; the runbook now scopes the new status line to before `finish`. - **E2E.** It now gets the facts through `offlineMoveFactsProbe` and fails if `statusLoop` stops setting `p.OfflineMove`. **Tests:** status, docsite, console `Offline`, host `Offline|MovesOffline|EdgesFile|Status`, the root package's copy and parity tests, and the census tests all pass. gofmt, vet and the darwin and windows builds are clean. Each new guard failed its test when disabled. **Census:** re-proposed under the same name and the census tests pass. It needs a reviewer from the other model family. **Final copy (pending Luna):** - **MV-O200:** `&lt;box&gt; still holds a live link for &lt;host&gt; from when it last ran there. stage refuses until it is cleared, since a mismatched link fails the move only after &lt;host&gt; is offline. see the offline move runbook` - **MV-O203:** "`stage` and `start` refuse a move that would fail after the instance goes offline: when a box in the target region still holds a live link for the instance from an earlier time it ran there. Each refusal names the box and what it found." - **MV-O204:** `&lt;box&gt; holds more live links than it can report, so stage cannot tell whether one is for &lt;host&gt;. see the offline move runbook` I deleted the `.luna-339*` files and committed Astra's findings file with the fixes.</result> <usage><subagent_tokens>361477</subagent_tokens><tool_uses>35</tool_uses><duration_ms>1567429</duration_ms></usage> </task-notification>

diff --git a/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md
index 72ad6c49b..fc46da2d2 100644
--- a/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md
+++ b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md
@@ -6,7 +6,7 @@ Ruling `census-ruling-offline-move-pool-target-413`. The independent reviewer ap
|---|---|---|---|
| `internal/host/movespass.go` `armOffline` | body | unchanged (1) | sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added |
-Envelopes re-pinned: `internal/host`, `internal/provision`.
+Envelopes re-pinned: `internal/host`.
Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
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 0a424c77c..1408ed3eb 100644
--- a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
+++ b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
@@ -108,7 +108,7 @@ Pass:
- one file per live box, and no file for a box that no longer exists (a stale file naming the home placement blocks `seal`; removing it needs Paul);
- every box in both regions lists `offline-move-1` **and** `offline-stage-1`;
- the target's `placement` is the region you move to, and it has a `data_bucket` (that is `$TGTDATA`);
-- exactly one box in the target region has `hibernation_configured` true and `serves_shared_pool` true. That box is the target: `start` pins it on the record as `move.target_box`, and every later step waits on it alone. A box beside it that serves only a named pool (`CARLOS_POOLS=cohort1`, like leo-climbing on dev) or a fleet is not a target and takes no part (amadan #413). A region with no such box is refused at `stage` and `start`;
+- exactly one box in the target region has `hibernation_configured` true and `serves_shared_pool` true. That box is the target, and the doors count only its target report. A box beside it that serves only a named pool (`CARLOS_POOLS=cohort1`, like leo-climbing on dev) or a fleet is not a target and takes no part (amadan #413). A region with no such box is refused at `stage` and `start`;
- `hibernation_configured` true;
- the target's `secrets_key_fp` equals the source's. The start door checks only the target's fingerprint against the console. A box with no `CARLOS_SECRETS_KEY` publishes no fingerprint at all; on dev, leo-climbing is such a box, and it is not a blocker unless it is the target.
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index 229408fde..7ac8f73f2 100644
--- a/internal/console/apiinstancemove_offline.go
+++ b/internal/console/apiinstancemove_offline.go
@@ -203,6 +203,10 @@ type offlineReport struct {
type offlineEvidence struct {
reports []offlineReport
seal *offlineReport
+ // targetsUnread: the move has target reports, and the edges files that
+ // say which of them count could not be read (offlineMoveEvidence), so
+ // none was kept and no door may decide from the target's side.
+ targetsUnread bool
}
func (e offlineEvidence) get(role, box string) (offlineReport, bool) {
@@ -214,21 +218,6 @@ 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 {
@@ -295,6 +284,49 @@ func (s *Server) readOfflineEvidence(ctx context.Context, host, id string) (offl
return ev, nil
}
+// offlineMoveEvidence is readOfflineEvidence for a move, with only the
+// target reports that count (amadan #413). It is the one read every door
+// and the status view decide from, so open, finish, the item list, the
+// failed flag and the reports the view returns (which the CLI reads) all
+// see the same targets. A target report counts only when the box that wrote
+// it is one the start door would have taken: published in the region the
+// move goes to, hibernating and serving the shared pool (boxesAt,
+// offlineCanHold), read fresh from the edges files. A box beside it that
+// serves only a named pool never gets the row, so its report is never
+// ready, and an old one that wrote a report anyway is not waited on. The
+// start door admits exactly one such box, so one target report counts.
+// Nothing is read from the record for this, so a record rewritten by an
+// older writer decides the same way.
+func (s *Server) offlineMoveEvidence(ctx context.Context, host string, mv *provision.MoveState) (offlineEvidence, error) {
+ ev, err := s.readOfflineEvidence(ctx, host, mv.ID)
+ if err != nil || len(ev.byRole(moves.OfflineRoleTarget)) == 0 {
+ return ev, err
+ }
+ fleet, ok := s.readOfflineFleet(ctx)
+ if !ok {
+ return offlineEligibleTargets(ev, nil, false), nil
+ }
+ return offlineEligibleTargets(ev, fleet.boxesAt(mv.To), true), nil
+}
+
+// offlineEligibleTargets keeps, of ev, the target reports of the boxes in
+// eligible, and every report of any other role. read false says the fleet
+// could not be read: no target report is kept, and targetsUnread is set.
+func offlineEligibleTargets(ev offlineEvidence, eligible []edgesFilePlacementView, read bool) offlineEvidence {
+ out := offlineEvidence{seal: ev.seal, targetsUnread: !read}
+ for _, r := range ev.reports {
+ if r.Role == moves.OfflineRoleTarget && !slices.ContainsFunc(eligible, func(b edgesFilePlacementView) bool { return b.Box == r.Box }) {
+ continue
+ }
+ out.reports = append(out.reports, r)
+ }
+ return out
+}
+
+// offlineFleetUnread is the refusal of a step whose evidence it could not
+// 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"}
+
func offlineFresh(r moves.OfflineReport, now time.Time) bool {
age := now.Sub(r.At)
return !r.At.IsZero() && age <= offlineReportFresh && age >= -time.Minute
@@ -595,16 +627,6 @@ 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 {
@@ -680,11 +702,11 @@ func (s *Server) handleAPIInstanceOfflineStart(w http.ResponseWriter, r *http.Re
writeRefusal(w, ref)
return
}
- s.offlineAdvance(w, r, d, provision.OfflineTargeted(fleet.targetBox(to), provision.OfflineStartStaged(mv.ID, d.addr, time.Now())))
+ s.offlineAdvance(w, r, d, provision.OfflineStartStaged(mv.ID, d.addr, time.Now()))
return
}
s.offlineBegin(w, r, d, func(id string) func(*provision.Record) error {
- return provision.OfflineTargeted(fleet.targetBox(to), provision.OfflineStart(id, d.rec.Region, to, d.addr, time.Now()))
+ return provision.OfflineStart(id, d.rec.Region, to, d.addr, time.Now())
})
}
@@ -977,7 +999,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.OfflineTargeted(fleet.targetBox(mv.To), provision.OfflineStartStaged(mv.ID, d.addr, now))}, nil
+ return offlineStep{mut: provision.OfflineStartStaged(mv.ID, d.addr, now)}, nil
case provision.OfflineStopping:
fleet, ok := s.readOfflineFleet(ctx)
if !ok {
@@ -1144,7 +1166,10 @@ 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.targets(mv)
+ if ev.targetsUnread {
+ return offlineFleetUnread
+ }
+ tgt := ev.byRole(moves.OfflineRoleTarget)
if len(tgt) != 1 {
return offlineStateRefusal(mv.State, host)
}
@@ -1183,7 +1208,10 @@ 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.targets(mv)
+ if ev.targetsUnread {
+ return offlineFleetUnread
+ }
+ tgt := ev.byRole(moves.OfflineRoleTarget)
if len(tgt) != 1 || tgt[0].Phase != targetPhase {
return refuse
}
@@ -1246,7 +1274,7 @@ func (s *Server) offlineVerbDoor(verb string) http.HandlerFunc {
return
}
ctx := r.Context()
- ev, err := s.readOfflineEvidence(ctx, d.host, mv.ID)
+ ev, err := s.offlineMoveEvidence(ctx, d.host, mv)
if err != nil {
log.Printf("console: offline move %s: reports: %v", d.host, err)
jsonError(w, http.StatusBadGateway, "could not read the move's reports. try again")
@@ -1418,7 +1446,7 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli
case provision.OfflineStaging, provision.OfflineStopping, provision.OfflineSealing, provision.OfflineSealed, provision.OfflineLanding, provision.OfflineLanded:
v.CanAbort = true
}
- ev, err := s.readOfflineEvidence(ctx, rec.Host, mv.ID)
+ ev, err := s.offlineMoveEvidence(ctx, rec.Host, mv)
if err != nil {
log.Printf("console: offline move %s: reading the reports: %v", rec.Host, err)
v.Waiting = "could not read the move's reports. try again"
@@ -1448,12 +1476,7 @@ 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 {
- v.Failed = true
- }
- }
- for _, r := range ev.targets(mv) {
- if r.Phase == moves.OfflinePhaseFailed {
+ if r.Phase == moves.OfflinePhaseFailed && (r.Role == moves.OfflineRoleSealer || r.Role == moves.OfflineRoleTarget) {
v.Failed = true
}
}
@@ -1468,7 +1491,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.targets(mv)}
+ owners := map[string][]offlineReport{moves.OfflineOwnerLanding: ev.byRole(moves.OfflineRoleTarget)}
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 1a58be930..df0444b76 100644
--- a/internal/console/apiinstancemove_offline_stage_test.go
+++ b/internal/console/apiinstancemove_offline_stage_test.go
@@ -157,8 +157,8 @@ func TestOfflineStageRefusesABoxThatCannotStage(t *testing.T) {
// 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.
+// stepped over (it need not even be able to stage), and the staged move
+// starts.
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())
@@ -176,9 +176,6 @@ func TestOfflineStageCountsOnlyBoxesThatCanHoldTheRow(t *testing.T) {
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
diff --git a/internal/console/apiinstancemove_offline_test.go b/internal/console/apiinstancemove_offline_test.go
index 4c9379c56..b0d8d5de9 100644
--- a/internal/console/apiinstancemove_offline_test.go
+++ b/internal/console/apiinstancemove_offline_test.go
@@ -1031,14 +1031,15 @@ func TestOfflineFinishDoor(t *testing.T) {
// 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) {
+// can never be ready. A target report counts only from a box the edges files
+// say can hold the row (offlineMoveEvidence): open, finish, the items, the
+// failed flag and the reports the view returns all leave the pool box out.
+// Nothing about it is on the record, so a record rewritten by an older
+// writer (the sealer's and the target's transitions decode and re-encode
+// the whole record) still opens.
+func TestOfflineCountsOnlyTargetsThatCanHoldTheRow(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.
@@ -1061,24 +1062,38 @@ func TestOfflineWaitsOnlyForThePinnedTarget(t *testing.T) {
w.landed("uk-box")
w.stopped(nil, "ie-box")
w.sealerFresh("ie-box")
+ // An older writer's rewrite: the record decoded into the move shape every
+ // release has and written back whole.
+ w.rewriteRecord()
+ onlyTarget := func(v offlineView, when string) {
+ t.Helper()
+ for _, r := range v.Reports {
+ if r.Role == moves.OfflineRoleTarget && r.Box != "uk-box" {
+ t.Fatalf("%s: the view returns %s's target report", when, r.Box)
+ }
+ }
+ for _, it := range v.Items {
+ if it.Owner == moves.OfflineOwnerLanding && (it.Status != "ok" || it.Detail != "ok") {
+ t.Fatalf("%s: landing item %s reads %s (%s) from a box that cannot hold the row", when, it.ID, it.Status, it.Detail)
+ }
+ }
+ }
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)
- }
- }
+ onlyTarget(v, "landed")
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)
- }
+ onlyTarget(v, "the pool box failed")
+ // The fleet unread: no target report counts, and open says why.
+ offlinePut(t, w.fx.rel, edgesFilePrefix+"broken.json", []byte("{"))
+ w.refused(http.MethodPost, "/open", "", http.StatusConflict, "the fleet's edges files could not all be read. try again")
+ if err := w.fx.rel.Delete(context.Background(), edgesFilePrefix+"broken.json"); err != nil {
+ t.Fatal(err)
}
w.ok("/open", "", provision.OfflineOpen)
w.report(moves.OfflineRoleTarget, "uk-box", moves.OfflinePhaseOpened, func(r *moves.OfflineReport) { r.Items = okChecks(moves.OfflineOwnerLanding) })
@@ -1086,6 +1101,29 @@ func TestOfflineWaitsOnlyForThePinnedTarget(t *testing.T) {
w.ok("/finish", "", provision.OfflineFinishing)
}
+// rewriteRecord stands in for an older writer's transition: the record read,
+// decoded into provision.Record and written back whole under its etag.
+func (w *offlineWorld) rewriteRecord() {
+ w.t.Helper()
+ ctx := context.Background()
+ key := provision.RecordKey("bab", "shop", offlineHost)
+ raw, etag, err := w.fx.rel.Get(ctx, key)
+ if err != nil {
+ w.t.Fatal(err)
+ }
+ var rec provision.Record
+ if err := json.Unmarshal(raw, &rec); err != nil {
+ w.t.Fatal(err)
+ }
+ out, err := json.Marshal(rec)
+ if err != nil {
+ w.t.Fatal(err)
+ }
+ if _, err := w.fx.rel.Put(ctx, key, out, etag); err != nil {
+ w.t.Fatal(err)
+ }
+}
+
func TestOfflineAbortDoor(t *testing.T) {
// Before the flip: the region is untouched.
w := newOfflineWorld(t, oneEach...)
diff --git a/internal/host/movesoffline.go b/internal/host/movesoffline.go
index 7e5cff9f1..28e01b56d 100644
--- a/internal/host/movesoffline.go
+++ b/internal/host/movesoffline.go
@@ -451,16 +451,13 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro
}
// offlineTargetHere says whether this box, in the region the move goes to,
-// is the move's target (amadan #413): its pools admit the record, and it is
-// the box the start pinned (move.target_box), or the move pins none (one
-// started before the pin). Any other box in that region never gets the row
-// from reconcile, or is not the box the doors wait on, so it writes no
-// target report and lands nothing.
+// can be the move's target (amadan #413): its pools admit the record. A box
+// whose pools do not never gets the row from reconcile, so it writes no
+// target report and lands nothing. The console counts a target report only
+// from a box its edges file says can hold the row, so this is the box's own
+// half of the same rule, and it reads nothing from the record but the pool.
func (c moveCfg) offlineTargetHere(rec provision.Record) bool {
- if !c.OfflinePools.Serves(rec.Pool) {
- return false
- }
- return rec.Move.TargetBox == "" || rec.Move.TargetBox == c.Box
+ return c.OfflinePools.Serves(rec.Pool)
}
// offlineReassertEvery is how often a box that takes part in an offline move
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go
index 7fa9b0dae..edd1f6b9b 100644
--- a/internal/host/movesoffline_e2e_test.go
+++ b/internal/host/movesoffline_e2e_test.go
@@ -1320,9 +1320,6 @@ func offlineMoveDone(t *testing.T, opts landOpts) {
t.Fatalf("env-pin across the two agent environments: %+v", r.Items["env-pin"])
}
if w.pool != nil {
- if rec := w.wd.record(); rec.Move.TargetBox != "uk-box" {
- t.Fatalf("the start pinned target %q, want uk-box", rec.Move.TargetBox)
- }
if rt := w.pool.row(offHost); rt != nil {
t.Fatalf("uk-pool holds a row for the host: %+v", rt)
}
diff --git a/internal/host/movesoffline_test.go b/internal/host/movesoffline_test.go
index d226ac12f..19ba781bf 100644
--- a/internal/host/movesoffline_test.go
+++ b/internal/host/movesoffline_test.go
@@ -285,16 +285,13 @@ func writeFile(t *testing.T, p, body string) {
// --- the hold ---------------------------------------------------------------
-// amadan #413: in the region a move goes to, only the box whose pools admit
-// the record and that the start pinned takes the target role. armOffline
-// reads the pools from CARLOS_POOLS the way reconcile does, so a box serving
-// only cohort1 (leo on dev) never lands a shared-pool record nor reports for
-// it, and a shared box beside the pinned one waits too. A move from before
-// the pin names no box: any box whose pools admit the record is a target,
-// as before.
-func TestOfflineTargetIsThePinnedBoxThatCanHoldTheRow(t *testing.T) {
- armed := func(box, pools string) moveCfg {
- cfg := moveCfg{Region: "uk", Box: box}
+// amadan #413: in the region a move goes to, a box takes the target role
+// only when its pools admit the record. armOffline reads the pools from
+// CARLOS_POOLS the way reconcile does, so a box serving only cohort1 (leo on
+// dev) never lands a shared-pool record nor reports for it.
+func TestOfflineTargetIsABoxThatCanHoldTheRow(t *testing.T) {
+ armed := func(pools string) moveCfg {
+ cfg := moveCfg{Region: "uk", Box: "uk-box"}
armOffline(&cfg, t.TempDir(), nil, nil, nil, hostwrite.Config{}, func(k string) string {
switch k {
case "CARLOS_POOLS":
@@ -306,26 +303,19 @@ func TestOfflineTargetIsThePinnedBoxThatCanHoldTheRow(t *testing.T) {
})
return cfg
}
- rec := func(pool, pinned string) provision.Record {
- return provision.Record{Host: offHost, Pool: pool, Region: "uk", Move: &provision.MoveState{Kind: provision.MoveKindOffline, ID: offID, To: "uk", State: provision.OfflineLanding, TargetBox: pinned}}
- }
+ rec := provision.Record{Host: offHost, Region: "uk", Move: &provision.MoveState{Kind: provision.MoveKindOffline, ID: offID, To: "uk", State: provision.OfflineLanding}}
for _, c := range []struct {
name string
cfg moveCfg
- rec provision.Record
want bool
}{
- {"the pinned shared box", armed("uk-box", ""), rec("", "uk-box"), true},
- {"the pinned box serving the shared pool beside a named one", armed("uk-box", "@shared,cohort1"), rec("", "uk-box"), true},
- {"a pool box beside the pinned one", armed("uk-pool", "cohort1"), rec("", "uk-box"), false},
- {"a shared box that is not the pinned one", armed("uk-other", ""), rec("", "uk-box"), false},
- {"a pool box named as the target of a shared-pool record", armed("uk-pool", "cohort1"), rec("", "uk-pool"), false},
- {"no pin, a shared box", armed("uk-box", ""), rec("", ""), true},
- {"no pin, a pool box", armed("uk-pool", "cohort1"), rec("", ""), false},
- {"a box with no pools armed", moveCfg{Region: "uk", Box: "uk-box"}, rec("", ""), false},
+ {"a shared box", armed(""), true},
+ {"a box serving the shared pool beside a named one", armed("@shared,cohort1"), true},
+ {"a box serving only a named pool", armed("cohort1"), false},
+ {"a box with no pools armed", moveCfg{Region: "uk", Box: "uk-box"}, false},
} {
t.Run(c.name, func(t *testing.T) {
- if got := c.cfg.offlineTargetHere(c.rec); got != c.want {
+ if got := c.cfg.offlineTargetHere(rec); got != c.want {
t.Fatalf("offlineTargetHere = %v, want %v", got, c.want)
}
})
diff --git a/internal/provision/offline_move.go b/internal/provision/offline_move.go
index be6f9ac6f..9176e8f99 100644
--- a/internal/provision/offline_move.go
+++ b/internal/provision/offline_move.go
@@ -250,29 +250,6 @@ func OfflineStartStaged(id, by string, now time.Time) func(*Record) error {
}
}
-// OfflineTargeted is a start that also pins the move's target box: the one
-// box in the region the move goes to that can hold the row, as the start
-// door found it (amadan #413). start is OfflineStart or OfflineStartStaged,
-// so the pin is written in the same write that takes the instance offline,
-// and every later step waits on that box alone. An empty box, or a mut that
-// does not leave the move in offline-stopping (a stage is not a start), is a
-// malformed start and writes nothing.
-func OfflineTargeted(box string, start func(*Record) error) func(*Record) error {
- return func(rec *Record) error {
- if box == "" {
- return fmt.Errorf("%w: %s", ErrMoveConflict, refusedMalformedStart)
- }
- if err := start(rec); err != nil {
- return err
- }
- if !rec.Move.Offline() || rec.Move.State != OfflineStopping {
- return fmt.Errorf("%w: %s", ErrMoveConflict, refusedMalformedStart)
- }
- rec.Move.TargetBox = box
- return nil
- }
-}
-
// OfflineRestage is staging to staging: the operator asked for another
// pre-copy round. It moves staged_at to now (always forward), which is the
// request the stager answers with exactly one round (the stager report's
diff --git a/internal/provision/offline_move_test.go b/internal/provision/offline_move_test.go
index e3becc2e1..1e52c760b 100644
--- a/internal/provision/offline_move_test.go
+++ b/internal/provision/offline_move_test.go
@@ -1058,61 +1058,3 @@ func TestMoveSeqExhaustionAtEveryTransition(t *testing.T) {
t.Fatalf("start one below the ceiling: %v %+v", err, got)
}
}
-
-// The start pins the one box in the target region that can hold the row
-// (amadan #413): every later step waits on that box alone, so a box beside
-// it that serves only another pool never holds the move up. Both starts pin
-// it, the direct one and a staged move's; an empty box is a malformed start
-// and writes nothing; and a mut that does not leave the move in stopping
-// (a stage) is not a start and writes nothing.
-func TestOfflineTargetedPinsTheTargetBox(t *testing.T) {
- ctx := context.Background()
- now := time.Date(2026, 11, 13, 9, 0, 0, 0, time.UTC)
- st := StageTarget{Stager: offSealer, Bucket: "data-uk", Region: "eu-west-2"}
- t.Run("direct start", func(t *testing.T) {
- s := release.NewDirStore(t.TempDir())
- rec := offlineRecord(t, s)
- got, err := SetRecordMove(ctx, s, rec.Account, rec.App, rec.Host, OfflineTargeted("uk-box", OfflineStart(offID, "", "uk", "ops@example.com", now)))
- if err != nil || got.Move.TargetBox != "uk-box" || got.Move.State != OfflineStopping {
- t.Fatalf("start = %v %+v", err, got.Move)
- }
- })
- t.Run("staged start", func(t *testing.T) {
- s := release.NewDirStore(t.TempDir())
- rec := offlineRecord(t, s)
- if _, err := SetRecordMove(ctx, s, rec.Account, rec.App, rec.Host, OfflineStage(offID, "", "uk", "ops@example.com", st, now)); err != nil {
- t.Fatal(err)
- }
- got, err := SetRecordMove(ctx, s, rec.Account, rec.App, rec.Host, OfflineTargeted("uk-box", OfflineStartStaged(offID, "ops@example.com", now.Add(time.Minute))))
- if err != nil || got.Move.TargetBox != "uk-box" || got.Move.State != OfflineStopping {
- t.Fatalf("staged start = %v %+v", err, got.Move)
- }
- })
- for name, mut := range map[string]func(*Record) error{
- "no box": OfflineTargeted("", OfflineStart(offID, "", "uk", "ops@example.com", now)),
- "a stage": OfflineTargeted("uk-box", OfflineStage(offID, "", "uk", "ops@example.com", st, now)),
- } {
- t.Run(name, func(t *testing.T) {
- s := release.NewDirStore(t.TempDir())
- rec := offlineRecord(t, s)
- key := RecordKey(rec.Account, rec.App, rec.Host)
- before, _, _ := s.Get(ctx, key)
- if _, err := SetRecordMove(ctx, s, rec.Account, rec.App, rec.Host, mut); !errors.Is(err, ErrMoveConflict) || !strings.Contains(err.Error(), refusedMalformedStart) {
- t.Fatalf("%s = %v, want the malformed start", name, err)
- }
- if after, _, _ := s.Get(ctx, key); !bytes.Equal(before, after) {
- t.Fatalf("%s wrote the record", name)
- }
- })
- }
- // The pin is additive on the wire: a journal without it reads empty, and
- // one with it round-trips.
- const pinned = `{"schema":1,"host":"a.go.example.com","slug":"s","app":"app","account":"bab","region":"ie","channel":"stable","created_at":"2026-09-01T08:00:00Z","move":{"id":"mv_abcdefghijklmnopqrstuvwxyz","from":"ie","to":"uk","state":"offline-stopping","requested_by":"ops@example.com","requested_at":"2026-10-21T09:00:00Z","updated_at":"2026-10-21T09:00:00Z","kind":"offline","target_box":"uk-box","seq":1}}`
- rec, err := DecodeRecord([]byte(pinned))
- if err != nil || rec.Move.TargetBox != "uk-box" {
- t.Fatalf("pinned journal: %v %+v", err, rec.Move)
- }
- if out, _ := json.Marshal(rec); string(out) != pinned {
- t.Errorf("pinned journal did not round-trip:\n got %s\nwant %s", out, pinned)
- }
-}
diff --git a/internal/provision/provision.go b/internal/provision/provision.go
index 17d2f5ed0..5a8d307ef 100644
--- a/internal/provision/provision.go
+++ b/internal/provision/provision.go
@@ -1339,14 +1339,6 @@ type MoveState struct {
// Additive and omitempty.
StageBucket string `json:"stage_bucket,omitempty"`
StageRegion string `json:"stage_region,omitempty"`
- // TargetBox is the one box in the region the move goes to that can
- // hold the row, pinned by the start (OfflineTargeted) from the edges
- // files the start door read. That box alone lands, and the doors read
- // that box's target report alone: a box beside it that serves only
- // another pool never gets the row, so a wait on it never ends (amadan
- // #413). Empty on a move started before the pin. Additive and
- // omitempty.
- TargetBox string `json:"target_box,omitempty"`
// Seq is the record's move_seq as the transition that produced this
// state left it (self-serve moves plan 1 Task 7, offline_move.go): the
// hold's for a held row, open's for the target, the abort's for the
diff --git a/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv
index b4b4b7934..7d475494f 100644
--- a/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv
+++ b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv
@@ -1,6 +1,5 @@
# Census overlay offline-move-pool-target-413, written by census-propose (#369). census-ruling-offline-move-pool-target-413, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md.
-# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
@legacy 1c7bd4ba117b1b09a161422e9344a24460fddd7418477fdca993d513254791b3 internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd
internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd
-@coverage internal/host 409447883edc805e3667a85bfa4244aaef442c8c84deb61d73dfd8b7f0d60900
-@coverage internal/provision 2384ec8d80a2f83455602ebec1d84b8793d9f2691df2ecbd7c3a283f42d52857
+@coverage internal/host d61aeb158451d6f59b0f702c4fc36304a79fe83473a2dbced957542ef7deece6
diff --git a/offline_move_e2e_test.go b/offline_move_e2e_test.go
index 7cc471e29..1c7125041 100644
--- a/offline_move_e2e_test.go
+++ b/offline_move_e2e_test.go
@@ -32,6 +32,9 @@ type offlineE2E struct {
put func(id, box, role, phase string, edit func(*moves.OfflineReport))
// srv is the real console, for a test that reads its region names.
srv *console.Server
+ // publish writes one more box's edges file and status snapshot;
+ // shared false is a box that serves only a named pool.
+ publish func(box, placement, aws, bucket string, shared bool)
}
func newOfflineE2E(t *testing.T, caps []string) *offlineE2E {
@@ -109,23 +112,23 @@ func newOfflineE2E(t *testing.T, caps []string) *offlineE2E {
if res.StatusCode != http.StatusCreated {
t.Fatalf("create the instance = %d", res.StatusCode)
}
- for _, b := range []struct{ box, placement, aws, bucket string }{
- {"ie-box", "ie", "eu-west-1", "data-ie"},
- {"uk-box", "uk", "eu-west-2", "data-uk"},
- } {
+ publish := func(box, placement, aws, bucket string, shared bool) {
+ t.Helper()
body, _ := json.Marshal(map[string]any{
- "v": 1, "box": b.box, "box_id": b.box, "eip": "1.2.3.4", "region": b.aws, "placement": b.placement,
- "data_bucket": b.bucket, "hibernation_configured": true, "serves_shared_pool": true,
+ "v": 1, "box": box, "box_id": box, "eip": "1.2.3.4", "region": aws, "placement": placement,
+ "data_bucket": bucket, "hibernation_configured": true, "serves_shared_pool": shared,
"accepts_inbound": true, "secrets_key_fp": fp,
"capabilities": caps, "hosts": map[string]any{},
})
- if _, err := rel.Put(ctx, "control/edges/"+b.box+".json", body, ""); err != nil {
+ if _, err := rel.Put(ctx, "control/edges/"+box+".json", body, ""); err != nil {
t.Fatal(err)
}
- if err := status.WriteBox(ctx, rel, status.Box{Label: b.box, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil {
+ if err := status.WriteBox(ctx, rel, status.Box{Label: box, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil {
t.Fatal(err)
}
}
+ publish("ie-box", "ie", "eu-west-1", "data-ie", true)
+ publish("uk-box", "uk", "eu-west-2", "data-uk", true)
run := func(c context.Context, args ...string) (int, string) {
var out bytes.Buffer
@@ -158,7 +161,7 @@ func newOfflineE2E(t *testing.T, caps []string) *offlineE2E {
}
}
- return &offlineE2E{host: host, rel: rel, run: run, put: put, srv: srv}
+ return &offlineE2E{host: host, rel: rel, run: run, put: put, srv: srv, publish: publish}
}
// TestMoveOfflineAgainstTheRealDoors drives `carlos move offline start` and
@@ -383,3 +386,100 @@ func TestMoveOfflineNamesRegionsThroughTheRealDoors(t *testing.T) {
cancel()
<-done
}
+
+// TestMoveOfflineFlipStepsOverAPoolBox (amadan #413, Astra round 1 finding
+// 2): uk also holds uk-a-pool, a box that serves only a named pool, and its
+// target report says it failed (it never gets the row). Through moveMain
+// against the real console, flip follows the landing past that report to
+// next == open and exits 0, and status says the move is ready to open: the
+// console returns only the reports of targets that can hold the row, so the
+// CLI, old or new, never reads the pool box's. The sealer, the source and
+// the target are played by their reports, and the target's landed
+// transition is written while flip polls.
+func TestMoveOfflineFlipStepsOverAPoolBox(t *testing.T) {
+ e := newOfflineE2E(t, []string{"region-ha-1", "offline-move-1"})
+ e.publish("uk-a-pool", "uk", "eu-west-2", "data-uk", false)
+ host, rel, ctx := e.host, e.rel, context.Background()
+ const id = "mv_abcdefghijklmnopqrstuvwxyz"
+ move := func(mut func(*provision.Record) error) {
+ t.Helper()
+ if _, err := provision.SetRecordMove(ctx, rel, release.OpsAccount, "shop", host, mut); err != nil {
+ t.Fatal(err)
+ }
+ }
+ sealed := map[string]moves.Check{}
+ for _, it := range moves.OfflineSourced() {
+ sealed[it.ID] = moves.Check{OK: true, Reason: "ok"}
+ }
+ landed := map[string]moves.Check{}
+ for _, it := range moves.OfflineOwned(moves.OfflineOwnerLanding) {
+ landed[it.ID] = moves.Check{OK: true, Reason: "ok"}
+ }
+ move(provision.OfflineStart(id, "ie", "uk", "paul@keymail.dev", time.Now()))
+ move(provision.OfflineSeal(id, "ie-box", []string{"ie-box"}))
+ seal, err := json.Marshal(moves.OfflineReport{V: moves.OfflineReportVersion, Op: id, Host: host, Box: "ie-box", Role: moves.OfflineRoleSealer,
+ Phase: moves.OfflinePhaseSealed, At: time.Now().UTC(), Items: sealed, FinalTXID: 7, TombstoneOwner: moves.TombstoneOwner(id)})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := rel.Put(ctx, moves.OfflineSealKey(host, id), seal, ""); err != nil {
+ t.Fatal(err)
+ }
+ move(provision.OfflineSealedBy(id, "ie-box", provision.MoveSource{FinalTXID: 7, Evidence: moves.OfflineSealEvidence(host, id, seal)}))
+ e.put(id, "ie-box", moves.OfflineRoleSource, moves.OfflinePhaseStopped, nil)
+ e.put(id, "ie-box", moves.OfflineRoleSealer, moves.OfflinePhaseSealed, func(r *moves.OfflineReport) {
+ r.Items, r.TombstoneOwner, r.TombstoneUntil = sealed, moves.TombstoneOwner(id), time.Now().Add(moves.TombstoneTTL)
+ })
+ e.put(id, "uk-box", moves.OfflineRoleTarget, moves.OfflinePhaseLanded, func(r *moves.OfflineReport) { r.Items = landed })
+ e.put(id, "uk-a-pool", moves.OfflineRoleTarget, moves.OfflinePhaseFailed, 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"}
+ }
+ })
+
+ fctx, cancel := context.WithTimeout(ctx, 30*time.Second)
+ defer cancel()
+ type result struct {
+ code int
+ out string
+ }
+ flipped := make(chan result, 1)
+ go func() {
+ code, out := e.run(fctx, "flip")
+ flipped <- result{code, out}
+ }()
+ // flip polls the landing; a few polls later the target says landed.
+ for deadline := time.Now().Add(20 * time.Second); ; time.Sleep(10 * time.Millisecond) {
+ rec, err := provision.GetRecord(ctx, rel, release.OpsAccount, "shop", host)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if rec.Move != nil && rec.Move.State == provision.OfflineLanding {
+ break
+ }
+ if time.Now().After(deadline) {
+ t.Fatal("flip never moved the record")
+ }
+ }
+ time.Sleep(100 * time.Millisecond)
+ move(provision.OfflineLandedBy(id, "uk"))
+ ready := "uk holds everything " + host + " needs. Nothing is served yet. Run carlos move offline open --host " + host + " to serve it from uk."
+ select {
+ case r := <-flipped:
+ if r.code != 0 {
+ t.Fatalf("flip exit %d:\n%s", r.code, r.out)
+ }
+ wantLines(t, r.out, ready)
+ wantNoLine(t, r.out, "could not take")
+ case <-time.After(25 * time.Second):
+ t.Fatal("flip never finished")
+ }
+ code, out := e.run(ctx, "status")
+ if code != 0 {
+ t.Fatalf("status exit %d:\n%s", code, out)
+ }
+ wantLines(t, out, ready)
+ wantNoLine(t, out, "could not take", "uk-a-pool")
+}