carlos / platform Public

offline move: wait only on targets that can hold the row (#413)

An offline move's open, finish, items, failed flag and status view now
count target reports only from boxes that hibernate and serve the shared
pool in the target region (offlineMoveEvidence), so a named-pool box
beside the target no longer hangs flip; a box outside the record's pools
never takes the target role; a region with no eligible box is refused at
stage (MV-O194). Paul's cut (#1005): the runbook forbids changing a
target box's CARLOS_POOLS mid-move. Astra R1 NOT READY, R2 READY AFTER
FIXES, merge check READY; census approved.

Squashed from offline-move-pool-target-413 into main.
claude agent, operated by paul@keymail.dev d6c6f3f223e71e50b213885d20c0d27065acc0ba parent 0ac7576
23 files changed, +633 −22
  • approved_moves_copy_test.go +1 −0
  • docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md +19 −0
  • docs/superpowers/plans/2026-10-06-moves-phase1-copy.md +6 −0
  • docs/superpowers/plans/2026-10-21-offline-move-runbook.md +1 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md +26 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md +19 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md +47 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md +30 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md +7 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md +11 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md +27 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md +23 −0
  • internal/console/apiinstancemove_offline.go +62 −4
  • internal/console/apiinstancemove_offline_stage_test.go +24 −0
  • internal/console/apiinstancemove_offline_test.go +117 −1
  • internal/host/movesoffline.go +11 −1
  • internal/host/movesoffline_e2e_test.go +37 −6
  • internal/host/movesoffline_land_test.go +4 −0
  • internal/host/movesoffline_test.go +38 −1
  • internal/host/movespass.go +8 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv +5 −0
  • offline_move_e2e_test.go +109 −9

CI passed — run details

diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go
index ce7f73f23..f4ec99c03 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",
// #339: refused while the instance still serves, and status after an
// abort from staging.
"MV-O200", "MV-O202", "MV-O203", "MV-O204",
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
new file mode 100644
index 000000000..916510b6b
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md
@@ -0,0 +1,19 @@
+# Census approval: offline-move-pool-target-413
+
+Ruling `census-ruling-offline-move-pool-target-413`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `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`.
+
+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.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/movespass.go` `armOffline`: legacy, task accepted-legacy. Basis: 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
+
+Seal: `87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16` → `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
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 cc00bfbd7..04f149ae5 100644
--- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
+++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
@@ -719,6 +719,12 @@ Three more console door refusals for a staged move (`internal/console/apiinstanc
| 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. Approved by Luna 2026-11-13 under Paul's delegation.
+
+| 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 | approved |
+
## Offline move: refused while the instance still serves (#339)
MV-O200, MV-O203 and MV-O204 approved by Luna on 2026-11-13 (Paul's 2026-10-25 delegation), as Luna rewrote them; MV-O202 approved by Luna unchanged.
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 7a1dbc704..c462692ef 100644
--- a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
+++ b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
@@ -108,6 +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, 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`. Do not change the target box's `CARLOS_POOLS` while a move holds it: a target that stops serving the shared pool skips its own revert, so an abort would leave its landed files unparked. If it has changed, set it back and restart the edge before you abort (amadan #413);
- `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/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md
new file mode 100644
index 000000000..b803ec571
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md
@@ -0,0 +1,26 @@
+Round 2’s P2: **resolved** for a target that landed and then changed pools. The broader rollback dispatch exposes one storage-safety defect.
+
+**P1 — A report without a held row authorizes parking on a non-participant.**
+
+**Invariant:** rollback may move only files belonging to this box’s participation in the move.
+
+The changed dispatch at [movesoffline.go:424](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:424) now reaches every capable destination box during abort. However, [offlineTargetRevert:245](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_land.go:245) accepts **any** prior target report when the row is absent.
+
+A concrete scenario:
+
+- An older named-pool box reports “no row yet” without ever holding the instance. This is the legacy behaviour explicitly modelled at [apiinstancemove_offline_test.go:1030](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline_test.go:1030).
+- Upgrade that box and abort the move.
+- Its report passes validation, so rollback renames any existing `H`, `H.env` and `H.config.env` paths despite having landed nothing. A locally registered host named `H.env` passes hostname validation; its flat files directory would also be renamed. Only the row for `H` is checked.
+
+Ordinary similarly named hosts remain untouched, and row/timer deletion requires the exact host and move. Nevertheless, report-only parking violates the requested non-participant guarantee. Repeated passes leave absent paths alone, but will park paths recreated later; they are not unconditionally harmless.
+
+**Fix:** require the move’s held row before parking. Since parking already precedes row deletion, retries after deletion can complete reporting without parking again. Add coverage for a legacy no-row report, neighbouring instance files, and repeated abort passes.
+
+| Census unit or envelope | Verdict | Evidence |
+|---|---|---|
+| `movespass.go:armOffline` | **APPROVED** | Lines 367–421 retain the existing environment parser and registry hooks; no new read. |
+| `internal/host` envelope | **REFUSED** | `offlineRound` lines 424–449 broadens access to the unsafe report-only parking path at `offlineTargetRevert` lines 238–255. |
+
+Reviewed `e2e54f66` against its parent at HEAD `c71866a8`, within round 2’s existing budget. MV-O194 is marked approved. `git diff --check` passed. Targeted tests could not start because the read-only sandbox blocked Go’s work directory; `GOCACHE` was unset. No files changed.
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md
new file mode 100644
index 000000000..ab3fe5a03
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md
@@ -0,0 +1,19 @@
+No P1 or P2 findings in the requested scope at `128c09e356ae5f5d066aec7f524ef7f95df8e351`. This check stays within round 2’s existing budget.
+
+- **Revert verified:** `e18f4f3c` restores the entire `internal/host` tree, including tests, exactly to the state before `e2e54f66`. Differences from `d024c46d` are confined to merged #339 changes.
+- **Accepted limitation documented:** changing the target’s pools can suppress rollback cleanup. The [runbook](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/docs/superpowers/plans/2026-10-21-offline-move-runbook.md:111) prohibits that change and requires restoring the pools and restarting the edge before aborting.
+- **Merge semantics preserved:** `offlineBoxFacts` and `offlineMoveEvidence` both select targets through `boxesAt(to)`. A named-pool-only box’s stale link does not trigger #339’s refusal. `reportStatus()` covers every box, including the pool box; both E2E cases remain.
+- **Copy records preserved:** MV-O194, MV-O200, MV-O202, MV-O203 and MV-O204 each appear once in the ID list and have approved deck rows.
+
+| Census unit or envelope | Verdict | Evidence |
+|---|---|---|
+| `internal/host/movespass.go:armOffline` | **APPROVED** | [Lines 367–421](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movespass.go:367): existing pool parser; unchanged read sites and hooks. Source digest matches the overlay. |
+| `internal/host` envelope | **APPROVED** | [Dispatch and eligibility, lines 416–460](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:416): restored pool gate removes the broadened rollback dispatch. Static recomputation matches the 482-file envelope. |
+
+The chain retains main’s overlays before #413. All 212 overlay fingerprints and seals verify, ending at `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182`.
+
+**P3 follow-up — approval wording:** the [deck introduction](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md:722) still says “Pending until reviewed,” although MV-O194 is approved. Remove that stale sentence to keep the approval record consistent. No further review round is needed.
+
+`git diff --check` passed. Targeted Go tests could not start: the read-only sandbox blocked work-directory creation, with `GOCACHE` unset. No files changed. Actual HEAD is `313d9083`; its only addition beyond the reviewed commit is this review’s brief.
+
+**READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md
new file mode 100644
index 000000000..e43485a41
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md
@@ -0,0 +1,47 @@
+**NOT READY — round 1 of 3.** Reviewed `4c641678..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`. Current HEAD adds only the review brief.
+
+1. **P1 — Older record writers erase the target pin during a mixed-version rollout.**
+
+ The new [`MoveState.TargetBox`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/provision.go:1342) is absent from the base commit’s struct. Older writers decode into that struct and marshal the entire record again through [`updateRecordSeeding`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/provision.go:1175), silently removing `target_box`.
+
+ **Scenario:** a new console starts a pinned move while the sealer still runs the previous release. Its [`OfflineSealedBy` write](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_seal.go:951) removes the pin. An older target likewise removes it when recording landed. The console then [falls back to every target report](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:222); an old named-pool box’s extra report reproduces the original open hang while the instance is offline. An older console performing a transition has the same preservation problem.
+
+ **Fix:** gate pinned starts on a capability proving participating writers preserve the field, with an explicit console rollout/rollback constraint. Add compatibility coverage using the previous record representation through both seal and landing writes. The new same-version JSON round-trip test cannot detect this.
+
+ **Invariant / fault family:** the selected target must survive every record rewrite throughout the move.
+
+2. **P2 — The CLI still treats an unpinned target’s failed report as authoritative.**
+
+ [`offlineViewOf`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:1427) returns all reports, although its items and failed flag now exclude other targets. The CLI’s [`failedReport` and `failure`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/move.go:1208) still scan all target reports independently.
+
+ **Scenario:** use the failed pool-box report already constructed by `TestOfflineWaitsOnlyForThePinnedTarget`. The API returns `Failed=false`, successful landing items and `Next=open`; the CLI nevertheless prints abort advice and returns exit 4. [`runFlip`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/move.go:1713) checks that failure before accepting `Next=open`. The runbook script consequently aborts an otherwise successful landing.
+
+ **Fix:** filter irrelevant target reports from the operational API view, or expose the pin and apply it consistently in CLI failure and served checks. Cover the existing fixture through CLI polling and status. Server-side filtering also protects older CLIs.
+
+ **Invariant / fault family:** every operator-facing decision must use the same target evidence.
+
+3. **P3 — Follow-up: target eligibility still ignores `CARLOS_INBOUND=none`.**
+
+ This is a **pre-existing admission gap**, retained by the new pin. [`offlineCanHold`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:359) checks hibernation and shared-pool membership, but [`mintHeld`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/reconcile.go:2775) refuses a no-inbound box.
+
+ **Scenario:** the only advertised target hibernates and serves the shared pool but declares no inbound work. Start accepts and pins it; landing waits indefinitely for a row reconcile refuses to create.
+
+ **Fix:** follow up with a target-specific admission check using published inbound eligibility; preserve conservative source-holder checks.
+
+ **Invariant / fault family:** an admitted target must be able to acquire the required row.
+
+**Census verdicts — source review**
+
+| Changed unit or envelope | Verdict | Evidence |
+|---|---|---|
+| `internal/host/movespass.go:armOffline` | **APPROVED** | Lines 367–421: the added pool configuration uses the existing parser; existing registry and release hooks remain unchanged. No new root read or path authority. |
+| `internal/host` envelope | **APPROVED** | `offlineRound`, `offlineTargetHere`, `armOffline`, and `moveCfg`: target dispatch gains restrictive pool and identity checks. Existing landing, hold, and release validations remain intact. |
+| `internal/provision` envelope | **APPROVED** | `OfflineTargeted` rejects empty targets and invalid resulting states; `TargetBox` adds data without introducing filesystem access or weakening root validation. The P1 above concerns preservation across versions. |
+
+These census approvals do not resolve the functional findings.
+
+The remaining checks support the intended behavior: staged start selects the currently eligible box and rechecks staging coordinates; loss of the pinned target before open permits abort without its acknowledgement. After-open recovery remains outside the merged design’s scope. MV-O194 matches the implemented zero-candidate refusal, but its copy row remains **pending**.
+
+The added E2E models the dev pool-box hang through real reconcile and move passes. It does not exercise older writers or the CLI, explaining the two missed cases.
+
+`git diff --check` passed. Targeted tests could not start because the sandbox refused Go’s work-directory creation; `GOCACHE` was unset. Network restrictions prevented reading discussion #413 or recording census verdicts on #280. No files were changed.
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md
new file mode 100644
index 000000000..22c3ac004
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md
@@ -0,0 +1,30 @@
+Round-1 P1 — **resolved**: the target pin is removed; production record code matches the base, so older writers cannot erase required targeting state.
+
+Round-1 P2 — **resolved**: `offlineMoveEvidence` filters target reports before both door decisions and API output. Older CLIs receive the same filtered evidence; the new CLI regression test covers flip and status.
+
+1. **P2 — Pool eligibility now suppresses rollback cleanup for an existing participant.**
+
+ **Invariant:** losing eligibility for a new landing must not cancel cleanup of data already landed.
+
+ The new condition at [movesoffline.go:424](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:424) gates every target step, including `OfflineReverting`.
+
+ **Scenario:** the target lands files, then restarts with `CARLOS_POOLS=cohort1`. The operator aborts. `offlineTargetHere` now returns false, so the worker never reaches [offlineTargetRevert](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_land.go:231), which parks the files, env and config and deletes the held row and timers. Reconcile retains the participant while the move exists. Abort can subsequently finish without target acknowledgement, clearing the move while its extracted files remain unparked.
+
+ **Fix:** apply pool admission to landing, while allowing reverting participants through the existing held-row/report ownership checks. Extend the rollback test to land, change pools, restart, abort and tick through production dispatch; assert files are parked and the row and timers removed.
+
+| Census unit or envelope | Verdict | Evidence |
+|---|---|---|
+| `internal/host/movespass.go:armOffline` | **APPROVED** | Lines 367–421: the added environment value uses reconcile’s existing pool parser. Registry, release and filesystem hooks remain unchanged. |
+| `internal/host` envelope | **APPROVED** | `offlineRound` lines 416–450, `offlineTargetHere` lines 453–460, and `moveCfg.OfflinePools`: no new root read or expanded path authority. The rollback defect above is functional and still needs fixing. |
+
+Other checks:
+
+- New consoles handle old boxes’ extra reports without record changes. An old console still needs upgrading to filter reports left by older boxes.
+- Staged start rechecks current target eligibility and stored bucket coordinates. Missing target evidence prevents open; abort remains available before open.
+- Pool parsing matches reconcile. The previously reported `CARLOS_INBOUND=none` admission gap remains a P3 follow-up.
+- The host E2E models the dev named-pool hang; console and CLI tests cover legacy extra reports. None covers eligibility changing before rollback.
+- MV-O194 matches the zero-eligible-target refusal. Its copy approval remains marked **pending**.
+
+Reviewed `4c641678..79afb1d91ab289d342fd8a5d9db2785fd87c000a`; HEAD adds only the brief. `git diff --check` passed. Targeted tests could not start: the read-only sandbox rejected Go’s work-directory creation, with `GOCACHE` unset. Network restrictions blocked discussion #413; census verdicts were not posted to #280. No files changed.
+
+**READY AFTER FIXES.** No P1 remains: stop review rounds here, apply the P2 fix, and perform the required census and changed-production-storage checks within this round’s budget.
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md
new file mode 100644
index 000000000..290e9d6f5
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md
@@ -0,0 +1,7 @@
+# Review brief: #413 round 2 P2 fix, census and storage check (same round budget)
+
+Repo carlos/platform, branch `offline-move-pool-target-413`. Under review: only the fix for round 2's P2 (`docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md`), commit e2e54f66 against its parent, plus MV-O194 marked approved (Luna, 2026-11-13).
+
+Not a new round (stopping rule 1). Check only: (1) census per changed unit; (2) the revert path's production-storage and termination behaviour: every destination-region box now runs the revert step during an abort, relying on the revert's own checks to skip non-participants. Can a non-participant box (never held the row) ever park, delete or touch anything for this host, including a pool box that serves another instance with a similar name? Is the revert idempotent across boxes? (3) one line: round 2's P2 resolved, partly, or not.
+
+Severity as before. End with READY, READY AFTER FIXES or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset).
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md
new file mode 100644
index 000000000..3bd0dd4c2
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md
@@ -0,0 +1,11 @@
+# Review brief: #413 after Paul's cut and the main merge (census and merge check, same budget)
+
+Repo carlos/platform, branch `offline-move-pool-target-413`, commit 128c09e356ae5f5d066aec7f524ef7f95df8e351.
+Paul's ruling (#1005): take the cut. e18f4f3c reverts e2e54f66 (back to round 2's code), e89c968e adds the runbook rule "do not change a target box's CARLOS_POOLS while a move holds it". a5815113 merges main (which gained #339, 94a6471e: stale live-link refusals at stage/start and status-report facts), 128c09e3 re-freezes the census.
+
+Not a new review round. Check only:
+1. The revert is exact: internal/host code equals round 2's reviewed state (d024c46d's tree for internal/host apart from the merge) and the round-2 P2 (target that changed pools skips revert) is now the documented limitation, nothing else.
+2. The merge's semantics: #339's refusal check and #413's evidence filter together (does #339 consult target facts from non-eligible boxes, or refuse because of a pool box's stale link?); the E2E's shared `reportStatus()` now covering every box; copy IDs and deck.
+3. **Census:** the re-frozen overlay `plan14-root-reads-offline-move-pool-target-413.tsv` and the chain order: APPROVED or REFUSED per changed unit.
+
+End with READY, READY AFTER FIXES or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset).
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md
new file mode 100644
index 000000000..7b2a062c3
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md
@@ -0,0 +1,27 @@
+# Review brief: offline move waits only on its pinned target (#413), branch, round 2 of 3
+
+Repo carlos/platform, branch `offline-move-pool-target-413`, commit 79afb1d91ab289d342fd8a5d9db2785fd87c000a.
+Under review: the diff `4c6416787a42ce5da5964588de721817d25fc15d..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`.
+Authorities, merged on main: `docs/superpowers/plans/2026-10-20-offline-operator-move.md`, the offline-move runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md`, AGENTS.md (stopping rules, census). Report: `amadan discuss show carlos/platform 413`. Do not review against unmerged branches (offline-move-stage-refusals-339 is separate).
+
+## The change (rev 2)
+Round 1 (`CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md`) found the record pin lost on rewrite by older writers (P1) and the CLI scanning every target report (P2). Rev 2 removes the pin entirely (provision code back to main). One console helper, `offlineMoveEvidence`, keeps a target report only if its box hibernates and serves the shared pool in the target region, from the same edges facts the start door uses; every door and the operational status view read through it, so any CLI sees only eligible targets. Unreadable edges files: no target report counts and open refuses. Box-side pool check and MV-O194 kept.
+
+## What to check
+1. Record compatibility: an additive field on the move record; older consoles and boxes reading or CAS-writing a record that carries it (do they drop it on rewrite, and does that reintroduce the hang or worse?); a mixed-version rollout (console new, boxes old, and the reverse).
+2. Can pinning ever make a move wait forever or land on the wrong box: pinned box replaced, renamed or lost mid-move; abort paths; a staged move whose eligible box changes between stage and start.
+3. The box-side pool check: same rule reconcile uses to give a row to a box (CARLOS_POOLS, shared pool, hibernation)? Any box that can hold the row but is now refused the target role, or the reverse? (The implementer notes CARLOS_INBOUND=none boxes are not excluded.)
+4. Every door and view that counted target reports now consistent (open, finish, status items, failed flag, seal, abort).
+5. Tests: would each fail without its guard? The E2E reproduces the dev hang?
+6. **Census:** `docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md` and overlay: APPROVED or REFUSED per changed unit (you are the census reviewer).
+7. MV-O194 accurate to the behaviour.
+
+## Round 2
+
+First one line per round-1 P1 and P2: resolved, partly, or not. Then new findings, naming the invariant beside each. Re-check census per changed unit (the overlay now re-pins only internal/host).
+
+## Severity
+P1 blocks; P2 fixed without another round; P3 follow-up. P1s state failure scenario and evidence.
+
+## Output
+Findings ranked with evidence, scenario, fix and invariant; a Census verdict table; exactly one verdict: READY, READY AFTER FIXES, or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset).
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md
new file mode 100644
index 000000000..93a9e64aa
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md
@@ -0,0 +1,23 @@
+# Review brief: offline move waits only on its pinned target (#413), branch, round 1 of 3
+
+Repo carlos/platform, branch `offline-move-pool-target-413`, commit 4ecf608d9a20b130327a8dc3c61d2b5e8792f16c.
+Under review: the diff `4c6416787a42ce5da5964588de721817d25fc15d..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`.
+Authorities, merged on main: `docs/superpowers/plans/2026-10-20-offline-operator-move.md`, the offline-move runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md`, AGENTS.md (stopping rules, census). Report: `amadan discuss show carlos/platform 413`. Do not review against unmerged branches (offline-move-stage-refusals-339 is separate).
+
+## The change
+Start (direct or staged) records the one eligible box as `move.target_box` (new `provision.OfflineTargeted`); open, finish, the item list and the failed flag read only that box's report (moves started before the change read all reports, as before); a box takes the target role only if its CARLOS_POOLS admit the record and it is the pinned box or nothing is pinned; a region with no eligible box is refused at stage with its own sentence (MV-O194).
+
+## What to check
+1. Record compatibility: an additive field on the move record; older consoles and boxes reading or CAS-writing a record that carries it (do they drop it on rewrite, and does that reintroduce the hang or worse?); a mixed-version rollout (console new, boxes old, and the reverse).
+2. Can pinning ever make a move wait forever or land on the wrong box: pinned box replaced, renamed or lost mid-move; abort paths; a staged move whose eligible box changes between stage and start.
+3. The box-side pool check: same rule reconcile uses to give a row to a box (CARLOS_POOLS, shared pool, hibernation)? Any box that can hold the row but is now refused the target role, or the reverse? (The implementer notes CARLOS_INBOUND=none boxes are not excluded.)
+4. Every door and view that counted target reports now consistent (open, finish, status items, failed flag, seal, abort).
+5. Tests: would each fail without its guard? The E2E reproduces the dev hang?
+6. **Census:** `docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md` and overlay: APPROVED or REFUSED per changed unit (you are the census reviewer).
+7. MV-O194 accurate to the behaviour.
+
+## Severity
+P1 blocks; P2 fixed without another round; P3 follow-up. P1s state failure scenario and evidence.
+
+## Output
+Findings ranked with evidence, scenario, fix and invariant; a Census verdict table; exactly one verdict: READY, READY AFTER FIXES, or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset).
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index 46db68bfb..fc2a82c57 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) {
@@ -280,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
@@ -377,8 +424,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 +448,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))}
}
@@ -1121,6 +1173,9 @@ 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 {
+ if ev.targetsUnread {
+ return offlineFleetUnread
+ }
tgt := ev.byRole(moves.OfflineRoleTarget)
if len(tgt) != 1 {
return offlineStateRefusal(mv.State, host)
@@ -1160,6 +1215,9 @@ 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 != "" {
+ if ev.targetsUnread {
+ return offlineFleetUnread
+ }
tgt := ev.byRole(moves.OfflineRoleTarget)
if len(tgt) != 1 || tgt[0].Phase != targetPhase {
return refuse
@@ -1223,7 +1281,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")
@@ -1395,7 +1453,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"
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go
index 9f1445389..b6217a446 100644
--- a/internal/console/apiinstancemove_offline_stage_test.go
+++ b/internal/console/apiinstancemove_offline_stage_test.go
@@ -154,6 +154,30 @@ 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 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())
+ 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)
+}
+
// 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 c1fcfb622..6f8d15261 100644
--- a/internal/console/apiinstancemove_offline_test.go
+++ b/internal/console/apiinstancemove_offline_test.go
@@ -440,6 +440,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"
}
@@ -582,7 +593,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")},
@@ -1013,6 +1032,103 @@ 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. 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()
+ // 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")
+ // 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)
+ }
+ 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)
+ }
+ 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) })
+ w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseParked, nil)
+ 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 0859e78b7..28e01b56d 100644
--- a/internal/host/movesoffline.go
+++ b/internal/host/movesoffline.go
@@ -421,7 +421,7 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro
}
here := cfg.parkRegion()
source := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.From, here)
- target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here)
+ target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) && cfg.offlineTargetHere(rec)
sealer := cfg.Box != "" && cfg.Box == m.Sealer
if !cfg.OfflineCapable {
if source || target || sealer {
@@ -450,6 +450,16 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro
return errors.Join(errs...)
}
+// offlineTargetHere says whether this box, in the region the move goes to,
+// 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 {
+ return c.OfflinePools.Serves(rec.Pool)
+}
+
// offlineReassertEvery is how often a box that takes part in an offline move
// rewrites the reports a door judges by age (harness Run 9, finding 7). The
// doors believe a report for two minutes (offlineReportFresh, internal/
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go
index 9c9a1a831..6491aaf69 100644
--- a/internal/host/movesoffline_e2e_test.go
+++ b/internal/host/movesoffline_e2e_test.go
@@ -214,6 +214,18 @@ type e2eWorld struct {
srcFiles, srcEnv, cfg string
srcTimers map[string]registry.Timer
rows int
+ // pool is uk-pool when the world has one (landOpts.poolBox): a box in
+ // uk that serves only cohort1, ticked beside the others.
+ pool *offBox
+}
+
+// boxes are the world's boxes in the order they tick.
+func (w *e2eWorld) boxes() []*offBox {
+ out := []*offBox{w.ie, w.uk}
+ if w.pool != nil {
+ out = append(out, w.pool)
+ }
+ return out
}
func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld {
@@ -342,6 +354,10 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld {
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}
+ if opts.poolBox {
+ w.pool = sw.box("uk-pool", "uk", map[string]string{"CARLOS_HIBERNATE_BUCKET": sealUK, "CARLOS_SECRETS_KEY": keyB64,
+ "CARLOS_HIBERNATE_REGION": sealUKRegion, "CARLOS_RELEASE_PUBKEY": pubB64, "CARLOS_POOLS": "cohort1"})
+ }
// The source box's production build-state carry, and each box's launch
// composer under its own agent environment.
@@ -395,6 +411,8 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld {
// probe (offlineMoveFactsProbe, #339), with the box's worker armed for the
// call, under the box's name. The loop's assignment is checked first
// (requireStatusLoopReportsOfflineFacts), so the snapshots are the loop's.
+// Every box reports, the pool box among them (#413), since the console's
+// fleet read sees all of them.
func (w *e2eWorld) reportStatus() {
w.t.Helper()
requireStatusLoopReportsOfflineFacts(w.t)
@@ -403,7 +421,7 @@ func (w *e2eWorld) reportStatus() {
}
prev := armedMovesWorker.Load()
defer armedMovesWorker.Store(prev)
- for _, b := range []*offBox{w.ie, w.uk} {
+ for _, b := range w.boxes() {
routes, err := b.reg.List()
if err != nil {
w.t.Fatal(err)
@@ -511,8 +529,9 @@ func (w *e2eWorld) setBoxClock(at time.Time) {
func (w *e2eWorld) tickAll() {
w.t.Helper()
- w.tick(w.ie)
- w.tick(w.uk)
+ for _, b := range w.boxes() {
+ w.tick(b)
+ }
}
// door posts to one of the doors (verb "" is start).
@@ -1172,6 +1191,10 @@ func TestOfflineMoveE2E(t *testing.T) {
// minutes of belief in a report.
t.Run("doors back to back", func(t *testing.T) { offlineMoveDoorsApart(t, 0) })
t.Run("doors three minutes apart", func(t *testing.T) { offlineMoveDoorsApart(t, 3*time.Minute) })
+ // amadan #413, seen on dev 2026-10-26: uk also holds a box that serves
+ // only a named pool. Reconcile never gives it the row, so it must not
+ // report as the target, and no step may wait on it.
+ t.Run("a pool box beside the target", func(t *testing.T) { offlineMoveDone(t, landOpts{poolBox: true}) })
// #339: a stale live link that failed a move only after the instance
// was offline is refused by stage and start, from the target box's own
// status report.
@@ -1245,7 +1268,7 @@ type e2eLoops struct {
func (w *e2eWorld) loops() *e2eLoops {
l := &e2eLoops{w: w, fast: map[*offBox]*fastDeps{}, tickAt: time.Now()}
- for _, b := range []*offBox{w.ie, w.uk} {
+ for _, b := range w.boxes() {
// The sweep's registry is empty: the sweep stages releases and is
// not what this test is about. The serial leg is.
l.fast[b] = &fastDeps{reg: restartTestRegistry(w.t), store: w.rs, fullPass: func(context.Context) {
@@ -1261,7 +1284,7 @@ func (w *e2eWorld) loops() *e2eLoops {
func (l *e2eLoops) round() bool {
before := l.passes
l.tickAt = l.tickAt.Add(fastFullClamp + time.Second)
- for _, b := range []*offBox{l.w.ie, l.w.uk} {
+ for _, b := range l.w.boxes() {
fastTick(context.Background(), l.fast[b], l.tickAt)
}
return l.passes > before
@@ -1295,7 +1318,7 @@ func (l *e2eLoops) after(gap time.Duration) {
func (l *e2eLoops) reassert(at time.Time) {
l.w.setBoxClock(at)
- for _, b := range []*offBox{l.w.ie, l.w.uk} {
+ for _, b := range l.w.boxes() {
b.w.offlineReassert(context.Background(), l.w.rs)
}
l.again++
@@ -1420,6 +1443,14 @@ func offlineMoveDone(t *testing.T, opts landOpts) {
if r := w.wd.reportFor(w.id, moves.OfflineRoleTarget, "uk-box"); !r.Items["env-pin"].OK {
t.Fatalf("env-pin across the two agent environments: %+v", r.Items["env-pin"])
}
+ if w.pool != nil {
+ if rt := w.pool.row(offHost); rt != nil {
+ t.Fatalf("uk-pool holds a row for the host: %+v", rt)
+ }
+ if _, _, err := w.wd.s.Get(ctx, moves.OfflineReportKey(offHost, w.id, moves.OfflineRoleTarget, "uk-pool")); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("uk-pool reported as a target: %v", err)
+ }
+ }
w.requireStopped("after the landing")
w.open()
if opts.lifetime {
diff --git a/internal/host/movesoffline_land_test.go b/internal/host/movesoffline_land_test.go
index 3954d3c2e..615d1a324 100644
--- a/internal/host/movesoffline_land_test.go
+++ b/internal/host/movesoffline_land_test.go
@@ -93,6 +93,10 @@ type landOpts struct {
// incarnation creates the record at that incarnation with no slot, as
// a claims-on box (no judge) sees one; only without judged or lifetime.
incarnation uint64
+ // poolBox adds uk-pool beside uk-box in uk, a capable box that serves
+ // only the named pool cohort1 (CARLOS_POOLS=cohort1), as leo did on dev
+ // (amadan #413). Only the end-to-end world reads it.
+ poolBox bool
}
// landWorld is offHost at home (ie-a, data-ie) moving to uk (uk-box,
diff --git a/internal/host/movesoffline_test.go b/internal/host/movesoffline_test.go
index 73d84ec62..19ba781bf 100644
--- a/internal/host/movesoffline_test.go
+++ b/internal/host/movesoffline_test.go
@@ -215,7 +215,7 @@ func (b *offBox) restart() {
func (b *offBox) reconcile() {
b.wd.t.Helper()
- cfg := provision.ReconcileConfig{Region: b.region, DataDir: b.dd, Judge: b.wd.judge}
+ cfg := provision.ReconcileConfig{Region: b.region, Pools: provision.ParseBoxPools(b.getenv("CARLOS_POOLS")), DataDir: b.dd, Judge: b.wd.judge}
if b.nested {
cfg.Layout = func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil }
} else {
@@ -285,6 +285,43 @@ func writeFile(t *testing.T, p, body string) {
// --- the hold ---------------------------------------------------------------
+// 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":
+ return pools
+ case "CARLOS_HIBERNATE_BUCKET":
+ return "data-uk"
+ }
+ return ""
+ })
+ return cfg
+ }
+ 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
+ want bool
+ }{
+ {"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(rec); got != c.want {
+ t.Fatalf("offlineTargetHere = %v, want %v", got, c.want)
+ }
+ })
+ }
+}
+
// offlineHold's table: a pure function of the record and the box's
// placement. The home's "" and a named region; every state.
func TestOfflineHoldIsAFunctionOfTheRecord(t *testing.T) {
diff --git a/internal/host/movespass.go b/internal/host/movespass.go
index c74154783..d4f2fe74b 100644
--- a/internal/host/movespass.go
+++ b/internal/host/movespass.go
@@ -22,6 +22,7 @@ import (
"github.com/carlosframework/platform/internal/cgroup"
"github.com/carlosframework/platform/internal/controlsock"
"github.com/carlosframework/platform/internal/dbverify"
+ "github.com/carlosframework/platform/internal/edgesfile"
"github.com/carlosframework/platform/internal/hostbox"
"github.com/carlosframework/platform/internal/hostclaim"
"github.com/carlosframework/platform/internal/hostguard"
@@ -365,6 +366,7 @@ func armMovesPass(hib activator.Config, dataDir string, reg *registry.Registry,
// for a record with an offline move.
func armOffline(cfg *moveCfg, dataDir string, reg *registry.Registry, svc *activator.Service, eb *activator.ExecBackend, writes hostwrite.Config, getenv func(string) string) {
cfg.OfflineCapable = offlineCapable(getenv, hibernationConfigured(getenv))
+ cfg.OfflinePools = provision.ReconcileConfig{Pools: provision.ParseBoxPools(getenv("CARLOS_POOLS"))}.ServedPools()
cfg.Offline = newOfflineView(*cfg, holdStageRequester(dataDir))
if svc != nil {
cfg.FenceAs = fenceAsWith(svc)
@@ -1009,6 +1011,12 @@ type moveCfg struct {
// keep view reconcile reads (offlineView.keep); the hold needs none.
OfflineCapable bool
Offline *offlineView
+ // OfflinePools are the pools this box serves, from CARLOS_POOLS through
+ // provision.ParseBoxPools, the parse reconcile and the edges file use.
+ // A box whose pools do not admit a record never takes the target role
+ // for it (offlineTargetHere): reconcile never gives it the row. Nil
+ // serves no pool.
+ OfflinePools edgesfile.PoolEvidence
// FenceAs installs, or meets again, an owned activator fence
// (activator.Service.FenceAndStopAs under a 2 s deadline,
// ErrStopUnproven counted as installed: fenceAsWith); LiftFenceAs lifts
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 3487f0b8a..da37016e4 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -211,3 +211,4 @@ plan14-root-reads-g6-fence.tsv 3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1
plan14-root-reads-offline-move-stage-refusals-339.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332
plan14-root-reads-fleet-tunnel-tls-state.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332
plan14-root-reads-replica-console-account.tsv 87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16
+plan14-root-reads-offline-move-pool-target-413.tsv f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182
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
new file mode 100644
index 000000000..9b1ce2106
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv
@@ -0,0 +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, 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 3b9380676b3e427ba4cb36e74310831fe635e65e80b91929c73daa7ef31a54fe
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")
+}