8000 T24 — End a box created for a run when the run ends, from the daemon's side by minimal-foundry[bot] · Pull Request #1680 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

T24 — End a box created for a run when the run ends, from the daemon's side - #1680

Merged
norrietaylor merged 1 commit into
mainfrom
agent/1619-end-a-box-created-for-a-run-when-the-run-ends-fr
Sep 25, 2026
Merged

norrietaylor merged 1 commit into
mainfrom
agent/1619-end-a-box-created-for-a-run-when-the-run-ends-fr

Conversation

@minimal-foundry
Copy link
Copy Markdown
Contributor

T24 — End a box created for a run when the run ends, from the daemon's side

slice: S5
kind: task
covers: NET-131
size: M
est: 150 code, 180 tests
executor: agent
difficulty: needs care
model: standard
diagnostics: the bundle's daemon log tail carries the end of each run box with its exit code
observability: one info log line when a run box ends, naming the session, the exec and the exit code
layers:
- rpc:
- crates/minimald-rpc/src/exec.rs: the task-run exec request carries a flag saying the run owns its box
test: cargo nextest run -p minimald run_box_ends_when_its_run_ends
- daemon:
- crates/minimald/src/exec.rs: after the task-run bridge returns and the exit status is sent, destroys the session when the flag is set
test: cargo nextest run -p minimald run_box_survives_when_run_keeps_it
- cli:
- crates/minimal/src/task.rs: sets the flag and drops the client-side destroy after a normal run, keeping the finalize-failure and interrupt paths
test: cargo nextest run -p minimal task_run_leaves_destroy_to_daemon
produces: none
consumes: none
proof: Run min task run, kill the client mid-run, and the session is gone once the task exits; a normal run ends its session the same way with no client-side destroy.

Proof

A min task run session now ends from the daemon's side of the exec's exit: the task-run request carries an owns-box flag, and once the task's exit status is on the wire the daemon destroys the session through the DestroySession path and logs one info line (session, run, exit code) — so a client killed mid-run leaves the session gone once the task exits, a normal run ends its box with no client-side destroy, and --keep (flag withheld) or min session run (unflagged form) still keep the box for whoever holds it.

Notes from the agent: One commit; the three layers are one protocol change. Touches outside the layers are compile-forced by the TaskRun variant gaining a field: cmd/session.rs sets owns_box=false (semantic no-op — min session run keeps the old behavior), tests.rs and the ignored minvmd integration test update constructions. Wire form is min://task/run --owns-box <task>; the unflagged payload is byte-for-byte the legacy form so an older client's request parses unchanged, and the marker is read only when a task name follows it, so a task literally named --owns-box still round-trips. After the change, a Ctrl-C mid-run now races the daemon-side destroy: the interrupt handler's destroy wins, and the daemon's own end_run_box logs a warn when it finds the session already gone — the box ends either way. The exec-open-failure path keeps the client-side destroy (no run started, so no owns-box destroy is coming); the finalize-failure and interrupt paths are untouched. The rpc-layer wire tests (47) and the exec e2e module (10) also pass. The VM lanes (just e2e/just test-vm, the ignored minvmd integration) were not run — no VM in this sandbox; the killed-client-mid-run proof rests on the in-process minimald e2e plus the existing lost-exec-client behavior, and the session e2e would confirm it against a real microVM.

Tests

line exit tail
cargo nextest run -p minimald run_box_ends_when_its_run_ends 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-d3e3... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/24280/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/24280/tree/crates/args) C
cargo nextest run -p minimald run_box_survives_when_run_keeps_it 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-9975... Compiling stdlib v0.0.20 (/home/runner/.local/state/minimal/sessions/4bf15/tree/crates/stdlib) Compiling version v0.6.0 (/home/runner/.local/state/minimal/sessions/4bf15/tree/crate
cargo nextest run -p minimal task_run_leaves_destroy_to_daemon 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-c89f... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/6e65c/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/6e65c/tree/crates/args) C

Verify

min task run agent-verify passed ([tasks.verify]).

Out of scope

