Skip to content

fix(minimald,minimal): a cleanup destroy keeps a session that finished activating - #2233

Merged
bryan-minimal merged 2 commits into
mainfrom
fix/690-cleanup-keeps-finished
Oct 22, 2026
Merged

bryan-minimal merged 2 commits into
mainfrom
fix/690-cleanup-keeps-finished

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Refs gominimal/inbox#690 (its destroy half; the deadline and progress half stays open). Stacked on #2224, whose tearing-down set it builds on.

What

A slow first activation outlasts the client's FinalizeSession deadline. The client gives up and sends a DestroySession to clean up, or is interrupted, and the daemon's connection-close reap sends one. That destroy queues behind the finalize still running; the finalize writes Active; then the destroy deletes the session it just finished. The user sees a timeout, then no session, though it would have been ready a moment later.

The change

A cleanup destroy is conditional, and the session decides it:

  • DestroySessionRequest carries only_if_unfinalized (default off).
  • The manager sends a live actor DestroyIfUnfinalized without claiming it. The actor handles it in mailbox order, after any finalize ahead of it: an Active session is kept, anything else is destroyed and the actor evicts itself. An idle session has no finalize in flight, so its record's status decides.
  • Until the actor answers, the session is in fix(minimald): run a session's teardown off the manager mainloop #2224's tearing-down set: a second destroy is refused rather than queued behind the cleanup, and a listing skips the session while its actor may be deleting the record. A kept session leaves the set with the answer.
  • min session activate's cleanup after a failed or timed-out finalize sends it. A user's min session destroy stays unconditional, and so does min task run's cleanup: a kept task box would have no exec whose end destroys it.
  • The connection-close reap sends it on a native daemon. Behind a VM host daemon the reap stays unconditional: the gone client's registration lease closed with its connection, the host withdrew the box's row, and nothing in the VM can publish it again.

The box row

min session activate holds the registration's lease across the finalize and, when the finalize fails, across the cleanup destroy too. The lease is settled on the destroy's answer:

