Repository navigation
fix(minimald): a box records a started event when its entrypoint first starts and when a resume - #3568
Conversation
A box wrote its started event only on a restart. The exec and attach launches now write it through one shared helper, and a resume writes it after its resumed event (BOX-040).
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Reviewed: no findings; approval withheld, 4 threads unresolved at APPROVE withheld: 4 unresolved threads — minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, minimal-foundry[bot] crates/minimald/src/box_actor.rs:1520, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, norrietaylor crates/minimald/src/box_actor/host.rs:1765. 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. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The change writes started on the exec launch, the attach mint, the resume and the restart, in the correct owner. One start of the entrypoint still writes no event. An attach that keeps a hooks host releases its shell at the start gate, and nothing writes started. architecture.md lists started as a lifecycle event, and line 500 says running means the entrypoint started. The PR body calls this a known gap but names no issue. Make the edit in C1, or file the gap as a named residual as C1 says.
Outside the diff
crates/minimald/src/box_actor/attach.rs:388: C1 · The kept hooks host starts its shell at this attach (box_runtime.rsline 2499). Afterh.attachreturnsOk, callrecord_started("attach")once for this host, unless a resume is in flight (C1).
Ruled at 5f5272f against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| // BOX-040: a new host started the box's entrypoint. On a resume, | ||
| // `finish_resume` writes `started` after `resumed`. | ||
| if !self.resume_in_flight { | ||
| self.record_started("attach").await; |
There was a problem hiding this comment.
C1 · This write covers only a host that mint_session_host launches. An attach that keeps a HostOrigin::Hooks host releases the shell at its start gate, and no started event is written. Write started once in the Some((h, _)) arm of attach_launch() in attach.rs, as C1 says.
There was a problem hiding this comment.
Disputed — not addressed: The gap is real, but it is outside this task's layers. A kept hook host starts its shell in the Some((h, _)) arm of attach_launch in crates/minimald/src/box_actor/attach.rs. This task names only box_actor.rs, host.rs and tests.rs, and its host.rs line excludes a hooks host. A follow-up task must cover that arm.
| // BOX-040: the resume started the entrypoint again, so `started` | ||
| // follows `resumed`. A launch that failed beside a host that was | ||
| // already there started nothing. | ||
| if launched.is_ok() { | ||
| self.record_started("resume").await; | ||
| } |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in finish_resume
finish_resume gates started on launched.is_ok(). But mint_session_host stores the new host and returns SessionBusy when the attach to it times out. On a resume that leaves a running host, so has_host is true and minted_host is false. The success path then records resumed with no started. The comment says a failed launch beside a host started nothing, and that is not true here. A first attach in the same case does record started (host.rs mint_session_host). Gate on whether the attach launch minted a host instead of on the launch result.
What the reviewer checked
box_actor.rs:
if launched.is_ok() { self.record_started("resume").await; }vs host.rs:Err(HostAttachError::Timeout) => Err(AttachError::SessionBusy)then the host is stored andrecord_started("attach")runs only when!resume_in_flight.
Hand this to an agent
Act on a code-review finding.
File: crates/minimald/src/box_actor.rs
Lines: 1467-1472
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
`finish_resume` gates `started` on `launched.is_ok()`. But `mint_session_host` stores the new host and returns `SessionBusy` when the attach to it times out. On a resume that leaves a running host, so `has_host` is true and `minted_host` is false. The success path then records `resumed` with no `started`. The comment says a failed launch beside a host started nothing, and that is not true here. A first attach in the same case does record `started` (host.rs mint_session_host). Gate on whether the attach launch minted a host instead of on the launch result.
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 d8c233cd63d6: mint_session_host now sets resume_attach_minted during a resume, and finish_resume writes started when the launch succeeded or the attach minted a host. Added resumed_session_box_records_started_when_attach_wedges.
An attach that mints a host during a resume and then times out stores that host, so its entrypoint started. finish_resume now writes started after resumed in that case too (BOX-040).
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
min box events on a new task box shows created, started, exited. A resumed session box shows resumed and then started. This is also true when the resume's attach mints a host that then reports busy. Notes from the agent: Revise round 1. A resume now writes started when the attach mints a host, even when the attach to that host times out. Without the fix, the new test resumed_session_box_records_started_when_attach_wedges failed. The arch thread is a real gap: an attach that keeps a hook-launched host releases its start gate and writes no started event. The fix site is attach_launch in crates/minimald/src/box_actor/attach.rs. That file is outside this task's layers, and the task's host.rs line excludes a hooks host. A follow-up task must cover that case. I did not run just clippy-strict. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 1 condition · the full ruling
The compare fixes a different path: a resume whose attach wedges now records resumed and then started. That part conforms. C1 is still open. A first attach that keeps a hooks host starts the shell but writes no started event, and attach.rs has no change. Architecture line 500 says that running means the entrypoint started, and line 382 makes started the event for it. Make the C1 edit in attach_launch(). Or file an issue and name it in the PR body under Residuals.
Ruled at d8c233c against gominimal/arch@327e1b57d16b by claude-opus-5-5.
| if self.resume_in_flight { | ||
| self.resume_attach_minted = true; | ||
| } else { | ||
| self.record_started("attach").await; |
There was a problem hiding this comment.
C1 · This line writes started only for a host that mint_session_host creates. A hooks host that an attach keeps gets no started when attach_launch() releases its shell (attach.rs line 413). Architecture line 500 says running means the entrypoint started. Do the C1 edit in attach.rs. Or file the gap as an issue and name it under Residuals in the PR body.
There was a problem hiding this comment.
Addressed in da9388839461: Took the residual branch: attach.rs is outside this task's layers. The gap is filed as #3604 and named under Residuals, and the record_started doc comment now names it.
|
/review |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 3 unresolved threads — minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, minimal-foundry[bot] crates/minimald/src/box_actor.rs:1482, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/revise Arch ruling CONDITIONS on d8c233c (arch_rulings 1407) keeps C1 open. C1 allows two branches, and this task takes the residual one: Do this one change:
|
…rds-a-started-event-when-its-entrypoin
An attach that keeps a hooks host releases the shell without a started event. Issue #3604 tracks it.
|
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:
min box events on a new task box shows created, started, exited. A resumed session box shows resumed and then started. The record_started doc comment now names the hooks-host attach gap and says that #3604 tracks it. Notes from the agent: This round changed only the doc comment of record_started in crates/minimald/src/box_actor.rs. No code path changed, and attach.rs is unchanged. The runner owns the PR body. Keep the ## Residuals entry for #3604 and the line 'Closes #3426 (the original issue this task was triaged from).', and remove any 'Known gap' sentence. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
C1 from the ruling on d8c233cd is met by its residual branch. The PR body names issue #3604 under Residuals for the hooks-host attach gap, and that fix is outside this task's layers. Each launch that starts the entrypoint now writes started through record_started. A resume writes resumed and then started. This conforms to the box event types and the running state in architecture.md lines 382 and 500.
Ruled at da93888 against gominimal/arch@327e1b57d16b by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 3 unresolved threads — minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, minimal-foundry[bot] crates/minimald/src/box_actor.rs:1482, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
norrietaylor
left a comment
There was a problem hiding this comment.
The resume, restart and first-launch paths look right. resume_in_flight is set and cleared within the one attach handler, finish_resume writes started after resumed (including the wedged-mint case), and the restart keeps its single started. The new tests pin those orders. One medium issue: started is also written whenever a host is re-minted while the record is already running. That happens on an attach or exec after an until_stopped box's shell returned, and on the daemon-start launch of an own-address box. BOX-040 ties started to the record entering running, so those streams show repeated started events with nothing in between. Details are inline. The hooks-host attach gap is already tracked as #3604, so this review does not repeat it.
Generated by Claude Code
| self.publish_host(); | ||
| // BOX-040: a new host started the box's entrypoint. An ended box is | ||
| // refused above, so no resume reaches this launch. | ||
| self.record_started("exec").await; |
There was a problem hiding this comment.
Medium: this write, and the matching one in mint_session_host (record_started("attach")), fires on every new host. That includes hosts minted while the record is already running, so the stream gets a second started with no exited or resumed before it. BOX-040 says started is written "each time the box's entrypoint starts and the record enters running".
Concrete path: take an until_stopped session box. Its shell returns (the user types exit and keeps the box). end_on_entrypoint_return sees ends_with_entrypoint == false, logs "the entrypoint returned; the box runs until it is stopped", and leaves the record running with no live host. The next min attach reaches attach_launch. The slot is either None or a dead host whose attach returns Closed, so the attach re-mints through mint_session_host, and resume_in_flight is false, so started is written again. A min exec there goes through this ensure_host launch, because h.is_alive() is false, and writes started too. Each time the shell is re-minted, the events read created, started, started, ... while the record never left running. The daemon-start rehydration of an own-address box (box_manager.rs, resume_own_ip_host -> session.ensure_host) hits the same line: it writes started for a box whose record stayed running across the restart, and logs it under op = "exec".
Suggested fix: write started only when this launch is the one that takes the record into running. One way is an actor flag that a write of started sets, and that exited, resumed and the restart's start clear. The other is to decide that a re-minted shell counts as a start and amend BOX-040's wording. Either way, add a test that attaches, exits the shell of an until_stopped box, attaches again, and asserts the resulting event list.
Generated by Claude Code
There was a problem hiding this comment.
Addressed in aeb472a2761f: record_started now writes started only when the record enters running: a started_recorded flag, cleared by exited, resumed and the restart's start, and seeded from the events file for a restored actor. New test reattached_running_box_records_started_once: attach, keep-exit, attach again, then an exec launch, and the events stay created, started.
|
/revise Review finding (norrietaylor, medium, thread at
|
…rds-a-started-event-when-its-entrypoin
A host minted while the record stays running, such as a second attach to an until_stopped box or an exec after its shell returned, wrote a second started event. The actor now tracks whether this start already wrote started. An exited or resumed write and the restart's start clear it. A restored actor reads the events file to decide.
|
Round 3 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:
min box events on a new task box shows created, started, exited. A resumed session box shows resumed and then started. An until_stopped session box that is attached, exits its shell, is attached again and then gets a min exec shows created, started with no second started. Notes from the agent: Round 3. The actor now has a started_recorded flag. record_started sets it and writes nothing when it is set. write_exited_event, the stop's exited write, the resumed write in finish_resume and the restart's move to running clear it. An actor restored from disk starts with the flag clear, so record_started then reads the events file: when the last of started, exited and resumed is started, it writes nothing. That covers the own-address rehydration at daemon start (box_manager.rs resume_own_ip_host -> ensure_host) with no change to box_manager.rs. The daemon-restart case has no dedicated test. The new test is reattached_running_box_records_started_once. I did not run it against the old code to see it fail. PR body items (Residuals entry for #3604, the Closes #3426 line) are the runner's to keep. I did not edit them. just clippy-strict was not run. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The new commit writes started only when the record enters running. A second attach or an exec in a running box now writes no second started. This matches the design's meaning of running in architecture.md line 500 and spec BOX-040. Every path that leaves running clears the new flag, and a restored actor reads the events file. Issue #3604 tracks the hooks-host gap. No condition is open.
Ruled at aeb472a against gominimal/arch@8b824707cde6 by claude-opus-5-5.
|
/review |
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 4 unresolved threads — minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, minimal-foundry[bot] crates/minimald/src/box_actor.rs:1520, minimal-arch[bot] crates/minimald/src/box_actor/host.rs:1989, norrietaylor crates/minimald/src/box_actor/host.rs:1765. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
Follow-up
Fixes #3552
crates/minimald/src/box_actor.rscrates/minimald/src/box_actor/host.rscrates/minimald/src/box_actor/tests.rsTask marker
Proof
min box events on a new task box now lists created, started, exited. On a session box, the first attach adds started after created. An attach that resumes a stopped session box adds resumed and then started, with no second started.
Notes from the agent: I ran each of the four test lines as written, and each one exited 0. I also ran the resume, event, until_complete and restart tests in the lib (81 passed). cargo clippy -p minimald --all-targets gave no warnings. A new actor field, resume_in_flight, is set by resume() and cleared by finish_resume(). It stops mint_session_host from writing started during a resume, so finish_resume writes started after resumed. finish_resume writes started only when the attach's launch succeeded. A failed started write is logged at warn with the op (exec, attach, resume, restart) and does not stop the box.
Tests
cargo test -p minimald created_task_box_records_startedcargo test -p minimald created_session_box_records_startedcargo test -p minimald resumed_session_box_records_startedcargo test -p minimald restart_records_exited_then_started_onlyVerify
min task run agent-verifytimed out after 1800s, so this PR is a draft.Residuals
startedevent. The fix is incrates/minimald/src/box_actor/attach.rs, outside this task's layers (arch_rulings 1401/1407 C1, residual branch).Closes #3426 (the original issue this task was triaged from).