diff --git a/crates/nemoclaw-build/src/images.rs b/crates/nemoclaw-build/src/images.rs index cba22135143..f0cd43c88af 100644 --- a/crates/nemoclaw-build/src/images.rs +++ b/crates/nemoclaw-build/src/images.rs @@ -208,20 +208,22 @@ pub fn plan( // target. Name the platforms that build it instead; other selections, such // as groups or the reference image, keep Bake's own resolution. let supported = platform_harnesses(root, platform)?; - let mut others = None; - for name in selection.iter().filter(|name| !supported.contains(name)) { - if others.is_none() { - others = Some( - PLATFORMS - .into_iter() - .filter(|other| *other != platform) - .map(|other| Ok((other, platform_harnesses(root, other)?))) - .collect::>>()?, - ); - } + let unsupported: Vec<&String> = selection + .iter() + .filter(|name| !supported.contains(name)) + .collect(); + let others = if unsupported.is_empty() { + Vec::new() + } else { + PLATFORMS + .into_iter() + .filter(|other| *other != platform) + .map(|other| Ok((other, platform_harnesses(root, other)?))) + .collect::>>()? + }; + for name in unsupported { let building: Vec<&str> = others .iter() - .flatten() .filter(|(_, harnesses)| harnesses.contains(name)) .map(|(other, _)| *other) .collect(); diff --git a/crates/nemoclaw-cli/src/formatting.rs b/crates/nemoclaw-cli/src/formatting.rs index 86f24b76851..b9014bbefcd 100644 --- a/crates/nemoclaw-cli/src/formatting.rs +++ b/crates/nemoclaw-cli/src/formatting.rs @@ -8,6 +8,7 @@ use crate::{ }; use nemoclaw_sdk::{Error, OperationResult, Outcome}; use std::{ + borrow::Cow, collections::BTreeSet, io::IsTerminal, path::PathBuf, @@ -91,6 +92,13 @@ impl RenderContext { .collect() } + fn add_warnings(&self, value: &mut serde_json::Value) { + let warnings = self.warnings(); + if !warnings.is_empty() { + value["warnings"] = serde_json::json!(warnings); + } + } + fn append_warnings(&self, output: &mut String) { let warnings = self.warnings(); if !warnings.is_empty() { @@ -131,8 +139,7 @@ pub(crate) fn render( }, OutputFormat::Json => { let mut value = serde_json::to_value(&result)?; - let warnings = context.warnings(); - if !warnings.is_empty() { value["warnings"] = serde_json::json!(warnings); } + context.add_warnings(&mut value); if result.outcome == Outcome::Planned { value["complete"] = serde_json::Value::Bool(result.deferred.is_empty()); } @@ -608,10 +615,7 @@ pub(crate) fn render_error( "stateDirectory": context.state_dir, "error": { "message": message }, }); - let warnings = context.warnings(); - if !warnings.is_empty() { - details["warnings"] = serde_json::json!(warnings); - } + context.add_warnings(&mut details); if let Some(input) = &context.input { details["input"] = serde_json::json!(input); } @@ -631,15 +635,15 @@ pub(crate) fn render_error( details["remainingState"] = serde_json::json!(remaining); } let help = match sdk { - Some(Error::SandboxChangeRefused { .. }) => Some( - "Keep this deployment's state. Use a separate deployment with a fresh UID and state directory; see docs/usage.md#choose-the-change-path. Export and destroy still use the retained configuration.".to_owned(), - ), - Some(Error::SandboxStartup { .. }) => Some( - "Inspect the sandbox with OpenShell using this deployment's gateway and workspace; collect gateway and supervisor logs before cleanup.".to_owned(), - ), - Some(Error::DockerModelUpdateRefused { service }) => Some(format!( - "To replace the running model container, set spec.services.{service}.updatePolicy: Recreate and apply again; the model is unavailable until the replacement starts. See docs/inference.md#set-container-limits-and-update-policy." + Some(Error::SandboxChangeRefused { .. }) => Some(Cow::Borrowed( + "Keep this deployment's state. Use a separate deployment with a fresh UID and state directory; see docs/usage.md#choose-the-change-path. Export and destroy still use the retained configuration.", )), + Some(Error::SandboxStartup { .. }) => Some(Cow::Borrowed( + "Inspect the sandbox with OpenShell using this deployment's gateway and workspace; collect gateway and supervisor logs before cleanup.", + )), + Some(Error::DockerModelUpdateRefused { service }) => Some(Cow::Owned(format!( + "To replace the running model container, set spec.services.{service}.updatePolicy: Recreate and apply again; the model is unavailable until the replacement starts. See docs/inference.md#set-container-limits-and-update-policy." + ))), _ => None, }; if let Some(help) = &help { diff --git a/crates/nemoclaw-sdk/src/state/mod.rs b/crates/nemoclaw-sdk/src/state/mod.rs index 2615239d819..44bede326aa 100644 --- a/crates/nemoclaw-sdk/src/state/mod.rs +++ b/crates/nemoclaw-sdk/src/state/mod.rs @@ -432,14 +432,14 @@ impl StateBinding { pub(crate) struct Store { pub directory: PathBuf, - _lock: File, + lock: File, } impl Drop for Store { fn drop(&mut self) { // A concurrently spawned child can retain the shared open file // description until exec. Closing our descriptor alone would then // leave the deployment locked after this operation has finished. - let _ = self._lock.unlock(); + let _ = self.lock.unlock(); } } impl Store { @@ -469,7 +469,7 @@ impl Store { })?; Ok(Self { directory: directory.into(), - _lock: lock, + lock, }) } pub fn load(&self) -> Result, Error> { diff --git a/crates/nemoclaw-sdk/src/state/tests.rs b/crates/nemoclaw-sdk/src/state/tests.rs index 276aae5d23d..6b93723fe9f 100644 --- a/crates/nemoclaw-sdk/src/state/tests.rs +++ b/crates/nemoclaw-sdk/src/state/tests.rs @@ -10,7 +10,7 @@ fn dropping_store_releases_lock_while_a_duplicate_descriptor_remains_open() { let store = Store::open(directory.path()).unwrap(); // Model the shared open file description inherited by a concurrent spawn // before exec closes the child's copy, without depending on spawn timing. - let inherited = store._lock.try_clone().unwrap(); + let inherited = store.lock.try_clone().unwrap(); assert!(Store::open(directory.path()).is_err()); drop(store);