cleanup answer lease row
destroyed dropped uncommitted withdrawn
kept committed stays; the host_ip name hold is made as for a successful activation
unknown (an error, or no answer within the cleanup's 30 s while a finalize may still be running) committed stays; the client says the session may yet become live and how to remove it

A row with no box behind it costs its addresses until the session is destroyed. A live box with no row has a name that does not resolve and addresses the host may hand to another box. So only a confirmed destroy withdraws the row.

Wire compatibility: the request flag defaults to off, so an older client's destroy is unconditional as before; kept in the response is only ever set in answer to the flag, so an older client never sees it.

Tests:

  • A cleanup destroy keeps an Active session and destroys a pending one.
  • The race itself, deterministically: the actor is held, a finalize and then a cleanup queue in its mailbox in that order, and once released the cleanup keeps the session the finalize finished. While the cleanup is in flight, a second destroy is refused and a listing skips the session.
  • A listing stays whole while a cleanup destroys an unfinished session.
  • The lease follows the cleanup's answer: closed uncommitted when destroyed, committed when kept or unknown.
  • The request and response round-trip, old shapes included.

Evidence

Lab (min-regress, Cloud Hypervisor, local-minimald): this branch at the review round on main 6fb3c55, beside main, four distros × 2 rounds (lab job 00902, batch c5-690r2-matrix):

scenario main 6fb3c55 this PR
690: the client's FinalizeSession times out during a throttled closure fetch; its cleanup destroy queues behind the finalize 0 / 8 (destroyed after finishing) 8 / 8 (kept, listed, Active)
690b: the client is interrupted mid-fetch; the connection-close reap 0 / 8 8 / 8
710d / 710e (from #2224 underneath) 0 / 16 16 / 16
000 baseline 8 / 8 8 / 8

The lab's daemon is native, so it exercises the reap's keep branch and not the VM host's unconditional one. The new unit tests also ran 30 times in a loop with no failure (lab job 00905).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Cleanup can now distinguish between unfinished sessions that should be removed and sessions that have finished activating and should be kept.
    • Session destruction now reports when a session is retained, and cleanup waits for results with a bounded timeout.
  • Bug Fixes

    • Session listings and lookups remain responsive while a session is being destroyed, and in-progress teardown is protected from duplicate operations.
    • Destroy hooks run with a limit on concurrent executions, while teardown continues if a hook fails.

@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 16, 2026 15:24
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

  • Run on-demand review

This review includes 21 billable files and costs up to $5.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 47 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ 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: Essentials
  • Run ID: 86063de1-e141-42e6-a82c-a8dc32804318
📥 Commits

Reviewing files that changed from the base of the PR and between 548daa8 and 6285891.

📒 Files selected for processing: 21
  • crates/minimal-client/src/box_registration.rs
  • crates/minimal-client/src/lib.rs
  • crates/minimal/src/cmd/boxes/create.rs
  • crates/minimal/src/cmd/boxes/lifecycle.rs
  • crates/minimal/src/cmd/boxes/vm_host.rs
  • crates/minimal/src/cmd/mod.rs
  • crates/minimal/src/dash/rpc.rs
  • crates/minimal/src/task.rs
  • crates/minimald-rpc/src/lib.rs
  • crates/minimald-rpc/src/tests.rs
  • crates/minimald/src/box_actor.rs
  • crates/minimald/src/box_actor/handle.rs
  • crates/minimald/src/box_actor/kind.rs
  • crates/minimald/src/box_actor/tests.rs
  • crates/minimald/src/box_manager.rs
  • crates/minimald/src/box_manager/handle.rs
  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/rpc.rs
  • crates/minimald/src/rpc/tests.rs
  • crates/minimald/src/server.rs
  • crates/minimald/src/traced.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ 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: Essentials
  • Run ID: caed8eb1-f381-451a-a281-46a6c9794625
📥 Commits

Reviewing files that changed from the base of the PR and between e30e124 and 548daa8.

📒 Files selected for processing: 21
  • crates/minimal-client/src/box_registration.rs
  • crates/minimal-client/src/lib.rs
  • crates/minimal/src/cmd/boxes/create.rs
  • crates/minimal/src/cmd/boxes/lifecycle.rs
  • crates/minimal/src/cmd/boxes/vm_host.rs
  • crates/minimal/src/cmd/mod.rs
  • crates/minimal/src/dash/rpc.rs
  • crates/minimal/src/task.rs
  • crates/minimald-rpc/src/lib.rs
  • crates/minimald-rpc/src/tests.rs
  • crates/minimald/src/box_actor.rs
  • crates/minimald/src/box_actor/handle.rs
  • crates/minimald/src/box_actor/kind.rs
  • crates/minimald/src/box_actor/tests.rs
  • crates/minimald/src/box_manager.rs
  • crates/minimald/src/box_manager/handle.rs
  • crates/minimald/src/box_manager/tests.rs
  • crates/minimald/src/rpc.rs
  • crates/minimald/src/rpc/tests.rs
  • crates/minimald/src/server.rs
  • crates/minimald/src/traced.rs

Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 0 remain after this review.

📝 Walkthrough

The change adds conditional session destruction based on activation state. The daemon coordinates teardown and hides sessions while deletion is in progress. The client receives whether cleanup kept the session and settles its registration lease accordingly.

Changes: Conditional session cleanup

Layer / File(s) Summary
Cleanup contract and client handling
crates/minimald-rpc/src/lib.rs, crates/minimal-client/..., crates/minimal/src/cmd/..., crates/minimal/src/task.rs
The destroy request and response carry conditional-cleanup status. Client cleanup waits for the daemon outcome and settles the lease and registration row based on that outcome. Existing destroy callers specify unconditional behavior.
Actor-level conditional destruction
crates/minimald/src/box_actor.rs, crates/minimald/src/box_actor/*
Actors keep sessions whose records are active when conditional destruction runs. Otherwise, actors run destroy hooks and tear down the session. A semaphore limits concurrent destroy-hook runs.
Manager teardown coordination
crates/minimald/src/box_manager.rs, crates/minimald/src/box_manager/*, crates/minimald/src/traced.rs
The manager runs teardown in separate tasks and tracks sessions being destroyed. Lookups and listings hide those sessions, duplicate destroys are rejected, and shutdown waits for teardown tasks. Tests cover teardown coordination and conditional destruction.
RPC routing and session reaping
crates/minimald/src/rpc.rs, crates/minimald/src/rpc/tests.rs, crates/minimald/src/server.rs
The RPC endpoint returns whether conditional cleanup kept a session. Session reaping uses conditional deletion for native daemons and unconditional deletion for microVM daemons.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant serve_destroy_session
  participant BoxManager
  participant BoxActor
  Client->>serve_destroy_session: conditional destroy request
  serve_destroy_session->>BoxManager: delete session if unfinalized
  BoxManager->>BoxActor: check activation and destroy if unfinished
  BoxActor-->>BoxManager: kept result or destroy-hook failures
  BoxManager-->>serve_destroy_session: optional failures
  serve_destroy_session-->>Client: kept status and hook failures
Loading

Possibly related issues

  • gominimal/minimal#2236 — The issue describes session lifecycle and record visibility; this change adds conditional destruction and hides sessions during teardown.

Suggested reviewers: mitodrummer

Merge Risk: ⚪ Minimal · up to 548da

The change makes cleanup of a failed or interrupted activation keep a session that has already finished activating, and it withdraws the registration row only when destruction is confirmed. The supplied context shows no remaining concrete merge-blocking risk. The VM-host reap path is verified only by reading the code.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title is a concise Conventional Commit subject that accurately identifies the main change: conditional cleanup destruction keeps sessions that finish activating.
Description check Passed The description is detailed and covers the change, rationale, compatibility behavior, testing, and evidence. It does not use the template's exact Summary, Testing, and Checklist headings, but it provi…
Docstring Coverage Passed Docstring coverage is 85.48% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 62 functions across 21 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed and covers the change, rationale, compatibility behavior, testing, and evidence. It does not use the template's exact Summary, Testing, and Checklist headings, but it provides the required information and is substantially complete.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit checks the session state,
Then waits while cleanup seals its fate.
If activation holds its ground,
The lease stays safe and sessions sound.
If not, the hooks begin their run,
And tidy records when they’re done.

Comment @coderabbitai help to get the list of available commands.

@bryan-minimal bryan-minimal added the bug Something isn't working label Oct 16, 2026
@minimal-foundry

minimal-foundry Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed: no findings; approval withheld, 4 threads unresolved at 628589137bec.

APPROVE withheld: 4 unresolved threads — norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs, norrietaylor crates/minimald/src/box_manager.rs:1645. 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.

Clobber: none seen.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

security

minimal-review — approved

Verdict APPROVE — No findings.

supply-chain

minimal-review — approved

Verdict APPROVE — No findings.

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

Comment thread crates/minimald/src/box_manager.rs Resolved

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

Review at head 64a2a38. The daemon-side rule is correct. DestroyIfUnfinalized is decided in mailbox order. A failed activation is still destroyed. An explicit min session destroy stays unconditional. An old daemon ignores the new field.

The client side has two problems that need a fix before merge: the registration row (comment on cmd/session.rs) and task boxes (comment on task.rs). The other two comments should be fixed or accepted on purpose.

Test gap: a_cleanup_destroy_keeps_a_finished_session checks an idle Active session and a Pending one. It does not queue a cleanup behind a finalize that is still running, so it does not reproduce the race this PR fixes. A slow finalize, or a park message like the one in #2231, can make that case deterministic. No test covers the client's kept handling, the reap path, or the lease.

Comment thread crates/minimal/src/cmd/session.rs Outdated
.and_then(|registration| registration.box_id),
)
.await;
let kept = best_effort_destroy(&mut client, id, true).await;

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.

A kept session has already lost its box registration row.

The lease moves into finalize_holding_lease above. When the finalize fails, that function drops the lease without a commit. Per the BoxLease doc, the VM host daemon withdraws the row when that connection closes. That happens before this line runs, so if !kept { withdraw_box_row(..) } protects nothing.

Failure case, on any host that uses the VM host daemon (the default on macOS):

  1. The activation registers and holds the lease.
  2. The finalize takes longer than the client deadline. The client drops the lease, and the host withdraws the row.
  3. The cleanup destroy keeps the session, which is now Active, and the client says it is live.

Result: a running box with no published row. Its name does not resolve, and the host can give its addresses to another registration. The client also skips its later activation steps, such as the host_ip name hold.

The reap path in crates/minimald/src/server.rs has the same problem: the client is gone, so its lease closed first.

Required change: keep the lease across the cleanup destroy, and commit it when the session is kept. The reap path needs a daemon-side answer.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in ff4f7aa. The lease is now held across the cleanup destroy too, and settled on its answer (settle_lease_after_cleanup): committed when the session is kept, dropped uncommitted with the row withdrawn when it was destroyed. A kept session also gets the host_ip name hold, as a successful activation does.

The reap path: behind a VM host daemon the reap stays unconditional. The gone client's lease closed with its connection, the host withdrew the row, and nothing in the VM can publish it again. A native daemon has no such row, and keeps the session. the_lease_follows_the_cleanup_destroys_answer covers the three answers against a fake daemon socket.

Comment thread crates/minimal/src/task.rs Outdated
crate::best_effort_destroy(&mut client, id).await;
// Only if unfinished: a finalize that completed after the client
// gave up leaves a live session, which is kept (inbox#690).
crate::best_effort_destroy(&mut client, id, true).await;

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.

This change leaves task boxes behind.

Failure case: min task run test without --keep. The finalize passes the client deadline, then completes. The cleanup destroy keeps the box as Active, and the client returns the error. No exec starts, so the destroy on exec exit never runs. The box stays until a person destroys it.

This file's own rule is that a client killed mid-run strands nothing.

Required change: keep this destroy unconditional, or make it conditional only with --keep.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. Reverted in ff4f7aa: min task run's cleanup after a failed finalize is unconditional again, with a comment saying why. Only min session activate's cleanup keeps a finished session.

Comment thread crates/minimal/src/cmd/mod.rs Outdated
match tokio::time::timeout(DESTROY_TIMEOUT, call).await {
Ok(Ok(minimald_rpc::Errorable::Ok(_))) => {}
Ok(Ok(minimald_rpc::Errorable::Ok(resp))) => {
if resp.kept {

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.

DESTROY_TIMEOUT (10 s, line 773) is now often shorter than the wait it covers. A conditional destroy waits behind the finalize in the actor's mailbox by design, and that finalize can take minutes on a stalled fetch.

Failure case: the finalize needs more than 10 s more. The client prints "could not remove the unfinished session", and kept is false, so it withdraws the row. Then the daemon processes the destroy and keeps the session. The message is wrong, and the row is withdrawn under a live box.

Required change: give the conditional destroy a timeout that covers the finalize, or treat a timeout as "unknown" and do not withdraw the row.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in ff4f7aa, both ways. The conditional destroy now waits up to 30 s. Anything short of a confirmed destroy is reported as unknown: the lease is committed, the row stays, and the client says the finalize may still be running, the session may yet become live, and how to remove it. A row with no box behind it costs its addresses until a destroy. A live box with no row loses its name and can lose its addresses. So only a confirmed destroy withdraws the row.

// it destroys. An idle session has no finalize in flight, so
// its record answers: a finished one is kept, an unfinished
// one takes the unconditional path below.
if only_if_unfinalized {

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.

This path destroys a session outside the tearing_down set that #2224 added. The actor deletes its own record and breaks with SelfInitiated, but its id is never in tearing_down, and its handle stays in running until Evict.

Two results:

  1. List reads store.handles() and then calls handle.record(). If the record is deleted between the two calls, record() fails and the whole min ls fails. The reap now always takes this path, so every interrupted activation opens this window. The window is small.
  2. A user's unconditional destroy is not serialized with this one. With [DestroyIfUnfinalized, Destroy] in the mailbox of an Active session, the cleanup answers kept, and then the user's destroy deletes the session. The cleanup caller then says the session is live and skips withdraw_box_row. This is the open minimal-foundry thread.

Required change: insert the id into tearing_down on this path too, or accept the race and say why.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in ff4f7aa: the conditional path puts the id in tearing_down until the actor answers, with the same guard as the unconditional path. While it is in flight, a second destroy is refused, and the refusal now says to destroy again if the session is still listed afterwards. List skips the session while its actor may be deleting the record. A kept session leaves the set with the answer. a_cleanup_destroy_queued_behind_a_running_finalize_keeps_the_session asserts both.

@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from 64a2a38 to ff4f7aa Compare October 16, 2026 19:03
@bryan-minimal

Copy link
Copy Markdown
Member Author

On the test gap from the review: a_cleanup_destroy_queued_behind_a_running_finalize_keeps_the_session holds the actor with a test-only message. It then queues a finalize and a cleanup behind it, waiting on the mailbox's queue length so the order is fixed, and asserts that the cleanup keeps the session the finalize finished. a_listing_survives_a_cleanup_destroy_of_an_unfinished_session covers the destroying side. The client's handling of the answer is in the_lease_follows_the_cleanup_destroys_answer. The reap's VM-host branch has no in-crate test: it would need a server state with in_microvm set for a one-line branch. The lab runs are in the updated description.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 5 unresolved threads — minimal-foundry[bot] crates/minimald/src/sessions.rs:1616, norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs:793, norrietaylor crates/minimald/src/sessions.rs:1569. No findings.

Panel: 1 of 3 personas ran (correctness); did not complete: security, supply-chain.

@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from ff4f7aa to e1e3ad1 Compare October 16, 2026 22:07

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness

minimal-review — approval withheld

Verdict COMMENT — APPROVE withheld: 5 unresolved threads — minimal-foundry[bot] crates/minimald/src/sessions.rs:1616, norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs:793, norrietaylor crates/minimald/src/sessions.rs:1569. No findings.

Panel: 1 of 3 personas ran (correctness); did not complete: security, supply-chain.

@bryan-minimal

Copy link
Copy Markdown
Member Author

Re-stacked on #2224 (cb0dbdd), which now caps concurrent destroy-hook runs. This PR's destroy_now holds the hook slot that #2224's Destroy handler held before, so a conditional cleanup destroy is capped the same way. No other change here.

@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from e1e3ad1 to 205e053 Compare October 17, 2026 04:50

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

correctness

minimal-review — advisory review

Verdict COMMENT — 2 findings, 2 inline.

supply-chain

minimal-review — approved

Verdict APPROVE — No findings.

Panel: 2 of 3 personas ran (correctness, supply-chain); did not complete: security.

Comment thread crates/minimal/src/cmd/session.rs Resolved
Comment thread crates/minimal/src/cmd/session.rs Resolved
@bryan-minimal
bryan-minimal force-pushed the fix/710-manager-destroy branch from cb0dbdd to f6f8071 Compare October 17, 2026 20:41
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from 205e053 to 79a3cf2 Compare October 17, 2026 20:42
@bryan-minimal

Copy link
Copy Markdown
Member Author

Rebased onto main 11b0b44, through the renames of #2228 and #2229 (session.rs is box_actor.rs, sessions.rs is box_manager.rs, SessionStatus is BoxState, and so on). The changes are the same; each commit builds, passes clippy and passes its tests on the new base. The one new commit answers the two review threads on the cleanup's wait and Ctrl-C. Lab on the new base (lab job 00957, four distros × 2 rounds): 690, 690b, 710d and 710e pass 8/8 each here and 0/8 on main; the baseline passes 8/8 on both.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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: 1 of 3 personas ran (correctness); did not complete: security, supply-chain.

Comment thread crates/minimal/src/cmd/mod.rs Resolved
@bryan-minimal
bryan-minimal force-pushed the fix/710-manager-destroy branch from f6f8071 to 7f00593 Compare October 18, 2026 18:36
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from 79a3cf2 to be1fbe1 Compare October 18, 2026 18:36
@bryan-minimal

Copy link
Copy Markdown
Member Author

Rebased onto main 9ea9433. Main's new test-only actor message (#2304) sits beside this stack's HoldUntil, and the merge GitHub would do leaves HoldUntil's kind arm outside cfg(test), which breaks the non-test build; the stack is re-pushed with that resolved. Each branch builds and passes its tests on the new base. One new commit, for the thread on the cleanup's deadline.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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 — 2 findings, 2 inline.

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

Comment thread crates/minimald/src/box_manager.rs Resolved
Comment thread crates/minimald/src/box_manager.rs Resolved
@bryan-minimal
bryan-minimal force-pushed the fix/710-manager-destroy branch from 7f00593 to c30facf Compare October 19, 2026 17:07
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from be1fbe1 to 6f13094 Compare October 19, 2026 17:07
@bryan-minimal

Copy link
Copy Markdown
Member Author

Rebased onto main 559a1d8. #2315 landed its UNKNOWN_SESSION_ID_LEAD constant in the DeleteSession handler this stack rewrites; the rebase carries it (the one conflict). Each branch builds and passes its tests on the new base. One new commit, for the two threads on the conditional path.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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: 6 unresolved threads — norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs, norrietaylor crates/minimald/src/box_manager.rs:1619, minimal-foundry[bot] crates/minimald/src/box_manager.rs:1685, …. No findings.

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

@bryan-minimal
bryan-minimal force-pushed the fix/710-manager-destroy branch from c30facf to 2a4db77 Compare October 19, 2026 17:48
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from 6f13094 to ff5dfbd Compare October 19, 2026 17:48
@bryan-minimal

Copy link
Copy Markdown
Member Author

Re-pushed under #2224's new commit (2a4db77, the composition read honours the tearing-down set). No change to this branch's own commits.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.

Comment thread crates/minimal/src/cmd/mod.rs Resolved
@bryan-minimal

Copy link
Copy Markdown
Member Author

Lab evidence for the stack on main 559a1d8 is on #2224: no regressions over 14 scenarios x 2 rounds x 4 distros; this branch's own scenarios, 690-cleanup-destroys-finished-session and 690b-sigint-reap-finished-session, go from 0/8 to 8/8 each.

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

The earlier threads are addressed: the lease is held across the cleanup, the task cleanup is unconditional again, the conditional destroy waits for its answer, and the conditional path goes through tearing_down. Two problems remain.

  1. Ctrl-C during the cleanup wait withdraws the row of a box that can still go live (crates/minimal/src/cmd/mod.rs:887-889). While the conditional destroy is in flight the id is in tearing_down, so GetRecord returns None (box_manager.rs ~1477), the Ctrl-C branch maps that to Destroyed, and session.rs:1652 drops the lease uncommitted and calls withdraw_box_row. The daemon's DestroyIfUnfinalized is not cancelled and runs on. On minvmd: finalize stalls, the user presses Ctrl-C after "Press Ctrl-C to stop waiting", the row goes, then finalize succeeds and the actor keeps the box. The box is Active with no row: its name does not resolve, its addresses can be handed out again, and no host_ip hold is made. That is the outcome this PR's table says it prevents. The note's "leaves the session as it is" is also not true, since the queued cleanup still destroys an unfinished box. Ctrl-C has to leave the lease committed (or Unknown) while the destroy is outstanding.
  2. Every daemon error maps to Unknown (mod.rs:873), the open bot thread. An error answer commits the lease, including NotFound when a concurrent min session destroy removed the box first. The row then stays with no box behind it, and min session destroy can no longer find it. NotFound should map to Destroyed.
  3. The Ctrl-C warning ("until the VM host daemon restarts") names an internal component and states a consequence the user cannot act on. Per the user-facing text rules in AGENTS.md it should say what happens to the box in the user's words, or name a command that clears it.

This is stacked on #2224, so no CI lane has compiled or tested it. A test merge into main conflicts in cmd/session.rs, task.rs, minimald-rpc/src/lib.rs, box_actor.rs, box_manager.rs and rpc.rs (#2479 and #2480); the stack needs rebasing and this retargeted to main before merge.

@bryan-minimal

Copy link
Copy Markdown
Member Author

Thanks @norrietaylor, both were real. Rebased onto the new #2224 head as one ported commit (main's rename of the CLI and RPC files made a replay conflict whole-file), with both fixed:

  1. Ctrl-C during the cleanup wait no longer reads the record. A session a destroy is in flight for is hidden from reads, so that read could only say "gone" for a box the destroy may yet keep, and the row went with it. The wait's end is now Unknown unconditionally: the lease is committed, the row stays, and the message says what is happening (the daemon still finishes or removes the session), how to see which (min ls), and what removes it if it is still there (min session destroy <id>). The note printed at 30 s no longer claims the session is left as it is.
  2. A daemon answer that opens with UNKNOWN_SESSION_ID_LEAD maps to Destroyed: a concurrent min session destroy removed it first, nothing runs behind the row, and a row kept there could never be removed. Every other error stays Unknown.
  3. The Ctrl-C text names no component now; see 1.

The lease is still held across the cleanup, the task-path cleanup unconditional, and the conditional destroy still waits for its answer under the 24 h client deadline. CI mirror on the box green apart from the known caps_root_integration environment failure; the minimald, minimal, minimal-client and minimald-rpc suites pass with the three cleanup tests and the lease test.

@bryan-minimal
bryan-minimal force-pushed the fix/710-manager-destroy branch from 2a4db77 to 470dbc4 Compare October 22, 2026 17:42
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from ff5dfbd to f9cbe92 Compare October 22, 2026 17:42

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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/mod.rs Resolved
@norrietaylor

Copy link
Copy Markdown
Member

The PR so nice I approved it twice!

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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 — norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs, norrietaylor crates/minimald/src/box_manager.rs:1628. No findings.

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

Base automatically changed from fix/710-manager-destroy to main October 22, 2026 20:00
…d activating

An activation the client gave up on (a finalize past its deadline) sent an
unconditional destroy that raced the finalize still running in the daemon:
the session could finish, and be destroyed, or be kept with its box row
withdrawn (inbox#690). The cleanup destroy is now conditional: the session
decides, in mailbox order after any finalize ahead of it, and answers
`kept` for one that finished. The client waits for that answer with the
registration's lease held, and settles the lease and the row on it.

Ported onto main's renamed tree on top of #2224's rebase. Two changes
from the earlier rounds: a Ctrl-C during the wait leaves the outcome
unknown (lease committed, row kept) rather than reading a record a destroy
in flight hides, which withdrew the row of a box that could still go live;
and a daemon answer that the session is already gone maps to destroyed,
since nothing runs behind the row and no later destroy could find it.
A cleanup destroy after a failed finalize waits for the daemon's answer
under a 24 h deadline, with the user's Ctrl-C as the real bound. With no
terminal on stdin (CI, a script) nothing presses it, so the wait is
bounded at 15 minutes instead and ends unknown: the row stays, the daemon
still settles the session, and the warning says how to see what became
of it.
@bryan-minimal
bryan-minimal force-pushed the fix/690-cleanup-keeps-finished branch from 548daa8 to 6285891 Compare October 22, 2026 20:12

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor

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 — norrietaylor crates/minimal/src/cmd/session.rs, norrietaylor crates/minimal/src/task.rs, norrietaylor crates/minimal/src/cmd/mod.rs, norrietaylor crates/minimald/src/box_manager.rs:1645. No findings.

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

@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 4cd07da Oct 22, 2026
37 checks passed
@bryan-minimal
bryan-minimal deleted the fix/690-cleanup-keeps-finished branch October 22, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants