Skip to content

Restart resilience acceptance: move a live tmux out of the server's unit, and the upgrade's config rule - #320

Merged
dinoderek merged 6 commits into
mainfrom
task/engine-346
Nov 23, 2026
Merged

dinoderek merged 6 commits into
mainfrom
task/engine-346

Conversation

@dinoderek

@dinoderek dinoderek commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Objective

Acceptance of restart resilience: each objective O1–O13 is checked against the tests that prove it and, where a real run was possible, against a run on the real fleet (devbox, the Linux server host; the Mac, a session host) with throwaway "hold" tasks. Two docs that the runs showed wrong or incomplete are fixed. The diff is docs only: the existing tests already cover every objective (map below), so this PR adds no test.

Gates

Lane Result Evidence
./dev test (every required lane) PASS local run 2026-11-23T22:00:43Z on this head, all 10 lanes PASS under umask 022; CI on this head: gates run, PASS
  • New or changed tests: none. The diff changes docs/recovery.md and docs/operator-setup.md only.
  • Not run, with reason: none. Note: under this session's umask 0077, TestTrustFolderKeepsEverythingElse and TestEditFileRetriesThenGivesUpOnABusyFile fail on main as well (file modes), so the gate was run under umask 022, as CI's default umask is.

Evidence per objective

Update numbers are the engine server's update sequences. Attempts are a<n>. Hold A, B and C are the throwaway tasks. The run's raw files are kept on devbox in ~/.local/state/engine-acceptance/restart-resilience/.

