Skip to content

fix(minimald): resume and restart re-run the root-constraint admission check - #3511

Merged
bryan-minimal merged 1 commit into
mainfrom
fix/resume-rechecks-stored-spec
Nov 18, 2026
Merged

bryan-minimal merged 1 commit into
mainfrom
fix/resume-rechecks-stored-spec

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

What

Creating a box checks that the box's type permits what its spec asks for (BOX-160). Resuming or restarting a box from its stored spec did not run that check. BOX-025a says a resume re-checks the stored spec and refuses "with the exit code creation would give", and the code's own comment says a stored spec is "refused as a create of that spec would be refused".

Resume and restart now call the same check creation uses, through one function, before anything is written. A refusal exits 3 with wording for a resume, and the box's record is left unchanged. Creation's own message does not change.

Is this safe for existing boxes

Yes, by reading every writer of a stored spec. Since specs were first stored, the client builds them in two shapes only, a session with a terminal or a task without, and each stored record is filed under the matching type. Task boxes and lifetimes no shipped client writes are already refused earlier, at other checks. So no box the product can create and stop is refused on resume.

That also bounds how reachable this was: it takes a stored spec that creation would refuse, which means a record edited on disk or written by another client. It is defence in depth that the spec asks for.

What was not missing

The other checks creation runs either already ran on resume (version, policy, unenforceable egress), cannot be reached there (a stored spec with secrets is already refused as unreadable), or do not apply (the projection digest compares with what a client sends at creation).

Testing

resume_refuses_stored_spec_its_root_excludes_keeps_state, driven through attach: three refusals (a task spec with a terminal, an unknown type, a session spec on a record filed as a task), each asserting exit 3, the message, unchanged record bytes and no resumed event; and a control, where the spec creation accepted is stored again and the box resumes to running.

Workspace lint, tests and the native end-to-end script pass on this commit.

🤖 Generated with Claude Code

…n check

A start from a box's stored spec (BOX-025, BOX-176) checked the spec's
version, its network policy and its egress rules, but not the BOX-160
check a create of the same spec meets: the constraints of its type's
built-in root and of the type the record is filed under. A stored spec
that create refuses, such as a `task` spec with a terminal or a type with
no built-in root, resumed and left the box running.

checked_stored_spec now passes the stored bytes through
root_constraint_refusal, the function the create path uses, with the
record's type in place of the creating verb's. The refusal keeps the
create's exit status 3, is worded for a start rather than a create, and
comes before the record is written, so the record stays as it was.

The test drives the refusals through an attach, checks the record bytes
are unchanged, and resumes the box once the spec the create accepted is
stored again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 17, 2026 22:47
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • 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 57 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: 9925f3c1-5eab-4da7-9ed4-831ab527190e
Commits

Reviewing files that changed from the base of the PR and between a6dd8c9 and 1dc07b0.

Files selected for processing: 3

  • crates/minimald/src/box_actor.rs
  • crates/minimald/src/box_actor/tests.rs
  • crates/minimald/src/box_manager.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-foundry

minimal-foundry Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Approved: no findings at 1dc07b00cfb4.

Nothing to do.

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.

minimal-review — approved

Verdict APPROVE — No findings.

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

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 17, 2026

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

Approving. The stored bytes go through the same root_constraint_refusal a create runs, with the record's type in the verb's place, and the check runs before held_spec or the record is touched, so a refusal leaves no state behind on either resume or restart. The kind() extraction keeps the create message byte-identical. Three low/nit notes inline.

/// terminal check passes it on. The control: the spec the create accepted
/// resumes once it is stored again.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn resume_refuses_stored_spec_its_root_excludes_keeps_state() {

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.

[low] The title and body say restart re-runs the check too, but only the resume path is tested. Restart goes through the same checked_stored_spec, so it works today, but nothing pins it: a later change that moves the root check out of checked_stored_spec into the resume branch would pass CI. One refused restart of an until_stopped box whose stored spec its root excludes (exit 3, RestartRefusalKind::Spec, record bytes unchanged) next to restart_refuses_box_not_until_stopped_keeps_state would cover it.

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, nothing pins restart. A follow-up PR adds the refused restart of an until_stopped box whose stored spec its root excludes (exit 3, RestartRefusalKind::Spec, record bytes unchanged), next to restart_refuses_box_not_until_stopped_keeps_state.

),
Err(AdmissionRootRefusal::UnknownRoot(UnknownRootRefusal { key, value, .. })) => {
format!(
"The settings it was created with set `{key}` to `{value}`, which names no \

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.

[low] When key is box.type, this arm also covers a project type that omits type.root, e.g. box.type = "ci". The text "set box.type to ci, which names no built-in type" suggests the type should have been a built-in one, when the actual problem is that the spec does not name the root ci extends. The create message makes that distinction ("does not name the built-in type that ci extends"). Branch on key here the way UnknownRootRefusal's Display does.

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.

You are right, for a project type the text points at the wrong thing. The follow-up branches on the key the way UnknownRootRefusal does, so a type that omits its root says it does not name the built-in type it extends.

let spec =
serde_json_lenient::from_slice::<serde_json_lenient::Value>(stored).map_err(|e| {
refused(format!(
"The settings it was created with cannot be read: {e}."

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.

[nit] This parse error can't happen on the only caller: checked_stored_spec has already parsed the same bytes as a BoxSpec through box_runtime::stored_spec, which returns this exact sentence on failure. The duplicated string will drift if either one changes. Pass the parsed Value in, or .expect with the reason, and keep one copy of the text.

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. The follow-up passes the parsed value in, so the sentence has one copy.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit 6b60cbc Nov 18, 2026
40 checks passed
@bryan-minimal
bryan-minimal deleted the fix/resume-rechecks-stored-spec branch November 18, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants