From carlos-infrastructure-e7, for Paul: Fable 5.2's plan for one-command offline moves, read-only from origin/main 433fcf16 and the plan branch. It replaces slice 1's unattended job with glue over the existing doors. Section 6 has the open questions.
Offline moves in one command: implementation plan
Code citations are to origin/main at 433fcf16. The plan branch's own tree is older (merge base 4c641678) and lacks #339 and #413, so its line numbers differ.
1. Summary
What ships (slice 1): carlos move offline run --host <h> --to <region> runs from the operator's terminal. It is a loop over the existing doors: stage until caught up, start, seal, flip, open, probe, finish. Before open, any failure runs abort then finish. The only durable state is what exists today: the instance record and the boxes' reports. The console gains two small stateless things: an optional expected move id on the doors, and a nudge door that only bumps the serial.
Why it avoids what R1 to R3 found. Every P1 came from a second source of truth (the SQL job row) drifting from the record:
| Fault family | Findings | Why it cannot occur here | |---|---|---| | Intended vs completed transition | R1#2, R2#1, R3#1, R3#4 | No intent, StageAsked or saved clock exists. Each pass decides from one fresh status read. | | Job and hand doors on one move | R2#1, R2#2, R3#2 | No ownership and no release. The glue is one more client of the same compare-and-set doors. | | Authority bound to one move | R1#1 | The door refuses a POST whose id is not the record's move. | | Lost serial notification | R1#3, R3#1, R3#2 | nudge re-announces without repeating a transition. | | Request identity on retry | R1#4 | Not in slice 1 (no job to re-attach to). Named for slice 2 in section 4. |
Not read in depth: the 2026-10-06 Phase 1 plans and the 2026-08-28 instance-moves plans. The offline doors refuse outright when Phase 1 or host claims are on (internal/console/apiinstancemove_offline.go:105), so I treated them as off this path.
2. The existing doors and steps, in order
Every mutating door has the same shape:
- Gate:
offlineGate (apiinstancemove_offline.go:100), which is moveGate's class rails (apiinstancemove.go:50) plus an operator's own CLI token (apiinstancemove.go:541), else a 404. - Write: exactly one
provision.SetRecordMove (read, CAS, one retry; internal/provision/provision.go:1533). - Announce:
bumpSerial (internal/console/serialbump.go:32), clamped to 2 s and log-only on failure.
Routes are at routedecls.go:710-717. Boxes act on a serial bump or a timed pass (five to six minutes per internal/host/movesoffline.go:463-471; the serial comment says hourly, unverified which holds). Source and sealer reports refresh every 15 s, but only for a move the box already knows (movesoffline.go:471-489).
| # | Step | Gate or precondition | Writes | How it fails | |---|---|---|---|---| | 1 | stage (:723; CLI move.go:1645) | offlineBeginChecks (:555): class, claims (:501), region, complete fleet read (:369), offlineSelect (:448), no stale live link (apiinstancemove_offline_facts.go:22); stage capability; the one-move lock (:878) | Lock control/offline-moves/active.json; record to offline-staging with pinned stager (offline_move.go:166). On a staging record it moves staged_at (offline_move.go:258). The stager runs one round per staged_at (movesoffline_stage.go:63-112) | Refusal, exit 5, nothing written. A failed round reports failed, exit 4, instance still serving. A lost write reply is reread server-side (:806-816) | | 2 | start (:685; move.go:1673) | All of step 1's checks again, stager present, same staging bucket | staging to stopping, new requested_at, move_seq (offline_move.go:229). Source boxes hold and fence (movesoffline.go:92) | Refusal leaves it serving. Once written the instance is offline, and the CLI waits with no timeout | | 3 | seal (:1269, :1075; move.go:1695) | Every source box's report fresh (2 min, :67) and stopped, stager stopped, no sidecar, local data on one box | stopping to sealing (offline_move.go:296). The sealer copies the delta and itself writes sealed (offline_move.go:314) | Stale report 409 (retry). Sidecar or two-box data refusals arrive with the instance already offline. Sealer failed, exit 4 | | 4 | flip (:1142; move.go:1721) | Seal hash matches the record, every sealed item OK, sources stopped with 0 processes | sealed to landing, region set to target (offline_move.go:336). The target lands and writes landed (movesoffline_land.go:77-109) | A failed landing item sets failed, exit 4; abort is the way on | | 5 | Gate before open | By hand: move.sh compares target facts with a baseline over SSM (runbook :791-799). In code: offlineOpenCheck (:1175) wants every landing item OK (internal/moves/offline.go:53-76), the seal intact, the tombstone held, sources still stopped | Nothing | The hand gate aborts; the door answers 409 | | 6 | open (move.go:1747) | Step 5's door check | landed to open, opened_at (offline_move.go:374). The target re-verifies, releases the hold, reports opened (movesoffline_land.go:134-216) | After this, abort refuses (:1310, offline_move.go:427). Fix forward | | 7 | Verify | By hand, runbook §7: first 2xx, facts, row fingerprint, quick_check | Nothing | Fix forward on the target | | 8 | finish (move.go:1782) | First post: target opened, sources parked. Second: sealer lifted, sources gone (:1215) | open to finishing to cleared with last_move (offline_move.go:444); lock released (:846-858) | 409 until boxes report; serving throughout | | 9 | abort (:1299; move.go:1829) | Any state from staging to landed | To reverting, region back (offline_move.go:412). A second abort writes nothing. finish then ends it as aborted | Refused from open on | | 10 | Source replica delete, nesting stop | Runbook §10 and §9, by hand, Paul's go | Deletes by exact key | Stays manual in this plan |
Today's CLI posts one door, polls every 2 s (move.go:1375) and "never runs the next verb by itself" (move.go:1037-1039). A POST that fails on the network exits 1 with no retry (move.go:623, :1016).
3. The glue: carlos move offline run
Shape. A new package internal/moves/offlinerun holds a pure Decide(view, policy, clock) Action and a small Step that performs one action through a Doors interface (Status, Post, Nudge). The CLI implements Doors over HTTP. The loop is: read status, decide, do at most one thing, sleep 2 s.
Sequencing and gates. Decide reads only the status view (:1433): state, id, next, waiting, failed, staged_at, stage.
| View | Action | |---|---| | No move, nothing bound | POST stage | | id differs from the bound id | Stop, exit 4, write nothing | | Staging, round not answered (stage.request != staged_at) | Wait | | Staging, round answered, round_bytes over 1 MiB, under 5 rounds | POST stage | | Staging, small round this process watched finish under 60 s ago, next == start | POST start | | Staging, small round but not watched (a resume) | POST stage first | | stopping, sealed, landed with next set | POST that verb | | sealing, landing | Wait | | Any pre-open state with failed, or over its budget with no ready step | POST abort, then follow to finish, exit 3 | | open | Probe https://<host><--probe-path> until 2xx, then POST finish | | finishing, reverting | POST finish when next == finish | | No move, last.id is ours | Exit 0 (done) or 3 (aborted) |
Rules that hold the table together:
- A ready step beats a deadline. If
next names the verb, the glue posts it even when over budget, so a slow console never aborts a healthy move. - Budgets run on the terminal's monotonic clock from when this process first saw the state: stop 3 min, seal 10 min, landing 5 min, open check 2 min, offline total 15 min (
--max-offline). These are drafts; Task 0 sets them. - Any POST that is not a clean 2xx is followed by a status read, never a blind retry. A committed POST whose reply was lost shows as an advanced state; a repeat would be a 409.
nudge is sent when a wait passes 30 s with no change, then every 60 s.- Abort is sticky in the process. Once decided, the glue posts
abort until the view is reverting or someone has opened it. - After open the glue never aborts. A failed probe stops it with exit 4 and no
finish. - The SSM gate is dropped. The landing verifies env, files, config, timers and the staged database against the seal, and
open requires all of it. The row fingerprint stays a runbook check.
Logging. One line per action, written before the POST with the UTC time, the door and the move id, then its result. --log <file> appends the same lines unbuffered. The process ignores SIGHUP, so a dropped SSH session does not stop the move (unverified on Windows; build-tag it like interactive_term_unix.go).
What status reports. The same view, reordered by a UX pass: state first, then move id, time offline (requested_at), time in state (updated_at), what it waits for, and the one command forward and one back. The server already sends all of these; the CLI ignores the two times today.
Resuming after a dead terminal.
carlos move offline status --host <h>, before anything else (runbook §1).- Then one of: -
run --host <h> --resume <move-id> to go forward from wherever the record is; - abort then finish to go back; - the hand verbs, one at a time.
run without --resume refuses a host that already has a move, so it never adopts a move by accident.
One writer. The glue holds no lock and no authority. Its POSTs carry the move id, the door checks the state the verb follows, and the record CAS picks one winner. A hand abort during run makes run follow the revert and exit 3. Two runs on one move produce one transition and one 409 each step.
4. Customer self-serve
Yes: a thin console pass that calls the same Decide and Step, with Doors implemented by the handlers' own functions. It needs its own plan and a security review of the token gate.
Minimum durability: one field. Add auto {by, to, max_offline} to the lock object the console already writes before the record (:880, internal/moves/offline.go:425). Only the console writes that object, so no box change and no record field. The lock already names the move id and is deleted at finish.
The pass: each tick reads the lock; if auto is set and the record's move id equals the lock's, it runs one Step. Deadlines come from requested_at and updated_at on the record, and stage freshness from the stager report's own at, set when the round ends (movesoffline_stage.go:96).
Cases from R1 to R3 it must handle:
- R1#1 A new move staged while the console was down: the id check stops the pass.
- R1#2 A failed abort write: nothing is remembered. Deadline aborts are re-decided each tick because the record's times only grow. If evidence now passes, opening is correct.
- R1#3, R3#1 A commit with a lost reply or lost bump, including the first stage write: the next tick sees the state and nudges.
- R1#4 A repeated
run request after the flip: the door must recognise the existing auto move before the "already in uk" check (:597). - R2#1 A hand restage: the pass compares the view's own
staged_at with the report. - R2#2 A hand flip: no observation time is recorded.
- R2#4, R3#4 Downtime while staging: a stager report older than 90 s forces a new round.
- R3#2 Release with a write outstanding: cut. There is no release verb; an operator stops an auto move with
abort, which the state machine fences. - R3#3 The simulation classifies writes by actor: boxes write
sealed and landed.
Also needed:
- The spec's move-capable token (§5; unverified whether any of it is on main).
- A neutral busy sentence: today's names another host (
:898), which would leak across tenants. - An
offline-auto-1 style gate is not needed, since boxes never see the field.
5. Tasks
Targeted -run tests only; CI runs the suite. One amadan task each.
Task 0: rehearsal on dev, by hand, no code. Needs Paul's go.
- Run the runbook's
move.sh on a fresh moverehearsal instance (runbook §13). - Acceptance, posted on the branch discussion: - step times on today's release; -
next and waiting recorded in every state; - a repeated seal POST answers 409; - what the edge answers between stop and open; - whether dev's release carries #339 and #413.
Task 1: UX pass and copy for run and status output.
- Files: none in product; mock and deck in the plan.
- Acceptance: approved deck before any string is coded.
Task 2: Decide.
- Files: create
internal/moves/offlinerun/decide.go, decide_test.go. - Tests first: one table row per line of section 3's table, plus "ready step beats deadline" and "id mismatch writes nothing".
- Acceptance:
go test ./internal/moves/offlinerun -run TestDecide.
Task 3: expected id on the doors.
- Files:
internal/console/apiinstancemove_offline.go (:685, :723, :1269, :1299), apiinstancemove_offline_test.go. - Tests first: wrong
id answers 409 with the existing "the record carries a different offline move" and leaves record_seq alone; no id is byte-identical to today.
Task 4: nudge door.
- Files:
apiinstancemove_offline.go, routedecls.go, linkedpolicy.go, testdata/claim-routes.txt, the route inventories. - Tests first: 202 with the view, serial advanced, record unchanged; no move answers 409; non-operator 404.
Task 5: Step and the CLI verb.
- Files: create
internal/moves/offlinerun/run.go, move_offline_run.go; modify move.go (:89, :122, :216, :1556), move_test.go. - Tests first, on
fakeOfflineConsole (move_test.go:1117): - POST order on the happy path; - a dropped reply on seal sends no second seal; - a failure in each pre-open state ends in abort, finish, exit 3; - a failed probe after open sends no abort and no finish, exit 4; - --resume with a wrong id writes nothing; - a stall sends nudge.
Task 6: status output.
- Files:
move.go (:1589), move_test.go. - Acceptance: first line is the state; id and both times shown.
Task 7: real-door witnesses.
- Files:
offline_move_e2e_test.go, internal/host/movesoffline_e2e_test.go (test only). - Tests: -
run against the real console with scripted box reports; - the two-box world (:199, :1260) driven by Step with boxes woken by serial only, so a missing nudge stalls it; - a seeded simulation with lost replies, lost bumps and hand doors interleaved. - Simulation asserts: no POST for another id, and every run ends cleared or stopped with a named state.
Task 8: docs and census.
- Files:
docs/site/cli.md (:3454), the runbook's §5, parity/*.tsv, copy rows, approved_moves_copy_test.go, census card for move.go.
Task 9: rehearsal on dev with run. Needs Paul's go and a dev release.
- Scenarios: - happy path; -
--max-offline 20s to force an abort mid-seal; - kill -9 mid-seal, then status and --resume; - a hand abort from a second terminal.
Slice 2 (own plan):
- S1
auto on the lock and an operator-only run door. - S2 The pass.
- S3 The token gate.
- S4 Neutral refusals.
- S5 Task 7's simulation with console crashes added.
6. Risks and open questions
- Review budget. Slice 1's three rounds are spent. This is a cut, not a fourth fix. Recommend one fresh whole-branch round, with Task 3 and Task 4 reviewed as gates.
- Does
run finish? Your #1005 ruling stopped run at open; your framing here includes cleanup. Recommend finish after a 2xx probe, with --no-finish. - Ctrl-C before open. Recommend the first Ctrl-C aborts and follows to finish; the second stops watching.
- A machine that dies mid-move still strands the instance until someone reads
status. Slice 1 cannot fix that; slice 2's pass does. Recommend running run under tmux on DOCS-T1 until then. - Refusals that arrive after the stop (sidecar, files over 256 MiB, #1003's app directories) cost about a minute of downtime before the abort. Recommend accepting for operators and fixing before self-serve.
- No release verb for auto moves. Recommend the cut;
abort is the stop. - Who approves copy: you or Luna under the 2026-10-25 delegation? Recommend Luna, as on #1005.
- One move per deployment will queue customers behind each other. Recommend keeping it for slice 2 and answering "try again shortly".