Obj. Tests (./dev test) Real run
O1 claimed death resumes internal/control/vanish_test.go TestTheVanishRule, TestReconcileResumesClaimedDeathsUntilTheCap; internal/controlrun/early_test.go TestASessionThatClaimedItsTaskResumesAfterItsDeathsUntilTheCap; internal/controlrun/hold_test.go TestResumeDispatchesAgainAsAResumeOfTheKeptBranch Pass. 17:22:41Z tmux kill-window on Hold B (a432, claimed). 3450: ended vanished, crashed (1 of 3); 3451: "the task stays resumable and is dispatched again as a resume"; 3452: resume a434 in the same worktree.
O2 host-wide loss internal/control/hostloss_test.go (all, incl. negatives); internal/controlrun/tmuxloss_test.go; internal/remote/ssh_test.go TestSSHRefusesAStatusWithoutATmuxStartTime Pass, twice. 17:26:39Z tmux kill-server on the Mac (Hold A a431, Hold C a433, plus two non-engine sessions). 3465/3466: both vanished, host_lost, uncounted, no per-task notice; 3467/3469: resumes a435/a436. A second, unplanned tmux kill-server on the Mac at 17:29:20Z, run by mistake by the operator's supervisor and recorded by them in 3481, ended the new tmux server with the resumed a435/a436. It was read the same way: 3478/3479, vanished, host_lost, uncounted, resumes a437/a438. It is not row 9's evidence. The operator's inbox holds exactly two host notices, "mac's tmux restarted; 2 tasks will resume": 3464 at 17:26:51 and 3477 at 17:29:25, one per kill, and no per-task death notice (3680, 3685).
O3 cap internal/control/vanish_test.go; internal/control/early_test.go; internal/control/planner_test.go; internal/controlrun/early_test.go (notice with the last two tails) Tests only, by design (plan Testing rows 2–3).
O4 CLI retry internal/controlcmd/retry_test.go; internal/pane/pane_test.go TestThePromptHooksSynchronousPostIsBoundedWithTheServerDown Pass. Unit stopped 17:28:33–17:29:23Z. A session engine tell sent 10 s into the outage printed one line, "engine server unreachable; retrying until 17:30:13 (request key b376…2def)" (its start plus 90 s), and landed at 17:29:30 as 3480.
O5 outage wake internal/controlrun/outage_test.go; internal/control/outage_test.go Pass. Unit stopped 17:29:55–17:36:36Z. Idle Hold B got one wake, "The engine server was unavailable from 2026-11-23T17:29:56Z to …", answered in 3484. A busy session was not woken.
O6 unit check internal/setup/unit_test.go Pass (read-only). Setup on devbox during the upgrades: "server unit: ok (engine-server.service enabled, restarts, lingers; the session tmux is outside it)".
O7 tmux outside the unit internal/session/tmuxscope_test.go; internal/hostops/tmuxunit_test.go Pass. devbox's live tmux, started inside the unit before this change, was moved into its own scope first (below). Then 6 unit stops kept every devbox window and the tmux start time: upgrades at 09:09 and 16:56 (the latter run by the operator's supervisor, 3412), rows 9 and 10, systemctl --user restart at 17:39:16Z, and the 19:12 upgrade.
O8 upgrade mid-plan internal/upgrade/upgrade_test.go; internal/control/upgrade_test.go; internal/controlrun/upgrade_test.go; internal/harness/codex/retain_test.go Pass. Three upgrades ran with tasks busy, the last (19:11–19:19Z) with Hold B's session and another plan's live planner running (Hold C was running with no live session, awaiting its resume, which reached devbox at 19:16:25: O10). No window died: the planner's window closed at 19:16, after the server returned, because it finished (3578). After finish, every throwaway task reached done by 19:27:44Z (dinoderek/engine-acceptance#1–#4, the last the plan's closing task), and the throwaway plan is done. The start and end marks were refused, because the upgrade ran with an execution credential (the operator chose that, 3261).
O9 unreachable host internal/control/unreachable_test.go; internal/controlrun/unreachable_test.go Pass. 17:43:01Z devbox's ssh to the Mac was blocked. 17:43:19 host status: mac unreachable. The operator confirmed one fleet question for the Mac, no earlier than 17:58:19Z, holding no task, with wait, move and stop as its choices (3680, 3685), and answered "move" (pane message 3506).
O10 move, pause, resume internal/controlcmd/move_test.go, hostpause_test.go; internal/control/move_test.go, hostpause_test.go; internal/controlrun/move_test.go Pass. 18:05:17 3503/3504: both Mac attempts ended moved ("… its old session there may still push. Its window is released when the host answers"). Resume a440 on devbox (3507). After the block was lifted at 18:05:41, the Mac's old windows were released by 18:06:11, with the worktrees kept and clean. Hold C's resume, a452, waited, as devbox's 3 slots were full and the Mac paused, and was dispatched on devbox at 19:16:25, as the other plan's planner window closed (the slot cause is inferred, not read). engine host resume mac at 19:20, run with the operator credential as the operator directed in 3521, returned "paused": false.
O11 limit choice internal/control/limitask_test.go; internal/reconcile/limitchoice_test.go; internal/controlrun/limitask_test.go Tests only, by design (no real-run row).
O12 watcher, server status/restart internal/watch/watch_test.go, main_test.go; internal/serverops/serverops_test.go Pass. The Mac's launchd watcher logged each failed check and reached {"failures":8,"alerted":true}, then {"failures":0,"alerted":false} once the server answered. The operator confirmed on Telegram one alert listing engine server status and engine server restart, then one recovery message (3680, 3685).
O13 hung session internal/controlrun/quiet_test.go; internal/reconcile/quiet_test.go; internal/hostops/activity_test.go Tests only (operator). A kill -STOP on Hold B at 17:47:21Z did not hold (ps read Ssl+ right after, and the session posted 3499 at 17:47:25), so no quiet stretch arose. The operator then skipped the live run (3521, 3524).
Stale index lock internal/session/adopt_integration_test.go TestCreateWorktreeRemovesAStaleIndexLockOnAdopt Tests only. The host reboot was not run (below).

Preparation (approved in 3253). devbox's tmux server (pid 2506755) and its pipe-pane loggers had started inside engine-server.service under the old build. They were moved into a transient scope with busctl … StartTransientUnit … PIDs, which killed nothing (3255). docs/recovery.md now documents this step.

Not run. The host reboot (row 12): the operator skipped it (3515, 3517) because devbox's root is on LUKS, so an unattended reboot may stop at the passphrase prompt with the server down. The reboot path rests on rows 8–11: a host with no tmux server read as one loss, and the unit coming back. An isolated engine instance was not used: the session tmux uses the default socket and every state path is under HOME, so an instance would need a separate HOME, which loses the harness and gh sign-ins, and it would not exercise the real unit or the second host.

Rulings

