8000 fix(minimal): T58 — A restart ends an attach with a line that names the restart by minimal-foundry[bot] · Pull Request #3559 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minimal): T58 — A restart ends an attach with a line that names the restart - #3559

Merged
mitodrummer merged 3 commits into
mainfrom
agent/3547-a-restart-ends-an-attach-with-a-line-that-names
Nov 19, 2026
Merged

mitodrummer merged 3 commits into
mainfrom
agent/3547-a-restart-ends-an-attach-with-a-line-that-names

Conversation

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

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 count
test: 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 stopped before running, and ShowBox reads 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

line exit tail
cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer 8000 version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling ot v0.0.1 (/workbench/crates/ot)

Verify

min task run agent-verify exited 100, so this PR is a draft.

 {
                "parent_span_id": "88c0ac1cc4fa0e4e",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "27fed2cc497fe80c",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "27fed2cc497fe80c",
                "queued_behind": "0",
                "span_id": "485e338a4136a1f0",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "88c0ac1cc4fa0e4e",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "9b17db71ed24feab",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "9b17db71ed24feab",
                "queued_behind": "0",
                "span_id": "5a2804c6671f6917",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "9b17db71ed24feab",
                "queued_behind": "0",
                "span_id": "f2c477cac4dd8a34",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "f2c477cac4dd8a34",
                "span_id": "722de6815b7956ad",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "f2c477cac4dd8a34",
                "queued_behind": "0",
                "span_id": "30a1ae7cdebd3016",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 
────────────
     Summary [  89.143s] 1195 tests run: 1194 passed, 1 failed, 2 skipped
        FAIL [  13.138s] (1195/1195) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Residuals:

Closes #3547

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).
@coderabbitai
coderabbitai Bot commented Nov 18, 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: 98f8878d-48a2-433a-8d9f-9e3ebde9d6fe

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

@agent-137
Copy link
Copy Markdown
Member

/revise

Head b7b93c11. One change, from T58's plan (#3547). Change nothing else.

An unread count names no cause. When the daemon reports 254 and the box reads running, but the count of ends before or after the attach was not read, the attach must not print "another terminal attached". That guesses a cause. Print the line that BoxAfterAttach::Unread prints today: Detached: host <host> ended the attach to <box>. Keep exit 254.

  • In crates/minimal/src/tests.rs, attach_ended_by_restart_names_restart_exit254 covers three cases: a count that rose gives the restart line, a count that did not rise gives the takeover line, and an unread count gives the host line.
  • Rename the test to attach_ended_by_restart_names_restart_exit254 if it has another name, so T58's test line runs it.

@agent-137
agent-137 requested a review from a team as a code owner November 18, 2026 20:44
@minimal-foundry
minimal-foundry Bot commented Nov 18, 2026 •
Copy link
Copy Markdown
8000
Contributor Author

Reviewed: no findings; approval withheld, 5 threads unresolved at 71b09cf6f79f.

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.

@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/minimal/src/cmd/boxes/attach.rs Outdated
Comment on lines +1553 to +1557
// 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);
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.

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.

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.

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.

@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: 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() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

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.
@minimal-foundry
Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on a /revise note, pushed as a2f89ebc35e5.

line exit tail
cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "2cd486fdfa09859e",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "14f0390c0313186b",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "14f0390c0313186b",
                "queued_behind": "0",
                "span_id": "5883e950ba73f5a7",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "2cd486fdfa09859e",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "7f2126c6f09e4622",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "7f2126c6f09e4622",
                "queued_behind": "0",
                "span_id": "4372966b86b1352a",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "7f2126c6f09e4622",
                "queued_behind": "0",
                "span_id": "d13b74266caf6fc6",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "d13b74266caf6fc6",
                "span_id": "fdf299471df9f4dd",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "d13b74266caf6fc6",
                "queued_behind": "0",
                "span_id": "8d00bc3da5c0bb30",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 
────────────
     Summary [  86.983s] 1195 tests run: 1194 passed, 1 failed, 2 skipped
        FAIL [  13.081s] (1195/1195) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Converted to a draft: something above needs a person before review.

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." When the count of ends before or after the attach is not read, the attach ends with exit 254 and "Detached: host ended the attach to ." It does not guess another terminal.

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.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft November 18, 2026 21:06
@agent-137
agent-137 marked this pull request as ready for review November 18, 2026 21:07
@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: 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.

