plan: slice 1 rev 2 (Astra round 1 dispositions)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md+377 −221
Intent
<task-notification> <task-id>a4a1b0aa020a2a126</task-id> <tool-use-id>toolu_01Sz689xGC33HmvYF7bo2THX</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>Rev 2 is written to the same plan file, uncommitted, with a "Round 1 dispositions" section at the end. All nine findings are accepted; none declined. **Structural changes** - **Durable intent on the job row, bound to one move id.** Findings 1 to 3 are treated as one fault family and closed by one tick order: bind, settle intent, then decide. Five named invariants (I1 to I5) each have one enforcing place and a test. - A tick whose record does not carry the job's move id reads and writes nothing; it only closes the row. - An intent clears only after the record shows its effect and the serial bump then succeeded. - An abort is a durable `returning` state, retried, and can never turn into an open. - Stage rounds are counted from the record's `staged_at`, not from attempts. - **Re-attach comes before any new-move check** in the `run` door, so it works in every state. - **`run` stops at open**, per your call. I built no `run --finish`: the existing `finish` verb already does it. The after-open half of the job is gone. - **New Task 0:** UX pass, then Paul's copy review, before any string is written. - **Census proposal moved to Task 7**, after the last source edit. - **Scratch** is a per-session `mktemp -d` directory. **Needs Paul** - Confirm the four controller's calls, each marked as such in the plan. - Finding 7 makes Paul, not Luna, the copy approver, which differs from the original brief. - W3's wording says the job finishes the move; rev 2 stops at open.</result> <usage><subagent_tokens>295118</subagent_tokens><tool_uses>5</tool_uses><duration_ms>342834</duration_ms></usage> </task-notification>
<task-notification> <task-id>a5a8684b1f0a9b866</task-id> <tool-use-id>toolu_013RT4XtvwWfyVsAbedxAyae</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a5a8684b1f0a9b866.output</output-file> <status>completed</status> <summary>Agent "Implement #339 stage refusals" is waiting on its own background work</summary> <note>This agent stopped with background work of its own still running. It may resume on its own when that work completes or reports, and the same task-id notifies again if it does; the result below may be interim.</note> <result>Waiting on the mutation runs.</result> <usage><subagent_tokens>288696</subagent_tokens><tool_uses>110</tool_uses><duration_ms>1555618</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| index 49d8f97f5..226073673 100644 |
| --- 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 |
| @@ -2,40 +2,51 @@ |
| > **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. |
| +Rev 2, 2026-11-13. Rev 1 (f6287be0) was reviewed by Astra, round 1 of 3: NOT READY, 5 P1 and 4 P2 (`docs/superpowers/reviews/CODEX-FINDINGS-SELF-SERVE-SLICE-1-R1.md`). Rev 2 answers every finding ("Round 1 dispositions" at the end) and carries four controller's calls, each marked so, that stand until Paul rules. The main change is one mechanism: the job's row holds a durable **intent** bound to one move id, and every tick settles that intent before it decides anything. |
| -**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. |
| +**Goal:** `carlos move offline run --host <h> --to <region>` asks the console to run an offline move from stage to open (stage, start, seal, flip, check, open) as a durable job that aborts on its own on any failure, and `carlos move offline status` names the step the job is on, even after a console or CLI restart. The operator checks the instance and runs the existing `finish`. |
| -**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`). |
| +**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), and writes at most one record transition per tick. Before a transition the row records the intent; the next look confirms it from the record, announces it (the serial bump) and only then clears it. 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. |
| -**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. |
| +**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` with its serial-driven `e2eLoops` (`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, §7, §8 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. |
| +- **The record is the truth.** The job decides from a record read on that tick, never from its row alone. |
| +- **The job's invariants** (Task 4 enforces each in one place and names it in a comment and a test): |
| + - **I1, one move.** A job's authority is one move id. A tick whose record does not carry an offline move with `Move.ID == Job.ID` reads no evidence and writes nothing to the record; it only closes the row. |
| + - **I2, intent before effect.** No record transition is written unless the row already says which one. An intent is cleared only after the record shows its effect *and* the serial was bumped after that. So recovery can always tell "meant to" from "did", and a transition whose reply was lost is still announced to the boxes. |
| + - **I3, a decided abort stays decided.** Once the row says `returning`, the job never advances the move. It retries the abort until the record is reverting, or until a person has opened the move by hand. |
| + - **I4, repeats are refusals.** Every transition the job writes names `Job.ID` and the one state it leaves (`provision.offlineAt`), so writing it twice is a refused conflict, never a second effect. The one transition that stays in its state (`OfflineRestage`) is harmless to repeat: rounds are counted from the record's `staged_at`, not from attempts. |
| + - **I5, nothing after open.** Once the record is `offline-open` or later, the job writes nothing to it, ever. |
| +- **`run` stops at open** (controller's call until Paul rules). The job ends when the move is open. `finish` stays the existing door and verb, run by the operator after the runbook's §7 checks, the row fingerprint among them. No `run --finish` is built: the existing `carlos move offline finish` already does it. |
| +- **Before open, every failure aborts, and the job finishes its own abort** (spec §7.5, runbook §11): the instance is back on the source with nothing for the operator to run. |
| +- **No paging in slice 1** (controller's call until Paul rules). An abort that cannot finish shows as overdue in `status` and exit 4. |
| +- **Build on today's main** (controller's call until Paul rules; stopping rule 4). W4's branches `offline-move-pool-target-413` and `offline-move-stage-refusals-339` are not on main and nothing here depends on them. 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. |
| +- **One console per deployment.** As every other console pass assumes (spec §7). The serve lock guards one database file, not two consoles on one bucket; this slice does not change that. |
| - **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. |
| +- **Census.** `move.go` is in the root binary (`go list -deps .`), so the CLI change needs a census card. The proposal is generated once, in Task 7, after the last source edit, and again after any later in-scope fix (AGENTS.md "The census"). `internal/console` and `cmd/console` are out of scope. |
| +- **UX pass, then copy, then code** (AGENTS.md "Every UI change gets a UX pass"; the copy-review skill). Task 0 does the UX pass on the CLI output and takes the deck in Appendix A to Paul. Luna may draft; only Paul's review makes a row `approved`. No new sentence enters a product file before that. Plain words, no em dashes. Reasons the job records are sentences the doors already speak wherever one exists. |
| - **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 budget (stopping rules 1 to 3):** this design has had one round. 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). Rounds 2 and 3 are all that remain for the design across plan, tasks and branch; a fourth needs Paul's go. 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). |
| +- **Scratch.** 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 a scratch directory this session made and owns: `export G=$(mktemp -d "$TMPDIR/g.XXXXXX")`, then `TMPDIR=$G go test …`, then `rm -r "$G"` when the task ends. Only if a test fails to bind a unix socket for the length of that path, use `mktemp -d /tmp/g.XXXXXX` instead (a few socket files, nothing large) and remove that one directory. Never a fixed shared name, never a glob. |
| +- **Branch:** `self-serve-moves-s1-one-command`, cut from amadan `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 to open. 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`). |
| +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. Task 4, `TestOfflineJobResumesAfterRestart`. |
| +2. **An operator runs a door by hand while the job runs** (`abort`, `flip`, or `open`). The job follows the record: it finishes the abort and ends `aborted`, carries on from the new state, or ends `opened`. It never undoes a hand step. Task 4, `TestOfflineJobFollowsHandDoors`. |
| +3. **`run` again, at any point of the move.** The same host and region re-attaches to the one job in every state from staging to finishing; another region is refused; another host gets the existing one-at-a-time sentence (MV-O30). Task 3, `TestOfflineRunDoorReattachesInEveryState`. |
| +4. **The move under a live job is replaced** (while the console was down, someone finished move A and staged move B for the same host). A's job closes and never reads, starts, opens or aborts B. Task 4, `TestOfflineJobLeavesAnotherMoveAlone`. |
| +5. **A write whose reply was lost, or a crash between the write and the serial bump.** The next tick confirms the transition from the record, bumps the serial, and writes nothing twice; a lost abort is retried and never turns into an open. Task 4, `TestOfflineJobSettlesALostReply` and `TestOfflineJobKeepsAPendingAbort`; Task 6's witness runs the boxes by serial only, so a missing bump fails it. |
| --- |
| @@ -45,7 +56,7 @@ |
| |---|---| |
| | `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.go` (create) | The `run` door, the worker, the tick (bind, settle, decide), 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. | |
| @@ -55,11 +66,26 @@ |
| --- |
| +### Task 0: UX pass on the CLI output, then Paul's copy review |
| + |
| +Nothing is built here. It runs first so that every later task writes approved text. |
| + |
| +**Files:** none in the product. The mock and the deck live in this plan (Appendix A) and in the copy-review server's result. |
| + |
| +- [ ] **Step 1: UX pass.** Write out, as plain terminal text, what a person sees for: `run` to open; `run` aborted by the console at `flip`; `status` mid-move (step `seal`); `status` after a console abort; `status` when the console has been quiet for a minute. Bar (AGENTS.md): the first line is the state, about a dozen words tell the reader where the move is, a problem is its own line and not inside a paragraph. Appendix A's "Mock" is the starting point; fix what reads badly there before the deck goes anywhere. |
| +- [ ] **Step 2: Draft pass.** A delegated Luna pass may tighten the deck's wording. It approves nothing. |
| +- [ ] **Step 3: Paul's review** with the copy-review skill (human text only: the deck's rows and the `cli.md` paragraph, shown in the mock's layout). Apply his edits verbatim to Appendix A. From here the rows are `approved` and later tasks copy them exactly. |
| +- [ ] **Step 4: No commit of product files.** Commit Appendix A's final text to the branch (`plan: slice 1 copy as approved`). |
| + |
| +If Paul's review is not back, Tasks 1 to 4 (which add five console sentences, MV-O194 to MV-O198) may be built up to but not including the lines that speak them; Task 5 waits. |
| + |
| +--- |
| + |
| ### 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).* |
| +*W4 note: #413 and #339 change `offlineSelect` and the stage and start refusals in these same functions. If either has merged by the time this task starts, 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` |
| @@ -70,7 +96,8 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| - 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) offlineRegionCode(region string) (to string, ref *offlineRefusal)`: the region's shape only (`homeRegionIn`, `provision.ValidRegion`; "invalid region"). |
| + - `func (s *Server) offlineRegionRefusal(ctx context.Context, d offlineDoor, region string) (to string, fleet offlineFleet, ref *offlineRefusal)`: `offlineRegionCode`, then `haTransferRegion`, already there, manifest regions, fleet read, the `CARLOS_REGION` home rule, `offlineSelect`. It does not take the lock; the lock refusal (MV-O30) stays in `offlineBeginMove`. |
| - `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`. |
| @@ -80,8 +107,11 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| ```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. |
| +// table that is refused before the lock is taken (class, claims, region and fleet |
| +// rules), offlineClassRefusal then offlineRegionRefusal, called directly on the same |
| +// world, return the status and sentence the POST answered. The table's lock case |
| +// (MV-O30) is not a helper's refusal: assert the helpers pass it (nil, nil) and that |
| +// offlineBeginMove returns it. |
| // TestOfflineSealCheckMarksFinalRefusals: the sidecar and two-data-box refusals carry |
| // final == true; offlineWaitRefusal, offlineStaleRefusal and offlineStateRefusal do not. |
| // TestOfflineApplyStepReleasesTheLock: an OfflineFinish applied through |
| @@ -91,14 +121,14 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineBeginRefusalsMatchTheDoor|TestOfflineSealCheckMarksFinalRefusals|TestOfflineApplyStepReleasesTheLock' -count=1` |
| +Run: `TMPDIR=$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` |
| +Run: `TMPDIR=$G go test ./internal/console -run 'TestOffline' -count=1` then `TMPDIR=$G go test . -run 'TestMoves|TestMoveOffline' -count=1` |
| Expected: PASS, with no existing test edited. |
| - [ ] **Step 5: Commit** |
| @@ -120,16 +150,25 @@ git commit -m "offline move: door bodies as functions, no behaviour change" |
| - Produces: |
| ```go |
| -// OfflineMoveJob is one console-run offline move. ID is the move id on the record. |
| +// OfflineMoveJob is one console-run offline move. ID is the move id on the record, |
| +// and the only move this job may ever act on (I1). |
| 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) |
| + State string // running | returning | opened | done | aborted | stopped |
| + Step string // stage | start | seal | flip | check | open | abort |
| + StepAt time.Time // when Step began |
| 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 |
| + TickAt time.Time // the pass's last look; set at admission |
| + // Intent is the one record transition the job has decided and not yet settled |
| + // (I2): "" | restage | start | seal | flip | open | abort | finish. |
| + Intent string |
| + IntentAt time.Time |
| + // StageAsked is the record's staged_at as of the last settled stage request; |
| + // Rounds counts settled requests. A stager report is a finished round only when |
| + // it answers StageAsked. |
| + StageAsked time.Time |
| + Rounds int |
| + FlippedAt time.Time // set when the flip intent is settled; 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 |
| @@ -149,19 +188,19 @@ func (s *Store) OfflineJobFor(host string) (*OfflineMoveJob, error) // newest by |
| ``` |
| - 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. |
| +- `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: the claim tests of step 4 range over `claimSQLTables`; 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. |
| +// Intent, IntentAt, StageAsked and Steps included; SaveOfflineJob changes Step, |
| +// Intent, 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. |
| +// running or returning returns ErrOfflineJobLive; after the first is saved as |
| +// opened, the second Insert succeeds and OfflineJobFor returns the second. |
| +// TestLiveOfflineJobs: of rows in running, returning, opened, done, aborted and |
| +// stopped, only the first two come back, oldest first. |
| // TestOfflineJobTableSurvivesReopen: Open the same file again; the row is there. |
| ``` |
| @@ -195,7 +234,7 @@ git commit -m "offline move job: the console's job table" |
| - 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. |
| +- Consumes: Task 1's `offlineClassRefusal`, `offlineRegionCode`, `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"`): |
| @@ -206,7 +245,7 @@ type offlineJobView struct { |
| 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 |
| + Overdue bool `json:"overdue,omitempty"` // returning, and past its deadline |
| CheckedAt int64 `json:"checked_at"` // the pass's last look |
| Reason string `json:"reason,omitempty"` |
| Steps []OfflineJobStep `json:"steps"` |
| @@ -214,39 +253,50 @@ type offlineJobView struct { |
| 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). |
| + `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`; 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:** |
| +**What the door does, in order** (invariant: *a retry of an accepted request keeps its identity for the whole move*, so the job is recognised before any check a new move must pass): |
| -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`. |
| +1. `offlineGate`. Authentication is the route's own (`cliGateRefused`): no token or a bad one is its 401, before this door runs. |
| +2. `readJSON`, then `offlineRegionCode` (the region's shape only). |
| +3. **The record carries an offline move:** |
| + - a live job (`running` or `returning`) with that move's id, and `to == mv.To`: write nothing, answer 202 with the view. This holds in every state from `offline-staging` to `offline-reverting`. |
| + - a job in `opened` with that move's id, and `to == mv.To` (the move is open or finishing): the same 202; the CLI says it is open. |
| + - such a job, another region: `offlineStagedFor` (MV-O179) while staging, else `offlineStateRefusal` (MV-O25). |
| + - no job for that move, `offline-staging`, same region: adopt the hand-staged move. `offlineClassRefusal`, `offlineRegionRefusal`, `offlineStageCoords`, `OfflineRestage` through `offlineApplyStep`, then insert the row. Another region: MV-O179. |
| + - no job for that move, any later state: `offlineStateRefusal` (MV-O25). A move a person started by hand past staging is theirs. |
| +4. **The record carries no offline move:** `offlineClassRefusal`, `offlineRegionRefusal`, `offlineStageMut`, `offlineBeginMove` (which takes the lock, so MV-O30 comes from here), then `InsertOfflineJob`: ID the new move's, `State: "running"`, `Step: "stage"`, `StepAt`, `TickAt` and `CreatedAt` now, `StageAsked` the record's `staged_at`, `Rounds: 1`, `DeadlineAt` now + 30 min, `RequestedBy: d.addr`, no intent. |
| +5. 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. |
| +// TestOfflineRunDoorIsOperatorOnly: /run answers what POST /stage answers, byte for |
| +// byte, for: no token and a fabricated token (the route's 401), a member's token and |
| +// a service token (the operator gate's 404). 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. |
| +// (the lock row included: it is the door's refusal, through offlineBeginMove) and of |
| +// TestOfflineStageRefusesABoxThatCannotStage, on a record at rest, 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 |
| +// len(.Steps) == 1; the row's TickAt and StageAsked are set and Intent is ""; |
| +// w.lock() names the host; the serial changed. |
| +// TestOfflineRunDoorReattachesInEveryState (Review Focus 3): with a live job for the |
| +// move, for the record in each of staging, stopping, sealing, sealed, landing, |
| +// landed and reverting (set with w.edit and the fixture's helpers; from landing on, |
| +// record().Region is already "uk"): POST /run {"region":"uk"} answers 202 with the |
| +// same view.ID, LiveOfflineJobs has one row and bucketState is unchanged. With the |
| +// job opened and the record open or finishing: the same 202. In each state POST /run |
| +// {"region":"de"} is refused (msgO179 while staging, msgO25(state) after) and writes |
| +// nothing. 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. |
| +// staged_at moved forward, one job row with the staged move's id and StageAsked |
| +// equal to the new staged_at. |
| // 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" |
| @@ -256,14 +306,14 @@ A crash between the record write and the row insert leaves an ordinary staged mo |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineRunDoor|TestOfflineStatusCarriesTheJob' -count=1` |
| +Run: `TMPDIR=$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` |
| +Run: `TMPDIR=$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** |
| @@ -287,7 +337,7 @@ Brief Astra on this commit: the door's gate order against the other offline door |
| - 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`. |
| +- Consumes: Tasks 1 to 3; `offlineStepFor`, `readOfflineEvidence`, `offlineStageOf`, `offlineOpenCheck`, `offlineReleaseLock`, `s.readRecord`, `s.store.AccountBySqid`, `s.movesNow`, `release.BumpSerial` (it returns the error `s.bumpSerial` only logs), `lifetimesWorker`, `s.lifetimesIteration`, `s.jobs.Run`, `jobFailed`. |
| - Produces: |
| ```go |
| @@ -302,22 +352,23 @@ const ( |
| 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 |
| + offlineJobAbortWait = 10 * time.Minute // returning: overdue after this, still retried |
| 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 offlineJobBound(j OfflineMoveJob, rec *provision.Record) (bound bool, close offlineJobDecision) // I1, pure |
| +func offlineJobSettled(j OfflineMoveJob, mv *provision.MoveState) bool // I2: does the record show the intent's effect; pure |
| +func offlineJobDecide(in offlineJobInput) offlineJobDecision // pure; called only with no intent pending |
| 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 |
| + Move *provision.MoveState // never nil, and Move.ID == Job.ID (I1 ran first) |
| 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 |
| @@ -325,113 +376,161 @@ type offlineJobInput struct { |
| 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 |
| + Action string // wait | intend | close |
| + Intent string // intend: restage | start | seal | flip | open | abort | finish |
| + Step string // the step the row shows from now |
| + Wait time.Duration // that step's deadline from now; 0 for none |
| + State string // close: opened | done | aborted | stopped. intend abort: returning |
| + 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 | | | |
| +**One tick, in this order.** Each phase names the invariant it is the one place for. |
| + |
| +1. **Bind (I1).** Read the record. `offlineJobBound`: the record carries an offline move and `Move.ID == Job.ID`. If not, the tick reads no report and no fleet, and writes nothing to the record. It closes the row: `Last.ID == Job.ID` gives `Last.Outcome` (`aborted` or `done`); anything else is `stopped` with MV-O197. A row closed here with intent `finish` first bumps the serial and calls `offlineReleaseLock(ctx, host, Job.ID)` (both safe to repeat; the lock helper only deletes a lock naming this host and this move), so a finish whose reply was lost is still announced and still frees the lock. |
| +2. **Clock.** If `now - TickAt > 30 s` and the row has a deadline, add the gap to `DeadlineAt` (downtime is not the step's fault). Set `TickAt = now`. |
| +3. **After open (I5).** Record state `offline-open` or `offline-finishing`: if the intent is `open`, bump the serial; then close the row `opened` (keeping `Reason`, if a pending abort lost to a hand `open`). Nothing is written to the record. |
| +4. **Settle the intent (I2, I3)**, when the row has one: |
| + |
| + | Intent | The record shows its effect when | When settled, the row gets | |
| + |---|---|---| |
| + | `restage` | `Move.StagedAt` is after `StageAsked` | `StageAsked = Move.StagedAt`, `Rounds++` | |
| + | `start` | state is not `offline-staging` | step `start`, deadline 5 min | |
| + | `seal` | state is past `offline-stopping` | step `seal`, deadline 10 min | |
| + | `flip` | state is past `offline-sealed` | step `flip`, `FlippedAt = now`, deadline 10 min | |
| + | `open` | phase 3 | | |
| + | `abort` | state is `offline-reverting` | (state `returning` and step `abort` were saved with the intent) | |
| + | `finish` | phase 1 | | |
| + |
| + - **Shown:** `release.BumpSerial`. Only if it succeeds, apply the row changes, clear the intent and save. If it fails, keep the intent; the next tick bumps again. The tick ends here. |
| + - **Not shown, intent `abort`:** write `OfflineAbort(Job.ID)` again through `offlineApplyStep`. The tick ends here. The job never decides anything else while this intent stands. |
| + - **Not shown, any other intent:** clear it and go on to phase 5 on this tick's evidence. Nothing is assumed from the old attempt: the checks run again, and if the old write lands late, the new one is a refused conflict (I4). |
| +5. **Decide**, with no intent pending: `readOfflineEvidence`, `offlineStepFor`, `offlineJobGate` in `offline-landed`, then `offlineJobDecide` (the table below). |
| +6. **Act.** For `intend`: save the row with the intent, `IntentAt`, the step and its `Steps` entry (the previous entry's `Took` filled in), and for `abort` also state `returning`, `Reason` and deadline now + 10 min. Then write the transition through `offlineApplyStep`, always built with `Job.ID`. If it returns without error, phase 4's "shown" branch runs at once (the record returned shows the effect; `offlineApplyStep` bumped, and the settle bumps once more, which is harmless). If it returns an error, leave the row as saved: the next tick settles it. |
| + |
| +**The decision table** (phase 5). Evidence first, deadline second: a step whose evidence is in advances even when its deadline has passed. |
| + |
| +| Row state | Record state | Step shown | Intend when | Intent | Deadline | Otherwise | |
| +|---|---|---|---|---|---|---| |
| +| running | `offline-staging` | `stage` | the stager's report answers `StageAsked` (`Stage.Request == StageAsked == Move.StagedAt`), phase `staged`, and (`Rounds >= 2` and `RoundBytes < 16 MiB`, or `Rounds >= 10`, or 30 min since `CreatedAt`), and `offlineClassRefusal`, `offlineRegionRefusal` and `offlineStepFor` pass on the fresh record | `start` (`OfflineStartStaged`) | 30 min | round answered, not caught up: intend `restage` (`OfflineRestage`). Round phase `failed`: abort, MV-O195. A start refusal: abort with that sentence (the instance never went offline) | |
| +| running | `offline-stopping` | `start` | `offlineStepFor` passes (every source box stopped) | `seal` (`OfflineSeal`) | 5 min | wait, then abort | |
| +| running | `offline-sealing` | `seal` | never: the box moves the record to `offline-sealed` | | 10 min | wait, then abort | |
| +| running | `offline-sealed` | `seal` | `offlineStepFor` passes (the flip's checks) | `flip` (`OfflineFlip`) | 5 min | wait, then abort | |
| +| running | `offline-landing` | `flip` | never: the box moves the record to `offline-landed` | | 10 min | wait, then abort | |
| +| running | `offline-landed` | `check` | `offlineJobGate` and `offlineStepFor` (`offlineOpenCheck`) both pass | `open` (`offlineOpenMut`) | 3 min | wait, then abort | |
| +| running | `offline-reverting` | `abort` | (a person aborted) set state `returning`, no `Reason`; then as the next row | | | | |
| +| returning | `offline-reverting` | `abort` | `offlineStepFor` passes (every box reverted) | `finish` (`OfflineFinish`) | 10 min | wait; past the deadline `Overdue`, still retried | |
| 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. |
| +- **Abort** is intent `abort`. It is decided 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 the row's step, the tick sets the row's step to the table's step for that state (a new `Steps` entry, a fresh deadline) and carries on. That is all "following" is. |
| +- **`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; when a person ran the flip, `FlippedAt` is when the job first saw the move past sealed); `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. |
| +- **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. |
| +- **One line per event in the console log:** `console: offline move job <host> <id>: <step>: <what>` for each intent, each settle, 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): |
| +- [ ] **Step 1: Write the failing pure tests** (`offlinejob_test.go`, 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". |
| +// TestOfflineJobBound (I1): record with no move, a non-offline move, an offline move |
| +// with another id -> not bound; close is Last's outcome when Last.ID == Job.ID, else |
| +// stopped with the MV-O197 reason. Same id -> bound. |
| +// TestOfflineJobSettled (I2): one row per line of the intent table, each with the |
| +// record just before (false) and just after (true) the effect; restage with |
| +// StagedAt equal to StageAsked is false, one nanosecond later true. |
| +// TestOfflineJobDecide: one case per line of the decision table, and: |
| +// staging, report answers StageAsked, Rounds 1, RoundBytes 1<<10 -> intend restage |
| +// staging, Rounds 2, RoundBytes 1<<10 -> intend start |
| +// staging, Rounds 2, RoundBytes 32<<20 -> intend restage |
| +// staging, Rounds 10, RoundBytes 32<<20 -> intend start |
| +// staging, report answers an older staged_at -> wait |
| +// staging, Stage.Phase failed -> intend abort, Reason "the copy to uk failed" |
| +// stopping, Step = offlineWaitRefusal, before deadline -> wait, Waiting = its sentence |
| +// stopping, same, Now after DeadlineAt -> intend abort, Reason "start did not finish within 5 minutes" |
| +// stopping, Step nil, Now after DeadlineAt -> intend seal (evidence first) |
| +// stopping, Step.final -> intend abort, Reason = the refusal's sentence |
| +// sealing, Failed "annie" -> intend abort, Reason names annie and seal |
| +// landed, Gate refuses -> wait; after deadline intend abort |
| +// landed, Gate nil, Step nil -> intend open |
| +// running, reverting -> State returning, Reason "" |
| +// returning, reverting, Step refuses, Now after DeadlineAt -> wait, Overdue true |
| +// returning, reverting, Step nil -> intend finish |
| +// TestOfflineJobReturningNeverAdvances (I3): for Job.State returning and every record |
| +// state and input the table uses, Intent is never start, seal, flip, open or restage. |
| // 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). |
| +// target reports -> a refusal (naming the box when there is one). |
| ``` |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `go test ./internal/console -run 'TestOfflineJobDecide|TestOfflineJobNeverAbortsAfterOpen|TestOfflineJobGate' -count=1` |
| +Run: `go test ./internal/console -run 'TestOfflineJobBound|TestOfflineJobSettled|TestOfflineJobDecide|TestOfflineJobReturningNeverAdvances|TestOfflineJobGate' -count=1` |
| Expected: build failure, `offlineJobDecide undefined`. |
| -- [ ] **Step 3: Write `offlineJobDecide` and `offlineJobGate`.** Run the three tests. Expected: PASS. |
| +- [ ] **Step 3: Write `offlineJobBound`, `offlineJobSettled`, `offlineJobDecide` and `offlineJobGate`.** Run the five 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): |
| +- [ ] **Step 4: Write the failing tick tests.** On `offlineWorld`, with `srv.movesClock` set to one test clock that the fixtures' report times also use. The boxes are played by the fixture's `staged`, `stagerStopped`, `stopped`, `sealed` and `sealerFresh`, plus two new helpers for the job's gate: `landedForJob(target string)` (the `landed` helper's report with `Held` and `RowPresent` true and `At` the test clock's now) and `advance(d time.Duration)` (steps the clock in 5 s ticks, calling `RunOfflineMoveJobs` at each, so no step is ever mistaken for downtime). A store wrapper `flakyStore` can make the next record `Put` either fail before it lands or land and return an error, and counts committed record `Put`s and serial bumps. |
| ```go |
| -// TestOfflineJobRunsAMoveEndToEnd: POST /run, then alternate RunOfflineMoveJobs with |
| +// TestOfflineJobRunsAMoveToOpen: 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. |
| +// (staging, stopping, sealing, sealed, landing, landed, open), record().Region == |
| +// "uk", the job row opened with Steps stage,start,seal,flip,check,open each with |
| +// Took > 0 and Intent "", the lock still held (finish is the operator's), and that |
| +// the test posted to no door but /run. Then POST /finish twice by hand with the |
| +// fixture's parked and gone reports ends the move done, and the job row is |
| +// unchanged. |
| +// TestOfflineJobWritesNothingAfterOpen (I5): with the record open or finishing and |
| +// the row running or returning, with and without an abort intent, ten ticks commit |
| +// zero record Puts. |
| +// TestOfflineJobIntentBeforeEffect (I2): flakyStore fails the next record Put before |
| +// it lands, in stopping: after the tick the row has Intent "seal" and a Steps entry |
| +// for it, and the record is still stopping; the next tick clears the stale intent, |
| +// decides again and writes the seal. |
| +// TestOfflineJobSettlesALostReply (Review Focus 5): for each of start, seal, flip, |
| +// open and restage: flakyStore lets the Put land and returns an error. After that |
| +// tick the row still has the intent. The next tick commits no record Put, bumps the |
| +// serial exactly once more (the count rises by one) and clears the intent. Then the |
| +// same with the process "crashing" between the write and the bump: apply the |
| +// transition directly with provision.SetRecordMove (no bump), leave the row's intent |
| +// set, tick: one bump, no record Put. |
| +// TestOfflineJobKeepsAPendingAbort (I3, Review Focus 5): in landed with a target |
| +// report phase failed: flakyStore fails the abort's Put before it lands; then the |
| +// target's report is replaced by a passing landedForJob. The next tick writes |
| +// OfflineAbort again (the record is reverting) and never open. Then: a hand POST |
| +// /open wins the race instead: the tick closes the row opened with its Reason kept |
| +// and writes nothing. |
| +// TestOfflineJobLeavesAnotherMoveAlone (I1, Review Focus 4): run move A to sealed; |
| +// by hand abort and finish A, then POST /stage a new move B for the same host, |
| +// leaving A's row running. With a counting store: A's next tick lists no report |
| +// prefix, commits no record Put, and closes A's row (aborted, from Last) or stopped |
| +// when B has since ended too; B's record is byte for byte unchanged. |
| // 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". |
| +// TestOfflineJobAbortsOnADeadline: in sealing, advance(10*time.Minute + 5*time.Second) |
| +// 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. |
| +// TestOfflineJobCountsRoundsFromTheRecord: flakyStore fails a restage before it |
| +// lands: Rounds does not rise and the old stager report (answering the old |
| +// staged_at) is not taken as a new round; after the retry lands, Rounds rises by one. |
| // 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. |
| +// Server over the same store and bucket; set the clock forward 20 min in one jump |
| +// (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). |
| +// stopping: the next ticks end the row aborted with Reason "" and commit no record |
| +// Put but the finish; (b) POST /flip by hand in sealed: the next tick sets the row's |
| +// step to flip and FlippedAt, commits nothing, and the move still reaches open; |
| +// (c) POST /open by hand in landed: the next tick closes the row opened. |
| // 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 |
| @@ -440,36 +539,35 @@ Expected: build failure, `offlineJobDecide undefined`. |
| - [ ] **Step 5: Run to see them fail** |
| -Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOfflineJob' -count=1` |
| +Run: `TMPDIR=$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}`. |
| +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}`, after phase 1 has passed. |
| - [ ] **Step 7: Run** |
| -Run: `TMPDIR=/tmp/g go test ./internal/console -run 'TestOffline|TestClaim|TestEveryWorkerReportsItsRuns|TestPassFailureLogsAlsoFailTheJob|TestWorkerRunsReachTheRegistry' -count=1` then `go build ./cmd/console` |
| +Run: `TMPDIR=$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" |
| +git commit -m "offline move: the console job that runs a move to open" |
| ``` |
| -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. |
| +Brief Astra on this commit with invariants I1 to I5 as the claims to check, each against the one phase that enforces it, and with round 1's findings 1 to 3 named as the fault family they close (*recovery must tell an intended transition from a completed and announced one, for the job's own move only*). Under stopping rule 2, a second round in that family means stop and offer Paul the cut, not a third fix. |
| --- |
| ### Task 5: The CLI: `carlos move offline run`, and what `status` says |
| -**Census card needed** (`move.go` is in the root binary). |
| +Needs Task 0's approved text. The census card is made in Task 7, after the last edit to `move.go`. |
| **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`) |
| +- 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`, the copy record, `approved_moves_copy_test.go` (`movesCopyIDs`, `movesScanFiles`) |
| **Interfaces:** |
| - Consumes: the status view's `job` (Task 3), the `/run` door. |
| @@ -479,10 +577,15 @@ Brief Astra on this commit with the decision table as the claim to check: no pat |
| - `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. |
| +- `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`). It ends when the job does: |
| + - `opened`: the existing served line (`sayServed`: "… is served from uk. Run carlos move offline finish --host … once ie has cleaned up."), then MV-O205, exit 0. The CLI does not post `finish`. |
| + - `aborted`: MV-O203 with the job's reason, then the existing abort lines (`ended`), exit 3. |
| + - `stopped`: MV-O204, exit 4. |
| + - `returning` and `overdue`: MV-O210, 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. |
| +- `status` with a job: after the headline, MV-O207, then one line per finished step (MV-O202), then MV-O206 or MV-O210 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 live job never says "Run carlos move offline <verb>": those lines are for a hand move. With the job `opened` it says today's lines unchanged (finish is a hand step). |
| - [ ] **Step 1: Write the failing tests** (`move_test.go`, with `fakeOfflineConsole` frames; `offline_move_e2e_test.go` for the real door): |
| @@ -491,22 +594,24 @@ Brief Astra on this commit with the decision table as the claim to check: no pat |
| // "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. |
| +// -> landing(flip) -> landed(check) -> open(job opened): exit 0; the output has |
| +// MV-O200 once, a started line for each of the six steps in order, a finished line |
| +// with seconds for each, the existing served line and MV-O205; the fake saw exactly |
| +// one POST, to /run (no /finish, no 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. |
| +// "The console stopped the move at step flip: x." and "Nothing was lost."; no POST |
| +// but /run. |
| +// TestMoveOfflineRunAbortOverdue: a frame reverting with job returning and overdue: |
| +// exit 4, MV-O210, no POST but /run. |
| // 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. |
| +// TestMoveOfflineRunReattaches: the first frame is already sealing with a job: the |
| +// output starts at step seal and ends as TestMoveOfflineRun does. |
| // 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". |
| @@ -519,109 +624,137 @@ Brief Astra on this commit with the decision table as the claim to check: no pat |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=/tmp/g go test . -run 'TestParseMoveArgsOfflineRun|TestMoveOfflineRun|TestMoveOfflineStatusNamesTheStep|TestMoveOfflineStatusAfterAConsoleAbort' -count=1` |
| +Run: `TMPDIR=$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 3: Add the verb, the flags, `runRun`, `sayJob` and the status lines.** Every sentence goes through `moveSay` with the approved text of Appendix A, exactly. Its row goes into the copy record with the status Task 0 gave it and its id into `movesCopyIDs` (MV-O181's row becomes `withdrawn`, replaced by MV-O199, the way MV-O56 was). The five console sentences of Tasks 3 and 4 get their rows here too. |
| - [ ] **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: `TMPDIR=$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 new console file: add `internal/console/offlinejob.go` to `movesScanFiles` and run it once with a row removed to see it bite. |
| -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** |
| +- [ ] **Step 5: 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 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 |
| git commit -m "carlos move offline run: one command, and status names the step" |
| ``` |
| --- |
| -### Task 6: Copy pass, docs, and the two-box witness |
| +### Task 6: 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` |
| +- Modify: `docs/site/cli.md:3371-3381`, `docs/superpowers/plans/2026-10-21-offline-move-runbook.md` (short version and §5), `internal/host/movesoffline_e2e_test.go` |
| **Interfaces:** |
| -- Consumes: `(*console.Server).RunOfflineMoveJobs`, `e2eWorld` (`tickAll`, `do`, `status`, `until`, `requireClosedWriteSet`). |
| +- Consumes: `(*console.Server).RunOfflineMoveJobs`, `e2eWorld` (`do`, `status`, `loops()` and `e2eLoops.round`, `requireClosedWriteSet`, `w.sw.fake`), the archive tamper of `offlineMoveRollback` (`movesoffline_e2e_test.go:1452-1460`). |
| - 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. |
| +- [ ] **Step 1: Docs.** In `cli.md`, put `carlos move offline run --host <host> --to <region>` first in the command list and add the approved paragraph D1 before the per-verb text; line 3371's "never acts on its own" (row MV-O32) becomes the approved D2. In the runbook, add to the short version and §5 that `run` replaces `move.sh`'s doors and gate up to open, and that sections 2, 3 (the target check above all, until #339 lands), 6, 7 (then `finish`, §8), 9 and 10 are still the operator's. |
| -Run: `TMPDIR=/tmp/g go test . -run 'TestMoveDocs|TestMovesCopy|TestMovesApprovedCopyIsApplied|TestMovesStringsAreRecorded' -count=1` |
| +Run: `TMPDIR=$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`): |
| +- [ ] **Step 2: Write the failing witness** (`internal/host/movesoffline_e2e_test.go`; keep the `*console.Server` on `e2eWorld`). Production wiring as `TestOfflineMoveE2E`: a real `console.Server`, two real box workers, the S3 fake. **The boxes are driven only by `e2eLoops`** (`l := w.loops()`, then `l.round()`): a box runs its pass when the serial moved, or on its 15 s re-assert tick, and never because the test told it to. `tickAll` is not called. So a transition the job wrote and did not announce stalls the test. |
| ```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. |
| +// TestOfflineJobE2E |
| +// forward: POST .../move/offline/run {"region":"uk"}; loop { l.round(); |
| +// srv.RunOfflineMoveJobs(ctx) } until the status view's job.state is "opened" |
| +// (bounded: fail after 200 rounds, naming the state it stuck in). The test posts |
| +// to no other door. Assert what TestOfflineMoveE2E asserts after its open (record |
| +// region uk, state offline-open, the row ready on the target, the source |
| +// tombstoned) and job.steps holds the six steps. Then the hand finish, as |
| +// TestOfflineMoveE2E does it, and its end-state assertions (last outcome done, |
| +// the closed write set, the tombstone lifted). |
| +// lost reply: the same, with the recording store made to return an error for the |
| +// committed Put of the start transition and of the flip. The move still reaches |
| +// opened, with no extra record Put for either. |
| +// abort: run until the record is offline-sealed (before the job's flip tick), then |
| +// tamper with the sealed archive exactly as offlineMoveRollback does (flip one |
| +// byte of moves.OfflineArchivePrefix(offHost, id)+offlineArchiveSealed in the uk |
| +// bucket). Loop until status state "none": last outcome aborted, job.state |
| +// aborted, job.reason not empty, and offlineMoveRollback's own assertions that the |
| +// source serves again with every row and holds its lease. 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. |
| +To stop exactly at sealed, the abort case calls `RunOfflineMoveJobs` only while the record is before `offline-sealed`, tampers, then resumes the loop. Real time is fine: no case waits on a deadline, and none is shorter than 3 minutes. |
| -- [ ] **Step 4: Run** |
| +- [ ] **Step 3: Run** |
| -Run: `TMPDIR=/tmp/g go test ./internal/host -run 'TestOfflineJobE2E|TestOfflineMoveE2E' -count=1` (sandbox off) |
| +Run: `TMPDIR=$G go test ./internal/host -run 'TestOfflineJobE2E|TestOfflineMoveE2E' -count=1` (sandbox off) |
| Expected: PASS. |
| -- [ ] **Step 5: Commit** |
| +- [ ] **Step 4: 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" |
| +git add docs internal/host/movesoffline_e2e_test.go |
| +git commit -m "offline move job: docs and the two-box witness" |
| ``` |
| --- |
| -### Task 7: Whole-branch review and merge |
| +### Task 7: Census, 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 2: Census, on the final source.** `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. Commit the overlay and the card (`internal/provision/testdata/plan14-root-reads-self-serve-moves-s1-one-command.tsv`, `docs/superpowers/notes/census-proposal-self-serve-moves-s1-one-command.md`). **If any file in census scope changes after this step** (a review fix to `move.go` above all), rerun `make census-propose` with the same NAME and commit again before asking for the verdict; the verdict names the tip it read. |
| + |
| +- [ ] **Step 3: 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: One whole-branch Astra review** (`-m gpt-6-astra`, effort high), brief from the template, carrying the round history (plan round 1 and the Task 3 and Task 4 rounds), the Review Focus list, invariants I1 to I5 and the census card. It gives the census verdict for every unit, recorded on #280 with the tip. It stops at the first round with no P1; P2 fixes are applied without a new round (then Step 2's rerun rule); 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. |
| +- [ ] **Step 5: 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 |
| +### Task 8: Paul sees a dev move reach open 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. |
| +Every step here changes dev and needs Paul's go at that step; 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`. |
| +- [ ] **Paul's go:** `carlos move offline run --host <dev host> --to uk --console https://platform.dev.carlosframework.com`. Pass: exit 0, six step lines, the served 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. |
| +- [ ] Runbook §7 on the target, then `carlos move offline finish --host <dev host>`: "Moved." |
| +- [ ] **Paul's go, at this step** (controller's call until Paul rules: only with his go here): a second move, with the dev console's unit restarted once between `seal` and `open` (about 11 s of console downtime). Pass: `status` afterwards names the same step or the next one, and the move still reaches open. |
| +- [ ] One abort: a third run, with `carlos move offline abort` by hand during `seal`, or a stale `/opt/carlos/live/<host>` link on the target if one can be arranged with Paul's approval. 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) |
| +## Appendix A. Copy deck (draft until Task 0; Paul's review makes a row approved) |
| -Next free ids after MV-O193; check `movesCopyIDs` before using them. `<step>` is one of: stage, start, seal, flip, check, open, finish. |
| +Next free ids after MV-O193; check `movesCopyIDs` before using them. `<step>` is one of: stage, start, seal, flip, check, open. |
| + |
| +**Mock** (Task 0 starts from this): |
| + |
| +``` |
| +$ carlos move offline run --host shop.example.com --to uk |
| +The console is moving shop.example.com from ie to uk. It runs every step itself. Stopping this command does not stop the move. |
| +Step stage started. |
| +Staged 305 of 305 objects (1580.0 MB). |
| +Step stage finished in 94 seconds. |
| +Step start started. |
| +Step start finished in 23 seconds. |
| +Step seal started. |
| +… |
| +Step open finished in 7 seconds. |
| +shop.example.com is served from uk. Run carlos move offline finish --host shop.example.com once ie has cleaned up. |
| +Check shop.example.com in uk before you run finish. |
| + |
| +$ carlos move offline status --host shop.example.com |
| +Moving shop.example.com from ie to uk. |
| +The console is running this move. It is on step seal, started 42 seconds ago. |
| +Step stage finished in 94 seconds. |
| +Step start finished in 23 seconds. |
| +``` |
| | Id | Where | Text | |
| |---|---|---| |
| @@ -636,26 +769,49 @@ Next free ids after MV-O193; check `movesCopyIDs` before using them. `<step>` is |
| | 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-O205 | CLI, after the served line | `Check <host> in <to> before you run finish.` | |
| | 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. | |
| +| MV-O210 | CLI, abort overdue | `The console is moving <host> back to <from>, and it has taken more than <n> minutes. Nothing is lost. The console keeps trying.` | |
| +| D1 | `docs/site/cli.md` | `carlos move offline run` runs the move for you up to the point where the instance is open in the new region. The console stages the copy, takes the instance offline, copies what changed, starts it in the new region, checks it and opens it. If anything fails before then, the console moves the instance back and nothing is lost. `carlos move offline status` shows which step it is on. You can close the terminal: the console carries on. When it is open, check the instance and run `carlos move offline finish`. | |
| | 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. |
| +- **`finish` by the job.** Controller's call until Paul rules: the operator's checks (runbook §7, the row fingerprint) come between open and finish, so finish stays a hand step. If Paul later wants it automatic, it is one more intent (`finishing`, `finish`) in the same table. |
| +- **Paging.** Controller's call until Paul rules: none in slice 1. 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. |
| +- **A pause.** Before open, `abort` is the operator's stop. No "stop driving, keep the move" control until someone needs one. |
| - **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 |
| +## Self-review (rev 2) |
| + |
| +- **Spec coverage.** W3 slice 1: one command (Tasks 3, 5); the console drives stage, start, seal, flip and open through the doors' logic (Tasks 1, 4), and finish stays the operator's by the controller's call (a stated difference from W3's wording, for Paul); 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 (§5, §11); the MV-O178 retry (any non-final refusal waits to the deadline); log each step before it runs (§1: intent before effect). |
| +- **Round 1.** Every finding has a line below and a test or step in the task that owns it. |
| +- **Types.** `OfflineMoveJob` (with `Intent`, `StageAsked`), `OfflineJobStep`, `offlineJobView`, `offlineJobInput`, `offlineJobDecision`, `offlineJobBound`, `offlineJobSettled`, `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`. Job states are the same six everywhere: running, returning, opened, done, aborted, stopped (`done` only when a person finished a move whose job was still live). |
| +- **Proportion.** No function bodies; the tick's order and the two tables are spelled out because the signatures and tests alone do not determine them. |
| + |
| +## Round 1 dispositions |
| + |
| +Astra, round 1 of 3, on f6287be0: NOT READY, 5 P1, 4 P2. Findings 1 to 3 are one fault family (*recovery must tell an intended transition from a completed and announced one, for the job's own move only*) and get one mechanism: the durable intent bound to the move id, settled before anything is decided (Task 4's tick order, invariants I1 to I4). |
| + |
| +1. **P1, the job is not bound to its move id.** Accepted. Tick phase 1 (I1, `offlineJobBound`): a record without `Move.ID == Job.ID` is never read further or written; the row closes. Every transition is built with `Job.ID`. Test: `TestOfflineJobLeavesAnotherMoveAlone`. |
| +2. **P1, a pending abort is lost across a failed write; rounds counted from attempts.** Accepted. Abort is a durable intent with state `returning`, retried until the record is reverting or a person has opened the move (I3); phase 5 never runs while it stands. Stage rounds are counted from the record's `staged_at` (`StageAsked`), not from attempts. Tests: `TestOfflineJobKeepsAPendingAbort`, `TestOfflineJobReturningNeverAdvances`, `TestOfflineJobCountsRoundsFromTheRecord`. |
| +3. **P1, a lost reply or a crash loses the serial bump.** Accepted. An intent clears only after the record shows its effect and `release.BumpSerial` then succeeded (I2), so the announcement is retried until it lands; a lost finish also releases the lock. Tests: `TestOfflineJobSettlesALostReply`; the witness drives boxes by `e2eLoops` only and has a lost-reply case. |
| +4. **P1, re-attach is unreachable after flip.** Accepted. The door recognises the job (move id and destination) right after the gate and the region's shape, before any new-move check. Test: `TestOfflineRunDoorReattachesInEveryState`, every state and the other-region refusal. |
| +5. **P1, five tests contradicted the interfaces.** Accepted, each: |
| + - the lock refusal is `offlineBeginMove`'s, not a helper's: Task 1's helper test covers the pre-lock rows and asserts the lock row separately; |
| + - no token is the route's 401, a member or service token the gate's 404: `TestOfflineRunDoorIsOperatorOnly` compares with `/stage` byte for byte; |
| + - deadlines are tested by ticking through the time (`advance`), downtime by one jump; `TickAt` is set at admission; |
| + - no `MoveSeq` assertions: committed record `Put`s and serial bumps are counted on the store; |
| + - `landedForJob` sets `Held`, `RowPresent` and the test clock's time; one clock for server and fixtures. |
| +6. **P2, `landOpts` has no fault field.** Accepted. The abort witness tampers with the sealed archive between seal and flip, as `offlineMoveRollback` does, and keeps its source-data and lease assertions. |
| +7. **P2, copy approved by the wrong reviewer, after the build.** Accepted. Task 0: UX pass, a Luna draft pass that approves nothing, then Paul's review with the copy-review skill, all before any sentence enters a product file. This differs from the original brief ("a delegated Luna pass"); if Paul prefers that for a deck this small, Task 0's step 3 is the only thing that changes. |
| +8. **P2, the census proposal preceded later edits.** Accepted. The proposal moved to Task 7, after the last source edit, with a rerun rule for any later in-scope fix and a verdict that names the tip. |
| +9. **P2, shared `/tmp/g`.** Accepted. A per-session `mktemp -d` directory under `$TMPDIR`, removed by exact path; a `/tmp` fallback of the same kind only if a unix socket path is too long. |
| + |
| +Declined: none. Astra's closing notes need no change: the role and linked-policy rows match the other doors; `OfflineAbort` refusing open and finishing is what I3's "or a person has opened it" relies on; the one-console assumption is stated in Global Constraints. |
| -- **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. |
| +Controller's calls recorded in this rev, each until Paul rules: `run` stops at open and `finish` stays the existing door (no `run --finish` built); no paging; the dev console restart only with Paul's go at that step; build on today's main. |