Repository navigation
fix: T62 — A restart ends an attach with the restart line on every host - #3661
mitodrummer merged 8 commits into
Conversation
The stop half of min box restart announces BoxEnd::Restart to an attached binding and writes stopped_by = "restart" on its exited event, before the start runs. A client that reads the box stopped between the stop and the start can then name the restart (BCLI-068).
An attach that a restart ends can read the box between the restart's stop and its start. The box reads stopped then. The client now waits briefly for that end's exited event, and when it carries the restart ending reason, prints the restart line with exit 254 (BCLI-068).
The attach-end proof starts a box whose entry sets lifetime = "until_stopped", attaches to it, runs min box restart from another terminal, and checks exit 254 and one restart line, with no retry.
…ends-an-attach-with-the-restart-line-o
|
Important Review skippedBot user detected. Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.
|
|
Undrafted. agent-verify's one failure is |
|
/arch-review |
|
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/minimald/src/box_actor/host.rs:2419, minimal-arch[bot] scripts/session-e2e.sh:2350, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:2433, minimal-arch[bot] scripts/session-e2e.sh:2343. 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. |
| pub(crate) struct EndsAfter { | ||
| /// How many times the box ended: the count of its `exited` events. | ||
| pub(crate) count: u64, | ||
| /// Whether the last `exited` event is the stop half of a restart. | ||
| pub(crate) last_by_restart: bool, | ||
| } | ||
|
|
||
| /// The key of an `exited` event's `data` that names the stop half of a | ||
| /// restart, and its value. The daemon writes them (`minimald`'s | ||
| /// `STOPPED_BY` and `STOPPED_BY_RESTART`). |
There was a problem hiding this comment.
LOW · correctness · confidence 0.55 · in ends_of
The client copies the stopped_by key and the restart value from minimald as separate literals (daemon: STOPPED_BY in box_actor/host.rs). No test ties the two together. If one side changes, a restart that is read as stopped prints the stop line again, and only the e2e step catches it. Put the key and value in a crate that both sides use, for example boxes::events. ends_of also repeats the Exited count in box_ends in cmd/boxes/wait.rs.
What the reviewer checked
attach.rs:36 const STOPPED_BY: &str = "stopped_by"; host.rs:2425 pub(crate) const STOPPED_BY: &str = "stopped_by";
Hand this to an agent
Act on a code-review finding.
File: crates/minimal/src/cmd/boxes/attach.rs
Lines: 1633-1642
Category: correctness
Severity: low (reviewer confidence 0.55)
Finding:
The client copies the `stopped_by` key and the `restart` value from `minimald` as separate literals (daemon: `STOPPED_BY` in `box_actor/host.rs`). No test ties the two together. If one side changes, a restart that is read as `stopped` prints the stop line again, and only the e2e step catches it. Put the key and value in a crate that both sides use, for example `boxes::events`. `ends_of` also repeats the `Exited` count in `box_ends` in `cmd/boxes/wait.rs`.
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 70297bfcee74: restart_records_restart_reason_before_start now asserts the literal ("stopped_by", "restart") that the min test also pins, so a rename on either side fails a unit test. I did not move the constants to boxes::events or merge the count with box_ends in wait.rs, because both files are outside this task's layers.
…ends-an-attach-with-the-restart-line-o
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 2 conditions · the full ruling
The change conforms to the design. A restart is a stop and then a start (L471), so a 254 with the restart line is correct (L376). The exited event keeps reason = "stopped" (L382, L500). The new stopped_by = "restart" key is a new field on the min/v1/event stream, and no spec names it. C1 amends BOX-178 to name it. The e2e restart step was not run, and C2 asks for that run at this head.
Ruled at e2e3305 against gominimal/arch@8b824707cde6 by claude-opus-5-5.
| /// gives it for every stopped record, and a plain stop writes no such key. | ||
| /// A client that reads the box `stopped` after its attach ended reads this | ||
| /// key, so it names the restart before the restart's start runs. | ||
| pub(crate) const STOPPED_BY: &str = "stopped_by"; |
There was a problem hiding this comment.
C1 · This key is a new field on the min/v1/event stream. The design lists what exited carries (architecture.md L382), and BOX-178 points to BOX-013's event. Amend BOX-178 to name stopped_by = "restart", or file that spec amendment and link it from the PR body.
There was a problem hiding this comment.
Filed as gominimal/inbox#1297 for BOX, which owns spec 29, to amend BOX-178. Linked from the PR body.
| kill "$AE_PID" 2>/dev/null || true | ||
| ae_fail | ||
| } | ||
| attach_end_wait restart "$aer_name" |
There was a problem hiding this comment.
C2 · This step is the task's proof leg, and it was not run (no /dev/kvm). Run just e2e at this head on a KVM host or the ci-linux-kvm lane. Record the result in the PR body. Do not add a retry.
The daemon test read its own constants, so a rename passed unseen. It now checks the literal text that the min client test also pins.
…ends-an-attach-with-the-restart-line-o # Conflicts: # crates/minimald/src/box_runtime/tests.rs
|
Round 1 of 10 on the runtime's review findings, pushed as Resolved conflicts in:
Verify Outside the task's
Converted to a draft: verify timed out after 1800s. Review threads the coder judged:
On a VM host, a person attached to a box with lifetime = "until_stopped" runs min box restart from another terminal. The attach ends with exit 254 and the restart line on the first try, and the just e2e restart-while-attached step checks this with no retry. This round adds a unit-test tie between the daemon and the client on the restart reason text. Notes from the agent: Revise round 1. The daemon test now asserts the literal wire text ("stopped_by", "restart"), and the min client test already builds its events from that same text. A rename on either side now fails a unit test, not only the e2e step. I did not move the constants into the boxes crate, because crates/boxes is outside this task's layers. The repeated Exited count in box_ends in crates/minimal/src/cmd/boxes/wait.rs is also outside the layers and is unchanged. I ran the minimald test before a rustfmt-only commit and did not run it again after that commit. I did not run just e2e on this box. |
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 2 conditions · the full ruling
The compare changes only test pins and a comment, so BCLI-068 still conforms as it did at e2e33053. Two conditions are still open. C1: the BOX-178 amendment now has a filed issue, but the task header still says observability: none new. Change that line to name the new stopped_by = "restart" key on the exited event. C2: the just e2e restart step did not run. Run it on a KVM host, and add its first-try result to the Tests table.
Ruled at 70297bf against gominimal/arch@8b824707cde6 by claude-opus-5-5.
| ) -> boxes::events::EventData { | ||
| let mut data = stopped_event_data(ending); | ||
| if end == box_runtime::BoxEnd::Restart { | ||
| data.insert(STOPPED_BY.to_string(), STOPPED_BY_RESTART.into()); |
There was a problem hiding this comment.
C1 · This line adds the stopped_by = "restart" key to the exited event on the min/v1/event stream. The task header says observability: none new, and that is not correct. Change the header line to name this key. Keep the link to gominimal/inbox#1297 for the BOX-178 amendment.
There was a problem hiding this comment.
Fixed in the task header (#3635): observability: now names the exited event's stopped_by = "restart" key, and keeps the link to gominimal/inbox#1297 for the BOX-178 amendment.
| ae_fail | ||
| } | ||
| aer_sid="$(printf '%s\n' "$out" | tail -n1 | tr -d '\r')" | ||
| attach_end_start restart "$aer_name" |
There was a problem hiding this comment.
C2 · This restart step did not run at this head (no /dev/kvm). Run just e2e on a KVM host or the ci-linux-kvm lane. Add the result to the Tests table. The step must pass on its first try with exit 254 and one restart line. Do not add a retry.
|
Undrafted again. agent-verify's failure is still only the known flake #3483, and the merge of main resolved its conflict. Arch C1: the task header now names the new key. Arch C2: I add the KVM |
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/minimald/src/box_actor/host.rs:2419, minimal-arch[bot] scripts/session-e2e.sh:2350, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:2433, minimal-arch[bot] scripts/session-e2e.sh:2343. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/arch-review |
There was a problem hiding this comment.
arch-review: PASS_WITH_CONDITIONS · 1 condition · the full ruling
The restart path conforms to the design. A restart is a stop and then a start (architecture.md line 471). So exit 254 with a line that names the restart is in lines 376 and 492. The record keeps reason = "stopped" (line 500). The new exited key stopped_by = "restart" is not a field that line 382 or BOX-178 names. C1 makes BOX name the key, through gominimal/inbox#1297. The change can merge with C1 open.
Ruled at 70297bf against gominimal/arch@8b824707cde6 by claude-opus-5-5.
| /// gives it for every stopped record, and a plain stop writes no such key. | ||
| /// A client that reads the box `stopped` after its attach ended reads this | ||
| /// key, so it names the restart before the restart's start runs. | ||
| pub(crate) const STOPPED_BY: &str = "stopped_by"; |
There was a problem hiding this comment.
C1 · This key is new on the exited event. Line 382 of the design lists reason with exit_code or signal, and BOX-178 does not name this key. Make BOX name stopped_by = "restart" (gominimal/inbox#1297). Then define it once in boxes::events.
There was a problem hiding this comment.
Deferred as the ruling allows, to gominimal/inbox#1297. After BOX amends BOX-178 to name the key, the key becomes one constant in boxes::events next to exec_data, and both copies (here and on the other side of the wire) go.
| /// them, so the tests on both sides pin the same wire text: | ||
| /// `restart_records_restart_reason_before_start` in `minimald` and | ||
| /// `attach_ended_by_restart_names_restart_exit254` here. | ||
| const STOPPED_BY: &str = "stopped_by"; |
There was a problem hiding this comment.
C1 · This is a second copy of the daemon's wire key. When BOX names the key (C1), use the one constant in boxes::events, next to exec_data, and remove this copy.
There was a problem hiding this comment.
Deferred as the ruling allows, to gominimal/inbox#1297. After BOX amends BOX-178 to name the key, the key becomes one constant in boxes::events next to exec_data, and both copies (here and on the other side of the wire) go.
Conflict in crates/minimald/src/box_actor/host.rs: main (#3661) made stop_box_inner announce the box's end, a stop or a restart, through `announce_end(end)`. Kept that and this branch's stop of the task containers after it, so a restart stops them too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA
T62 — A restart ends an attach with the restart line on every host
slice: S3
kind: task
covers: BCLI-068
size: M
est: 150 code, 250 tests
executor: agent
difficulty: involved
model: strongest
diagnostics: none new
observability: none new
layers:
- daemon:
- crates/minimald/src/box_runtime/binding.rs:
BoxEnd::Restart- crates/minimald/src/box_actor/host.rs:
restart_namedannouncesBoxEnd::Restart, and its stop half records the ending reasonrestart- crates/minimald/src/box_runtime/tests.rs:
restart_records_restart_reason_before_starttest: cargo nextest run -p minimald restart_records_restart_reason_before_start
- client:
- crates/minimal/src/cmd/boxes/attach.rs: the restart line is chosen for a box that reads
stoppedwith the ending reasonrestart- crates/minimal/src/tests.rs: the restart-decision unit test covers the
stopped-with-restartread- scripts/session-e2e.sh: the restart-while-attached step, with no retry
test: cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254
produces: none
consumes: none
proof: On a VM host, attached to a box whose entry sets
lifetime = "until_stopped",min box restart <box>from another terminal ends the attach with exit 254 and the restart line, on the first try, injust e2e.depends on:
- blocked by #3525
Proof
just e2eat head70297bfc, passed on all three lanes. The restart step passed on its first try on both VM lanes, loggingrestart while attached: exit 254, one line that names the restart:On a VM host, a person attaches to a box whose entry sets lifetime = "until_stopped" and runs
min box restart <box>from another terminal. The attach ends with exit 254 and one line, 'Detached: was restarted. Run min box attach to attach again.' The line is right on the first try, also when the attach reads the box between the restart's stop and its start. The new restart step injust e2e(attach_ends_on_stop) checks this once, with no retry. I could not run that e2e step on this box (no /dev/kvm). The in-process harness test attach_ended_by_restart_names_restart_exit254_through_the_host shows the same line for a box that reads stopped after the restart's stop.Notes from the agent: Out of layers: crates/minimald/src/box_actor.rs, one line.
restart_namedis in box_actor.rs, not in host.rs as the layer says. Its stop call now calls the newstop_box_for_restartin host.rs. host.rs carries the rest:stop_box_as(end, ...)announcesBoxEnd::Restartto the binding and writes the reason on the exited event.The ending reason is a new
exitedevent data key,stopped_by = "restart". The event'sreasonkey and the record's reason staystopped. The plan said 'records the ending reason restart'. I did not putrestartin the recordreason, for three reasons. BOX-011 permits onlystoppedfor a stopped record.RecordState::from_storedrefuses any other value, so the record becomes unreadable. That change also needs the boxes crate, which is outside the layers. Also, the existing test restart_start_failure_leaves_box_stopped_with_its_stop_recorded pins reason = "stopped" on a restart's exited event. If BOX wants a named key or a value in its table, a spec amendment must define it.Client: when a 254 attach reads the box
stoppedand the box ran before the attach, the client waits up to 2 s for the new exited event. The stop writes that event just after the stopped record. If the last exited event carries stopped_by = restart, t…[truncated]Tests
cargo nextest run -p minimald restart_records_restart_reason_before_startcargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254Verify
min task run agent-verifyexited 100, so this PR is a draft.Base
The base branch moved while the coder worked; it was merged in before the tests ran.
Residuals
exitedevent's newstopped_by = "restart"key is not yet named by a spec. BOX amends BOX-178 to name it: gominimal/inbox#1297 (arch C1).Out of scope
These files are outside the task's
layers:, so this PR is a draft:crates/minimald/src/box_actor.rsCloses #3635