Repository navigation
fix(minimal): T58 — A restart ends an attach with a line that names the restart - #3559
mitodrummer merged 3 commits into
Conversation
A 254 against a box that runs again, and whose count of ends rose while the attach ran, prints the restarted line in place of the line for another terminal (BCLI-068).
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
/revise Head An unread count names no cause. When the daemon reports 254 and the box reads
|
|
Reviewed: no findings; approval withheld, 5 threads unresolved at APPROVE withheld: 5 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes/attach.rs, minimal-arch[bot] crates/minimal/src/tests.rs:11217, minimal-arch[bot] crates/minimal/src/cmd/boxes/attach.rs, minimal-arch[bot] crates/minimal/src/tests.rs:11217, minimal-arch[bot] crates/minimal/src/tests.rs:11355. Resolving the last thread releases the approval on this head. Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none seen. |
| // BCLI-068: a box that runs again after the host ended the attach, and | ||
| // whose count of ends rose, was restarted, not taken by another terminal. | ||
| let restarted = code == DAEMON_ENDED_ATTACH | ||
| && matches!(&after, BoxAfterAttach::Listed(entry) if entry.state == "running") | ||
| && ends_show_restart(ends_before, box_end_count(&target).await); |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in box_attach_ending
The restart line depends on the settled read after a 254 returning a running box. box_after_attach_settled returns at the first read that is not running. If that read lands between the stop and the start of a restart, the box reads stopped and the attach prints "was stopped", not the restart line. The PR body admits this gap and says no test proves it closed. The restarted expression is also inline in the command, so no test runs it. The test calls only ends_show_restart and box_attach_ending. Move the expression into a pure function and test it, or read the count before you trust the box state.
What the reviewer checked
attach.rs:1553 let restarted = code == DAEMON_ENDED_ATTACH && matches!(&after, BoxAfterAttach::Listed(entry) if entry.state == "running") && ends_show_restart(ends_before, box_end_count(&target).await);
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/boxes/attach.rs
Lines: 1553-1557
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
The restart line depends on the settled read after a 254 returning a running box. `box_after_attach_settled` returns at the first read that is not running. If that read lands between the stop and the start of a restart, the box reads stopped and the attach prints "was stopped", not the restart line. The PR body admits this gap and says no test proves it closed. The `restarted` expression is also inline in the command, so no test runs it. The test calls only `ends_show_restart` and `box_attach_ending`. Move the expression into a pure function and test it, or read the count before you trust the box state.
First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.
👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.
There was a problem hiding this comment.
Addressed in 71b09cf6f79f: Moved the inline expression into the pure function attach_restart(code, after, before, ends_after), and covered it in attach_ended_by_restart_names_restart_exit254. The case where the box reads stopped in the middle of a restart is now pinned in attach_ended_by_restart_names_restart_exit254_through_the_host, and it is listed as a residual.
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The restart line conforms to the design. A restart stops the box, and line 492 of architecture.md lists a stop as a cause of 254. The task's proof leg did not run, and the new test checks only the pure functions. Nothing exercises the restarted expression in box_attach_on_hosts against a real restart. C1 adds that test through the in-process AttachHost, as #3546 did for a stop. Also run exec_run_attach_and_task_run_share_the_commands_trace again. This change adds an events read to every attach on a running box.
Ruled at b7b93c1 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| /// count that rose is a restart. A count that did not rise, or that the | ||
| /// host did not give, keeps the line for another terminal. | ||
| #[test] | ||
| fn attach_ended_by_restart_names_restart_exit254() { |
There was a problem hiding this comment.
C1 · This test checks ends_show_restart and box_attach_ending only. It does not drive a restart through a host. Add an async test beside it with AttachHost and cmd::restart_box_on_hosts, and assert the 254 and the restart line (architecture.md line 492).
There was a problem hiding this comment.
Addressed in 71b09cf6f79f: Added attach_ended_by_restart_names_restart_exit254_through_the_host. It joins box_attach_on_hosts with cmd::restart_box_on_hosts on a harness host, and asserts 254 and the restarted line.
A 254 against a running box whose count of ends was not read, before or after the attach, prints the host line, not the takeover line.
|
Round 1 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. Attached to a running box, Notes from the agent: ends_show_restart now returns a three-way BoxRestart (Restarted, NotRestarted, Unread), and box_attach_ending takes it. Unread prints the line that BoxAfterAttach::Unread prints. EndsBefore::Unread (the host did not give the box's state at the start) also counts as Unread. EndsBefore::Ended (the box was stopped or exited when the attach started) keeps the takeover line, as before. cargo clippy -p minimal --all-targets is clean. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The new unread case is correct. An unread count of ends now prints the line for a host that ended the attach, and not the takeover line. That conforms to architecture.md lines 376 and 492. C1 from the last ruling is still open. No test drives a real min box restart through the host against a live attach. Add the host-level test in C1. If the restart can read stopped, pin that case and name its issue in the PR body.
Ruled at a2f89eb against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| // BCLI-068: a box that runs again after the host ended the attach, and | ||
| // whose count of ends rose, was restarted, not taken by another terminal. | ||
| // A count that was not read names no cause. | ||
| let restarted = if code == DAEMON_ENDED_ATTACH |
There was a problem hiding this comment.
C1 · No test reaches this expression or the second box_end_count read with a real restart. The pure test calls ends_show_restart and box_attach_ending only. Add attach_ended_by_restart_names_restart_exit254_through_the_host, as C1 says.
There was a problem hiding this comment.
Addressed in 71b09cf6f79f: The new host test reaches attach_restart and the second box_end_count read after a real RestartBox raises the count of ends.
| /// terminal. A count that the host did not give names no cause, so the | ||
| /// line names the host that ended the attach. | ||
| #[test] | ||
| fn attach_ended_by_restart_names_restart_exit254() { |
There was a problem hiding this comment.
C1 · This test proves the pure functions only. Add a #[tokio::test] beside it that joins box_attach_on_hosts with cmd::restart_box_on_hosts on an AttachHost. Assert 254 and the restarted line. Model it on attach_ended_from_other_side_notice_exit254_before_the_record.
There was a problem hiding this comment.
Addressed in 71b09cf6f79f: Added the #[tokio::test] beside the unit test, modelled on attach_ended_from_other_side_notice_exit254_before_the_record. It asserts 254 and the restarted line, and also the stop line when the read lands between the stop and the start.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 4 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes/attach.rs, minimal-arch[bot] crates/minimal/src/tests.rs:11217, minimal-arch[bot] crates/minimal/src/cmd/boxes/attach.rs:1556, minimal-arch[bot] crates/minimal/src/tests.rs:11217. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/revise Head 1. C1: a test that drives a real restart through a host.
2. LOW: the restart decision is a pure function. 3. Threads. Reply on the three C1 threads and on the LOW thread with this round's commit. |
The restart decision for an ended attach is now the pure function attach_restart, which the unit test covers. A new test joins the attach with min box restart on a harness host. It pins the restarted line when the box runs again, and the stop line when the command reads the box between the restart's stop and its start (BCLI-068).
|
Round 2 of 10 on a /revise note, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
Attached to a running box, a min box restart of it from another terminal ends the attach with exit 254 and "Detached: web was restarted. Run min box attach web to attach again." A new test drives this through a harness host with the real RestartBox RPC. Notes from the agent: Residuals for the PR body: (1) The harness daemon in the minimal crate has no package store. minimald starts a box again only through its cfg(test) mock launcher, which this crate cannot reach. So the real RestartBox in the new test stops the box and raises its count of ends, and then its start half fails with 'did not start again'. The test does the start half itself: it writes back the running record.json, the way the other tests here already write to the state dir. The end-to-end restart step stays with T56 (#3525). (2) A restart can show |
|
The runtime will not revise this pull request again on its own: the diff is +318/-13 (331 lines), past 3x the plan's estimate of 100 lines (est: 30 code, 70 tests, as #3547 reads now), at round 2 (the last trigger was a /revise note). A person decides now. Remove |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The new test meets the main part of C1. It drives a real restart through a host and pins the restarted line and the stopped case. The second part of C1 is still open. The PR body names the restart window as a known gap, but it names no issue for it. The body also says the window is "probably closed". The daemon writes stopped before running, and ShowBox reads the record outside the box actor, so the window is open. Make the edit in C1 to the PR body. Then the change conforms to architecture.md line 492.
Ruled at 71b09cf against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| /// the start half fails and leaves the box stopped. The test does the | ||
| /// start half itself: it writes back the record of the running box. | ||
| /// | ||
| /// A restart stops the box and then starts it. When the command reads the |
There was a problem hiding this comment.
C1 · This comment states the restart window, and the second case pins it. The PR body still names no issue for the window, and it calls the window "probably closed". Open an issue for it, name the URL in the PR body, and remove that sentence.
There was a problem hiding this comment.
Addressed. The restart window is gominimal/inbox#1277, named under Residuals in the PR body. The "probably closed" sentence is replaced: the window is open, and the host-level test pins that case.
|
/arch-review |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 5 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes/attach.rs, minimal-arch[bot] crates/minimal/src/tests.rs:11217, minimal-arch[bot] crates/minimal/src/cmd/boxes/attach.rs, minimal-arch[bot] crates/minimal/src/tests.rs:11217, minimal-arch[bot] crates/minimal/src/tests.rs:11355. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling
The change conforms to the design. A restart is a stop and then a start (architecture.md line 471). Line 492 binds an attach that the daemon ends to exit 254 and one stderr line. The change keeps 254 and names the restart. An unread count gives the host line, so no cause is guessed. One leg is open: no live min box restart ran against a real attach. C1 puts that step in T56 (#3525). The read window that prints the stop line is filed as gominimal/inbox#1277. The verify run is red in an otel test. Find out if this change causes that failure before you leave draft.
Ruled at 71b09cf against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| /// box between the two, it reads `stopped` and prints the line for a stop. | ||
| /// The second case pins that, with the box left stopped. | ||
| #[tokio::test] | ||
| async fn attach_ended_by_restart_names_restart_exit254_through_the_host() { |
There was a problem hiding this comment.
C1 · This test drives the restart through the harness host. The test writes the running record back itself, because the harness cannot start the box again. Line 492 binds the live attach. Add a step under T56 (#3525) to scripts/session-e2e.sh that runs a real min box restart <box> against an attach, and assert exit 254 and the restarted line.
There was a problem hiding this comment.
Done. T56 (#3525) has the step: attach with min session start, run min box restart <box> from a second shell, and assert exit 254 and Detached: <box> was restarted. Run min box attach <box> to attach again. The step fails on "was stopped" or "another terminal attached".
T58 — A restart ends an attach with a line that names the restart
slice: S3
kind: task
covers: BCLI-068
size: S
est: 30 code, 70 tests
executor: agent
difficulty: routine
model: standard
diagnostics: none new
observability: none new
layers:
- client:
- crates/minimal/src/cmd/boxes/attach.rs: the attach reads the count of ends of a running box too, and a 254 against a running box whose count rose prints the restarted line
- crates/minimal/src/tests.rs:
attach_ended_by_restart_names_restart_exit254, with a running box whose count rises, one whose count does not, and an unread counttest: cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254
produces: none
consumes: none
proof: Attached to a running box,
min box restart <box>from another terminal ends the attach with exit 254 and "Detached: was restarted. Run min box attach to attach again."depends on:
- blocked by #3526
Proof
A person is attached to a running box and runs
min box restart <box>from another terminal. The attach now ends with exit 254 and the line "Detached: was restarted. Run min box attach to attach again." The old line "another terminal attached to " no longer appears for a restart. The unit test pins the line and the count logic. No live restart ran on this box.Notes from the agent: The attach now reads the count of ends of a running box too, as EndsBefore::Running(Option). After a 254, the attach reads the count again if the box reads running. A count that rose selects the restart line. A count that did not rise, or that was not read, keeps the takeover line. The test checks the pure functions ends_show_restart and box_attach_ending. It does not drive a daemon restart end to end. Known gap: the settled read after a 254 returns at the first read that is not running. If that read falls between the stop and the start of the restart, the box reads stopped and the line says "was stopped". This change does not cover that window. The window is open: the daemon writes
stoppedbeforerunning, andShowBoxreads the record outside the box actor. The host-level test pins that case. The existing resumed_box_copies_at_next_end_only test changed only for the new variant shape. The attach_ended_from_other_side tests and clippy -p minimal --all-targets also passed.Tests
cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254Verify
min task run agent-verifyexited 100, so this PR is a draft.Residuals:
Closes #3547