Repository navigation
T6 — Resume a stopped box from its stored spec - #2744
Conversation
An attach to a stopped or exited box resumes it. The refusals run in order: a spec with no terminal, a running box that holds the name, a stored spec this daemon cannot start from, an upload in flight. Each leaves the record as it was. A resume sets the network settings and hooks switch from spec.json, sets the record to running, and writes a resumed event. Only on_attach runs. One box.resume span carries the outcome. The daemon now sets orphaned running records to stopped at start. Refs BOX-025, BOX-027, BOX-030, BOX-154.
Calling stop_orphaned_running_records at BoxManager::init stops every box at a restart. Nine restart tests expect a restart to keep running boxes live and route their names, two of them in box_manager/tests.rs. The flip must replace that behaviour in one change. Refs BOX-154.
…topped-box-from-its-stored-spec
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: every review thread resolved at @mitodrummer resolved the last thread, which releases the approval this review had withheld. Nothing to do. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 3 conditions · the full ruling
The resume conforms to line 495 of the architecture. The box restarts from its stored spec under the same id and name, and only on_attach runs. But a refused resume sends no exit status, so min session attach exits 255. Lines 359 and 487 say exit 2, and BOX-025 asks for the create code when the spec cannot be satisfied. C1 fixes this and adds the exit-code checks to the tests. C2 makes the name check refuse when it cannot read a record. C3 names gominimal/inbox#731 as the owner of the deferred BOX-154 flip.
Ruled at aa2f93c against gominimal/arch@109541a48c31 by claude-opus-5-5.
The resume set the record to running before the attach launched a host. A launch that failed left the box running with no processes. The attach now restores the state the box resumed from, and marks its name stopped, when the launch fails and leaves no host. The resumed event is written only after the launch succeeds.
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
The resume conforms to architecture line 495, and the compare fixes the failed launch: the record goes back to its ended state, and resumed waits for a host. The refusals do not send an exit code. The daemon closes the channel with no exit-status, so min session attach exits 255. Lines 359–360 give 2 for a name a running box holds or a box in the wrong state, and 3 for a bad Box Spec. C1 sends those codes and makes the tests assert them. C2 names gominimal/inbox#731 and the flip condition in the BOX-154 interim comment.
Ruled at 44461b6 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
A stopped session resumes with its files, id and name when a person attaches to it. If the launch fails during the attach, the session stays stopped, and the next attach resumes it. Notes from the agent: Revise round 1. The attach now splits into resume, attach_launch and finish_resume. finish_resume writes the resumed event only after the launch gives the box a host. When the launch fails and leaves no host, finish_resume sets the record back to the state it resumed from (it re-reads the record and calls set_state, so fields that the launch wrote stay) and marks the name stopped. A wedged host that the mint keeps in the slot (SessionBusy) counts as running, because its processes are alive. The box.resume span now covers the launch, and its outcome is resumed, refused or launch failed. The new test resume_launch_failure_keeps_stopped_state uses the existing mint_attach_seam. just clippy-strict and the whole-crate suite did not run. |
|
/revise Four changes on 44461b6. Arch C2 (BOX-154's owner) waits on a maintainer decision; leave 1. arch-review C1: each resume refusal carries the design's exit code. In crates/minimald/src/box_actor/attach.rs, 2. minimal-review MEDIUM, box_actor.rs:1270 3. minimal-review MEDIUM, box_actor.rs:1085 4. minimal-review LOW, crates/minimald/src/hooks.rs:65 Leave the PR body's |
|
/revise Arch C2 and minimal-review's BOX-154 thread (box_manager.rs:1399): switch BOX-154 on in this task, as the maintainer decided.
Update the PR body: BOX-154 is no longer a residual. Reply on the arch C2 thread and the box_manager.rs:1399 thread. Run the plan's test lines plus |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
A refused resume now ends the attach with exit status 2 (terminal, name) or 3 (stored spec). The connection sends it before the close. A failed resume launch writes back the whole record the resume read. The unused runs_on_resume predicate and HookEvent::ALL are removed.
The name check skipped a record it could not read, and that record can belong to a running box that holds the name. The resume now refuses with exit status 2. A record removed since the listing is still skipped.
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling
The resume conforms to architecture.md line 495 for BOX-025, BOX-027 and BOX-030. It restarts from the stored spec under the same id and name and records resumed. It refuses in the spec's order and leaves the state unchanged. A resume runs only the attach hooks. One edit remains. The new doc comment on stop_orphaned_running_records defers the BOX-154 flip to an unnamed task. Name gominimal/inbox#731 there, as C1 says. The flip itself is a residual on that issue.
Ruled at 0f2092f against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 2 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. Review threads the coder judged:
An attach to a stopped session resumes it with its files, id and name. A refused resume now ends the attach with exit status 2 (terminal or name) or 3 (stored spec), not 255. A resume whose launch fails leaves record.json byte-identical to what it was before. Notes from the agent: Item 1: AttachError::ResumeRefused(io::Error, u32) plus AttachError::exit_code(). connection.rs (outside the layers, asked for by arch) sends exit_status_request before close. Item 2: the resume already committed only after launch for the event, and rolled back the state on failure. With item 3 the rollback now writes back the whole pre-resume record (PendingResume.before), and the name is marked stopped again, so a failed resume leaves record, events and name as they were. resume_launch_failure_keeps_stopped_state now compares record.json bytes. Item 4: runs_on_resume and HookEvent::ALL are removed, so hooks.rs is identical to main. The finish log no longer claims which hooks ran. The test checks the real dispatch: on_activate does not run again. on_attach cannot be shown in a unit test because the mock launcher has no session leader (see the existing note in tests.rs). The session e2e covers it. Also fixed arch thread PRRT_kwDOPdfcxM6xcG5t: running_name_holder now fails the check on an unreadable record (a NotFound record is still skipped), and the resume refuses with exit 2. New test resume_refuses_when_another_record_is_unreadable. Per the /revise note, stop_orphaned_running_records and its comment are unchanged. just clippy-strict was not run. |
…topped-box-from-its-stored-spec
|
/revise Fix two tests that fail since 0f2092f (round 2), in the
Both cover a destroy racing a box coming up. Round 2 changed when a resume commits (launch first, then commit or roll back) and how a failed launch restores the record, so the likely cause is that path: a destroy that lands during the window now sees, or restores, a record the destroy already removed. Reproduce locally first. Then fix the code, not the tests: a box destroyed during the landing window or between enumeration and grant must stay destroyed and be released once, whether or not a resume is in flight. Don't weaken either assertion. Leave the PR body's |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
BOX-154: BoxManager::init now sets every running record with no process left to stopped, so the restart's resume no longer relaunches it. The next attach resumes it from its stored spec (BOX-025). A stopped box's actor no longer takes over a name another box routes, and a resume checks the name again after it writes running, so two resumes of boxes that share a name cannot both keep it. The restart tests, NET-129's included, now assert the stopped record and the resume on attach.
…topped-box-from-its-stored-spec
|
/revise Fix a regression the BOX-154 switch-on (b442f3d) causes in After a daemon restart, a session whose processes are gone now loads as Leave the PR body's |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
Round 3 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. Review threads the coder judged:
After a daemon restart, a session that was running reads stopped, with no exit code and no signal, and with an exited event. An attach to it resumes it with its files, its id, its name and its network settings. A plain stop followed by an attach does the same. Notes from the agent: Revise round 3. BOX-154 is now on. BoxManager::init calls stop_orphaned_running_records right after reap_unresumable_records, and the expect(dead_code) is gone. resume_active_sessions keeps its code, but at daemon start it no longer finds an orphaned running record: init already set each one stopped. It still destroys a run's box (NET-131) and still brings up a record that reads Active. The PR body must drop BOX-154 from the residuals. The runner writes the body, so I did not change it. New behaviour in box_actor.rs, which the rewritten tests found: (1) An ended box's actor that comes up for an RPC no longer registers its name when another box routes that name. Before, a refused resume of a same-named box took the route away from the running holder. A resume that passes registers the name if it is not registered. (2) The name check now runs a second time after the resume writes running. On a conflict the resume writes the record back and refuses. This is the fix for the foundry thread. Tests rewritten to the new behaviour (the maintainer accepted edits outside the layers in box_manager/tests.rs): a_restarted_daemon_routes_a_restored_name_once_an_attach_resumes_it, a_restarted_daemon_resumes_an_own_ip_box_on_attach_with_its_address, a_restored_session_that_fails_to_resume_does_not_stop_the_others, a_restored_hostname_collision_is_refused_on_resume, a_restored_session_sharing_another_sessions_registry_name_is_refused_on_resume, shared_address_holder_kept_when_boxes_resume_in_creation_order (was shared_address_holder_same_in_any_resume_order), shared_address_port_stays_with_the_box_that_bound_it_across_a_restart, resume_keeps_a_plain_session_stopped_beside_a_run_owned_one, res…[truncated] |
After a daemon restart a composed box reads stopped, and the Attached hook launch refused it at the Active status gate, so its destroy skipped the on_destroy hooks. Launch the hook-only host for an ended box without that gate. The record stays stopped and the shell waits at its start gate, so the entrypoint does not start.
|
Round 4 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. A stopped session resumes with its files, id and name. In addition, a session that a daemon restart left stopped now runs its on_destroy hook from its stored composition when a person destroys it, and its record and files are then removed. Notes from the agent: Cause of the native-daemon-e2e failure: after a restart the box reads stopped, and the destroy's hook launch uses the Attached phase. BoxActor::context (box_actor/setup.rs) refuses any status other than Active, so the launch failed and the hooks were skipped. The daemon log before the fix shows: 'launching the session to run its hooks: init of minimal context: session isn't attachable yet (status is Stopped, need Active ...)'. Fix, in box_actor.rs only: destroy_now calls a new launch_ended_box_for_destroy_hooks. For a stopped or exited box with destroy hooks it mints the hook-only host with LaunchPhase::Activating, which builds the context without the status gate. The record stays stopped (no resume, no resumed event). The for_hooks launch holds the shell at its start gate, so the entrypoint does not start. The hooks then run through the same run_session_hooks path, with the same environment and working directory. A failed or timed-out launch is logged and the hooks are skipped, so the destroy does not wait on a second failing launch. New unit test: box_actor::tests::on_destroy_runs_once_for_a_box_stopped_by_a_restart (compose, restart, assert stopped, destroy, assert the hook ran exactly once and the record is gone). Limit: the test harness's mock session_launcher (box_actor/launcher.rs) never calls context(), so this test also passed before the fix. It pins run-once and no-resume, but not the status gate. Making the mock apply the gate needs box_actor/launcher.rs, which is outside the layers. e2e: scripts/session-e2e.sh runs in this box, but no sandbox can start here: every launch dies with 'mount(... etc ...) => EPERM' (session_exec fails the same way). With the fix, the restart case's daemo…[truncated] |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 11 unresolved threads — minimal-foundry[bot] crates/minimald/src/box_actor.rs, minimal-arch[bot] crates/minimald/src/box_actor/attach.rs, minimal-arch[bot] crates/minimald/src/box_manager.rs, minimal-arch[bot] crates/minimald/src/box_manager.rs, minimal-foundry[bot] crates/minimald/src/box_actor.rs, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to line 495 of architecture.md. This head wires the daemon-start stop of orphaned running records into BoxManager::init. It stores stopped with no code and no signal, as line 495 and BOX-154 require. The second name check and the on_destroy launch for an ended box both fail closed. Neither one writes the record. No condition is open. Update the PR body, because it still says the BOX-154 call is reverted.
Ruled at 57d79c5 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
/revise One fix on 57d79c5, from minimal-review (crates/minimald/src/box_actor.rs ~1377, The name check and the write of Leave the PR body's |
The name check and the write of running were two steps, and each box has its own actor, so two stopped boxes that share a name could both resume. The manager's name check now claims the name for the resuming box. A later check for that name finds the claim and refuses with exit status 2. The resume releases the claim when it is refused or when its record reads running. This replaces the second name check, which could refuse both boxes.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare replaces the second name check with a name claim in the manager loop. Of two resumes that share a name, exactly one runs, and the other is refused with exit 2. This keeps a name unique among running boxes, as Addressing line 385 says. Each refusal path, the running write and Evict release the claim. The new test proves the rule. The PASS on 57d79c56 stands for the rest of the change.
Ruled at e4708e2 against gominimal/arch@109541a48c31 by claude-opus-5-5.
|
Round 5 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: something above needs a person before review. 1 thread was already answered in earlier rounds, with nothing new on it since. A stopped session resumes with its files, id and name. When two stopped sessions with the same name resume at the same time, exactly one runs, and the other is refused with exit status 2 and stays stopped. Notes from the agent: The plan's four actor test lines and resume_runs_only_on_attach_hook ran inside the single |
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @mitodrummer closed the last one. The review of e4708e201ea9 withheld this approval on the threads open then. Posted as a comment: the App cannot approve its own pull request; the check and the label carry it.
mitodrummer
left a comment
There was a problem hiding this comment.
Approved at e4708e2. Resume restarts a stopped PTY box from its stored spec and refuses with the design's exit codes: 2 for a name or terminal refusal, 3 for a stored-spec refusal. It commits only after a successful launch, and a failed launch restores the whole record. A name claim in the manager stops two same-named boxes from both resuming. BOX-154 is on: a restarted box with no process comes back stopped, resumes on attach, and still runs on_destroy when destroyed.
T6 — Resume a stopped box from its stored spec
slice: S0
kind: task
covers: BOX-025, BOX-027, BOX-030
size: L
est: 380 code, 400 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: daemon log names deciding refusal
observability: one span per resume with its outcome
layers:
- actor:
- crates/minimald/src/box_actor.rs: resume; terminal, name, spec, upload, then volume
- crates/minimald/src/box_actor/attach.rs: attach resumes stopped box
- crates/minimald/src/box_actor/tests.rs: tests
test: cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name
test: cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state
test: cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box
test: cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state
- runtime:
- crates/minimald/src/box_runtime/launcher.rs: restarts from stored spec
- crates/minimald/src/hooks.rs: only the attach hook
- crates/minimald/src/box_manager.rs: resumed event; upload refusal after spec check; call stop_orphaned_running_records at BoxManager::init (BOX-154, deferred from T3 #2733)
test: cargo nextest run -p minimald resume_runs_only_on_attach_hook
test: cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited
produces: none
consumes:
- crates/mfile/src/spec.rs
- crates/boxes/src/events.rs
proof: A stopped session resumes with its files, id and name.
depends on:
- blocked by #2390
- blocked by #2388
- blocked by #2389
Proof
A session stopped with the daemon's stop resumes on the next
min session attach. It keeps its workspace files, its id and its name. Its record goes back to running and its events gain aresumedevent. Its network settings and hooks switch come from the spec stored at create. A resume that cannot happen prints why, and the session stays stopped or exited.Notes from the agent: Not done: the layer note 'call stop_orphaned_running_records at BoxManager::init (BOX-154)'. I wired it and ran the whole minimald suite once. Nine restart tests then failed, because they expect a restart to keep running boxes live and route their names (resume_active_sessions, T119/NET behaviour). Two of them are in crates/minimald/src/box_manager/tests.rs, which is outside the layers. Those nine are a_restarted_daemon_launches_a_restored_own_ip_boxs_host_on_resume, a_restarted_daemon_routes_restored_sessions_names_without_an_rpc, a_restored_hostname_collision_is_logged_and_skipped, a_restored_session_sharing_another_sessions_registry_name_is_skipped, a_restored_session_that_fails_to_resume_does_not_stop_the_others, shared_address_holder_same_in_any_resume_order, shared_address_port_stays_with_the_box_that_bound_it_across_a_restart, box_manager::tests::resume_teardown_keeps_the_route_of_a_same_named_box and box_manager::tests::resume_still_resumes_a_plain_session_beside_a_run_owned_one. I reverted the call in a second commit, so the function stays unwired with its dead_code expect. The BOX-154 flip needs a task that also changes resume_active_sessions and those tests. After the revert, a filtered run of every restart, resume and stop test passed (65 tests). Design: a stopped or exited record now gets an actor (BoxActor::run hosts it with no host, and marks its name stopped). BoxActor::resume runs on attach. The checks run in this order: PTY, name, stored spec, workspace upload, volume. No volumes exist in this tree (BVOL is absent), so the volume step is a comment. The layer n…[truncated]
Tests
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_namecargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_statecargo nextest run -p minimald resume_refuses_when_name_held_by_running_boxcargo nextest run -p minimald resume_non_pty_box_refuses_keeps_statecargo nextest run -p minimald resume_runs_only_on_attach_hookcargo nextest run -p minimald pty_box_resumes_from_stopped_and_exitedVerify
min task run agent-verifypassed ([tasks.verify]).Base
The base branch moved while the coder worked; it was merged in before the tests ran.
Closes #2393
Maintainer accepted the out-of-layer edits:
crates/minimald/src/connection.rs(resume refusal exit codes, arch C1) and the restart and resume test updates inbox_manager/tests.rsand the NET restart tests (BOX-154 switch-on), 2026-10-29.