Skip to content

T6 — Resume a stopped box from its stored spec - #2744

Merged
mitodrummer merged 11 commits into
mainfrom
agent/2393-resume-a-stopped-box-from-its-stored-spec
Oct 29, 2026
Merged

mitodrummer merged 11 commits into
mainfrom
agent/2393-resume-a-stopped-box-from-its-stored-spec

Conversation

@minimal-foundry

@minimal-foundry minimal-foundry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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 a resumed event. 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

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-5f22... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling args v0.0.1 (/workbench/crates/args) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-4bf0... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-e6ca... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-9a46... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-7f4a... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-9284... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify

min task run agent-verify passed ([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 in box_manager/tests.rs and the NET restart tests (BOX-154 switch-on), 2026-10-29.

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.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 96628759-8778-4fff-8c0a-ca346a9b093e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry

minimal-foundry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Approved: every review thread resolved at e4708e201ea9.

@mitodrummer resolved the last thread, which releases the approval this review had withheld.

Nothing to do.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/minimald/src/box_actor.rs Resolved

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/minimald/src/box_actor/attach.rs Resolved
Comment thread crates/minimald/src/box_manager.rs Resolved
Comment thread crates/minimald/src/box_manager.rs Resolved
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.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 3 findings, 3 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/minimald/src/box_actor.rs Resolved
Comment thread crates/minimald/src/hooks.rs Resolved
Comment thread crates/minimald/src/box_manager.rs Resolved

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/minimald/src/box_actor.rs Resolved
Comment thread crates/minimald/src/box_actor/attach.rs Resolved
Comment thread crates/minimald/src/box_actor/tests.rs Resolved
Comment thread crates/minimald/src/box_manager.rs Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on the runtime's review findings, pushed as 44461b63fdeb.

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-7f3f... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-4162... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-a8a8... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-7be3... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-185b... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-5b60... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👍 valid — crates/minimald/src/box_actor.rs:1270: A failed launch after the resume now puts the record back in its stopped or exited state and marks the name stopped. The resumed event is written only after the launch succeeds. The test resume_launch_failure_keeps_stopped_state covers it.

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.

@mitodrummer

Copy link
Copy Markdown
Member

/revise Four changes on 44461b6. Arch C2 (BOX-154's owner) waits on a maintainer decision; leave stop_orphaned_running_records and its comment as they are in this round.

1. arch-review C1: each resume refusal carries the design's exit code. In crates/minimald/src/box_actor/attach.rs, AttachError::ResumeRefused carries an exit code beside its io::Error: 2 for the terminal refusal and the name refusal, 3 for every stored-spec refusal (unreadable spec, wrong version, invalid network settings, unenforceable declaration). Set it in the refused closure of BoxActor::resume_ended (crates/minimald/src/box_actor.rs) and add AttachError::exit_code() -> Option<u32>. In crates/minimald/src/connection.rs, where session_handle.attach(...) returns Err(e), call hnd.exit_status_request(id, code) after the data write and before close when e.exit_code() is Some(code). In crates/minimald/src/box_actor/tests.rs, make attach_and_echo return the ChannelMsg::ExitStatus it sees and make assert_resume_refused assert the code: 2 in resume_refuses_when_name_held_by_running_box and resume_non_pty_box_refuses_keeps_state, 3 in resume_refuses_unsatisfiable_spec_keeps_state. connection.rs is outside the layers; arch asked for it.

2. minimal-review MEDIUM, box_actor.rs:1270 resume_ended: don't commit a resume before it launches. resume() writes the record as running, emits resumed and marks the name running before the attach launches anything, and the attach can still fail after that (e.g. host_row_lost). Either launch first and commit after the launch succeeds, or roll the commit back on a later failure. A failed resume must leave the record, events and name as they were.

3. minimal-review MEDIUM, box_actor.rs:1085 finish_resume: a failed launch restores the whole record. The restore sets only the state back to from, but resume_ended also wrote the network mode, policy and hooks switch from the stored spec. Restore every field it changed (keep the pre-resume record and write it back), and test that a failed launch leaves the record byte-identical.

4. minimal-review LOW, crates/minimald/src/hooks.rs:65 runs_on_resume. It gates no hook; only a log field and a test use it, so the log can claim only on_attach ran while the real dispatch did something else. Either make the real hook dispatch use it on resume, or remove it and log what the dispatch actually ran.

Leave the PR body's ## Residuals section as it is. Reply on each thread. Run the plan's test lines plus cargo nextest run -p minimald resume_.

@mitodrummer

Copy link
Copy Markdown
Member

/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.

  1. Call stop_orphaned_running_records from BoxManager::init, beside reap_unresumable_records, and remove its expect(dead_code).
  2. Change BoxManager::resume_active_sessions so it no longer relaunches a running record whose processes are gone. After a daemon restart, such a box comes back stopped (BOX-154: no code, no signal) and is resumed on its next attach through this task's resume path (BOX-025). A record whose processes really are still alive (if any path can have that) keeps its current handling.
  3. Update the restart tests that expect a relaunch, including NET-129's and NET-138's tests and the resume_* tests in box_manager and box_actor, so they assert the new behaviour: after a restart the record is stopped, and an attach resumes it with its network settings, ports and name intact. The maintainer accepts edits to those test files outside the layers.
  4. Add a test: restart the daemon with a running record and no process, then assert the record is stopped with no code and no signal and a stopped/exited event, and that attaching resumes it.

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 cargo nextest run -p minimald restart_ resume_ and the NET restart tests by name.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #2393. Your note is kept and goes into the next round here, which starts when that coder finishes.

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.

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/minimald/src/box_manager.rs Resolved

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

Comment thread crates/minimald/src/box_actor.rs Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 2 of 10 on a /revise note, pushed as 0f2092fa499f.

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-bfdc... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-8db2... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-4cfb... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-b0a4... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-aa23... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-50e8... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify min task run agent-verify passed.

Outside the task's layers::

  • crates/minimald/src/connection.rs

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — crates/minimald/src/box_actor/attach.rs: ResumeRefused now carries an exit status (2 terminal/name, 3 stored spec), and connection.rs sends it with exit_status_request before close.
  • 👍 valid — crates/minimald/src/box_manager.rs: running_name_holder now returns an error for a record it cannot read (NotFound is still skipped), and the resume refuses with exit 2 and the record unchanged. Test: resume_refuses_when_another_record_is_unreadable.
  • 👎 invalid — crates/minimald/src/box_manager.rs:1399: Not changed this round: the /revise note holds stop_orphaned_running_records and its comment as they are until a maintainer decides who owns BOX-154.
  • 👍 valid — crates/minimald/src/box_actor.rs: PendingResume keeps the record resume read, and finish_resume writes it back whole on a failed launch. The launch-failure test compares record.json bytes.
  • 👍 valid — PRRT_kwDOPdfcxM6xcPXt: Removed runs_on_resume and HookEvent::ALL and the hooks log field. The test checks the real dispatch: on_activate does not run again on resume. (not posted on the thread: not an open thread on the pull request)
  • 👎 invalid — PRRT_kwDOPdfcxM6xcPX1: Not changed this round: the /revise note holds the BOX-154 start-time call for a maintainer decision on its owner. (not posted on the thread: not an open thread on the pull request)
  • 👍 valid — crates/minimald/src/box_actor.rs: The refused closure in resume_ended takes the exit status: 2 for the terminal and name refusals, 3 for every stored-spec refusal.
  • 👍 valid — crates/minimald/src/box_actor/attach.rs: Added the u32 to ResumeRefused, AttachError::exit_code(), and the exit_status_request call before close in connection.rs.
  • 👍 valid — crates/minimald/src/box_actor/tests.rs:13450: attach_and_echo returns the ExitStatus it sees. assert_resume_refused asserts 2 for the name and terminal tests and 3 for the spec test.
  • 👎 invalid — crates/minimald/src/box_manager.rs:1395: Not changed this round: the /revise note leaves stop_orphaned_running_records and its comment as they are until a maintainer decides the BOX-154 owner.

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.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft October 29, 2026 16:54
@mitodrummer

Copy link
Copy Markdown
Member

/revise Fix two tests that fail since 0f2092f (round 2), in the tests lane:

  • minimald box_actor::tests::a_box_destroyed_inside_the_landing_window_is_not_resurrected
  • minimald box_actor::tests::a_box_destroyed_between_enumeration_and_grant_is_released_once

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 ## Residuals section as it is. Run the plan's test lines plus cargo nextest run -p minimald a_box_destroyed resume_.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #2393. Your note is kept and goes into the next round here, which starts when that coder finishes.

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.
@mitodrummer

Copy link
Copy Markdown
Member

/revise Fix a regression the BOX-154 switch-on (b442f3d) causes in native-daemon-e2e: on_destroy did not run for a session composed by a previous daemon.

After a daemon restart, a session whose processes are gone now loads as stopped and no actor hosts it. Destroying it then skips its on_destroy hook, which the restart e2e asserts runs for a session a previous daemon composed. Make destroying an ended box run its on_destroy hook from the stored composition, the same way the live path does, without restarting the box's entrypoint: the hook runs, then the record and files are removed. Keep the hook's existing environment and working directory. Add a unit test: compose a box, restart the daemon so it's stopped, destroy it, and assert on_destroy ran once. Check the e2e's other restart steps against the new stopped-after-restart behaviour too.

Leave the PR body's ## Residuals section as it is. Run the plan's test lines plus cargo nextest run -p minimald on_destroy restart_ resume_, and scripts/session-e2e.sh for the restart steps if your sandbox can run it.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #2393. Your note is kept and goes into the next round here, which starts when that coder finishes.

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.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 3 of 10 on a /revise note, pushed as b442f3d402d1.

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-ab37... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-b6d7... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-97da... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-0984... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-6dbd... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-fb11... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify min task run agent-verify passed.

Outside the task's layers::

  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/connection.rs

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — crates/minimald/src/box_manager.rs: The interim is gone. BoxManager::init calls stop_orphaned_running_records beside reap_unresumable_records, and the expect(dead_code) is removed. resume_active_sessions no longer relaunches an orphaned running record, and the restart tests now assert stopped and resume on attach.
  • 👍 valid — crates/minimald/src/box_actor.rs:1302: resume_ended now checks the name again after it writes running. On a conflict it writes the record back and refuses with exit 2, so at most one of two racing resumes keeps the name. Also, a stopped box's actor no longer takes over a name another box routes.
  • 👍 valid — crates/minimald/src/box_manager.rs: Done as the maintainer decided: BoxManager::init now calls stop_orphaned_running_records, and resume_active_sessions no longer relaunches an orphaned running record. The interim comment and its expect(dead_code) are removed.
  • 👍 valid — crates/minimald/src/box_manager.rs: The deferred flip landed in this pull request, so it has no owner to name now. The interim comment and the expect reason are gone, and init calls stop_orphaned_running_records.

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.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 4 of 10 on a /revise note, pushed as 57d79c56b3bb.

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-2595... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-2078... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-6a92... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-aba1... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-e44a... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-6a90... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify min task run agent-verify passed.

Outside the task's layers::

  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/connection.rs

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]

@mitodrummer
mitodrummer marked this pull request as ready for review October 29, 2026 18:55

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mitodrummer

Copy link
Copy Markdown
Member

/revise One fix on 57d79c5, from minimal-review (crates/minimald/src/box_actor.rs ~1377, resume_ended).

The name check and the write of running aren't atomic. Two stopped boxes with the same name can both pass running_name_holder, because neither record is running yet, and each box has its own actor, so both then write running and mark the name running, and two running boxes hold one name (BOX-005). Make the check reserve the name: have the manager's RunningNameHolder handler record a pending claim (box id, name) that later checks for the same name treat as held, and have the resume release it on failure and convert it on success. Alternatively, serialize resumes per name through the manager. Add a test that starts two concurrent resumes of two stopped boxes with the same name: exactly one runs, and the other is refused with exit code 2 and keeps its stopped record. Reply on the thread.

Leave the PR body's ## Residuals section as it is. Run the plan's test lines plus cargo nextest run -p minimald resume_.

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.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 1 unresolved thread — minimal-foundry[bot] crates/minimald/src/box_actor.rs:1410. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 5 of 10 on a /revise note, pushed as e4708e201ea9.

line exit tail
cargo nextest run -p minimald resume_restarts_from_stored_spec_same_id_and_name 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-98db... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling ot v0.0.1 (/workbench/crates/ot) Compiling args v0.0.1 (/workbench/crates/args) Compiling client-config v0.0.1 (/wo
cargo nextest run -p minimald resume_refuses_unsatisfiable_spec_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-18b6... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_refuses_when_name_held_by_running_box 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-7429... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_non_pty_box_refuses_keeps_state 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-cf50... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald resume_runs_only_on_attach_hook 0 Applying loadouts: default Running task runtime-implement-test-4 in session task-runtime-implement-test-4-f471... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.
cargo nextest run -p minimald pty_box_resumes_from_stopped_and_exited 0 Applying loadouts: default Running task runtime-implement-test-5 in session task-runtime-implement-test-5-fc8c... Compiling stdlib v0.0.22 (/workbench/crates/stdlib) Compiling version v0.8.0 (/workbench/crates/version) Compiling decode v0.0.1 (/workbench/crates/decode) Compiling mlog v0.

Verify min task run agent-verify passed.

Outside the task's layers::

  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/connection.rs

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 cargo nextest run -p minimald resume_ run that the directive asked for. They were not run one at a time. The manager's RunningNameHolder handler now claims the name (box id, name) when no running record holds it. A later check for the same name finds the claim. It refuses with exit status 2 and the text "Session <id> is resuming now with the name <name>. Attach again when that resume ends." The resume releases its claim through the new ReleaseNameClaim message after it writes running or is refused. A check that times out also releases the claim. Evict drops the claim of an actor that ended. This replaces the earlier second name check after the write, because two racing resumes could both fail it and both be refused. The running-holder message did not change. The PR body's Residuals section did not change.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft October 29, 2026 19:44

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 29, 2026
@mitodrummer
mitodrummer marked this pull request as ready for review October 29, 2026 19:55

@mitodrummer mitodrummer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mitodrummer
mitodrummer added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit a811980 Oct 29, 2026
36 checks passed
@mitodrummer
mitodrummer deleted the agent/2393-resume-a-stopped-box-from-its-stored-spec branch October 29, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T6 — Resume a stopped box from its stored spec

1 participant