Comment thread crates/minimal/src/cmd/boxes/attach.rs Outdated
// 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

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() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

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.

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

@agent-137
Copy link
Copy Markdown
Member

/revise

Head a2f89ebc. This round answers arch C1 and minimal-review's LOW finding. Change nothing else.

1. C1: a test that drives a real restart through a host.
Add a #[tokio::test] in crates/minimal/src/tests.rs, beside attach_ended_by_restart_names_restart_exit254. Model it on attach_ended_from_other_side_notice_exit254_before_the_record. Join box_attach_on_hosts with cmd::restart_box_on_hosts on an AttachHost, and assert exit 254 and Detached: <box> was restarted. Run min box attach <box> to attach again.

2. LOW: the restart decision is a pure function.
Move the inline restarted expression (crates/minimal/src/cmd/boxes/attach.rs, about line 1553) into a pure function that takes the code, the settled read and the two counts, and cover it in the unit test.

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).
@minimal-foundry
Copy link
Copy Markdown
Contributor Author

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

line exit tail
cargo nextest run -p minimal attach_ended_by_restart_names_restart_exit254 0 warning: unknown fields in task runtime-implement-test-0: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in box runtime-implement-test-0-1... Compiling paths v0.0.1 (/workbench/crates/paths) Compiling args v0.0.1 (/workbench/crates/args

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "d44dd255f4d5f2c2",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "0a1430fc842c9e65",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "0a1430fc842c9e65",
                "queued_behind": "0",
                "span_id": "cb9e4c7399479304",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "d44dd255f4d5f2c2",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "2e4d9ef6587793aa",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "2e4d9ef6587793aa",
                "queued_behind": "0",
                "span_id": "6f49a1b8cae09060",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "2e4d9ef6587793aa",
                "queued_behind": "0",
                "span_id": "2e1949d4f4d8ce89",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "2e1949d4f4d8ce89",
                "span_id": "377c08a9cfb0c3e3",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "2e1949d4f4d8ce89",
                "queued_behind": "0",
                "span_id": "8a0a2384d7a5a213",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
    ]
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

  Cancelling due to test failure: 
────────────
     Summary [  91.669s] 1196 tests run: 1195 passed, 1 failed, 2 skipped
        FAIL [  13.156s] (1196/1196) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — crates/minimal/src/cmd/boxes/attach.rs: 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_
  • 👍 valid — crates/minimal/src/tests.rs:11217: 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.
  • 👍 valid — crates/minimal/src/cmd/boxes/attach.rs: The new host test reaches attach_restart and the second box_end_count read after a real RestartBox raises the count of ends.
  • 👍 valid — crates/minimal/src/tests.rs:11217: 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.

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 stopped to the settled read. box_after_attach_settled returns at the first read that is not running, and a real start takes time after the stop. When that happens the attach prints "Detached: web was stopped.", not the restart line. The second case of the new test pins this. Closing that gap needs a change to the settled read, which this round's note excluded. cargo clippy -p minimal --all-targets is clean. I did not run just clippy-strict.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft November 18, 2026 21:46
@minimal-foundry minimal-foundry Bot added the needs-human An agent handed off; a human must act, then clear this label. Set by defer and handoffs. label Nov 18, 2026
@minimal-foundry
Copy link
Copy Markdown
Contributor Author

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 needs-human from this pull request to let /revise <note> or the automatic rounds resume, or finish #3547 by hand.

@agent-137
agent-137 marked this pull request as ready for review November 18, 2026 21:46
@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: 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

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.

@agent-137
Copy link
Copy Markdown
Member

/arch-review

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

@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_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() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

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

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

Approved.

@mitodrummer
mitodrummer added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 359a34c Nov 19, 2026
41 checks passed
@mitodrummer
mitodrummer deleted the agent/3547-a-restart-ends-an-attach-with-a-line-that-names branch November 19, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human An agent handed off; a human must act, then clear this label. Set by defer and handoffs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T58 — A restart ends an attach with a line that names the restart

2 participants

0