Skip to content

feat: T53 — A typed session entry starts from its own expanded body and lifetime - #3500

Draft
minimal-foundry[bot] wants to merge 10 commits into
mainfrom
agent/3486-a-typed-session-entry-starts-from-its-own-expand
Draft

minimal-foundry[bot] wants to merge 10 commits into
mainfrom
agent/3486-a-typed-session-entry-starts-from-its-own-expand

Conversation

@minimal-foundry

Copy link
Copy Markdown
Contributor

T53 — A typed session entry starts from its own expanded body and lifetime

slice: S3
kind: task
covers: BCLI-029, BCLI-071
size: M
est: 220 code, 200 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: none new; the NamedSessionUnsupported refusal is removed, and the tests that pin it move with it
observability: none new
layers:
- mfile:
- crates/mfile/src/spec.rs: BoxSpec::build takes the lifetime from the expanded spec instead of hard-coding until_complete; the spec tests pin both values
test: cargo nextest run -p mfile box_spec_takes_lifetime_from_expansion
- client:
- crates/minimal/src/cmd/boxes/create.rs: stamp_session_spec_as builds the create's spec from session_box_expansion for the typed entry, not from [session]; project_bep_and_grants reads that expansion for secrets, env and the Box Egress Proxy; plan_start drops NamedSessionUnsupported and the #3204 interim comments
- crates/minimal/src/tests.rs: tests
test: cargo nextest run -p minimal start_typed_session_entry_stores_its_own_body
test: cargo nextest run -p minimal session_entry_until_stopped_stores_until_stopped
produces: none
consumes: none
proof: With [sessions.dev] declaring its own packages, secrets and an on_activate hook, and [sessions.dev.box] lifetime = "until_stopped", min session start dev and min box start dev both start the box. Its stored spec names dev and carries dev's packages, secrets, hook and until_stopped, matching min box spec dev, and min box restart reaches it.
depends on:
- blocked by #3409

Proof

With [sessions.dev] that declares its own packages, a secret and an on_activate hook, and [sessions.dev.box] lifetime = "until_stopped", min session start dev and min box start dev both plan a session start. They are not refused now. The spec that the create stores names dev and carries dev's packages, dev's hook and until_stopped, and the activation grants dev's secret. The test creates that box on an in-process daemon, and min box spec renders the same stored spec. The tests do not run min box restart against the box.

Notes from the agent: crates/minimal/src/main.rs is outside the layers. Its failure_exit_code test listed StartEntryRefusal::NamedSessionUnsupported, so it did not compile after the removal. I removed only that one entry, as the task's diagnostics line says the pinning tests move with the refusal. project_bep_and_grants is now pub(crate) and takes the entry name, so tests.rs can check dev's secrets. Its return type changed from ProjectFileInvalid to anyhow::Error, and the error text for a broken file is the same. Behaviour change: a legacy [session] table reads as [defaults.session], so its packages, secrets and vars now reach every session entry through the expansion, typed entries included. Before this change, a typed entry got only the [session] body. stamp_session_spec_as also uses the picked entry's name for spec.entry when no entry is given (a bare activate of a sole [sessions.x] stores entry x, not default). BoxSpec::build also reads timeout and hooks_on_resume from their execution.* nested form. The mfile expansion merges these keys, and the spec reads the flat key first. pty_enabled stays true for every session spec. Not verified: min box restart on the started box (no test drives it), and the dashboard activation in dash/rpc.rs, which still builds no stored spec (a known gap that this change does not touch).

Tests