Ruling (risk: low): no new test; every objective already has its proof in ./dev test (table above).
Ruling (risk: low): the docs name busctl … StartTransientUnit with PIDs for moving a live tmux out of the unit; it ends no window, unlike the tmux kill-server that the tmux_unit reason names.
Operator answers followed: 3253 (moving devbox's tmux), 3261 (deploy with config edit and an execution credential), 3436 (operator-credential reads), 3446/3447/3458/3460 (rows 1 and 8), 3506 (the fleet question's "move"), 3680/3685 (the Telegram messages, host notices and fleet question confirmed), the pane authorization 3462 (unit stops, the cut-off, SIGSTOP), 3515 (skip the reboot), 3521/3524 (O13 tests-only, then row 13; 3521 also directed engine host resume mac with the operator credential).

Review

  • Fresh reviewer: Claude Code, claude-opus-5-5, a fresh session each round, build skill review mode. Round 1: CHANGES_REQUESTED (PR body: an ID-like label, the unconfirmed Telegram delivery, an uncited answer; all fixed). Round 2: CHANGES_REQUESTED (the Telegram delivery had no operator decision; the operator confirmed it, 3680/3685). Round 3: APPROVED, with one optional fix applied (check the unit with systemd-cgls, since tmux_unit reads the server pid alone). Round 4: CHANGES_REQUESTED (the second Mac kill was uncited by name; fixed above with 3481), with optional fixes applied (name the unit and pid to move, a restart ends the windows too, §1 points at §2, the Deviations line on the pane authorization). Round 5: CHANGES_REQUESTED (the Gates row cited the run on the previous head; it now cites the run on this head; and the O8 row overstated Hold C, reworded). Round 6: CHANGES_REQUESTED (the host resume was a state change with the operator credential, uncredited; it now cites 3521; and Hold C's later resume is stated), with its optional fixes applied (ps shows each pid's parent; what to do on tmux_unit_error). Round 7, on this head: APPROVED, no must-fix; its optional citation of the 16:56 upgrade (3412) applied to this body.
  • Declined findings: listing more preflight refusals in operator-setup.md (rounds 1 and 4): the text claims no completeness, the others print their own reason, and the doc is at 1709 of its 1710-word budget, so it would need a budget raise. Rewording "an unreachable or open host" (round 3): the same budget. A per-server scope name instead of engine-tmux.scope (round 4): with mode fail a clash refuses and ends nothing, and one move per unit is the case. "Runs inside" for "started inside" in recovery.md step 1 (round 5): both are true of the case it names, so the head was left as reviewed. Round 7's optional wording (a pid source for the tmux_unit_error case; "changes nothing" beside --dry-run): left, keeping the approved head.
  • Review hard: docs/recovery.md §2 "Run" step 1 (the busctl line must match systemd's StartTransientUnit signature, and the claim that it ends nothing); docs/operator-setup.md "Upgrading" (each refusal it names must be one of internal/upgrade/preflight.go's; the list is not complete).

Deviations

  • devbox's ~/.config/engine/config.toml [server] changed from url to host = "devbox" so the upgrade could run (3261). This is host config, not repo.
  • A temporary ~/.ssh/config on devbox (17:43:01–18:05:41Z) blocked ssh to the Mac for the cut-off, under the operator's pane authorization (3462). It was deleted after.
  • The card asks for an engine ask before each destructive run. Rows 1 and 8 had one each (3446/3447, 3458/3460). Rows 9–11, the cut-off and the SIGSTOP ran under one pane authorization from the operator instead (3462), after the permission hard stop it answered.
  • Follow-ups for the operator, not in this PR: the upgrade's preflight does not refuse while tmux_unit is reported; the Mac's setup stays OPEN at the Codex daemon step after each upgrade; the tmux_unit reason text (internal/hostops/tmuxunit.go) still recommends tmux kill-server, not the move; under umask 0077 two file-mode tests fail.

Harness and model: Claude Code, claude-opus-5-5.

🤖 Generated with Claude Code

https://claude.ai/code/session_012F3VVEvpwUs9kd61mNLrbv

dinoderek and others added 6 commits November 23, 2026 18:43
…of the unit

The upgrade refuses unless the caller's config.toml sets [server] host;
the docs said it ran from any host. A session tmux that started inside
the server's unit can be moved into its own scope with no window ended,
before an upgrade stops the unit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVEvpwUs9kd61mNLrbv
… in one place

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVEvpwUs9kd61mNLrbv
@dinoderek
dinoderek merged commit 82ea041 into main Nov 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant