8000 T61 — A stop racing a box's natural end gives one honest ending by minimal-foundry[bot] · Pull Request #2863 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

T61 — A stop racing a box's natural end gives one honest ending - #2863

Merged
mitodrummer merged 3 commits into
mainfrom
agent/2862-a-stop-racing-a-box-s-natural-end-gives-one-hone
Nov 3, 2026
Merged

mitodrummer merged 3 commits into
mainfrom
agent/2862-a-stop-racing-a-box-s-natural-end-gives-one-hone

Conversation

@minimal-foundry
Copy link
Copy Markdown
Contributor

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

line exit tail
cargo nextest run -p minimald stop_racing_natural_end_answers_already_exited 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-cbaa... 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 daemon_kill_racing_reap_is_not_a_natural_exit 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-cd85... 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]).

Closes #2862

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.
@coderabbitai
coderabbitai Bot commented Nov 3, 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: 55253e72-ee28-43bc-9977-eea396927cda

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@minimal-foundry
minimal-foundry Bot commented Nov 3, 2026 •
Copy link
Copy Markdown
Contributor Author

Reviewed: 1 finding, none blocking at cd720c602649.

Address the comments on the diff.

Clobber: none seen.

@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

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.

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

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

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 3, 2026
@mitodrummer
Copy link
Copy Markdown
Member

/revise One remaining item from this task's own description. In crates/minimald/src/box_runtime.rs Host::run, the step-error branch (~1502) still sets requested = pending.is_none(). When a pty error was already stashed and step errs because of a queued Message::Kill (a destroy or a daemon shutdown with no Stop), the kill is read as the entrypoint returning on its own. Make step (or this branch) report whether the error came from a Kill, for example by returning a distinct error or recording the kill, and set requested from that rather than from pending. Keep the pty-error notification behaviour as it is. Add a test: a Kill that arrives after a pty error was stashed is recorded as requested, and the box is not ended as exited by its entrypoint. Touch nothing else.

@minimal-foundry
Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #2862. 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 1 of 10 on a failed check suite: the coder changed nothing. Noop on purpose. The failed tests job log excerpt does not name the failing test: it stops at test 1167 of 5057, in the decode crate, and the rest is cleanup. ci-linux-native-success only aggregates that failure. I could not reproduce a failure in any crate that this change reaches. minimald, minimald-rpc, minimal, minimal-client and minvmd all pass, minimald and the last two under --profile ci. Stress runs of the new race tests and all stop, exit and reap tests pass. clippy with -D warnings and fmt are clean. origin/main has not moved since the branch base f6fcbab. I did not run the whole workspace suite, because no test line names it. The next step is to re-run the tests job, or to read its junit summary to find the failing test name. If that name is in a crate this change touches, a new round can fix it.

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).
@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_runtime.rs Resolved
@minimal-foundry minimal-foundry Bot removed the review:approved minimal-review approved the current head label Nov 3, 2026
@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 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.

@minimal-foundry
Copy link
Copy Markdown
Contributor Author

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

line exit tail
cargo nextest run -p minimald stop_racing_natural_end_answers_already_exited 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-21e8... 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 daemon_kill_racing_reap_is_not_a_natural_exit 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-6f38... 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.

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.

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

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.

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

Gate passes at cd720c6 except gate 8 (CodeRabbit skips bot PRs), which Karl overrode at this head. Queuing.

@mitodrummer
mitodrummer added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 687d2f3 Nov 3, 2026
38 of 40 checks passed
@mitodrummer
mitodrummer deleted the agent/2862-a-stop-racing-a-box-s-natural-end-gives-one-hone branch November 3, 2026 18:49
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.

T61 — A stop racing a box's natural end gives one honest ending

1 participant

0