From d4214240d419e26f45ad22da418e7141104ad8f4 Mon Sep 17 00:00:00 2001 From: Karl Godard Date: Fri, 4 Dec 2026 20:47:06 -0700 Subject: [PATCH] fix(mfile): refuse minimal.toml keys this release does not support yet, and a pty_enabled the root excludes (#4067) * fix(mfile): refuse minimal.toml keys that no box applies Owner ruling (#4038): a key with no working implementation is not a box setting. The expansion now refuses, with exit 3, for every box: volumes, loadouts, flat name, box.type, execution.exec, [install], the io mimetype keys, on_oom, restart, file_imports, github_imports, otel, machine, nesting, github_token_mode, profile, and an entry's params or upstream. A key that 0.7 read or a committed minimal.toml sets carries a hint: profile names packages, name names box.name, and the keys of the architecture's example say that nothing replaces them. A [defaults] profile is no longer moved to [defaults.task], so the refusal names the table that set it. The projection fills a GitHub grant's mode from the root's token mode; the BOX-071 field set and the golden digests are unchanged. A stored spec that carries a removed key still reads back, so its box resumes. Also fixes the BoxSpec docs that said minimald reads neither lifetime nor timeout (#4034), and narrows spec 29 BOX-049, BOX-051, BOX-076, BOX-085 and BOX-145 to match. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * fix(mfile): refuse a pty_enabled that the entry's built-in root excludes pty_enabled stays a box setting, and follows the entry's built-in root (BOX-160): a session always has a terminal and a task never has one. The expansion now refuses, with exit 3, a session-rooted entry that sets pty_enabled = false and a task-rooted entry that sets it to true, flat or under [io], from any layer. The error names the key as the layer wrote it, the layer and the root. The root's own value is accepted. The check runs in the expansion, so min box spec refuses what min box start, min session start and min task run refuse, and the two no longer disagree on the value. Closes #4044 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * fix(mfile): refuse an unapplied key or terminal value in the layer that set it A more specific layer's table replaces a lower layer's whole, so `[defaults.execution] restart` under an entry's own `[execution]` never reached the expanded spec, and the check after the fold missed it. The expansion now checks the refused keys, and an upstream from any layer but the top-level [upstream], in every layer before the fold, naming the layer that set the key. pty_enabled is checked the same way: for each spelling, the last layer that sets it decides, so a later layer's own value still overrides, and a lower [io] pty_enabled that a later [io] table drops is still refused. Spec 29 names the two gaps left open: #4069 (a session entry's task action keys) and #4070 (constraints on keys no entry may set). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * fix(mfile): refuse box.toml keys as not supported yet, and keep them in the schema Owner direction (#4067): the keys the architecture's box.toml specifies and this release does not implement stay legal, and are refused until each ships. They are back in SPEC_KEYS and the section schemas: volumes and box.volumes, nesting, file_imports, github_imports, github_token_mode, otel, machine, on_oom and execution.on_oom, restart and execution.restart, an entry's params, install.raw_packages and the io mimetype keys. One constant, mfile::expand::NOT_SUPPORTED_YET, holds the set, and its doc comment says docs must not describe them as usable. Any layer that sets one fails with exit 3: " in minimal.toml sets ``, which this release does not support yet. Remove `` to start the box." A key that another key replaces keeps its refusal as not a box setting: profile, flat name, box.type, execution.exec, install.packages, entry loadouts, and upstream outside the top level. install.packages and box.type now name their replacement. The projection is back to main's, so the BOX-071 field set and the golden digests are unchanged. Spec 29 restores BOX-049, BOX-076, BOX-085 and the BOX-071 token-mode bullet, adds one sub-requirement for the not-supported-yet refusal, and rewrites the 2026-12-04 reasoning to match. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * docs: remove mentions of features this release does not implement Owner direction (#4067): the user docs describe only what main does. - tasks.md, minimal-dot-toml.md: a task does not take env_vars from [defaults] or [defaults.task] (#3266), so drop the merge claim and its examples. - minimal-dot-toml.md: drop [agents.] and [services.] from the entry tables, which no start accepts (BOX-063), and the note on a `uses` secret that is not delivered yet. - cli-min.md: min task run keeps vpn_network_names and does not apply it; drop the issue that tracks a stored-spec rebuild, and the test coverage notes under min net forward. - loadouts.md: subcommands.forward no longer mentions nested sessions. - install.md: 0.8 reads vars and vars_lenient with a hint; only 0.9.0 refuses them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * fix(mfile): take an entry's flat name as the box's written name The architecture's example writes a box's name as a flat `name` in its entry. The expansion now moves it to `box.name`, so a start names the box from it and `min box spec` renders it there. One value in both keys is kept. Two different values fail with exit 3, naming each key and the layer that set it. The flat key leaves the replaced keys, and its hint goes away. In the pty_enabled check, only a true or false value now supersedes a lower one, so a malformed value cannot hide an excluded `false`. The shape check still refuses a malformed value that the fold keeps. Spec 29 adds the flat name to BOX-049 and drops it from the replaced keys, and notes that each not-supported-yet key leaves that list when its feature ships. The reference says when `profile` is refused. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * fix(mfile): name a task's exec as the replacement for execution.exec execution.exec now carries a hint, as BOX-076 requires of a replaced key: "A task entry's command is its `exec` key. Move the value to `exec` in the same table." It names the task entry's key, so it does not promise that a session runs it (#4069). The minimal.toml reference now says what `uses` does with a service's secret: it adds a [secrets] entry under the service's variable, a declared broker or store entry takes its place, and a client_env entry or an env_vars value for that variable fails with exit 3. Spec 29 narrows the stored-spec claim to the keys a stored spec keeps. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * docs(specs): link each not-supported-yet key to its owner issue Each key in NOT_SUPPORTED_YET now names the issue whose fix takes it off the list, in spec 29's Non-goals and in the constant's doc comment. The user docs still name none of them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA * test(mfile): pin that a [defaults] profile is no legacy refusal at 0.9.0 At the refusing release the legacy pass leaves a profile under [defaults] in place, so the expansion's "Profiles were removed" hint is what the user reads, not a legacy refusal that points at [defaults.task]. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016CYvTvep9ZaSf5pJMB2hQA --------- Co-authored-by: Karl Godard Co-authored-by: Claude Opus 5.5 (cherry picked from commit 8d1df1390152ef182c8edad8a5c3e1094ca52869) --- crates/mfile/src/box_types.rs | 11 +- crates/mfile/src/error.rs | 77 ++ crates/mfile/src/expand.rs | 877 ++++++++++++++++-- crates/mfile/src/legacy.rs | 136 ++- crates/mfile/src/spec.rs | 254 ++--- crates/mfile/tests/golden.rs | 24 +- crates/mfile/tests/golden/vectors.json | 4 +- crates/minimal/src/tests.rs | 129 ++- crates/minimald/src/box_manager/tests.rs | 30 +- docs/guide/install.md | 7 +- docs/guide/migrate-to-minimal-session.md | 10 +- docs/reference/cli-min.md | 16 +- docs/reference/loadouts.md | 2 +- docs/reference/minimal-dot-toml.md | 47 +- docs/reference/tasks.md | 14 +- .../29-spec-box-local-first.md | 43 +- 16 files changed, 1269 insertions(+), 412 deletions(-) diff --git a/crates/mfile/src/box_types.rs b/crates/mfile/src/box_types.rs index 3339240b4b..c42ee53eea 100644 --- a/crates/mfile/src/box_types.rs +++ b/crates/mfile/src/box_types.rs @@ -1250,19 +1250,20 @@ mod tests { // A type that sets a key in both forms is not checked against // itself, and each form constrains the type that extends it. let both = "[box_types.dev]\nextends = \"session\"\n\ - constraints = { restart = [\"never\", \"always\"], execution = { restart = \"never\" } }\n"; + constraints = { lifetime = [\"until_complete\", \"until_stopped\"], \ + box = { lifetime = \"until_complete\" } }\n"; types(both).expect("one type's two forms are not checked against each other"); let err = types(&format!( - "{both}[box_types.leaf]\nextends = \"dev\"\nconstraints = {{ restart = \"always\" }}\n" + "{both}[box_types.leaf]\nextends = \"dev\"\nconstraints = {{ lifetime = \"until_stopped\" }}\n" )) - .expect_err("the section form of dev excludes always"); + .expect_err("the section form of dev excludes until_stopped"); assert_eq!( err, BoxTypeError::Loosening { name: "leaf".into(), - key: "restart".into(), + key: "lifetime".into(), parent: "dev".into(), - value: Some("\"always\"".into()), + value: Some("\"until_stopped\"".into()), } ); diff --git a/crates/mfile/src/error.rs b/crates/mfile/src/error.rs index 84770ca040..ada8bf72cf 100644 --- a/crates/mfile/src/error.rs +++ b/crates/mfile/src/error.rs @@ -108,6 +108,28 @@ pub enum Error { box_type: String, admitted: Vec, }, + /// A layer sets `pty_enabled` to the value that the entry's built-in + /// root excludes (BOX-160, #4044): `false` for `session`, `true` for + /// `task`. Carries the key as the layer wrote it, the layer as the + /// message names it, the root, and whether the layer is a table of the + /// project's `minimal.toml`. Exits 3. + TerminalExcluded { + key: String, + layer: String, + root: &'static str, + in_project_file: bool, + }, + /// A spec sets the box's name twice, as a flat `name` and as + /// `box.name`, to two different values (#4067). Carries each layer as + /// the message names it, each value, and whether the flat key's layer + /// is a table of the project's `minimal.toml`. Exits 3. + NameSetTwice { + flat_layer: String, + nested_layer: String, + flat: String, + nested: String, + in_project_file: bool, + }, /// The entry's Box Type does not resolve, or the entry cannot use it. /// Exits 3. BoxType(Box), @@ -249,6 +271,14 @@ pub enum TrustedCaProblem { pub enum SpecKeyProblem { /// No box setting has this name. Unknown, + /// No box setting has this name, and the key was in use: a release + /// or a committed `minimal.toml` set it (#4038). Carries the sentences + /// that name what to do instead. + Removed { hint: &'static str }, + /// The architecture's `box.toml` specifies the key, and this release + /// does not implement it yet + /// ([`crate::expand::NOT_SUPPORTED_YET`], #4038). + NotSupportedYet, /// The key is inside an `[upstream]` table, and is not one of the /// registry pin's keys. UnknownUpstream, @@ -336,6 +366,8 @@ impl Error { | Error::LoadoutSetsLoadoutMode { .. } | Error::NamedLoadoutOnSealedBox { .. } | Error::ConstraintViolated { .. } + | Error::TerminalExcluded { .. } + | Error::NameSetTwice { .. } | Error::BoxType(_) | Error::LoadoutVarConflict { .. } | Error::DerivedGrantConflictsWithClientEnv { .. } @@ -380,6 +412,12 @@ impl Error { | Error::InvalidSpecKey { in_project_file, .. } + | Error::TerminalExcluded { + in_project_file, .. + } + | Error::NameSetTwice { + in_project_file, .. + } | Error::InfrastructureCasSet { in_project_file, .. } @@ -501,6 +539,17 @@ impl fmt::Display for Error { "{layer} sets `{key}`, which is not a box setting. \ Remove the key or correct its name." ), + SpecKeyProblem::NotSupportedYet => write!( + f, + "{layer} sets `{key}`, which this release does not support yet. \ + Remove `{key}` to start the box." + ), + SpecKeyProblem::Removed { hint } => { + write!( + f, + "{layer} sets `{key}`, which is not a box setting. {hint}" + ) + } SpecKeyProblem::UnknownUpstream => write!( f, "{layer} sets `{key}`, which is not an `[upstream]` setting. \ @@ -623,6 +672,32 @@ impl fmt::Display for Error { ), } } + Error::TerminalExcluded { + key, layer, root, .. + } => { + let (value, has, fix) = if *root == "task" { + ("true", "A task never has a terminal", "false") + } else { + ("false", "A session always has a terminal", "true") + }; + write!( + f, + "{layer} sets `{key}` to `{value}`, but the entry's built-in \ + type is `{root}`. {has}. Remove `{key}`, or set it to `{fix}`." + ) + } + Error::NameSetTwice { + flat_layer, + nested_layer, + flat, + nested, + .. + } => write!( + f, + "{flat_layer} sets `name` to {flat:?}, and {nested_layer} sets \ + `box.name` to {nested:?}. Both set the box's name. Remove one of \ + them, or give them the same value." + ), // The type error's own message is the whole message. Error::BoxType(error) => write!(f, "{error}"), Error::ConstraintViolated { @@ -833,6 +908,8 @@ impl std::error::Error for Error { Error::LoadoutSetsLoadoutMode { .. } => None, Error::NamedLoadoutOnSealedBox { .. } => None, Error::ConstraintViolated { .. } => None, + Error::TerminalExcluded { .. } => None, + Error::NameSetTwice { .. } => None, // `Display` prints the type error, so a chain printer prints it // once. Error::BoxType(_) => None, diff --git a/crates/mfile/src/expand.rs b/crates/mfile/src/expand.rs index 03fddca694..b6d8337acc 100644 --- a/crates/mfile/src/expand.rs +++ b/crates/mfile/src/expand.rs @@ -816,6 +816,8 @@ pub fn expand(entry: &BoxEntry, layers: &Layers) -> Result { .zip(&resolved) .map(|((origin, table), own)| (origin.clone(), own.as_ref().unwrap_or(*table))) .collect(); + refuse_unapplied_keys(entry, &ordered)?; + check_terminal(entry, &ordered)?; let mut expansion = fold(&ordered); merge_vars(entry, &ordered, &layers.host_vars, &mut expansion)?; secret_name_warnings(entry, loadouts, &mut expansion); @@ -842,10 +844,200 @@ pub fn expand(entry: &BoxEntry, layers: &Layers) -> Result { expansion.report.implicit = entry.implicit; expansion.report.client_config_cas = client_config_cas; check_keys(entry, &expansion)?; + fold_flat_name(entry, &mut expansion)?; check_file_exports(entry, &expansion)?; Ok(expansion) } +/// Moves an entry's flat `name` to `box.name`, the box's written name, as +/// the architecture's example writes it (#4067). A spec that sets both +/// keys to one value keeps it. Two different values are refused with exit +/// 3, naming each key and the layer that set it. [`check_keys`] has +/// already checked that each is a string. +fn fold_flat_name(entry: &BoxEntry, expansion: &mut Expansion) -> Result<(), Error> { + let Some(name) = expansion.spec.remove("name") else { + return Ok(()); + }; + let name_origin = expansion.report.values.remove("name"); + let nested = expansion + .spec + .get("box") + .and_then(|b| b.get("name")) + .cloned(); + match nested { + Some(nested) if nested != name => { + let flat_at = name_origin.as_ref().and_then(ValueOrigin::first); + let nested_at = expansion + .report + .values + .get("box") + .and_then(ValueOrigin::first); + Err(Error::NameSetTwice { + flat_layer: layer_words(entry, flat_at), + nested_layer: layer_words(entry, nested_at), + flat: name.as_str().unwrap_or_default().to_owned(), + nested: nested.as_str().unwrap_or_default().to_owned(), + in_project_file: in_project_file(flat_at), + }) + } + Some(_) => Ok(()), + None => { + let table = expansion + .spec + .entry("box") + .or_insert_with(|| toml::Value::Table(toml::Table::new())); + if let Some(table) = table.as_table_mut() { + table.insert("name".to_owned(), name); + } + if let Some(origin) = name_origin { + expansion + .report + .values + .entry("box".to_owned()) + .or_insert(origin); + } + Ok(()) + } + } +} + +/// Refuses a `pty_enabled`, flat or under `[io]`, that the entry's built-in +/// root excludes (BOX-160, #4044): `false` for a `session`-rooted entry, +/// which always has a terminal, and `true` for a `task`-rooted one, which +/// never has one. A value equal to the root's passes. The check runs in the +/// expansion, so `min box spec` refuses what a start refuses. +/// +/// It reads `ordered`, the layers before the fold, so a value that a later +/// layer's `io` table drops by replacing the table is still checked. For +/// each spelling, the last layer that sets it to true or false decides: a +/// later layer that sets the root's own value overrides an earlier one. +fn check_terminal(entry: &BoxEntry, ordered: &[(Origin, &toml::Table)]) -> Result<(), Error> { + let (root, terminal) = match entry.root { + Some(root @ "session") => (root, true), + Some(root @ "task") => (root, false), + _ => return Ok(()), + }; + for (key, section) in [("pty_enabled", None), ("io.pty_enabled", Some("io"))] { + let last = ordered.iter().rev().find_map(|(origin, table)| { + let table = match section { + Some(section) => table.get(section)?.as_table()?, + None => *table, + }; + // Only a true or false value supersedes a lower one, so a + // malformed value cannot hide an excluded one. `check_keys` + // refuses a malformed value that the fold keeps. + table + .get("pty_enabled") + .and_then(toml::Value::as_bool) + .map(|value| (origin, value)) + }); + let Some((origin, value)) = last else { + continue; + }; + if value == terminal { + continue; + } + return Err(Error::TerminalExcluded { + key: key.to_owned(), + layer: layer_words(entry, Some(origin)), + root, + in_project_file: in_project_file(Some(origin)), + }); + } + Ok(()) +} + +/// The keys that another key replaces or duplicates, top-level and under +/// their section (#4038). They are not box settings: [`check_keys`] +/// refuses them in the expanded spec, and [`refuse_unapplied_keys`] in +/// each layer before the fold, with [`unknown_key`]'s hint where one +/// exists. +const REPLACED_KEYS: &[&str] = &[ + "box.type", + "execution.exec", + "install.packages", + "loadouts", + "profile", +]; + +/// The keys that the architecture's `box.toml` specifies and this release +/// does not implement yet, top-level or under their section. Each stays a +/// key of the schema ([`SPEC_KEYS`], [`crate::spec`]'s sections), so the +/// projection and a stored spec are unchanged, and any layer that sets one +/// is refused with exit 3 as not supported yet ([`refuse_unapplied_keys`], +/// #4038). Until a key ships and leaves this list, the user documentation +/// must not describe it as usable. +/// +/// Each key's owner issue is the condition for taking it off this list: +/// `volumes` docs/specs/27-spec-box-volumes; `nesting` gominimal/inbox#568; +/// `file_imports` gominimal/arch#163 and gominimal/inbox#678; +/// `github_imports` #4072; `github_token_mode` #4073; `otel` +/// gominimal/inbox#515; `machine` and `on_oom` gominimal/inbox#698; +/// `restart` gominimal/inbox#678; the `io.*_mimetype` keys #4074; +/// `install.raw_packages` #4075; an entry's `params` gominimal/arch#100. +pub const NOT_SUPPORTED_YET: &[&str] = &[ + "box.volumes", + "execution.on_oom", + "execution.restart", + "file_imports", + "github_imports", + "github_token_mode", + "install.raw_packages", + "io.stderr_mimetype", + "io.stdin_mimetype", + "io.stdout_mimetype", + "machine", + "nesting", + "on_oom", + "otel", + "params", + "restart", + "volumes", +]; + +/// Refuses a key of [`NOT_SUPPORTED_YET`] or [`REPLACED_KEYS`], or an +/// `upstream` from any layer but the top-level `[upstream]` table, in any +/// layer of `ordered`, before the fold, naming the layer that set it. The fold replaces a table whole with +/// a more specific layer's, so `[defaults.execution] restart` under an +/// entry's own `[execution]` table never reaches the expanded spec, and +/// [`check_keys`] alone would not see it (#4038). +fn refuse_unapplied_keys( + entry: &BoxEntry, + ordered: &[(Origin, &toml::Table)], +) -> Result<(), Error> { + for (origin, table) in ordered { + let mut keys: Vec = Vec::new(); + for (key, value) in table.iter() { + keys.push(key.clone()); + if let Some(inner) = value.as_table() { + keys.extend(inner.keys().map(|sub| format!("{key}.{sub}"))); + } + } + keys.sort(); + let refused = keys.into_iter().find_map(|key| { + let problem = if NOT_SUPPORTED_YET.contains(&key.as_str()) { + SpecKeyProblem::NotSupportedYet + } else if REPLACED_KEYS.contains(&key.as_str()) { + unknown_key(&key) + } else if key == "upstream" && origin.layer != Layer::Upstream { + SpecKeyProblem::Unknown + } else { + return None; + }; + Some((key, problem)) + }); + if let Some((key, problem)) = refused { + return Err(Error::InvalidSpecKey { + key, + layer: layer_words(entry, Some(origin)), + problem, + in_project_file: in_project_file(Some(origin)), + }); + } + } + Ok(()) +} + /// Why a service of the Service Library does not fit a box (BOX-241). One /// answer to "can this box take it", for the box's own `uses` and for a /// loadout's services. Each caller decides what to do with a misfit: a loadout @@ -2701,6 +2893,13 @@ pub(crate) const fn value_words(value: &toml::Value) -> &'static str { /// BOX-049, the top-level sections of a Box Spec, and the keys a type's /// defaults set. /// +/// The keys of [`NOT_SUPPORTED_YET`] are here, as the architecture's +/// `box.toml` defines them, and [`refuse_unapplied_keys`] refuses each one +/// in every layer. A key that only duplicates or replaces another, such as +/// a flat `name`, is not here (#4038). `upstream` is here for the +/// top-level `[upstream]` table alone: [`check_keys`] refuses it from any +/// other layer. +/// /// This table is an interim. The interim table goes when /// lands: BOX-076 /// replaces it with the full Box Spec schema. Two more residuals of this @@ -2732,7 +2931,6 @@ const SPEC_KEYS: &[(&str, Shape)] = &[ ("lifecycle_hooks", Shape::List), ("lifetime", Shape::Str), ("loadout_mode", Shape::Str), - ("loadouts", Shape::List), ("machine", Shape::Table), ("name", Shape::Str), ("nesting", Shape::Table), @@ -2743,7 +2941,6 @@ const SPEC_KEYS: &[(&str, Shape)] = &[ ("params", Shape::Table), ("patch", Shape::Table), ("patches", Shape::TableOrList), - ("profile", Shape::Str), ("pty_enabled", Shape::Bool), ("restart", Shape::Str), ("secrets", Shape::Table), @@ -2767,8 +2964,13 @@ fn check_keys(entry: &BoxEntry, expansion: &Expansion) -> Result<(), Error> { for key in keys { let value = &expansion.spec[key.as_str()]; let origin = expansion.report.values.get(key.as_str()); + let from_upstream = origin + .and_then(ValueOrigin::first) + .is_some_and(|o| o.layer == Layer::Upstream); let problem = match SPEC_KEYS.iter().find(|(k, _)| k == key) { - None => SpecKeyProblem::Unknown, + None => unknown_key(key), + // Only the top-level `[upstream]` table sets the registry pin. + Some(_) if key.as_str() == "upstream" && !from_upstream => SpecKeyProblem::Unknown, Some((_, shape)) => match shape.mismatch(value) { None if key.as_str() == "upstream" => { check_upstream(entry, value, origin)?; @@ -2788,10 +2990,14 @@ fn check_keys(entry: &BoxEntry, expansion: &Expansion) -> Result<(), Error> { .and_then(|rest| rest.split('.').next()) .and_then(|sub| expansion.report.network.get(sub)) .or_else(|| origin.and_then(ValueOrigin::first)); + let problem = match bad.problem { + SpecKeyProblem::Unknown => unknown_key(&bad.key), + other => other, + }; return Err(Error::InvalidSpecKey { key: bad.key, layer: layer_words(entry, at), - problem: bad.problem, + problem, in_project_file: in_project_file(at), }); } @@ -2813,6 +3019,32 @@ fn check_keys(entry: &BoxEntry, expansion: &Expansion) -> Result<(), Error> { Ok(()) } +/// The problem with `key`, a dotted path that is not a box setting: a hint +/// that names the key's replacement, for a key that a release or a +/// committed `minimal.toml` used (#4038), else [`SpecKeyProblem::Unknown`]. +fn unknown_key(key: &str) -> SpecKeyProblem { + let hint = match key { + "profile" => { + "Profiles were removed. Remove `profile`, and list the packages \ + the box needs in `packages` of the same table." + } + "install.packages" => { + "An entry's packages are its `packages` key. Move the list to \ + `packages` in the same table." + } + "execution.exec" => { + "A task entry's command is its `exec` key. Move the value to \ + `exec` in the same table." + } + "box.type" => { + "An entry's Box Type is its `type` key. Move the value to `type` \ + in the same table." + } + _ => return SpecKeyProblem::Unknown, + }; + SpecKeyProblem::Removed { hint } +} + /// The keys of an `[upstream]` table, the registry pin. Each takes a /// string. const UPSTREAM_KEYS: &[&str] = &["branch", "build_cache_url", "commit", "repo_url"]; @@ -2978,12 +3210,12 @@ mod tests { [defaults] packages = ["git", "ripgrep"] timeout = "2h" - machine = { cpus = 2, memory = "4G" } + execution = { timeout = 2, hooks_on_resume = true } [defaults.session] packages = ["helix", "git"] timeout = "8h" - machine = { cpus = 4 } + execution = { timeout = 4 } [sessions.dev] packages = ["fish"] @@ -2998,8 +3230,11 @@ mod tests { ["git", "ripgrep", "helix", "fish"] ); assert_eq!(dev.spec["timeout"].as_str(), Some("8h")); - // The more specific table replaces the whole table: no `memory`. - assert_eq!(dev.spec["machine"], toml::Value::Table(table("cpus = 4"))); + // The more specific table replaces the whole table: no `hooks_on_resume`. + assert_eq!( + dev.spec["execution"], + toml::Value::Table(table("timeout = 4")) + ); assert_eq!(dev.spec["type"].as_str(), Some("session")); // A task gets `[defaults]` but not `[defaults.session]`. @@ -3007,8 +3242,8 @@ mod tests { assert_eq!(strings(lint.spec.get("packages")), ["git", "ripgrep"]); assert_eq!(lint.spec["timeout"].as_str(), Some("2h")); assert_eq!( - lint.spec["machine"], - toml::Value::Table(table("cpus = 2\nmemory = \"4G\"")) + lint.spec["execution"], + toml::Value::Table(table("timeout = 2\nhooks_on_resume = true")) ); assert!(!lint.spec.contains_key("session"), "{:?}", lint.spec); assert_eq!(strings(lint.spec.get("exec")), ["cargo", "clippy"]); @@ -3266,7 +3501,7 @@ mod tests { [defaults] packages = ["d"] timeout = "1s" - machine = { cpus = 3 } + execution = { timeout = 3 } [defaults.session] packages = ["ds"] @@ -3287,7 +3522,7 @@ mod tests { ), ( "session".to_owned(), - table("packages = [\"u\"]\ntimeout = \"4s\"\npty_enabled = false"), + table("packages = [\"u\"]\ntimeout = \"4s\"\nexec_enabled = false"), ), ( "rust-dev".to_owned(), @@ -3299,7 +3534,7 @@ mod tests { ), ], loadouts: one(table("packages = [\"l\", \"u\"]\ntimeout = \"7s\"")), - overrides: table("timeout = \"8s\"\nmachine = { memory = \"1G\" }"), + overrides: table("timeout = \"8s\"\nexecution = { hooks_on_resume = true }"), ..Layers::default() }; let all = expand_in(file, "dev", layers()).expect("expands"); @@ -3309,10 +3544,10 @@ mod tests { ); assert_eq!(all.spec["timeout"].as_str(), Some("8s")); assert_eq!( - all.spec["machine"], - toml::Value::Table(table("memory = \"1G\"")) + all.spec["execution"], + toml::Value::Table(table("hooks_on_resume = true")) ); - assert_eq!(all.spec["pty_enabled"].as_bool(), Some(false)); + assert_eq!(all.spec["exec_enabled"].as_bool(), Some(false)); // The `[upstream]` layer is the registry pin: the spec's one // `upstream` table, as minimal.toml writes it. assert_eq!( @@ -3331,7 +3566,10 @@ mod tests { l.overrides = toml::Table::new(); let e = expand_in(file, "dev", l.clone()).expect("expands"); assert_eq!(e.spec["timeout"].as_str(), Some("7s")); - assert_eq!(e.spec["machine"], toml::Value::Table(table("cpus = 3"))); + assert_eq!( + e.spec["execution"], + toml::Value::Table(table("timeout = 3")) + ); l.loadouts = one(toml::Table::new()); let e = expand_in(file, "dev", l.clone()).expect("expands"); assert_eq!(e.spec["timeout"].as_str(), Some("3s")); @@ -3397,7 +3635,7 @@ mod tests { [defaults.session] packages = ["helix"] - machine = { memory = "4G", cpus = 2 } + execution = { hooks_on_resume = true, timeout = 2 } [sessions.dev] packages = ["fish", "git"] @@ -3654,9 +3892,9 @@ mod tests { timeout = "30m" type = "session" - [machine] - cpus = 2 - memory = "4G" + [execution] + hooks_on_resume = true + timeout = 2 [network] mode = "own_ip" @@ -3691,14 +3929,17 @@ mod tests { packages.clone(), packages.clone(), proptest::option::of("[0-9]{1,2}h"), - proptest::option::of(any::()), + // A session always has a terminal (BOX-160). + proptest::option::of(Just(true)), proptest::option::of(1u8..16), ) .prop_map(|(defaults, entry, timeout, pty, cpus)| { let list = |p: &[String]| format!("{p:?}"); let mut file = format!("[defaults]\npackages = {}\n", list(&defaults)); if let Some(cpus) = cpus { - file.push_str(&format!("machine = {{ cpus = {cpus}, memory = \"2G\" }}\n")); + file.push_str(&format!( + "execution = {{ timeout = {cpus}, hooks_on_resume = true }}\n" + )); } file.push_str(&format!("[sessions.dev]\npackages = {}\n", list(&entry))); if let Some(t) = timeout { @@ -3805,19 +4046,17 @@ mod tests { ( "[sessions.dev]\nupstream = { colour = \"red\" }\n", Layers::default(), - "`[sessions.dev]` in minimal.toml sets `upstream.colour`, which is \ - not an `[upstream]` setting. The `[upstream]` settings are \ - `repo_url`, `branch`, `commit` and `build_cache_url`. Remove the \ - key or correct its name.", + "`[sessions.dev]` in minimal.toml sets `upstream`, which is not a \ + box setting. Remove the key or correct its name.", ), ( "[tasks.lint]\nexec = \"cargo clippy\"\n", Layers { - overrides: table("machine = 4"), + overrides: table("execution = 4"), ..Layers::default() }, - "a command-line flag sets `machine` to a whole number, but \ - `machine` takes a table. Fix the value.", + "a command-line flag sets `execution` to a whole number, but \ + `execution` takes a table. Fix the value.", ), ]; for (file, layers, message) in cases { @@ -3856,18 +4095,15 @@ mod tests { // Every key a built-in type's defaults set, and the Box Spec // sections an entry can set, are box settings. let ok = expand_in( - "[sessions.dev]\nio = { stdin_mimetype = \"text/plain\" }\n\ - [[sessions.dev.file_imports]]\nsrc = \"a\"\ndst = \"/a\"\n\ + "[sessions.dev]\nio = { exec_enabled = true }\n\ + box = { name = \"web\", lifetime = \"until_stopped\" }\n\ + execution = { hooks_on_resume = true, timeout = \"1h\" }\n\ [sessions.dev.env_vars]\nmy_var = \"1\"\n", "dev", Layers { type_defaults: vec![( "session".to_owned(), - table( - "loadout_mode = \"open\"\nexec_enabled = true\n\ - restart = \"never\"\ngithub_token_mode = \"none\"\n\ - nesting = { allowed = true }", - ), + table("loadout_mode = \"open\"\nexec_enabled = true"), )], ..Layers::default() }, @@ -3875,6 +4111,462 @@ mod tests { assert!(ok.is_ok(), "{ok:?}"); } + // #4067: an entry's flat `name` is the box's written name, as the + // architecture's example writes it. The expansion moves it to + // `box.name`. The same value in both keys is kept, and two different + // values are refused with exit 3, naming each key and its layer. + #[test] + fn flat_name_folds_into_box_name() { + let e = expand_in( + "[sessions.dev]\nname = \"docs-preview\"\n", + "dev", + Layers::default(), + ) + .expect("a flat name expands"); + assert!(!e.spec.contains_key("name"), "{:?}", e.spec); + assert_eq!(e.spec["box"]["name"].as_str(), Some("docs-preview")); + assert_eq!( + e.report.values["box"], + ValueOrigin::Value(Origin::of(Layer::Entry)) + ); + let bytes = e.spec_bytes().expect("writes"); + assert!(bytes.contains("[box]\nname = \"docs-preview\""), "{bytes}"); + + // With other `[box]` keys, and the same value in both keys. + let e = expand_in( + "[defaults]\nname = \"web\"\n\ + [sessions.dev]\nbox = { name = \"web\", lifetime = \"until_stopped\" }\n", + "dev", + Layers::default(), + ) + .expect("one value in both keys expands"); + assert_eq!(e.spec["box"]["name"].as_str(), Some("web")); + assert_eq!(e.spec["box"]["lifetime"].as_str(), Some("until_stopped")); + assert!(!e.spec.contains_key("name")); + + let err = expand_in( + "[defaults]\nname = \"web\"\n[sessions.dev]\nbox = { name = \"api\" }\n", + "dev", + Layers::default(), + ) + .expect_err("two names are refused"); + assert_eq!(err.exit_code(), Some(3)); + assert!(err.is_in_project_file()); + assert_eq!( + err.to_string(), + "`[defaults]` in minimal.toml sets `name` to \"web\", and `[sessions.dev]` \ + in minimal.toml sets `box.name` to \"api\". Both set the box's name. Remove \ + one of them, or give them the same value." + ); + + // A name that is not a string is refused by its shape. + let err = expand_in("[sessions.dev]\nname = 5\n", "dev", Layers::default()) + .expect_err("not a string"); + assert_eq!( + err.to_string(), + "`[sessions.dev]` in minimal.toml sets `name` to a whole number, but \ + `name` takes a string. Fix the value." + ); + } + + // BOX-160, #4044: `pty_enabled`, flat or under `[io]`, follows the + // entry's built-in root. A session-rooted entry that sets `false`, or a + // task-rooted one that sets `true`, is refused with exit 3, naming the + // key, the layer that set it and the root. The root's own value passes. + #[test] + fn pty_enabled_against_built_in_root_exit3() { + const TYPES: &str = "[box_types.dev]\nextends = \"session\"\n\ + [box_types.ci]\nextends = \"task\"\n"; + let session = "A session always has a terminal. Remove"; + let task = "A task never has a terminal. Remove"; + for (setting, key) in [ + ("pty_enabled = {v}", "pty_enabled"), + ("io = {{ pty_enabled = {v} }}", "io.pty_enabled"), + ] { + let set = |v: bool| { + setting + .replace("{v}", &v.to_string()) + .replace("{{", "{") + .replace("}}", "}") + }; + // (file, entry, layer, root, refused value) + let cases = [ + ( + format!("[sessions.dev]\n{}\n", set(false)), + "dev", + "`[sessions.dev]`", + "session", + false, + ), + ( + format!("[defaults.session]\n{}\n[sessions.dev]\n", set(false)), + "dev", + "`[defaults.session]`", + "session", + false, + ), + ( + format!("{TYPES}[boxes.web]\ntype = \"dev\"\n{}\n", set(false)), + "web", + "`[boxes.web]`", + "session", + false, + ), + ( + format!("[tasks.lint]\nexec = \"x\"\n{}\n", set(true)), + "lint", + "`[tasks.lint]`", + "task", + true, + ), + ( + format!("[defaults]\n{}\n[tasks.lint]\nexec = \"x\"\n", set(true)), + "lint", + "`[defaults]`", + "task", + true, + ), + ( + format!( + "{TYPES}[boxes.check]\ntype = \"ci\"\nexec = \"x\"\n{}\n", + set(true) + ), + "check", + "`[boxes.check]`", + "task", + true, + ), + ]; + for (file, name, layer, root, value) in cases { + let err = expand_in(&file, name, Layers::default()).expect_err(&file); + assert_eq!(err.exit_code(), Some(3), "{err}"); + assert!(err.is_in_project_file(), "{err}"); + let (has, fix) = if root == "task" { + (task, "false") + } else { + (session, "true") + }; + assert_eq!( + err.to_string(), + format!( + "{layer} in minimal.toml sets `{key}` to `{value}`, but the entry's \ + built-in type is `{root}`. {has} `{key}`, or set it to `{fix}`." + ), + "{file}" + ); + // The root's own value is accepted. + let ok = file.replace(&set(value), &set(!value)); + expand_in(&ok, name, Layers::default()).unwrap_or_else(|e| panic!("{ok}: {e}")); + } + } + // A more specific layer's `io` table replaces the lower one whole, + // so the lower `io.pty_enabled` is not in the expanded spec. It is + // refused in the layer that set it all the same. + for (file, name, layer, root, value) in [ + ( + "[defaults.io]\npty_enabled = false\n[sessions.dev.io]\nexec_enabled = true\n", + "dev", + "`[defaults]`", + "session", + false, + ), + ( + "[defaults.task.io]\npty_enabled = true\n\ + [tasks.lint]\nexec = \"x\"\nio = { exec_enabled = true }\n", + "lint", + "`[defaults.task]`", + "task", + true, + ), + ] { + let err = expand_in(file, name, Layers::default()).expect_err(file); + assert!(matches!(err, Error::TerminalExcluded { .. }), "{err:?}"); + let (has, fix) = if root == "task" { + (task, "false") + } else { + (session, "true") + }; + assert_eq!( + err.to_string(), + format!( + "{layer} in minimal.toml sets `io.pty_enabled` to `{value}`, but the \ + entry's built-in type is `{root}`. {has} `io.pty_enabled`, or set it \ + to `{fix}`." + ), + "{file}" + ); + } + // A malformed value does not hide a lower excluded one (CodeRabbit + // on #4067). + let err = expand_in( + "[defaults.io]\npty_enabled = false\n\ + [defaults.session.io]\npty_enabled = \"yes\"\n\ + [sessions.dev.io]\nexec_enabled = true\n", + "dev", + Layers::default(), + ) + .expect_err("the lower false is refused"); + assert_eq!( + err.to_string(), + format!( + "`[defaults]` in minimal.toml sets `io.pty_enabled` to `false`, but the \ + entry's built-in type is `session`. {session} `io.pty_enabled`, or set it \ + to `true`." + ) + ); + // A malformed value the fold keeps is refused by its shape. + let err = expand_in( + "[sessions.dev.io]\npty_enabled = \"yes\"\n", + "dev", + Layers::default(), + ) + .expect_err("a malformed value is refused"); + assert!( + matches!(&err, Error::InvalidSpecKey { key, .. } if key == "io.pty_enabled"), + "{err:?}" + ); + // A later layer that sets the root's own value overrides. + expand_in( + "[defaults.io]\npty_enabled = false\n[sessions.dev.io]\npty_enabled = true\n", + "dev", + Layers::default(), + ) + .expect("the entry's own value overrides"); + + // A type's defaults are named as their layer. + let err = expand_in( + "[sessions.dev]\n", + "dev", + Layers { + type_defaults: vec![("dev".to_owned(), table("pty_enabled = false"))], + ..Layers::default() + }, + ) + .expect_err("a session type's default cannot drop the terminal"); + assert_eq!( + err.to_string(), + "the `defaults` table of `[box_types.dev]` sets `pty_enabled` to `false`, but the entry's \ + built-in type is `session`. A session always has a terminal. Remove \ + `pty_enabled`, or set it to `true`." + ); + } + + // #4038: a key that the architecture's `box.toml` specifies and this + // release does not implement yet is refused as not supported yet, flat + // or under its section, in every layer and for every root. A key that + // another key replaces is not a box setting, with a hint where one + // exists. A more specific layer's table that replaces a lower one whole + // does not hide a refused key: it is refused in the layer that set it. + #[test] + fn unimplemented_keys_exit3_not_a_box_setting() { + let not_yet = |key: &str| { + format!("which this release does not support yet. Remove `{key}` to start the box.") + }; + let replaced = |hint: &str| format!("which is not a box setting. {hint}"); + let generic = "Remove the key or correct its name."; + let cases: Vec<(&str, &str, String)> = vec![ + ("volumes = [\"dev\"]", "volumes", not_yet("volumes")), + ( + "box = { volumes = [\"dev\"] }", + "box.volumes", + not_yet("box.volumes"), + ), + ( + "file_imports = [{ path = \"a\" }]", + "file_imports", + not_yet("file_imports"), + ), + ( + "github_imports = [{ repo = \"r\" }]", + "github_imports", + not_yet("github_imports"), + ), + ( + "nesting = { allowed = true }", + "nesting", + not_yet("nesting"), + ), + ( + "github_token_mode = \"user\"", + "github_token_mode", + not_yet("github_token_mode"), + ), + ("otel = { enabled = true }", "otel", not_yet("otel")), + ("machine = { cpus = 2 }", "machine", not_yet("machine")), + ("on_oom = \"kill\"", "on_oom", not_yet("on_oom")), + ( + "execution = { on_oom = \"kill\" }", + "execution.on_oom", + not_yet("execution.on_oom"), + ), + ("restart = \"never\"", "restart", not_yet("restart")), + ( + "execution = { restart = \"never\" }", + "execution.restart", + not_yet("execution.restart"), + ), + ( + "params = { mode = { default = \"x\" } }", + "params", + not_yet("params"), + ), + ( + "install = { raw_packages = [\"a\"] }", + "install.raw_packages", + not_yet("install.raw_packages"), + ), + ( + "io = { stdin_mimetype = \"text/plain\" }", + "io.stdin_mimetype", + not_yet("io.stdin_mimetype"), + ), + ( + "io = { stdout_mimetype = \"text/plain\" }", + "io.stdout_mimetype", + not_yet("io.stdout_mimetype"), + ), + ( + "io = { stderr_mimetype = \"text/plain\" }", + "io.stderr_mimetype", + not_yet("io.stderr_mimetype"), + ), + ( + "profile = \"dev\"", + "profile", + replaced( + "Profiles were removed. Remove `profile`, and list the packages \ + the box needs in `packages` of the same table.", + ), + ), + ( + "install = { packages = [\"git\"] }", + "install.packages", + replaced( + "An entry's packages are its `packages` key. Move the list to \ + `packages` in the same table.", + ), + ), + ( + "box = { type = \"session\" }", + "box.type", + replaced( + "An entry's Box Type is its `type` key. Move the value to `type` \ + in the same table.", + ), + ), + ("loadouts = [\"ed\"]", "loadouts", replaced(generic)), + ( + "execution = { exec = \"x\" }", + "execution.exec", + replaced( + "A task entry's command is its `exec` key. Move the value to \ + `exec` in the same table.", + ), + ), + ]; + for (setting, key, tail) in &cases { + for (file, name, layer) in [ + ( + format!("[sessions.dev]\n{setting}\n"), + "dev", + "[sessions.dev]", + ), + ( + format!("[tasks.lint]\nexec = \"x\"\n{setting}\n"), + "lint", + "[tasks.lint]", + ), + ( + format!("[defaults]\n{setting}\n[sessions.dev]\n"), + "dev", + "[defaults]", + ), + ( + format!("[defaults.task]\n{setting}\n[tasks.lint]\nexec = \"x\"\n"), + "lint", + "[defaults.task]", + ), + ] { + let err = expand_in(&file, name, Layers::default()).expect_err(&file); + assert_eq!(err.exit_code(), Some(3), "{err}"); + assert_eq!( + err.to_string(), + format!("`{layer}` in minimal.toml sets `{key}`, {tail}"), + "{file}" + ); + } + } + for (file, name, layer, key, tail) in [ + ( + "[defaults.execution]\nrestart = \"always\"\n\ + [sessions.dev.execution]\ntimeout = \"1h\"\n", + "dev", + "[defaults]", + "execution.restart", + not_yet("execution.restart"), + ), + ( + "[defaults.session.box]\nloadout_mode = \"open\"\nvolumes = [\"dev\"]\n\ + [sessions.dev.box]\nname = \"web\"\n", + "dev", + "[defaults.session]", + "box.volumes", + not_yet("box.volumes"), + ), + ( + "[defaults.task.io]\nstdin_mimetype = \"text/plain\"\n\ + [tasks.lint]\nexec = \"x\"\nio = { exec_enabled = true }\n", + "lint", + "[defaults.task]", + "io.stdin_mimetype", + not_yet("io.stdin_mimetype"), + ), + ( + "[defaults.execution]\nexec = \"x\"\n\ + [tasks.lint]\nexec = \"x\"\nexecution = { timeout = 5 }\n", + "lint", + "[defaults]", + "execution.exec", + replaced( + "A task entry's command is its `exec` key. Move the value to \ + `exec` in the same table.", + ), + ), + ] { + let err = expand_in(file, name, Layers::default()).expect_err(file); + assert_eq!(err.exit_code(), Some(3), "{err}"); + assert_eq!( + err.to_string(), + format!("`{layer}` in minimal.toml sets `{key}`, {tail}"), + "{file}" + ); + } + // A supported key that a more specific table replaces still does. + let e = expand_in( + "[defaults.execution]\ntimeout = \"2h\"\n\ + [sessions.dev.execution]\nhooks_on_resume = true\n", + "dev", + Layers::default(), + ) + .expect("a replaced supported key expands"); + assert_eq!( + e.spec["execution"], + toml::Value::Table(table("hooks_on_resume = true")) + ); + // `upstream` is the top-level `[upstream]` table's alone. + let err = expand_in( + "[defaults]\nupstream = { commit = \"abc\" }\n[sessions.dev]\n", + "dev", + Layers::default(), + ) + .expect_err("a layer cannot set the registry pin"); + assert_eq!( + err.to_string(), + "`[defaults]` in minimal.toml sets `upstream`, which is not a box \ + setting. Remove the key or correct its name." + ); + } + // BOX-065: a project's client sections are left out of the spec and // listed for the caller to warn, never refused. #[test] @@ -3927,7 +4619,7 @@ mod tests { }; assert_eq!(value("upstream"), Origin::of(Layer::Upstream)); assert_eq!(value("lifetime"), Origin::type_defaults("session")); - assert_eq!(value("machine"), Origin::of(Layer::DefaultsType)); + assert_eq!(value("execution"), Origin::of(Layer::DefaultsType)); assert_eq!(value("network"), Origin::of(Layer::Entry)); assert_eq!(value("pty_enabled"), Origin::of(Layer::Entry)); assert_eq!(value("timeout"), Origin::of(Layer::Overrides)); @@ -4389,36 +5081,36 @@ mod tests { [box_types.ci] extends = "task" defaults = { packages = ["git"] } - constraints = { pty_enabled = false, restart = ["never", "on-failure"], network = { mode = "none" } } + constraints = { exec_enabled = false, state_key = ["never", "on-failure"], network = { mode = "none" } } [box_types.ci-small] extends = "ci" - constraints = { packages = ["git", "make"], restart = "never" } + constraints = { packages = ["git", "make"], state_key = "never", lifetime = "until_complete" } [defaults.ci] - restart = "always" + state_key = "always" [boxes.ok] type = "ci-small" packages = ["make"] - restart = "never" + state_key = "never" network = { mode = "none" } [boxes.pty] type = "ci" - pty_enabled = true + exec_enabled = true [boxes.from-defaults] type = "ci" [boxes.extra] type = "ci-small" - restart = "never" + state_key = "never" packages = ["curl"] [boxes.small-always] type = "ci-small" - restart = "always" + state_key = "always" "#; // BOX-061: the expanded spec is checked against the type's constraints @@ -4431,20 +5123,20 @@ mod tests { // The entry's own table. let (_, checked) = expand_checked(CONSTRAINED_FILE, "pty", "", ""); - let err = checked.expect_err("pty_enabled = true is outside the type"); + let err = checked.expect_err("exec_enabled = true is outside the type"); assert_eq!(err.exit_code(), 3); assert_eq!( err.to_string(), - "`[boxes.pty]` in minimal.toml sets `pty_enabled` to `true`. \ - `[box_types.ci]` allows only `false` for `pty_enabled`. Change the value." + "`[boxes.pty]` in minimal.toml sets `exec_enabled` to `true`. \ + `[box_types.ci]` allows only `false` for `exec_enabled`. Change the value." ); // `[defaults.]`. let (_, checked) = expand_checked(CONSTRAINED_FILE, "from-defaults", "", ""); assert_eq!( - checked.expect_err("restart = always").to_string(), - "`[defaults.ci]` in minimal.toml sets `restart` to `\"always\"`. \ - `[box_types.ci]` allows only `\"never\"` or `\"on-failure\"` for `restart`. \ + checked.expect_err("state_key = always").to_string(), + "`[defaults.ci]` in minimal.toml sets `state_key` to `\"always\"`. \ + `[box_types.ci]` allows only `\"never\"` or `\"on-failure\"` for `state_key`. \ Change the value." ); @@ -4462,9 +5154,9 @@ mod tests { // constraint is checked first. let (_, checked) = expand_checked(CONSTRAINED_FILE, "small-always", "", ""); assert_eq!( - checked.expect_err("restart = always").to_string(), - "`[boxes.small-always]` in minimal.toml sets `restart` to `\"always\"`. \ - `[box_types.ci-small]` allows only `\"never\"` for `restart`. \ + checked.expect_err("state_key = always").to_string(), + "`[boxes.small-always]` in minimal.toml sets `state_key` to `\"always\"`. \ + `[box_types.ci-small]` allows only `\"never\"` for `state_key`. \ Change the value." ); @@ -4482,14 +5174,18 @@ mod tests { // The check runs after the override layer: an override can break a // constraint, and an override can repair a value an earlier layer // set. - let (_, checked) = expand_checked(CONSTRAINED_FILE, "ok", "", "pty_enabled = true"); + let (_, checked) = expand_checked(CONSTRAINED_FILE, "ok", "", "exec_enabled = true"); let msg = checked.expect_err("override breaks").to_string(); assert!( - msg.starts_with("a command-line flag sets `pty_enabled`"), + msg.starts_with("a command-line flag sets `exec_enabled`"), "{msg}" ); - let (_, checked) = - expand_checked(CONSTRAINED_FILE, "from-defaults", "", "restart = \"never\""); + let (_, checked) = expand_checked( + CONSTRAINED_FILE, + "from-defaults", + "", + "state_key = \"never\"", + ); checked.expect("the override sets an allowed value last"); // A selected loadout is named as its layer. A `task`-rooted entry @@ -4507,14 +5203,14 @@ mod tests { // A setting under its section is checked as the flat key is. for (setting, key, value, allowed) in [ ( - "execution = { restart = \"always\" }", - "execution.restart", - "\"always\"", - "`[box_types.ci-small]` allows only `\"never\"`", + "box = { lifetime = \"until_stopped\" }", + "box.lifetime", + "\"until_stopped\"", + "`[box_types.ci-small]` allows only `\"until_complete\"`", ), ( - "io = { pty_enabled = true }", - "io.pty_enabled", + "io = { exec_enabled = true }", + "io.exec_enabled", "true", "`[box_types.ci]` allows only `false`", ), @@ -4539,35 +5235,29 @@ mod tests { let file = r#" [box_types.ci-io] extends = "task" - constraints = { io = { pty_enabled = false }, install = { packages = ["git"] } } + constraints = { io = { exec_enabled = false }, box = { lifetime = "until_complete" } } [boxes.x] type = "ci-io" - pty_enabled = true + exec_enabled = true "#; let (_, checked) = expand_checked(file, "x", "", ""); assert_eq!( - checked.expect_err("flat pty_enabled").to_string(), - "`[boxes.x]` in minimal.toml sets `pty_enabled` to `true`. \ - `[box_types.ci-io]` allows only `false` for `pty_enabled`. Change the value." + checked.expect_err("flat exec_enabled").to_string(), + "`[boxes.x]` in minimal.toml sets `exec_enabled` to `true`. \ + `[box_types.ci-io]` allows only `false` for `exec_enabled`. Change the value." ); - let (_, checked) = - expand_checked(file, "x", "", "pty_enabled = false\npackages = [\"jq\"]"); - assert_eq!( - checked.expect_err("flat packages").to_string(), - "a command-line flag adds `\"jq\"` to `packages`. \ - `[box_types.ci-io]` allows only `\"git\"` in `packages`. Change the value." + let (_, checked) = expand_checked( + file, + "x", + "", + "exec_enabled = false\nlifetime = \"until_stopped\"", ); - - // A built-in type ships its own constraints: a task has no PTY. - let file = "[tasks.x]\npty_enabled = true\n"; - let (_, checked) = expand_checked(file, "x", "", ""); - let err = checked.expect_err("a task with a PTY"); - assert_eq!(err.exit_code(), 3); assert_eq!( - err.to_string(), - "`[tasks.x]` in minimal.toml sets `pty_enabled` to `true`. \ - The built-in type `task` allows only `false` for `pty_enabled`. Change the value." + checked.expect_err("flat lifetime").to_string(), + "a command-line flag sets `lifetime` to `\"until_stopped\"`. \ + `[box_types.ci-io]` allows only `\"until_complete\"` for `lifetime`. \ + Change the value." ); } @@ -4595,11 +5285,11 @@ mod tests { layer_values in prop::collection::vec(prop::option::of(small_value()), 4), ) { let mut file = format!( - "[box_types.outer]\nextends = \"session\"\nconstraints = {{ restart = {outer} }}\n\ - [box_types.inner]\nextends = \"outer\"\nconstraints = {{ restart = {constraint} }}\n" + "[box_types.outer]\nextends = \"session\"\nconstraints = {{ state_key = {outer} }}\n\ + [box_types.inner]\nextends = \"outer\"\nconstraints = {{ state_key = {constraint} }}\n" ); let set = |v: &Option| { - v.as_ref().map(|v| format!("restart = {v}\n")).unwrap_or_default() + v.as_ref().map(|v| format!("state_key = {v}\n")).unwrap_or_default() }; file.push_str(&format!("[defaults.inner]\n{}", set(&layer_values[0]))); file.push_str(&format!("[boxes.dev]\ntype = \"inner\"\n{}", set(&layer_values[1]))); @@ -4608,7 +5298,7 @@ mod tests { prop_assume!(BoxTypes::from_file(&doc).is_ok()); let (expansion, checked) = expand_checked(&file, "dev", &set(&layer_values[2]), &set(&layer_values[3])); - let inside = expansion.spec.get("restart").is_none_or(|v| { + let inside = expansion.spec.get("state_key").is_none_or(|v| { crate::box_types::admitted(&constraint).contains(v) && crate::box_types::admitted(&outer).contains(v) }); @@ -4623,7 +5313,7 @@ mod tests { "the loadout `l`", "a command-line flag", ][layer]; - prop_assert!(msg.starts_with(&format!("{words} sets `restart`")), "{}", msg); + prop_assert!(msg.starts_with(&format!("{words} sets `state_key`")), "{}", msg); prop_assert!(msg.contains("`[box_types.inner]`"), "{}", msg); } } @@ -6055,7 +6745,6 @@ mod tests { const GRANTS_FILE: &str = r#" [box_types.release] extends = "task" - defaults = { github_token_mode = "installation" } [sessions.dev.secrets.GH] source = "broker" @@ -6086,8 +6775,8 @@ mod tests { "#; // BOX-071: before the projection is canonicalised, each `github:*` - // grant's omitted `mode` is filled from the type's - // `github_token_mode`, an omitted `network.quic443` with `auto` and an + // grant's omitted `mode` is filled from the token mode of the type's + // built-in root, an omitted `network.quic443` with `auto` and an // omitted `bep.steering` with `dns`, so the digest binds the effective // values. A value the spec sets is kept. The spec bytes keep only what // a layer set. @@ -6148,8 +6837,8 @@ mod tests { let (_, ship, _) = projected("ship"); assert_eq!( mode(&ship, "GH"), - s("installation"), - "the type's token mode" + s("user"), + "the token mode of the type's built-in root" ); let (_, set, _) = projected("set"); assert_eq!(mode(&set, "GH"), s("installation")); diff --git a/crates/mfile/src/legacy.rs b/crates/mfile/src/legacy.rs index db57fb2d1c..fb0069a01a 100644 --- a/crates/mfile/src/legacy.rs +++ b/crates/mfile/src/legacy.rs @@ -4,8 +4,8 @@ //! layout moves: //! //! - a top-level `[session]` table, now `[defaults.session]` (BOX-050); -//! - `state_key` and `profile` under top-level `[defaults]`, now under -//! `[defaults.task]` (BOX-051); +//! - `state_key` under top-level `[defaults]`, now under `[defaults.task]` +//! (BOX-051); //! - a top-level `[params]` parameter schema, now `[args]` (BOX-052). //! //! Releases before [`REFUSING_RELEASE`] read each one as its new location and @@ -49,9 +49,9 @@ pub fn this_release() -> &'static str { pub enum LegacyTable { /// A top-level `[session]` table (BOX-050). Session, - /// `state_key` or `profile`, or both, under top-level `[defaults]` - /// (BOX-051). - DefaultsTaskKeys { state_key: bool, profile: bool }, + /// `state_key` under top-level `[defaults]` (BOX-051). A `profile` + /// there is not read: the expansion refuses it (#4038). + DefaultsStateKey, /// A top-level `[params]` parameter schema (BOX-052). Params, /// `vars` or `vars_lenient`, the variable keys of 0.7, in a layer of @@ -71,9 +71,7 @@ impl LegacyTable { pub fn what(&self) -> String { match self { LegacyTable::Session => "the `[session]` table".to_owned(), - LegacyTable::DefaultsTaskKeys { .. } => { - format!("{} under `[defaults]`", self.keys()) - } + LegacyTable::DefaultsStateKey => "`state_key` under `[defaults]`".to_owned(), LegacyTable::Params => "the `[params]` table".to_owned(), LegacyTable::VarKey { key, @@ -105,18 +103,6 @@ impl LegacyTable { } } - /// The keys of [`LegacyTable::DefaultsTaskKeys`], as the text names them. - fn keys(&self) -> &'static str { - match self { - LegacyTable::DefaultsTaskKeys { - state_key: true, - profile: true, - } => "`state_key` and `profile`", - LegacyTable::DefaultsTaskKeys { profile: true, .. } => "`profile`", - _ => "`state_key`", - } - } - /// The hint: the change to make, and the release that stops reading /// the old spelling. The same text goes to stderr during the grace /// window and into the exit-3 refusal after it. @@ -129,24 +115,11 @@ impl LegacyTable { "Rename `[session]` to `[defaults.session]` in minimal.toml. \ Release {refusing} and later refuse `[session]`." ), - LegacyTable::DefaultsTaskKeys { state_key, profile } => { - let keys = self.keys(); - let them = if *state_key && *profile { - "these keys" - } else { - "it" - }; - let deprecated = if *profile { - " `profile` is deprecated." - } else { - "" - }; - format!( - "Move {keys} from `[defaults]` to `[defaults.task]` in \ - minimal.toml.{deprecated} Release {refusing} and later refuse \ - {them} under `[defaults]`." - ) - } + LegacyTable::DefaultsStateKey => format!( + "Move `state_key` from `[defaults]` to `[defaults.task]` in \ + minimal.toml. Release {refusing} and later refuse it under \ + `[defaults]`." + ), LegacyTable::Params => format!( "Rename `[params]` to `[args]` in minimal.toml. \ Release {refusing} and later refuse `[params]`." @@ -251,8 +224,9 @@ fn merge_under(old: toml::Table, new: &mut toml::Table) { /// Rewrites a raw `minimal.toml` document to the Box Spec layout, for the /// entry expansion: `[session]` becomes `[defaults.session]`, `state_key` -/// and `profile` under `[defaults]` move to `[defaults.task]`, and -/// `[params]` becomes `[args]`. A task entry's own `args` is not touched. +/// under `[defaults]` moves to `[defaults.task]`, and `[params]` becomes +/// `[args]`. A `profile` under `[defaults]` stays there, where the +/// expansion refuses it with a hint (#4038). A task entry's own `args` is not touched. /// /// Returns one [`LegacyTable`] for each legacy table it read. The caller /// prints each one, on every read. @@ -273,9 +247,9 @@ pub fn canonicalize(doc: &mut toml::Table, release: &str) -> Result Result, the task that makes - /// the daemon end the box at its timeout (BOX-037). + /// `minimald` reads it: an `until_complete` box that runs past its + /// timeout ends with `reason = "timeout"` (`timeout_of`, + /// `BoxActor::end_on_timeout`, BOX-037). An `until_stopped` box runs + /// past it. pub timeout: Option, /// The box's network settings. pub network: SpecNetwork, @@ -313,7 +315,7 @@ impl BoxSpec { /// A setting that the expansion keeps both flat and under its section /// takes the form that the later layer set. Within the type chain's /// defaults, the more derived type is the later layer. The packages - /// take both lists, in that order, without duplicates. + /// are the expanded `packages`, each once. #[must_use] pub fn for_session_entry( entry: &str, @@ -323,7 +325,7 @@ impl BoxSpec { flags: SpecFlags, ) -> Self { let ranking = Ranking { report, type_chain }; - let packages = layered_packages(expanded, ranking); + let packages = expanded_packages(expanded); let mut spec = Self::build( boxes::SESSION_BOX_TYPE, entry, @@ -584,48 +586,16 @@ impl Ranking<'_> { } } -/// The expanded spec's packages: the flat `packages` and the -/// `install.packages` of its `[install]` section, merged in the order of -/// the origins that set them, without duplicates. The fold already unions -/// each form across its layers, and the report keeps the origin of each -/// flat item and of the `install` table. -fn layered_packages(expanded: &toml::Table, ranking: Ranking<'_>) -> Vec { - let strings = |value: Option<&toml::Value>| -> Vec { - value - .and_then(toml::Value::as_array) - .into_iter() - .flatten() - .filter_map(toml::Value::as_str) - .map(str::to_owned) - .collect() - }; - let flat = strings(expanded.get("packages")); - let flat_layers: Vec> = match ranking.report.values.get("packages") { - Some(ValueOrigin::List(origins)) => origins.iter().map(|o| Some(ranking.of(o))).collect(), - Some(ValueOrigin::Value(o)) => vec![Some(ranking.of(o)); flat.len()], - None => Vec::new(), - }; - let nested = strings( - expanded - .get("install") - .and_then(toml::Value::as_table) - .and_then(|t| t.get("packages")), - ); - let nested_layer = ranking.key("install"); - let mut items: Vec<(Option<(Layer, usize)>, String)> = flat - .into_iter() - .enumerate() - .map(|(i, p)| (flat_layers.get(i).copied().flatten(), p)) - .chain(nested.into_iter().map(|p| (nested_layer, p))) - .collect(); - // A stable sort keeps each form's own order, and the flat items first - // within one layer. - items.sort_by_key(|(layer, _)| *layer); - let mut seen = std::collections::BTreeSet::new(); - items +/// The expanded spec's `packages`, in the order the fold unioned them +/// across its layers. [`BoxSpec::build`] keeps each one once. +fn expanded_packages(expanded: &toml::Table) -> Vec { + expanded + .get("packages") + .and_then(toml::Value::as_array) .into_iter() - .map(|(_, p)| p) - .filter(|p| seen.insert(p.clone())) + .flatten() + .filter_map(toml::Value::as_str) + .map(str::to_owned) .collect() } @@ -1107,7 +1077,6 @@ enum KeyShape { Int, StrOrInt, StrList, - StrOrStrList, /// A string that is one of the listed values. Word(&'static [&'static str]), /// A table whose keys are the ones listed. @@ -1131,7 +1100,6 @@ impl KeyShape { KeyShape::Int => "a whole number", KeyShape::StrOrInt => "a string or a whole number", KeyShape::StrList => "a list of strings", - KeyShape::StrOrStrList => "a string or a list of strings", KeyShape::Keys(_) => "a table", KeyShape::Owned(_) => "any value", } @@ -1146,10 +1114,9 @@ impl KeyShape { (KeyShape::Str | KeyShape::Word(_) | KeyShape::StrOrInt, V::String(_)) | (KeyShape::Bool, V::Boolean(_)) | (KeyShape::Int | KeyShape::StrOrInt, V::Integer(_)) - | (KeyShape::StrOrStrList, V::String(_)) | (KeyShape::Keys(_), V::Table(_)) | (KeyShape::Owned(_), _) => true, - (KeyShape::StrList | KeyShape::StrOrStrList, V::Array(items)) => { + (KeyShape::StrList, V::Array(items)) => { if !items.iter().all(V::is_str) { return Some("a list with an item that is not a string"); } @@ -1174,12 +1141,13 @@ const fn value_words(value: &toml::Value) -> &'static str { } } -/// `[box]`: the box's type, name, lifetime, loadout mode and volumes. +/// `[box]`: the box's name, lifetime, loadout mode and volumes. The +/// entry's own `type` names its Box Type, so `[box]` has no `type` +/// (#4038). const BOX_KEYS: &[SectionKey] = &[ ("lifetime", KeyShape::Word(Lifetime::ACCEPTED)), ("loadout_mode", KeyShape::Str), ("name", KeyShape::Str), - ("type", KeyShape::Str), ("volumes", KeyShape::StrList), ]; @@ -1192,10 +1160,10 @@ const IO_KEYS: &[SectionKey] = &[ ("stdout_mimetype", KeyShape::Str), ]; -/// `[execution]`: what the box runs and how its run ends. `on_oom` is as -/// the resources spec (BRES) defines it, a string. +/// `[execution]`: how the box's run ends. `on_oom` is as the resources +/// spec (BRES) defines it, a string. The entry's own `exec` names what a +/// task runs, so `[execution]` has no `exec` (#4038). const EXECUTION_KEYS: &[SectionKey] = &[ - ("exec", KeyShape::StrOrStrList), ("hooks_on_resume", KeyShape::Bool), ("on_oom", KeyShape::Str), ("restart", KeyShape::Str), @@ -1264,10 +1232,13 @@ const NESTING_KEYS: &[SectionKey] = &[ /// /// The other sections are tables whose keys belong to the part of the /// product that reads them. `[machine]` and `on_oom` belong to the -/// resources spec (BRES). `[params]`, `[vars]`, `[env_vars]` and `[args]` -/// carry the project's own names. `[secrets]` and `[otel]` are read by -/// their own components. No component reads `[nesting]` yet, so this -/// schema is the only check of its keys. +/// resources spec (BRES). `[params]`, `[env_vars]` and `[args]` carry the +/// project's own names. `[secrets]` and `[otel]` are read by their own +/// components. +/// +/// The keys of [`crate::expand::NOT_SUPPORTED_YET`] are named here as the +/// architecture's `box.toml` defines them, and the expansion refuses each +/// one until it ships (#4038). const SECTIONS: &[SectionKey] = &[ ("box", KeyShape::Keys(BOX_KEYS)), ("execution", KeyShape::Keys(EXECUTION_KEYS)), @@ -1691,7 +1662,7 @@ mod tests { KeyShape::Str => "corp".into(), KeyShape::Bool => false.into(), KeyShape::Int | KeyShape::StrOrInt => 3.into(), - KeyShape::StrList | KeyShape::StrOrStrList => vec![toml::Value::from("corp")].into(), + KeyShape::StrList => vec![toml::Value::from("corp")].into(), KeyShape::Word(words) => words[0].into(), KeyShape::Keys(keys) | KeyShape::Owned(keys) => toml::Value::Table( keys.iter() @@ -1737,9 +1708,42 @@ mod tests { .or_insert_with(|| sample(*shape)); } } + // The keys a stored spec keeps that the schema of a spec no longer + // names (#4038): a spec stored before then still reads back, so its + // box can resume. + let mut set = |path: &[&str], value: toml::Value| { + let (last, sections) = path.split_last().unwrap(); + let mut table = &mut stored; + for section in sections { + table = table + .entry((*section).to_owned()) + .or_insert_with(|| toml::Value::Table(toml::Table::new())) + .as_table_mut() + .unwrap(); + } + table.insert((*last).to_owned(), value); + }; + let corp = || toml::Value::from(vec![toml::Value::from("corp")]); + set(&["box", "volumes"], corp()); + for key in ["stdin_mimetype", "stdout_mimetype", "stderr_mimetype"] { + set(&["io", key], "text/plain".into()); + } + set(&["execution", "on_oom"], "kill".into()); + set(&["execution", "restart"], "never".into()); + set(&["install", "raw_packages"], corp()); + set( + &["nesting"], + toml::Value::Table(toml::Table::from_iter([( + "allowed".to_owned(), + true.into(), + )])), + ); // The typed keys that `for_session` leaves out, in a shape that // the typed spec reads. - stored["execution"]["exec"] = vec![toml::Value::from("make")].into(); + set( + &["execution", "exec"], + vec![toml::Value::from("make")].into(), + ); stored["execution"]["timeout"] = 30.into(); stored["execution"]["hooks_on_resume"] = true.into(); stored["network"]["egress"] = sample(KeyShape::Keys(EGRESS_KEYS)); @@ -2404,15 +2408,15 @@ mod tests { assert_eq!(spec.lifetime, Lifetime::UntilComplete, "{:?}", dev.spec); } - // BCLI-029: the stored packages union the flat `packages` and the - // `[install] packages` of every layer, in layer order, once each. + // BCLI-029: the stored packages union the `packages` of every layer, + // in layer order, once each. #[test] fn box_spec_takes_lifetime_from_expansion_unions_packages() { let file = r#" [defaults] packages = ["a", "c"] - [sessions.dev.install] + [sessions.dev] packages = ["b", "a"] "#; let dev = expand_in(file, "dev").expect("dev expands"); @@ -2583,36 +2587,20 @@ mod tests { let file = r#" [sessions.dev] hooks_on_resume = true - volumes = ["cache"] [sessions.dev.box] - type = "session" name = "dev" lifetime = "until_stopped" loadout_mode = "open" - volumes = ["cache"] [sessions.dev.io] pty_enabled = true exec_enabled = false - stdin_mimetype = "text/plain" - stdout_mimetype = "text/plain" - stderr_mimetype = "text/plain" [sessions.dev.execution] - exec = ["bash", "-l"] timeout = "30m" - on_oom = "kill" hooks_on_resume = true - [sessions.dev.install] - packages = ["git"] - raw_packages = ["ripgrep"] - - [sessions.dev.machine] - cpus = 2 - memory = "4G" - [sessions.dev.network] mode = "own_ip" quic443 = "auto" @@ -2631,30 +2619,13 @@ mod tests { proxy_env = true no_proxy = ["localhost"] - [sessions.dev.nesting] - allowed = true - max_depth = 2 - providers = ["local"] - types = ["task"] - dynamic_providers = "deny" - [sessions.dev.secrets.gh] source = "store" - [sessions.dev.otel] - endpoint = "http://localhost:4317" - - [[sessions.dev.file_imports]] - src = "a" - dst = "/a" - [[sessions.dev.file_exports]] src = "/b" dst = "b" - [[sessions.dev.github_imports]] - repo = "gominimal/minimal" - [tasks.lint] args = { fix = "false" } exec = "cargo clippy" @@ -2672,15 +2643,9 @@ mod tests { "box", "io", "execution", - "install", - "machine", "network", - "nesting", "secrets", - "otel", - "file_imports", "file_exports", - "github_imports", ] { assert!(dev.spec.contains_key(section), "{section} is carried"); } @@ -2728,9 +2693,9 @@ mod tests { strings. Fix the value.", ), ( - "[sessions.dev.io]\nstdin_mimetype = 0\n", - "`[sessions.dev]` in minimal.toml sets `io.stdin_mimetype` to a whole \ - number, but `io.stdin_mimetype` takes a string. Fix the value.", + "[sessions.dev.io]\nexec_enabled = 0\n", + "`[sessions.dev]` in minimal.toml sets `io.exec_enabled` to a whole \ + number, but `io.exec_enabled` takes true or false. Fix the value.", ), ( "[sessions.dev.io]\nstdin = \"null\"\n", @@ -2738,14 +2703,9 @@ mod tests { which is not a box setting. Remove the key or correct its name.", ), ( - "[sessions.dev.nesting]\nalowed = true\n", - "`[sessions.dev]` in minimal.toml sets `nesting.alowed`, \ - which is not a box setting. Remove the key or correct its name.", - ), - ( - "[sessions.dev.nesting]\nmax_depth = \"2\"\n", - "`[sessions.dev]` in minimal.toml sets `nesting.max_depth` to a \ - string, but `nesting.max_depth` takes a whole number. Fix the value.", + "[sessions.dev.box]\nname = 2\n", + "`[sessions.dev]` in minimal.toml sets `box.name` to a whole \ + number, but `box.name` takes a string. Fix the value.", ), ( "[sessions.dev.network.bep]\nstering = \"dns\"\n", @@ -2767,12 +2727,6 @@ mod tests { "`[sessions.dev]` in minimal.toml sets `network.quic443` to a true \ or false value, but `network.quic443` takes a string. Fix the value.", ), - ( - "[sessions.dev.install]\npackages = [\"git\", 3]\n", - "`[sessions.dev]` in minimal.toml sets `install.packages` to a list \ - with an item that is not a string, but `install.packages` takes a \ - list of strings. Fix the value.", - ), ( "[defaults.session.network.egress]\ndeny = [\"x\"]\n[sessions.dev]\n", "`[defaults.session]` in minimal.toml sets `network.egress.deny`, \ @@ -2831,34 +2785,32 @@ mod tests { ); } - // BOX-085: `[params]` on an entry is accepted and carried in the - // expanded spec's bytes. + // BOX-085: an entry's `[params]` is a key of the architecture's + // `box.toml` that no box reads yet, so the expansion refuses it as not + // supported yet in every layer, whatever its shape (#4038). #[test] - fn params_accepted_and_rendered() { - let file = r#" - [defaults.session.params] - region = "eu" - [sessions.dev] - [sessions.dev.params] - model = "large" - retries = 3 - "#; - let e = expand_in(file, "dev").expect("params are accepted"); - let params = e.spec["params"].as_table().expect("a table"); - assert_eq!(params["model"].as_str(), Some("large")); - assert_eq!(params["retries"].as_integer(), Some(3)); - assert!( - !params.contains_key("region"), - "the entry's table replaces the defaults' table: {params:?}" - ); - let bytes = e.spec_bytes().expect("writes"); - assert!(bytes.contains("[params]"), "{bytes}"); - assert!(bytes.contains("model = \"large\""), "{bytes}"); - assert!(bytes.contains("retries = 3"), "{bytes}"); - - let err = expand_in("[sessions.dev]\nparams = \"x\"\n", "dev").expect_err("not a table"); - assert_eq!(err.exit_code(), Some(3)); - assert!(err.to_string().contains("`params` takes a table"), "{err}"); + fn entry_params_refused_exit3() { + for (file, layer) in [ + ( + "[sessions.dev.params]\nmodel = \"large\"\n", + "[sessions.dev]", + ), + ( + "[defaults.session.params]\nregion = \"eu\"\n[sessions.dev]\n", + "[defaults.session]", + ), + ("[sessions.dev]\nparams = \"x\"\n", "[sessions.dev]"), + ] { + let err = expand_in(file, "dev").expect_err("params are refused"); + assert_eq!(err.exit_code(), Some(3)); + assert_eq!( + err.to_string(), + format!( + "`{layer}` in minimal.toml sets `params`, which this release \ + does not support yet. Remove `params` to start the box." + ) + ); + } } // BOX-001, BOX-059: the spec of a session entry whose project Box Type diff --git a/crates/mfile/tests/golden.rs b/crates/mfile/tests/golden.rs index 161aaf3941..5c978232e6 100644 --- a/crates/mfile/tests/golden.rs +++ b/crates/mfile/tests/golden.rs @@ -7,6 +7,11 @@ //! pinned in `tests/golden/vectors.json`. The six built-in types render //! their definitions equal to theirs. //! +//! The design's example sets keys that this release does not support yet +//! (`mfile::expand::NOT_SUPPORTED_YET`, #4038). Each entry that sets one is refused +//! naming it, and its vector is the expansion of the entry without +//! [`REFUSED_KEYS`]. +//! //! The vectors file holds one vector on each line, as JCS. When a vector //! fails, the test names it and the first byte that differs. After an //! intended change, run the test with `MFILE_BLESS_GOLDEN=1` to write the @@ -24,6 +29,10 @@ fn golden_dir() -> PathBuf { PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/golden") } +/// The keys of the example's session and task entries that this release +/// refuses (#4038). +const REFUSED_KEYS: [&str; 2] = ["file_imports", "volumes"]; + /// The vector of one entry, expanded as `min box start` expands it: the /// file's legacy tables read, the type chain and `[defaults]` layers /// applied, and the flat egress keys moved to their nested keys. @@ -46,7 +55,20 @@ fn entry_vector(doc: &toml::Table, types: &BoxTypes, entry: &BoxEntry) -> Json { ..Layers::default() } .with_file_defaults(&defaults, entry.box_type.as_deref(), &project_types); - let mut expansion = expand(entry, &layers).expect("the entry expands"); + let mut entry = entry.clone(); + for key in REFUSED_KEYS { + if !entry.body.contains_key(key) { + continue; + } + let err = expand(&entry, &layers).expect_err("the entry sets a refused key"); + assert!( + matches!(&err, mfile::Error::InvalidSpecKey { key: k, .. } if k == key), + "{} is refused naming {key}: {err}", + entry.name + ); + entry.body.remove(key); + } + let mut expansion = expand(&entry, &layers).expect("the entry expands"); mfile::network::canonicalize(&mut expansion.spec).expect("the network canonicalises"); let spec = expansion.spec_bytes().expect("the spec serialises"); let projection = expansion.projection(&resolved); diff --git a/crates/mfile/tests/golden/vectors.json b/crates/mfile/tests/golden/vectors.json index b9282ae10c..466b55fc4f 100644 --- a/crates/mfile/tests/golden/vectors.json +++ b/crates/mfile/tests/golden/vectors.json @@ -1,6 +1,6 @@ { -"example/dev":{"digest":"MVpa9OJLzIWhOOeXuVbzoGPDgug-HWQVrAQnFsGwxyw","projection":"{\"bep\":{\"steering\":\"dns\"},\"lifetime\":null,\"loadout_mode\":\"open\",\"nesting\":{\"allowed\":null,\"dynamic_providers\":null,\"max_depth\":null,\"providers\":null,\"types\":null},\"network\":{\"egress_deny_subnets\":[],\"egress_dns\":[\"github.com\",\"api.anthropic.com\"],\"egress_subnets\":[],\"ingress_ports\":[],\"mode\":\"own_ip\",\"quic443\":\"auto\"},\"pty_enabled\":null,\"registry_commit\":\"defad31c69130df153e9263cb1e4dca96b3e2994\",\"registry_pinned\":true,\"secret_grants\":[],\"trusted_cas\":[],\"type\":{\"name\":\"session\",\"root\":\"session\",\"source\":\"builtin\"},\"v\":2}","spec":"description = \"Everyday interactive dev shell\"\nexec = \"bash --noprofile -l\"\nloadout_mode = \"open\"\npackages = [\"base\", \"mermaid-cli\", \"emacs\", \"emacs-config-dev1\", \"kittyview\", \"claude-code\", \"less\"]\ntype = \"session\"\nvolumes = [\"dev\"]\n\n[network]\nmode = \"own_ip\"\n\n[network.egress]\nallow_dns_hosts = [\"github.com\", \"api.anthropic.com\"]\n\n[upstream]\nbranch = \"main\"\nbuild_cache_url = \"https://cache.gominimal.dev\"\ncommit = \"defad31c69130df153e9263cb1e4dca96b3e2994\"\nrepo_url = \"https://github.com/gominimal/pkgs\"\n"}, -"example/render-diagrams":{"digest":"95O6krOfVuVkkwjzsWguvWeSSTsGMcOOJ-MZ_26MCwM","projection":"{\"bep\":{\"steering\":\"dns\"},\"lifetime\":null,\"loadout_mode\":\"sealed\",\"nesting\":{\"allowed\":null,\"dynamic_providers\":null,\"max_depth\":null,\"providers\":null,\"types\":null},\"network\":{\"egress_deny_subnets\":[],\"egress_dns\":[],\"egress_subnets\":[],\"ingress_ports\":[],\"mode\":\"none\",\"quic443\":\"auto\"},\"pty_enabled\":null,\"registry_commit\":\"defad31c69130df153e9263cb1e4dca96b3e2994\",\"registry_pinned\":true,\"secret_grants\":[],\"trusted_cas\":[],\"type\":{\"name\":\"task\",\"root\":\"task\",\"source\":\"builtin\"},\"v\":2}","spec":"description = \"Render the mermaid diagrams in architecture.md to SVG\"\nexec = \"mmdc -i architecture.md -o out/\"\nloadout_mode = \"sealed\"\npackages = [\"base\", \"mermaid-cli\"]\ntype = \"task\"\n\n[[file_exports]]\npath = \"out/\"\n\n[[file_imports]]\npath = \"architecture.md\"\n\n[network]\nmode = \"none\"\n\n[upstream]\nbranch = \"main\"\nbuild_cache_url = \"https://cache.gominimal.dev\"\ncommit = \"defad31c69130df153e9263cb1e4dca96b3e2994\"\nrepo_url = \"https://github.com/gominimal/pkgs\"\n"}, +"example/dev":{"digest":"MVpa9OJLzIWhOOeXuVbzoGPDgug-HWQVrAQnFsGwxyw","projection":"{\"bep\":{\"steering\":\"dns\"},\"lifetime\":null,\"loadout_mode\":\"open\",\"nesting\":{\"allowed\":null,\"dynamic_providers\":null,\"max_depth\":null,\"providers\":null,\"types\":null},\"network\":{\"egress_deny_subnets\":[],\"egress_dns\":[\"github.com\",\"api.anthropic.com\"],\"egress_subnets\":[],\"ingress_ports\":[],\"mode\":\"own_ip\",\"quic443\":\"auto\"},\"pty_enabled\":null,\"registry_commit\":\"defad31c69130df153e9263cb1e4dca96b3e2994\",\"registry_pinned\":true,\"secret_grants\":[],\"trusted_cas\":[],\"type\":{\"name\":\"session\",\"root\":\"session\",\"source\":\"builtin\"},\"v\":2}","spec":"description = \"Everyday interactive dev shell\"\nexec = \"bash --noprofile -l\"\nloadout_mode = \"open\"\npackages = [\"base\", \"mermaid-cli\", \"emacs\", \"emacs-config-dev1\", \"kittyview\", \"claude-code\", \"less\"]\ntype = \"session\"\n\n[network]\nmode = \"own_ip\"\n\n[network.egress]\nallow_dns_hosts = [\"github.com\", \"api.anthropic.com\"]\n\n[upstream]\nbranch = \"main\"\nbuild_cache_url = \"https://cache.gominimal.dev\"\ncommit = \"defad31c69130df153e9263cb1e4dca96b3e2994\"\nrepo_url = \"https://github.com/gominimal/pkgs\"\n"}, +"example/render-diagrams":{"digest":"95O6krOfVuVkkwjzsWguvWeSSTsGMcOOJ-MZ_26MCwM","projection":"{\"bep\":{\"steering\":\"dns\"},\"lifetime\":null,\"loadout_mode\":\"sealed\",\"nesting\":{\"allowed\":null,\"dynamic_providers\":null,\"max_depth\":null,\"providers\":null,\"types\":null},\"network\":{\"egress_deny_subnets\":[],\"egress_dns\":[],\"egress_subnets\":[],\"ingress_ports\":[],\"mode\":\"none\",\"quic443\":\"auto\"},\"pty_enabled\":null,\"registry_commit\":\"defad31c69130df153e9263cb1e4dca96b3e2994\",\"registry_pinned\":true,\"secret_grants\":[],\"trusted_cas\":[],\"type\":{\"name\":\"task\",\"root\":\"task\",\"source\":\"builtin\"},\"v\":2}","spec":"description = \"Render the mermaid diagrams in architecture.md to SVG\"\nexec = \"mmdc -i architecture.md -o out/\"\nloadout_mode = \"sealed\"\npackages = [\"base\", \"mermaid-cli\"]\ntype = \"task\"\n\n[[file_exports]]\npath = \"out/\"\n\n[network]\nmode = \"none\"\n\n[upstream]\nbranch = \"main\"\nbuild_cache_url = \"https://cache.gominimal.dev\"\ncommit = \"defad31c69130df153e9263cb1e4dca96b3e2994\"\nrepo_url = \"https://github.com/gominimal/pkgs\"\n"}, "defaults_session_only/default":{"digest":"8At-_KEUG2WxdDvjHmyXoxwFHGy_HVDaRQLFwwswyxw","projection":"{\"bep\":{\"steering\":\"dns\"},\"lifetime\":null,\"loadout_mode\":\"open\",\"nesting\":{\"allowed\":null,\"dynamic_providers\":null,\"max_depth\":null,\"providers\":null,\"types\":null},\"network\":{\"egress_deny_subnets\":[],\"egress_dns\":[],\"egress_subnets\":[],\"ingress_ports\":[],\"mode\":\"own_ip\",\"quic443\":\"auto\"},\"pty_enabled\":null,\"registry_commit\":null,\"registry_pinned\":false,\"secret_grants\":[],\"trusted_cas\":[],\"type\":{\"name\":\"session\",\"root\":\"session\",\"source\":\"builtin\"},\"v\":2}","spec":"loadout_mode = \"open\"\npackages = [\"git\", \"zsh\"]\ntimeout = \"4h\"\n\n[network]\nmode = \"own_ip\"\n"}, "builtin/session":{"constraints":"pty_enabled = true\n","defaults":"loadout_mode = \"open\"\n","root":"session"}, "builtin/task":{"constraints":"pty_enabled = false\n","defaults":"loadout_mode = \"sealed\"\n","root":"task"}, diff --git a/crates/minimal/src/tests.rs b/crates/minimal/src/tests.rs index 8591f26d1f..d11eb5ba40 100644 --- a/crates/minimal/src/tests.rs +++ b/crates/minimal/src/tests.rs @@ -22962,15 +22962,119 @@ async fn box_spec_argument_directory_then_entry_then_box() { ); } +// #4067: an entry's flat `name` is the box's written name. The start's +// expansion names the box from it, and `min box spec` renders it as +// `box.name`. +#[tokio::test] +async fn flat_name_names_the_box_in_start_and_box_spec() { + let (project, global) = spec_project("[sessions.dev]\nname = \"docs-preview\"\n"); + let dir = camino::Utf8Path::from_path(project.path()).expect("a UTF-8 path"); + let expanded = + crate::session_box_expansion(dir, Some("dev"), true, &crate::SelectedLoadouts::default()) + .expect("the entry expands") + .expect("the project has a minimal.toml"); + assert_eq!( + crate::expanded_box_name(&expanded.spec).as_deref(), + Some("docs-preview") + ); + let toml = box_spec_text(&global, &["min", "box", "spec", "dev"]) + .await + .expect("the entry renders"); + let parsed: toml::Table = toml::from_str(&toml).expect("the render is TOML"); + assert_eq!( + parsed["box"]["name"].as_str(), + Some("docs-preview"), + "{toml}" + ); + assert!(!parsed.contains_key("name"), "{toml}"); +} + +// BOX-160, #4044: `pty_enabled`, flat or under `[io]`, follows the entry's +// built-in root. A session-rooted entry that sets `false`, or a task-rooted +// one that sets `true`, is refused with exit 3 by the start's expansion and +// by `min box spec` alike, with the same text. The root's own value is +// accepted by both. +#[tokio::test] +async fn pty_enabled_against_built_in_root_refused_by_start_and_box_spec() { + for (setting, key) in [ + ("pty_enabled = VALUE", "pty_enabled"), + ("io = { pty_enabled = VALUE }", "io.pty_enabled"), + ] { + let set = |v: bool| setting.replace("VALUE", &v.to_string()); + for (root, entry, refused) in [("session", "dev", false), ("task", "lint", true)] { + let table = if root == "task" { + format!("[tasks.{entry}]\nexec = \"true\"\n") + } else { + format!("[sessions.{entry}]\n") + }; + let (has, fix) = if root == "task" { + ("A task never has a terminal.", "false") + } else { + ("A session always has a terminal.", "true") + }; + let message = format!( + "`[{}s.{entry}]` in minimal.toml sets `{key}` to `{refused}`, but the \ + entry's built-in type is `{root}`. {has} Remove `{key}`, or set it \ + to `{fix}`.", + if root == "task" { "task" } else { "session" } + ); + for value in [refused, !refused] { + let (project, global) = spec_project(&format!("{table}{}\n", set(value))); + let dir = camino::Utf8Path::from_path(project.path()).expect("a UTF-8 path"); + // The start's expansion. + let started = if root == "task" { + crate::task_box_entry( + dir, + entry, + true, + &crate::SelectedLoadouts::default(), + None, + ) + .map(|_| ()) + } else { + crate::session_box_expansion( + dir, + Some(entry), + true, + &crate::SelectedLoadouts::default(), + ) + .map(|_| ()) + }; + // `min box spec `. + let spec = box_spec_text(&global, &["min", "box", "spec", entry]).await; + if value != refused { + started.unwrap_or_else(|e| panic!("{root} {key} = {value} starts: {e:#}")); + spec.unwrap_or_else(|e| panic!("{root} {key} = {value} renders: {e:#}")); + continue; + } + let error = started.expect_err("the start refuses it"); + let invalid = error + .downcast_ref::() + .unwrap_or_else(|| panic!("an invalid minimal.toml: {error:#}")); + assert!( + matches!(invalid.error, mfile::Error::TerminalExcluded { .. }), + "{error:#}" + ); + assert_eq!(invalid.error.exit_code(), Some(3)); + assert_eq!(invalid.error.to_string(), message); + let error = spec.expect_err("`min box spec` refuses it"); + let refused_by_spec = spec_project_error(&error); + assert_eq!(refused_by_spec.exit_code(), Some(3)); + assert_eq!(refused_by_spec.to_string(), message); + } + } + } +} + // BCLI-023: every section of the spec renders, whether or not this host -// enforces it. +// enforces it. `network.vpn_network_names` is one the daemon does not +// enforce. #[tokio::test] async fn box_spec_renders_unenforced_sections() { let (_project, global) = spec_project( "[sessions.default]\ntimeout = \"2h\"\nlifetime = \"until_stopped\"\n\ - on_oom = \"restart\"\nvolumes = [\"data\"]\n\n\ - [sessions.default.machine]\ncpus = 2\n\n\ - [sessions.default.otel]\nenabled = true\n", + execution = { hooks_on_resume = true }\n\n\ + [sessions.default.network]\nvpn_network_names = [\"corp\"]\n", ); let toml = box_spec_text(&global, &["min", "box", "spec", "default"]) .await @@ -22978,13 +23082,12 @@ async fn box_spec_renders_unenforced_sections() { let parsed: toml::Table = toml::from_str(&toml).expect("the render is TOML"); assert_eq!(parsed["timeout"].as_str(), Some("2h")); assert_eq!(parsed["lifetime"].as_str(), Some("until_stopped")); - assert_eq!(parsed["on_oom"].as_str(), Some("restart")); - assert_eq!(parsed["volumes"], toml::Value::Array(vec!["data".into()])); - assert_eq!(parsed["machine"]["cpus"].as_integer(), Some(2)); - assert_eq!(parsed["otel"]["enabled"].as_bool(), Some(true)); - for key in [ - "timeout", "lifetime", "on_oom", "volumes", "machine", "otel", - ] { + assert_eq!(parsed["execution"]["hooks_on_resume"].as_bool(), Some(true)); + assert_eq!( + parsed["network"]["vpn_network_names"], + toml::Value::Array(vec!["corp".into()]) + ); + for key in ["timeout", "lifetime", "execution", "network"] { assert!( toml.contains(&format!("# {key}: from [sessions.default]\n")), "{key}\n{toml}" @@ -22995,9 +23098,7 @@ async fn box_spec_renders_unenforced_sections() { .await .expect("the entry renders"); let doc: serde_json_lenient::Value = serde_json_lenient::from_str(&json).expect("JSON"); - for key in [ - "timeout", "lifetime", "on_oom", "volumes", "machine", "otel", - ] { + for key in ["timeout", "lifetime", "execution", "network"] { assert!(!doc["spec"][key].is_null(), "{key}\n{json}"); } } diff --git a/crates/minimald/src/box_manager/tests.rs b/crates/minimald/src/box_manager/tests.rs index cf14d7583f..e6cba0f1de 100644 --- a/crates/minimald/src/box_manager/tests.rs +++ b/crates/minimald/src/box_manager/tests.rs @@ -8050,12 +8050,12 @@ fn stored_spec_root_refusal_words_each_unknown_root() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn derived_task_type_refused_at_expansion_and_admission() { use mfile::box_types::{BoxTypeError, BoxTypes}; - use mfile::expand::{Layers, check_constraints, expand, expandable_type}; + use mfile::expand::{Layers, expand, expandable_type}; const FILE: &str = r#" [box_types.ci] extends = "task" - constraints = { pty_enabled = false, restart = "never" } + constraints = { pty_enabled = false } [boxes.lint-flat] type = "ci" @@ -8100,23 +8100,31 @@ async fn derived_task_type_refused_at_expansion_and_admission() { type_defaults: resolved.defaults.clone(), ..Layers::default() }; - let expansion = expand(entry, &layers).expect("the entry expands"); - - // Refused at expansion. - let err = check_constraints(entry, &expansion, &resolved) - .expect_err("the entry breaks the type's constraint"); - assert_eq!(err.exit_code(), 3, "{name}"); + // Refused at expansion: a task-rooted entry never has a terminal + // (#4044). + let err = expand(entry, &layers).expect_err("the expansion refuses a terminal"); + assert!( + matches!(&err, mfile::Error::TerminalExcluded { root: "task", .. }), + "{name}: {err:?}" + ); + assert_eq!(err.exit_code(), Some(3), "{name}"); let text = err.to_string(); for word in [ format!("`[boxes.{name}]`"), format!("`{key}`"), - "`[box_types.ci]`".to_owned(), + "`task`".to_owned(), ] { assert!( text.contains(&word), "{name}: expansion names {word}: {text}" ); } + // The spec another client sends: the entry without the key, then + // the key set. + let mut unchecked = entry.clone(); + unchecked.body.remove("pty_enabled"); + unchecked.body.remove("io"); + let expansion = expand(&unchecked, &layers).expect("the entry expands"); // Refused again at the daemon, which receives the spec unchecked. let mut spec = task_spec(name, None); @@ -8135,6 +8143,10 @@ async fn derived_task_type_refused_at_expansion_and_admission() { } spec["box"]["type"] = serde_json_lenient::json!(resolved.name); spec["type"] = serde_json_lenient::json!({ "root": resolved.root }); + match key { + "pty_enabled" => spec["pty_enabled"] = serde_json_lenient::json!(true), + _ => spec["io"]["pty_enabled"] = serde_json_lenient::json!(true), + } let before = mngr.list_boxes(None).await.unwrap().len(); let err = mngr diff --git a/docs/guide/install.md b/docs/guide/install.md index 49d3daae5e..77665213cf 100644 --- a/docs/guide/install.md +++ b/docs/guide/install.md @@ -101,9 +101,10 @@ What changes in 0.8: `[box] name` exactly as you wrote it. When any box on the host has that name, in any state, the command refuses and creates nothing. - One table, `env_vars`, sets environment variables in `minimal.toml` and in - loadout files. A session, task or defaults table, or a loadout file, that - sets `vars` or `vars_lenient` fails with exit code 3. The message - names the file and the key. Rename `vars` to `env_vars`. Move each + loadout files. Release 0.8 reads `vars` and `vars_lenient` in a session, + task or defaults table, or in a loadout file, as `env_vars`, and prints a + hint that names the file and the key. Release 0.9.0 and later refuse them + with exit code 3. Rename `vars` to `env_vars`. Move each `vars_lenient` entry into `env_vars` as `NAME = "value"`. Minimal refuses a name in `env_vars` that starts with a digit, or that holds a character other than a letter, a digit or `_`. diff --git a/docs/guide/migrate-to-minimal-session.md b/docs/guide/migrate-to-minimal-session.md index 26b033dc6f..431f778a3b 100644 --- a/docs/guide/migrate-to-minimal-session.md +++ b/docs/guide/migrate-to-minimal-session.md @@ -54,7 +54,7 @@ Prior to v0.5.0, `minimal.toml` had five sections: `upstream`, `harness`, `defau |---|---| | `[upstream]` | Unchanged | | `[harness]` | Renamed to [`[stack]`](../concepts/stacks.md). A `minimal.toml` with `[harness]` fails to parse | -| `[defaults]` | `profile` deprecated (see [Profiles](#profiles)) | +| `[defaults]` | `profile` removed (see [Profiles](#profiles)) | | `[outputs]` | Unchanged | | `[tasks]` | Tasks that set `interactive = true` move to [sessions](#sessions). Non-interactive tasks (test, build) stay tasks | @@ -74,10 +74,14 @@ Release 0.8 moves three spellings that a 0.7 `minimal.toml` uses: - `[session]` becomes `[defaults.session]`, and its `[[session.lifecycle_hooks]]` become `[[defaults.session.lifecycle_hooks]]`. -- `state_key` and `profile` under `[defaults]` move to `[defaults.task]`. A - `state_key` there applies to tasks only. +- `state_key` under `[defaults]` moves to `[defaults.task]`, where it + applies to tasks only. - `[params]` becomes `[args]`. +Profiles were removed. A start or `min box spec` of an entry fails with exit +code 3 when a table that the entry takes its settings from sets `profile`. +List the packages a box needs in `packages` instead. + Release 0.8 also renames the variable keys, in `minimal.toml` and in each loadout file: diff --git a/docs/reference/cli-min.md b/docs/reference/cli-min.md index 531afb2218..a6494eb379 100644 --- a/docs/reference/cli-min.md +++ b/docs/reference/cli-min.md @@ -382,8 +382,8 @@ Runs a task that the project's `minimal.toml` declares, in a box of its own. A task is a `[tasks.]` entry, or a `[boxes.]` entry whose type is `task` or a `[box_types]` type that extends `task`. The box takes the `packages` of the `defaults` of the entry's type and of each type it -extends. Of their `network` keys, the box applies `mode`, `egress`, -`vpn_network_names` and `uses`. Any other `network` key, such as `quic443` +extends. Of their `network` keys, the box applies `mode`, `egress` and +`uses`, and keeps `vpn_network_names` in its spec. Any other `network` key, such as `quic443` or `ingress`, in the entry, in `[defaults.]`, in `[defaults]` or in the `defaults` of one of those types refuses the run with exit code 3, and the refusal names the table that sets it. This holds for a `[tasks.]` @@ -934,9 +934,7 @@ The spec of a box holds the packages that its loadouts add, and the `min box spec ` shows what `min box spec ` shows when you pass it the same `--loadout` or `--no-loadouts` flags that you gave `min box start`. A box that an earlier release created has a spec without them. The host -still builds the box from what `min` sends with the spec, not from these keys. -[#3257](https://github.com/gominimal/minimal/issues/3257) tracks building it -from the stored spec. +builds the box from what `min` sends with the spec, not from these keys. The TOML form starts with the box's name and its origin, as the box's record holds them. The origin says whether a person wrote the name or the host @@ -1041,14 +1039,6 @@ close with it. `min host stop` does not remove a box: it ends a forward only bec daemon's exit does, and it keeps every box record, so a later `min net forward` reaches those sessions again. -What the tree proves today is the host-address mode (`--network host_ip`) -end to end: the `net_forward_*` tests drive a real daemon and relay bytes -through a live laptop-side listener. The in-box dial that the isolated modes -(`--network none`, `--network own_ip`) take — a `socat` relay injected into -the box's namespaces — is exercised by the daemon's harness test with a -host-side stand-in relay rather than a real box; a root-integration proof of -that leg (`just test-root-integration`) is still owed to the root lane. - ### `finalize-install` ``` diff --git a/docs/reference/loadouts.md b/docs/reference/loadouts.md index e3e1f1098e..09273f8a4b 100644 --- a/docs/reference/loadouts.md +++ b/docs/reference/loadouts.md @@ -615,7 +615,7 @@ forward = "ctrl-]" | `leader` | `ctrl-]` | The chord that enters command mode, as a logical key name (`"ctrl-]"`, `"ctrl-^"`, `"d"`, …). Rejected loudly at load if termios-special (`ctrl-c`, `ctrl-w`, `ctrl-\`, … — consumed by the line discipline before the app) or wrapping-ambiguous (`ctrl-i` = TAB, `ctrl-m` = CR, …) | | `bell_on_leader` | `false` | Ring the terminal bell (BEL `0x07`) on entering command mode. The terminal renders it per its own bell config; minimal picks no modality | | `subcommands.detach` | `d` | The command-mode key that detaches the channel | -| `subcommands.forward` | `ctrl-]` | The command-mode key that verbatim-forwards a leader byte down the PTY (for nested sessions). Defaults to the resolved `leader`, so a double-press forwards | +| `subcommands.forward` | `ctrl-]` | The command-mode key that verbatim-forwards a leader byte down the PTY, to a program in the box that reads it. Defaults to the resolved `leader`, so a double-press forwards | Key names take one of two forms: `ctrl-`, where the glyph is a single ASCII character in `@`..`~` (so `ctrl-2` and `ctrl-?` are rejected), or a diff --git a/docs/reference/minimal-dot-toml.md b/docs/reference/minimal-dot-toml.md index 692dbe5b8f..242412e29b 100644 --- a/docs/reference/minimal-dot-toml.md +++ b/docs/reference/minimal-dot-toml.md @@ -133,11 +133,13 @@ RUST_LOG = "info" [defaults.session.env_vars] RUST_LOG = "debug" # sessions get debug, and every other entry gets info -[tasks.test] -exec = "cargo test" -env_vars.RUST_BACKTRACE = "1" # this task gets RUST_LOG too +[sessions.web.env_vars] +RUST_BACKTRACE = "1" # this session gets RUST_LOG = "debug" too ``` +A task takes its `env_vars` from its own entry table, as +[tasks](./tasks.md) says. + `env_vars` is the key that sets variables, in `minimal.toml` and in a loadout file. Release 0.8 reads the 0.7 keys `vars` and `vars_lenient` as `env_vars`, with a hint. See [Legacy tables](#legacy). A name in @@ -183,9 +185,16 @@ with no `egress` already reaches every name, so `uses` adds nothing to it. A `--deny-all-egress` and `--network none` leave out the hosts of every service. A name that is not a service fails with exit code 3, and the error lists the services. The box's spec never holds `uses`. `min box spec` shows -each host a service added and names the service. `uses` adds the service's -hosts only. It does not deliver the service's secret yet, so a `[secrets]` -entry still declares it (gominimal/inbox#1328). +each host a service added and names the service. + +A service that has a secret also gives the box that secret, as a +`[secrets]` entry under the service's variable. For a GitHub sign-in it is +a broker grant. For a token you store with `min secret set`, it is a +reference to the item named for the service in your system's secret store. +A `broker` or `store` entry for that variable in `[secrets]` takes the +place of the one the service gives. A `client_env` entry for that variable +fails with exit code 3, and so does an `env_vars` value for it. +`min box spec` shows the entry and names the service that added it. ```toml [sessions.agent.network] @@ -345,7 +354,7 @@ A session entry applies these keys: |---|---| | `type` | The entry's Box Type, `session` for a `[sessions.]` entry. A `[boxes.]` entry names a [`[box_types]`](#box-types) type here | | `description` | Prose for people. No command reads it | -| `[box] name` | The box's name. Without it, Minimal derives the name from the project and the entry | +| `[box] name` | The box's name. A flat `name` sets it too. Setting both to different values fails with exit code 3. Without either, Minimal derives the name from the project and the entry | | `packages` | The packages installed in the box, with those of `[defaults]` and `[defaults.session]` | | `env_vars` | Environment variables in the box, as in [`[defaults.session]`](#session) | | `patches` | Files copied into the box's home, as in [`[defaults.session]`](#session) | @@ -388,8 +397,6 @@ tables is a shorter way to write `[boxes.]` with its `type` set: |---|---| | `[sessions.]` | `[boxes.]` with `type = "session"` | | `[tasks.]` | `[boxes.]` with `type = "task"` | -| `[agents.]` | `[boxes.]` with `type = "agent"` | -| `[services.]` | `[boxes.]` with `type = "service"` | This release starts a box only from an entry whose type is `session` or `task`, or a `[box_types]` type that extends one of them. An entry of a @@ -419,8 +426,7 @@ in the same way as a `[tasks.]` entry. It sets one action key, such as does not read as a task, fails with exit code 3. A `[tasks.]` entry always has the type `task`, so an entry of a type that extends `task` is declared as `[boxes.]`. -`min session start` starts only session entries. It refuses an entry from -`[agents.]` or `[services.]` with exit code 4. +`min session start` starts only session entries. An entry name is 1 to 63 lowercase letters, digits, or hyphens, and does not start or end with a hyphen. Each name is used once in the file, whichever @@ -434,6 +440,17 @@ lists the keys a session applies. `packages`, `patches`, `env_vars`, and [`[defaults.session]`](#session). [`trusted_cas`](#trusted_cas) is described below. +#### `pty_enabled` - Whether the box has a terminal {#pty_enabled} + +`pty_enabled` follows the entry's built-in type. A session always has a +terminal, and a task never has one. An entry whose type is `session`, or a +type that extends `session`, can set only `pty_enabled = true`. An entry +whose type is `task`, or a type that extends `task`, can set only +`pty_enabled = false`. The other value fails with exit code 3, whether the +table writes the key flat or under `[io]`. The error names the key, the +table that set it and the entry's built-in type. `min box spec ` +refuses the entry with the same error. + #### `timeout` - How long a box runs {#timeout} `timeout` sets how long a box can run. Set it in `[defaults]`, @@ -749,7 +766,7 @@ hint. | Older spelling | Write instead | |---|---| | `[session]` | [`[defaults.session]`](#session) | -| `state_key` and `profile` under `[defaults]` | the same keys under [`[defaults.task]`](#defaults) | +| `state_key` under `[defaults]` | the same key under [`[defaults.task]`](#defaults) | | `[params]` | [`[args]`](#args) | | `vars`, a table of variables, in any table that sets variables | `env_vars` in the same table | | `vars_lenient`, a list of `{ name, value }` entries, in any table that sets variables | each entry as ` = ` in `env_vars` of the same table | @@ -766,5 +783,7 @@ such as `A-B`, fails as the same name in `env_vars` fails. Rename the variable to a POSIX-shaped name, such as `A_B`. Then update each script and file that reads the old name. -`profile` is deprecated. A task's own `args` key is not a legacy spelling, -and it keeps its meaning. +Profiles were removed. A start or `min box spec` of an entry fails with +exit code 3 when a table that the entry takes its settings from sets +`profile`. List the packages a box needs in `packages` instead. +A task's own `args` key is not a legacy spelling, and it keeps its meaning. diff --git a/docs/reference/tasks.md b/docs/reference/tasks.md index 7788f079b1..e837853694 100644 --- a/docs/reference/tasks.md +++ b/docs/reference/tasks.md @@ -205,19 +205,7 @@ table and the change. Release 0.9.0 and later refuse `vars` with exit code 3. See [Legacy tables](./minimal-dot-toml.md#legacy). A name holds only ASCII letters, digits and `_`, and does not start with a digit. -A task's `env_vars` merges by name with the `env_vars` of -[`[defaults]` and `[defaults.task]`](./minimal-dot-toml.md#defaults). The task -gets every name that those tables set, and its own value wins for a name that -both set: - -```toml -[defaults.task.env_vars] -RUST_LOG = "info" -CC = "clang" - -[tasks.my_task] -env_vars.CC = "gcc" # my_task gets CC = "gcc" and RUST_LOG = "info" -``` +A task takes its `env_vars` from its own table: ```toml [tasks.my_task] diff --git a/docs/specs/29-spec-box-local-first/29-spec-box-local-first.md b/docs/specs/29-spec-box-local-first/29-spec-box-local-first.md index 950d5a6834..94b7f3fc6e 100644 --- a/docs/specs/29-spec-box-local-first/29-spec-box-local-first.md +++ b/docs/specs/29-spec-box-local-first/29-spec-box-local-first.md @@ -5,7 +5,7 @@ owner: mitodrummer epic: gominimal/inbox#731 arch: https://github.com/gominimal/arch/blob/4f2eb87d5d12485906e73e2dcaeeae1c56e76d66/architecture.md arch_sha: "4f2eb87d5d12485906e73e2dcaeeae1c56e76d66" -updated: 2026-12-02 +updated: 2026-12-04 --- # BOX — Box — one record and one spec for every session and task on a stock install @@ -393,6 +393,13 @@ After this ships, a developer on a stock install with no identity plane runs ses - **BOX-049** THE SYSTEM SHALL accept per-entry keys written flat (`timeout`, `pty_enabled`, and the `[machine]` and `on_oom` keys as the resources spec (gominimal/inbox#698; BRES) defines them) and keep the meaning of `packages`, `patches`, `env_vars` and `lifecycle_hooks`. tier: T0 verify: cargo nextest run -p mfile flat_per_entry_keys_and_legacy_keys_keep_meaning + - WHERE an entry or a layer sets a flat `name` THE SYSTEM SHALL write it to the expanded spec as `box.name`, the box's written name, as the architecture's example writes it. + tier: T0 + verify: cargo nextest run -p mfile flat_name_folds_into_box_name + verify: cargo nextest run -p minimal flat_name_names_the_box_in_start_and_box_spec + - IF the expanded spec sets a flat `name` and `box.name` to different values THEN THE SYSTEM SHALL fail with exit 3, naming both keys and the layer that set each. + tier: T0 + verify: cargo nextest run -p mfile flat_name_folds_into_box_name - **BOX-050** WHERE a file carries a top-level `[session]` table THE SYSTEM SHALL read it as `[defaults.session]` for one release and print one hint each time the legacy table is read. tier: T0 @@ -434,7 +441,7 @@ After this ships, a developer on a stock install with no identity plane runs ses tier: T0 verify: cargo nextest run -p mfile singular_entry_table_exit3_names_plural -- **BOX-051** WHERE a file carries `state_key` or `profile` under top-level `[defaults]` THE SYSTEM SHALL read them as `[defaults.task]` for one release and print one hint, which names `profile` as deprecated. +- **BOX-051** WHERE a file carries `state_key` under top-level `[defaults]` THE SYSTEM SHALL read it as `[defaults.task]` for one release and print one hint. tier: T0 verify: cargo nextest run -p mfile legacy_defaults_task_keys_with_hint @@ -468,6 +475,10 @@ After this ships, a developer on a stock install with no identity plane runs ses - **BOX-160** IF the expanded spec the daemon receives at creation carries a value that the constraints of its type's built-in root (the projection's `type.root`, BOX-071) exclude THEN THE SYSTEM SHALL refuse the creation with exit 3 naming the type, its root and the key, whatever client sent the spec, whatever expander version it reports (BOX-074), and whether or not the client's check (BOX-061) ran, enforced by `minimald` at admission, on the host side of TB2 (inside the guest on `local-minvmd0`, on the developer's machine on `local0`). tier: T0 verify: cargo nextest run -p minimald admission_refuses_spec_breaching_builtin_root_constraint_exit3 + - IF an entry whose built-in root is `session` expands with `pty_enabled` or `io.pty_enabled` set to `false`, or an entry whose built-in root is `task` expands with either set to `true`, THEN THE SYSTEM SHALL refuse the expansion with exit 3, naming the key as the layer wrote it, the layer that set it and the root, in `min box spec` as in every start (gominimal/minimal#4044). + tier: T0 + verify: cargo nextest run -p mfile pty_enabled_against_built_in_root_exit3 + verify: cargo nextest run -p minimal pty_enabled_against_built_in_root_refused_by_start_and_box_spec - **BOX-062** THE SYSTEM SHALL never let a type constraint add a package, a port, or an egress entry. tier: T1 @@ -806,7 +817,7 @@ After this ships, a developer on a stock install with no identity plane runs ses tier: T0 verify: cargo nextest run -p minimal expander_skew_reports_and_continues -- **BOX-145** THE SYSTEM SHALL expand the session and task entries of the architecture's example `minimal.toml`, and the implicit `default` entry (BOX-165) of a pinned file that declares only `[defaults.session]`, to canonical spec bytes and projection digests equal to the pinned golden vectors, and render the six built-in types' definitions equal to theirs. +- **BOX-145** THE SYSTEM SHALL expand the session and task entries of the architecture's example `minimal.toml`, each without the keys that this release does not support yet (BOX-076), and the implicit `default` entry (BOX-165) of a pinned file that declares only `[defaults.session]`, to canonical spec bytes and projection digests equal to the pinned golden vectors, and render the six built-in types' definitions equal to theirs. tier: T0 verify: cargo nextest run -p mfile example_expansion_matches_golden_vectors @@ -816,7 +827,13 @@ After this ships, a developer on a stock install with no identity plane runs ses - IF a spec carries an unknown key, other than a flat egress key BOX-157 accepts, or a value of the wrong shape THEN THE SYSTEM SHALL fail with exit 3 naming the key. tier: T0 verify: cargo nextest run -p mfile unknown_key_or_shape_exit3 - - WHEN the daemon creates a box whose expanded spec carries `[[file_imports]]`, `[[github_imports]]`, `[otel]` or `[network] vpn_network_names`, none of which this spec enforces, THE SYSTEM SHALL carry the section in the stored spec, create the box, and warn once for each such section, naming it. + - IF an entry or any layer sets a key that the architecture's `box.toml` defines and this release does not implement yet (`volumes`, `[nesting]`, `[[file_imports]]`, `[[github_imports]]`, `github_token_mode`, `[otel]`, `[machine]`, `on_oom`, `restart`, `[params]`, `install.raw_packages` or an `io.*_mimetype` key) THEN THE SYSTEM SHALL refuse it with exit 3, naming the key and the layer that set it, and saying that this release does not support it yet. + tier: T0 + verify: cargo nextest run -p mfile unimplemented_keys_exit3_not_a_box_setting + - IF a layer sets `box.type`, `execution.exec` or `install.packages`, which an entry writes as its `type`, a task's `exec` and `packages`, or the entry key `loadouts`, `upstream` or `profile`, THEN THE SYSTEM SHALL fail with exit 3 naming the key and the layer. Where a release or a committed `minimal.toml` used the key, or another key replaces it, the error SHALL also say what to set in its place. + tier: T0 + verify: cargo nextest run -p mfile unimplemented_keys_exit3_not_a_box_setting + - WHEN the daemon creates a box whose received spec carries `[[file_imports]]`, `[[github_imports]]`, `[otel]` or `[network] vpn_network_names`, none of which this spec enforces, THE SYSTEM SHALL carry the section in the stored spec, create the box, and warn once for each such section, naming it. tier: T0 verify: cargo nextest run -p minimald unenforced_sections_warn_once_each_naming_section - IF a project `minimal.toml` carries a `[secret-store-rules]`, `[package-file-rules]` or `[loadout-file-rules]` section THEN THE SYSTEM SHALL leave it out of the expanded spec and warn, naming it, as BEP-037 states for `[secret-store-rules]`. @@ -830,7 +847,6 @@ After this ships, a developer on a stock install with no identity plane runs ses | `[project]`, one key `name` (BOX-214) | top level | permanent | | `args` (BOX-052) | a task entry | permanent | | `state_key` (BOX-051) | `[defaults.task]` | task-only with today's meaning, retired when Box Volumes land, a volume replacing it | - | `profile` (BOX-051) | `[defaults.task]` | deprecated, accepted for BOX-051's one release only | | `authorities`, `inject` (BOX-071) | a `source = "store"` entry in `[secrets]` | written by expansion from the client's `[secret-store-rules]`, never by the project | - **BOX-079** THE SYSTEM SHALL accept `[network] mode` values `none`, `host_ip` and `own_ip`, and accept for one release the legacy spellings `no-net`, `host-net` and `own-ip` that NET-037 names for the `--network` flag, printing a hint naming the new value and writing the new value, never the legacy spelling, into the expanded spec and its projection. @@ -852,9 +868,9 @@ After this ships, a developer on a stock install with no identity plane runs ses tier: T0 verify: cargo nextest run -p minimald broker_secret_unenrolled_exit5 -- **BOX-085** THE SYSTEM SHALL accept `[params]` on an entry and carry it in the expanded spec. +- **BOX-085** THE SYSTEM SHALL accept `[params]` on an entry as a key of the Box Spec, which BOX-076 refuses as not supported yet until a box reads it. tier: T0 - verify: cargo nextest run -p mfile params_accepted_and_rendered + verify: cargo nextest run -p mfile entry_params_refused_exit3 - **BOX-185** WHEN a `min` command that waits for a box sees it end after its entrypoint started, or `min box wait` finds it already ended, whether its entrypoint exited with any code, it timed out, it ran out of memory or it was stopped, THE SYSTEM SHALL copy each path that its expanded spec's `[[file_exports]]` declares, from `/workbench/` in the box's retained filesystem (BOX-017) to the same `` under the project root, from the client, before the command exits. The commands that wait are an attached `min task run` or `min box run`, `min box attach`, a `min box start` that attaches, and `min box wait`. @@ -1057,13 +1073,16 @@ Moved to the sibling spec `docs/specs/28-spec-box-cli` (BCLI) when the grammar w - Choosing the entry a bare start creates from, the entry named `default` else the sole entry, and its exit 2 when a non-session entry named `default` blocks the implicit one: `docs/specs/28-spec-box-cli` (BCLI). This spec supplies the implicit entry (BOX-165). - Credentialed egress, the node-local egress proxy, `[network.bep]`, `[secrets]` resolution, `min auth`, `min secret`, and `min box audit`: the egress-proxy spec, `docs/specs/24-spec-box-egress-proxy` (BEP), and gominimal/minimal#1501. - Entries of type `agent`, `service` and `container-build`, including their expansion and validation, the `[agents.]` and `[services.]` tables, and their type-specific behaviour (the agent harness, hermetic container builds): the Agent Box epic gominimal/inbox#678 and successors. BOX-063 refuses each such entry when it is expanded or created, until that epic's spec lands; BOX-059 keeps all six built-in types as data. The `build` type's build boxes left that epic on 2026-11-06 ([arch#167](https://github.com/gominimal/arch/issues/167)): BOX-209 and BOX-210 bind them here, and NET binds their network. A hand-written `build` entry stays refused by BOX-063. -- One attribute rule, which follows the attribute on any type that sets it rather than any one type (architecture design principle 8): what ends a box whose spec sets `lifetime = "until_stopped"`, what happens when its entrypoint returns, and the `[execution] restart` policy that applies to it. It goes to the Agent Box epic gominimal/inbox#678 or its successor. This spec accepts, expands and projects the key (BOX-071) and does not enforce it. A restart that a client asks for is not the `[execution] restart` policy: BOX-176 defines it. The `loadout_mode` gate on loadouts is in this spec (BOX-166 to BOX-175, BOX-181 and BOX-182). +- One attribute rule, which follows the attribute on any type that sets it rather than any one type (architecture design principle 8): what ends a box whose spec sets `lifetime = "until_stopped"`, what happens when its entrypoint returns, and the `[execution] restart` policy that applies to it. It goes to the Agent Box epic gominimal/inbox#678 or its successor. The key is legal, and BOX-076 refuses it as not supported yet until that epic implements it. A restart that a client asks for is not the `[execution] restart` policy: BOX-176 defines it. The `loadout_mode` gate on loadouts is in this spec (BOX-166 to BOX-175, BOX-181 and BOX-182). - The default `loadout_mode` of the `agent`, `service` and `container-build` types. gominimal/inbox#678 defines those types. - Changing a running box's spec: `min add` and any other runtime change, with the `package_added` and `port_exposed` events it writes: a follow-up spec, not yet filed. The `file_exported` event is BOX-195's. A box here resumes from its creation-time spec (BOX-025). - Organization Box Types: resolving a type from an organization registry, and refusing a project type that redefines an organization type's name: the Gatehouse directory work, gominimal/inbox#579. Until it lands, BOX-059 resolves only built-in and project types, and `type.source` in the projection (BOX-071) is `builtin` or `project`. -- Spec sections this spec accepts and carries but does not enforce, each warned of at creation (BOX-076): `[[file_imports]]`, whose copy at creation stays with gominimal/arch#163 and whose schema validation the Agent Box epic gominimal/inbox#678 owns; `[[github_imports]]`, unowned, a follow-up (the clone is the broker's creation-time mint under Gatehouse §6.3); `[otel]`, the observability epic gominimal/inbox#515 and the Agent Box epic gominimal/inbox#678's telemetry receiver; and `[network] vpn_network_names`, the mesh spec MRF (gominimal/minimal#1420). `[[file_exports]]` is no longer on this list: BOX-185 to BOX-204 copy it, and its schema validation stays with gominimal/inbox#678. A project's `[secret-store-rules]`, `[package-file-rules]` and `[loadout-file-rules]` are not carried: BOX-076 leaves them out with a warning, as BEP-037 does for the first. +- `[network] vpn_network_names`, which this spec accepts and carries but does not enforce, warned of at creation (BOX-076): the mesh spec MRF (gominimal/minimal#1420). +- Spec sections that the architecture defines and BOX-076 refuses as not supported yet, until their owners implement them: `[[file_imports]]`, whose copy at creation stays with gominimal/arch#163 and whose schema validation the Agent Box epic gominimal/inbox#678 owns; `[[github_imports]]`, gominimal/minimal#4072 (the clone is the broker's creation-time mint under Gatehouse §6.3); `[otel]`, the observability epic gominimal/inbox#515 and the Agent Box epic gominimal/inbox#678's telemetry receiver; `[nesting]`, gominimal/inbox#568; and `volumes`, `docs/specs/27-spec-box-volumes`. The refusal also covers `github_token_mode`, gominimal/minimal#4073; the `io.*_mimetype` keys, gominimal/minimal#4074; `install.raw_packages`, gominimal/minimal#4075; and an entry's `[params]`, gominimal/arch#100. Each key leaves the not-supported-yet list when its feature ships. `[[file_exports]]` is no longer on this list: BOX-185 to BOX-204 copy it, and its schema validation stays with gominimal/inbox#678. A project's `[secret-store-rules]`, `[package-file-rules]` and `[loadout-file-rules]` are not carried: BOX-076 leaves them out with a warning, as BEP-037 does for the first. +- A session entry's task action keys, such as `exec`, `bash`, `cmdcmd` and `echo`: BOX-076 accepts them on every entry, and a session ignores them, because its first process is its login shell. Refusing them on a session entry is gominimal/minimal#4069. +- A Box Type's `constraints` naming a key that no entry may set, such as `restart`: BOX-156 resolves such a constraint, and it constrains nothing. Refusing it is gominimal/minimal#4070. - Nesting, the `local-box` provider, and running `min` inside a box, including `min box spec self` and the project name of a root that is a box's own copy of its project: gominimal/inbox#568. -- Memory and resource declaration, admission, the per-box cgroup limit, OOM handling and `enforced`/`advisory` reporting (epic story S15): the resources spec (gominimal/inbox#698; BRES), written from that epic. +- Memory and resource declaration, admission, the per-box cgroup limit, OOM handling and `enforced`/`advisory` reporting (epic story S15): the resources spec (gominimal/inbox#698; BRES), written from that epic. BOX-076 refuses `[machine]` and `on_oom` as not supported yet until it lands. - The dash (epic story S14: type, state, provider and host columns; resume, reap and start from the list; the create form over entries): an amendment to `docs/specs/07-spec-min-dash-tui`, filed as a follow-up issue on that spec when this merges. - The local providers serving the Box Provider API (epic story S16, BPA-013). gominimal/arch#45 ruled on 2026-10-27 that the daemons serve them over their Unix sockets. The Box Provider requirements spec (BPA), which that ruling moves into this repository, specifies them. - A test-suite requirement per requirement (epic story S18): every requirement's `tier:` and `verify:` lines carry it, and the golden vectors are BOX-145. @@ -1163,7 +1182,9 @@ Moved to the sibling spec `docs/specs/28-spec-box-cli` (BCLI) when the grammar w **A literal variable is not a secret.** Karl's decision of 2026-11-24 (gominimal/minimal#3210): a loadout or project `env_vars` value is stored in the box record as written (BOX-230). What `min box spec` shows of a loadout's values stays spec 28's (BCLI-077, gominimal/minimal#3255). A secret goes in `[secrets]`, whose `store` and `broker` sources keep the value out of the spec (BOX-080, BOX-141). The expander warns when a variable's name looks like a credential (BOX-231), and the warning prints only in `min box spec`. Redacting every value in `min box spec` was rejected because it hides ordinary configuration. Refusing such a variable was rejected because a name alone cannot tell a secret from a setting. -**Unenforced sections are accepted and warned of, never silently dropped.** Decided on 2026-10-05: BOX-076 keeps accepting the whole `box.toml` schema, and the daemon warns once at creation for each section this spec does not enforce, naming it, with each section's owner listed under Non-goals; a project's `[secret-store-rules]` is left out with BEP-037's warning. Decided on 2026-10-06: a project's `[package-file-rules]` and `[loadout-file-rules]` get the same treatment, because both authorize reads of the client's filesystem outside the project subtree, and carrying a cloned file's `allow` rules into the stored spec would hand the follow-up that enforces them a spec that says to honour them. The alternative, refusing those sections until an owner enforces them, was rejected because epic story S9 accepts keys whether or not this host enforces them yet, and the architecture's own example uses them. +**Unenforced sections are accepted and warned of, never silently dropped.** Decided on 2026-10-05, and narrowed on 2026-12-04 by the next paragraph for the keys this release does not support yet: BOX-076 keeps accepting the whole `box.toml` schema, and the daemon warns once at creation for each section this spec does not enforce, naming it, with each section's owner listed under Non-goals; a project's `[secret-store-rules]` is left out with BEP-037's warning. Decided on 2026-10-06: a project's `[package-file-rules]` and `[loadout-file-rules]` get the same treatment, because both authorize reads of the client's filesystem outside the project subtree, and carrying a cloned file's `allow` rules into the stored spec would hand the follow-up that enforces them a spec that says to honour them. The alternative, refusing those sections until an owner enforces them, was rejected because epic story S9 accepts keys whether or not this host enforces them yet, and the architecture's own example uses them. + +**A key the architecture specifies and this release does not implement is refused as not supported yet.** Owner ruling 2026-12-04 (gominimal/minimal#4038): a key that the expansion accepted and no box applied looked like a setting that worked. The keys stay legal: BOX-076 and BOX-085 accept them as `box.toml` defines them, and the projection keeps its `[nesting]` bounds. A stored spec keeps `box.volumes`, `[nesting]`, `execution.on_oom`, `execution.restart`, `install.raw_packages` and the `io.*_mimetype` keys, so a stored spec that carries one still reads back. A stored spec has no place for the other keys, and `min` never writes them into one: a stored spec that carries one of them, such as `file_imports`, does not read back. Until each key ships, BOX-076 refuses it with exit 3 in every layer, before the fold, naming the layer, and saying that this release does not support it yet, and the user documentation does not describe it. A key that another key replaces, such as `profile`, is not a box setting, and its refusal names the replacement. An entry's flat `name` is not one of these: it is the box's written name, as the architecture's example writes it, and the expansion writes it as `box.name` (BOX-049). The daemon still carries and warns of `[network] vpn_network_names`, because `min box show` displays it and BCLI-024 binds `--vpn-network-names` as its override. It still warns of `[[file_imports]]`, `[[github_imports]]` and `[otel]` in a spec that another client sends. The alternative, removing the keys from the schema, was rejected because it would contradict the architecture, which defines them. **A task's declared exports come back on the client, after the box ends.** Decided on 2026-11-12 and 2026-11-13 (gominimal/minimal#2668): the `min` command that waits for the box copies each `[[file_exports]]` path out of the box's retained filesystem once the box ends, on every end, through the same file reads `min box cp` uses: an attached run, an attach, and `min box wait` (BOX-185, gominimal/arch#180). A detached command and `min box stop` copy nothing, because no process stays on the client to copy later (BOX-186). Each export of an end is claimed by one command at a time, and only in the project that created the box (BOX-198, BOX-199); a claim whose command loses its connection before reporting is released, so the next waiting command copies what is left (BOX-202). The copy runs on the client because the client holds the project root, and a VM-backed host serves the box's files from inside the VM, where the daemon cannot write the host's project. The alternative, the daemon copying into the host project, was rejected for that reason. A run copies on a failed or timed-out end as well, because a task's output is most often wanted when it failed, such as a test report. A path that leaves the project subtree is refused at expansion with exit 3, so a bad path never costs a run (BOX-189); a symlink can only be seen at copy time, so BOX-192 refuses it there. A skipped export turns a successful command into exit 125, the architecture's code for a failure on `min`'s side of a run-style command; exit 1 was rejected because a caller cannot tell it from an entrypoint that exited 1. A command whose box already failed keeps its code, and the record keeps the entrypoint's (BOX-193, BOX-194, BOX-197). The client reports each export to the daemon, which appends a `file_exported` event, so the record carries what was exported as it carries every other event (BOX-195). Imports, and any sync at creation, stay with gominimal/arch#163.