plan: self-serve moves slice 1, one command runs the move (Fable draft)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md+661 −0
Intent
<task-notification> <task-id>a4a1b0aa020a2a126</task-id> <tool-use-id>toolu_01Wv7NHDseFghqzPjR5Auj39</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a4a1b0aa020a2a126.output</output-file> <status>completed</status> <summary>Agent "Fable drafts W3 slice 1 plan" 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>Plan written to `/home/paulca/amadan.net/carlos/platform/.claude/worktrees/plan-tito-nesting-moves/docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md`. Only that file was touched; nothing was committed. **Tasks** 1. Door bodies become functions the job can call, with no behaviour change (same code as #413 and #339; noted). 2. Job table `offline_move_jobs` in the console's SQLite store. 3. `POST …/move/offline/run` door plus a `job` block in the status view (per-task Astra review). 4. The job pass: a pure decision table plus a tick that writes its step before each record transition (per-task Astra review). 5. CLI `carlos move offline run` and the step lines in `status` (needs a census card). 6. Luna pass on a 16-row deck, docs, and the two-box witness `TestOfflineJobE2E`. 7. Whole-branch review and merge. 8. Dev move from one command, each step on Paul's go. **Riskiest: Task 4.** The console stops, opens and aborts an instance with nobody watching. Two faults to avoid: a deadline firing after console downtime, and any abort after open. **Grounding** - The CLI is in this repo (`move.go`, root package), not a separate one. - The job reuses the `StartDomainPurchasePass` worker shape. - No box, record or bucket changes. - D4: slice 1 does not need the lifetimes cutover on. **Unknown, with the check written into the plan** - How the CLI turns a view field into console-authored text (`serverText`). - Whether the copy scan sees sentences in the new console file. - The exact shape of the `claimSQLTables` entry. - `landOpts` fault names for the abort witness. **Questions for Paul** 1. Should `run` finish on its own after open, or stop there so the runbook's row-fingerprint check comes first? Planned: finish, since it parks and deletes nothing. 2. Is no paging acceptable for slice 1 (the operator reads exit 4), with paging arriving in slice 2? 3. May the dev witness restart the dev console mid-move, to prove the restart case? 4. Build now on today's main, or wait for W4 to merge? The plan works either way.</result> <usage><subagent_tokens>247979</subagent_tokens><tool_uses>48</tool_uses><duration_ms>844797</duration_ms></usage> </task-notification>
diff --git a/docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md b/docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md| new file mode 100644 |
| index 000000000..49d8f97f5 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md |
| @@ -0,0 +1,661 @@ |
| +# Self-serve moves, slice 1: one command runs the whole move. Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** `carlos move offline run --host <h> --to <region>` asks the console to run a whole offline move (stage, start, seal, flip, check, open, finish) as a durable job that aborts on its own before open, and `carlos move offline status` names the step the job is on, even after a console or CLI restart. |
| + |
| +**Architecture:** The job is a row in the console's SQLite store plus the instance record, which stays the only truth about the move. A worker pass (the `RunClaimWorker` shape, as `StartDomainPurchasePass`) reads the record fresh on every tick, runs the same checks the operator doors run (`offlineStepFor`, and the door bodies Task 1 turns into functions), writes at most one record transition per tick, and writes the step to its row before the transition. The CLI only starts the job and watches the status view; killing it changes nothing. No box code, no record field and no new bucket object. |
| + |
| +**Tech Stack:** Go. `internal/console` (doors, store, worker), the CLI in this repo's root package (`move.go`; it is not in a separate repo), `docs/site/cli.md`. Tests use the existing `offlineWorld` fixture (`internal/console/apiinstancemove_offline_test.go`), the CLI's `fakeOfflineConsole` (`move_test.go`) and the two-box witness `e2eWorld` (`internal/host/movesoffline_e2e_test.go`). |
| + |
| +**Spec:** the program plan's W3 and Appendix A (`docs/superpowers/plans/2026-11-13-tito-nesting-and-self-serve-moves.md`, this branch); `docs/superpowers/specs/2026-10-21-self-serve-offline-moves-design.md` §7, §7.2, §7.5 and §6.2 for intent (origin/main); `docs/superpowers/plans/2026-10-21-offline-move-runbook.md` §1, §4, §5 and §11 for the steps and gates (origin/main). Where they differ, this plan is the thin cut: nothing from the spec's reservations, `offline-queued`, lane probes, target-ready report, estimates, health probe or cleanup is built here. |
| + |
| +## Global Constraints |
| + |
| +- **Operator-only.** The new door sits behind `offlineGate` (`moveOperatorGate`, then MV-O20) exactly as the other offline doors do. No token, role or route gains anything else. |
| +- **The doors keep their bytes.** Every existing door answers the same status and sentence for the same input after Task 1. `TestOffline*` in `internal/console` passes unchanged. |
| +- **The record is the truth.** The job decides from a record read on that tick, never from its row. The row holds only what the record cannot: that the console is driving, the step, its start, its deadline, the last look, and why it stopped. |
| +- **Before open, every failure aborts; after open, nothing aborts** (spec §7.5, runbook §11). After open the job retries `finish` each tick and never skips a finish gate. |
| +- **Write the step before the transition** (runbook §1, the 12.7-minute outage of 2026-10-21): the row says "about to run X" before the record changes. |
| +- **No dependency on unmerged work (stopping rule 4).** W4's branches `offline-move-pool-target-413` and `offline-move-stage-refusals-339` are not on main. This plan works with today's refusals. Because the job calls the doors' own check functions, it picks up W4's refusals when they merge, with no change here. Tasks 1 and 4 carry a one-line note where they touch the same code. |
| +- **D4 answered:** slice 1 does not need the lifetimes cutover switched on. The cutover's admission gate is on main, so the pass runs each tick as a `lifetimesIteration` unit (mutating); it then works before and after a cutover. |
| +- **Package scope.** `internal/provision`, `internal/moves` and `internal/host` (non-test) are not changed. If a task finds it must change one, stop and say so: that is a census change and a box roll this slice does not plan. |
| +- **Census.** `move.go` is in the root binary (`go list -deps .`), so Task 5 changes census scope: `make census-card`, a CLAIMS file, `make census-propose NAME=self-serve-moves-s1-one-command`, and the other-family reviewer's verdict recorded on #280 (AGENTS.md "The census"). `internal/console` and `cmd/console` are out of scope. |
| +- **Copy.** Every new operator-facing sentence is a row of the deck in Appendix A, added to `docs/superpowers/plans/2026-10-06-moves-phase1-copy.md` as `pending` and to `movesCopyIDs` (`approved_moves_copy_test.go`). Plain words, no em dashes. Reasons the job records are sentences the doors already speak wherever one exists. A delegated Luna pass reviews the deck (Task 6); her edits are applied verbatim. |
| +- **No tenant names:** `shop.example.com`, account `bab`, app `shop`, regions `ie` and `uk`. |
| +- **S3 cost:** with no live job the pass makes one SQL read and no bucket request. |
| +- **Review budget (stopping rules 1 to 3):** per-task Astra review for Task 3 (a new route behind the operator gate) and Task 4 (the console takes a production instance offline and opens it with nobody watching). Everything else is one whole-branch review (Task 7). Three rounds in total for this design, then cut or ask Paul. Every brief carries the round history and follows `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`. |
| +- **Lean local verification:** targeted `-run` on changed packages only; never `make test` or `go test ./...` locally (CI on amadan runs the full gate). `GOCACHE`, `GOMODCACHE` and `GOTMPDIR` unset (the default cache; ignore AGENTS.md's older sandbox note). Tests that open a listener or a unix socket (`internal/console` door tests, `internal/host` e2e, the root package's CLI tests) run with the sandbox off and `TMPDIR=/tmp/g` (`mkdir -p /tmp/g` first, `rm -r /tmp/g` when the task ends). |
| +- **Branch:** `self-serve-moves-s1-one-command`, cut from amadan `main` after W4 merges if it has, else from today's main. One amadan task per plan task. Commit subjects under 80 characters, body after a blank line, ending `Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>`. |
| +- **Something Paul can see (rule 6):** this slice is one merge, and what it changes is visible: one command moves a dev instance. No scaffolding merges ahead of it. |
| + |
| +## Review Focus |
| + |
| +1. **The console restarts between seal and flip, with the CLI gone.** The job resumes from the record and its row on the first tick; `status` names the step and when it began; time the console was down does not count against the step's deadline. Test in Task 4 (`TestOfflineJobResumesAfterRestart`). |
| +2. **An operator runs a door by hand while the job runs** (`abort`, or `flip` a second before the job would). The job follows the record: it finishes the abort and ends `aborted`, or carries on from the new state. It never undoes a hand step. Test in Task 4 (`TestOfflineJobFollowsHandDoors`). |
| +3. **`run` twice.** The same host and region again re-attaches to the one job (no second row, no second move); another host is refused with the existing one-at-a-time sentence (MV-O30). Test in Task 3 (`TestOfflineRunDoorTwice`). |
| +4. **A box goes quiet after open.** The job never aborts, never writes `finish` without the gate's evidence, keeps trying, and `status` and the CLI say the instance is open and the finish is overdue (exit 4). Tests in Task 4 (`TestOfflineJobNeverAbortsAfterOpen`) and Task 5 (`TestMoveOfflineRunOverdueAfterOpen`). |
| +5. **A record write whose reply was lost.** The next tick reads the record and continues from what it says; no transition is written twice and no step is skipped. Test in Task 4 (`TestOfflineJobRereadsAfterALostReply`). |
| + |
| +--- |
| + |
| +## File structure |
| + |
| +| File | Responsibility | |
| +|---|---| |
| +| `internal/console/apiinstancemove_offline.go` (modify) | Task 1: door bodies as functions. Task 3: `Job` on `offlineView`. | |
| +| `internal/console/offlinejob_store.go` (create) | The `offline_move_jobs` table and its four store methods. | |
| +| `internal/console/offlinejob.go` (create) | The `run` door, the worker, the tick, the pure decision, the pre-open gate. | |
| +| `internal/console/offlinejob_test.go`, `offlinejob_store_test.go` (create) | Their tests. | |
| +| `internal/console/store.go`, `store_gate.go`, `routedecls.go`, `linkedpolicy.go`, `claim_workers.go`, `cmd/console/main.go` (modify) | Wiring: migration, table class, route, linked policy, worker registration and start. | |
| +| `internal/console/testdata/claim-routes.txt`, `claim_invariant_fixtures_test.go`, `svcroutes_test.go`, `jobs_test.go` (modify) | The inventories a new route and worker must appear in. | |
| +| `move.go`, `move_test.go`, `offline_move_e2e_test.go` (modify) | The `run` verb, the status lines, their tests. | |
| +| `internal/host/movesoffline_e2e_test.go` (modify, test only) | The two-box witness driven by the job. | |
| +| `docs/site/cli.md`, `parity/cli.tsv`, `parity/parity.tsv`, the copy record, `approved_moves_copy_test.go` (modify) | Docs, projections, copy rows. | |
| + |
| +--- |
| + |
| +### Task 1: Door bodies become functions the job can call |
| + |
| +No behaviour change. The doors' checks are already half split (`offlineStepFor` takes no `http.ResponseWriter`); `offlineBeginChecks`, `offlineBegin` and `offlineWrite` are not. |
| + |
| +*W4 note: #413 and #339 change `offlineSelect` and the stage and start refusals in these same functions. If either has merged, rebase first and carry its refusals through the extraction unchanged; if one merges mid-task, the conflict is mechanical (same bodies, new signatures).* |
| + |
| +**Files:** |
| +- Modify: `internal/console/apiinstancemove_offline.go` (`offlineBeginChecks` near :500, `offlineBegin` near :740, `offlineWrite` near :800, `offlineRefusal` near :148, `offlineSealCheck`), `internal/console/seedmove.go:22,202` |
| +- Test: `internal/console/apiinstancemove_offline_test.go` |
| + |
| +**Interfaces:** |
| +- Consumes: nothing new. |
| +- Produces (all in `internal/console`): |
| + - `offlineRefusal` gains `final bool`: a refusal no wait can mend. Set true only on the two `offlineSealCheck` refusals "keeps a sidecar file" and "keeps local data on more than one box". The doors ignore it. |
| + - `func (s *Server) offlineClassRefusal(ctx context.Context, d offlineDoor) *offlineRefusal`: the checks of `offlineBeginChecks` before `readJSON` (seed, rootfs, replica, replicas, steering or unit, `offlineClaimEvidence`), same order, same sentences. `refuseSeedMove` and `refuseRootfsMove` each get a twin returning `*offlineRefusal` that the `w` form calls. |
| + - `func (s *Server) offlineRegionRefusal(ctx context.Context, d offlineDoor, region string) (to string, fleet offlineFleet, ref *offlineRefusal)`: the checks after `readJSON` (region shape, `haTransferRegion`, already there, manifest regions, fleet read, the `CARLOS_REGION` home rule, `offlineSelect`). |
| + - `func (s *Server) offlineStageMut(d offlineDoor, to string, fleet offlineFleet) (begin func(id string) func(*provision.Record) error, ref *offlineRefusal)`: the stage door's own checks for a record at rest (stage capability on every box, MV-O191 same bucket) and the `OfflineStage` transition with the pinned stager and coordinates. |
| + - `func (s *Server) offlineBeginMove(ctx context.Context, d offlineDoor, begin func(id string) func(*provision.Record) error) (*provision.Record, *offlineRefusal)`: `offlineBegin` minus the response (mint, probe, lock, bounded write, reread on a lost reply, serial bump). |
| + - `func (s *Server) offlineApplyStep(ctx context.Context, d offlineDoor, mut func(*provision.Record) error) (*provision.Record, error)`: apply, bump the serial, release the lock when the move cleared. `offlineWrite` becomes this plus `offlineWriteFailed`. |
| + - `offlineDoor` is unchanged. Its users read only `acct.Sqid` of the account (`offlineApply`, `offlineClaimEvidence`, `offlineTakeLock`, `offlineWriteFailed`), which is what lets Task 4 build one from a job row. |
| + |
| +- [ ] **Step 1: Write the failing tests** in `apiinstancemove_offline_test.go`: |
| + |
| +```go |
| +// TestOfflineBeginRefusalsMatchTheDoor: for every case of TestOfflineStartRefusals' |
| +// table, offlineClassRefusal then offlineRegionRefusal, called directly on the same |
| +// world, return the status and sentence the POST answered. |
| +// TestOfflineSealCheckMarksFinalRefusals: the sidecar and two-data-box refusals carry |
| +// final == true; offlineWaitRefusal, offlineStaleRefusal and offlineStateRefusal do not. |
| +// TestOfflineApplyStepReleasesTheLock: an OfflineFinish applied through |
| +// offlineApplyStep leaves no control/offline-moves/active.json (w.lock() ok == false) |
| +// and bumps the serial (serialBytes changes). |
| +``` |
| + |
| +- [ ] **Step 2: Run to see them fail** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineBeginRefusalsMatchTheDoor|TestOfflineSealCheckMarksFinalRefusals|TestOfflineApplyStepReleasesTheLock' -count=1` |
| +Expected: build failure, `s.offlineClassRefusal undefined`. |
| + |
| +- [ ] **Step 3: Extract the functions** with the signatures above. The handlers become: gate, class refusal, `readJSON`, region refusal, then their own branch. Move code; do not rewrite a sentence. |
| + |
| +- [ ] **Step 4: Run the new tests and every existing offline door test** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOffline' -count=1` then `TMPDIR=/tmp/g go test . -run 'TestMoves|TestMoveOffline' -count=1` |
| +Expected: PASS, with no existing test edited. |
| + |
| +- [ ] **Step 5: Commit** |
| + |
| +```bash |
| +git add internal/console/apiinstancemove_offline.go internal/console/seedmove.go internal/console/apiinstancemove_offline_test.go |
| +git commit -m "offline move: door bodies as functions, no behaviour change" |
| +``` |
| + |
| +--- |
| + |
| +### Task 2: The job table |
| + |
| +**Files:** |
| +- Create: `internal/console/offlinejob_store.go`, `internal/console/offlinejob_store_test.go` |
| +- Modify: `internal/console/store.go:752` (call `migrateOfflineJobs` beside `migrateDomains`), `internal/console/store_gate.go:210` (`claimSQLTables`) |
| + |
| +**Interfaces:** |
| +- Produces: |
| + |
| +```go |
| +// OfflineMoveJob is one console-run offline move. ID is the move id on the record. |
| +type OfflineMoveJob struct { |
| + ID, Host, Account, App, To, RequestedBy string // Account is the sqid |
| + State string // running | returning | done | aborted | stopped |
| + Step string // stage | start | seal | flip | check | open | finish | abort |
| + StepAt time.Time // when Step began (written before its transition) |
| + DeadlineAt time.Time // zero: no deadline |
| + TickAt time.Time // the pass's last look |
| + Rounds int // stage rounds asked for so far |
| + FlippedAt time.Time // when the job wrote the flip; zero before |
| + Waiting string // the sentence the step last waited on |
| + Reason string // why the console aborted or stopped; "" otherwise |
| + Steps []OfflineJobStep // history, oldest first |
| + CreatedAt, UpdatedAt time.Time |
| +} |
| +type OfflineJobStep struct { |
| + Step string `json:"step"` |
| + At time.Time `json:"at"` |
| + Took float64 `json:"took_s,omitempty"` // 0 while it runs |
| +} |
| +var ErrOfflineJobLive = errors.New("console: this host already has a live offline move job") |
| + |
| +func (s *Store) InsertOfflineJob(j OfflineMoveJob) error // ErrOfflineJobLive on the unique index |
| +func (s *Store) SaveOfflineJob(j OfflineMoveJob) error // update by ID; sets UpdatedAt |
| +func (s *Store) LiveOfflineJobs() ([]OfflineMoveJob, error) // state running or returning, oldest first |
| +func (s *Store) OfflineJobFor(host string) (*OfflineMoveJob, error) // newest by created_at; nil, nil when none |
| +``` |
| + |
| +- Table `offline_move_jobs`: the fields above (`steps` as JSON text, times as Unix nanoseconds, `INTEGER NOT NULL DEFAULT 0`), `id TEXT PRIMARY KEY`, and `CREATE UNIQUE INDEX offline_move_jobs_live ON offline_move_jobs(host) WHERE state IN ('running','returning')`. `CREATE TABLE IF NOT EXISTS`, as `migrateDomains` does. |
| +- `claimSQLTables`: `"offline_move_jobs": {Refuse: "offline moves are not available while host claims or Phase 1 moves are on"}`, the `demo_jobs` form. unknown: whether the table's census wants `Account`/`App` columns named instead: run `TestClaim` tests that range over `claimSQLTables` (step 4) and follow what they ask. |
| + |
| +- [ ] **Step 1: Write the failing tests** (`offlinejob_store_test.go`): |
| + |
| +```go |
| +// TestOfflineJobRoundTrip: Insert then OfflineJobFor(host) returns every field equal, |
| +// Steps included; SaveOfflineJob changes Step, StepAt, Reason and a third Steps entry |
| +// and the next read has them. |
| +// TestOfflineJobOneLivePerHost: a second Insert for the same host while the first is |
| +// running or returning returns ErrOfflineJobLive; after the first is saved as done, |
| +// the second Insert succeeds and OfflineJobFor returns the second. |
| +// TestLiveOfflineJobs: of rows in running, returning, done, aborted and stopped, only |
| +// the first two come back, oldest first. |
| +// TestOfflineJobTableSurvivesReopen: Open the same file again; the row is there. |
| +``` |
| + |
| +- [ ] **Step 2: Run to see them fail** |
| + |
| +Run: `go test ./internal/console -run 'TestOfflineJob|TestLiveOfflineJobs' -count=1` |
| +Expected: build failure, `OfflineMoveJob undefined`. |
| + |
| +- [ ] **Step 3: Write the table, the migration call and the four methods.** |
| + |
| +- [ ] **Step 4: Run** |
| + |
| +Run: `go test ./internal/console -run 'TestOfflineJob|TestLiveOfflineJobs|TestClaimConstructorInstallsEveryBoundary|TestClaimConsoleMutationInvariant' -count=1` |
| +Expected: PASS (the claim tests are the ones that range over `claimSQLTables`). |
| + |
| +- [ ] **Step 5: Commit** |
| + |
| +```bash |
| +git add internal/console/offlinejob_store.go internal/console/offlinejob_store_test.go internal/console/store.go internal/console/store_gate.go |
| +git commit -m "offline move job: the console's job table" |
| +``` |
| + |
| +--- |
| + |
| +### Task 3: The `run` door, and the job in the status view |
| + |
| +**Per-task Astra review** (a new route behind the operator gate). |
| + |
| +**Files:** |
| +- Create: `internal/console/offlinejob.go`, `internal/console/offlinejob_test.go` |
| +- Modify: `internal/console/apiinstancemove_offline.go` (`offlineView` near :1290, `offlineViewOf`, the file comment's door list), `internal/console/routedecls.go:715`, `internal/console/linkedpolicy.go:199`, `internal/console/testdata/claim-routes.txt:305`, `internal/console/claim_invariant_fixtures_test.go:1960`, `internal/console/svcroutes_test.go:764` |
| + |
| +**Interfaces:** |
| +- Consumes: Task 1's `offlineClassRefusal`, `offlineRegionRefusal`, `offlineStageMut`, `offlineBeginMove`, `offlineApplyStep`; Task 2's store methods. |
| +- Produces: |
| + - Route `POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/run`, body `{"region":"uk"}`, `Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance)`, `linkedRefuse`, handler `(*Server).handleAPIInstanceOfflineRun`. Answers 202 with the status view. |
| + - `offlineView.Job *offlineJobView` (`json:"job,omitempty"`): |
| + |
| +```go |
| +type offlineJobView struct { |
| + State string `json:"state"` |
| + Step string `json:"step"` |
| + StepAt int64 `json:"step_at"` // Unix seconds |
| + Deadline int64 `json:"deadline,omitempty"` |
| + Overdue bool `json:"overdue,omitempty"` // deadline passed and the job cannot abort |
| + CheckedAt int64 `json:"checked_at"` // the pass's last look |
| + Reason string `json:"reason,omitempty"` |
| + Steps []OfflineJobStep `json:"steps"` |
| +} |
| +func (s *Server) offlineJobViewFor(host string, mv *provision.MoveState, last *provision.MoveOutcome, now time.Time) *offlineJobView |
| +``` |
| + |
| + `offlineJobViewFor` returns the host's newest job when its ID is the move in flight, or, with no move in flight, when its ID is `last.ID` or its state is `stopped`; else nil. `offlineViewOf` sets `v.Job` from it in both branches (state `none` included, so `status` after the end still says why the console stopped). |
| + |
| +**What the door does, in order:** |
| + |
| +1. `offlineGate`. |
| +2. `offlineClassRefusal`, `readJSON`, `offlineRegionRefusal`: the stage door's checks, so a `run` is refused for exactly what a `stage` is. |
| +3. By the record's move: |
| + - **none:** `offlineStageMut`, `offlineBeginMove`, then `InsertOfflineJob` (ID the new move's, `State: "running"`, `Step: "stage"`, `StepAt` now, `Rounds: 1`, `DeadlineAt` now + 30 min, `RequestedBy: d.addr`). |
| + - **`offline-staging` for the same region:** if the host has a live job with that move id, write nothing (re-attach). Otherwise adopt the hand-staged move: `offlineStageCoords`, `OfflineRestage` through `offlineApplyStep`, then insert the row as above. |
| + - **`offline-staging` for another region:** `offlineStagedFor` (MV-O179). |
| + - **any later state:** with a live job for that move id, write nothing (re-attach); without one, `offlineStateRefusal` (MV-O25). A move a person started by hand past staging is theirs. |
| +4. 202 with `offlineViewOf`. |
| + |
| +A crash between the record write and the row insert leaves an ordinary staged move, with the instance serving; running `run` again adopts it. That is the whole admission story for this slice. |
| + |
| +- [ ] **Step 1: Write the failing tests** (`offlinejob_test.go`, on `newOfflineWorld(t, ieOff("annie"), ukOff("iris"))`): |
| + |
| +```go |
| +// TestOfflineRunDoorIsOperatorOnly: the cases of TestOfflineDoorsAreOperatorOnly |
| +// against /run: a member token, a service token and no token each get the 404 the |
| +// other doors give, byte for byte; under HostClaim it answers MV-O20. |
| +// TestOfflineRunDoorRefusesWhatStageRefuses: for each row of TestOfflineStartRefusals |
| +// and TestOfflineStageRefusesABoxThatCannotStage, POST /run answers the same status |
| +// and sentence as POST /stage, and bucketState and the jobs table are unchanged. |
| +// TestOfflineRunDoorStagesAndRecordsTheJob: 202; record().Move.State == |
| +// provision.OfflineStaging; view.Job.State == "running", .Step == "stage", |
| +// len(.Steps) == 1; w.lock() names the host; the serial changed. |
| +// TestOfflineRunDoorTwice (Review Focus 3): a second POST /run with the same region |
| +// answers 202 with the same view.ID, LiveOfflineJobs has one row, record().MoveSeq |
| +// did not advance; POST /run for a second host answers 409 |
| +// "shop.example.com is moving offline. move one instance at a time". |
| +// TestOfflineRunDoorAdoptsAHandStagedMove: after w.stage(), POST /run answers 202, |
| +// staged_at moved forward, one job row with the staged move's id. |
| +// TestOfflineRunDoorLeavesAHandMoveAlone: after w.start() (no job), POST /run answers |
| +// 409 msgO25(provision.OfflineStopping) and inserts no row. |
| +// TestOfflineStatusCarriesTheJobAfterItEnds: a job saved as aborted with Reason "x" |
| +// and the record's LastMove.ID equal to it: GET status has State "none" and |
| +// Job.Reason "x"; with a newer LastMove.ID, Job is nil. |
| +``` |
| + |
| +- [ ] **Step 2: Run to see them fail** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineRunDoor|TestOfflineStatusCarriesTheJob' -count=1` |
| +Expected: FAIL, 404 from an unknown route. |
| + |
| +- [ ] **Step 3: Write `handleAPIInstanceOfflineRun` and `offlineJobViewFor`; add the route and its rows** in `routedecls.go`, `linkedpolicy.go`, `claim-routes.txt`, `claim_invariant_fixtures_test.go` (copy the `/stage` fixture) and `svcroutes_test.go`. |
| + |
| +- [ ] **Step 4: Run** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOffline|TestClaim|TestEveryCLIDoor|TestInstanceRole|TestEveryClosedDoor|TestLinked' -count=1` |
| +Expected: PASS. These are the tests that read the route lists (`claim_routes_test.go`, `svcroutes_test.go`, the linked policy's). A failing one names the list that still lacks the route; add the row it asks for. |
| + |
| +- [ ] **Step 5: Commit, then the per-task review** |
| + |
| +```bash |
| +git add internal/console |
| +git commit -m "offline move: the run door and the job in the status view" |
| +``` |
| + |
| +Brief Astra on this commit: the door's gate order against the other offline doors, and what a re-attach or adopt can write. |
| + |
| +--- |
| + |
| +### Task 4: The job pass |
| + |
| +**Per-task Astra review** (the console stops, opens and aborts a production instance unattended). |
| + |
| +*W4 note: #413 changes which target boxes `flip` waits on, inside `offlineStepFor` and `offlineSelect`. The pass calls those functions and reads no fleet of its own, so it needs no change when #413 lands.* |
| + |
| +**Files:** |
| +- Modify: `internal/console/offlinejob.go`, `internal/console/offlinejob_test.go`, `internal/console/claim_workers.go:18`, `cmd/console/main.go:812`, `internal/console/testdata/claim-routes.txt:429`, `internal/console/claim_invariant_fixtures_test.go:2483`, `internal/console/jobs_test.go:53` |
| + |
| +**Interfaces:** |
| +- Consumes: Tasks 1 to 3; `offlineStepFor`, `readOfflineEvidence`, `offlineStageOf`, `offlineOpenCheck`, `s.readRecord`, `s.store.AccountBySqid`, `s.movesNow`, `lifetimesWorker`, `s.lifetimesIteration`, `s.jobs.Run`, `jobFailed`. |
| +- Produces: |
| + |
| +```go |
| +const ( |
| + offlineJobTick = 5 * time.Second |
| + offlineJobStageBound = 30 * time.Minute // spec §6.2 |
| + offlineJobStageRounds = 10 |
| + offlineJobStageMin = 2 |
| + offlineJobReadyBytes = 16 << 20 // a round that copied less is caught up |
| + offlineJobStopWait = 5 * time.Minute // start: every source box stopped (spec §7.2 floors) |
| + offlineJobSealWait = 10 * time.Minute |
| + offlineJobFlipWait = 5 * time.Minute // sealed: the flip's checks |
| + offlineJobLandWait = 10 * time.Minute |
| + offlineJobCheckWait = 3 * time.Minute |
| + offlineJobLateWait = 10 * time.Minute // finish and abort: overdue, never aborted |
| + offlineJobGap = 30 * time.Second // a longer gap between looks is console downtime |
| +) |
| + |
| +func (s *Server) StartOfflineMoveJobs(ctx context.Context) // the worker, registered under that name |
| +func (s *Server) RunOfflineMoveJobs(ctx context.Context) error // one pass over LiveOfflineJobs; exported for the host witness |
| +func (s *Server) offlineJobTickOne(ctx context.Context, j *OfflineMoveJob, now time.Time) error |
| +func offlineJobDecide(in offlineJobInput) offlineJobDecision // pure |
| +func offlineJobGate(ev offlineEvidence, mv *provision.MoveState, flippedAt time.Time) *offlineRefusal |
| +``` |
| + |
| +```go |
| +type offlineJobInput struct { |
| + Job OfflineMoveJob |
| + Move *provision.MoveState // nil: the record carries no offline move |
| + Last *provision.MoveOutcome |
| + Stage *offlineStageView // offlineStageOf(ev) |
| + Step *offlineRefusal // offlineStepFor's refusal for the state's verb; nil: it would pass |
| + Gate *offlineRefusal // offlineJobGate; read only in offline-landed |
| + Failed string // box whose sealer or target report says failed; "" for none |
| + Now time.Time |
| +} |
| +type offlineJobDecision struct { |
| + Action string // wait | restage | advance | abort | close |
| + Step string // the step the row moves to (advance, abort) |
| + Wait time.Duration // that step's deadline from now; 0 for none |
| + State string // close: done | aborted | stopped |
| + Reason string // abort, close |
| + Waiting string |
| + Overdue bool |
| +} |
| +``` |
| + |
| +**The decision table.** Evidence first, deadline second: a step whose evidence is in advances even when its deadline has passed. |
| + |
| +| Record state | Row step | Advance when | The tick then | Deadline | Fails to | |
| +|---|---|---|---|---|---| |
| +| `offline-staging` | `stage` | the stager's report answers the record's `staged_at` (`Stage.Request == StagedAt`), phase `staged`, and (`Rounds >= 2` and `RoundBytes < 16 MiB`, or `Rounds >= 10`, or 30 min since the job began) | sets step `start`, then `offlineClassRefusal` and `offlineRegionRefusal` on the fresh record, `offlineStepFor`, writes `OfflineStartStaged` | 30 min | round phase `failed`: abort, reason MV-O195. A round that answered but is not caught up: `restage` (`OfflineRestage`, `Rounds++`). A start refusal: abort with that sentence (the instance never went offline) | |
| +| `offline-stopping` | `start` | `offlineStepFor` passes (every source box stopped) | sets step `seal`, writes `OfflineSeal` | 5 min | abort | |
| +| `offline-sealing` | `seal` | the box moves the record to `offline-sealed` | nothing to write | 10 min | abort | |
| +| `offline-sealed` | `seal` | `offlineStepFor` passes (the flip's checks) | sets step `flip`, stamps `FlippedAt`, writes `OfflineFlip` | 5 min | abort | |
| +| `offline-landing` | `flip` | the box moves the record to `offline-landed` | nothing to write | 10 min | abort | |
| +| `offline-landed` | `check` | `offlineJobGate` and `offlineStepFor` (`offlineOpenCheck`) both pass | sets step `open`, writes `offlineOpenMut` | 3 min | abort | |
| +| `offline-open` | `finish` | `offlineStepFor` passes (target opened, sources parked) | writes `OfflineFinishingTransition` | 10 min | **overdue; never abort** | |
| +| `offline-finishing` | `finish` | `offlineStepFor` passes (sealer lifted, sources gone) | writes `OfflineFinish`; next tick closes `done` | 10 min | overdue | |
| +| `offline-reverting` | `abort` | `offlineStepFor` passes | writes `OfflineFinish`; next tick closes `aborted` | 10 min | overdue | |
| +| no move, `Last.ID == Job.ID` | any | always | close with `Last.Outcome` (`done`, `aborted`) | | | |
| +| no move, another id or none | any | always | close `stopped`, reason MV-O197 | | | |
| + |
| +Rules the table does not show: |
| + |
| +- **Abort** means: set row state `returning`, step `abort`, `Reason`, deadline now + 10 min, save; then write `OfflineAbort`. It is taken when, before open, (a) the step's refusal is `final`, (b) `Failed` names a box (reason MV-O196), or (c) the deadline passed with the evidence still missing (reason MV-O194 with the step and its minutes; `Waiting` keeps the sentence it waited on). A refusal that is not final is a wait until the deadline. |
| +- **A hand door wins.** If the record's state is ahead of or beside the row's step (someone ran a door, or `abort`), the tick sets the row's step to the table's step for that state and carries on. `offline-reverting` reached by hand sets `returning` with no `Reason`. |
| +- **Row before record.** Every "sets step X, writes T" is: save the row (step, `StepAt`, deadline, a new `Steps` entry, the previous entry's `Took`), then `offlineApplyStep`. A refused or failed write leaves the row on X; the next tick reads the record and decides again. |
| +- **Downtime is not the step's fault.** At the start of a tick, if `now - TickAt > 30 s` and the row has a deadline, add the gap to `DeadlineAt`. Then set `TickAt = now`. |
| +- **`offlineJobGate`** is the check `move.sh` made by hand between `flip` and `open` (runbook §5 "the gate"), read from the landing report instead of over SSM: exactly one target report; phase `landed`; `Held` and `RowPresent` true; `At` not before `flippedAt` (so it is this landing's report; the target does not rewrite it on the 15 s refresh, so the 2-minute freshness rule would be wrong here); `ItemsOK(moves.OfflineOwnerLanding)`. Its refusal is MV-O198 with the box. The landing items already compare the env file, the instance key, the files digest, the timers, `next-due`, the replication rung and the release with the seal, which is what `facts.box.sh` compared by eye. Not covered, and left to the operator after open as today: the row fingerprint of runbook §3.4 and §7. |
| +- **The worker:** `lifetimesWorker(ctx, offlineJobTick, …)`; each iteration first reads `LiveOfflineJobs` and returns if there are none (one SQL read, no bucket request, no job-registry run); otherwise `s.lifetimesIteration(ctx, "StartOfflineMoveJobs", true, false, …)` around `s.jobs.Run(ctx, "StartOfflineMoveJobs", s.RunOfflineMoveJobs)`. It returns at once when `s.cfg.Releases == nil || s.cfg.HostClaim || s.cfg.MovesEnabled`. A tick's error is logged, passed to `jobFailed`, and never ends the pass; the other live job (there is at most one today, by the lock) still gets its tick. |
| +- **One line per event in the console log:** `console: offline move job <host> <id>: <step>: <what>` for each step start, each wait sentence when it changes, each abort with its reason, and the close. |
| + |
| +- [ ] **Step 1: Write the failing decision tests** (`offlinejob_test.go`, pure, table-driven): |
| + |
| +```go |
| +// TestOfflineJobDecide: one row per line of the decision table, and: |
| +// staging, report answers, Rounds 1, RoundBytes 1<<10 -> restage |
| +// staging, Rounds 2, RoundBytes 1<<10 -> advance start |
| +// staging, Rounds 2, RoundBytes 32<<20 -> restage |
| +// staging, Rounds 10, RoundBytes 32<<20 -> advance start |
| +// staging, report does not answer staged_at -> wait |
| +// staging, Stage.Phase failed -> abort, Reason "the copy to uk failed" |
| +// stopping, Step = offlineWaitRefusal, before deadline -> wait, Waiting = its sentence |
| +// stopping, same, Now after DeadlineAt -> abort, Reason "start did not finish within 5 minutes" |
| +// stopping, Step nil, Now after DeadlineAt -> advance seal (evidence first) |
| +// stopping, Step.final -> abort, Reason = the refusal's sentence |
| +// sealing, Failed "annie" -> abort, Reason names annie and seal |
| +// landed, Gate refuses -> wait; after deadline abort |
| +// landed, Gate nil, Step nil -> advance open |
| +// open, Step refuses, Now after DeadlineAt -> wait, Overdue true, Action never "abort" |
| +// finishing, Failed "iris", Now after DeadlineAt -> wait, Overdue true |
| +// reverting by hand (Job.State running) -> wait, row state returning, Reason "" |
| +// Move nil, Last.ID == Job.ID, Outcome "done" -> close done |
| +// Move nil, Last.ID other -> close stopped |
| +// TestOfflineJobNeverAbortsAfterOpen (Review Focus 4): for every input with Move.State |
| +// in open or finishing, over every Step, Failed and Now combination the table uses, |
| +// Action != "abort". |
| +// TestOfflineJobGate: a landed report with Held, RowPresent, At after flippedAt and |
| +// okChecks(moves.OfflineOwnerLanding) passes; each of: phase failed, Held false, |
| +// RowPresent false, At before flippedAt, one item not OK, no target report, two |
| +// target reports -> refusal naming the box (or MV-O25 with no report). |
| +``` |
| + |
| +- [ ] **Step 2: Run to see them fail** |
| + |
| +Run: `go test ./internal/console -run 'TestOfflineJobDecide|TestOfflineJobNeverAbortsAfterOpen|TestOfflineJobGate' -count=1` |
| +Expected: build failure, `offlineJobDecide undefined`. |
| + |
| +- [ ] **Step 3: Write `offlineJobDecide` and `offlineJobGate`.** Run the three tests. Expected: PASS. |
| + |
| +- [ ] **Step 4: Write the failing tick tests** (on `offlineWorld`, with `srv.movesClock` set to a test clock and the boxes played by the fixture's `staged`, `stagerStopped`, `stopped`, `sealed`, `landed`, `sealerFresh` helpers): |
| + |
| +```go |
| +// TestOfflineJobRunsAMoveEndToEnd: POST /run, then alternate RunOfflineMoveJobs with |
| +// the box helper for the state reached. Asserts the record's states in order |
| +// (staging, stopping, sealing, sealed, landing, landed, open, finishing, cleared), |
| +// record().Region == "uk", LastMove.Outcome == "done", the job row done with Steps |
| +// stage,start,seal,flip,check,open,finish each with Took > 0, no lock left, and |
| +// that the test posted to no door but /run. |
| +// TestOfflineJobWritesTheStepBeforeTheTransition: with a store that fails the next |
| +// record Put, one tick in stopping leaves the row on step "seal" with a Steps entry |
| +// for it and the record still stopping; the next tick writes the seal. |
| +// TestOfflineJobAbortsBeforeOpen: a target report with phase failed in landing: |
| +// one tick leaves the record offline-reverting and the row returning with Reason |
| +// set; after w reports every box reverted, the next ticks leave LastMove.Outcome |
| +// "aborted", the row aborted, the lock gone. |
| +// TestOfflineJobAbortsOnADeadline: in sealing, advance the clock 10 min + 1 s with no |
| +// seal: the record is reverting and Reason is "seal did not finish within 10 minutes". |
| +// TestOfflineJobAbortFromStagingNeverOffline: a failed stage round: the record goes |
| +// to reverting from staging and the status view has never_offline true. |
| +// TestOfflineJobResumesAfterRestart (Review Focus 1): run to sealing; build a second |
| +// Server over the same store and bucket; advance the clock 20 min (the downtime); |
| +// put the seal; one tick of the new server: the record is not reverting, the row's |
| +// DeadlineAt moved by the gap, and after the next tick the record is landing. |
| +// GET status at each point names job.step "seal" then "flip" and the same step_at |
| +// the first server wrote. |
| +// TestOfflineJobFollowsHandDoors (Review Focus 2): (a) POST /abort by hand in |
| +// stopping: the next ticks end the row aborted with Reason "" and write no |
| +// transition but the finish; (b) POST /flip by hand in sealed: the next tick sets |
| +// the row's step to flip and writes nothing; the move still ends done. |
| +// TestOfflineJobRereadsAfterALostReply (Review Focus 5): a store whose record Put |
| +// lands but returns an error once: the tick logs it, the next tick finds the record |
| +// already sealing and writes no second seal (record().MoveSeq advanced once). |
| +// TestOfflineJobPassIsQuietWithNoJob: with no live row, RunOfflineMoveJobs and one |
| +// worker iteration make zero requests on a counting store. |
| +// TestOfflineJobOffUnderClaims: with HostClaim or MovesEnabled the worker returns and |
| +// records no run. |
| +``` |
| + |
| +- [ ] **Step 5: Run to see them fail** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineJob' -count=1` |
| +Expected: FAIL, `RunOfflineMoveJobs undefined`. |
| + |
| +- [ ] **Step 6: Write `offlineJobTickOne`, `RunOfflineMoveJobs` and `StartOfflineMoveJobs`; register the worker** in `registerClaimWorkers`, start it in `cmd/console/main.go` beside `StartDomainPurchasePass` (`go srv.RunClaimWorker(context.Background(), "StartOfflineMoveJobs")`), and add its rows to `claim-routes.txt` (`worker StartOfflineMoveJobs`), `claim_invariant_fixtures_test.go` (copy the purchase-pass fixture's shape, with a job row as setup) and `jobs_test.go`'s `jobPassFuncs` (`"StartOfflineMoveJobs": {"RunOfflineMoveJobs", "offlineJobTickOne"}`). |
| + |
| +The tick builds its door value as `offlineDoor{acct: <AccountBySqid(j.Account)>, app: j.App, host: j.Host, rec: <the record read this tick>, addr: j.RequestedBy}`. |
| + |
| +- [ ] **Step 7: Run** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOffline|TestClaim|TestEveryWorkerReportsItsRuns|TestPassFailureLogsAlsoFailTheJob|TestWorkerRunsReachTheRegistry' -count=1` then `go build ./cmd/console` |
| +Expected: PASS; the build is clean. |
| + |
| +- [ ] **Step 8: Commit, then the per-task review** |
| + |
| +```bash |
| +git add internal/console cmd/console/main.go |
| +git commit -m "offline move: the console job that runs the whole move" |
| +``` |
| + |
| +Brief Astra on this commit with the decision table as the claim to check: no path writes `OfflineAbort` from open or finishing; no path writes open without `offlineJobGate` and `offlineOpenCheck` passing on that tick's evidence; no tick writes two transitions. |
| + |
| +--- |
| + |
| +### Task 5: The CLI: `carlos move offline run`, and what `status` says |
| + |
| +**Census card needed** (`move.go` is in the root binary). |
| + |
| +**Files:** |
| +- Modify: `move.go` (`moveCommand` :122, `moveArgs` :164, `parseMoveArgs` :215, `moveOfflineUsage` :89, the CLI's `offlineView` :1067, `headline` :1489, `mover.offline` :1545, `runStatus` :1578), `move_test.go`, `offline_move_e2e_test.go`, `parity/cli.tsv` (by `make parity-doc`), `parity/parity.tsv:78` |
| +- Create: `internal/provision/testdata/plan14-root-reads-self-serve-moves-s1-one-command.tsv` and `docs/superpowers/notes/census-proposal-self-serve-moves-s1-one-command.md` (both written by `make census-propose`) |
| + |
| +**Interfaces:** |
| +- Consumes: the status view's `job` (Task 3), the `/run` door. |
| +- Produces: |
| + - Verb `run` in `moveCommand`'s offline list, first. `moveArgs.offline` may be `run`; it takes `--to` (required, as `start` and `stage`) and `--no-wait`. |
| + - The CLI's `offlineView` gains `Job *offlineJobSeen` (`json:"job"`): `State, Step, Reason string; StepAt, CheckedAt int64; Overdue bool; Steps []struct{Step string; At time.Time; Took float64 "json:\"took_s\""}`. `Reason` is console text: decode it as the existing `waiting` is and say it only through `saySpoken` (unknown: how `roundTrip` makes `serverText` for a field inside the view rather than an error body: read `moveReply.answer` at `move.go:442-520` and follow the path `waiting` takes; `TestMovesServerTextHasOneMaker` holds the rule). |
| + - `func (w *offlineRun) runRun(ctx context.Context, to string, wait bool) int` and `func (w *offlineRun) sayJob(v offlineView)`. |
| + |
| +**Behaviour:** |
| +- `run`: POST `/run` with `{"region": to}`. A refusal is the console's sentence, exit 5. On 202 say MV-O200. With `--no-wait`, exit 0. Otherwise `follow` the status view: say each step once as it starts (MV-O201) and once as it ends with its seconds (MV-O202), the existing stage progress line (`sayStaged`) on each round, and the console's waiting sentence each time it changes (`sayWaiting`). End: `done` is the existing `ended` lines, exit 0; `aborted` is MV-O203 (with the job's reason) and then the existing abort lines, exit 3; `stopped` is MV-O204, exit 4; `overdue` after open is MV-O205, exit 4, and the command stops watching. Interrupted (`m.sleep` false): MV-O208 instead of "Stopped waiting.", exit 1. |
| +- While following, if `now - job.checked_at > 30 s`, say MV-O206 once per gap. |
| +- `status` with a job: after the headline, MV-O207, then one line per finished step (MV-O202), then MV-O206 or MV-O205 when they apply, then today's item and report lines. With state `none` and a job whose state is `aborted` or `stopped`, say MV-O203 or MV-O204 before the outcome line. Exit 4 when `overdue` or `stopped`; otherwise today's codes. |
| +- `headline` with a job never says "Run carlos move offline <verb>": those five lines are for a hand move. |
| + |
| +- [ ] **Step 1: Write the failing tests** (`move_test.go`, with `fakeOfflineConsole` frames; `offline_move_e2e_test.go` for the real door): |
| + |
| +```go |
| +// TestParseMoveArgsOfflineRun: "offline run --host h --to uk" parses with offline |
| +// "run", to "uk", wait true; "--no-wait" clears wait; without --to it says |
| +// moveNeedsTo; "offline" alone says the new usage line (MV-O199). |
| +// TestMoveOfflineRun: frames staging(job step stage) -> stopping(start) -> sealing(seal) |
| +// -> landing(flip) -> landed(check) -> open(finish) -> none(last done, job done): |
| +// exit 0; the output has MV-O200 once, a started line for each of the seven steps |
| +// in order, a finished line with seconds for each, and the existing "Moved." line; |
| +// the fake saw exactly one POST, to /run, and no POST to any other door. |
| +// TestMoveOfflineRunNoWait: exit 0 after the 202; no GET. |
| +// TestMoveOfflineRunRefused: the door answers 409 with a sentence: exit 5, the |
| +// sentence as written, nothing else. |
| +// TestMoveOfflineRunAbortedByTheConsole: frames ... landing -> reverting(job returning, |
| +// reason "x") -> none(last aborted, job aborted, reason "x"): exit 3; output has |
| +// "The console stopped the move at step flip: x." and "Nothing was lost." |
| +// TestMoveOfflineRunOverdueAfterOpen (Review Focus 4): a frame open with job.overdue: |
| +// exit 4; output says the host is open in uk and the finish is still waiting; no |
| +// POST /abort. |
| +// TestMoveOfflineRunSaysWhenTheConsoleIsQuiet: a frame whose job.checked_at is 60 s |
| +// old: MV-O206 is said once. |
| +// TestMoveOfflineRunInterrupted: cancel ctx mid-follow: exit 1, MV-O208, no POST. |
| +// TestMoveOfflineStatusNamesTheStep: one frame sealing with job step seal started |
| +// 42 s ago and steps stage(79 s), start(23 s): output has "It is on step seal, |
| +// started 42 seconds ago." and both finished lines; no "Run carlos move offline". |
| +// TestMoveOfflineStatusAfterAConsoleAbort: frame none with last aborted and job |
| +// aborted with reason: MV-O203 then the outcome line; exit as today for aborted. |
| +// TestMoveOfflineRunAgainstTheRealDoors (offline_move_e2e_test.go): moveMain |
| +// "offline run --no-wait" on newOfflineE2E answers exit 0 and the record is |
| +// offline-staging; "offline status" then prints the step line for stage. |
| +``` |
| + |
| +- [ ] **Step 2: Run to see them fail** |
| + |
| +Run: `TMPDIR=/tmp/g go test . -run 'TestParseMoveArgsOfflineRun|TestMoveOfflineRun|TestMoveOfflineStatusNamesTheStep|TestMoveOfflineStatusAfterAConsoleAbort' -count=1` |
| +Expected: FAIL, `offline run` is a usage error. |
| + |
| +- [ ] **Step 3: Add the verb, the flags, `runRun`, `sayJob` and the status lines.** Every sentence goes through `moveSay` with the deck's text, and its row goes into the copy record as `pending` with its id in `movesCopyIDs` (MV-O181's row becomes `withdrawn`, replaced by MV-O199, the way MV-O56 was). |
| + |
| +- [ ] **Step 4: Run the CLI tests, the copy gate and the projection** |
| + |
| +Run: `TMPDIR=/tmp/g go test . -run 'TestParseMoveArgs|TestMoveOffline|TestMoves|TestCLIProjection|TestMoveDocs' -count=1` |
| +Expected: `TestMoveDocsOfflineParagraph` fails ("the page has no example of carlos move offline run") until Task 6; `TestCLIProjection` passes after `make parity-doc`; everything else PASS. unknown: whether `TestMovesStringsAreRecorded` sees sentences in the two new console files: add `internal/console/offlinejob.go` to `movesScanFiles` and run it once with a row removed to see it bite. |
| + |
| +- [ ] **Step 5: Census** |
| + |
| +Run: `make census-card`, write the CLAIMS file (one line per changed unit of `move.go`: output only, no new read), `make census-propose NAME=self-serve-moves-s1-one-command CLAIMS=<file>`, then `go test ./internal/provision -run 'TestPlan14RootReadCensus|TestCensusScopeIsTheRootBinary' -count=1`. |
| +Expected: PASS. The reviewer's verdict goes on #280 with the whole-branch review (Task 7). |
| + |
| +- [ ] **Step 6: Commit** |
| + |
| +```bash |
| +git add move.go move_test.go offline_move_e2e_test.go parity approved_moves_copy_test.go docs/superpowers/plans/2026-10-06-moves-phase1-copy.md internal/provision/testdata docs/superpowers/notes |
| +git commit -m "carlos move offline run: one command, and status names the step" |
| +``` |
| + |
| +--- |
| + |
| +### Task 6: Copy pass, docs, and the two-box witness |
| + |
| +**Files:** |
| +- Modify: `docs/site/cli.md:3371-3381`, `docs/superpowers/plans/2026-10-21-offline-move-runbook.md` (short version and §5), the copy record, `internal/host/movesoffline_e2e_test.go` |
| + |
| +**Interfaces:** |
| +- Consumes: `(*console.Server).RunOfflineMoveJobs`, `e2eWorld` (`tickAll`, `do`, `status`, `until`, `requireClosedWriteSet`). |
| +- Produces: `TestOfflineJobE2E`. |
| + |
| +- [ ] **Step 1: Hand the deck (Appendix A) to a delegated Luna pass** (the copy-review skill, human text only). Apply her edits verbatim to `move.go`, `offlinejob.go`, the tests that quote them and the record; set the rows `approved`. If the pass is not back when the rest is done, the rows stay `pending` and the merge waits for it. |
| + |
| +- [ ] **Step 2: Docs.** In `cli.md`, put `carlos move offline run --host <host> --to <region>` first in the command list and add the deck's paragraph D1 before the per-verb text; the sentence "never acts on its own" (line 3371, row MV-O32) now needs "except `run`": that edit is deck row D2. In the runbook, add to the short version and §5 that `run` replaces `move.sh`'s doors and gate, and that sections 2, 3 (the target check above all, until #339 lands), 6, 7, 9 and 10 are still the operator's. |
| + |
| +Run: `TMPDIR=/tmp/g go test . -run 'TestMoveDocs|TestMovesCopy|TestMovesApprovedCopyIsApplied|TestMovesStringsAreRecorded' -count=1` |
| +Expected: PASS. |
| + |
| +- [ ] **Step 3: Write the failing witness** (`internal/host/movesoffline_e2e_test.go`; keep the `*console.Server` on `e2eWorld`): |
| + |
| +```go |
| +// TestOfflineJobE2E, production wiring as TestOfflineMoveE2E (real console.Server, |
| +// two real box workers, the S3 fake): |
| +// forward: POST .../move/offline/run {"region":"uk"}; loop { w.tickAll(); |
| +// srv.RunOfflineMoveJobs(ctx) } until status state "none". The test posts to no |
| +// other door. Then the end-state assertions TestOfflineMoveE2E makes after its |
| +// finish (record region uk, last outcome done, the closed write set, the source |
| +// tombstone lifted, the row ready on the target) and job.steps holds the seven |
| +// steps. |
| +// abort: the same with the landing fault TestOfflineMoveE2E's abort-after-flip case |
| +// uses (landOpts); the loop ends with last outcome aborted, job.reason not empty, |
| +// the source row serving again, and no POST from the test but /run. |
| +``` |
| + |
| +unknown: `landOpts`' fault field names and whether the console's clock can be set from another package: read `newE2EWorld` and `landOpts` (`movesoffline_e2e_test.go:215` and `movesoffline_land_test.go`); real time is fine for both cases, since no deadline is shorter than 3 minutes and neither case waits on one. |
| + |
| +- [ ] **Step 4: Run** |
| + |
| +Run: `TMPDIR=/tmp/g go test ./internal/host -run 'TestOfflineJobE2E|TestOfflineMoveE2E' -count=1` (sandbox off) |
| +Expected: PASS. |
| + |
| +- [ ] **Step 5: Commit** |
| + |
| +```bash |
| +git add docs internal/host/movesoffline_e2e_test.go move.go move_test.go internal/console |
| +git commit -m "offline move job: copy pass, docs and the two-box witness" |
| +``` |
| + |
| +--- |
| + |
| +### Task 7: Whole-branch review and merge |
| + |
| +- [ ] **Step 1: Targeted verification, once.** |
| + |
| +Run: `gofmt -l .` (empty), `go vet ./internal/console ./cmd/console .`, `go build ./...`, `GOOS=darwin go build .`, `GOOS=windows go build .`, then the `-run` lines of Tasks 1 to 6 once more. |
| +Expected: clean. Do not run the full suite locally. |
| + |
| +- [ ] **Step 2: Push to amadan and read CI:** `amadan ci status carlos/platform -branch self-serve-moves-s1-one-command` exits 0. |
| + |
| +- [ ] **Step 3: One whole-branch Astra review** (`-m gpt-6-astra`, effort high), brief from the template, carrying the Task 3 and Task 4 round history, the Review Focus list, and the census card. It stops at the first round with no P1; P2 fixes are applied without a new round; P3s go on the branch's follow-up list. |
| + |
| +- [ ] **Step 4: Squash-merge on amadan** with an explicit message built in the same command (subject under 80 characters, body after a blank line). Read `main`'s CI run afterwards. |
| + |
| +--- |
| + |
| +### Task 8: Paul sees a dev move finish from one command |
| + |
| +Every step here changes dev and needs Paul's go; nothing in it is done by the build session on its own. |
| + |
| +- [ ] **Paul's go:** a release holding the merge, rolled to dev (console and CLI; boxes need nothing new). Release and roll by the platform recipes. |
| +- [ ] Runbook §2 and §3 for one small dev instance (source `sophie-knitting`, target `dennis-stenciling`), read-only. |
| +- [ ] **Paul's go:** `carlos move offline run --host <dev host> --to uk --console https://platform.dev.carlosframework.com`. Pass: exit 0, seven step lines, the "Moved." line; a client-measured offline time logged beside the console's. |
| +- [ ] In a second terminal during the move: `carlos move offline status --host <dev host>` names the step. Then restart the dev console's unit once between `seal` and `open` (**Paul's go**; about 11 s of console downtime) and read `status` again: same step or the next one, and the move still finishes. |
| +- [ ] One abort: a second instance, with a stale `/opt/carlos/live/<host>` link on the target if one can be arranged with Paul's approval, else `carlos move offline abort` by hand during `seal`. Pass: exit 3 from `run`, the reason line, the instance serving from `ie`. |
| +- [ ] Post the log on the branch's discussion and on the program plan's W3 line. |
| + |
| +--- |
| + |
| +## Appendix A. Copy deck (for the Luna pass) |
| + |
| +Next free ids after MV-O193; check `movesCopyIDs` before using them. `<step>` is one of: stage, start, seal, flip, check, open, finish. |
| + |
| +| Id | Where | Text | |
| +|---|---|---| |
| +| MV-O194 | console, job reason | `<step> did not finish within <n> minutes` | |
| +| MV-O195 | console, job reason | `the copy to <to> failed` | |
| +| MV-O196 | console, job reason | `<box> reported that it could not finish <step>` | |
| +| MV-O197 | console, job reason | `the move is no longer on the record. someone ended it by hand` | |
| +| MV-O198 | console, wait sentence | `the report from <box> does not show <host> landed and held for this move` | |
| +| MV-O199 | CLI usage, replaces MV-O181 | `carlos move offline needs run, stage, start, seal, flip, open, finish, abort or status.` | |
| +| MV-O200 | CLI, `run` accepted | `The console is moving <host> from <from> to <to>. It runs every step itself. Stopping this command does not stop the move.` | |
| +| MV-O201 | CLI, a step starts | `Step <step> started.` | |
| +| MV-O202 | CLI, a step ends | `Step <step> finished in <n> seconds.` | |
| +| MV-O203 | CLI, console abort | `The console stopped the move at step <step>: <reason>. It is moving <host> back to <from>.` | |
| +| MV-O204 | CLI, job stopped | `The console is no longer running this move: <reason>.` | |
| +| MV-O205 | CLI, overdue after open | `<host> is open in <to>. The move cannot finish yet: step <step> has waited <n> minutes. Nothing is lost, and the console keeps trying.` | |
| +| MV-O206 | CLI, console quiet | `The console last checked this move <n> seconds ago. If it is restarting, it carries on from this step when it is back.` | |
| +| MV-O207 | CLI, `status` | `The console is running this move. It is on step <step>, started <n> seconds ago.` | |
| +| MV-O208 | CLI, interrupted | `Stopped watching. The console keeps running the move. Run carlos move offline status --host <host> to see it.` | |
| +| MV-O209 | CLI flag help, `--no-wait` | `return once the console has accepted the move` | |
| +| D1 | `docs/site/cli.md` | `carlos move offline run` runs the whole move for you. The console stages the copy, takes the instance offline, copies what changed, starts it in the new region, checks it and opens it, then cleans up. If anything fails before the instance is open in the new region, the console moves it back and nothing is lost. `carlos move offline status` shows which step it is on. You can close the terminal: the console carries on. | |
| +| D2 | `docs/site/cli.md`, edit to MV-O32 | The other verbs do one step each and never act on their own: each says which verb comes next. | |
| + |
| +## Appendix B. Deferred, and why |
| + |
| +- **Paging.** Spec §8 pages on an overdue finish. Slice 1's operator is at the terminal and reads exit 4. It becomes necessary with slice 2, when nobody is watching. |
| +- **The health probe after open** (spec §7.4) needs the edge's probe mode. Slice 3 measures what a visitor sees first. |
| +- **A pause.** Before open, `abort` is the operator's stop; after open the job only finishes. No "stop driving, keep the move" control until someone needs one. |
| +- **The row fingerprint** (runbook §3.4, §7) stays a hand check: it reads the app's tables, which no box report carries. |
| +- **Per-box reservations, `offline-queued`, lane and target-ready reports, estimates, cleanup** (spec §7.1, §7.3, §6.3, §7.6): the program plan's W3 "Deferred". |
| + |
| +## Self-review |
| + |
| +- **Spec coverage.** W3 slice 1: one command (Tasks 3, 5); the console drives stage, start, seal, flip, open, finish through the doors' logic (Tasks 1, 4); a durable job (Tasks 2, 4); the landing reports as the gate (Task 4, `offlineJobGate`); aborts on its own before open (Task 4); `status` names each step (Tasks 3, 5); operator-only (Task 3); Paul sees a dev move (Task 8). Runbook: stage until caught up and once more before start (§4: the job's last round is the final stage, and start follows it on the next tick); "before open any failure aborts, after open none" (§5, §11); the MV-O178 retry (any non-final refusal waits to the deadline); log each step before it runs (§1: row before record). Program-plan gate "W4 merged before slice 1": the plan builds either way and says where the two meet. D4: answered in Global Constraints. |
| +- **Gaps left on purpose:** Appendix B. |
| +- **Types.** `OfflineMoveJob`, `OfflineJobStep`, `offlineJobView`, `offlineJobInput`, `offlineJobDecision`, `offlineJobGate`, `RunOfflineMoveJobs`, `StartOfflineMoveJobs` are spelled the same in Tasks 2 to 6. The CLI's own type is `offlineJobSeen` because `offlineRun` and `offlineView` already exist in `move.go`. |
| +- **Review Focus.** Each of the five lines names its test and task. |
| +- **Proportion.** No function bodies; the decision is a table because the signatures and tests alone do not determine it. |