carlos / platform Public

offline move: refuse a stale live link at stage and start (#339)

Each box reports, in its private status report, the hosts it keeps an
/opt/carlos/live link for with no route row (names only, bounded,
skipped under effective UID 0). The offline move stage and start doors
refuse before anything goes offline (MV-O200, MV-O204), the staging
status no longer offers start then, and status after an abort from
staging says nothing moved (MV-O202). Item 4 (app directories) moved to
#1003. Astra R1 NOT READY, fixes check READY AFTER FIXES, census
approved; copy by Luna under Paul's delegation.

Squashed from offline-move-stage-refusals-339 into main.
claude agent, operated by paul@keymail.dev 94a6471e2376c58e225d49fdbe2569f6417d22a2 parent 4c64167
24 files changed, +815 −18
  • approved_moves_copy_test.go +4 −0
  • docs/site/cli.md +2 −0
  • docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md +27 −0
  • docs/superpowers/plans/2026-10-06-moves-phase1-copy.md +13 −0
  • docs/superpowers/plans/2026-10-21-offline-move-runbook.md +6 −4
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-FIXES.md +35 −0
  • docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md +59 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339-FIXES.md +13 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339.md +22 −0
  • internal/console/apiinstancemove_offline.go +12 −1
  • internal/console/apiinstancemove_offline_facts.go +36 −0
  • internal/console/apiinstancemove_offline_stage_test.go +73 −2
  • internal/console/apiinstancemove_offline_test.go +6 −1
  • internal/host/agent.go +6 −0
  • internal/host/movesoffline_e2e_test.go +130 −8
  • internal/host/movesoffline_facts.go +121 −0
  • internal/host/movesoffline_facts_test.go +123 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.tsv +16 −0
  • internal/status/contract_test.go +8 −1
  • internal/status/snapshot.go +39 −1
  • internal/status/snapshot_test.go +23 −0
  • move.go +16 −0
  • move_test.go +24 −0

CI passed — run details

diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go
index af7993a5d..ce7f73f23 100644
--- a/approved_moves_copy_test.go
+++ b/approved_moves_copy_test.go
@@ -110,6 +110,9 @@ 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",
+ // #339: refused while the instance still serves, and status after an
+ // abort from staging.
+ "MV-O200", "MV-O202", "MV-O203", "MV-O204",
}
// copyRow is one row of the record. The File cell is the file the sentence is
@@ -1213,6 +1216,7 @@ var movesScanFiles = []string{
"internal/host/movesrefusals.go",
"internal/console/movesrecovery.go",
"internal/console/apiinstancemove_offline.go",
+ "internal/console/apiinstancemove_offline_facts.go",
"internal/console/claim_runtime.go",
"internal/alerting/alerting.go",
"internal/hostops/move_log_writer.go",
diff --git a/docs/site/cli.md b/docs/site/cli.md
index e72a1fce5..c2042885f 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -3385,6 +3385,8 @@ The instance is offline from `start` until `open`. Until `open`, `abort` puts it
`stage` is optional and comes before `start`. It copies the instance's data to the region it moves to while the instance keeps serving, and each time it runs it copies only what is new. The more it has copied, the less is left to copy while the instance is offline. Until `start`, `abort` removes the staged copy and the instance is never offline.
+`stage` and `start` refuse an offline move when a box in the target region still holds a live link for the instance from an earlier time it ran there, or has more live links than its report can carry. The refusal names the box and says what it found.
+
## On the host
These are what systemd starts. You will rarely type them, but knowing what
diff --git a/docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md b/docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md
new file mode 100644
index 000000000..74b2b994c
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md
@@ -0,0 +1,27 @@
+# Census approval: offline-move-stage-refusals-339
+
+Ruling `census-ruling-offline-move-stage-refusals-339`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/status/snapshot.go` `CollectBox` | body | unchanged (28) | #339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added. |
+| `internal/host/agent.go` `statusLoop` | sites | +whole:Route | #339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added. |
+
+Envelopes re-pinned: `.`, `internal/host`, `internal/status`.
+
+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/status/snapshot.go` `CollectBox`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.
+- `internal/host/agent.go` `statusLoop`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/host/movesoffline_facts.go:movesWorker.offlineMoveFacts`: reads +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/host/movesoffline_facts.go:offlineMoveFactsProbe`: reads +whole:Route; written legacy, accepted-legacy, frozen
+- new `internal/host/movesoffline_facts.go:readNamesBounded`: reads +file:Open, +file:Readdirnames ×2; written legacy, accepted-legacy, frozen
+
+Seal: `3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1442bbe0055d5631` → `846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.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 28adb242c..cc00bfbd7 100644
--- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
+++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md
@@ -718,3 +718,16 @@ Three more console door refusals for a staged move (`internal/console/apiinstanc
| MV-O191 | internal/console/apiinstancemove_offline.go | <to> publishes the same data bucket as <from>. a staged copy there would replace the serving one | approved |
| MV-O192 | internal/console/apiinstancemove_offline.go | <to> now publishes a different data bucket or region from what was recorded when <host> was staged. abort the move and stage it again | approved |
| MV-O193 | internal/console/seedmove.go (haMoveSentence; RHA-P1a-C1 approved verbatim; emitted at apiinstancemove.go:450,631 and apiinstancemove_offline.go:538) | %s has high availability turned on. offline moves into or out of it are not available yet | approved |
+
+## 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.
+
+A live link the target box still kept for the host from an earlier time it ran there failed an offline move only after `start` had taken the instance offline: the landing's `release` item fails at `flip` (MV-O177) over any link that does not name the sealed build (amadan #339, item 1). Each box now reports the hosts it keeps such a link for in its status report while the instance serves, and the `stage` and `start` doors refuse first (branch `offline-move-stage-refusals-339`). The report names the link and not its build, so the doors refuse any such link: MV-O200 states the fact and that policy, not a predicted failure (Astra round 1, P2-6). MV-O204 is the refusal when the box holds more links than its bounded report can carry (Astra round 1, P1-3), so it cannot say whether one is for the host. Both are console door refusals (`internal/console/apiinstancemove_offline_facts.go`), lower case like the other door sentences; `<box>` is the target box. Item 4 (app directories beside the files directory) was cut from this branch after round 1 and is a follow-up, so its row is gone. MV-O202 is what `carlos move offline status` says for a move aborted from staging (item 2), in place of MV-O8 and the manifest's items, until `finish` ends the move: nothing moved. It is followed by MV-O187 or MV-O188. MV-O203 is the CLI page's paragraph for the refusal, in Luna's wording with its directories clause dropped. The ids start at 200 so that another branch's rows from 194 do not collide.
+
+| id | file | text | status |
+|---|---|---|---|
+| MV-O200 | internal/console/apiinstancemove_offline_facts.go | <box> still holds a live link for <host> from when it last ran there. stage and start refuse until it is cleared, since a mismatched link fails the move only after <host> is offline. see the offline move runbook | approved |
+| MV-O202 | move.go | Nothing moved. The stage of <host> was abandoned, and <host> kept serving in <from>. | approved |
+| MV-O203 | docs/site/cli.md | `stage` and `start` refuse an offline move when a box in the target region still holds a live link for the instance from an earlier time it ran there, or has more live links than its report can carry. The refusal names the box and says what it found. | approved |
+| MV-O204 | internal/console/apiinstancemove_offline_facts.go | <box> holds more live links than it can report, so stage and start cannot tell whether one is for <host>. see the offline move runbook | approved |
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 8a8c7705d..7a1dbc704 100644
--- a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
+++ b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md
@@ -8,7 +8,7 @@ Sources: harness `RUNLOG.md` Runs 9 and 10 with corrections M2 to M15; the dev r
## The short version
-1. Check the fleet once (section 2) and the instance and the target box before each move (section 3). The target check is the one that matters most: a stale `/opt/carlos/live/<host>` link on the target makes `flip` fail only after the instance is already offline.
+1. Check the fleet once (section 2) and the instance and the target box before each move (section 3). The target check is the one that matters most: a stale `/opt/carlos/live/<host>` link on the target makes `flip` fail only after the instance is already offline. From the release carrying the #339 fix, `stage` and `start` refuse such a link while the instance still serves; on an older release section 3 is the only check.
2. Run `stage` while the instance serves, and run it again until a round copies almost nothing (section 4).
3. Run `move.sh`. It stages once more, records a baseline, then runs `start`, `seal`, `flip`, a check of the target and `open` back to back, judging each step by its exit code. Before `open`, any surprise aborts the move. Expect about 2.5 to 3 minutes offline for an instance with a 1.6 to 3.7 GB replica (section 5).
4. Measure the offline time yourself, from just before `start` to the first 2xx through the target. The console's figure read 40 to 75 seconds low on the flagship (section 6).
@@ -166,12 +166,14 @@ src "set -- $H; $(cat "$W/sizes.box.sh")"
aws --profile "$PROFILE" s3 ls --recursive --summarize "s3://$SRCDATA/instances/$H/" | tail -2
```
-Pass: the files tree is under 268435456 bytes (256 MiB; over that the seal refuses safely); no sidecar file. Record the database size and the replica's object count and total size: staging time and the size of the target's copy scale with the replica, not the database. A legacy flat `/data/<host>/` directory holding old key copies needs nothing: the seal passes and the retire parks it with the instance.
+Pass: the files tree is under 268435456 bytes (256 MiB; over that the seal refuses safely); no sidecar file; nothing beside the files directory in `/data/.instances/<host>/` but the platform's own entries (an app's `data/`, `documents/` or `blobs/` there makes the seal refuse with exit 4, and the move cannot carry it). Nothing refuses such a directory before `start` yet (a #339 follow-up), so this check is the only one. Record the database size and the replica's object count and total size: staging time and the size of the target's copy scale with the replica, not the database. A legacy flat `/data/<host>/` directory holding old key copies needs nothing: the seal passes and the retire parks it with the instance.
### 3.3 The target box
This check exists because of the first staged move on the flagship. An earlier attempt had left a root-owned link `/opt/carlos/live/<host>` on the UK box, naming a build from weeks before. Nothing reports it before `flip`, and `flip` fails the landing's `release` item only after `start` has taken the instance offline: `flip` exited 4 with "uk could not take shop.example.com: the target box still holds an older build of this instance", the move was aborted, and the instance was offline for about two minutes for nothing (amadan #339).
+From the release carrying the #339 fix, the target box reports every live link it keeps for a host it has no row for, and `stage` and `start` refuse such a host with "<box> still holds a live link for <host> from when it last ran there. stage and start refuse until it is cleared, since a mismatched link fails the move only after <host> is offline. see the offline move runbook" (exit 5), before anything goes offline. The report names the link and not its build, so the doors refuse any such link, even one that names the build the instance runs. A box that holds more live links than its report can carry (more than 128) makes them refuse every host with "<box> holds more live links than it can report, so stage and start cannot tell whether one is for <host>. see the offline move runbook". A box whose agent runs as root reports no links, and the doors then refuse nothing over it. A box reports again within about six minutes, so after clearing a link wait for its next report before staging. The landing's own check stays behind the doors. Run the checks below anyway: they also cover older releases.
+
```bash
tgt "set -- $H; $(cat "$W/target.box.sh")"
src "readlink /opt/carlos/live/$H"
@@ -243,7 +245,7 @@ While a move is staged:
- the instance serves as normal;
- it refuses `carlos run` and deletion;
- no other instance in the deployment can stage or move offline;
-- `abort` removes the staged copy and ends the move with the instance never offline. `abort` and the `finish` after it both exit 3, the normal "aborted" code, with "The staged copy of shop.example.com is removed." and "shop.example.com is back in ie and serving. Nothing was lost." Afterwards `status` prints "Moving shop.example.com from ie to uk. Moving shop.example.com back to ie." and a list of items "waiting". Ignore that; the abort's own lines are the record (#339).
+- `abort` removes the staged copy and ends the move with the instance never offline. `abort` and the `finish` after it both exit 3, the normal "aborted" code, with "The staged copy of shop.example.com is removed." and "shop.example.com is back in ie and serving. Nothing was lost." Between the two, while the move is still reverting, `status` prints "Nothing moved. The stage of shop.example.com was abandoned, and shop.example.com kept serving in ie." and lists no items. After `finish` it says the move is aborted. A CLI older than the #339 fix prints, before `finish`, "Moving shop.example.com from ie to uk. Moving shop.example.com back to ie." and a list of items "waiting" instead; ignore that, the abort's own lines are the record.
---
@@ -456,7 +458,7 @@ A retry is a new move, staged from scratch, after section 3 passes again.
## 12. Known gaps
-- **amadan #339: nothing checks the target before the instance goes offline.** A stale root-owned `/opt/carlos/live/<host>` on the target fails `flip` (exit 4, the `release` item, MV-O177) only after `start`. Section 3.3 is the workaround. The same discussion covers two smaller things: after an abort from staging, `status` reads as if the instance moved and came back; and no output says how many objects the seal copied (section 6 has the count).
+- **amadan #339: stale live links and app directories.** Before the release carrying the fix, a stale root-owned `/opt/carlos/live/<host>` on the target fails `flip` (exit 4, the `release` item, MV-O177) only after `start`; section 3.3 is the workaround. With the fix, `stage` and `start` refuse it before anything goes offline, but there is still no supported way to clear a stale link (root by hand, section 3.3). App directories beside the files directory still fail `seal` (exit 4) only after `start`, and the move cannot carry them, empty ones included; section 3.2 is the only check. No output says how many objects the seal copied (section 6 has the count).
- **amadan #338: an alias row can keep the flat socket after nesting** and answer 502. Check an instance's aliases after the nesting stop (section 9).
- **The source keeps root-owned files.** `/data/programs/<host>.json` (root, 0644, in a root-owned directory) cannot be parked by the agent, which runs as `carlos`; `status` says "left /data/programs/<host>.json in place: cannot be renamed: ... permission denied". The root-owned `/opt/carlos/live/<host>` link stays too, by design. Both are listed for the claim census, and both are the kind of leftover that section 3.3 catches if that box is ever a move target.
- **The console's offline figure ends at `open`** and leaves out the first wake (section 6).
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-FIXES.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-FIXES.md
new file mode 100644
index 000000000..7fe740df6
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-FIXES.md
@@ -0,0 +1,35 @@
+Reviewed `ccd35818..6b580cd6db9e7d4c2bc59e02a306d58332fee3fb`, within round 1’s fix-check budget. HEAD adds only the brief.
+
+**P2-6 remains partly unresolved.** [docs/site/cli.md:3388](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/docs/site/cli.md:3388) still says the refused move “would fail.” A leftover link naming the sealed build passes [liveNotSealed:1250](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/movesoffline_land.go:1250), but the name-only probe cannot distinguish it. MV-O200 now explains the conservative policy correctly; MV-O203 still predicts an unestablished failure. Update the CLI paragraph and its copy-table row to describe that policy. **Invariant:** refusal copy distinguishes observed facts from predicted failures. Fix without reopening review.
+
+Round 1 dispositions:
+
+- **P1-1 — resolved:** effective UID 0 returns before filesystem access.
+- **P1-3, remaining half — resolved:** enumeration and reported names/bytes are bounded; overflow is explicit.
+- **P2-4 — resolved:** staging status checks the same facts before offering start.
+- **P2-5 — resolved by removal:** app-directory paths no longer reach refusal output; reported link names are compared, not printed.
+- **P2-6 — partly resolved:** MV-O200 corrected; MV-O203 remains inaccurate.
+- **P2-7 — resolved:** the runbook now limits the headline to status before finish.
+
+The app-directory implementation is removed. `movesoffline_seal.go` has the identical Git blob on the reviewed commit and `origin/main`: `f98559c24d3d6e0231790e339fe798b1ceef0853`. P1-2 and the directory half of P1-3 are therefore removed, not fixed.
+
+The probe opens only the live directory and enumerates names; it never stats, opens or follows an entry. Its precise bound is **4,096 retained names plus one overflow lookahead**, rather than literally 4,096 names read. It reports at most 128 names and 8 KiB of hostname bytes, plus JSON overhead. The added round-trip test covers `WriteBox` and `LoadBoxesComplete`.
+
+Bootstrap creates the host live directory with mode 0755; root’s release paths create links through `PointLive`. Tenant units receive read-only executable mounts. I found no tenant filesystem path that can create entries there. Legitimate deployments can cause root to create hostname entries; the bounds cover their accumulation.
+
+MV-O204 does not strand a move: it gates stage/start and staging status. [Abort:1241](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/console/apiinstancemove_offline.go:1241) and reverting-to-finish checks do not consult these facts.
+
+| Census unit or envelope | Verdict | Evidence |
+|---|---|---|
+| `CollectBox` | APPROVED | `snapshot.go:1251–1258,1315–1316`: supplied metrics only; no new external read. |
+| `statusLoop` | APPROVED | `agent.go:5086`: calls the identity-gated probe. |
+| `offlineMoveFactsProbe` | APPROVED | `movesoffline_facts.go:38–39`: passes actual effective UID. |
+| `movesWorker.offlineMoveFacts` | APPROVED | `movesoffline_facts.go:56–91`: UID refusal first; bounded name-only collection. |
+| `readNamesBounded` | APPROVED | `movesoffline_facts.go:97–120`: directory open and bounded enumeration, including one lookahead; no entry access. |
+| Envelope `.` | APPROVED | `move.go:1501–1511,1614–1619`: display changes add no root authority. |
+| Envelope `internal/host` | APPROVED | Gated probe above; seal restored byte-for-byte. |
+| Envelope `internal/status` | APPROVED | `snapshot.go:243–263,814,1258,1316`: private schema and supplied-value projection. |
+
+Targeted tests, including census checks, could not start: with `GOCACHE` unset, Go failed creating its work directory in the read-only sandbox. These are source-review approvals, not a claim that the tests passed. No files were edited; no subagents were used.
+
+**READY AFTER FIXES**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md
new file mode 100644
index 000000000..815ff863b
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md
@@ -0,0 +1,59 @@
+Reviewed `4c641678..b7aa5590792d1c05c12fa2af586b3badc91db327`, round 1 of 3. Found three P1s.
+
+1. **P1 — The new periodic probe bypasses the census’s non-root condition.**
+ [agent.go:5086](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/agent.go:5086) invokes the probe without an offline move in progress. [movesoffline_facts.go:51](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/movesoffline_facts.go:51) checks capability but not effective UID; [agententry.go:61](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/agententry.go:61) explicitly permits a root-run agent to continue. Such an agent now lists and opens tenant-controlled paths automatically, before an operator could perform the runbook’s `User=carlos` precheck. The existing census approval expressly depended on that precheck.
+ **Fix:** Refuse this probe under UID 0 before filesystem access; test that refusal.
+ **Invariant:** Tenant filesystem inspection accepted as agent-only must never execute as root.
+
+2. **P1 — `emptyDir` can follow a replacement symlink or block on a FIFO.**
+ At [movesoffline_facts.go:105](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/movesoffline_facts.go:105), `Lstat` and `Open` resolve the path separately. The running app can replace the checked directory between them. A symlink redirects the open; a FIFO with no writer blocks it indefinitely, stopping the box’s status publication. These paths use the raw `.instances` tree, bypassing the protected mount view.
+ **Fix:** Open directories atomically with no-follow and directory-only guarantees, anchored to a trusted directory; add replacement-race and special-file tests.
+ **Invariant:** A tenant-controlled entry must neither redirect nor block the status probe.
+
+3. **P1 — Unbounded app entries can invalidate fleet evidence.**
+ [movesoffline_facts.go:83](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/movesoffline_facts.go:83) collects every stray entry and appends every full path. A tenant creating 5,000 siblings with long names readily pushes the snapshot above the reader’s 1 MiB limit. [fleet.go:298](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/status/fleet.go:298) then drops the whole box report and marks evidence incomplete. Consequently, unrelated moves cannot stage or start; a move already stopping cannot seal. Scanning and allocation are also unbounded.
+ **Fix:** Bound enumeration, per-host detail and total report bytes, retaining an explicit overflow/refusal indication without losing the heartbeat. Test through `WriteBox` and `LoadBoxesComplete`.
+ **Invariant:** One tenant’s directory contents cannot disable box reporting or deployment-wide move operations.
+
+4. **P2 — Status recommends starting a move that the start door refuses.**
+ The staging branch of [apiinstancemove_offline.go:938](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/console/apiinstancemove_offline.go:938) omits `offlineBoxFacts`. When a blocking link or directory appears after staging, status still returns `next: start`, despite having the same report that makes POST start return 409.
+ **Fix:** Apply the facts check when computing the staging view’s next action, and test both newly appearing blockers.
+ **Invariant:** Status must not recommend an action that its current evidence already disqualifies.
+
+5. **P2 — Tenant filenames reach the operator’s terminal unescaped.**
+ [apiinstancemove_offline_facts.go:35](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/console/apiinstancemove_offline_facts.go:35) inserts raw paths into the refusal. JSON escaping does not protect terminal output: the CLI decodes the string and [move.go:104](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/move.go:104) prints it verbatim. A filename containing newlines or terminal escape sequences can forge lines or obscure the refusal.
+ **Fix:** Escape control characters when rendering individual paths, with a malicious-filename test.
+ **Invariant:** Tenant-controlled names remain displayed data, never terminal instructions.
+
+6. **P2 — MV-O200 and MV-O203 claim a failure the report does not establish.**
+ [apiinstancemove_offline_facts.go:26](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/console/apiinstancemove_offline_facts.go:26) says the move “would fail at flip.” The probe reports every unrouted live-link name without reading its target, while [movesoffline_land.go:1250](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/internal/host/movesoffline_land.go:1250) accepts a link naming the sealed build. The runbook explicitly acknowledges this conservative refusal.
+ **Fix:** Describe the conservative policy accurately, or collect enough evidence to establish the claimed mismatch.
+ **Invariant:** Refusal copy distinguishes observed facts from predicted failures.
+
+7. **P2 — The runbook promises the new headline after `finish`, when it is unavailable.**
+ [runbook:248](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/docs/superpowers/plans/2026-10-21-offline-move-runbook.md:248) says subsequent status prints “Nothing moved…” after describing abort and finish. Once finish clears the move, [move.go:1595](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-stage-refusals-339/move.go:1595) prints the generic recorded outcome. MV-O202 applies only while the staged abort remains in `offline-reverting`.
+ **Fix:** Scope the documentation to status before finish, or preserve the necessary outcome information.
+ **Invariant:** Documented output matches the completed workflow.
+
+The refusal checks precede record and lock writes, and start repeats them after staging. The extracted seal rule preserves its previous behavior. Missing facts from older boxes leave the existing seal and landing safeguards intact.
+
+The new tests assert refusals and unchanged records. The E2E fixture reproduces collection and publication, but injects the worker’s facts directly; removing the production status-loop assignment would not fail it. Root execution, replacement races and report limits lack coverage.
+
+Tests could not run: the targeted `go test -run` attempt, with `GOCACHE` unset, failed creating Go’s build directory in the read-only sandbox. Discussion #339 was inaccessible because networking was blocked. No files were edited.
+
+Census verdicts for the requested commit:
+
+| Changed unit or envelope | Verdict | Basis |
+|---|---|---|
+| `internal/status/snapshot.go:CollectBox` | APPROVED | Lines 1255–1256 and 1314 carry supplied private metrics; no new external read. |
+| `internal/host/agent.go:statusLoop` | REFUSED | Line 5086 introduces the ungated periodic reads; findings 1–3. |
+| `internal/host/movesoffline_seal.go:movesWorker.offlineFilesOf` | APPROVED | Lines 672–685 preserve registry enumeration and delegation semantics. |
+| `internal/host/movesoffline_facts.go:emptyDir` | REFUSED | Lines 105–114 violate the no-follow basis; finding 2. |
+| `internal/host/movesoffline_facts.go:movesWorker.offlineMoveFacts` | REFUSED | Lines 51–96 permit root execution, unsafe opens and unbounded reporting. |
+| `internal/host/movesoffline_facts.go:offlineMoveFactsProbe` | REFUSED | Lines 31–32 expose those reads without the required identity restriction. |
+| `internal/host/movesoffline_seal.go:offlineFilesAt` | APPROVED | Lines 692–716 preserve the former seal classification and refusal rule; the unsafe new calling path is refused above. |
+| Envelope `.` | APPROVED | CLI changes add no root filesystem authority. |
+| Envelope `internal/host` | REFUSED | Findings 1–3 invalidate the proposed read-safety basis. |
+| Envelope `internal/status` | APPROVED | Additive private schema and supplied-value projection only. |
+
+NOT READY
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339-FIXES.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339-FIXES.md
new file mode 100644
index 000000000..284ee7a7f
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339-FIXES.md
@@ -0,0 +1,13 @@
+# Review brief: #339 round 1 fixes, census and root check (same round budget)
+
+Repo carlos/platform, branch `offline-move-stage-refusals-339`, commit 6b580cd6db9e7d4c2bc59e02a306d58332fee3fb.
+Under review: the diff from ccd35818 (round 1's brief commit) to 6b580cd6db9e7d4c2bc59e02a306d58332fee3fb, i.e. the fixes for `docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md`.
+
+The controller cut item 4 (app directories) from this branch (follow-up amadan #1003), so P1-2 and the directory half of P1-3 are removed, not fixed. Confirm the removal is complete (seal byte-for-byte back to main).
+
+This is not a new review round (AGENTS.md stopping rule 1). Check only:
+1. **Census:** the re-proposed overlay and card for this branch: APPROVED or REFUSED per changed unit (statusLoop, the live-link probe, its helpers, envelopes).
+2. **Root and security behaviour the fixes changed:** the effective-UID 0 refusal is first, before any filesystem access; the probe reads only names in /opt/carlos/live (no stat, follow or open), bounded (4096 names read, 128 reported, 8 KiB, overflow flag) with the heartbeat kept valid; is /opt/carlos/live truly root-written only (who creates entries; can a tenant create a name there through any path)? Overflow refusal (MV-O204) cannot strand a move.
+3. One line each: round 1's P1-1, P1-3 (remaining half), P2-4, P2-5, P2-6, P2-7 resolved, partly, or not.
+
+Severity as in round 1. 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-REFUSALS-339.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339.md
new file mode 100644
index 000000000..967c1b5b2
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-REFUSALS-339.md
@@ -0,0 +1,22 @@
+# Review brief: offline move stage/start refusals (#339 items 1, 2, 4), branch, round 1 of 3
+
+Repo carlos/platform, branch `offline-move-stage-refusals-339`, commit b7aa5590792d1c05c12fa2af586b3badc91db327.
+Under review: the diff `4c6416787a42ce5da5964588de721817d25fc15d..b7aa5590792d1c05c12fa2af586b3badc91db327`.
+Authorities, merged on main: the offline-move runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md`; `docs/superpowers/plans/2026-10-20-offline-operator-move.md`; AGENTS.md (stopping rules, census). The report: `amadan discuss show carlos/platform 339`. Do not review against unmerged branches (offline-move-pool-target-413 is in flight separately).
+
+You are an independent reviewer. Read the diff, then the code it touches, and check every claim.
+
+## What to check
+1. The new private status-report block (`offline_move`: stale live links for hosts with no route row; app directories beside an instance's files directory, empty or not): can a tenant influence what the agent reports (symlinks, races, names), and does the agent read anything as root or follow tenant-controlled links? Is it attributed to the right box and host, and bounded in size?
+2. The stage and start door refusals: do they refuse before anything goes offline or changes on the record; does start refuse even after stage passed; is "older box sends nothing, door lets it through" safe (backstops at landing and seal unchanged)? Any way a refusal could strand a move mid-state?
+3. `offlineFilesAt` refactor: the seal's refusal rule is byte-for-byte the same as before.
+4. Status after an abort from staging: correct for every abort path; older consoles handled by the CLI.
+5. Tests: would each fail if its guard were removed? The E2E's status-report writing mirrors the real status loop?
+6. **Census:** `docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md` and its overlay: you are the census reviewer (AGENTS.md "The census: the reviewer decides"); give APPROVED or REFUSED per changed unit.
+7. Copy rows MV-O200..O203: accurate to the behaviour (wording is reviewed separately).
+
+## Severity
+P1 blocks; P2 fixed without another round; P3 follow-up. A P1 states its failure scenario and evidence (file:line).
+
+## Output
+Findings ranked with evidence, failure scenario, fix and invariant. Then a Census verdict table. End with exactly one verdict: READY, READY AFTER FIXES, or NOT READY. Do not edit files; no subagents; targeted `go test -run` only (GOCACHE unset).
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index 862501c3b..46db68bfb 100644
--- a/internal/console/apiinstancemove_offline.go
+++ b/internal/console/apiinstancemove_offline.go
@@ -572,6 +572,10 @@ func (s *Server) offlineBeginChecks(w http.ResponseWriter, r *http.Request, d of
writeRefusal(w, ref)
return "", offlineFleet{}, false
}
+ if ref := offlineBoxFacts(fleet, host, to); ref != nil {
+ writeRefusal(w, ref)
+ return "", offlineFleet{}, false
+ }
return to, fleet, true
}
@@ -941,6 +945,9 @@ func (s *Server) offlineStepFor(ctx context.Context, d offlineDoor, mv *provisio
if ref := s.offlineSelect(ctx, fleet, host, mv.From, mv.To); ref != nil {
return offlineStep{}, ref
}
+ if ref := offlineBoxFacts(fleet, host, mv.To); ref != nil {
+ return offlineStep{}, ref
+ }
if ref := s.offlineStagerPresent(fleet, mv, host); ref != nil {
return offlineStep{}, ref
}
@@ -1397,7 +1404,11 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli
for _, r := range ev.reports {
v.Reports = append(v.Reports, offlineReportView{OfflineReport: r.OfflineReport, Fresh: offlineFresh(r.OfflineReport, now)})
}
- v.Items = offlineItems(ev, mv)
+ // A move that never went offline (staging, or reverting from it) has
+ // checked nothing of the manifest, so it lists no item as waiting.
+ if !v.NeverOffline {
+ v.Items = offlineItems(ev, mv)
+ }
v.Stage = offlineStageOf(ev)
for _, r := range ev.byRole(moves.OfflineRoleSource) {
for _, p := range r.Retired {
diff --git a/internal/console/apiinstancemove_offline_facts.go b/internal/console/apiinstancemove_offline_facts.go
new file mode 100644
index 000000000..d4e2d908b
--- /dev/null
+++ b/internal/console/apiinstancemove_offline_facts.go
@@ -0,0 +1,36 @@
+package console
+
+import (
+ "fmt"
+ "net/http"
+ "slices"
+)
+
+// offlineBoxFacts refuses a start or a stage over a live link the target
+// box still holds for the host (#339), read from the box's status report
+// (status.OfflineMoveFacts), which the box writes while the instance still
+// serves. The landing fails its release item over any such link that does
+// not name the sealed build, at flip, with the instance offline; the
+// report names the link and not its build, so the door refuses any link,
+// and a list the box could not report whole as well. A box whose report
+// carries no facts says nothing, and the landing keeps its own check
+// behind this one. offlineSelect has already required exactly one target
+// box. Neither name in the sentences is a tenant's: host is the record's
+// host, a validated hostname, and the box is named as every other door
+// sentence names it, from its edges file, which only a box writes. The
+// link names in the report are never printed, only compared with host.
+func offlineBoxFacts(f offlineFleet, host, to string) *offlineRefusal {
+ for _, b := range f.boxesAt(to) {
+ m := f.metrics[b.Box]
+ if m == nil || m.OfflineMove == nil {
+ continue
+ }
+ if slices.Contains(m.OfflineMove.StaleLiveLinks, host) {
+ return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s still holds a live link for %s from when it last ran there. stage and start refuse until it is cleared, since a mismatched link fails the move only after %s is offline. see the offline move runbook", b.Box, host, host)}
+ }
+ if m.OfflineMove.StaleLiveLinksOverflow {
+ return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s holds more live links than it can report, so stage and start cannot tell whether one is for %s. see the offline move runbook", b.Box, host)}
+ }
+ }
+ return nil
+}
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go
index a22255413..9f1445389 100644
--- a/internal/console/apiinstancemove_offline_stage_test.go
+++ b/internal/console/apiinstancemove_offline_stage_test.go
@@ -161,8 +161,13 @@ func TestOfflineAbortFromStagingDoor(t *testing.T) {
w := newOfflineWorld(t, oneEach...)
w.stage()
w.staged("ie-box", nil)
- if v := w.ok("/abort", "", provision.OfflineReverting); !v.NeverOffline {
- t.Fatal("an abort from staging does not say the instance was never offline")
+ if v := w.ok("/abort", "", provision.OfflineReverting); !v.NeverOffline || len(v.Items) != 0 {
+ t.Fatalf("an abort from staging: never offline %v, items %v", v.NeverOffline, v.Items)
+ }
+ // Nothing of the manifest was ever checked, so the status lists no
+ // item as waiting (#339, item 2).
+ if st := w.status(); len(st.Items) != 0 {
+ t.Fatalf("the status of an abort from staging lists %d items", len(st.Items))
}
if rec := w.record(); rec.Region != "ie" || rec.Move.State != provision.OfflineReverting {
t.Fatalf("after abort: %q %+v", rec.Region, rec.Move)
@@ -323,3 +328,69 @@ func TestOfflineStagedMoveRefusesChangedCoordinates(t *testing.T) {
})
}
}
+
+// ---- #339: refused while the instance still serves ----
+
+func msgO200(box string) string {
+ return box + " still holds a live link for " + offlineHost + " from when it last ran there. stage and start refuse until it is cleared, since a mismatched link fails the move only after " + offlineHost + " is offline. see the offline move runbook"
+}
+
+func msgO204(box string) string {
+ return box + " holds more live links than it can report, so stage and start cannot tell whether one is for " + offlineHost + ". see the offline move runbook"
+}
+
+// A target box that reports a live link for the host, left from an earlier
+// time the instance ran there, would fail the landing's release item at
+// flip, with the instance offline. Stage and start refuse it before
+// anything is written, and so does a box that could not report its links
+// whole. A link that appears after the stage refuses the start, the status
+// no longer offers start, and the move stays staging until it is gone.
+func TestOfflineStageAndStartRefuseAStaleLiveLinkOnTheTarget(t *testing.T) {
+ stale := offlineBox{Box: "uk-box", Placement: "uk", Bucket: "data-uk", LiveLinks: []string{"other.shop.example.com", offlineHost}}
+ w := newOfflineWorld(t, ieOff("ie-box"), stale)
+ w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgO200("uk-box"))
+ w.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, msgO200("uk-box"))
+ if rec := w.record(); rec.Move != nil {
+ t.Fatalf("a refused door wrote %+v", rec.Move)
+ }
+ if _, ok := w.lock(); ok {
+ t.Fatal("a refused door took the lock")
+ }
+
+ // A list the box could not report whole refuses too, the host in it
+ // or not.
+ full := offlineBox{Box: "uk-box", Placement: "uk", Bucket: "data-uk", LiveLinks: []string{"other.shop.example.com"}, LinksOverflow: true}
+ wo := newOfflineWorld(t, ieOff("ie-box"), full)
+ wo.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgO204("uk-box"))
+ wo.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, msgO204("uk-box"))
+
+ // A link for another host, or one on a source box, refuses nothing.
+ w2 := newOfflineWorld(t, offlineBox{Box: "ie-box", Placement: "ie", Bucket: "data-ie", LiveLinks: []string{offlineHost}},
+ offlineBox{Box: "uk-box", Placement: "uk", Bucket: "data-uk", LiveLinks: []string{"other.shop.example.com"}})
+ w2.stage()
+
+ // The link appears after the stage: start refuses, the staging status
+ // says why instead of offering start, the move stays staging, and once
+ // the box no longer reports it start goes ahead.
+ for _, c := range []struct {
+ box offlineBox
+ want string
+ }{{stale, msgO200("uk-box")}, {full, msgO204("uk-box")}} {
+ w3 := newOfflineWorld(t, oneEach...)
+ w3.stage()
+ if st := w3.status(); st.Next != offlineVerbStart {
+ t.Fatalf("a clean staged move: next %q, waiting %q", st.Next, st.Waiting)
+ }
+ w3.fleet(c.box)
+ if st := w3.status(); st.Next != "" || st.Waiting != c.want {
+ t.Fatalf("staged with a blocking report: next %q, waiting %q", st.Next, st.Waiting)
+ }
+ w3.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, c.want)
+ w3.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, c.want)
+ if rec := w3.record(); rec.Move.State != provision.OfflineStaging {
+ t.Fatalf("after a refused start the move is %s", rec.Move.State)
+ }
+ w3.fleet(ukOff("uk-box"))
+ w3.ok("", `{"region":"uk"}`, provision.OfflineStopping)
+ }
+}
diff --git a/internal/console/apiinstancemove_offline_test.go b/internal/console/apiinstancemove_offline_test.go
index 7b6d0c144..c1fcfb622 100644
--- a/internal/console/apiinstancemove_offline_test.go
+++ b/internal/console/apiinstancemove_offline_test.go
@@ -73,6 +73,10 @@ type offlineBox struct {
NoHibernation bool // hibernation_configured false
Hosts []string // hosts its edges file lists
FP string // secrets_key_fp; testKeyFP when empty
+ // LiveLinks and LinksOverflow are the box's offline move facts (#339):
+ // the hosts it keeps a stale live link for, and whether it holds more.
+ LiveLinks []string
+ LinksOverflow bool
}
func ieOff(box string) offlineBox { return offlineBox{Box: box, Placement: "ie", Bucket: "data-ie"} }
@@ -166,7 +170,8 @@ func (w *offlineWorld) fleet(boxes ...offlineBox) {
offlinePut(w.t, w.fx.rel, edgesFilePrefix+b.Box+".json", body)
sb := status.Box{Label: b.Box, GeneratedAt: time.Now()}
if !b.NoMetrics {
- sb.Metrics = &status.BoxMetrics{HostClaimEnabled: b.ClaimsOn}
+ sb.Metrics = &status.BoxMetrics{HostClaimEnabled: b.ClaimsOn,
+ OfflineMove: &status.OfflineMoveFacts{StaleLiveLinks: b.LiveLinks, StaleLiveLinksOverflow: b.LinksOverflow}}
}
if err := status.WriteBox(context.Background(), w.fx.rel, sb); err != nil {
w.t.Fatal(err)
diff --git a/internal/host/agent.go b/internal/host/agent.go
index 50a5c1d02..3e3f3e5b9 100644
--- a/internal/host/agent.go
+++ b/internal/host/agent.go
@@ -5078,6 +5078,12 @@ func statusLoop(reg *registry.Registry, svc *activator.Service, buildStates func
// activator's memory: no store request, no root call. nil with no
// activator. Private Metrics only.
p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes)
+ // What an offline move's stage and start doors read from this box
+ // while its instances still serve (#339): stale live links and the
+ // entries beside each instance's files directory. Directory
+ // listings only; nil when the box cannot take part in an offline
+ // move. Private Metrics only: hosts.
+ p.OfflineMove = offlineMoveFactsProbe(routes)
// A fleet box (CARLOS_FLEET set) never gets here as a contender: it
// self-reports only, never attempting the election at all — no
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go
index a663ec804..9c9a1a831 100644
--- a/internal/host/movesoffline_e2e_test.go
+++ b/internal/host/movesoffline_e2e_test.go
@@ -9,6 +9,9 @@ import (
"encoding/json"
"errors"
"fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
"io"
"net/http"
"net/http/httptest"
@@ -62,9 +65,10 @@ import (
// and the restore;
// - the operator page (sealWorld.arm's Page records instead of writing
// the outbox), so the test can say no page fired;
-// - the box status snapshots, written once before the move as each box's
-// status loop would (status.WriteBox), because the console's fleet read
-// joins them and no status loop runs in a test;
+// - the box status snapshots, written before the move as each box's
+// status loop would (CollectBox with the box's offline move facts, then
+// status.WriteBox), because the console's fleet read joins them and no
+// status loop runs in a test;
// - the reconcile Layout intent (offBox.reconcile names flat or nested)
// instead of mintLayoutIntentWith, as T3 to T5's worlds do;
// - the source's config.env is rendered once by RenderHeld before the
@@ -379,17 +383,81 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld {
// Both boxes published as their loops publish them, and their status
// snapshots.
w.tickAll()
- for _, b := range []*offBox{ie, lw.uk} {
- if err := status.WriteBox(ctx, rs, status.Box{Label: b.name, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil {
- t.Fatal(err)
- }
- }
+ w.reportStatus()
if !ie.lists(offHost) || lw.uk.lists(offHost) {
t.Fatal("fixture: ie-box must serve the host and uk-box must not")
}
return w
}
+// reportStatus writes each box's status snapshot as its status loop does:
+// CollectBox over the box's rows with p.OfflineMove from the loop's own
+// 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.
+func (w *e2eWorld) reportStatus() {
+ w.t.Helper()
+ requireStatusLoopReportsOfflineFacts(w.t)
+ if os.Geteuid() == 0 {
+ w.t.Skip("the offline move facts are never read as root")
+ }
+ prev := armedMovesWorker.Load()
+ defer armedMovesWorker.Store(prev)
+ for _, b := range []*offBox{w.ie, w.uk} {
+ routes, err := b.reg.List()
+ if err != nil {
+ w.t.Fatal(err)
+ }
+ armedMovesWorker.Store(b.w)
+ var p status.Probes
+ p.OfflineMove = offlineMoveFactsProbe(routes)
+ box := status.CollectBox(routes, p, time.Now())
+ box.Label = b.name
+ if err := status.WriteBox(context.Background(), w.rs, box); err != nil {
+ w.t.Fatal(err)
+ }
+ }
+}
+
+// requireStatusLoopReportsOfflineFacts: statusLoop sets p.OfflineMove from
+// offlineMoveFactsProbe over the tick's routes. No test can run the loop
+// itself, so the E2E reads it: without the assignment no box would report
+// a live link and the doors would refuse nothing.
+func requireStatusLoopReportsOfflineFacts(t *testing.T) {
+ t.Helper()
+ file, err := parser.ParseFile(token.NewFileSet(), "agent.go", nil, 0)
+ if err != nil {
+ t.Fatal(err)
+ }
+ found := false
+ for _, decl := range file.Decls {
+ fn, ok := decl.(*ast.FuncDecl)
+ if !ok || fn.Name.Name != "statusLoop" {
+ continue
+ }
+ ast.Inspect(fn.Body, func(n ast.Node) bool {
+ as, ok := n.(*ast.AssignStmt)
+ if !ok || len(as.Lhs) != 1 || len(as.Rhs) != 1 {
+ return true
+ }
+ sel, ok := as.Lhs[0].(*ast.SelectorExpr)
+ call, isCall := as.Rhs[0].(*ast.CallExpr)
+ if !ok || !isCall || sel.Sel.Name != "OfflineMove" || len(call.Args) != 1 {
+ return true
+ }
+ if id, ok := call.Fun.(*ast.Ident); ok && id.Name == "offlineMoveFactsProbe" {
+ if arg, ok := call.Args[0].(*ast.Ident); ok && arg.Name == "routes" {
+ found = true
+ }
+ }
+ return true
+ })
+ }
+ if !found {
+ t.Fatal("statusLoop does not set p.OfflineMove = offlineMoveFactsProbe(routes): no box reports its live links")
+ }
+}
+
// publish is one pass of edgesFileLoop on b: the identity it builds at arm
// from the box's own environment, the capability from the box's armed
// worker, through the production writer, with the box's lifetimes switch
@@ -1104,6 +1172,60 @@ 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) })
+ // #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.
+ t.Run("stage and start refuse a stale live link on the target", offlineRefusesAStaleLiveLink)
+}
+
+// requireRefused posts verb and wants a 409 with msg, no write to the
+// deployment store and the record byte for byte as it was.
+func (w *e2eWorld) requireRefused(verb, msg string) {
+ w.t.Helper()
+ mark, rec := w.rs.mark(), w.recordRaw()
+ code, out := w.door(verb, `{"region":"uk"}`)
+ var e struct {
+ Error string `json:"error"`
+ }
+ _ = json.Unmarshal([]byte(out), &e)
+ if code != http.StatusConflict || e.Error != msg {
+ w.t.Fatalf("%s = %d %s\nwant 409 %q", verbName(verb), code, out, msg)
+ }
+ if writes := w.rs.since(mark); len(writes) != 0 {
+ w.t.Fatalf("a refused %s wrote %v", verbName(verb), writes)
+ }
+ if !bytes.Equal(w.recordRaw(), rec) {
+ w.t.Fatalf("a refused %s changed the record", verbName(verb))
+ }
+}
+
+// A return move to a box that still keeps the host's live link from the
+// last time it ran there (2026-10-21, #339 item 1): uk-box reports the link
+// in its status report, and stage and start refuse before anything is
+// written. Without the link stage goes ahead; a link that appears after the
+// stage refuses the start, with the instance still serving from ie-box.
+func offlineRefusesAStaleLiveLink(t *testing.T) {
+ w := newE2EWorld(t, landOpts{})
+ old := w.stageLive("v0")
+ w.reportStatus()
+ msg := "uk-box still holds a live link for " + offHost + " from when it last ran there. stage and start refuse until it is cleared, since a mismatched link fails the move only after " + offHost + " is offline. see the offline move runbook"
+ w.requireRefused("stage", msg)
+ w.requireRefused("", msg)
+ if got, err := os.Readlink(release.LiveLink(w.uk.opt, offHost)); err != nil || got != old {
+ t.Fatalf("the live link is %q (%v), want it left at %q", got, err, old)
+ }
+
+ if err := os.Remove(release.LiveLink(w.uk.opt, offHost)); err != nil {
+ t.Fatal(err)
+ }
+ w.reportStatus()
+ w.accept("stage", `{"region":"uk"}`, provision.OfflineStaging)
+ w.stageLive("v0")
+ w.reportStatus()
+ w.requireRefused("", msg)
+ if !w.ie.lists(offHost) {
+ t.Fatal("ie-box stopped serving the host over a refused start")
+ }
}
// e2eLoops are what acts on the two boxes between door calls in production,
diff --git a/internal/host/movesoffline_facts.go b/internal/host/movesoffline_facts.go
new file mode 100644
index 000000000..4745494af
--- /dev/null
+++ b/internal/host/movesoffline_facts.go
@@ -0,0 +1,121 @@
+package host
+
+import (
+ "errors"
+ "io"
+ "log"
+ "os"
+ "path/filepath"
+ "sort"
+
+ "github.com/carlosframework/platform/internal/controlname"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// What a box tells an offline move's stage and start doors about its own
+// disk while the instance still serves (#339): the hosts it keeps a live
+// link for with no row here. A box the instance once left keeps the link,
+// root-owned, naming the build it ran then (retirePaths leaves it), and the
+// landing fails its release item over any link that does not name the
+// sealed build (liveNotSealed), at flip, with the instance offline. The box
+// reports the names in its status report and the doors refuse first. The
+// landing keeps its own check.
+//
+// The probe reads one directory's names and nothing else: <opt>/live is
+// root's (bootstrap makes it 0755, root alone writes it, and every name in
+// it is one root gave PointLive for a host its registry held). It never
+// stats, follows or opens an entry, and changes nothing.
+
+// offlineLiveScanMax bounds how many names one probe reads from <opt>/live.
+// Past it the probe stops and says so (StaleLiveLinksOverflow).
+const offlineLiveScanMax = 4096
+
+// offlineMoveFactsProbe is the armed worker's facts over routes, for the
+// status loop; nil when no worker is armed, the box cannot take part in an
+// offline move, or the agent runs as root.
+func offlineMoveFactsProbe(routes []registry.Route) *status.OfflineMoveFacts {
+ return armedMovesWorker.Load().offlineMoveFacts(routes, os.Geteuid())
+}
+
+// offlineMoveFacts is this box's report, from routes (every row on the
+// box, as the status loop lists them): every name in <opt>/live that is a
+// hostname with no row here, sorted. At most status.MaxStaleLiveLinks names
+// and status.MaxStaleLiveLinkBytes bytes of them are reported, and at most
+// offlineLiveScanMax names are read; past any of these the list is partial
+// and StaleLiveLinksOverflow says so, so the report stays small enough for
+// every reader whatever the box holds.
+//
+// nil, before any filesystem access, under euid 0: the census accepts this
+// read as the agent's (user carlos) and never root's, the rule the metrics
+// loop's root-run probes follow (engineBeatArmed, newRestartWatchFile).
+// nil too when the box cannot take part in an offline move, or when the
+// listing fails: a box that cannot say reports nothing, rather than a
+// partial answer a door would read as complete.
+func (w *movesWorker) offlineMoveFacts(routes []registry.Route, euid int) *status.OfflineMoveFacts {
+ if euid == 0 || w == nil || !w.cfg.OfflineCapable || w.cfg.Offline == nil {
+ return nil
+ }
+ routed := map[string]bool{}
+ for _, rt := range routes {
+ routed[rt.Host] = true
+ }
+ optDir := w.cfg.OptDir
+ if optDir == "" {
+ optDir = release.OptDir()
+ }
+ liveDir := filepath.Dir(release.LiveLink(optDir, "host"))
+ names, more, err := readNamesBounded(liveDir, offlineLiveScanMax)
+ if err != nil {
+ log.Printf("moves: offline move facts: list %s: %v", liveDir, err)
+ return nil
+ }
+ facts := &status.OfflineMoveFacts{StaleLiveLinksOverflow: more}
+ var stale []string
+ for _, name := range names {
+ if controlname.ValidHostShape(name) && !routed[name] {
+ stale = append(stale, name)
+ }
+ }
+ sort.Strings(stale)
+ size := 0
+ for _, name := range stale {
+ if len(facts.StaleLiveLinks) == status.MaxStaleLiveLinks || size+len(name) > status.MaxStaleLiveLinkBytes {
+ facts.StaleLiveLinksOverflow = true
+ break
+ }
+ facts.StaleLiveLinks = append(facts.StaleLiveLinks, name)
+ size += len(name)
+ }
+ return facts
+}
+
+// readNamesBounded reads at most max entry names of dir (getdents only: no
+// entry is stat'd or followed). more says the directory holds more. A
+// directory that does not exist has no names.
+func readNamesBounded(dir string, max int) (names []string, more bool, err error) {
+ f, err := os.Open(dir)
+ if errors.Is(err, os.ErrNotExist) {
+ return nil, false, nil
+ } else if err != nil {
+ return nil, false, err
+ }
+ defer f.Close()
+ for len(names) < max {
+ batch, err := f.Readdirnames(min(256, max-len(names)))
+ names = append(names, batch...)
+ if errors.Is(err, io.EOF) {
+ return names, false, nil
+ } else if err != nil {
+ return nil, false, err
+ }
+ }
+ extra, err := f.Readdirnames(1)
+ if errors.Is(err, io.EOF) {
+ return names, false, nil
+ } else if err != nil {
+ return nil, false, err
+ }
+ return names, len(extra) > 0, nil
+}
diff --git a/internal/host/movesoffline_facts_test.go b/internal/host/movesoffline_facts_test.go
new file mode 100644
index 000000000..ee4271b17
--- /dev/null
+++ b/internal/host/movesoffline_facts_test.go
@@ -0,0 +1,123 @@
+package host
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "path/filepath"
+ "slices"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// factsWorker is a capable worker over its own <opt>, with names in
+// <opt>/live as dangling links (the probe reads names and follows nothing).
+func factsWorker(t *testing.T, names ...string) *movesWorker {
+ t.Helper()
+ opt := t.TempDir()
+ for _, n := range names {
+ link := release.LiveLink(opt, n)
+ if err := os.MkdirAll(filepath.Dir(link), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Symlink(filepath.Join(opt, "versions", "gone", n), link); err != nil {
+ t.Fatal(err)
+ }
+ }
+ return newMovesWorker(moveCfg{OfflineCapable: true, Offline: &offlineView{}, OptDir: opt})
+}
+
+// The facts are the unrouted hostnames in <opt>/live, sorted; a routed
+// host, a name that is not a hostname, a box that cannot take part and a
+// root-run agent report none (#339, Astra round 1, P1-1: never read as
+// root, before any filesystem access).
+func TestOfflineMoveFactsReportsStaleLiveLinks(t *testing.T) {
+ w := factsWorker(t, "b.example.com", "a.example.com", "served.example.com", ".tmp-x")
+ routes := []registry.Route{{Host: "served.example.com", Kind: "instance"}}
+ f := w.offlineMoveFacts(routes, 1000)
+ if f == nil || !slices.Equal(f.StaleLiveLinks, []string{"a.example.com", "b.example.com"}) || f.StaleLiveLinksOverflow {
+ t.Fatalf("facts %+v", f)
+ }
+ // Under root the probe reports nothing, the links there or not: it
+ // returns before it touches the disk.
+ if f := w.offlineMoveFacts(routes, 0); f != nil {
+ t.Fatalf("a root-run agent reported %+v", f)
+ }
+ notDir := filepath.Join(t.TempDir(), "file")
+ writeFile(t, notDir, "x")
+ w.cfg.OptDir = notDir
+ if f := w.offlineMoveFacts(nil, 1000); f != nil {
+ t.Fatalf("a failed listing reported %+v", f)
+ }
+ w.cfg.OptDir = filepath.Join(t.TempDir(), "absent")
+ if f := w.offlineMoveFacts(nil, 1000); f == nil || len(f.StaleLiveLinks) != 0 {
+ t.Fatalf("no live directory: %+v", f)
+ }
+ if f := newMovesWorker(moveCfg{OptDir: w.cfg.OptDir}).offlineMoveFacts(nil, 1000); f != nil {
+ t.Fatalf("a box that cannot take part reported %+v", f)
+ }
+ var nilWorker *movesWorker
+ if f := nilWorker.offlineMoveFacts(nil, 1000); f != nil {
+ t.Fatalf("no worker reported %+v", f)
+ }
+}
+
+// Astra round 1, P1-3: whatever a box holds, the report stays bounded in
+// names, bytes and the names read, says it is partial, and the heartbeat
+// still reads back whole through WriteBox and LoadBoxesComplete.
+func TestOfflineMoveFactsAreBounded(t *testing.T) {
+ long := strings.Repeat("a", 60)
+ for _, c := range []struct {
+ name string
+ names []string
+ max int // the most names the report may carry
+ }{
+ {"names", hostNames(300, "h%03d.example.com"), status.MaxStaleLiveLinks},
+ {"bytes", hostNames(150, long+"%03d.example.com"), status.MaxStaleLiveLinkBytes / (len(long) + 15)},
+ // Every name but two is routed, so only the scan bound can say
+ // the box holds more than it read.
+ {"scan", hostNames(offlineLiveScanMax+1, "s%05d.example.com"), 2},
+ } {
+ t.Run(c.name, func(t *testing.T) {
+ w := factsWorker(t, c.names...)
+ var routes []registry.Route
+ if c.name == "scan" {
+ for _, h := range c.names[2:] {
+ routes = append(routes, registry.Route{Host: h, Kind: "instance"})
+ }
+ }
+ f := w.offlineMoveFacts(routes, 1000)
+ size := 0
+ for _, n := range f.StaleLiveLinks {
+ size += len(n)
+ }
+ if !f.StaleLiveLinksOverflow || len(f.StaleLiveLinks) > c.max || len(f.StaleLiveLinks) == 0 || size > status.MaxStaleLiveLinkBytes || !slices.IsSorted(f.StaleLiveLinks) {
+ t.Fatalf("%d names (%d bytes), overflow %v", len(f.StaleLiveLinks), size, f.StaleLiveLinksOverflow)
+ }
+ s := release.NewDirStore(t.TempDir())
+ box := status.CollectBox(nil, status.Probes{OfflineMove: f}, time.Now())
+ box.Label = "uk-box"
+ if err := status.WriteBox(context.Background(), s, box); err != nil {
+ t.Fatal(err)
+ }
+ boxes, complete, err := status.LoadBoxesComplete(context.Background(), s)
+ if err != nil || !complete || len(boxes) != 1 || boxes[0].Metrics == nil || boxes[0].Metrics.OfflineMove == nil ||
+ !boxes[0].Metrics.OfflineMove.StaleLiveLinksOverflow || len(boxes[0].Metrics.OfflineMove.StaleLiveLinks) != len(f.StaleLiveLinks) {
+ t.Fatalf("read back: complete %v, err %v, boxes %d", complete, err, len(boxes))
+ }
+ })
+ }
+}
+
+func hostNames(n int, format string) []string {
+ out := make([]string, n)
+ for i := range out {
+ out[i] = fmt.Sprintf(format, i)
+ }
+ return out
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 6420219f5..93ce12e38 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -208,3 +208,4 @@ plan14-root-reads-instance-gomemlimit-991.tsv 19c9f395547d998f4b5e87e89c0dfa3b5f
plan14-root-reads-ppv2-operator-copy.tsv 19c9f395547d998f4b5e87e89c0dfa3b5f012d177a87eb5010a8c4defac305dc
plan14-root-reads-same-box-edge-fence.tsv 76c986ad534d23071100a9a573ffb38afc60b26c8942baf218436bf6a3ff03b3
plan14-root-reads-g6-fence.tsv 3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1442bbe0055d5631
+plan14-root-reads-offline-move-stage-refusals-339.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332
diff --git a/internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.tsv b/internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.tsv
new file mode 100644
index 000000000..19fc9e5b4
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.tsv
@@ -0,0 +1,16 @@
+# Census overlay offline-move-stage-refusals-339, written by census-propose (#369). census-ruling-offline-move-stage-refusals-339, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md.
+# 1 body, 1 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 82364189d85f53dceebfa94131a75303ea4f8423ff2b8c8d19efccfe7cc9a329 internal/status/snapshot.go CollectBox legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added. registry:Alias@4543,registry:CertExpiresAt@3160,registry:CertExpiresAt@3396,registry:CertExpiresAt@4658,registry:DBPath@2495,registry:DBPath@2553,registry:DNSCheckedAt@3365,registry:DNSCheckedAt@4627,registry:DNSStatus@3139,registry:DNSStatus@3334,registry:DNSStatus@4597,registry:Hibernate@3853,registry:Host@2295,registry:Host@2437,registry:Host@2666,registry:Host@3280,registry:Host@3315,registry:Host@4578,registry:Kind@2473,registry:Kind@3807,registry:Platform@2152,registry:ServingVersion@2324,registry:ServingVersion@2447,registry:Socket@4066,registry:Version@2186,registry:Version@2305,whole:Route@1581,whole:RouteAlias@4440 32791b85240b09b4c70694b6cc07cddf1f657838f35072544ffe08e25c93be09
+@legacy 5e6134d8233749331c52d44ced78938f076ec696732e1c1113ea32554ed699f7 internal/host/movesoffline_facts.go movesWorker.offlineMoveFacts legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1: item 4 cut, P1-1, P1-3): returns nil under euid 0 before touching the disk. Otherwise lists only the names of <opt>/live (root-owned, 0755; every name made by root PointLive for a host its registry held) through readNamesBounded; no entry is stat'd, followed or opened, and nothing under the .instances tree or any tenant path is read. Reports at most 128 unrouted hostnames and 8 KiB of them, with an overflow flag past those or the 4096-name scan bound. Agent only (user carlos); changes nothing; root never reads the report. registry:Host@261,whole:Route@243 faf46d977778900a12fcb0bd3d8aba94e9e227a166af4fb489af012e0c0a83c1
+@legacy ff9bc0958d50dfd6527959a953e8b28b68ddbae45a98cec255f55ec66c271a41 internal/host/movesoffline_facts.go offlineMoveFactsProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1 P1-1): the armed moves worker's offlineMoveFacts over the status tick's routes with os.Geteuid(); nil when none is armed, the box is not offline-capable, or the agent runs as root (refused before any filesystem access). whole:Route@128 3ca4f5b13ed40f19e642093e27c0b254080fd724eb123c8daa342d26d19433f8
+@legacy 3eb94c44249fdbd841db5c046e4e4e67117cf016b70678eda2447eca0a385934 internal/host/movesoffline_facts.go readNamesBounded legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1 P1-3): os.Open of the directory and Readdirnames in batches, at most max names (getdents only: nothing stat'd or followed), and whether more remain; a missing directory has no names. Agent only, read only. file:Open@95,file:Readdirnames@279,file:Readdirnames@485 48773914dfdc133ba845b7855486d6151c0752f4b6bd80f73e71abf9e831222e
+@legacy 837bbc4fc70d6dd6071861d7fc9f548b350c9b9d9f9076dd71b535a0c78fdf79 internal/host/agent.go statusLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added. whole:Route@10554,whole:Route@12368,whole:Route@12649,whole:Route@13007,whole:Route@6583,whole:Route@6610,whole:Route@7918 d31679b7894515917fe6fff0181b1e05d3507e042fc6952f557c8b3bed453783
+internal/status/snapshot.go CollectBox legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-rootfs-apps-2;basis=copies Probes.RootfsReady and RootfsBlocked into BoxMetrics (private, like Layout); the same 28 sites, no read added;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: copies Probes.Egress and Probes.SizeCommittedMiB into BoxMetrics (private, like Layout) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3: comment only, the Hibernate count is left as is (display);rev3=census-ruling-regional-domains-447;basis=#447 Task 7: copies Probes.AliasesRead into BoxMetrics.AliasesRead (json aliases_read, omitempty) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-fleet-alerts-1;basis=copies Probes.DiskFullETAHours into BoxMetrics.DiskFullETAHours (json disk_full_eta_hours, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added;rev3=census-ruling-edge-held-streams;basis=copies Probes.HeldStreams into BoxMetrics.HeldStreams (json held_streams, omitempty, additive) and counts it in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: carry already-supplied ReplicaCopies into a separate optional private BoxMetrics replica_copies field; allow copy evidence alone to create the metrics block. Upstreams retains address probes only. Existing 28 Route read sites unchanged; no filesystem, bucket, console or CLI read.;rev3=census-ruling-agent-start-demo-3;basis=Report claim-seed protocol capability only when explicitly configured and runtime moved readiness only when armed; dormant status keeps its original JSON shape. Census read-site delta: unchanged (28).;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 (#511 R16 and its amendment): copies Probes.PrevRelease and Probes.ApplyFinished into BoxMetrics (json prev_release and apply_finished, omitempty; private, like Release) and counts them in the condition that builds Metrics; the same 28 sites, no read added.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: copies Probes.OfflineMove into BoxMetrics.OfflineMove (json offline_move, omitempty; private, like Layout) and counts it in the condition that builds Metrics; the same 28 sites, no read added. registry:Alias@4543,registry:CertExpiresAt@3160,registry:CertExpiresAt@3396,registry:CertExpiresAt@4658,registry:DBPath@2495,registry:DBPath@2553,registry:DNSCheckedAt@3365,registry:DNSCheckedAt@4627,registry:DNSStatus@3139,registry:DNSStatus@3334,registry:DNSStatus@4597,registry:Hibernate@3853,registry:Host@2295,registry:Host@2437,registry:Host@2666,registry:Host@3280,registry:Host@3315,registry:Host@4578,registry:Kind@2473,registry:Kind@3807,registry:Platform@2152,registry:ServingVersion@2324,registry:ServingVersion@2447,registry:Socket@4066,registry:Version@2186,registry:Version@2305,whole:Route@1581,whole:RouteAlias@4440 32791b85240b09b4c70694b6cc07cddf1f657838f35072544ffe08e25c93be09
+internal/host/movesoffline_facts.go movesWorker.offlineMoveFacts legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1: item 4 cut, P1-1, P1-3): returns nil under euid 0 before touching the disk. Otherwise lists only the names of <opt>/live (root-owned, 0755; every name made by root PointLive for a host its registry held) through readNamesBounded; no entry is stat'd, followed or opened, and nothing under the .instances tree or any tenant path is read. Reports at most 128 unrouted hostnames and 8 KiB of them, with an overflow flag past those or the 4096-name scan bound. Agent only (user carlos); changes nothing; root never reads the report. registry:Host@261,whole:Route@243 faf46d977778900a12fcb0bd3d8aba94e9e227a166af4fb489af012e0c0a83c1
+internal/host/movesoffline_facts.go offlineMoveFactsProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1 P1-1): the armed moves worker's offlineMoveFacts over the status tick's routes with os.Geteuid(); nil when none is armed, the box is not offline-capable, or the agent runs as root (refused before any filesystem access). whole:Route@128 3ca4f5b13ed40f19e642093e27c0b254080fd724eb123c8daa342d26d19433f8
+internal/host/movesoffline_facts.go readNamesBounded legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339 (round 1 P1-3): os.Open of the directory and Readdirnames in batches, at most max names (getdents only: nothing stat'd or followed), and whether more remain; a missing directory has no names. Agent only, read only. file:Open@95,file:Readdirnames@279,file:Readdirnames@485 48773914dfdc133ba845b7855486d6151c0752f4b6bd80f73e71abf9e831222e
+internal/host/agent.go statusLoop legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's context carries the box's lifetime judge; read sites unchanged, offsets moved;rev3=census-ruling-rootfs-apps-2;basis=main's body as of the merge of origin/main 953b9fda (its later changes, regional box names and self-serve moves plan 1 among them, under main's own census rulings), where the tick fills rootfs_ready and rootfs_blocked from armedRootfs.Load().probe, which each tick runs NestedOK's checks and asks the control socket's GET /ready/rootfs (never the store); the same four direct sites;rev3=census-ruling-instance-egress-sizes-328-329;basis=#328 plan 2 Task 11 and #329 plan 3 Task 7: takes root's GET /egress reader and fills p.Egress = egressStatusProbe(egressStatus, routes, provision.PolicyReadStates()) and p.SizeCommittedMiB = sizeCommittedMiB(armedSizeSource.Load(), routes); the two added whole:Route sites are the tick's own registry list handed to those two units (decision rows), which read root's control socket and the activator's memory; no store request added; the four existing sites unchanged, offsets moved.;rev3=census-ruling-fleet-alerts-1;basis=the agent (carlos-edge.service, user carlos): the status tick passes os.Geteuid() to alertDeliveryProbe, which fills AlertDelivery.EngineBeat/EngineBeatWhy from engineBeatArmed (the env value and the euid only, no file access, root refused before the path is looked at), and fills Probes.DiskFullETAHours from diskETAProbe(&processDiskTrend, now), a Theil-Sen fit over the metrics loop's in-memory ring of disk readings; the same six sites, no read added, no store request added;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): the status tick's Probes gain HeldStreams: heldStreamsState(), which calls the edge's in-memory counters function (nil until the edge is ready). No file, bucket or registry access added.;rev3=census-ruling-stateless-replicas-3;basis=Fix round 1 Q20: read the detached in-memory replica snapshot source into Probes.ReplicaCopies on the existing five-minute tick. Existing six direct read sites unchanged. No additional bucket request, changed cadence or app lifecycle action.;rev3=census-ruling-agent-start-demo-3;basis=Report moved capability only when the serving edge reports readiness; report claim-seed support only with CARLOS_DEMO_CLAIM=1. Reads the explicit capability flag from the process environment; no new filesystem or registry read.;rev3=census-ruling-stateless-replicas-4-task5;basis=Task 5 fix round 1 (#511 R16 amendment): the status tick also fills Probes.ApplyFinished from systemApplyFinished(release.OptDir()), an Lstat of root's apply journal <opt>/system/router/journal.json in the root-owned, world-readable state directory: finished only when the journal is absent, any other answer unknown and so unfinished. Round 0: Probes.PrevRelease from prevReleaseOf (carlos.prev and carlos.prev.version, the files withMovesFields already reads). Reported in the private BoxMetrics block; no bucket request or cadence change.;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the agent (carlos-edge.service, user carlos): the status tick fills p.OfflineMove = offlineMoveFactsProbe(routes); the added whole:Route site is the tick's own registry list handed to that unit, which under a non-root euid lists the names of root's <opt>/live and nothing else; no store request added. whole:Route@10554,whole:Route@12368,whole:Route@12649,whole:Route@13007,whole:Route@6583,whole:Route@6610,whole:Route@7918 d31679b7894515917fe6fff0181b1e05d3507e042fc6952f557c8b3bed453783
+@coverage . 3bbbac33b39ea2533731fafb1c1f1a2e21f206ab6a8784469905f1da29596e35
+@coverage internal/host 207c76a96e63f14af1f170282d6f3b488b5fd6490c22ee027d00c0feb0eed1c0
+@coverage internal/status b133ac8995f6ef0123394e2d0611304aa37f11409b1e14ae67a43e1ed3bf2469
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go
index 8c672eab7..cee5ea4f5 100644
--- a/internal/status/contract_test.go
+++ b/internal/status/contract_test.go
@@ -83,7 +83,7 @@ var allowedBoxKeys = map[string][]string{
"routes": {"static", "resident", "hibernating", "awake", "asleep"},
"replication": {"healthy", "lag_seconds"},
// capabilities names supported protocols only, in the bucket-private metrics.
- "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib"},
+ "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib", "offline_move"},
"metrics.route_versions": {wildcardAnyKey},
"metrics.upstreams": {wildcardAnyKey},
"metrics.upstreams.*[]": {"addr", "up", "since", "fails", "last_error"},
@@ -116,6 +116,10 @@ var allowedBoxKeys = map[string][]string{
// in the private block only; the values are pinned to the field level.
"metrics.egress": {wildcardAnyKey},
"metrics.egress.*": {"allowed", "refused", "state", "detail"},
+ // offline_move (#339) is what an offline move's stage and start doors
+ // read: the hosts this box keeps a stale live link for, bounded, and
+ // whether it holds more. Private block only, pinned to the field level.
+ "metrics.offline_move": {"stale_live_links", "stale_live_links_overflow"},
}
// allowedFleetKeys are THE schema for Fleet's JSON output. Same friction as
@@ -386,6 +390,9 @@ func fixtureProbes() status.Probes {
// The committed figure, so metrics.size_committed_mib is exercised
// by the allowlist walk too (#329).
SizeCommittedMiB: &sizeCommitted,
+ // The offline move facts, so metrics.offline_move is exercised by
+ // the allowlist walk too (#339).
+ OfflineMove: &status.OfflineMoveFacts{StaleLiveLinks: []string{"contract-left.internal"}, StaleLiveLinksOverflow: true},
ConfigGuard: "bypassed (CARLOS_NO_SEALED_CONFIG)",
MemFrac: &memFrac,
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index f81d61f59..a8ba12dc2 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -229,8 +229,39 @@ type Probes struct {
// SizeCommittedMiB is the sum, in MiB, of the sizes this box's awake
// instances run at (#329, spec §5.5), or nil with no activator armed.
SizeCommittedMiB *int64
+ // OfflineMove is what this box tells an offline move's stage and start
+ // doors while the instance still serves (#339), or nil when the box
+ // cannot take part in an offline move or cannot say. Private Metrics
+ // only: it names hosts.
+ OfflineMove *OfflineMoveFacts
}
+// OfflineMoveFacts is what a box that can take part in an offline move
+// reports about its own disk for the console's stage and start doors
+// (#339): a live link it keeps for a host it has no row for, which would
+// otherwise refuse the move only at flip, with the instance offline.
+// Present (even empty) means the box looked; absent is a box that cannot
+// say, which the doors read as saying nothing.
+type OfflineMoveFacts struct {
+ // StaleLiveLinks are the hosts this box keeps a live link for
+ // (<opt>/live/<host>) with no route row here: what a box the instance
+ // once left keeps, root-owned. Sorted, and bounded: at most
+ // MaxStaleLiveLinks names and MaxStaleLiveLinkBytes bytes of them.
+ StaleLiveLinks []string `json:"stale_live_links,omitempty"`
+ // StaleLiveLinksOverflow says the box holds more than it reports
+ // (StaleLiveLinks is then a partial list), or stopped listing early.
+ // A door cannot tell from it that a host has no link.
+ StaleLiveLinksOverflow bool `json:"stale_live_links_overflow,omitempty"`
+}
+
+// The bounds on OfflineMoveFacts.StaleLiveLinks, which keep a box report
+// far below the reader's per-report cap (maxFleetBoxBodyBytes) whatever a
+// box holds: past either, the box sets StaleLiveLinksOverflow.
+const (
+ MaxStaleLiveLinks = 128
+ MaxStaleLiveLinkBytes = 8 << 10
+)
+
// HostEgress is one instance's egress read-back (#328, spec §4.4): the
// addresses its slice holds, the entries refused and why, and a state word
// with its detail when the allow is not simply in force. Everything is
@@ -777,6 +808,11 @@ type BoxMetrics struct {
// promised, beside MemTotalBytes and MemAvailBytes. Information for the
// console's size door, never a gate. Omitted with no activator armed.
SizeCommittedMiB *int64 `json:"size_committed_mib,omitempty"`
+ // OfflineMove is the box's offline move facts (#339, Probes.OfflineMove):
+ // the hosts it keeps a stale live link for. Hostname-bearing and private
+ // like RouteVersions. Omitted on a box that cannot take part in an
+ // offline move.
+ OfflineMove *OfflineMoveFacts `json:"offline_move,omitempty"`
}
// UpdateSettingsProtocol is the BoxMetrics.UpdateSettings a binary reports
@@ -1218,7 +1254,8 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
len(routeVersions) > 0 || len(routeServing) > 0 || len(aliasReadings) > 0 || p.AliasesRead || len(p.Upstreams) > 0 || len(p.ReplicaCopies) > 0 ||
len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" ||
p.Alerts != nil || p.GeoIP != nil || p.HeldStreams != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" ||
- p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil {
+ p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil ||
+ p.OfflineMove != nil {
var capabilities []string
if p.DemoClaimSeedReady {
capabilities = append(capabilities, seeds.DemoClaimCapability)
@@ -1276,6 +1313,7 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box {
Egress: p.Egress,
SizeCommittedMiB: p.SizeCommittedMiB,
+ OfflineMove: p.OfflineMove,
}
}
diff --git a/internal/status/snapshot_test.go b/internal/status/snapshot_test.go
index 95aafe5a3..7d3447d2c 100644
--- a/internal/status/snapshot_test.go
+++ b/internal/status/snapshot_test.go
@@ -447,3 +447,26 @@ func TestDemoClaimSeedCapabilityConfigured(t *testing.T) {
t.Fatal("dormant claim changed status JSON")
}
}
+
+// TestCollectBoxCarriesOfflineMoveFacts pins Probes.OfflineMove (#339): the
+// facts reach the private Metrics block as offline_move, and an empty
+// report (the box looked and found nothing) is still published, so a door
+// can tell it from a box that cannot say.
+func TestCollectBoxCarriesOfflineMoveFacts(t *testing.T) {
+ at := time.Date(2026, 11, 13, 9, 0, 0, 0, time.UTC)
+ facts := &OfflineMoveFacts{StaleLiveLinks: []string{"left.example.com"}, StaleLiveLinksOverflow: true}
+ b := CollectBox(nil, Probes{OfflineMove: facts}, at)
+ if b.Metrics == nil || b.Metrics.OfflineMove != facts {
+ t.Fatalf("metrics = %+v, want the offline move facts", b.Metrics)
+ }
+ out, err := json.Marshal(CollectBox(nil, Probes{OfflineMove: &OfflineMoveFacts{}}, at))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(out), `"offline_move":{}`) {
+ t.Fatalf("an empty report is not published: %s", out)
+ }
+ if b := CollectBox(nil, Probes{}, at); b.Metrics != nil {
+ t.Fatalf("no facts and nothing else known must mean no metrics block: %+v", b.Metrics)
+ }
+}
diff --git a/move.go b/move.go
index 29d6eb566..a897a2d3f 100644
--- a/move.go
+++ b/move.go
@@ -1498,6 +1498,17 @@ func (w *offlineRun) headline(r offlineReply) {
w.sayWaiting(r)
return
}
+ if v.State == provision.OfflineReverting && v.NeverOffline {
+ // An abort from staging: nothing moved and nothing comes back,
+ // only the staged copy goes (#339).
+ moveSay(w.m.out, fmt.Sprintf("Nothing moved. The stage of %s was abandoned, and %s kept serving in %s.", host, host, v.fromPlace()))
+ if v.Next == "finish" {
+ moveSay(w.m.out, fmt.Sprintf("The staged copy of %s is removed. Run carlos move offline finish --host %s to end the move.", host, host))
+ } else {
+ moveSay(w.m.out, fmt.Sprintf("Removing the staged copy of %s from %s.", host, v.toPlace()))
+ }
+ return
+ }
moveSay(w.m.out, moves.MoveStartingLine(host, v.fromPlace(), v.toPlace()))
if w.sayFailure(v) {
return
@@ -1600,6 +1611,11 @@ func (w *offlineRun) runStatus(ctx context.Context) int {
}
failed := false
for _, it := range v.Items {
+ if v.NeverOffline {
+ // Nothing of the manifest is checked for a move that never
+ // went offline; an older console still sends the items.
+ break
+ }
if it.Diagnostic == "" {
moveSay(w.m.out, fmt.Sprintf("Item %s is %s.", it.Slug, it.Check))
} else {
diff --git a/move_test.go b/move_test.go
index d64b063e4..be2a38120 100644
--- a/move_test.go
+++ b/move_test.go
@@ -1914,6 +1914,30 @@ func TestMoveOfflineAbortStaged(t *testing.T) {
}
}
+// status after an abort from staging (#339, item 2): nothing moved, so it
+// says so, and lists no item as waiting even from a console that still
+// sends the manifest's items.
+func TestMoveOfflineStatusAfterAStagedAbort(t *testing.T) {
+ const nothing = "Nothing moved. The stage of acme.shop.example.com was abandoned, and acme.shop.example.com kept serving in ie."
+ items := []frame{{"id": "db", "owner": "landing", "status": "waiting"}, {"id": "files", "owner": "landing", "status": "waiting"}}
+ c := &fakeOfflineConsole{gets: []frame{offView("offline-reverting", frame{"never_offline": true, "sealer": "", "items": items,
+ "reports": []frame{offReport("ie-box", "source", "reverted", true)}})}}
+ code, out := runOfflineAgainst(t, c, "status")
+ if want := nothing + "\n" + oUnstage + "\nie-box is reverted as the source.\n"; code != 0 || out != want {
+ t.Fatalf("exit %d, output:\n%s\nwant 0:\n%s", code, out, want)
+ }
+ c = &fakeOfflineConsole{gets: []frame{offView("offline-reverting", frame{"never_offline": true, "sealer": "", "next": "finish", "items": items})}}
+ code, out = runOfflineAgainst(t, c, "status")
+ if want := nothing + "\n" + oUnstaged + "\n"; code != 0 || out != want {
+ t.Fatalf("exit %d, output:\n%s\nwant 0:\n%s", code, out, want)
+ }
+ for _, line := range []string{oStarting, oBack, "Item "} {
+ if strings.Contains(out, line) {
+ t.Fatalf("the status of a staged abort says %q:\n%s", line, out)
+ }
+ }
+}
+
// TestMoveLinesNameRegionsByLabel: surface 25. Labels in every sentence,
// the request still sends the code.
func TestMoveLinesNameRegionsByLabel(t *testing.T) {