line exit tail
cargo nextest run -p mfile box_spec_takes_lifetime_from_expansion 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimal start_typed_session_entry_stores_its_own_body 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal session_entry_until_stopped_stores_until_stopped 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify

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

 {
                "parent_span_id": "4a0a00cec9196ff9",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "c02dba97e10864b2",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "c02dba97e10864b2",
                "queued_behind": "0",
                "span_id": "ee0fcd9291bb47ee",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "4a0a00cec9196ff9",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "b47be281b622f708",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "b47be281b622f708",
                "queued_behind": "0",
                "span_id": "2b3423e1e2c4e9a1",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "b47be281b622f708",
                "queued_behind": "0",
                "span_id": "88c51421b2876986",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "88c51421b2876986",
                "span_id": "3d8c895b1acb0d0c",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "88c51421b2876986",
                "queued_behind": "0",
                "span_id": "13dad409ad12a60f",
                "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.465s] 1355 tests run: 1354 passed, 1 failed, 2 skipped
        FAIL [  13.099s] (1355/1355) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Base

The base branch moved while the coder worked; it was merged in before the tests ran.

Out of scope

These files are outside the task's layers:, so this PR is a draft:

  • crates/minimal/src/main.rs

Closes #3486

BoxSpec::build reads lifetime from the entry's settings in place of a
hard-coded until_complete. BoxSpec::for_session_entry builds a session
spec from an expanded entry (BCLI-029).
stamp_session_spec_as builds the spec from session_box_expansion, and
project_bep_and_grants reads the entry's secrets, vars and Box Egress
Proxy settings from it. plan_start no longer refuses a typed session
entry other than default (BCLI-029, BCLI-071).
@coderabbitai

coderabbitai Bot commented Nov 17, 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: 91627f39-44b5-4f63-bc30-c375fc22f1b0

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

Undrafting at 3831b52c, with the owner's approval (2026-11-17). The runtime drafted this PR for two reasons:

@agent-137
agent-137 marked this pull request as ready for review November 17, 2026 18:46
@agent-137
agent-137 requested a review from a team as a code owner November 17, 2026 18:46
@minimal-foundry

minimal-foundry Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewed: no findings; approval withheld, 7 threads unresolved at 6a66a614d921.

APPROVE withheld: 7 unresolved threads — minimal-foundry[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes/create.rs, minimal-foundry[bot] crates/mfile/src/spec.rs, …. 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: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.

Comment thread crates/mfile/src/spec.rs Outdated
Comment on lines +329 to +334
/// when the entry sets none. [`crate::File::validate`] and the expansion
/// refuse a bad value before a spec is built, so a bad value here reads as
/// `None`.
fn entry_lifetime(extra: &toml::Table) -> Option<Lifetime> {
first_value(extra, &[&["lifetime"], &["box", "lifetime"]])
.and_then(|value| value.clone().try_into().ok())

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.

MEDIUM · correctness · confidence 0.60 · in entry_lifetime

The doc comment says File::validate and the expansion refuse a bad lifetime before a spec is built. I found no such check: expand.rs only checks that lifetime is a string. So lifetime = "until-stopped" or a typo reads as None here, and the box silently stores until_complete. Validate the value at expansion, or return an error from this function.

What the reviewer checked

entry_lifetime: .and_then(|value| value.clone().try_into().ok()); expand.rs:1408 ("lifetime", Shape::Str); no other Lifetime validation found by rg.

Hand this to an agent
Act on a code-review finding.

File:       crates/mfile/src/spec.rs
Lines:      329-334
Category:   correctness
Severity:   medium (reviewer confidence 0.60)

Finding:
The doc comment says `File::validate` and the expansion refuse a bad `lifetime` before a spec is built. I found no such check: expand.rs only checks that `lifetime` is a string. So `lifetime = "until-stopped"` or a typo reads as `None` here, and the box silently stores `until_complete`. Validate the value at expansion, or return an error from this function.

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 8a583e73b42a: The expansion now refuses a lifetime other than until_complete or until_stopped, flat or under [box], with the UnknownValue message. A test pins both forms, and the doc comment is corrected.

@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 typed session entry now starts from its own expansion, and the interim refusal is gone cleanly. One defect is left. The new first_value in crates/mfile/src/spec.rs reads a flat key before its nested form, whatever layer set it. So a flat lifetime in [defaults.session] or a legacy [session] beats the entry's [box] lifetime, and packages with install.packages do not union. The design says that the entry beats every default and that lists union (architecture.md lines 1247-1253). Resolve the two forms by layer rank, as C1 states.

Ruled at f5ac57c against gominimal/arch@327e1b57d16b by claude-opus-5-5.

Comment thread crates/mfile/src/spec.rs Outdated

/// The first value that one of `paths` finds in `table`. An expanded spec
/// can carry a key flat or under its `box.toml` section.
fn first_value<'a>(table: &'a toml::Table, paths: &[&[&str]]) -> Option<&'a toml::Value> {

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 reads the flat key first, whatever layer set it. fold keeps lifetime and box.lifetime as separate keys. So a flat lifetime in [defaults.session] beats the entry's [box] lifetime. Lines 1247-1253 say that the entry beats every default. Take the form from the later layer by report.values, as expand.rs does for loadout_mode.

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 65a914d54c75: Removed first_value. lifetime, timeout and hooks_on_resume now take the flat or the section form from the later layer in report.values, as loadout_mode does.

Comment thread crates/mfile/src/spec.rs Outdated
#[must_use]
pub fn for_session_entry(entry: &str, expanded: &toml::Table, flags: SpecFlags) -> Self {
let packages: Vec<String> =
first_value(expanded, &[&["packages"], &["install", "packages"]])

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 takes only one of packages and install.packages. The expansion keeps them as separate keys, so [defaults] packages beside the entry's [install] packages stores only the flat list. Line 1247 says that lists union. Union both lists in layer order, and remove the duplicates.

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 65a914d54c75: layered_packages now unions packages and install.packages in layer order without duplicates. Pinned by box_spec_takes_lifetime_from_expansion_unions_packages.

Comment thread crates/minimal/src/cmd/boxes/create.rs Outdated
)?;
let mut spec = match &expanded {
Some(expanded) => {
mfile::spec::BoxSpec::for_session_entry(&expanded.wire.name, &expanded.spec, flags)

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 · Pass the expansion report here. Add report to BoxEntryExpansion from full.report in box_entry, and give it to BoxSpec::for_session_entry. Then the spec can resolve the flat and nested forms by layer rank.

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 65a914d54c75: BoxEntryExpansion now carries report from full.report, and stamp_session_spec_as passes it to BoxSpec::for_session_entry.

@agent-137

Copy link
Copy Markdown
Member

/revise

Head f5ac57c5. This round answers arch ruling 1358's condition C1. Change nothing else.

C1: the stored spec takes each setting from the later layer, not the flat key first.
first_value (crates/mfile/src/spec.rs) returns the flat key before the nested one, whichever layer set each. fold (crates/mfile/src/expand.rs) keeps both forms as separate top-level keys: lifetime/box.lifetime, timeout/execution.timeout, hooks_on_resume/execution.hooks_on_resume and packages/install.packages. So [defaults.session] lifetime = "until_complete" beside [sessions.dev.box] lifetime = "until_stopped" stores until_complete, and a default beats the entry. A legacy [session], which reads as [defaults.session], does the same.

  • Add the expansion's report: mfile::expand::ExpansionReport (full.report in box_entry) to BoxEntryExpansion in crates/minimal/src/cmd/boxes/create.rs, and pass it to BoxSpec::for_session_entry.
  • For lifetime, timeout and hooks_on_resume, take the form whose origin in report.values is the later layer. expand.rs already resolves loadout_mode against box.loadout_mode by layer rank this way.
  • For packages, union packages and install.packages in layer order, de-duplicated.
  • Remove first_value if nothing else reads it. Keep no flat-first path.
  • Tests, beside box_spec_takes_lifetime_from_expansion:
    • [defaults.session] lifetime = "until_complete" with [sessions.dev.box] lifetime = "until_stopped" stores until_stopped.
    • [defaults] packages = ["a"] with [sessions.dev.install] packages = ["b"] stores both.

@minimal-foundry

Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. A coder is already running on #3486. Your note is kept and goes into the next round here, which starts when that coder finishes.

Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet.

A typo such as lifetime = "until-stopped" read as no lifetime, and the
box stored until_complete. The expansion now refuses any value that is
not until_complete or until_stopped, flat or under [box].
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on the runtime's review findings, pushed as 8a583e73b42a.

line exit tail
cargo nextest run -p mfile box_spec_takes_lifetime_from_expansion 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimal start_typed_session_entry_stores_its_own_body 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal session_entry_until_stopped_stores_until_stopped 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "0f1c2787d000449e",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "7965b0487779d833",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "7965b0487779d833",
                "queued_behind": "0",
                "span_id": "7f5ee210cdc3390d",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "0f1c2787d000449e",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "fa214890c8a4074f",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "fa214890c8a4074f",
                "queued_behind": "0",
                "span_id": "4d2fc7a2301d4c53",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "fa214890c8a4074f",
                "queued_behind": "0",
                "span_id": "fe5425ab2a597eb8",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "fe5425ab2a597eb8",
                "span_id": "37b00300e35cb109",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "fe5425ab2a597eb8",
                "queued_behind": "0",
                "span_id": "e2b78584d308acdb",
                "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.913s] 1361 tests run: 1360 passed, 1 failed, 2 skipped
        FAIL [  13.052s] (1361/1361) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Outside the task's layers::

  • crates/minimal/src/main.rs

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

Review threads the coder judged:

  • 👍 valid — crates/mfile/src/spec.rs: The expansion now refuses a lifetime other than until_complete or until_stopped, flat or under [box], with the UnknownValue message. A test pins both forms, and the doc comment is corrected.

With [sessions.dev] declaring its own packages, secrets and on_activate hook, and [sessions.dev.box] lifetime = "until_stopped", min session start dev and min box start dev start the box from dev's own expansion. The stored spec names dev and carries dev's packages, secrets, hook and until_stopped, the same as min box spec dev. A lifetime value other than until_complete or until_stopped is now refused when the entry expands, so a typo no longer stores until_complete silently.

Notes from the agent: Revise round 1: the lifetime check is in crates/mfile/src/spec.rs. check_section now also checks a flat key that a section carries, so the flat lifetime key is checked there and expand.rs (outside the layers) does not change. The refusal reuses the existing SpecKeyProblem::UnknownValue message: ' sets lifetime to "until-stopped". lifetime accepts only until_complete or until_stopped. Fix the value.' The legacy [session] table (BoxSpec::for_session) does not pass through the expansion, so a bad lifetime there still reads as until_complete. The full mfile suite (184 tests) and clippy -p mfile --all-targets pass.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft November 17, 2026 19:21

@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 · the full ruling

The change conforms to the design. A typed session entry now stores its own expanded body, and pty_enabled stays true as the session type constrains it. The fix commit refuses a lifetime that is not until_complete or until_stopped, from every layer. A typo no longer stores until_complete. The stored spec still does not include the selected loadouts. Issue #3236 tracks that gap, and it is a residual.

Ruled at 8a583e7 against gominimal/arch@327e1b57d16b by claude-opus-5-5.

The flat key and its section's key are separate top-level keys in an
expansion, so the flat one won whatever layer set it. The spec now
ranks the two forms by the expansion report, and unions packages and
install.packages in layer order.

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

Comment thread crates/mfile/src/spec.rs Outdated
Comment on lines +280 to +286
let hooks_on_resume = extra.is_some_and(hooks_on_resume);
let timeout = extra.and_then(entry_timeout);
// A spec that sets no lifetime keeps the `until_complete` that the
// shipped `session` and `task` types declare.
let lifetime = extra
.and_then(entry_lifetime)
.unwrap_or(Lifetime::UntilComplete);

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.

MEDIUM · correctness · confidence 0.55 · in BoxSpec::build

BoxSpec::build now reads lifetime for every caller, but only expanded entries are validated (check_keys in expand.rs). for_session(Some(&Session)) and for_task pass raw extra. File::validate checks only timeout there. A typo such as lifetime = "until-stopped" in [session] or [tasks.x] silently stores until_complete. A valid until_stopped on a task now changes the stored spec, which the task scope did not intend. The doc comment on entry_lifetime claims the value is always validated, which is false for these two paths.

What the reviewer checked

spec.rs:211 session.map(|s| settings_of(&s.extra)); spec.rs:264 Some(&settings_of(&task.extra)); lib.rs File::validate calls only check_entry_timeout; check_section is called only from expand.rs:1454.

Hand this to an agent
Act on a code-review finding.

File:       crates/mfile/src/spec.rs
Lines:      280-286
Category:   correctness
Severity:   medium (reviewer confidence 0.55)

Finding:
`BoxSpec::build` now reads `lifetime` for every caller, but only expanded entries are validated (`check_keys` in expand.rs). `for_session(Some(&Session))` and `for_task` pass raw `extra`. `File::validate` checks only `timeout` there. A typo such as `lifetime = "until-stopped"` in `[session]` or `[tasks.x]` silently stores `until_complete`. A valid `until_stopped` on a task now changes the stored spec, which the task scope did not intend. The doc comment on `entry_lifetime` claims the value is always validated, which is false for these two paths.

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 6a66a614d921: Still true at head for the task path: BoxSpec::for_task passes the raw [tasks.x] table, so build reads lifetime unchecked. The entry_lifetime doc now speaks only of expanded specs. The /revise note limited this round to C1, so this path is not changed yet. The fix is to read lifetime only for an expanded entry.

Keeps BoxSpec::build within clippy's argument limit.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 2 of 10 on a /revise note, pushed as 65a914d54c75.

line exit tail
cargo nextest run -p mfile box_spec_takes_lifetime_from_expansion 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimal start_typed_session_entry_stores_its_own_body 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal session_entry_until_stopped_stores_until_stopped 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "47cdb81c19fee71b",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "ae3595068b0f4e4f",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "ae3595068b0f4e4f",
                "queued_behind": "0",
                "span_id": "7c74947fe53366b7",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "47cdb81c19fee71b",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "def231c78e6523da",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "def231c78e6523da",
                "queued_behind": "0",
                "span_id": "72f7cd9aecfcd7f2",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "def231c78e6523da",
                "queued_behind": "0",
                "span_id": "0a2a0d1474f53c42",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "0a2a0d1474f53c42",
                "span_id": "26261184ea3a50ca",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "0a2a0d1474f53c42",
                "queued_behind": "0",
                "span_id": "9777071f17d8c6e1",
                "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 [  83.090s] 1363 tests run: 1362 passed, 1 failed, 2 skipped
        FAIL [  12.971s] (1363/1363) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Outside the task's layers::

  • crates/minimal/src/main.rs

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

Review threads the coder judged:

  • 👍 valid — crates/mfile/src/spec.rs: Removed first_value. lifetime, timeout and hooks_on_resume now take the flat or the section form from the later layer in report.values, as loadout_mode does.
  • 👍 valid — crates/mfile/src/spec.rs: layered_packages now unions packages and install.packages in layer order without duplicates. Pinned by box_spec_takes_lifetime_from_expansion_unions_packages.
  • 👍 valid — crates/minimal/src/cmd/boxes/create.rs: BoxEntryExpansion now carries report from full.report, and stamp_session_spec_as passes it to BoxSpec::for_session_entry.

1 outdated runtime thread(s) were not judged: PRRT_kwDOPdfcxM64nNrB

With [sessions.dev] declaring its own packages, secrets and an on_activate hook, and [sessions.dev.box] lifetime = "until_stopped", min session start dev and min box start dev start the box from dev's expansion. The stored spec names dev and carries dev's packages, secrets, hook and until_stopped. A [defaults.session] lifetime or a legacy [session] lifetime no longer overrides the entry's [box] lifetime, and [defaults] packages join the entry's [install] packages.

Notes from the agent: This round addresses only C1. first_value is removed. The new later_value ranks the flat key and its section key by the Layer of their origin in report.values. The nested form wins only when its layer is strictly later, which is the same tie rule as loadout_mode in expand.rs. for_session and for_task pass no report, so they keep the flat form on a tie in their one table. layered_packages merges packages and install.packages by origin layer, with a stable sort and de-duplication. One limit: Layer ranks all type-defaults layers as one rank, and all loadouts as one rank. Two forms set by two different loadouts, or by two types in the chain, therefore tie, and the flat form wins. The report does not carry the position in the layer list, so the spec cannot order them more finely. BoxSpec::build now takes the report beside the settings table as one tuple argument, to stay within clippy's too_many_arguments limit. The two new tests are box_spec_takes_lifetime_from_expansion_later_layer_wins and box_spec_takes_lifetime_from_expansion_unions_packages. They use the name prefix of the plan's mfile test line, so that line runs them.

@agent-137

Copy link
Copy Markdown
Member

Undrafting at 65a914d5, under the owner's approval of 2026-11-17 (option a). CI is green at this head. The runtime re-drafted after round 2 for the same two reasons as before:

Round 2 answers arch ruling 1358's C1: the flat and nested forms resolve by layer rank from the expansion report, and packages union in layer order. The agent note in this body that says "the spec reads the flat key first" describes the earlier head, not this one.

@agent-137
agent-137 marked this pull request as ready for review November 17, 2026 20:29

@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 compare fixes the main defect. The stored spec now takes lifetime, timeout and hooks_on_resume from the later layer, and the packages union across layers, as line 1247 says. One gap stays. later_value ranks by Layer only, so in an extends chain the parent type's flat key beats the derived type's [box] key. Line 1283 says the more specific type wins. C1 breaks that tie by the type chain order, as loadout_mode in expand.rs does.

Ruled at 65a914d against gominimal/arch@327e1b57d16b by claude-opus-5-5.

Comment thread crates/mfile/src/spec.rs Outdated
.and_then(|t| t.get(key));
match (flat, nested) {
(Some(f), Some(n)) => {
let rank = |k: &str| report.and_then(|r| Some(r.values.get(k)?.first()?.layer));

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 rank uses Origin::layer only. Two types of one extends chain are both Layer::TypeDefaults, so they tie and the flat key wins. Line 1283 says the more specific type wins. Break the tie by the position of Origin::box_type in the type chain, as loadout_mode in expand.rs does.

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 6a66a614d921: Fixed in 6a66a61. Inside Layer::TypeDefaults, the rank now uses the position of Origin::box_type in the type chain, root first, which BoxEntryExpansion passes to for_session_entry. The fix covers lifetime, timeout, hooks_on_resume and packages, and box_spec_takes_lifetime_from_expansion_derived_type_wins pins it.

@agent-137

Copy link
Copy Markdown
Member

/revise

Head 65a914d5. This round answers arch ruling 1363's C1. Change nothing else.

C1: a derived Box Type's setting beats its parent's.
later_value (crates/mfile/src/spec.rs) compares only Origin::layer. Every type in an extends chain is Layer::TypeDefaults, so a parent type's flat lifetime beats a derived type's box.lifetime. That contradicts architecture.md line 1283.

  • Break a tie inside Layer::TypeDefaults by the position of Origin::box_type in the entry's type chain, root first, so the more derived type wins. loadout_mode in crates/mfile/src/expand.rs already ranks by position in ordered, and this uses the same order.
  • Pass that order into BoxSpec::for_session_entry through BoxEntryExpansion (crates/minimal/src/cmd/boxes/create.rs). The other choice is to rank the whole Origin against it. Keep one ranking function for lifetime, timeout, hooks_on_resume and the package union.
  • Add a test in spec.rs: [box_types.a] extends = "session" with defaults.lifetime = "until_complete", and [box_types.b] extends = "a" with defaults.box.lifetime = "until_stopped". A type = "b" session entry stores until_stopped.

Reply on the arch thread with the commit.

@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/mfile/src/spec.rs
Comment on lines +336 to +342
/// The entry's own `lifetime`, from `lifetime` or `box.lifetime`. `None`
/// when the entry sets none. The expansion refuses a value that is not
/// one of [`Lifetime::ACCEPTED`] (see [`check_section`]), so an expanded
/// spec never reaches here with a bad value.
fn entry_lifetime(extra: &toml::Table, report: Option<&ExpansionReport>) -> Option<Lifetime> {
later_value(extra, report, "lifetime", "box").and_then(|value| value.clone().try_into().ok())
}

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 entry_lifetime

entry_lifetime drops an invalid value with .ok() and relies on the expansion to refuse it. BoxSpec::for_task and BoxSpec::for_session call build with settings_of(extra) and never pass through check_section. A task or legacy [session] with lifetime = "until-stopped" still stores until_complete without an error. A task with a valid until_stopped now stores it, and before this change it stored until_complete. The doc comment says an expanded spec never reaches here with a bad value, which is false for these callers. Reject a bad value there, or limit the lifetime read to the expanded path.

What the reviewer checked

spec.rs:340 later_value(extra, report, "lifetime", "box").and_then(|value| value.clone().try_into().ok()); for_task passes Some((&settings_of(&task.extra), None)); check_section is called only at expand.rs:1454

Hand this to an agent
Act on a code-review finding.

File:       crates/mfile/src/spec.rs
Lines:      336-342
Category:   correctness
Severity:   low (reviewer confidence 0.50)

Finding:
`entry_lifetime` drops an invalid value with `.ok()` and relies on the expansion to refuse it. `BoxSpec::for_task` and `BoxSpec::for_session` call `build` with `settings_of(extra)` and never pass through `check_section`. A task or legacy `[session]` with `lifetime = "until-stopped"` still stores `until_complete` without an error. A task with a valid `until_stopped` now stores it, and before this change it stored `until_complete`. The doc comment says an expanded spec never reaches here with a bad value, which is false for these callers. Reject a bad value there, or limit the lifetime read to the expanded path.

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.

Every type of an extends chain is a TypeDefaults layer, so a rank by
layer alone tied them and the flat key won. The stored spec now ranks
an origin by layer, then by the type's position in the chain, root
first, as loadout_mode does. One ranking serves lifetime, timeout,
hooks_on_resume and the package union. BoxEntryExpansion carries the
chain to BoxSpec::for_session_entry.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 3 of 10 on a /revise note, pushed as 6a66a614d921.

line exit tail
cargo nextest run -p mfile box_spec_takes_lifetime_from_expansion 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-0 in bo
cargo nextest run -p minimal start_typed_session_entry_stores_its_own_body 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-1 in bo
cargo nextest run -p minimal session_entry_until_stopped_stores_until_stopped 0 warning: unknown fields in task runtime-implement-test-0: network warning: unknown fields in task runtime-implement-test-1: network warning: unknown fields in task runtime-implement-test-2: network help: do you need to update to a newer version of minimal? Running task runtime-implement-test-2 in bo

Verify min task run agent-verify exited 100.

 {
                "parent_span_id": "53724b6988a7ad46",
                "rpc": "minimald-v1-GetSessionRecord",
                "span_id": "bfece9873389ccc1",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "bfece9873389ccc1",
                "queued_behind": "0",
                "span_id": "13c42cff252c4bdb",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "rpc",
            fields: {
                "parent_span_id": "53724b6988a7ad46",
                "rpc": "minimald-v1-DestroySession",
                "span_id": "9af99acf6a513bdc",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "GetRecord",
                "parent_span_id": "9af99acf6a513bdc",
                "queued_behind": "0",
                "span_id": "c5a932a37630fed7",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "DeleteSession",
                "parent_span_id": "9af99acf6a513bdc",
                "queued_behind": "0",
                "span_id": "9e59e4372238a5e4",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "session.message",
            fields: {
                "kind": "Destroy",
                "parent_span_id": "9e59e4372238a5e4",
                "span_id": "d7beb42b44db24dc",
                "trace_id": "0af7651916cd43dd8448eb211c803111",
            },
            parent: None,
            closed: true,
        },
        LoggedSpan {
            name: "sessions.manager.message",
            fields: {
                "kind": "HandOverName",
                "parent_span_id": "9e59e4372238a5e4",
                "queued_behind": "0",
                "span_id": "409946feba8f7111",
                "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 [  84.812s] 1369 tests run: 1368 passed, 1 failed, 2 skipped
        FAIL [  12.982s] (1369/1369) minimal::otel_cli exec_run_attach_and_task_run_share_the_commands_trace
error: test run failed

Outside the task's layers::

  • crates/minimal/src/main.rs

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

Review threads the coder judged:

  • 👍 valid — crates/mfile/src/spec.rs:362: Fixed in 6a66a61. Inside Layer::TypeDefaults, the rank now uses the position of Origin::box_type in the type chain, root first, which BoxEntryExpansion passes to for_session_entry. The fix covers lifetime, timeout, hooks_on_resume and packages, and box_spec_takes_lifetime_from_expansion_derived_typ
  • 👍 valid — crates/mfile/src/spec.rs: Still true at head for the task path: BoxSpec::for_task passes the raw [tasks.x] table, so build reads lifetime unchecked. The entry_lifetime doc now speaks only of expanded specs. The /revise note limited this round to C1, so this path is not changed yet. The fix is to read lifetime only for an exp

With [sessions.dev] declaring its own packages, secrets and an on_activate hook, and [sessions.dev.box] lifetime = "until_stopped", min session start dev and min box start dev store a spec that names dev and carries dev's body and until_stopped. When a derived Box Type sets box.lifetime and its parent sets a flat lifetime, the stored spec now takes the derived type's value.

Notes from the agent: Round 3 answers arch C1 in commit 6a66a61. spec.rs has one Ranking (layer, then the type's position in the chain, root first) for lifetime, timeout, hooks_on_resume and the package union. BoxEntryExpansion carries type_chain from whole.type_defaults to BoxSpec::for_session_entry. The new test declares the entry as [boxes.dev] type = "b", because read_entries refuses type = "b" under [sessions.dev]. Foundry thread PRRT_kwDOPdfcxM64nNrB holds for the task path. task.rs calls BoxSpec::for_task with the raw [tasks.x] table, so build reads lifetime there without checking the value, and File::validate checks only timeout. The /revise note limits this round to C1, so I did not change that path. One fix is to read lifetime only for an expanded entry, where a ranking is present. That fix is in spec.rs. Ran cargo clippy -p mfile --all-targets and -p minimal --all-targets with no warnings, and cargo fmt. Did not run just ci or clippy-strict.

@minimal-foundry
minimal-foundry Bot marked this pull request as draft November 17, 2026 21:04

@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 · the full ruling

The new commit ranks a value by its layer and then by its type's position in the extends chain, root first. So a derived type's [box] lifetime now beats its parent's flat lifetime. Line 1283 of architecture.md requires this: defaults in a chain are overridden by the more specific layer. The order is the same one that loadout_mode uses, and the new test checks the rule itself. The merge of main is clean. No condition is open.

Ruled at 6a66a61 against gominimal/arch@327e1b57d16b by claude-opus-5-5.

@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: 7 unresolved threads — minimal-foundry[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/mfile/src/spec.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes/create.rs, minimal-foundry[bot] crates/mfile/src/spec.rs, …. No findings.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T53 — A typed session entry starts from its own expanded body and lifetime

2 participants