These files are outside the task's layers:, so this PR is a draft:

  • crates/minimal/src/cmd/session.rs
  • crates/minimal/src/tests.rs
  • crates/minvmd/tests/minimald_session_integration.rs

Closes #1619

A box created for a non-detached run ended only when its client
destroyed it after the exec returned, so a min task run client killed
mid-run stranded its session: the abandoned-launch reap covers only
un-finalized sessions and there is no idle stop to catch one (NET-131).

The task-run exec request now carries an owns-box flag, encoded as a
--owns-box marker in front of the task name; the unflagged payload is
byte-for-byte the legacy form, so an older client's request parses
exactly as before. After the task-run bridge returns and the exit
status is on the wire, the daemon destroys the session through the
DestroySession RPC's own path and logs one info line naming the
session, the run and the exit code — the line a diagnostic bundle's
daemon-log tail reads the end of a run box from.

min task run sets the flag and drops its client-side destroy after a
run that bridged; the finalize-failure path, the interrupt handler,
and --keep (which withholds the flag and keeps the session) are
unchanged. min session run keeps sending the unflagged form: its box
is an attachable session someone else keeps.
@coderabbitai
coderabbitai Bot commented Sep 24, 2026 •
Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

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

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5fba6ad1-c3d5-47ec-8a85-b81ddf66e99d

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

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

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

Reviewed against the T24 plan block on #1437. Taking it out of draft: the single commit is authored work, not a budget snapshot; the draft came from three files outside the block's layers, and all three are constructor updates forced by the new TaskRun { owns_box } variant (crates/minimal/src/cmd/session.rs, crates/minimal/src/tests.rs, crates/minvmd/tests/minimald_session_integration.rs), semantic no-ops.

Plan compliance.

  • rpc: TaskRun { task, owns_box } with the --owns-box payload marker (crates/minimald-rpc/src/exec.rs:216-267); the unflagged form is byte-identical to the legacy wire.
  • daemon: ExecTask::run returns the exit code and end_run_box runs after the bridge when the flag is set (crates/minimald/src/exec.rs:341-442); it is the serve_destroy_session path (get_record then delete_session) and logs run box ended with session, task and exit.
  • cli: flag set unless --keep, post-run client destroy removed, the exec-open-failure and interrupt paths keep their client-side destroy (crates/minimal/src/task.rs:54-109, 356-440, 832).
  • Killed-client claim holds by construction: handle_exec is a detached spawn, bridge_one ends on write failure, and ExecTask::run ignores the eof/exit/close errors, so the daemon-side end fires either way. Not exercised by a test; the PR says so.

Test lines. All three present and at exit 0 in the task status; confirmed again in the CI tests job (run 35974482067): run_box_ends_when_its_run_ends, run_box_survives_when_run_keeps_it, task_run_leaves_destroy_to_daemon, plus the wire round-trip. The last of the three proves the flag encoding only; the removal of the client destroy is asserted by the deleted code rather than a test. Acceptable for a unit test.

Non-blocking.

  • set_global_default(...).unwrap() in the new daemon test (crates/minimald/src/exec.rs:2725) relies on nextest's one-process-per-test; a second global subscriber under plain cargo test would panic.
  • Version skew: a new client against an old daemon sends --owns-box build, the old daemon runs task "--owns-box build", the run fails and neither side destroys. Client and guest payload ship together, so this is the stale-VM case only. Worth a line in the PR body.

Approving; merge waits on the runtime review and CodeRabbit now that it is out of draft.

@minimal-foundry
minimal-foundry Bot commented Sep 25, 2026 •
Copy link
Copy Markdown
Contributor Author

Approved: no findings at 2ba6b0c8cb31.

Nothing to do.

Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it.

Clobber: none: git log on all touched files shows a single feature commit over main with no reverted fix.

8000

@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 — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Sep 25, 2026
@norrietaylor
norrietaylor merged commit 29a7f5d into main Sep 25, 2026
33 checks passed
@norrietaylor
norrietaylor deleted the agent/1619-end-a-box-created-for-a-run-when-the-run-ends-fr branch September 25, 2026 00:28
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.

T24 — End a box created for a run when the run ends, from the daemon's side

1 participant

0