plan: slice 1 rev 3 (Paul's cut: one writer per move)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/superpowers/plans/2026-11-13-self-serve-moves-slice-1-one-command.md+344 −235
Intent
<cross-session-message from="uds:/run/user/1001/cc-socks/914213.sock" from-name="platform-e2" from-mode="bypass"> platform-a9 (#511): I am not changing dorothy-sailing or rolling Tito staging. Tito's own session (paseo 09cca118, carlos-infrastructure-e7) runs the staging rolls, so check with it first: today it rolled the staging boxes to v0.35.2 and may still roll the staging console to v0.35.2. Two facts about dorothy-sailing for your rehearsal. (1) It is the hub. Its carlos-edge now has a hub-only drop-in setting CARLOS_REPLICA_CONSOLE_ADDR=127.0.0.1:8090 (new in v0.35.2), so keep that drop-in through the layout migrate and the revert. (2) tito-id on the classic fleet had a 16-min staging outage at 05:37-05:53Z (#1008). It is serving again on box-1, and Tito is holding its stateless trial, so nothing of mine is in flight there. </cross-session-message>
[Cross-session delivery notice] Your message to another session was not approved before expiry (recipient: uds:/run/user/1001/cc-socks/3221035.sock; msg_id: 4ad96e89-0abe-43fc-8fed-2b42fb5453b8). Not delivered to that session's Claude, and nothing is waiting there. Do not wait for a reply, and do not resend unprompted: while the two sessions' permission modes differ a resend is only held again. Tell your user what was not delivered and why; send it again, edited if that helps, when they ask.
<task-notification> <task-id>a98af11bd05f28f48</task-id> <tool-use-id>toolu_01GUSLrdzwTezpbX3nnCyGTG</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/96a09f74-e398-48ed-a97f-140bd1f7e255/tasks/a98af11bd05f28f48.output</output-file> <status>completed</status> <summary>Agent "Fable runs W1a staging rehearsal" 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>W1a stopped at step 1: three stop conditions hit, so nothing was changed on staging. No exit-list item was run, no SSM command was sent, and the plan file is unedited. **Why I stopped** (all read at 06:06–06:08Z, console `https://console.staging.platform.tito.io`): 1. **A roll inside the last hour.** `carlos system status` shows canary promoted to v0.35.2 at 05:33:13Z and stable at 05:36:01Z, about 31 minutes before I looked. All four boxes report v0.35.2 `current`. 2. **A console roll looks pending.** The console answers `x-carlos-version: 7d168df`, which is v0.35.1; v0.35.2 is `5eb7889`. Tito's session (09cca118) will presumably roll the console next. I could not read console promotions: `carlos channels --app console --account ops` answers "not found". 3. **dorothy-sailing is already nested.** `carlos status --layout` shows all eight titogo rows `nested` (acme-1 to acme-3, acme-bill, bristol-beer-company, pentest, pentest-isolation-20261102, simple-conf). `carlos system layout status` holds no intent for dorothy-sailing, only "flat for box grace-sailing (2026-11-02, force)", so the box is nested by default. The plan's flat baseline and first migrate don't exist as written. **Other facts read** - acme-1 is Running and answers `/api/version` 200; the other seven are Asleep. - titogo build is `aede64e`. I did not check whether it holds 952fb18d. - tito-id on box-1 answers 302. - `system status` warns that `bootstrap/carlos` is not stable's build. **Coordinator's hub facts** Not acted on, since I stopped first. The carlos-edge drop-in is not recorded yet, and I have not checked whether `layout migrate` or `revert` restarts carlos-edge. Both need doing before any layout command on the hub. **Final state** dorothy-sailing is nested, exactly as I found it. **What changes W1b** - Nothing is proven yet. - W1b must run on the release proven on staging (v0.35.2 or later), so production (v0.33.5) needs rolling forward first. - If W1a resumes, it has to start with `revert --force` to get a flat baseline. That makes the first measured event a forced stop of awake acme-1 on the hub, not the 1-hour grace stop the plan describes. **Left for Paul or the coordinator** 1. Confirm with Tito's session that the console roll is done, or that it won't overlap, and say when to resume. 2. Find out who nested dorothy-sailing and when; if it was deliberate, the exit list may already be partly exercised. 3. Approve the reordered rehearsal: record the edge drop-in, run the exit list nested as found, revert with `--force` (timed), run the flat exit list, migrate, then run the nested exit list again. The grace-stop webhook check would then need acme-1 awake through a non-forced migrate. 4. The controld account, the alias and a private Gotenberg are still absent on staging, as far as I read. The log is kept for the restart at `/home/paulca/.cache/tmp/claude-1001/w1a-log.md`; it is the only scratch file, and should be deleted when W1a ends.</result> <usage><subagent_tokens>66075</subagent_tokens><tool_uses>9</tool_uses><duration_ms>87970</duration_ms></usage> </task-notification>
<task-notification> <task-id>a4a1b0aa020a2a126</task-id> <tool-use-id>toolu_0183zV2Q9MPbm7LXDFGkrqFY</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 3 is written to the plan file, uncommitted, with a "Round 2 dispositions" section at the end. All seven round 2 findings are answered; none declined. **Paul's rulings applied** - **One writer.** While a job is live, `stage`, `start`, `seal`, `flip`, `open`, `abort` and `finish` by hand refuse with one sentence naming `run --abort` and `run --release`. The job row is written before the move exists. - **P1-1 and P1-2 are removed, not fixed.** The hand-door reconciliation rule is deleted, and so is the flip-time comparison in the pre-open gate. - **The escape, stated once.** `run --release` marks the row released first, under the same mutex the tick holds, so the job never writes again. - **Copy** is a Luna gate again, with the UX pass first. - **`run` stops at open; cutover stays off.** **Other fixes** - **P1-3:** the two-box driver sets the box clock, re-asserts, and drains before asserting. A one-off step proves the witness fails without the recovery bump. - **P2-4:** start requires a staging round settled within 2 minutes; the stage budget excludes downtime. - **P2-5:** the `done` job state is gone; the watcher's outcome table has a catch-all. - **P2-6:** scratch is under `$TMPDIR` only. - **P2-7:** the plan's review budget is stated as spent. **Beyond the brief** - `run` no longer adopts a hand-staged move; it refuses. This removes the adoption race in P1-1. - I added a small seeded simulation test over the six invariants.</result> <usage><subagent_tokens>362880</subagent_tokens><tool_uses>6</tool_uses><duration_ms>403967</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 226073673..1e60a30a1 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,11 +2,11 @@ |
| > **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. |
| -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. |
| +Rev 3, 2026-11-14. Round history, which every later brief carries: rev 1 (f6287be0), Astra round 1, NOT READY, 5 P1 and 4 P2 (`docs/superpowers/reviews/CODEX-FINDINGS-SELF-SERVE-SLICE-1-R1.md`); rev 2 (5a8163fe), Astra round 2, NOT READY, 3 P1 and 4 P2, with stopping rule 2 triggered on the recovery family (`…-R2.md`). Paul ruled on discussion #1005 ("yes to all"), and rev 3 takes his cut rather than a third fix: **while a job owns a move, every hand-run offline door for that host refuses**, so the job is the only writer of the move and nothing a person did by hand has to be reconciled. The dispositions of both rounds are at the end. **The plan's review budget is spent** with the round that reads this rev (round 3 of 3); see "Review budget" below. |
| **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`. |
| -**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. |
| +**Architecture:** The job is a row in the console's SQLite store plus the instance record, which stays the only truth about the move. The row exists before the move does, and while it is live the hand doors for that host refuse, so the job is the move's only writer. 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. |
| **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`). |
| @@ -15,38 +15,40 @@ Rev 2, 2026-11-13. Rev 1 (f6287be0) was reviewed by Astra, round 1 of 3: NOT REA |
| ## 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 doors keep their bytes, with one new refusal.** After Task 1 every existing door answers the same status and sentence for the same input, and `TestOffline*` in `internal/console` passes unchanged. Task 3 adds the one difference: a mutating door for a host whose job is live refuses (I0). |
| - **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): |
| +- **The job's invariants** (each is enforced in one place, named in a comment there, and has a test): |
| + - **I0, one writer** (Paul's ruling, #1005). While a job is live (`running` or `returning`) it is the only writer of its host's move. The row is written before the move exists. `stage`, `start`, `seal`, `flip`, `open`, `abort` and `finish` by hand answer one refusal (MV-O211) that names the two ways on: `run --abort` and `run --release`. Ownership ends durably, in the row, before anyone else may write: when the job closes, or when an operator releases it. |
| - **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. |
| + - **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. |
| + - **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`, which only the job moves (I0). |
| - **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. |
| +- **The escape, stated once.** `carlos move offline run --host <h> --release` ends the job's ownership: the row becomes `released` first, durably, and the job never writes again. The move stays exactly where it is, and from then on it is an ordinary hand move: `status`, then the existing verbs. It is for a move the job cannot get further with. It does not abort anything. |
| +- **`run` stops at open** (Paul, #1005). 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. |
| - **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. |
| +- **No paging in slice 1** (Paul, #1005). An abort that cannot finish shows as overdue in `status` and exit 4. |
| +- **Build on today's main** (Paul, #1005; stopping rule 4). #339's stage and start refusals are on main (94a6471) and travel through Task 1's extraction as they are. #413 is not on main and nothing here depends on it. Because the job calls the doors' own check functions, it picks up later refusals with no change here. |
| +- **D4** (Paul, #1005): the lifetimes cutover stays off, and slice 1 does not need it. The cutover's admission gate is on main, so the pass runs each tick as a `lifetimesIteration` unit (mutating); it works with the cutover off, which is the only mode this slice is witnessed in. |
| +- **One console per deployment.** As every other console pass assumes (spec §7). I0's exclusion between the pass, the `run` door and a release is one in-process mutex; 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 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. |
| +- **UX pass, then copy, then code** (AGENTS.md "Every UI change gets a UX pass"). Task 0 does the UX pass on the CLI output first, then Luna reviews the deck in Appendix A. **Luna's verdict is the approval**, under Paul's delegation of 2026-10-25, confirmed for this plan on #1005. 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):** 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`. |
| +- **Review budget (stopping rules 1 to 3).** The *plan* has had its three rounds once rev 3 is read; there is no fourth plan round, and no further plan revision is reviewed, without Paul's go. What remains are reviews of *code*, which Paul's ruling leaves in place: a per-task Astra review for Task 3 (a new route behind the operator gate, and a new refusal on seven doors) and Task 4 (the console takes a production instance offline and opens it with nobody watching), and one whole-branch review (Task 7). Each of those stops at its first round with no P1, and each brief carries the round history above and follows `docs/superpowers/reviews/REVIEW-BRIEF-TEMPLATE.md`. A code finding in the family rule 2 already fired on (*recovery must tell an intended transition from a completed and announced one*) is not fixed a third time: stop and take it to Paul with the cut (drop automatic recovery for that case: the job stops and says so). |
| - **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. |
| +- **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, under `$TMPDIR` only: `export G=$(mktemp -d "$TMPDIR/g.XXXXXX")`, then `TMPDIR=$G go test …`, then `rm -r "$G"` when the task ends. Nothing goes under `/tmp`. If a test cannot bind a unix socket because that path is too long, stop and report it; do not move the scratch. 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. 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`. |
| +2. **An operator reaches for a hand door while the job runs.** Every mutating door refuses with the one sentence and writes nothing; `status` still answers. `run --abort` stops the move through the job; `run --release` hands it over, after which the doors work and the job never writes again. Task 3, `TestOfflineHandDoorsRefuseWhileAJobOwns`, `TestOfflineRunAbortAndRelease`. |
| 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. |
| +4. **The console is down for most of an hour while a move is staging.** On return the job does not start from the old round: it asks for a fresh one first, and the stage budget does not count the downtime. Task 4, `TestOfflineJobRestagesAfterDowntime`. |
| +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`, `TestOfflineJobKeepsAPendingAbort` and the seeded `TestOfflineJobSimulation`; Task 6's witness runs the boxes by serial only, so a missing bump stalls it. |
| --- |
| @@ -54,11 +56,11 @@ Rev 2, 2026-11-13. Rev 1 (f6287be0) was reviewed by Astra, round 1 of 3: NOT REA |
| | File | Responsibility | |
| |---|---| |
| -| `internal/console/apiinstancemove_offline.go` (modify) | Task 1: door bodies as functions. Task 3: `Job` on `offlineView`. | |
| +| `internal/console/apiinstancemove_offline.go` (modify) | Task 1: door bodies as functions. Task 3: `Job` on `offlineView`, and the owned refusal in the four mutating handlers. | |
| | `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 (bind, settle, decide), the pure decision, the pre-open gate. | |
| +| `internal/console/offlinejob.go` (create) | The `run` door (start, abort, release), the owned check, 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/store.go`, `store_gate.go`, `routedecls.go`, `linkedpolicy.go`, `claim_workers.go`, `server.go`, `cmd/console/main.go` (modify) | Wiring: migration, table class, route, linked policy, worker registration and start, the mutex field. | |
| | `internal/console/testdata/claim-routes.txt`, `claim_invariant_fixtures_test.go`, `svcroutes_test.go`, `jobs_test.go` (modify) | The inventories a new route and worker must appear in. | |
| | `move.go`, `move_test.go`, `offline_move_e2e_test.go` (modify) | The `run` verb, the status lines, their tests. | |
| | `internal/host/movesoffline_e2e_test.go` (modify, test only) | The two-box witness driven by the job. | |
| @@ -66,18 +68,17 @@ Rev 2, 2026-11-13. Rev 1 (f6287be0) was reviewed by Astra, round 1 of 3: NOT REA |
| --- |
| -### Task 0: UX pass on the CLI output, then Paul's copy review |
| +### Task 0: UX pass on the CLI output, then Luna'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. |
| +**Files:** none in the product. The mock and the deck live in this plan (Appendix A). |
| -- [ ] **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`). |
| +- [ ] **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`; `run --abort`; `run --release`; a hand door refused; `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 to review. |
| +- [ ] **Step 2: Luna's review, which is the gate** (Paul's delegation of 2026-10-25). Brief her as the copy-review gate itself for this set, human text only (the deck's rows and the `cli.md` paragraphs, shown in the mock's layout), with her verdicts written to a scratch file under `$G`; she does not start a copy-review server. Apply her table verbatim to Appendix A. From here the rows are `approved` and later tasks copy them exactly. |
| +- [ ] **Step 3: 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. |
| +If the review is not back, Tasks 1 to 4 may be built up to but not including the lines that speak the new console sentences (MV-O194 to MV-O198, MV-O211 to MV-O214); Task 5 waits. |
| --- |
| @@ -85,10 +86,10 @@ If Paul's review is not back, Tasks 1 to 4 (which add five console sentences, MV |
| 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 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).* |
| +*W4 note: #339's refusals (the target's stale live link, extra app directories) are on main inside these functions; move them with the bodies, unchanged, and keep their e2e case (`offlineRefusesAStaleLiveLink`) green. #413 would change `offlineSelect`; if it 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` |
| +- Modify: `internal/console/apiinstancemove_offline.go` (`offlineBeginChecks`, `offlineBegin`, `offlineWrite`, `offlineRefusal`, `offlineSealCheck`; find each by name, the line numbers moved with #339), `internal/console/seedmove.go` (`refuseSeedMove`, `refuseRootfsMove`) |
| - Test: `internal/console/apiinstancemove_offline_test.go` |
| **Interfaces:** |
| @@ -97,9 +98,9 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| - `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) 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) offlineRegionRefusal(ctx context.Context, d offlineDoor, region string) (to string, fleet offlineFleet, ref *offlineRefusal)`: `offlineRegionCode`, then every check `offlineBeginChecks` makes after `readJSON` as main has them (the HA rule, already there, manifest regions, the fleet read, the `CARLOS_REGION` home rule, `offlineSelect`, #339's). 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) offlineBeginMove(ctx context.Context, d offlineDoor, id string, begin func(id string) func(*provision.Record) error) (rec *provision.Record, ref *offlineRefusal, uncertain bool)`: `offlineBegin` minus the response (probe, lock, bounded write, reread on a lost reply, serial bump). `id == ""` mints one, as today; the `run` door passes the id its row already holds. `uncertain` is true only when the write failed and the reread could not show whether it landed (today's 502 "could not write the move. try again"); every other refusal is definite, and nothing was written. |
| - `func (s *Server) offlineApplyStep(ctx context.Context, d offlineDoor, mut func(*provision.Record) error) (*provision.Record, error)`: apply, bump the serial, release the lock when the move cleared. `offlineWrite` becomes this plus `offlineWriteFailed`. |
| - `offlineDoor` is unchanged. Its users read only `acct.Sqid` of the account (`offlineApply`, `offlineClaimEvidence`, `offlineTakeLock`, `offlineWriteFailed`), which is what lets Task 4 build one from a job row. |
| @@ -111,7 +112,9 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| // 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. |
| +// offlineBeginMove returns it with uncertain == false. |
| +// TestOfflineBeginMoveTakesAnID: offlineBeginMove with id "mv_test" leaves |
| +// record().Move.ID == "mv_test" and the lock naming it; with "" it mints one. |
| // TestOfflineSealCheckMarksFinalRefusals: the sidecar and two-data-box refusals carry |
| // final == true; offlineWaitRefusal, offlineStaleRefusal and offlineStateRefusal do not. |
| // TestOfflineApplyStepReleasesTheLock: an OfflineFinish applied through |
| @@ -121,14 +124,14 @@ No behaviour change. The doors' checks are already half split (`offlineStepFor` |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=$G go test ./internal/console -run 'TestOfflineBeginRefusalsMatchTheDoor|TestOfflineSealCheckMarksFinalRefusals|TestOfflineApplyStepReleasesTheLock' -count=1` |
| +Run: `TMPDIR=$G go test ./internal/console -run 'TestOfflineBeginRefusalsMatchTheDoor|TestOfflineBeginMoveTakesAnID|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=$G go test ./internal/console -run 'TestOffline' -count=1` then `TMPDIR=$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`, then `TMPDIR=$G go test ./internal/host -run 'TestOfflineMoveE2E' -count=1` |
| Expected: PASS, with no existing test edited. |
| - [ ] **Step 5: Commit** |
| @@ -144,17 +147,18 @@ git commit -m "offline move: door bodies as functions, no behaviour change" |
| **Files:** |
| - Create: `internal/console/offlinejob_store.go`, `internal/console/offlinejob_store_test.go` |
| -- Modify: `internal/console/store.go:752` (call `migrateOfflineJobs` beside `migrateDomains`), `internal/console/store_gate.go:210` (`claimSQLTables`) |
| +- Modify: `internal/console/store.go` (call `migrateOfflineJobs` beside `migrateDomains`), `internal/console/store_gate.go` (`claimSQLTables`) |
| **Interfaces:** |
| - Produces: |
| ```go |
| // 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). |
| +// and the only move this job may ever act on (I1). While State is running or |
| +// returning the job owns the host's move (I0). |
| type OfflineMoveJob struct { |
| ID, Host, Account, App, To, RequestedBy string // Account is the sqid |
| - State string // running | returning | opened | done | aborted | stopped |
| + State string // running | returning | opened | aborted | stopped | released |
| Step string // stage | start | seal | flip | check | open | abort |
| StepAt time.Time // when Step began |
| DeadlineAt time.Time // zero: no deadline |
| @@ -163,14 +167,14 @@ type OfflineMoveJob struct { |
| // (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 |
| + // StageAsked is the record's staged_at as of the last settled stage request, and |
| + // StageAskedAt when the job settled it. Rounds counts settled requests. A stager |
| + // report is a finished round only when it answers StageAsked. |
| + StageAsked time.Time |
| + StageAskedAt time.Time |
| + Rounds int |
| Waiting string // the sentence the step last waited on |
| - Reason string // why the console aborted or stopped; "" otherwise |
| + Reason string // why the job aborted, stopped or was released; "" otherwise |
| Steps []OfflineJobStep // history, oldest first |
| CreatedAt, UpdatedAt time.Time |
| } |
| @@ -181,9 +185,10 @@ type OfflineJobStep struct { |
| } |
| var ErrOfflineJobLive = errors.New("console: this host already has a live offline move job") |
| +func (j OfflineMoveJob) Live() bool // State is running or returning |
| func (s *Store) InsertOfflineJob(j OfflineMoveJob) error // ErrOfflineJobLive on the unique index |
| func (s *Store) SaveOfflineJob(j OfflineMoveJob) error // update by ID; sets UpdatedAt |
| -func (s *Store) LiveOfflineJobs() ([]OfflineMoveJob, error) // state running or returning, oldest first |
| +func (s *Store) LiveOfflineJobs() ([]OfflineMoveJob, error) // live rows, oldest first |
| func (s *Store) OfflineJobFor(host string) (*OfflineMoveJob, error) // newest by created_at; nil, nil when none |
| ``` |
| @@ -194,13 +199,14 @@ func (s *Store) OfflineJobFor(host string) (*OfflineMoveJob, error) // newest by |
| ```go |
| // TestOfflineJobRoundTrip: Insert then OfflineJobFor(host) returns every field equal, |
| -// Intent, IntentAt, StageAsked and Steps included; SaveOfflineJob changes Step, |
| -// Intent, Reason and a third Steps entry and the next read has them. |
| +// Intent, IntentAt, StageAsked, StageAskedAt 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 |
| -// 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. |
| +// opened (or aborted, stopped, released), the second Insert succeeds and |
| +// OfflineJobFor returns the second. |
| +// TestLiveOfflineJobs: of rows in running, returning, opened, aborted, stopped and |
| +// released, only the first two come back, oldest first, and Live() agrees. |
| // TestOfflineJobTableSurvivesReopen: Open the same file again; the row is there. |
| ``` |
| @@ -209,7 +215,7 @@ func (s *Store) OfflineJobFor(host string) (*OfflineMoveJob, error) // newest by |
| Run: `go test ./internal/console -run 'TestOfflineJob|TestLiveOfflineJobs' -count=1` |
| Expected: build failure, `OfflineMoveJob undefined`. |
| -- [ ] **Step 3: Write the table, the migration call and the four methods.** |
| +- [ ] **Step 3: Write the table, the migration call and the methods.** |
| - [ ] **Step 4: Run** |
| @@ -225,18 +231,20 @@ git commit -m "offline move job: the console's job table" |
| --- |
| -### Task 3: The `run` door, and the job in the status view |
| +### Task 3: The `run` door, the owned refusal, and the job in the status view |
| -**Per-task Astra review** (a new route behind the operator gate). |
| +**Per-task Astra review** (a new route behind the operator gate, and a new refusal on seven doors). |
| **Files:** |
| - Create: `internal/console/offlinejob.go`, `internal/console/offlinejob_test.go` |
| -- Modify: `internal/console/apiinstancemove_offline.go` (`offlineView` near :1290, `offlineViewOf`, the file comment's door list), `internal/console/routedecls.go:715`, `internal/console/linkedpolicy.go:199`, `internal/console/testdata/claim-routes.txt:305`, `internal/console/claim_invariant_fixtures_test.go:1960`, `internal/console/svcroutes_test.go:764` |
| +- Modify: `internal/console/apiinstancemove_offline.go` (`offlineView`, `offlineViewOf`, the four mutating handlers, the file comment's door list), `internal/console/server.go` (`offlineJobMu sync.Mutex`), `internal/console/routedecls.go` (beside the `/stage` row), `internal/console/linkedpolicy.go`, `internal/console/testdata/claim-routes.txt`, `internal/console/claim_invariant_fixtures_test.go`, `internal/console/svcroutes_test.go` |
| **Interfaces:** |
| -- Consumes: Task 1's `offlineClassRefusal`, `offlineRegionCode`, `offlineRegionRefusal`, `offlineStageMut`, `offlineBeginMove`, `offlineApplyStep`; Task 2's store methods. |
| +- Consumes: Task 1's `offlineClassRefusal`, `offlineRegionCode`, `offlineRegionRefusal`, `offlineStageMut`, `offlineBeginMove`; Task 2's store methods; `moves.NewMoveID`. |
| - 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. |
| + - Route `POST /api/cli/apps/{account}/{app}/instances/{host}/move/offline/run`, `Kind: kindCLI, Allow: svcrole.Allow(svcrole.Instance)`, `linkedRefuse`, handler `(*Server).handleAPIInstanceOfflineRun`. Body, exactly one of: `{"region":"uk"}` (start or re-attach), `{"abort":true}`, `{"release":true}`; anything else is 400 "invalid request" (unknown: the existing bad-body sentence: use what `readJSON` answers). Answers 202 with the status view. |
| + - `func (s *Server) offlineOwned(w http.ResponseWriter, d offlineDoor) bool`: answers 409 MV-O211 and returns true when `OfflineJobFor(d.host)` is `Live()`; a store error is 502 "could not read the instance" and true. Called right after `offlineGate` in `handleAPIInstanceOfflineStart`, `handleAPIInstanceOfflineStage`, `offlineVerbDoor` (seal, flip, open, finish) and `handleAPIInstanceOfflineAbort`. Not in the status GET. |
| + - `s.offlineJobMu`: held by the `run` door for its whole body and by the pass for each job's tick (Task 4). It is what makes "the row says who owns the move" true at the moment anyone writes. |
| - `offlineView.Job *offlineJobView` (`json:"job,omitempty"`): |
| ```go |
| @@ -255,20 +263,13 @@ func (s *Server) offlineJobViewFor(host string, mv *provision.MoveState, last *p |
| `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** (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): |
| +**What the door does**, under `s.offlineJobMu`, after `offlineGate` (authentication is the route's own, `cliGateRefused`: no token or a bad one is its 401 before this door runs) and `readJSON`: |
| -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. |
| +- **`{"release":true}`** (the escape). The host's newest job must be live, else 409 MV-O214. Save the row `released` with reason MV-O213 and no intent. Nothing is written to the record or the lock. 202. Because the pass takes the same mutex and reads its row again under it, no tick is mid-write when this returns and none writes afterwards. |
| +- **`{"abort":true}`**. The host's newest job must be live, else 409 MV-O214. Already `returning`: 202. Otherwise save the row `returning`, step `abort`, intent `abort`, reason MV-O212, deadline now + 10 min (exactly what the job saves when it decides an abort itself); the next tick writes it (Task 4, settle). 202. |
| +- **`{"region":…}`**. `offlineRegionCode`, then: |
| + 1. **The record carries an offline move.** A job with that move's id that is live or `opened`, and `to == mv.To`: write nothing, 202 (re-attach, in every state; 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). Such a job and another region: `offlineStagedFor` (MV-O179) while staging, else `offlineStateRefusal` (MV-O25). No such job, whatever the state: `offlineStateRefusal` (MV-O25). A move a person began by hand, staged ones included, is theirs; `run` does not adopt it (that removes the adoption race of round 2). |
| + 2. **The record carries no offline move.** `offlineClassRefusal`, `offlineRegionRefusal`, `offlineStageMut`. Then mint the id (`moves.NewMoveID`) and **insert the row first** (I0): `State: "running"`, `Step: "stage"`, `StepAt`, `TickAt`, `CreatedAt` and `StageAskedAt` now, `Rounds: 1`, `DeadlineAt` now + 30 min, `RequestedBy: d.addr`. `ErrOfflineJobLive` (a row from an admission still inside its grace) is 409 MV-O211. Then `offlineBeginMove` with that id. A definite refusal: save the row `stopped` with the refusal's sentence and answer the refusal (the row is never shown: no move carries its id). Uncertain: leave the row and answer the 502; the pass settles it (Task 4, bind). Success: set `StageAsked` to the record's `staged_at`, save, 202. |
| - [ ] **Step 1: Write the failing tests** (`offlinejob_test.go`, on `newOfflineWorld(t, ieOff("annie"), ukOff("iris"))`): |
| @@ -276,15 +277,18 @@ A crash between the record write and the row insert leaves an ordinary staged mo |
| // 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. |
| +// Each for all three bodies. |
| // TestOfflineRunDoorRefusesWhatStageRefuses: for each row of TestOfflineStartRefusals |
| -// (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. |
| +// (the lock row included) and of TestOfflineStageRefusesABoxThatCannotStage, on a |
| +// record at rest, POST /run answers the same status and sentence as POST /stage, |
| +// bucketState is unchanged and no live job row remains. |
| // TestOfflineRunDoorStagesAndRecordsTheJob: 202; record().Move.State == |
| -// provision.OfflineStaging; view.Job.State == "running", .Step == "stage", |
| -// len(.Steps) == 1; the row's TickAt and StageAsked are set and Intent is ""; |
| -// w.lock() names the host; the serial changed. |
| +// provision.OfflineStaging and record().Move.ID == the row's ID; view.Job.State == |
| +// "running", .Step == "stage", len(.Steps) == 1; the row's TickAt and StageAsked are |
| +// set and Intent is ""; w.lock() names the host; the serial changed. |
| +// TestOfflineRunDoorWritesTheRowFirst (I0): with a store that blocks the record Put, |
| +// the job row is already live while the Put is held; a hand POST /stage for the host |
| +// made then answers MV-O211. |
| // 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, |
| @@ -294,11 +298,22 @@ A crash between the record write and the row insert leaves an ordinary staged mo |
| // {"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 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. |
| +// TestOfflineRunDoorLeavesAHandMoveAlone: after w.stage() and, separately, after |
| +// w.start() (no job), POST /run answers 409 msgO25(state), inserts no row and leaves |
| +// bucketState unchanged. |
| +// TestOfflineHandDoorsRefuseWhileAJobOwns (I0, Review Focus 2): with a live job, in |
| +// each record state from staging to reverting and for the row both running and |
| +// returning, each of POST /stage, "" (start), /seal, /flip, /open, /abort and /finish |
| +// answers 409 with MV-O211 and leaves bucketState unchanged, whatever the evidence |
| +// says (run it with the fixture's reports making the step otherwise pass). GET status |
| +// answers 200. With the row opened, aborted, stopped or released, each door answers |
| +// exactly what it answers with no job row at all. |
| +// TestOfflineRunAbortAndRelease (Review Focus 2): {"abort":true} on a running job in |
| +// stopping: 202, the row returning with intent abort and the operator's reason, the |
| +// record not yet written; a second {"abort":true}: 202, row unchanged. {"release": |
| +// true}: 202, the row released, bucketState unchanged, the lock still held; then |
| +// POST /seal by hand with passing evidence answers 202. Each of abort and release |
| +// with no live job: 409 MV-O214. |
| // TestOfflineStatusCarriesTheJobAfterItEnds: a job saved as aborted with Reason "x" |
| // and the record's LastMove.ID equal to it: GET status has State "none" and |
| // Job.Reason "x"; with a newer LastMove.ID, Job is nil. |
| @@ -306,10 +321,10 @@ A crash between the record write and the row insert leaves an ordinary staged mo |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=$G go test ./internal/console -run 'TestOfflineRunDoor|TestOfflineStatusCarriesTheJob' -count=1` |
| +Run: `TMPDIR=$G go test ./internal/console -run 'TestOfflineRunDoor|TestOfflineHandDoors|TestOfflineRunAbortAndRelease|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 3: Write `handleAPIInstanceOfflineRun`, `offlineOwned` and `offlineJobViewFor`; add the owned check to the four handlers; 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** |
| @@ -320,10 +335,10 @@ Expected: PASS. These are the tests that read the route lists (`claim_routes_tes |
| ```bash |
| git add internal/console |
| -git commit -m "offline move: the run door and the job in the status view" |
| +git commit -m "offline move: the run door, and hand doors refuse an owned move" |
| ``` |
| -Brief Astra on this commit: the door's gate order against the other offline doors, and what a re-attach or adopt can write. |
| +Brief Astra on this commit with the round history: the door's gate order against the other offline doors; I0 (is there any way to write a job-owned move from a hand door, or for the job to write after a release); what a re-attach can write. |
| --- |
| @@ -331,22 +346,24 @@ Brief Astra on this commit: the door's gate order against the other offline door |
| **Per-task Astra review** (the console stops, opens and aborts a production instance unattended). |
| -*W4 note: #413 changes which target boxes `flip` waits on, inside `offlineStepFor` and `offlineSelect`. The pass calls those functions and reads no fleet of its own, so it needs no change when #413 lands.* |
| +*W4 note: #413 would change which target boxes `flip` waits on, inside `offlineStepFor` and `offlineSelect`. The pass calls those functions and reads no fleet of its own, so it needs no change if #413 lands.* |
| **Files:** |
| -- Modify: `internal/console/offlinejob.go`, `internal/console/offlinejob_test.go`, `internal/console/claim_workers.go:18`, `cmd/console/main.go:812`, `internal/console/testdata/claim-routes.txt:429`, `internal/console/claim_invariant_fixtures_test.go:2483`, `internal/console/jobs_test.go:53` |
| +- Modify: `internal/console/offlinejob.go`, `internal/console/offlinejob_test.go`, `internal/console/claim_workers.go` (`registerClaimWorkers`), `cmd/console/main.go` (beside `StartDomainPurchasePass`), `internal/console/testdata/claim-routes.txt`, `internal/console/claim_invariant_fixtures_test.go`, `internal/console/jobs_test.go` (`jobPassFuncs`) |
| **Interfaces:** |
| -- 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`. |
| +- Consumes: Tasks 1 to 3; `offlineStepFor`, `readOfflineEvidence`, `offlineStageOf`, `offlineOpenCheck`, `offlineReleaseLock`, `offlineLockGrace`, `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 |
| const ( |
| offlineJobTick = 5 * time.Second |
| - offlineJobStageBound = 30 * time.Minute // spec §6.2 |
| + offlineJobStageBound = 30 * time.Minute // spec §6.2; the stage step's deadline |
| offlineJobStageRounds = 10 |
| offlineJobStageMin = 2 |
| offlineJobReadyBytes = 16 << 20 // a round that copied less is caught up |
| + offlineJobRoundFresh = 2 * time.Minute // start only from a round the job settled this recently |
| + offlineJobRoundWait = 10 * time.Minute // a stage request unanswered this long is a failed round |
| offlineJobStopWait = 5 * time.Minute // start: every source box stopped (spec §7.2 floors) |
| offlineJobSealWait = 10 * time.Minute |
| offlineJobFlipWait = 5 * time.Minute // sealed: the flip's checks |
| @@ -358,11 +375,11 @@ const ( |
| 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 offlineJobBound(j OfflineMoveJob, rec *provision.Record) (bound bool, close offlineJobDecision) // I1, pure |
| +func (s *Server) offlineJobTickOne(ctx context.Context, id string, now time.Time) error // takes s.offlineJobMu, reads the row again |
| +func offlineJobBound(j OfflineMoveJob, rec *provision.Record, now time.Time) (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 |
| +func offlineJobGate(ev offlineEvidence, mv *provision.MoveState) *offlineRefusal |
| ``` |
| ```go |
| @@ -370,6 +387,7 @@ type offlineJobInput struct { |
| Job OfflineMoveJob |
| Move *provision.MoveState // never nil, and Move.ID == Job.ID (I1 ran first) |
| Stage *offlineStageView // offlineStageOf(ev) |
| + Start *offlineRefusal // staging only: class, region and offlineStepFor refusals on the fresh record |
| Step *offlineRefusal // offlineStepFor's refusal for the state's verb; nil: it would pass |
| Gate *offlineRefusal // offlineJobGate; read only in offline-landed |
| Failed string // box whose sealer or target report says failed; "" for none |
| @@ -380,89 +398,109 @@ type offlineJobDecision struct { |
| 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 |
| + State string // close: opened | aborted | stopped. intend abort: returning |
| Reason string // abort, close |
| Waiting string |
| Overdue bool |
| } |
| ``` |
| -**One tick, in this order.** Each phase names the invariant it is the one place for. |
| +**One tick**, under `s.offlineJobMu`, 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. |
| +0. **Own (I0).** Read the row again by id. Not `Live()` (released, or closed by the door): return. Nothing below runs for a job that does not own its move. |
| +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: |
| + - no offline move at all, and `now - CreatedAt < offlineLockGrace` (2 min): return and look again next tick (the door's begin write may still land, as the lock's own grace allows); |
| + - `Last.ID == Job.ID`: close `aborted` (the only outcome a live job's move can reach, since `finish` after open is not the job's and hand doors refuse). If the intent was `finish`, first bump the serial and call `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; |
| + - anything else: close `stopped` with MV-O197. |
| +2. **Clock.** If `now - TickAt > 30 s`, the gap is downtime: add it to `DeadlineAt` when there is one. Set `TickAt = now`. (`StageAskedAt` is *not* moved: a round that finished before a long gap is stale, which is the point of the fresh rule below.) |
| +3. **Guard (I5).** Record state `offline-open` or `offline-finishing` with an intent other than `open`: close `stopped` with MV-O197 and write nothing. (It cannot happen while I0 holds; this is the one place that says so.) |
| 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++` | |
| + | `restage` | `Move.StagedAt` is after `StageAsked` | `StageAsked = Move.StagedAt`, `StageAskedAt = now`, `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 | | |
| + | `flip` | state is past `offline-sealed` | step `flip`, deadline 10 min | |
| + | `open` | state is `offline-open` or `offline-finishing` | closed `opened`, the last step's `Took` | |
| | `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). |
| +5. **Decide**, with no intent pending: `readOfflineEvidence`, `offlineStepFor`, in staging also `offlineClassRefusal` and `offlineRegionRefusal`, in landed `offlineJobGate`, 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-staging` | `stage` | see "Staging" below | `start` or `restage` | 30 min | see below | |
| | 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 | |
| +A row whose record state has moved on under a box's own transition (sealing to sealed, landing to landed) gets the table's step for the new state: a new `Steps` entry and a fresh deadline. No other state change can happen without the job (I0). |
| + |
| +**Staging** (runbook §4: stage until caught up, and once more right before `start`; invariant: *start follows a round that finished moments ago*). With the stager's report `R` = `Stage`: |
| + |
| +1. `R` does not answer `StageAsked` (`R.Request != StageAsked`, or `StageAsked != Move.StagedAt`): wait. If `now - StageAskedAt > 10 min`: abort, MV-O195 (a round that never answered). |
| +2. `R` answers, phase `failed`: abort, MV-O195. The instance never went offline. |
| +3. `R` answers, phase `staged`. Let *enough* = (`Rounds >= 2` and `R.RoundBytes < 16 MiB`) or `Rounds >= 10` or `now` is past `DeadlineAt` (the 30 minutes, which phase 2 already stretched by any downtime). Let *fresh* = `now - StageAskedAt <= 2 min`. |
| + - *enough* and *fresh*, and `Start` is nil: intend `start` (`OfflineStartStaged`). |
| + - *enough* and *fresh*, and `Start` refuses: abort with that sentence. |
| + - otherwise (not enough yet, or enough but the round is old): intend `restage` (`OfflineRestage`). |
| + |
| +So a console that was down for 45 minutes comes back to a round that is not fresh and asks for one more before it starts, whatever `Rounds` and the budget say. |
| + |
| Rules the table does not show: |
| -- **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. |
| +- **Abort** is intent `abort`. The job decides it 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. An operator's `run --abort` saves the same row state (Task 3). |
| +- **`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; `ItemsOK(moves.OfflineOwnerLanding)`. Its refusal is MV-O198 with the box. No time is compared: the report's key carries this move's id, and a target box writes it only after the record's region is the destination (`offlineLand`), so a `landed` report for this id cannot predate this move's flip. 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 pure tests** (`offlinejob_test.go`, table-driven): |
| ```go |
| -// 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. |
| +// TestOfflineJobBound (I1): record with no move and CreatedAt 1 min ago -> not bound, |
| +// close nil (wait); the same 3 min ago -> close stopped; a non-offline move or an |
| +// offline move with another id -> close stopped; no move and Last.ID == Job.ID -> |
| +// close aborted. 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 |
| +// TestOfflineJobDecide: one case per line of the decision table and of "Staging": |
| +// staging, report answers, Rounds 1, RoundBytes 1<<10, fresh -> intend restage |
| +// staging, Rounds 2, RoundBytes 1<<10, fresh -> intend start |
| +// staging, Rounds 2, RoundBytes 32<<20, fresh -> intend restage |
| +// staging, Rounds 10, RoundBytes 32<<20, fresh -> intend start |
| +// staging, Rounds 1, Now past DeadlineAt, fresh -> intend start |
| +// staging, Rounds 2, RoundBytes 1<<10, StageAskedAt 3 min ago -> intend restage |
| +// staging, Rounds 1, Now past DeadlineAt, StageAskedAt 45 min ago -> intend restage |
| +// staging, report answers an older staged_at, asked 1 min ago -> wait |
| +// staging, the same, asked 11 min ago -> intend abort, Reason "the copy to uk failed" |
| +// staging, Stage.Phase failed -> intend abort, same Reason |
| +// staging, enough and fresh, Start refuses -> intend abort, Reason = that sentence |
| +// 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 |
| +// 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 -> a refusal (naming the box when there is one). |
| +// TestOfflineJobGate: a landed report with Held, RowPresent and |
| +// okChecks(moves.OfflineOwnerLanding) passes whatever its At; each of: phase failed, |
| +// Held false, RowPresent false, one item not OK, no target report, two target |
| +// reports -> a refusal (naming the box when there is one). |
| ``` |
| - [ ] **Step 2: Run to see them fail** |
| @@ -472,7 +510,7 @@ Expected: build failure, `offlineJobDecide undefined`. |
| - [ ] **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 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. |
| +- [ ] **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: `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 |
| // TestOfflineJobRunsAMoveToOpen: POST /run, then alternate RunOfflineMoveJobs with |
| @@ -481,11 +519,16 @@ Expected: build failure, `offlineJobDecide undefined`. |
| // "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. |
| +// fixture's parked and gone reports ends the move done (the doors are open again), |
| +// and the job row is unchanged. |
| +// TestOfflineJobWritesNothingAfterOpen (I5): with the record open or finishing and a |
| +// live row (running or returning, with and without an abort intent), ten ticks |
| +// commit zero record Puts and the row ends opened (intent open) or stopped. |
| +// TestOfflineJobNeverWritesAfterRelease (I0): release in each of stopping, sealed and |
| +// landed, with passing evidence for the next step and, separately, with an intent |
| +// pending: twenty ticks commit zero record Puts and zero serial bumps. A release |
| +// called while a tick is blocked inside its record Put returns only after that tick |
| +// does (the mutex), and the row is released afterwards. |
| // 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, |
| @@ -493,21 +536,24 @@ Expected: build failure, `offlineJobDecide undefined`. |
| // 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. |
| +// serial exactly once more 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. For finish: the move is cleared with no bump and the lock left; the |
| +// tick bumps, releases the lock and closes the row aborted. |
| // 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. |
| +// OfflineAbort again (the record is reverting) and never open. The same for an |
| +// abort the operator asked for with {"abort":true}. |
| +// TestOfflineJobLeavesAnotherMoveAlone (I1): a live row for move A while the record |
| +// carries offline move B (set with w.edit; it cannot arise through the doors any |
| +// more): with a counting store, the tick lists no report prefix, commits no record |
| +// Put, closes A's row stopped, and B's record is byte for byte unchanged. |
| +// TestOfflineJobWaitsOutAnUncertainAdmission: a row with no move on the record: a |
| +// tick 1 min after CreatedAt leaves it running; when the record then shows the move |
| +// with the row's id the job carries on from stage; with no move 3 min after |
| +// CreatedAt the row closes stopped. |
| // 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 |
| @@ -520,17 +566,28 @@ Expected: build failure, `offlineJobDecide undefined`. |
| // 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. |
| +// TestOfflineJobRestagesAfterDowntime (Review Focus 4): stage one round (Rounds 1, |
| +// report answered); jump the clock 45 min in one step; tick: the record is still |
| +// offline-staging, staged_at moved forward, the row's intent settled as restage and |
| +// DeadlineAt 45 min later than before. Only after the stager answers that request |
| +// does a tick write the start. |
| // TestOfflineJobResumesAfterRestart (Review Focus 1): run to sealing; build a second |
| // 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 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. |
| +// TestOfflineJobSimulation (I0 to I5; the guard rule 2 asks for): 200 seeds, each up |
| +// to 200 steps, a step chosen by the seed from: a tick; the box helper for the |
| +// current state (pass or failed); a hand POST to a random door; {"abort":true}; |
| +// {"release":true}; a clock step of 5 s or of 1 to 60 min; flakyStore failing the |
| +// next Put before or after it lands; a Server rebuilt over the same store. After |
| +// every step: (I0) every committed record Put while the row was live came from a |
| +// tick; (I2) no tick committed a transition its row did not name first; (I3) no |
| +// open after the row first said returning; (I4) no tick committed two transitions; |
| +// (I5) no committed Put by a tick with the record open or later; and a live row |
| +// with the boxes always passing reaches opened within the step budget. The failing |
| +// seed is printed. Budget: under 5 s; t.Skip under -short. |
| // 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 |
| @@ -558,7 +615,7 @@ git add internal/console cmd/console/main.go |
| git commit -m "offline move: the console job that runs a move to open" |
| ``` |
| -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. |
| +Brief Astra on this commit with the round history and invariants I0 to I5 as the claims to check, each against the one phase that enforces it and against `TestOfflineJobSimulation`. Name the family rule 2 fired on. A P1 in that family is not fixed: stop, and take Paul the cut (the job stops and says so for that case). |
| --- |
| @@ -567,32 +624,41 @@ Brief Astra on this commit with invariants I1 to I5 as the claims to check, each |
| 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`, the copy record, `approved_moves_copy_test.go` (`movesCopyIDs`, `movesScanFiles`) |
| +- Modify: `move.go` (`moveCommand`, `moveArgs`, `parseMoveArgs`, `moveOfflineUsage`, the CLI's `offlineView`, `headline`, `mover.offline`, `runStatus`), `move_test.go`, `offline_move_e2e_test.go`, `parity/cli.tsv` (by `make parity-doc`), `parity/parity.tsv` (the `move` row), the copy record, `approved_moves_copy_test.go` (`movesCopyIDs`, `movesScanFiles`) |
| **Interfaces:** |
| - Consumes: the status view's `job` (Task 3), the `/run` door. |
| - Produces: |
| - - Verb `run` in `moveCommand`'s offline list, first. `moveArgs.offline` may be `run`; it takes `--to` (required, as `start` and `stage`) and `--no-wait`. |
| - - The CLI's `offlineView` gains `Job *offlineJobSeen` (`json:"job"`): `State, Step, Reason string; StepAt, CheckedAt int64; Overdue bool; Steps []struct{Step string; At time.Time; Took float64 "json:\"took_s\""}`. `Reason` is console text: decode it as the existing `waiting` is and say it only through `saySpoken` (unknown: how `roundTrip` makes `serverText` for a field inside the view rather than an error body: read `moveReply.answer` at `move.go:442-520` and follow the path `waiting` takes; `TestMovesServerTextHasOneMaker` holds the rule). |
| - - `func (w *offlineRun) runRun(ctx context.Context, to string, wait bool) int` and `func (w *offlineRun) sayJob(v offlineView)`. |
| + - Verb `run` in `moveCommand`'s offline list, first. `moveArgs.offline` may be `run`, with exactly one of `--to <region>`, `--abort`, `--release` (none or more than one: MV-O215, a usage error), and `--no-wait` with `--to`. |
| + - The CLI's `offlineView` gains `Job *offlineJobSeen` (`json:"job"`): `State, Step, Reason string; StepAt, CheckedAt int64; Overdue bool; Steps []struct{Step string; At time.Time; Took float64 "json:\"took_s\""}`. `Reason` is console text: decode it as the existing `waiting` is and say it only through `saySpoken` (unknown: how `roundTrip` makes `serverText` for a field inside the view rather than an error body: read `moveReply.answer` in `move.go` and follow the path `waiting` takes; `TestMovesServerTextHasOneMaker` holds the rule). |
| + - `func (w *offlineRun) runRun(ctx context.Context, a moveArgs) 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`). 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. |
| +- `run --to`: 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 on every outcome** (invariant: *every terminal job state ends the watcher*): |
| + |
| + | The view shows | Says | Exit | |
| + |---|---|---| |
| + | job `opened` | the existing served line (`sayServed`), then MV-O205. The CLI does not post `finish`. | 0 | |
| + | job `aborted` | MV-O203 with the job's reason, then the existing abort lines (`ended`) | 3 | |
| + | job `stopped` or `released` | MV-O204 with the reason | 4 | |
| + | job `returning` and `overdue` | MV-O210, and the command stops watching | 4 | |
| + | anything else that is not a live job: no `job` in the view, a job state the CLI does not know, or move state `none` | the existing `stray` (which says where the move stands, or how it ended through `ended`) | `stray`'s | |
| + | interrupted (`m.sleep` false) | MV-O208 instead of "Stopped waiting." | 1 | |
| + |
| +- `run --abort`: POST `{"abort":true}`; a refusal is exit 5; on 202 follow as above from where the move is (it ends `aborted`, exit 3). |
| +- `run --release`: POST `{"release":true}`; a refusal is exit 5; on 202 say MV-O216 and exit 0. It does not follow. |
| - 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-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). |
| +- `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. With a job `released`, say MV-O204 and then today's lines for a hand move. Exit 4 when `overdue`, `stopped` or `released`; 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` or `released` it says today's lines unchanged. |
| +- A hand verb refused because the job owns the move needs no CLI change: it is a 409 with the console's sentence (MV-O211), which `refusal` already says, exit 5. |
| - [ ] **Step 1: Write the failing tests** (`move_test.go`, with `fakeOfflineConsole` frames; `offline_move_e2e_test.go` for the real door): |
| ```go |
| // TestParseMoveArgsOfflineRun: "offline run --host h --to uk" parses with offline |
| -// "run", to "uk", wait true; "--no-wait" clears wait; without --to it says |
| -// moveNeedsTo; "offline" alone says the new usage line (MV-O199). |
| +// "run", to "uk", wait true; "--no-wait" clears wait; "--abort" and "--release" |
| +// parse; none of the three, or two of them, says MV-O215; "offline" alone says the |
| +// new usage line (MV-O199). |
| // TestMoveOfflineRun: frames staging(job step stage) -> stopping(start) -> sealing(seal) |
| // -> 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 |
| @@ -605,8 +671,13 @@ Needs Task 0's approved text. The census card is made in Task 7, after the last |
| // 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."; no POST |
| // but /run. |
| -// TestMoveOfflineRunAbortOverdue: a frame reverting with job returning and overdue: |
| -// exit 4, MV-O210, no POST but /run. |
| +// TestMoveOfflineRunEveryOutcomeEnds: one case per row of the outcome table, the |
| +// "anything else" row three times over (a frame with no job; a frame with job state |
| +// "paused"; a frame with move state none and last done, as when someone finished the |
| +// move): each returns, with the row's exit code, within three frames. |
| +// TestMoveOfflineRunAbort: POST body {"abort":true}; frames reverting(job returning) |
| +// -> none(job aborted): exit 3. Refused with 409: exit 5. |
| +// TestMoveOfflineRunRelease: POST body {"release":true}; exit 0, MV-O216, no GET. |
| // 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. |
| @@ -617,17 +688,21 @@ Needs Task 0's approved text. The census card is made in Task 7, after the last |
| // started 42 seconds ago." and both finished lines; no "Run carlos move offline". |
| // TestMoveOfflineStatusAfterAConsoleAbort: frame none with last aborted and job |
| // aborted with reason: MV-O203 then the outcome line; exit as today for aborted. |
| +// TestMoveOfflineHandVerbRefusedWhileOwned: "offline seal" against a fake answering |
| +// 409 with MV-O211: exit 5 and the sentence as written. |
| // TestMoveOfflineRunAgainstTheRealDoors (offline_move_e2e_test.go): moveMain |
| // "offline run --no-wait" on newOfflineE2E answers exit 0 and the record is |
| -// offline-staging; "offline status" then prints the step line for stage. |
| +// offline-staging; "offline status" prints the step line for stage; "offline abort" |
| +// exits 5 with MV-O211; "offline run --release" exits 0, and then "offline abort" |
| +// is accepted. |
| ``` |
| - [ ] **Step 2: Run to see them fail** |
| -Run: `TMPDIR=$G go test . -run 'TestParseMoveArgsOfflineRun|TestMoveOfflineRun|TestMoveOfflineStatusNamesTheStep|TestMoveOfflineStatusAfterAConsoleAbort' -count=1` |
| +Run: `TMPDIR=$G go test . -run 'TestParseMoveArgsOfflineRun|TestMoveOfflineRun|TestMoveOfflineStatusNamesTheStep|TestMoveOfflineStatusAfterAConsoleAbort|TestMoveOfflineHandVerbRefusedWhileOwned' -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 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 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 as `approved` (Task 0) and its id into `movesCopyIDs` (MV-O181's row becomes `withdrawn`, replaced by MV-O199, the way MV-O56 was). The console sentences of Tasks 3 and 4 get their rows here too. |
| - [ ] **Step 4: Run the CLI tests, the copy gate and the projection** |
| @@ -646,49 +721,64 @@ git commit -m "carlos move offline run: one command, and status names the step" |
| ### 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), `internal/host/movesoffline_e2e_test.go` |
| +- Modify: `docs/site/cli.md` (the `carlos move offline` section), `docs/superpowers/plans/2026-10-21-offline-move-runbook.md` (short version, §5 and §11), `internal/host/movesoffline_e2e_test.go` |
| **Interfaces:** |
| -- 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`. |
| +- Consumes: `(*console.Server).RunOfflineMoveJobs`, `e2eWorld` (`do`, `status`, `requireClosedWriteSet`, `w.sw.fake`, `w.rs`), `e2eLoops` (`w.loops()`, `after`, `reassert`, `passes`), the archive tamper of `offlineMoveRollback`. |
| +- Produces: `TestOfflineJobE2E`, and `func (l *e2eLoops) job(srv *console.Server) e2eView`. |
| -- [ ] **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. |
| +- [ ] **Step 1: Docs.** In `cli.md`, put the three `run` forms first in the command list (`run --host <host> --to <region>`, `run --host <host> --abort`, `run --host <host> --release`) and add the approved paragraphs D1 and D3 before the per-verb text; the sentence "never acts on its own" (row MV-O32) becomes the approved D2. In the runbook: the short version and §5 say `run` replaces `move.sh`'s doors and gate up to open; §11 says that while `run` owns a move the hand verbs refuse, `run --abort` is the abort, and `run --release` hands a stuck move back; sections 2, 3, 6, 7 (then `finish`, §8), 9 and 10 are still the operator's. |
| Run: `TMPDIR=$G go test . -run 'TestMoveDocs|TestMovesCopy|TestMovesApprovedCopyIsApplied|TestMovesStringsAreRecorded' -count=1` |
| Expected: PASS. |
| -- [ ] **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. |
| +- [ ] **Step 2: Write the driver and 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 move only as production moves them, through `e2eLoops`, used the way `offlineMoveDoorsApart` uses it (it sets the boxes' clock; a bare `round()` does not, and reports written at a zero time fail the doors' freshness check). |
| + |
| +`l.job(srv)` is one beat of the driver, and the only thing the witness calls in its loops: |
| + |
| +1. `srv.RunOfflineMoveJobs(ctx)`: the job's tick. |
| +2. `l.after(0)`: sets the boxes' clock to now and runs each box's serial pass for as long as the serial keeps moving (so a transition the job wrote and announced is acted on, and one it did not announce is not). |
| +3. `l.reassert(time.Now())`: the 15-second re-assert tick, which sets the clock and refreshes the source and sealer reports the doors judge by age. |
| +4. returns `w.status()`. |
| ```go |
| // 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 |
| +// forward: POST .../move/offline/run {"region":"uk"}; loop v := l.job(srv) until |
| +// v.Job.State == "opened" (bounded: fail after 200 beats, naming the state and |
| +// the waiting sentence it stuck on). Then drain: l.after(0) once more, so the |
| +// target's pass that the open's serial bump starts has run (it is what releases |
| +// the hold and makes the row ready). Only then assert what TestOfflineMoveE2E |
| +// asserts after its open (record region uk, state offline-open, the row ready on |
| +// the target, the source tombstoned) and that job.steps holds the six steps. The |
| +// test posts to no door but /run. Then the hand finish as TestOfflineMoveE2E does |
| +// it (the doors answer again: the job is opened), with its end-state assertions |
| +// (last outcome done, the closed write set, the tombstone lifted). |
| +// owned: mid-move (record offline-stopping), a hand POST /abort answers 409 with |
| +// MV-O211 and w.requireRefused's no-write checks hold. |
| +// lost reply: forward, with w.rs made to return an error for the committed Put of |
| +// the start transition and of the flip (the write lands; offlineApplyStep's own |
| +// bump never runs). The move still reaches opened, with no second record Put for |
| +// either. Because no box pass runs without a moved serial, and the re-assert tick |
| +// acts only on moves the box's last pass already saw past staging, the only thing |
| +// that can carry the start to the boxes here is the job's settle bump: assert |
| +// l.passes rose on the beat after the lost reply. |
| +// abort: loop l.job(srv) only while the record is before offline-sealed; 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. |
| +// bucket); resume the loop until status state is "none"; drain with l.after(0). |
| +// Assert 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. |
| ``` |
| -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 3: Prove the witness can fail** (once, not committed): comment out the settle phase's `release.BumpSerial` call and run the lost-reply case. Expected: it fails at the 200-beat bound, stuck in `offline-stopping`. Restore the line. If it passes without the bump, the driver is letting boxes run unannounced: fix the driver before going on. |
| -- [ ] **Step 3: Run** |
| +- [ ] **Step 4: Run** |
| Run: `TMPDIR=$G go test ./internal/host -run 'TestOfflineJobE2E|TestOfflineMoveE2E' -count=1` (sandbox off) |
| -Expected: PASS. |
| +Expected: PASS. Real time is fine: no case waits on a deadline, and none is shorter than 3 minutes. |
| -- [ ] **Step 4: Commit** |
| +- [ ] **Step 5: Commit** |
| ```bash |
| git add docs internal/host/movesoffline_e2e_test.go |
| @@ -704,13 +794,13 @@ git commit -m "offline move job: docs and the two-box witness" |
| 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: 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 2: Census, on the final source.** `make census-card`; write the CLAIMS file (one line per changed unit of `move.go`: output and two request bodies, 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 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: One whole-branch Astra review** (`-m gpt-6-astra`, effort high), brief from the template, carrying the full round history (plan rounds 1 to 3, Paul's ruling on #1005, the Task 3 and Task 4 reviews), the Review Focus list, invariants I0 to I5 and the census card. It gives the census verdict for every unit, recorded on #280 with the tip. It stops at its 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. A P1 in the family rule 2 fired on goes to Paul with the cut, not to a fix. |
| -- [ ] **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. |
| +- [ ] **Step 5: Squash-merge on amadan** with an explicit message built in the same command (subject under 80 characters, body after a blank line; write the message file inside the worktree, not under a sandbox `$TMPDIR` the unsandboxed command cannot see). Read `main`'s CI run afterwards. |
| --- |
| @@ -721,15 +811,16 @@ Every step here changes dev and needs Paul's go at that step; nothing in it is d |
| - [ ] **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, 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. |
| +- [ ] In a second terminal during the move: `carlos move offline status --host <dev host>` names the step, and `carlos move offline seal --host <dev host>` is refused with the one sentence. |
| - [ ] 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`. |
| +- [ ] **Paul's go, at this step** (#1005: 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 run --host <dev host> --abort` during `seal`. Pass: exit 3 from both commands, the reason line, the instance serving from `ie`. |
| +- [ ] One release: a fourth run, `run --release` while staging, then `carlos move offline abort` by hand. Pass: the release exits 0, the hand abort is accepted, the instance never went offline. |
| - [ ] Post the log on the branch's discussion and on the program plan's W3 line. |
| --- |
| -## Appendix A. Copy deck (draft until Task 0; Paul's review makes a row approved) |
| +## Appendix A. Copy deck (draft until Task 0; Luna'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. |
| @@ -754,6 +845,9 @@ 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. |
| + |
| +$ carlos move offline seal --host shop.example.com |
| +the console is running the move of shop.example.com. to stop it run carlos move offline run --host shop.example.com --abort. to carry on by hand run it with --release first |
| ``` |
| | Id | Where | Text | |
| @@ -761,57 +855,72 @@ Step start finished in 23 seconds. |
| | MV-O194 | console, job reason | `<step> did not finish within <n> minutes` | |
| | MV-O195 | console, job reason | `the copy to <to> failed` | |
| | MV-O196 | console, job reason | `<box> reported that it could not finish <step>` | |
| -| MV-O197 | console, job reason | `the move is no longer on the record. someone ended it by hand` | |
| +| MV-O197 | console, job reason | `the move is no longer on the record` | |
| | MV-O198 | console, wait sentence | `the report from <box> does not show <host> landed and held for this move` | |
| | MV-O199 | CLI usage, replaces MV-O181 | `carlos move offline needs run, stage, start, seal, flip, open, finish, abort or status.` | |
| | MV-O200 | CLI, `run` accepted | `The console is moving <host> from <from> to <to>. It runs every step itself. Stopping this command does not stop the move.` | |
| | MV-O201 | CLI, a step starts | `Step <step> started.` | |
| | MV-O202 | CLI, a step ends | `Step <step> finished in <n> seconds.` | |
| | MV-O203 | CLI, console abort | `The console stopped the move at step <step>: <reason>. It is moving <host> back to <from>.` | |
| -| MV-O204 | CLI, job stopped | `The console is no longer running this move: <reason>.` | |
| +| MV-O204 | CLI, job stopped or released | `The console is no longer running this move: <reason>.` | |
| | 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` | |
| | 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.` | |
| +| MV-O211 | console, a hand door on an owned move | `the console is running the move of <host>. to stop it run carlos move offline run --host <host> --abort. to carry on by hand run it with --release first` | |
| +| MV-O212 | console, job reason | `an operator asked the console to stop the move` | |
| +| MV-O213 | console, job reason | `an operator took the move over by hand` | |
| +| MV-O214 | console, abort or release with no job | `the console is not running a move of <host>` | |
| +| MV-O215 | CLI usage | `carlos move offline run needs one of --to <region>, --abort or --release.` | |
| +| MV-O216 | CLI, released | `The console has stopped running this move and left it where it is. Run carlos move offline status --host <host>, then carry on with the other verbs.` | |
| +| MV-O217 | CLI flag help, `--abort` | `ask the console to stop the move and move the instance back` | |
| +| MV-O218 | CLI flag help, `--release` | `stop the console running this move and leave it as it is, to carry on by hand` | |
| | 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. | |
| +| D3 | `docs/site/cli.md` | While the console is running a move, the other verbs refuse for that instance. To stop the move, run `carlos move offline run --host <host> --abort`: the console moves the instance back. If a move is stuck and you want to carry on by hand, run it with `--release`: the console stops and leaves the move as it is, and the other verbs work again. | |
| ## Appendix B. Deferred, and why |
| -- **`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. |
| +- **`finish` by the job.** Paul, #1005: the operator's checks (runbook §7, the row fingerprint) come between open and finish, so finish stays a hand step. If that changes later, it is one more intent in the same table. |
| +- **Adopting a hand-staged move.** Cut in rev 3 with the ownership rule: `run` starts its own move or refuses. Abort the hand stage and run again. |
| +- **Paging.** Paul, #1005: 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. 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 (rev 2) |
| +## Self-review (rev 3) |
| -- **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. |
| +- **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 Paul's ruling (a stated difference from W3's wording); 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 right before start (§4: the staging rule's *fresh*); 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). |
| +- **Paul's ruling.** Ownership and its refusal: Task 3 (`offlineOwned`, row first), Task 4 phase 0, I0. The escape, once: `run --release`, Global Constraints. Luna's gate: Task 0. `run` stops at open; cutover off. |
| +- **Rounds 1 and 2.** Every finding has a line below and a test or step in the task that owns it. |
| +- **Types.** `OfflineMoveJob` (with `Intent`, `StageAsked`, `StageAskedAt`; no `FlippedAt`), `OfflineJobStep`, `offlineJobView`, `offlineJobInput`, `offlineJobDecision`, `offlineJobBound`, `offlineJobSettled`, `offlineJobGate(ev, mv)`, `offlineOwned`, `offlineJobMu`, `RunOfflineMoveJobs`, `StartOfflineMoveJobs`, `offlineBeginMove(ctx, d, id, begin)` are spelled the same in every task. 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, aborted, stopped, released. |
| +- **Proportion.** No function bodies; the tick's order, the two tables and the staging rule 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. |
| - |
| -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. |
| +Astra, round 1 of 3, on f6287be0: NOT READY, 5 P1, 4 P2. Where rev 3 changed a rev 2 answer, the line says so. |
| + |
| +1. **P1, the job is not bound to its move id.** Accepted. Tick phase 1 (I1, `offlineJobBound`); 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 (I3). Rounds are counted from the record's `staged_at`. 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); a lost finish also releases the lock. Tests: `TestOfflineJobSettlesALostReply`; the witness's lost-reply case. |
| +4. **P1, re-attach is unreachable after flip.** Accepted. The door recognises the job right after the gate and the region's shape. Test: `TestOfflineRunDoorReattachesInEveryState`. |
| +5. **P1, five tests contradicted the interfaces.** Accepted, each: the lock refusal is `offlineBeginMove`'s; no token is the route's 401; deadlines are tested by ticking through the time and downtime by one jump, with `TickAt` set at admission; committed `Put`s and bumps are counted instead of `MoveSeq`; `landedForJob` sets `Held` and `RowPresent` on one shared clock. |
| +6. **P2, `landOpts` has no fault field.** Accepted. The abort witness tampers with the sealed archive, as `offlineMoveRollback` does. |
| +7. **P2, copy approved by the wrong reviewer, after the build.** Accepted in part, and changed in rev 3. The order stands: UX pass, then copy review, then code (Task 0). The approver is Luna, not Paul: Paul delegated copy review to her on 2026-10-25 and confirmed it for this plan on #1005, so rev 2's "only Paul's review makes a row approved" is withdrawn. |
| +8. **P2, the census proposal preceded later edits.** Accepted. Task 7, after the last source edit, with a rerun rule. |
| +9. **P2, shared `/tmp/g`.** Accepted; finished in rev 3 (round 2, finding 6): `$TMPDIR` only. |
| + |
| +## Round 2 dispositions |
| + |
| +Astra, round 2 of 3, on 5a8163fe: NOT READY, 3 P1, 4 P2, and stopping rule 2 on the recovery family. Paul ruled on #1005: take the cut. Findings 1 and 2 are therefore removed, not fixed. |
| + |
| +1. **P1, a hand restage leaves the job waiting on a request that never matches** (and concurrent adoption does the same). **Removed by the cut.** Invariant I0: while a job is live it is the only writer of its host's move. The stage door refuses (MV-O211), so `staged_at` moves only when the job moves it; and `run` no longer adopts a hand-staged move, so there is no adoption to race. The row is written before the move exists (`TestOfflineRunDoorWritesTheRowFirst`). Tests: `TestOfflineHandDoorsRefuseWhileAJobOwns`, `TestOfflineRunDoorLeavesAHandMoveAlone`, `TestOfflineJobSimulation`. |
| +2. **P1, following a hand flip can reject a valid landing.** **Removed by the cut.** The flip door refuses while the job owns the move, so there is no hand flip to follow, and the "a hand door wins" rule is deleted from the tick. The time comparison that made the failure possible is gone too: `offlineJobGate` no longer takes `flippedAt` (and the row no longer has it), because a `landed` report under this move's id cannot predate this move's flip. Invariant: *evidence is bound to the move by its key, never by when the console noticed*. Test: `TestOfflineJobGate` ("whatever its At"). |
| +3. **P1, the two-box driver cannot satisfy its assertions.** Accepted. Task 6 defines the driver beat `l.job(srv)`: the job's tick, `l.after(0)` (which sets the boxes' clock and runs serial passes), then `l.reassert(time.Now())`. After `opened` the witness drains with `l.after(0)` before it asserts anything about the target or the source. Step 3 proves the witness fails with the settle bump removed. Invariant: *a witness runs production's scheduling with real clocks and waits for the effect it asserts*. |
| +4. **P2, console downtime replaces the final staging round with old evidence.** Accepted. The staging rule starts only from a round the job settled within 2 minutes (`StageAskedAt`, `offlineJobRoundFresh`), whatever `Rounds` and the budget say; the 30-minute budget is the stage step's `DeadlineAt`, which phase 2 stretches by downtime, instead of time since `CreatedAt`; a request unanswered for 10 minutes is a failed round. Invariant: *start follows a round that finished moments ago*. Tests: `TestOfflineJobRestagesAfterDowntime`, the staging cases of `TestOfflineJobDecide`. |
| +5. **P2, `run` has no terminal handling for `done`.** Accepted, mostly by removal. A job can no longer end `done` (the finish door refuses while it is live, and the job closes at open), so the state is deleted. The watcher's outcome table now has a row for every job state and a catch-all (no job, an unknown state, or move state `none`) that ends through the existing `stray`. Invariant: *every terminal job state ends the watcher*. Test: `TestMoveOfflineRunEveryOutcomeEnds`. |
| +6. **P2, the scratch fallback is outside the permitted location.** Accepted. `$TMPDIR` only; no `/tmp` fallback; a socket path that is too long is reported, not worked around. |
| +7. **P2, reviews scheduled beyond the budget.** Accepted. The plan's review budget is stated as spent with round 3: no fourth plan round and no reviewed plan revision without Paul's go. The code reviews that remain (Task 3, Task 4, the whole branch) are the ones Paul's ruling leaves in place; each stops at its first round with no P1, each brief carries the full round history including this round, and a code P1 in the recovery family goes to Paul with the cut instead of a third fix. |
| + |
| +Declined: none. |