offline move #339 round 1: cut app dirs, bound and gate the link probe
Astra round 1 (3 P1, 4 P2) and the controller's cut: - item 4 (app directories) is cut: its report, refusal (MV-O201), tests and the offlineFilesAt split are gone; the seal is main's. - P1-1: the live-link probe returns nil under euid 0 before any filesystem access. - P1-3: it reads only the names of root's <opt>/live (getdents, nothing stat'd or followed), at most 4096, and reports at most 128 names and 8 KiB with an overflow flag; the doors refuse on overflow (MV-O204). - P2-4: the staging status view runs the same check before next start. - P2-5: the refusals print only the record's host and the box name. - P2-6: MV-O200 states the fact and the policy; MV-O203 is Luna's text without the directories clause. Copy rows pending. - P2-7: the runbook scopes the new status line to before finish. - The E2E reports through offlineMoveFactsProbe and fails if statusLoop stops assigning it. Census overlay re-proposed under the same name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
approved_moves_copy_test.go+1 −1docs/site/cli.md+1 −1docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md+5 −8docs/superpowers/plans/2026-10-06-moves-phase1-copy.md+4 −4docs/superpowers/plans/2026-10-21-offline-move-runbook.md+5 −5docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-REFUSALS-339-R1.md+59 −0internal/console/apiinstancemove_offline.go+4 −1internal/console/apiinstancemove_offline_facts.go+17 −26internal/console/apiinstancemove_offline_stage_test.go+38 −51internal/console/apiinstancemove_offline_test.go+5 −6internal/host/movesoffline_e2e_test.go+60 −41internal/host/movesoffline_facts.go+72 −67internal/host/movesoffline_facts_test.go+123 −0internal/host/movesoffline_seal.go+10 −23internal/provision/testdata/plan14-root-reads-chain.tsv+1 −1internal/provision/testdata/plan14-root-reads-offline-move-stage-refusals-339.tsv+12 −16internal/status/contract_test.go+4 −10internal/status/snapshot.go+22 −20internal/status/snapshot_test.go+1 −4
CI cancelled — superseded by a newer push — run details
Intent
<task-notification> <task-id>buwuq4zv4</task-id> <tool-use-id>toolu_0117NN418FGVd97xbZ7R8R7H</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/buwuq4zv4.output</output-file> <status>completed</status> <summary>Background command "Describe branch and run Astra review of #339" completed (exit code 0)</summary> </task-notification>
<task-notification> <task-id>a5ef49b8d47227ee5</task-id> <tool-use-id>toolu_01KeTG15pBpbxnRGekH4M3Rz</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a5ef49b8d47227ee5.output</output-file> <status>completed</status> <summary>Agent "Implement #413 offline move pool target" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>The hang is fixed on branch `offline-move-pool-target-413`, as four local commits. Nothing is pushed or posted. The census overlay is written but still needs an independent reviewer's verdict before merge. **Root cause.** The open door required exactly one target report (`internal/console/apiinstancemove_offline.go:1117`, same rule in finish at :1156). On the box side, any box in the destination region took the target role whatever its pools (`internal/host/movesoffline.go:424`). Leo serves only cohort1, so reconcile never gives it the row, yet it kept writing a target report that could never be ready. Two reports meant open never became the next step, so `flip`, which waits until open is ready, never returned. **Fix.** - **Pin:** start, direct or staged, now records the one eligible box as `move.target_box` (new `provision.OfflineTargeted`). The field is additive. The record had no target pin to reuse; I pin at start, not at stage, because staging copies to a bucket, not a box. - **Console:** open, finish, the item list and the failed flag read only the pinned box's report. A move started before this change reads all target reports, as before. - **Box:** a box takes the target role only if its `CARLOS_POOLS` admit the record and it is the pinned box, or nothing is pinned. - **Gate:** "exactly one box" already counted only eligible boxes. A region with none now gets its own sentence instead of "uk has 0 boxes". Two eligible boxes still refuse as before. **Tests.** Each was written first and failed on the old code. - `TestOfflineMoveE2E/a_pool_box_beside_the_target` adds `uk-pool` (cohort1). On the old code it stopped at offline-landed with no next step, exactly as on dev. - `TestOfflineWaitsOnlyForThePinnedTarget` (console door test). - `TestOfflineStageCountsOnlyBoxesThatCanHoldTheRow`: a region with only a pool box is refused at stage, with nothing written. - New `TestOfflineStartRefusals` cases, including two shared boxes beside a pool box, which still refuses. - `TestOfflineTargetIsThePinnedBoxThatCanHoldTheRow` (host) and `TestOfflineTargetedPinsTheTargetBox` (provision). Runs, all ok: - `go test ./internal/console/ -run Offline` - `./internal/host/ -run 'Offline|MovesOffline'` - `./internal/provision/ -run 'Offline|Move|Census'` - `./internal/moves/` - root `-run 'TestMoves|TestPendingCopy|Offline'` gofmt and vet are clean, and `go build ./...` plus the darwin and windows builds pass. `TestClaimServingAssemblyWithoutMoves` (host) fails here with or without my changes ("lifecycle provider unavailable"), so it is not caused by this branch. **Mutation checks.** I disabled each guard once (13 in all: the console report filter in each place it is used, both start pins, the empty-region refusal, the box's pool and pin checks, its call site, the pool setting, and the provision checks). Each made its test fail, and the code was restored. **Census.** `TestPlan14RootReadCensus` failed as expected. Overlay `plan14-root-reads-offline-move-pool-target-413.tsv` and its card are committed, with one claim on `armOffline` (no new read), and the census tests pass. Nothing posted on #280. **New string** (row MV-O194, pending): `<region> has no box that can take <host>. an offline move needs one box there that hibernates and serves the shared pool`. The copy gate's scanner does not see sentences built this way (MV-O22 next to it is missed too), so I added the row and its inventory entry by hand. The runbook fleet check got one bullet; `docs/site/cli.md` needed nothing. **Commits:** - `7264b0d1` provision - `2725ae64` console - `6510229e` host + census - `4ecf608d` runbook **Unsure:** - Boxes with `CARLOS_INBOUND=none` probably can't hold the row either, but the console doesn't exclude them; I left that alone. - If the pinned box is replaced mid-move, open waits until the operator aborts. - Moves started before this change still read every target report, including any a pool box already wrote. - Pool boxes in the source region still write source reports, which the doors ignore. Files are in `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413`: - `internal/console/apiinstancemove_offline.go` - `internal/host/movesoffline.go` - `internal/host/movespass.go` - `internal/provision/offline_move.go` - `internal/provision/provision.go`</result> <usage><subagent_tokens>313717</subagent_tokens><tool_uses>107</tool_uses><duration_ms>2665578</duration_ms></usage> </task-notification>
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go| index dc09e006f..ce7f73f23 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -112,7 +112,7 @@ var movesCopyIDs = []string{ |
| "MV-O193", |
| // #339: refused while the instance still serves, and status after an |
| // abort from staging. |
| - "MV-O200", "MV-O201", "MV-O202", "MV-O203", |
| + "MV-O200", "MV-O202", "MV-O203", "MV-O204", |
| } |
| // copyRow is one row of the record. The File cell is the file the sentence is |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index de24fb86d..df99e0ed4 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -3385,7 +3385,7 @@ 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 a move that would fail after the instance goes offline: when the box in the target region still holds a live link for the instance from an earlier time it ran there, or when the instance keeps directories beside its files directory, which the move cannot carry. Each refusal names the box and what it found. |
| +`stage` and `start` refuse a move that would fail after the instance goes offline: when a box in the target region still holds a live link for the instance from an earlier time it ran there. Each refusal names the box and what it found. |
| ## On the host |
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| index 44395df29..74b2b994c 100644 |
| --- a/docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md |
| +++ b/docs/superpowers/notes/census-proposal-offline-move-stage-refusals-339.md |
| @@ -1,12 +1,11 @@ |
| # Census approval: offline-move-stage-refusals-339 |
| -Ruling `census-ruling-offline-move-stage-refusals-339`. The independent reviewer approves or rejects every change below, 4 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| +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 lists <opt>/live and each instance-kind row's instance directory (agent-readable, read only, nothing followed or changed); no store request added. | |
| -| `internal/host/movesoffline_seal.go` `movesWorker.offlineFilesOf` | sites | -file:ReadDir, -whole:Route | #339: the body moved to offlineFilesAt unchanged (nested ReadDir, flat FlatLeftovers); offlineFilesOf now passes its registry host listing as a closure. Sites moved, none added; the seal's refusal is unchanged. | |
| +| `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`. |
| @@ -16,15 +15,13 @@ 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. |
| -- `internal/host/movesoffline_seal.go` `movesWorker.offlineFilesOf`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-moves-offline;basis=route-and-input (J1,J4, as main's sourceFinal.run); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, reads the row and lists the nested instance directory for the files, env and config paths; an app entry beside the files directory refuses the seal |
| New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| -- new `internal/host/movesoffline_facts.go:emptyDir`: reads +file:Lstat, +file:Open, +file:Readdirnames; written legacy, accepted-legacy, frozen |
| -- new `internal/host/movesoffline_facts.go:movesWorker.offlineMoveFacts`: reads +file:ReadDir, +registry:Host ×6, +registry:Kind, +whole:Route ×5; written legacy, accepted-legacy, frozen |
| +- 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_seal.go:offlineFilesAt`: reads +file:ReadDir, +whole:Route ×2; 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` → `71e5cd60dda695b6ce12a2ec95b0f9ca3c0ee98561f0333570a9ebb4668924ec`. |
| +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 c52484885..d636bd2db 100644 |
| --- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| +++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| @@ -721,11 +721,11 @@ Three more console door refusals for a staged move (`internal/console/apiinstanc |
| ## Offline move: refused while the instance still serves (#339) |
| -Two things failed an offline move only after `start` had taken the instance offline (amadan #339, items 1 and 4): a live link the target box still kept for the host from an earlier time it ran there, which fails the landing's `release` item at `flip` (MV-O177), and directories the instance keeps beside its files directory, which the seal refuses (MV-O76). Each box now reports both in its status report while the instance serves, and the `stage` and `start` doors refuse first (branch `offline-move-stage-refusals-339`). MV-O200 and MV-O201 are those door refusals (`internal/console/apiinstancemove_offline_facts.go`), lower case like the other door sentences. In MV-O200 `<box>` is the target box. In MV-O201 `<dirs>` are the entries' paths on the source box `<box>`, joined with ", ", each followed by " (empty)" when it is an empty directory. 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: nothing moved. It is followed by MV-O187 or MV-O188. MV-O203 is the CLI page's paragraph for the two refusals. The ids start at 200 so that another branch's rows from 194 do not collide. Pending a copy review. |
| +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. Luna approved MV-O200 and MV-O202 in their first wording; MV-O200 is reworded, so MV-O200, MV-O203 and MV-O204 are pending a copy review. |
| | 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. the move would fail at flip, after <host> is offline. see the offline move runbook | pending | |
| -| MV-O201 | internal/console/apiinstancemove_offline_facts.go | <host> keeps <dirs> beside its files directory on <box>, and this move can carry only the files directory. see the offline move runbook | pending | |
| +| MV-O200 | internal/console/apiinstancemove_offline_facts.go | <box> still holds a live link for <host> from when it last ran there. stage refuses until it is cleared, since a mismatched link fails the move only after <host> is offline. see the offline move runbook | pending | |
| | MV-O202 | move.go | Nothing moved. The stage of <host> was abandoned, and <host> kept serving in <from>. | pending | |
| -| MV-O203 | docs/site/cli.md | `stage` and `start` refuse a move that would fail after the instance goes offline: when the box in the target region still holds a live link for the instance from an earlier time it ran there, or when the instance keeps directories beside its files directory, which the move cannot carry. Each refusal names the box and what it found. | pending | |
| +| MV-O203 | docs/site/cli.md | `stage` and `start` refuse a move that would fail after the instance goes offline: when a box in the target region still holds a live link for the instance from an earlier time it ran there. Each refusal names the box and what it found. | pending | |
| +| MV-O204 | internal/console/apiinstancemove_offline_facts.go | <box> holds more live links than it can report, so stage cannot tell whether one is for <host>. see the offline move runbook | pending | |
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 596d586d1..a8027c3f7 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. From the release carrying the #339 fix, `stage` and `start` refuse such a link, and app directories beside the files directory, while the instance still serves; on an older release section 3 is the only check. |
| +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,13 +166,13 @@ 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; 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). From the release carrying the #339 fix, the source box reports such directories and `stage` and `start` refuse with "<host> keeps <dirs> beside its files directory on <box>, and this move can carry only the files directory. see the offline move runbook" (exit 5), each directory marked "(empty)" when it is empty, before the instance goes offline. 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. the move would fail at flip, after <host> is offline. see the offline move runbook" (exit 5), before anything goes offline. The doors refuse any such link, even one that names the build the instance runs. 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. |
| +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 refuses 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 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")" |
| @@ -245,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 "Nothing moved. The stage of shop.example.com was abandoned, and shop.example.com kept serving in ie." and lists no items. A CLI older than the #339 fix prints "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. |
| +- `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. |
| --- |
| @@ -458,7 +458,7 @@ A retry is a new move, staged from scratch, after section 3 passes again. |
| ## 12. Known gaps |
| -- **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`, and app directories beside the files directory fail `seal` (exit 4) only after `start`; sections 3.2 and 3.3 are the workaround. With the fix, `stage` and `start` refuse both before anything goes offline, but there is still no supported way to clear a stale link (root by hand, section 3.3) and no way to carry app directories, empty ones included. 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-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/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index 3ccf034a7..46db68bfb 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -572,7 +572,7 @@ func (s *Server) offlineBeginChecks(w http.ResponseWriter, r *http.Request, d of |
| writeRefusal(w, ref) |
| return "", offlineFleet{}, false |
| } |
| - if ref := offlineBoxFacts(fleet, host, rec.Region, to); ref != nil { |
| + if ref := offlineBoxFacts(fleet, host, to); ref != nil { |
| writeRefusal(w, ref) |
| return "", offlineFleet{}, false |
| } |
| @@ -945,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 |
| } |
diff --git a/internal/console/apiinstancemove_offline_facts.go b/internal/console/apiinstancemove_offline_facts.go| index b800a6c8b..d40f716b6 100644 |
| --- a/internal/console/apiinstancemove_offline_facts.go |
| +++ b/internal/console/apiinstancemove_offline_facts.go |
| @@ -4,42 +4,33 @@ import ( |
| "fmt" |
| "net/http" |
| "slices" |
| - "strings" |
| ) |
| -// offlineBoxFacts refuses a start or a stage that a box's own report says |
| -// would fail after the instance is offline (#339): a live link the target |
| -// box still holds for the host, which fails the landing's release item at |
| -// flip, and entries beside the instance's files directory on a source box, |
| -// which the seal refuses. Both are read from the boxes' status reports |
| -// (status.OfflineMoveFacts), which each box writes while the instance still |
| -// serves. A box whose report carries no facts says nothing, and the landing |
| -// and the seal keep their own refusals behind this one. offlineSelect has |
| -// already required exactly one target box. |
| -func offlineBoxFacts(f offlineFleet, host, from, to string) *offlineRefusal { |
| +// 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. the move would fail at flip, after %s is offline. see the offline move runbook", b.Box, host, host)} |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s still holds a live link for %s from when it last ran there. stage refuses 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)} |
| } |
| - } |
| - for _, b := range f.boxesAt(from) { |
| - m := f.metrics[b.Box] |
| - if m == nil || m.OfflineMove == nil || len(m.OfflineMove.AppDirs[host]) == 0 { |
| - continue |
| - } |
| - var dirs []string |
| - for _, d := range m.OfflineMove.AppDirs[host] { |
| - if d.Empty { |
| - dirs = append(dirs, d.Path+" (empty)") |
| - } else { |
| - dirs = append(dirs, d.Path) |
| - } |
| + if m.OfflineMove.StaleLiveLinksOverflow { |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s holds more live links than it can report, so stage cannot tell whether one is for %s. see the offline move runbook", b.Box, host)} |
| } |
| - return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s keeps %s beside its files directory on %s, and this move can carry only the files directory. see the offline move runbook", host, strings.Join(dirs, ", "), b.Box)} |
| } |
| return nil |
| } |
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go| index 47d163778..9a1ccb947 100644 |
| --- a/internal/console/apiinstancemove_offline_stage_test.go |
| +++ b/internal/console/apiinstancemove_offline_stage_test.go |
| @@ -9,7 +9,6 @@ import ( |
| "github.com/carlosframework/platform/internal/moves" |
| "github.com/carlosframework/platform/internal/provision" |
| - "github.com/carlosframework/platform/internal/status" |
| ) |
| // The pre-copy door (offline-staging), in-process against the offline |
| @@ -333,18 +332,19 @@ 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. the move would fail at flip, after " + offlineHost + " is offline. see the offline move runbook" |
| + return box + " still holds a live link for " + offlineHost + " from when it last ran there. stage refuses until it is cleared, since a mismatched link fails the move only after " + offlineHost + " is offline. see the offline move runbook" |
| } |
| -func msgO201(dirs, box string) string { |
| - return offlineHost + " keeps " + dirs + " beside its files directory on " + box + ", and this move can carry only the files directory. see the offline move runbook" |
| +func msgO204(box string) string { |
| + return box + " holds more live links than it can report, so stage 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; a link that appears after the stage refuses the |
| -// start, and the move stays staging until it is gone. |
| +// 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) |
| @@ -357,53 +357,40 @@ func TestOfflineStageAndStartRefuseAStaleLiveLinkOnTheTarget(t *testing.T) { |
| t.Fatal("a refused door took the lock") |
| } |
| - // A link for another host refuses nothing. |
| - w2 := newOfflineWorld(t, ieOff("ie-box"), 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 move stays |
| - // staging, and once the box no longer reports it start goes ahead. |
| - w3 := newOfflineWorld(t, oneEach...) |
| - w3.stage() |
| - w3.fleet(stale) |
| - w3.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, msgO200("uk-box")) |
| - w3.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgO200("uk-box")) |
| - 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) |
| -} |
| + // 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 source box that reports app directories beside the instance's files |
| -// directory would have the seal refuse them, with the instance offline. |
| -// Stage and start refuse first, naming the directories and saying which |
| -// are empty; the seal's own refusal stays as it was. |
| -func TestOfflineStageAndStartRefuseAppDirsBesideTheFiles(t *testing.T) { |
| - dirs := map[string][]status.AppDir{offlineHost: {{Path: "/data/.instances/i/blobs"}, {Path: "/data/.instances/i/documents", Empty: true}}} |
| - src := offlineBox{Box: "ie-b", Placement: "ie", Bucket: "data-ie", AppDirs: dirs} |
| - want := msgO201("/data/.instances/i/blobs, /data/.instances/i/documents (empty)", "ie-b") |
| - w := newOfflineWorld(t, ieOff("ie-a"), src, ukOff("uk-box")) |
| - w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, want) |
| - w.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, want) |
| - 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") |
| - } |
| - |
| - // Another host's directories refuse nothing. |
| - w2 := newOfflineWorld(t, offlineBox{Box: "ie-a", Placement: "ie", Bucket: "data-ie", |
| - AppDirs: map[string][]status.AppDir{"other.shop.example.com": {{Path: "/data/.instances/o/blobs"}}}}, ukOff("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 directories appear after the stage: start refuses. |
| - w3 := newOfflineWorld(t, ieOff("ie-a"), ieOff("ie-b"), ukOff("uk-box")) |
| - w3.stage() |
| - w3.fleet(src) |
| - w3.refused(http.MethodPost, "", `{"region":"uk"}`, http.StatusConflict, want) |
| - if rec := w3.record(); rec.Move.State != provision.OfflineStaging { |
| - t.Fatalf("after a refused start the move is %s", rec.Move.State) |
| + // 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 eb953119b..c1fcfb622 100644 |
| --- a/internal/console/apiinstancemove_offline_test.go |
| +++ b/internal/console/apiinstancemove_offline_test.go |
| @@ -73,11 +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 AppDirs are the box's offline move facts (#339): the |
| - // hosts it keeps a stale live link for, and per host the entries beside |
| - // its files directory. |
| - LiveLinks []string |
| - AppDirs map[string][]status.AppDir |
| + // 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"} } |
| @@ -172,7 +171,7 @@ func (w *offlineWorld) fleet(boxes ...offlineBox) { |
| sb := status.Box{Label: b.Box, GeneratedAt: time.Now()} |
| if !b.NoMetrics { |
| sb.Metrics = &status.BoxMetrics{HostClaimEnabled: b.ClaimsOn, |
| - OfflineMove: &status.OfflineMoveFacts{StaleLiveLinks: b.LiveLinks, AppDirs: b.AppDirs}} |
| + 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/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go| index 8a09f4bf1..671349fea 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" |
| @@ -388,16 +391,27 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| } |
| // reportStatus writes each box's status snapshot as its status loop does: |
| -// CollectBox over the box's rows with the facts the loop's probe reads from |
| -// the box's worker (offlineMoveFacts, #339), under the box's name. |
| +// 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) |
| } |
| - box := status.CollectBox(routes, status.Probes{OfflineMove: b.w.offlineMoveFacts(routes)}, time.Now()) |
| + 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) |
| @@ -405,6 +419,45 @@ func (w *e2eWorld) reportStatus() { |
| } |
| } |
| +// 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 |
| @@ -1119,10 +1172,10 @@ func TestOfflineMoveE2E(t *testing.T) { |
| // minutes of belief in a report. |
| t.Run("doors back to back", func(t *testing.T) { offlineMoveDoorsApart(t, 0) }) |
| t.Run("doors three minutes apart", func(t *testing.T) { offlineMoveDoorsApart(t, 3*time.Minute) }) |
| - // #339: what failed a move only after the instance was offline is |
| - // refused by stage and start, from the boxes' own status reports. |
| + // #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) |
| - t.Run("stage and start refuse app directories beside the files", offlineRefusesAppDirs) |
| } |
| // requireRefused posts verb and wants a 409 with msg, no write to the |
| @@ -1155,7 +1208,7 @@ 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. the move would fail at flip, after " + offHost + " is offline. see the offline move runbook" |
| + msg := "uk-box still holds a live link for " + offHost + " from when it last ran there. stage refuses 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 { |
| @@ -1175,40 +1228,6 @@ func offlineRefusesAStaleLiveLink(t *testing.T) { |
| } |
| } |
| -// An instance that keeps app directories beside its files directory |
| -// (2026-10-21, #339 item 4): ie-box reports them, and stage and start refuse |
| -// before anything is written, naming each and saying which is empty. Gone, |
| -// the move stages; back after the stage, the start refuses. |
| -func offlineRefusesAppDirs(t *testing.T) { |
| - w := newE2EWorld(t, landOpts{nested: true}) |
| - raw := filepath.Dir(w.srcFiles) |
| - documents, blobs := filepath.Join(raw, "documents"), filepath.Join(raw, "blobs") |
| - if err := os.Mkdir(documents, 0o755); err != nil { |
| - t.Fatal(err) |
| - } |
| - writeFile(t, filepath.Join(blobs, "b"), "blob") |
| - w.reportStatus() |
| - msg := offHost + " keeps " + blobs + ", " + documents + " (empty) beside its files directory on ie-box, and this move can carry only the files directory. see the offline move runbook" |
| - w.requireRefused("stage", msg) |
| - w.requireRefused("", msg) |
| - |
| - for _, p := range []string{documents, blobs} { |
| - if err := os.RemoveAll(p); err != nil { |
| - t.Fatal(err) |
| - } |
| - } |
| - w.reportStatus() |
| - w.accept("stage", `{"region":"uk"}`, provision.OfflineStaging) |
| - if err := os.Mkdir(documents, 0o755); err != nil { |
| - t.Fatal(err) |
| - } |
| - w.reportStatus() |
| - w.requireRefused("", offHost+" keeps "+documents+" (empty) beside its files directory on ie-box, and this move can carry only the files directory. see the offline move runbook") |
| - 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, |
| // and nothing else: each box's fast-converge tick (fastTick, the real serial |
| // rule: a moved serial runs the pass set once per clamp, and a nudge made |
diff --git a/internal/host/movesoffline_facts.go b/internal/host/movesoffline_facts.go| index efc2504c5..4745494af 100644 |
| --- a/internal/host/movesoffline_facts.go |
| +++ b/internal/host/movesoffline_facts.go |
| @@ -15,102 +15,107 @@ import ( |
| ) |
| // What a box tells an offline move's stage and start doors about its own |
| -// disk while every instance on it still serves (#339). Two things refused a |
| -// move only after the instance was offline: a target box's old live link |
| -// for the host (the landing's release item, at flip) and entries an |
| -// instance keeps beside its files directory (the seal). The box reports |
| -// both in its status report, and the doors refuse on them before anything |
| -// goes offline. The landing and the seal keep their own refusals. |
| +// 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. |
| // |
| -// Everything here only lists directories and lstats names. Nothing is |
| -// followed, opened as a file or changed. |
| +// 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 or the box cannot take part in |
| -// an offline move. |
| +// 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) |
| + 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): |
| -// |
| -// - StaleLiveLinks: every name in <opt>/live that is a hostname 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). |
| -// - AppDirs: per instance-kind row, the entries beside its files |
| -// directory, by the seal's own rule (offlineFilesAt), each with whether |
| -// it is an empty directory. |
| +// 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 when the box cannot take part in an offline move, or when a 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) *status.OfflineMoveFacts { |
| - if w == nil || !w.cfg.OfflineCapable || w.cfg.Offline == nil { |
| +// 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 |
| } |
| - facts := &status.OfflineMoveFacts{} |
| routed := map[string]bool{} |
| - hosts := make([]string, 0, len(routes)) |
| for _, rt := range routes { |
| routed[rt.Host] = true |
| - hosts = append(hosts, rt.Host) |
| } |
| optDir := w.cfg.OptDir |
| if optDir == "" { |
| optDir = release.OptDir() |
| } |
| liveDir := filepath.Dir(release.LiveLink(optDir, "host")) |
| - links, err := os.ReadDir(liveDir) |
| - if err != nil && !errors.Is(err, os.ErrNotExist) { |
| + names, more, err := readNamesBounded(liveDir, offlineLiveScanMax) |
| + if err != nil { |
| log.Printf("moves: offline move facts: list %s: %v", liveDir, err) |
| return nil |
| } |
| - for _, e := range links { |
| - if name := e.Name(); controlname.ValidHostShape(name) && !routed[name] { |
| - facts.StaleLiveLinks = append(facts.StaleLiveLinks, name) |
| + facts := &status.OfflineMoveFacts{StaleLiveLinksOverflow: more} |
| + var stale []string |
| + for _, name := range names { |
| + if controlname.ValidHostShape(name) && !routed[name] { |
| + stale = append(stale, name) |
| } |
| } |
| - sort.Strings(facts.StaleLiveLinks) |
| - boxHosts := func() ([]string, error) { return hosts, nil } |
| - for i := range routes { |
| - rt := routes[i] |
| - if rt.Kind != "instance" { |
| - continue |
| - } |
| - _, _, _, stray, err := offlineFilesAt(w.cfg.DataDir, rt.Host, &rt, boxHosts) |
| - if err != nil { |
| - log.Printf("moves: offline move facts: %s: %v", rt.Host, err) |
| - return nil |
| - } |
| - if len(stray) == 0 { |
| - continue |
| - } |
| - sort.Strings(stray) |
| - if facts.AppDirs == nil { |
| - facts.AppDirs = map[string][]status.AppDir{} |
| - } |
| - for _, p := range stray { |
| - facts.AppDirs[rt.Host] = append(facts.AppDirs[rt.Host], status.AppDir{Path: p, Empty: emptyDir(p)}) |
| + 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 |
| } |
| -// emptyDir reports whether p is itself a directory (not a link to one) with |
| -// no entries. Anything it cannot tell is not empty. |
| -func emptyDir(p string) bool { |
| - fi, err := os.Lstat(p) |
| - if err != nil || !fi.IsDir() { |
| - return false |
| - } |
| - f, err := os.Open(p) |
| - if err != nil { |
| - return false |
| +// 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() |
| - _, err = f.Readdirnames(1) |
| - return errors.Is(err, io.EOF) |
| + 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/host/movesoffline_seal.go b/internal/host/movesoffline_seal.go| index 486b25d85..f98559c24 100644 |
| --- a/internal/host/movesoffline_seal.go |
| +++ b/internal/host/movesoffline_seal.go |
| @@ -670,26 +670,7 @@ func sameListing(source map[string]lease.MirrorObject, srcPrefix string, staged |
| // configPath is the rendered configuration beside the env file, which the |
| // effective instance key may come from. |
| func (w *movesWorker) offlineFilesOf(host string, rt *registry.Route) (files, envPath, configPath string, stray []string, err error) { |
| - return offlineFilesAt(w.cfg.DataDir, host, rt, func() ([]string, error) { |
| - var hosts []string |
| - if w.cfg.Registry != nil { |
| - rows, err := w.cfg.Registry.List() |
| - if err != nil { |
| - return nil, err |
| - } |
| - for _, r := range rows { |
| - hosts = append(hosts, r.Host) |
| - } |
| - } |
| - return hosts, nil |
| - }) |
| -} |
| - |
| -// offlineFilesAt is offlineFilesOf under the data directory dd, with the |
| -// box's hosts (which a flat row's leftovers are judged against) read only |
| -// for a flat row. The seal and the box's offline move facts |
| -// (offlineMoveFacts, #339) judge stray entries by this one rule. |
| -func offlineFilesAt(dd, host string, rt *registry.Route, boxHosts func() ([]string, error)) (files, envPath, configPath string, stray []string, err error) { |
| + dd := w.cfg.DataDir |
| platform := func(name string) bool { return layout.IsNestedPlatformName(host, name) } |
| if rt != nil && provision.NestedPaths(dd, *rt) { |
| raw := layout.RawInstanceDir(dd, host) |
| @@ -704,9 +685,15 @@ func offlineFilesAt(dd, host string, rt *registry.Route, boxHosts func() ([]stri |
| } |
| return filepath.Join(raw, host), filepath.Join(raw, host+".env"), filepath.Join(raw, host+".config.env"), stray, nil |
| } |
| - hosts, err := boxHosts() |
| - if err != nil { |
| - return "", "", "", nil, err |
| + var hosts []string |
| + if w.cfg.Registry != nil { |
| + rows, err := w.cfg.Registry.List() |
| + if err != nil { |
| + return "", "", "", nil, err |
| + } |
| + for _, r := range rows { |
| + hosts = append(hosts, r.Host) |
| + } |
| } |
| for _, p := range layout.FlatLeftovers(dd, host, hosts) { |
| if name := filepath.Base(p); !platform(name) && name != host { |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 20498510a..93ce12e38 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -208,4 +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 71e5cd60dda695b6ce12a2ec95b0f9ca3c0ee98561f0333570a9ebb4668924ec |
| +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| index 7ec1a8a85..19fc9e5b4 100644 |
| --- 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 |
| @@ -1,20 +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, 2 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| -# 4 new dispositions: 0 reads re-frozen at their disposition with the claim, 4 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +# 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 5b7bdd41366d5dad04e2696d42f759df43dc8318d2deb83428d81b0fd711e0cc internal/host/movesoffline_facts.go emptyDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: Lstat (no link followed) then Open and Readdirnames(1) of a stray directory to report whether it is empty; agent only, read only. file:Lstat@43,file:Open@116,file:Readdirnames@189 0cba8242519951c3e589abe749242ea6773bbd2e3f8dc87478232fa2d660b5f7 |
| -@legacy 89655072de547e999bdac18d39be0951edecbeba592ef9de477523e5e3d743ea internal/host/movesoffline_facts.go movesWorker.offlineMoveFacts legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: agent only (user carlos): ReadDir of <opt>/live (root-owned, 0755) reporting names that are hostnames with no route row; offlineFilesAt per instance-kind row reporting stray entries. Reports into the private status report; opens, runs or changes nothing; root never reads it. file:ReadDir@516,registry:Host@1082,registry:Host@1175,registry:Host@1393,registry:Host@1425,registry:Host@316,registry:Host@356,registry:Kind@987,whole:Route@1092,whole:Route@269,whole:Route@298,whole:Route@955,whole:Route@972 bd0863123815c36c4eda13707e611a196855321c89de760a94a53509c7cefef6 |
| -@legacy 288380d466e6d44ce0afb55257fbfed74a5a68296a03cdb1b37e2b33800e16c5 internal/host/movesoffline_facts.go offlineMoveFactsProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the armed moves worker's offlineMoveFacts over the status tick's routes; nil when none is armed or the box is not offline-capable. whole:Route@128 790159ee8c2d000c730596e5a9332d7f60f8597ddfa5be999f6c3b58f46d2f8a |
| -@legacy 05f889e3facb9e04ca3b6a15d567d4fe0f9f96d36112fa7731a9b02b42a393c3 internal/host/movesoffline_seal.go offlineFilesAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: offlineFilesOf's former body, verbatim but for the box hosts read through a closure; shared by the seal and offlineMoveFacts so both judge stray entries by one rule. file:ReadDir@350,whole:Route@248,whole:Route@288 ebadb82e4769301403b1bfc1e5f1000ac942e8e1cde754b934c2300a76cc36e4 |
| -@legacy a42863379cbad9a371d51de145bfcc6879e0a1d0fdd51bfccbea414a15069e7f 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 lists <opt>/live and each instance-kind row's instance directory (agent-readable, read only, nothing followed or changed); 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 |
| -@legacy 3617fe8e9b2dabb4797843b5b7126b4d2ce9016c48736f818d394a5c7a601333 internal/host/movesoffline_seal.go movesWorker.offlineFilesOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=route-and-input (J1,J4, as main's sourceFinal.run); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, reads the row and lists the nested instance directory for the files, env and config paths; an app entry beside the files directory refuses the seal;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the body moved to offlineFilesAt unchanged (nested ReadDir, flat FlatLeftovers); offlineFilesOf now passes its registry host listing as a closure. Sites moved, none added; the seal's refusal is unchanged. registry:Host@396,whole:Route@179,whole:Route@363 03b96f80b08c934c6fe86e901e998c5277ea56ddbab6396bea183db555e85784 |
| +@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 emptyDir legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: Lstat (no link followed) then Open and Readdirnames(1) of a stray directory to report whether it is empty; agent only, read only. file:Lstat@43,file:Open@116,file:Readdirnames@189 0cba8242519951c3e589abe749242ea6773bbd2e3f8dc87478232fa2d660b5f7 |
| -internal/host/movesoffline_facts.go movesWorker.offlineMoveFacts legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: agent only (user carlos): ReadDir of <opt>/live (root-owned, 0755) reporting names that are hostnames with no route row; offlineFilesAt per instance-kind row reporting stray entries. Reports into the private status report; opens, runs or changes nothing; root never reads it. file:ReadDir@516,registry:Host@1082,registry:Host@1175,registry:Host@1393,registry:Host@1425,registry:Host@316,registry:Host@356,registry:Kind@987,whole:Route@1092,whole:Route@269,whole:Route@298,whole:Route@955,whole:Route@972 bd0863123815c36c4eda13707e611a196855321c89de760a94a53509c7cefef6 |
| -internal/host/movesoffline_facts.go offlineMoveFactsProbe legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the armed moves worker's offlineMoveFacts over the status tick's routes; nil when none is armed or the box is not offline-capable. whole:Route@128 790159ee8c2d000c730596e5a9332d7f60f8597ddfa5be999f6c3b58f46d2f8a |
| -internal/host/movesoffline_seal.go offlineFilesAt legacy accepted-legacy accepted-legacy;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: offlineFilesOf's former body, verbatim but for the box hosts read through a closure; shared by the seal and offlineMoveFacts so both judge stray entries by one rule. file:ReadDir@350,whole:Route@248,whole:Route@288 ebadb82e4769301403b1bfc1e5f1000ac942e8e1cde754b934c2300a76cc36e4 |
| -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 lists <opt>/live and each instance-kind row's instance directory (agent-readable, read only, nothing followed or changed); 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/host/movesoffline_seal.go movesWorker.offlineFilesOf legacy accepted-legacy accepted-legacy;rev3=census-ruling-moves-offline;basis=route-and-input (J1,J4, as main's sourceFinal.run); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): new, reads the row and lists the nested instance directory for the files, env and config paths; an app entry beside the files directory refuses the seal;rev3=census-ruling-offline-move-stage-refusals-339;basis=#339: the body moved to offlineFilesAt unchanged (nested ReadDir, flat FlatLeftovers); offlineFilesOf now passes its registry host listing as a closure. Sites moved, none added; the seal's refusal is unchanged. registry:Host@396,whole:Route@179,whole:Route@363 03b96f80b08c934c6fe86e901e998c5277ea56ddbab6396bea183db555e85784 |
| +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 87fab05c7a570d55a4084e62628018103638827b4e1801f79935ad1a0a474af7 |
| -@coverage internal/status 28a72a0af5cfdba86a4adf650de8587cb1afe3935caece4c0724890b6dfa6252 |
| +@coverage internal/host 207c76a96e63f14af1f170282d6f3b488b5fd6490c22ee027d00c0feb0eed1c0 |
| +@coverage internal/status b133ac8995f6ef0123394e2d0611304aa37f11409b1e14ae67a43e1ed3bf2469 |
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go| index e628ed5f1..cee5ea4f5 100644 |
| --- a/internal/status/contract_test.go |
| +++ b/internal/status/contract_test.go |
| @@ -117,12 +117,9 @@ var allowedBoxKeys = map[string][]string{ |
| "metrics.egress": {wildcardAnyKey}, |
| "metrics.egress.*": {"allowed", "refused", "state", "detail"}, |
| // offline_move (#339) is what an offline move's stage and start doors |
| - // read: hosts with a stale live link here, and per host the entries |
| - // beside its files directory. Private block only, pinned to the field |
| - // level. |
| - "metrics.offline_move": {"stale_live_links", "app_dirs"}, |
| - "metrics.offline_move.app_dirs": {wildcardAnyKey}, |
| - "metrics.offline_move.app_dirs.*[]": {"path", "empty"}, |
| + // 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 |
| @@ -395,10 +392,7 @@ func fixtureProbes() status.Probes { |
| 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"}, |
| - AppDirs: map[string][]status.AppDir{"contract-dirs.internal": {{Path: "/data/.instances/x/documents", Empty: true}}}, |
| - }, |
| + 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 a15622d34..a8ba12dc2 100644 |
| --- a/internal/status/snapshot.go |
| +++ b/internal/status/snapshot.go |
| @@ -231,34 +231,36 @@ type Probes struct { |
| 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. Private Metrics only: it names |
| - // hosts. |
| + // 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): the two things that otherwise refuse the move only after the |
| -// instance is offline. Present (even empty) means the box looked; absent |
| -// is a box that cannot say, which the doors read as saying nothing. |
| +// (#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. A move back to this box fails the |
| - // landing's release item over it, at flip. Sorted. |
| + // once left keeps, root-owned. Sorted, and bounded: at most |
| + // MaxStaleLiveLinks names and MaxStaleLiveLinkBytes bytes of them. |
| StaleLiveLinks []string `json:"stale_live_links,omitempty"` |
| - // AppDirs is, per instance this box hosts that keeps any, the entries |
| - // beside its files directory that an offline move cannot carry, as the |
| - // seal judges them. Sorted by path. |
| - AppDirs map[string][]AppDir `json:"app_dirs,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"` |
| } |
| -// AppDir is one entry an instance keeps beside its files directory: its |
| -// path on the box, and whether it is an empty directory. |
| -type AppDir struct { |
| - Path string `json:"path"` |
| - Empty bool `json:"empty,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 |
| @@ -807,9 +809,9 @@ type BoxMetrics struct { |
| // 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): |
| - // stale live links and app directories beside instances' files |
| - // directories. Host-keyed and private like RouteVersions. Omitted on a |
| - // box that cannot take part in an offline move. |
| + // 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"` |
| } |
diff --git a/internal/status/snapshot_test.go b/internal/status/snapshot_test.go| index 1f75e861a..7d3447d2c 100644 |
| --- a/internal/status/snapshot_test.go |
| +++ b/internal/status/snapshot_test.go |
| @@ -454,10 +454,7 @@ func TestDemoClaimSeedCapabilityConfigured(t *testing.T) { |
| // 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"}, |
| - AppDirs: map[string][]AppDir{"shop-a.example.com": {{Path: "/data/.instances/i/documents", Empty: true}}}, |
| - } |
| + 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) |