Repository navigation
T61 — A stop racing a box's natural end gives one honest ending - #2863
mitodrummer merged 3 commits into
Conversation
When the host loop reaps a process while a kill from the daemon waits in its mailbox, report the end as requested, so the box is not ended as if its entrypoint returned on its own (BOX-038).
A stop that reads a box as running, then finds that the entrypoint returned first, answers that the box already exited, with its code. It no longer writes a second ending over the exited record. StopBox carries already_exited, and the stop span records the outcome.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none seen. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
This change conforms to line 499 of architecture.md. A box record keeps exactly one ending: stopped when a stop ended the box, exited when the entrypoint returned. A stop that the entrypoint beats now answers already_exited and does not write over the exited record. A queued daemon kill that loses the race to the reap is not recorded as the entrypoint's own exit. The design is silent on the new StopBox field and the stop span outcome field, and both are additive.
Ruled at c5818d3 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
|
/revise One remaining item from this task's own description. In crates/minimald/src/box_runtime.rs |
|
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 1 of 10 on a failed check suite: the coder changed nothing. Noop on purpose. The failed |
The step-error branch read requested from the absence of a stashed pty error. A kill that arrived after a pty error was then read as the entrypoint's own return. Record the kill in step and read requested from that (BOX-038).
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The compare from c5818d3f changes one value in the host loop. The value is now read from the kill itself, so a stashed pty error does not hide a daemon kill. The design says a stop ends a box as stopped, and only the entrypoint's own return is exited (architecture.md line 499). The change keeps that split and adds a test that fails on the earlier head. The PASS on c5818d3f stands for the rest of the change.
Ruled at cd720c6 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
|
Round 2 of 10 on a /revise note, pushed as
Verify A stop that loses the race to the entrypoint's return answers "already exited" with the code. A daemon kill is never recorded as the entrypoint's own exit: not when it loses the race to the reap, and now also not when it arrives after a pty error was stashed. Notes from the agent: Round 2 addresses the /revise note. Host::step now sets a new kill_requested field when it takes Message::Kill. The step-error branch in Host::mainloop sets requested from that field, not from pending.is_none(). The pty-error notification code is unchanged. step returns Err only on Kill or on a stashed pty error, so with no pty error the result is the same as before. New test: daemon_kill_racing_reap_is_not_a_natural_exit_after_pty_error stashes an EIO pty error, queues a kill, and asserts that exit.requested is true and that the reap is logged as a requested teardown. I also ran a_kill_tells_the_binding_nothing, cargo clippy -p minimald --all-targets and cargo fmt --check. All passed. I did not run just clippy-strict. |
There was a problem hiding this comment.
Reviewed at cd720c6. A stop that loses to a box's natural end answers already_exited with the code, additive on the wire, with the stop span recording the outcome. A daemon kill that loses the reap race (kill_queued) or arrives after a stashed pty error (kill_requested) is recorded as requested, never as the entrypoint's own exit. The shutdown-teardown message in that race is a ledger follow-up.
There was a problem hiding this comment.
Gate passes at cd720c6 except gate 8 (CodeRabbit skips bot PRs), which Karl overrode at this head. Queuing.
T61 — A stop racing a box's natural end gives one honest ending
slice: S2
kind: task
covers: BOX-013, BOX-038
size: S
est: 100 code, 140 tests
executor: agent
difficulty: known ground
model: strongest
diagnostics: daemon log names the race outcome (stopped, or already exited with code)
observability: stop span records outcome = stopped | already_exited
layers:
- daemon:
- crates/minimald/src/box_manager.rs: stop answers an already-exited box
- crates/minimald/src/box_manager/tests.rs: tests
- crates/minimald/src/rpc.rs: serve_stop_box answers already-exited
test: cargo nextest run -p minimald stop_racing_natural_end_answers_already_exited
- runtime:
- crates/minimald/src/box_runtime.rs: daemon kill losing the reap race is not a natural exit
- crates/minimald/src/box_runtime/tests.rs: tests
test: cargo nextest run -p minimald daemon_kill_racing_reap_is_not_a_natural_exit
- wire:
- crates/minimald-rpc/src/lib.rs: StopBox answer can say already exited
produces: none
consumes: none
proof: A stop that loses the race to the entrypoint's return answers "already exited" with the code, and a daemon kill that wins it is never recorded as the entrypoint's own exit.
depends on:
- blocked by #2401
Proof
Say a stop reads an until_complete box as running, and the entrypoint returns before the stop reaches the box. The box stays exited with its exit code and has one exited event. StopBox answers already_exited: true with that exit_code, and the daemon log and the stop span name the outcome. Say a kill from the daemon is queued when the host loop reaps the process. The loop reports the end as requested, so it is never recorded as the entrypoint's own exit.
Notes from the agent: Where a stop races the entrypoint inside the actor, the actor takes the queued stop first (biased select). That stop records the BOX-011 row 'stopped, exit code', and this task does not change it. The manager change covers the race where the actor ends the box before the stop reaches it. Before this change, get_session then started a fresh actor, and its stop wrote Stopped(AtDaemonStart) over the exited record. The stop now reads the record again after get_session and answers AlreadyExited without a dispatch. stop_box now returns StopAnswer. stop_box_with_grace (now #[cfg(test)]) keeps its StopEnding signature for the test callers in sftp.rs and box_actor/tests.rs, so those files are unchanged. It refuses an already-exited answer with InvalidInput. A stop of a box whose record was already exited before the stop read it is still refused as not running. A cfg(test) seam, stop_dispatch_seam in box_manager.rs, holds the stop between its read and its dispatch for the test. StopBoxResponse gains already_exited (serde default, skipped when false), so old clients and daemons interoperate. The minimald-rpc round-trip test now covers it. No printed text changed. The CLI does not print the StopBox answer. Extra runs: the minimald-rpc stop_box_request_round_trips test passed, and 70 minimald stop, reap and until_complete tests passed.
Tests
cargo nextest run -p minimald stop_racing_natural_end_answers_already_exitedcargo nextest run -p minimald daemon_kill_racing_reap_is_not_a_natural_exitVerify
min task run agent-verifypassed ([tasks.verify]).Closes #2862