From 7461c7a6d174a27f3e0ffc57adac4485572f6608 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Thu, 8 Oct 2026 23:42:47 -0700 Subject: [PATCH 01/18] ci: report where test time goes after each test step Test time had no visible budget: the lifecycle step reached 684 s on linux_arm64 for 2,673 s of tests, and finding the slow tests meant downloading an artifact and reading JUnit XML. After the test, lifecycle, and live steps, cargo ci reads the step's nextest JUnit report and prints its test count, wall and summed time, the time per test binary and module, and the slowest tests. In GitHub Actions the report goes to the job summary. The deterministic step now writes and uploads a JUnit report too. Part of #12877. --- .config/nextest.toml | 5 + .github/workflows/rust.yml | 8 ++ crates/nemoclaw-build/src/ci.rs | 14 +++ crates/nemoclaw-build/src/ci/timing.rs | 123 +++++++++++++++++++++++++ crates/nemoclaw-build/src/run_ci.rs | 40 ++++++++ crates/nemoclaw-build/tests/ci.rs | 55 +++++++++++ docs/contributing/testing.md | 3 +- 7 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 crates/nemoclaw-build/src/ci/timing.rs diff --git a/.config/nextest.toml b/.config/nextest.toml index 07709b53ff1..e4cf710a944 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -9,6 +9,11 @@ retries = 0 test-threads = 8 slow-timeout = { period = "30s", terminate-after = 10 } +# Each test step writes a JUnit report that `cargo ci` summarizes into where +# its time went. +[profile.ci.junit] +path = "test.xml" + [profile.lifecycle] inherits = "ci" test-threads = 4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 68d0ead996b..821cde0c244 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -58,6 +58,14 @@ jobs: run: cargo ci bundle - name: Execute real OpenTofu and SDK/CLI lifecycle run: cargo ci lifecycle + - name: Upload deterministic test timings + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: test-${{ matrix.platform }}-${{ github.run_attempt }} + path: target/nextest/ci/test.xml + if-no-files-found: ignore + retention-days: 14 - name: Upload lifecycle timings if: always() uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/crates/nemoclaw-build/src/ci.rs b/crates/nemoclaw-build/src/ci.rs index d5fb671f47c..34954eab2f6 100644 --- a/crates/nemoclaw-build/src/ci.rs +++ b/crates/nemoclaw-build/src/ci.rs @@ -63,6 +63,19 @@ impl Step { .find(|step| step.name() == name) } + /// The nextest profile and the JUnit report a test step writes under + /// `target/nextest`. + #[must_use] + pub fn junit(self) -> Option<(&'static str, &'static str)> { + match self { + Step::Test => Some(("ci", "test.xml")), + Step::Lifecycle => Some(("lifecycle", "lifecycle.xml")), + Step::LiveDocker => Some(("live-docker", "live-docker.xml")), + Step::LiveKind => Some(("live-kind", "live-kind.xml")), + _ => None, + } + } + /// Cargo arguments for this step. Tools, schema, and bundle run in-process /// or through the built tool and have none. pub fn cargo_args(self) -> &'static [&'static [&'static str]] { @@ -132,6 +145,7 @@ impl Step { } pub mod live; +pub mod timing; /// The nextest release target for a bundle platform. pub fn nextest_target(platform: &str) -> Result<&'static str, String> { diff --git a/crates/nemoclaw-build/src/ci/timing.rs b/crates/nemoclaw-build/src/ci/timing.rs new file mode 100644 index 00000000000..687655d7cca --- /dev/null +++ b/crates/nemoclaw-build/src/ci/timing.rs @@ -0,0 +1,123 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Where test time goes, read from a nextest JUnit report. + +use std::{collections::BTreeMap, fmt::Write}; + +/// One test's result. +#[derive(Clone, Debug, PartialEq)] +pub struct Test { + /// Test binary, as nextest names it, such as `nemoclaw-e2e::integration`. + pub binary: String, + /// Test path within the binary, such as `deployment::applies`. + pub name: String, + pub seconds: f64, + pub failed: bool, +} + +/// One nextest run. +#[derive(Clone, Debug, PartialEq)] +pub struct Run { + /// Elapsed time of the whole run. + pub wall_seconds: f64, + pub tests: Vec, +} + +/// The value of `name` among an element's attributes, unescaped. +fn attribute(element: &str, name: &str) -> Option { + let start = element.find(&format!(" {name}=\""))? + name.len() + 3; + let end = start + element[start..].find('"')?; + Some( + element[start..end] + .replace("<", "<") + .replace(">", ">") + .replace(""", "\"") + .replace("'", "'") + .replace("&", "&"), + ) +} + +fn seconds(element: &str) -> Result { + attribute(element, "time") + .and_then(|time| time.parse().ok()) + .ok_or_else(|| "JUnit element lacks its time".to_owned()) +} + +impl Run { + /// Read a nextest JUnit report. + /// + /// # Errors + /// Returns an error when the report lacks its run or test times. + pub fn parse(xml: &str) -> Result { + let open = xml + .find("")?; + let header = &xml[open..open + xml[open..].find('>').ok_or("unterminated ")?]; + let wall_seconds = seconds(header)?; + let mut tests = Vec::new(); + let mut rest = &xml[open..]; + while let Some(start) = rest.find("').ok_or("unterminated ")?; + let element = &rest[..end]; + // A test failed when its element holds a failure or error. + let failed = !element.ends_with('/') && { + let body = &rest[end..rest.find("").unwrap_or(rest.len())]; + body.contains(" String { + let summed: f64 = self.tests.iter().map(|test| test.seconds).sum(); + let mut report = format!( + "### {profile}: {} tests, {:.1} s wall, {:.1} s summed\n\n", + self.tests.len(), + self.wall_seconds, + summed + ); + let mut groups: BTreeMap<(&str, &str), (usize, f64, f64)> = BTreeMap::new(); + for test in &self.tests { + let module = test.name.split("::").next().unwrap_or(&test.name); + let group = groups.entry((&test.binary, module)).or_default(); + group.0 += 1; + group.1 += test.seconds; + group.2 = group.2.max(test.seconds); + } + let mut groups: Vec<_> = groups.into_iter().collect(); + groups.sort_by(|a, b| b.1.1.total_cmp(&a.1.1)); + report.push_str("| Binary | Module | Tests | Summed | Slowest |\n|---|---|---|---|---|\n"); + for ((binary, module), (count, total, max)) in groups { + let _ = writeln!( + report, + "| {binary} | {module} | {count} | {total:.1} s | {max:.1} s |" + ); + } + let mut tests: Vec<_> = self.tests.iter().collect(); + tests.sort_by(|a, b| b.seconds.total_cmp(&a.seconds)); + report.push_str("\n| Time | Slowest tests |\n|---|---|\n"); + for test in tests.into_iter().take(slowest) { + let failed = if test.failed { " (failed)" } else { "" }; + let _ = writeln!( + report, + "| {:.1} s | {} {}{failed} |", + test.seconds, test.binary, test.name + ); + } + report + } +} diff --git a/crates/nemoclaw-build/src/run_ci.rs b/crates/nemoclaw-build/src/run_ci.rs index f4b428f5635..69d016c9a29 100644 --- a/crates/nemoclaw-build/src/run_ci.rs +++ b/crates/nemoclaw-build/src/run_ci.rs @@ -206,6 +206,45 @@ fn run_step(tools: &Tools<'_>, platform: &str, step: Step) -> Result<()> { Ok(()) } +/// Report where a test step spent its time, from the JUnit report it wrote +/// after `begun`, and add the report to the GitHub job summary. +fn report_timing(step: Step, begun: Instant) { + let Some((profile, file)) = step.junit() else { + return; + }; + let path = Path::new("target").join("nextest").join(profile).join(file); + let started = std::time::SystemTime::now() - begun.elapsed(); + // A report from an earlier run would misstate this one. + let fresh = std::fs::metadata(&path) + .and_then(|metadata| metadata.modified()) + .is_ok_and(|modified| modified >= started); + if !fresh { + return; + } + let report = match std::fs::read_to_string(&path) + .map_err(|error| error.to_string()) + .and_then(|xml| ci::timing::Run::parse(&xml)) + { + Ok(run) => run.report(step.name(), 15), + Err(error) => { + eprintln!("cannot read test timings from {}: {error}", path.display()); + return; + } + }; + eprintln!("{report}"); + if let Some(summary) = std::env::var_os("GITHUB_STEP_SUMMARY") { + use std::io::Write; + let appended = std::fs::OpenOptions::new() + .append(true) + .create(true) + .open(summary) + .and_then(|mut file| writeln!(file, "{report}")); + if let Err(error) = appended { + eprintln!("cannot write the job summary: {error}"); + } + } +} + pub(super) async fn run_steps(pins: &Pins, selected: Option<&str>) -> Result<()> { let tools = Tools { pins, @@ -250,6 +289,7 @@ pub(super) async fn run_steps(pins: &Pins, selected: Option<&str>) -> Result<()> run_step(&tools, &platform, step) }; let elapsed = begun.elapsed().as_secs(); + report_timing(step, begun); if let Err(error) = result { eprintln!("FAILED {} after {elapsed}s: {error}", step.name()); eprintln!("Rerun it with: cargo ci {}", step.name()); diff --git a/crates/nemoclaw-build/tests/ci.rs b/crates/nemoclaw-build/tests/ci.rs index dc4b61c2c2c..d2fef239943 100644 --- a/crates/nemoclaw-build/tests/ci.rs +++ b/crates/nemoclaw-build/tests/ci.rs @@ -239,3 +239,58 @@ fn nextest_archive_installs_only_its_single_executable() { assert!(ci::install_nextest(&archive, &directory.path().join("other"), false).is_err()); } } + +const JUNIT: &str = r#" + + + + + + failed + + + + + + + +"#; + +#[test] +fn timing_reports_show_wall_time_and_where_test_time_goes() { + let run = ci::timing::Run::parse(JUNIT).unwrap(); + assert_eq!(run.wall_seconds, 12.5); + assert_eq!(run.tests.len(), 4); + assert_eq!(run.tests[1].name, r#"deployment::quick & "quoted""#); + assert!(run.tests[1].failed); + + let report = run.report("lifecycle", 2); + // The headline names the profile, its test count, wall time, and summed time. + assert!( + report.contains("lifecycle: 4 tests, 12.5 s wall, 12.5 s summed"), + "{report}" + ); + // Groups are a binary and a test module, slowest first. + let groups = report.find("| nemoclaw-e2e::integration | deployment | 2 | 10.0 s | 9.2 s |"); + let storage = + report.find("| nemoclaw-e2e::integration | service_storage | 1 | 2.0 s | 2.0 s |"); + assert!( + groups.is_some() && storage.is_some() && groups < storage, + "{report}" + ); + // Only the slowest tests are listed, slowest first. + assert!( + report.contains("| 9.2 s | nemoclaw-e2e::integration deployment::slow_scenario |"), + "{report}" + ); + assert!( + report.contains("| 2.0 s | nemoclaw-e2e::integration service_storage::applies |"), + "{report}" + ); + assert!( + !report.contains("| 0.5 s | nemoclaw-sdk state::reads |"), + "{report}" + ); + + assert!(ci::timing::Run::parse("").is_err()); +} diff --git a/docs/contributing/testing.md b/docs/contributing/testing.md index f3a5cb119d1..0641e452769 100644 --- a/docs/contributing/testing.md +++ b/docs/contributing/testing.md @@ -74,7 +74,8 @@ All native CI platforms use cargo-nextest 0.9.144 for ordinary tests and the exp The `ci` profile runs at most eight tests concurrently, reports slow tests every 30 seconds, terminates a test after five minutes, and does not retry failures. The `lifecycle` profile selects the isolated bundle fixtures and native-state test, with four concurrent tests and the same timeout. CI retains the same workspace and target selection across both runs so Cargo can reuse the compiled tests. -Lifecycle timing artifacts contain per-test durations for comparing scheduling changes. +After each test step, `cargo ci` prints where the time went: the step's test count, wall time, and summed test time, the time per test binary and module, and the 15 slowest tests. +In GitHub Actions, the report is added to the job summary, and the JUnit reports with per-test durations are uploaded as the `test-` and `lifecycle-` artifacts. Both profiles finish the remaining tests after a failure. Use the [fixture prerequisites](integration-tests.md#opentofu-and-bundle-lifecycle) before selecting ignored tests; the profiles do not configure a bundle or authorize live resources. Nextest does not run doctests, so the separate Cargo command remains required. From 087ffee3df7a4ae9f296ff88b114ef74f4575153 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 00:04:43 -0700 Subject: [PATCH 02/18] ci: read nextest JUnit reports with quick-junit The timing report parsed JUnit XML by hand. quick-junit, the library nextest writes these reports with, deserializes them. The report also limits its module table to the slowest rows and sums the rest, since the deterministic step has over a hundred modules. --- Cargo.lock | 54 ++++++++++++++++- Cargo.toml | 1 + crates/nemoclaw-build/Cargo.toml | 1 + crates/nemoclaw-build/src/ci/timing.rs | 82 ++++++++++---------------- crates/nemoclaw-build/tests/ci.rs | 15 +++-- 5 files changed, 97 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f97f2ccfb36..dcb6d5614ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2305,6 +2305,7 @@ dependencies = [ "nemoclaw-sdk", "pulldown-cmark", "pulldown-cmark-to-cmark", + "quick-junit", "reqwest 0.13.5", "serde", "serde-saphyr 1.2.0", @@ -2603,6 +2604,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "newtype-uuid" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa56da58097c7ae893c4097bb6d91bb5f7fa330053e07e033349db4d5f83ba8" +dependencies = [ + "uuid", +] + [[package]] name = "nix" version = "0.29.0" @@ -3338,6 +3348,30 @@ dependencies = [ "pulldown-cmark", ] +[[package]] +name = "quick-junit" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae23b8e1a59a90f7bf98caa2f4c8c2eedf6df011c6c88ed633e85a87c84526e" +dependencies = [ + "chrono", + "indexmap", + "newtype-uuid", + "quick-xml", + "strip-ansi-escapes", + "thiserror 2.0.20", + "uuid", +] + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + [[package]] name = "quinn" version = "0.11.12" @@ -4314,6 +4348,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strip-ansi-escapes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" +dependencies = [ + "vte 0.14.1", +] + [[package]] name = "strsim" version = "0.11.1" @@ -5098,7 +5141,16 @@ checksum = "054ff75fb8fa83e609e685106df4faeffdf3a735d3c74ebce97ec557d5d36fd9" dependencies = [ "itoa", "unicode-width 0.2.2", - "vte", + "vte 0.15.0", +] + +[[package]] +name = "vte" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" +dependencies = [ + "memchr", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f4afb673aa8..19b5ad7c1b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ unsafe_code = "forbid" all = "warn" [workspace.dependencies] +quick-junit = "0.8.0" thiserror = "2" async-trait = "0.1" serde = { version = "1", features = ["derive"] } diff --git a/crates/nemoclaw-build/Cargo.toml b/crates/nemoclaw-build/Cargo.toml index 6c9f025ed78..e9c3be244ab 100644 --- a/crates/nemoclaw-build/Cargo.toml +++ b/crates/nemoclaw-build/Cargo.toml @@ -31,6 +31,7 @@ serde-saphyr.workspace = true pulldown-cmark = { workspace = true, optional = true } pulldown-cmark-to-cmark = { workspace = true, optional = true } url.workspace = true +quick-junit.workspace = true [build-dependencies] sha2.workspace = true [lints] diff --git a/crates/nemoclaw-build/src/ci/timing.rs b/crates/nemoclaw-build/src/ci/timing.rs index 687655d7cca..f442fc15325 100644 --- a/crates/nemoclaw-build/src/ci/timing.rs +++ b/crates/nemoclaw-build/src/ci/timing.rs @@ -23,66 +23,43 @@ pub struct Run { pub tests: Vec, } -/// The value of `name` among an element's attributes, unescaped. -fn attribute(element: &str, name: &str) -> Option { - let start = element.find(&format!(" {name}=\""))? + name.len() + 3; - let end = start + element[start..].find('"')?; - Some( - element[start..end] - .replace("<", "<") - .replace(">", ">") - .replace(""", "\"") - .replace("'", "'") - .replace("&", "&"), - ) -} - -fn seconds(element: &str) -> Result { - attribute(element, "time") - .and_then(|time| time.parse().ok()) - .ok_or_else(|| "JUnit element lacks its time".to_owned()) -} - impl Run { /// Read a nextest JUnit report. /// /// # Errors - /// Returns an error when the report lacks its run or test times. + /// Returns an error when the report is not JUnit XML or lacks its run time. pub fn parse(xml: &str) -> Result { - let open = xml - .find("")?; - let header = &xml[open..open + xml[open..].find('>').ok_or("unterminated ")?]; - let wall_seconds = seconds(header)?; - let mut tests = Vec::new(); - let mut rest = &xml[open..]; - while let Some(start) = rest.find("').ok_or("unterminated ")?; - let element = &rest[..end]; - // A test failed when its element holds a failure or error. - let failed = !element.ends_with('/') && { - let body = &rest[end..rest.find("").unwrap_or(rest.len())]; - body.contains(" String { + pub fn report(&self, profile: &str, rows: usize) -> String { let summed: f64 = self.tests.iter().map(|test| test.seconds).sum(); let mut report = format!( "### {profile}: {} tests, {:.1} s wall, {:.1} s summed\n\n", @@ -101,16 +78,21 @@ impl Run { let mut groups: Vec<_> = groups.into_iter().collect(); groups.sort_by(|a, b| b.1.1.total_cmp(&a.1.1)); report.push_str("| Binary | Module | Tests | Summed | Slowest |\n|---|---|---|---|---|\n"); - for ((binary, module), (count, total, max)) in groups { + let rest: f64 = groups.iter().skip(rows).map(|group| group.1.1).sum(); + let others = groups.len().saturating_sub(rows); + for ((binary, module), (count, total, max)) in groups.into_iter().take(rows) { let _ = writeln!( report, "| {binary} | {module} | {count} | {total:.1} s | {max:.1} s |" ); } + if others > 0 { + let _ = writeln!(report, "| {others} other modules | | | {rest:.1} s | |"); + } let mut tests: Vec<_> = self.tests.iter().collect(); tests.sort_by(|a, b| b.seconds.total_cmp(&a.seconds)); report.push_str("\n| Time | Slowest tests |\n|---|---|\n"); - for test in tests.into_iter().take(slowest) { + for test in tests.into_iter().take(rows) { let failed = if test.failed { " (failed)" } else { "" }; let _ = writeln!( report, diff --git a/crates/nemoclaw-build/tests/ci.rs b/crates/nemoclaw-build/tests/ci.rs index d2fef239943..c2c1466c8d9 100644 --- a/crates/nemoclaw-build/tests/ci.rs +++ b/crates/nemoclaw-build/tests/ci.rs @@ -241,17 +241,17 @@ fn nextest_archive_installs_only_its_single_executable() { } const JUNIT: &str = r#" - + - + - + failed - + - + "#; @@ -278,6 +278,11 @@ fn timing_reports_show_wall_time_and_where_test_time_goes() { groups.is_some() && storage.is_some() && groups < storage, "{report}" ); + // The remaining modules are summed on one row. + assert!( + report.contains("| 1 other modules | | | 0.5 s | |"), + "{report}" + ); // Only the slowest tests are listed, slowest first. assert!( report.contains("| 9.2 s | nemoclaw-e2e::integration deployment::slow_scenario |"), From 0d08c53935cf53a19184652c141d6a311ad8e118 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 01:51:16 -0700 Subject: [PATCH 03/18] test(e2e): deploy each configuration variant once in deployment The deployment module took 1,331 s of the 2,948 s summed lifecycle time on linux_amd64. Profiling one lifecycle() locally showed where it goes: about 11-18 s per full plan, apply, CLI export, reapply, drift checks, and CLI destroy, of which five OpenTofu plans take a third. On CI each lifecycle takes about 33 s, and 12 tests ran 24 of them to cover configuration variants that the SDK already proves equivalent. Each variant group now deploys once per behavior the deployment owns: - web_search: 6 -> 2 lifecycles. One per provider, in different scopes; web_search::agent_inline_and_enclosing_definitions_compile_to_the_same_search_grants owns scope equivalence. - execution_settings: 3 -> 1. Heartbeats are opaque native settings; execution_settings owns the timeout projection. - tool_disclosure: 2 -> 1. agent_tools::disclosure_belongs_to_opaque_native_settings owns both modes. - provider_definitions: 4 -> 2. One scope per harness; inference_references owns that both scopes compile and export unchanged. Locally the four tests take 34 s at four threads instead of over 109 s for web_search alone. Part of #12882. --- crates/nemoclaw-e2e/tests/deployment.rs | 100 +++++++++++++----------- 1 file changed, 56 insertions(+), 44 deletions(-) diff --git a/crates/nemoclaw-e2e/tests/deployment.rs b/crates/nemoclaw-e2e/tests/deployment.rs index 3ad0f41fa64..23f60a83093 100644 --- a/crates/nemoclaw-e2e/tests/deployment.rs +++ b/crates/nemoclaw-e2e/tests/deployment.rs @@ -413,37 +413,42 @@ async fn separate_agent_sandboxes_cli_export_reapply_and_policy_drift() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE"] async fn tool_disclosure_cli_export_reapply_and_drift() { - for mode in ["direct".to_owned(), "progressive".to_owned()] { - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()) - .unwrap(); - document.spec.sandboxes[0].harness.as_mut().unwrap().settings = Some(serde_json::from_value(serde_json::json!({"native_config":{"tools":{"toolSearch":if mode == "direct" { serde_json::json!(false) } else { serde_json::json!({"mode":"tools","searchDefaultLimit":8,"maxSearchLimit":20}) }}}})).unwrap()); - // Exercise the existing launch-setting drift assertions as well as export/reapply. - document.spec.inference_providers[0].api = - Some(nemoclaw_sdk::config::InferenceApi::OpenaiCompletions); - lifecycle(&document.yaml().unwrap()).await; - } + // Disclosure modes are opaque native settings; agent_tools in the SDK owns + // both modes, so one deployment covers their drift detection. + let mut document = + Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); + document.spec.sandboxes[0] + .harness + .as_mut() + .unwrap() + .settings = Some( + serde_json::from_value(serde_json::json!({"native_config":{"tools":{"toolSearch": + {"mode":"tools","searchDefaultLimit":8,"maxSearchLimit":20}}}})) + .unwrap(), + ); + // Exercise the existing launch-setting drift assertions as well as export/reapply. + document.spec.inference_providers[0].api = + Some(nemoclaw_sdk::config::InferenceApi::OpenaiCompletions); + lifecycle(&document.yaml().unwrap()).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE"] async fn execution_settings_cli_export_reapply_and_drift() { - for heartbeat in [None, Some("0m"), Some("30m")] { - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()) - .unwrap(); - document.spec.sandboxes[0] - .harness - .as_mut() - .unwrap() - .execution = Some(nemoclaw_sdk::config::AgentExecution { - timeout_seconds: Some(900), - }); - if let Some(every) = heartbeat { - document.spec.sandboxes[0].harness.as_mut().unwrap().settings = Some(serde_json::from_value(serde_json::json!({"native_config":{"agents":{"defaults":{"heartbeat":{"every":every,"isolatedSession":true}}}}})).unwrap()); - } - lifecycle(&document.yaml().unwrap()).await; - } + // Heartbeats are opaque native settings, and execution_settings in the SDK + // owns the timeout projection, so one deployment covers both. + let mut document = + Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); + let harness = document.spec.sandboxes[0].harness.as_mut().unwrap(); + harness.execution = Some(nemoclaw_sdk::config::AgentExecution { + timeout_seconds: Some(900), + }); + harness.settings = Some( + serde_json::from_value(serde_json::json!({"native_config":{"agents":{"defaults": + {"heartbeat":{"every":"30m","isolatedSession":true}}}}})) + .unwrap(), + ); + lifecycle(&document.yaml().unwrap()).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -479,21 +484,22 @@ async fn hermes_interfaces_sdk_export_reapply_and_drift() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE"] async fn web_search_cli_export_reapply_and_destroy() { - for provider in ["tavily", "brave"] { + // Every definition scope compiles to the same targets (web_search in the + // SDK), so each provider deploys once, in a different scope. + for (provider, inline) in [("tavily", false), ("brave", true)] { let mut document = Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()) .unwrap(); - document.spec.integrations = serde_json::from_value(serde_json::json!({ + let definitions = serde_json::from_value(serde_json::json!({ "search":{"kind":"webSearch","provider":provider,"credential":{"env":"SEARCH_KEY"}} })) .unwrap(); - document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; - lifecycle(&document.yaml().unwrap()).await; - document.spec.sandboxes[0].integrations = std::mem::take(&mut document.spec.integrations); - lifecycle(&document.yaml().unwrap()).await; - let sandbox = &mut document.spec.sandboxes[0]; - sandbox.agent.integration_refs.clear(); - sandbox.agent.integrations = std::mem::take(&mut sandbox.integrations); + if inline { + document.spec.sandboxes[0].agent.integrations = definitions; + } else { + document.spec.integrations = definitions; + document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; + } lifecycle(&document.yaml().unwrap()).await; } } @@ -501,9 +507,12 @@ async fn web_search_cli_export_reapply_and_destroy() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE"] async fn provider_definitions_export_reapply_and_destroy_in_their_authored_scope() { - for input in [ - include_str!("../../../examples/fabric-openclaw.yaml"), - include_str!("../../../examples/hermes-auth.yaml"), + for (input, inline_route) in [ + ( + include_str!("../../../examples/fabric-openclaw.yaml"), + false, + ), + (include_str!("../../../examples/hermes-auth.yaml"), true), ] { let mut document = Document::parse(input.as_bytes()).unwrap(); document.spec.sandboxes[0].inference_providers = @@ -515,12 +524,15 @@ async fn provider_definitions_export_reapply_and_destroy_in_their_authored_scope })) .unwrap(), ); - lifecycle(&document.yaml().unwrap()).await; - let sandbox = &mut document.spec.sandboxes[0]; - let provider = sandbox.inference_providers.remove(0); - let route = &mut sandbox.agent.inference.as_mut().unwrap().routes[0]; - route.provider_ref = None; - route.provider = Some(provider); + // Each harness deploys its providers in one scope; inference_references + // in the SDK owns that both scopes compile and export unchanged. + if inline_route { + let sandbox = &mut document.spec.sandboxes[0]; + let provider = sandbox.inference_providers.remove(0); + let route = &mut sandbox.agent.inference.as_mut().unwrap().routes[0]; + route.provider_ref = None; + route.provider = Some(provider); + } lifecycle(&document.yaml().unwrap()).await; } } From ff263fff73461c28f86d3553d3553af9b5d89509 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 02:05:43 -0700 Subject: [PATCH 04/18] test(e2e): check each redaction rule once through the CLI cli_redaction ran 13 CLI applies, about 30 s locally: four credentials in both output formats. nemoclaw-sdk's process tests own the redaction rules for short, colliding, overlapping, and Unicode credentials. The CLI test now checks that each rule reaches a failed apply's output, one credential per rule across both formats, in 18 s. Part of #12882. --- crates/nemoclaw-e2e/tests/deployment.rs | 96 +++++++++++++------------ 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/crates/nemoclaw-e2e/tests/deployment.rs b/crates/nemoclaw-e2e/tests/deployment.rs index 23f60a83093..ace14829193 100644 --- a/crates/nemoclaw-e2e/tests/deployment.rs +++ b/crates/nemoclaw-e2e/tests/deployment.rs @@ -1709,54 +1709,58 @@ async fn cli_redaction_preserves_failures_and_recovery_with_short_and_colliding_ fixture.state.lock().unwrap().configuration_error = Some(serde_json::json!({ "error": {"stage":"start", "code":"lifecycle_adapter_start_failed", "runtime_state":"unavailable", "message":"native-secret-must-not-escape"} })); - for secret in [ - "a", - "z", - "lifecycle_adapter_start_failed", - "inert-credential-for-context-check", + // Redaction rules belong to nemoclaw-sdk's process tests; this checks + // that each rule reaches both output formats of a failed apply. + for (secret, format) in [ + ("a", "text"), + ("lifecycle_adapter_start_failed", "json"), + ("inert-credential-for-context-check", "text"), ] { - for format in ["text", "json"] { - let failed = invoke("apply", format, secret); - assert_eq!(failed.status.code(), Some(1)); - let stdout = String::from_utf8(failed.stdout).unwrap(); - let stderr = String::from_utf8(failed.stderr).unwrap(); - let message = if format == "json" { - let result: serde_json::Value = serde_json::from_str(&stdout).unwrap(); - assert_eq!(result["outcome"], "failed"); - result["error"]["message"].as_str().unwrap().to_owned() - } else { - stderr.clone() - }; - if secret.len() == 1 { - assert!(message.contains("child diagnostic withheld because a credential is too short for safe redaction"), "{message}"); - assert!( - !message.contains("[redacted]"), - "short-value character matches must not escape" - ); - } else if secret == "lifecycle_adapter_start_failed" { - assert!(message.contains("[redacted]"), "{message}"); - assert!( - message.contains("agent runtime is unavailable"), - "{message}" - ); - assert!(!message.contains(secret)); - } else { - assert!(message.contains("sandbox/assistant"), "{message}"); - assert!( - message.contains("lifecycle_adapter_start_failed"), - "{message}" - ); - assert!( - message.contains("agent runtime is unavailable"), - "{message}" - ); - } - assert!(!message.contains("[[redacted]]")); - assert!(!stdout.contains("native-secret-must-not-escape")); - assert!(!stderr.contains("native-secret-must-not-escape")); - assert_eq!(fixture.state.lock().unwrap().sandboxes, original); - assert_eq!(fixture.state.lock().unwrap().effects, effects); + let failed = invoke("apply", format, secret); + assert_eq!(failed.status.code(), Some(1)); + let stdout = String::from_utf8(failed.stdout).unwrap(); + let stderr = String::from_utf8(failed.stderr).unwrap(); + let message = if format == "json" { + let result: serde_json::Value = serde_json::from_str(&stdout).unwrap(); + assert_eq!(result["outcome"], "failed"); + result["error"]["message"].as_str().unwrap().to_owned() + } else { + stderr.clone() + }; + if secret.len() == 1 { + assert!( + message.contains( + "child diagnostic withheld because a credential is too short for safe redaction" + ), + "{message}" + ); + assert!( + !message.contains("[redacted]"), + "short-value character matches must not escape" + ); + } else if secret == "lifecycle_adapter_start_failed" { + assert!(message.contains("[redacted]"), "{message}"); + assert!( + message.contains("agent runtime is unavailable"), + "{message}" + ); + assert!(!message.contains(secret)); + } else { + assert!(message.contains("sandbox/assistant"), "{message}"); + assert!( + message.contains("lifecycle_adapter_start_failed"), + "{message}" + ); + assert!( + message.contains("agent runtime is unavailable"), + "{message}" + ); } + assert!(!message.contains("[[redacted]]")); + assert!(!stdout.contains("native-secret-must-not-escape")); + assert!(!stderr.contains("native-secret-must-not-escape")); + assert_eq!(fixture.state.lock().unwrap().sandboxes, original); + assert_eq!(fixture.state.lock().unwrap().effects, effects); } fixture.state.lock().unwrap().configuration_error = None; let recovered = invoke("apply", "json", "a"); From fed2f353c1828e4a80b26d28ec768d19e4e864c4 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 02:27:37 -0700 Subject: [PATCH 05/18] test(e2e): keep each harness's remote service checks to what it owns remote_service took 697 s summed on linux_amd64. Locally each of its five full lifecycles runs about 30 CLI commands in 80-136 s, and only two steps depend on the harness: image pull checks for OpenClaw and refused sandbox changes for Pi. - The non-authenticated Hermes lifecycle repeated the OpenClaw vLLM lifecycle step for step. Hermes with remote vLLM stays covered by the bearer lifecycle, and fabric_deployment covers each harness. - Pi stops after admission without generation, its refused sandbox changes, and destroy; the service recovery that followed did not depend on the harness. - Refused sandbox changes exported after each of eight refusals, about 4 s each, while byte comparisons of the saved intent and state already prove nothing changed. One export after the refusals checks that the intent still reproduces the accepted document. Locally the module sums 400 s instead of 562 s across its tests. Part of #12882. --- crates/nemoclaw-e2e/tests/remote_service.rs | 31 +++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/crates/nemoclaw-e2e/tests/remote_service.rs b/crates/nemoclaw-e2e/tests/remote_service.rs index e003a70281e..67415645fbe 100644 --- a/crates/nemoclaw-e2e/tests/remote_service.rs +++ b/crates/nemoclaw-e2e/tests/remote_service.rs @@ -85,18 +85,13 @@ async fn remote_model_lifecycle_preserves_data_and_stops_on_observation_failure( lifecycle("nvidia.fabric.openclaw", false, "vllm", false, false).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE; isolated fixtures"] -async fn managed_hermes_model_lifecycle_preserves_data_without_generation() { - lifecycle("nvidia.fabric.hermes", false, "vllm", false, false).await; -} -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE; isolated credential and SSH fixtures"] async fn managed_bearer_credentials_survive_export_reapply_and_destroy() { lifecycle("nvidia.fabric.hermes", true, "vllm", false, false).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires explicit verified NEMOCLAW_TEST_BUNDLE; isolated SSH/Docker and OpenShell fixtures"] -async fn managed_pi_model_lifecycle_preserves_data_without_generation() { +async fn managed_pi_applies_without_generation_and_refused_sandbox_changes_keep_intent() { lifecycle("nvidia.fabric.pi", false, "vllm", false, false).await; } #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -389,6 +384,15 @@ async fn lifecycle( ); } } + // Pi proves a managed service applies without generation and that refused + // sandbox changes keep retained intent; the service recovery below does + // not depend on the harness and runs for the other harnesses. + if harness == "nvidia.fabric.pi" { + refused_sandbox_changes_preserve_retained_intent(root, &bundle, &gateway).await; + run(root, &bundle, "destroy", "", true).await; + assert!(read(root, "engine.json")["container"].is_null()); + return; + } if check_pulls { assert_eq!(read(root, "engine.json")["pulls"], 1); let original = read(root, "config.yaml"); @@ -582,9 +586,6 @@ async fn lifecycle( || arg == "probe" || arg == "--message") ); - if harness == "nvidia.fabric.pi" { - refused_sandbox_changes_preserve_retained_intent(root, &bundle, &gateway).await; - } if check_pulls { let mut changed = read(root, "config.yaml"); changed["spec"]["services"]["qwen"] @@ -794,13 +795,15 @@ async fn refused_sandbox_changes_preserve_retained_intent( assert!(result.get("remainingState").is_none(), "{result}"); } assert!(result["help"].as_str().unwrap().contains("docs/usage.md")); - let exported = run(root, bundle, "export", "", true).await; - assert_eq!( - Document::parse(exported.as_slice()).unwrap(), - Document::parse(serde_json::to_vec(&original).unwrap().as_slice()).unwrap() - ); } } + // The saved intent is byte-identical after each refusal, so one export + // shows it still reproduces the accepted document. + let exported = run(root, bundle, "export", "", true).await; + assert_eq!( + Document::parse(exported.as_slice()).unwrap(), + Document::parse(serde_json::to_vec(&original).unwrap().as_slice()).unwrap() + ); // A root observation failure after runtime planning must not save a new // document either, even when its sandbox changes would otherwise be valid. let mut revised = original.clone(); From 611c123d2837fa03d1414c3f8db610c4055babad Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 02:32:34 -0700 Subject: [PATCH 06/18] test(e2e): surface each gateway capability failure kind once through OpenTofu production_provider_applies_refreshes_and_destroys_the_reference_graph was the slowest test in opentofu_openshell, 113 s on linux_amd64, with 23 OpenTofu runs locally. It planned once per incompatibility reason, five times, and re-applied a saved plan for both failure kinds in both the unchanged and creating cases. nemoclaw-openshell's observation tests own every incompatibility reason and its message. Through OpenTofu, one precondition failure and one failed read now show both diagnostics reach the user, and the saved-plan check runs each failure kind once: the driver change for an unchanged plan and the failed read while creating. The test runs 14 OpenTofu commands in 19 s locally instead of 30 s. Part of #12882. --- .../nemoclaw-e2e/tests/opentofu_openshell.rs | 173 ++++++++---------- 1 file changed, 76 insertions(+), 97 deletions(-) diff --git a/crates/nemoclaw-e2e/tests/opentofu_openshell.rs b/crates/nemoclaw-e2e/tests/opentofu_openshell.rs index 510f2c0b422..f48cd96761d 100644 --- a/crates/nemoclaw-e2e/tests/opentofu_openshell.rs +++ b/crates/nemoclaw-e2e/tests/opentofu_openshell.rs @@ -54,66 +54,46 @@ async fn production_provider_applies_refreshes_and_destroys_the_reference_graph( }; let versions: Value = serde_json::from_str(include_str!("../../../versions.json")).unwrap(); let version = versions["openshell"].as_str().unwrap(); - for failure in ["version", "driver", "multiple", "unavailable", "incomplete"] { + // nemoclaw-openshell's observation tests own each incompatibility reason; + // OpenTofu must surface one precondition failure and one failed read. + for failure in ["version", "unavailable"] { { let mut state = fixture.state.lock().unwrap(); - match failure { - "version" => { - state.gateway_info = Some(openshell_core::proto::GetGatewayInfoResponse { - gateway_version: "incompatible-version".into(), - compute_drivers: vec![openshell_core::proto::ComputeDriverInfo { - name: "docker".into(), - ..Default::default() - }], + if failure == "version" { + state.gateway_info = Some(openshell_core::proto::GetGatewayInfoResponse { + gateway_version: "incompatible-version".into(), + compute_drivers: vec![openshell_core::proto::ComputeDriverInfo { + name: "docker".into(), ..Default::default() - }) - } - "driver" => state.driver = Some("podman".into()), - "multiple" => { - state.gateway_info = Some(openshell_core::proto::GetGatewayInfoResponse { - gateway_version: version.into(), - compute_drivers: vec![ - openshell_core::proto::ComputeDriverInfo { - name: "docker".into(), - ..Default::default() - }; - 2 - ], - ..Default::default() - }); - } - "unavailable" => state.fail_read = Some(("gateway", tonic::Code::Unavailable)), - _ => state.gateway_info = Some(Default::default()), + }], + ..Default::default() + }); + } else { + state.fail_read = Some(("gateway", tonic::Code::Unavailable)); } } let output = run(&["plan", "-input=false", "-no-color"]); assert!(!output.status.success(), "{failure} gateway was accepted"); let diagnostic = String::from_utf8_lossy(&output.stderr); - assert!( - diagnostic.contains(if matches!(failure, "version" | "driver" | "multiple") { - "Resource precondition failed" - } else { - "Gateway capability observation failed" - }), - "{diagnostic}" - ); - if matches!(failure, "version" | "driver" | "multiple") { + if failure == "version" { + assert!( + diagnostic.contains("Resource precondition failed"), + "{diagnostic}" + ); let normalized = diagnostic.split_whitespace().collect::>().join(" "); - let reason = match failure { - "version" => format!( - "gateway runs OpenShell incompatible-version, but this build requires {version}" - ), - "driver" => { - "gateway compute driver is podman, but spec.gateway.runtime.provider is docker" - .into() - } - _ => "gateway reports 2 compute drivers, but exactly one is required".into(), - }; - let expected = format!("Gateway is incompatible with this configuration: {reason}."); + let expected = format!( + "Gateway is incompatible with this configuration: gateway runs OpenShell \ + incompatible-version, but this build requires {version}." + ); assert!( normalized.contains(&expected), "missing {expected}: {diagnostic}" ); + } else { + assert!( + diagnostic.contains("Gateway capability observation failed"), + "{diagnostic}" + ); } assert!(!diagnostic.contains("secret-sentinel")); let mut state = fixture.state.lock().unwrap(); @@ -153,58 +133,57 @@ async fn production_provider_applies_refreshes_and_destroys_the_reference_graph( fixture.state.lock().unwrap().fail_read = None; // A saved plan must re-observe compatibility during apply, even when // every managed resource is unchanged. No SDK coordinator runs here. - for create in [false, true] { - for failure in ["driver", "unavailable"] { - if create { - let mut sandbox = document.spec.sandboxes[0].clone(); - sandbox.name = format!("extra-{failure}"); - document.spec.sandboxes.push(sandbox); - graph = compile(&document, &generations, "0.1.0").unwrap(); - fs::write(directory.path().join("main.tf.json"), graph.to_string()).unwrap(); - } - success(&["plan", "-input=false", "-out=fresh.plan", "-no-color"]); - let before = fs::read(directory.path().join("terraform.tfstate")).unwrap(); - let effects = fixture.state.lock().unwrap().effects; - { - let mut state = fixture.state.lock().unwrap(); - if failure == "driver" { - state.driver = Some("podman".into()); - } else { - state.fail_read = Some(("gateway", tonic::Code::Unavailable)); - } - } - let output = run(&["apply", "-input=false", "-no-color", "fresh.plan"]); - assert!( - !output.status.success(), - "saved plan reused stale gateway metadata: create={create}, {failure}" - ); - let diagnostic = String::from_utf8_lossy(&output.stderr); - let normalized = diagnostic.split_whitespace().collect::>().join(" "); - assert!( - normalized.contains(if failure == "driver" { - "Gateway is incompatible with this configuration: gateway compute driver is \ - podman, but spec.gateway.runtime.provider is docker." - } else { - "Gateway capability observation failed" - }), - "{diagnostic}" - ); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - assert_same_managed_resources( - &fs::read(directory.path().join("terraform.tfstate")).unwrap(), - &before, - ); - { - let mut state = fixture.state.lock().unwrap(); - state.driver = None; - state.fail_read = None; + // Each failure kind runs once, unchanged and when creating. + for (create, failure) in [(false, "driver"), (true, "unavailable")] { + if create { + let mut sandbox = document.spec.sandboxes[0].clone(); + sandbox.name = format!("extra-{failure}"); + document.spec.sandboxes.push(sandbox); + graph = compile(&document, &generations, "0.1.0").unwrap(); + fs::write(directory.path().join("main.tf.json"), graph.to_string()).unwrap(); + } + success(&["plan", "-input=false", "-out=fresh.plan", "-no-color"]); + let before = fs::read(directory.path().join("terraform.tfstate")).unwrap(); + let effects = fixture.state.lock().unwrap().effects; + { + let mut state = fixture.state.lock().unwrap(); + if failure == "driver" { + state.driver = Some("podman".into()); + } else { + state.fail_read = Some(("gateway", tonic::Code::Unavailable)); } - success(&["apply", "-auto-approve", "-input=false", "-no-color"]); - assert_eq!( - fixture.state.lock().unwrap().sandboxes.len(), - document.spec.sandboxes.len() - ); } + let output = run(&["apply", "-input=false", "-no-color", "fresh.plan"]); + assert!( + !output.status.success(), + "saved plan reused stale gateway metadata: create={create}, {failure}" + ); + let diagnostic = String::from_utf8_lossy(&output.stderr); + let normalized = diagnostic.split_whitespace().collect::>().join(" "); + assert!( + normalized.contains(if failure == "driver" { + "Gateway is incompatible with this configuration: gateway compute driver is \ + podman, but spec.gateway.runtime.provider is docker." + } else { + "Gateway capability observation failed" + }), + "{diagnostic}" + ); + assert_eq!(fixture.state.lock().unwrap().effects, effects); + assert_same_managed_resources( + &fs::read(directory.path().join("terraform.tfstate")).unwrap(), + &before, + ); + { + let mut state = fixture.state.lock().unwrap(); + state.driver = None; + state.fail_read = None; + } + success(&["apply", "-auto-approve", "-input=false", "-no-color"]); + assert_eq!( + fixture.state.lock().unwrap().sandboxes.len(), + document.spec.sandboxes.len() + ); } for provider in ["nemoclaw", "openshell", "fabric"] { From f143611cbb2bb413c5202842c63f0885b41b505d Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 02:48:55 -0700 Subject: [PATCH 07/18] test(e2e): run harness-independent Fabric checks for one harness fabric_deployment took 328 s summed on linux_amd64, about 30 s for each of ten harnesses. Locally each harness took 26 s: 3 s to apply, 16 s for a model change and its export, and 7 s refusing adapter, image, and observed sandbox changes and destroying. Only the first part depends on the harness; the rest exercises the Fabric provider and the SDK's sandbox protections the same way every time. Every harness still applies, reapplies without rewriting its runtime configuration, exports unchanged, and destroys. OpenClaw also runs the model change and the refusals, and Pi its route-role model change. Locally the module sums about 146 s instead of 280 s; eight harnesses take 9 s each instead of 26 s. Part of #12882. --- crates/nemoclaw-e2e/tests/fabric_deployment.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/nemoclaw-e2e/tests/fabric_deployment.rs b/crates/nemoclaw-e2e/tests/fabric_deployment.rs index dd3bbed39c9..b2e1c1e8fc7 100644 --- a/crates/nemoclaw-e2e/tests/fabric_deployment.rs +++ b/crates/nemoclaw-e2e/tests/fabric_deployment.rs @@ -171,6 +171,20 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: .iter() .any(|arg| arg == "invoke" || arg == "--message")) ); + // Model changes and the refusal of adapter, image, and observed changes do + // not depend on the harness. OpenClaw covers them, and Pi its route roles; + // every other harness only proves it applies, reapplies, and exports. + if !matches!(harness, "nvidia.fabric.openclaw" | "nvidia.fabric.pi") { + deployment.destroy(&cancel).await.unwrap(); + assert!(fixture.state.lock().unwrap().sandboxes.is_empty()); + assert!(fixture.state.lock().unwrap().providers.is_empty()); + assert_eq!( + *unexpected.lock().unwrap(), + Vec::::new(), + "only the model catalog may be requested" + ); + return; + } if harness != "nvidia.fabric.pi" { let mut changed_model = document.clone(); changed_model.spec.sandboxes[0] From 36eff229eb85be0ae3738b0f3580fe48487324d7 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 03:02:02 -0700 Subject: [PATCH 08/18] build: optimize dependencies in development and test builds The onboarding TUI journeys took 168 s summed in the deterministic step on linux_amd64, up to 15 s per journey. Each answer resolves the journey several times, and each resolution validates the partial document against the SDK's JSON Schema and parses it; unoptimized, jsonschema and its regex and JSON dependencies made one resolution take about 8 ms. Dependencies now build at opt-level 2 in the dev and test profiles; workspace crates stay unoptimized. Locally the slowest journey takes 1.0 s instead of 2.5 s, and the nemoclaw-onboarding, nemoclaw-authoring, and nemoclaw-sdk tests finish in 8.0 s instead of 13.4 s at eight threads. A cold workspace build takes 82 s instead of 46 s locally; CI restores dependencies from its cache, and this file is part of the cache key, so the first run after this change builds cold. Part of #12882. --- .cargo/config.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index f749ae87153..abffe459360 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -18,6 +18,12 @@ images = ["run", "--locked", "--quiet", "--target-dir", "target/ci-runner", "-p" [profile.dev] debug = 1 +# Dependencies change rarely, and unoptimized they dominate test time: JSON +# Schema validation, parsing, and hashing run throughout every test step. +# Workspace crates stay unoptimized for incremental builds. +[profile.dev.package."*"] +opt-level = 2 + # Deployment tests verify native bundle digests on every operation. [profile.dev.package.sha2] opt-level = 3 From 18c44e575daeb0eda3873bfce521e33c7d87c961 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 03:13:23 -0700 Subject: [PATCH 09/18] perf(onboarding): resolve an unchanged journey once (#12901) Stacked on #12885. Part of #12882. ## Failure The onboarding wizard resolved its journey again for each of these: the next question, each step, the review document, and every view redraw. A resolution validates the partial document against the SDK schema and parses it. Instrumenting the slowest example journey, `spark_spark_inline`, showed 196 resolutions across 36 answers, about 8 ms each in a debug build. This made the TUI journey tests the largest cost in the deterministic test step: 168 s summed on `linux_amd64`. Every redraw of the running TUI paid the same cost. ## Decision - `JourneyWizard` keeps its last resolution, including a failed one, and reuses it until the state or observations change. - `state` and `observations` are private. Every change goes through `submit`, `delegate`, `back`, or `remember`, which clear the kept resolution. The view and terminal read them through accessors. Tests record observations through a test-only `record` method that also clears it. - The view's information notes and review document use the kept resolution. - `JourneyState::answer` still resolves internally. That code is in `nemoclaw-authoring` and unchanged here. ## Validation - **New test:** asking for the next question and the document repeatedly resolves once. An answer, an undo, and a new observation each cause exactly one new resolution. The test was written first and failed to compile without the counter. - **Timings:** on top of #12885's optimized dependencies, `spark_spark_inline` takes 0.74 s locally instead of 1.06 s. The `nemoclaw-onboarding` library tests take 0.92 s instead of 1.28 s. - **Checks:** all 79 library tests pass, and clippy at `-D warnings` and fmt are clean. --- examples/onboarding-tui/src/tui/app.rs | 77 +++++++++++++---- examples/onboarding-tui/src/tui/terminal.rs | 25 ++++-- examples/onboarding-tui/src/tui/tests.rs | 95 ++++++++++++++++----- examples/onboarding-tui/src/tui/view.rs | 9 +- 4 files changed, 153 insertions(+), 53 deletions(-) diff --git a/examples/onboarding-tui/src/tui/app.rs b/examples/onboarding-tui/src/tui/app.rs index 751a755f40f..a532efd88dd 100644 --- a/examples/onboarding-tui/src/tui/app.rs +++ b/examples/onboarding-tui/src/tui/app.rs @@ -2,19 +2,28 @@ // SPDX-License-Identifier: Apache-2.0 use super::labels::display_value; -use nemoclaw_authoring::{Capabilities, Diagnostics, JourneyQuestion, JourneyState}; +use nemoclaw_authoring::{ + Capabilities, Diagnostics, JourneyQuestion, JourneyResolution, JourneyState, +}; use nemoclaw_sdk::discovery::DiscoveryObservations; use nemoclaw_sdk::{config::Document, discovery::DiscoveryRequest}; use serde_json::Value; +use std::cell::{Cell, RefCell}; pub(crate) struct JourneyWizard { pub(super) capabilities: Capabilities, - pub(super) state: JourneyState, + /// Private, with `observations`, so every change clears `resolution`. + state: JourneyState, pub(super) history: Vec, pub(super) selected: usize, pub(super) selection_changed: bool, pub(super) custom_answer: bool, - pub(super) observations: DiscoveryObservations, + observations: DiscoveryObservations, + /// The last resolution of `state` with `observations`. Resolving + /// validates and parses the whole document, and the view, the next + /// question, and each step ask for it again. + resolution: RefCell>>, + resolutions: Cell, /// The engines this machine's environment names, read before the first question. pub(super) local_engine_candidates: Vec, pub(super) input: String, @@ -34,6 +43,8 @@ impl JourneyWizard { selection_changed: false, custom_answer: false, observations: DiscoveryObservations::new(), + resolution: RefCell::new(None), + resolutions: Cell::new(0), local_engine_candidates: Vec::new(), input: String::new(), error: None, @@ -57,19 +68,54 @@ impl JourneyWizard { self.observations.merge(observed); self.state .use_local_engines(&self.local_engine_candidates, &self.observations); + self.changed(); } + /// Keep one observation of the target. #[cfg(test)] + pub(super) fn record( + &mut self, + query: nemoclaw_sdk::discovery::DiscoveryQuery, + observation: nemoclaw_sdk::discovery::DiscoveryObservation, + ) { + self.observations.record(query, observation); + self.changed(); + } + pub(crate) fn state(&self) -> &JourneyState { &self.state } - pub(crate) fn question(&self) -> Result, Diagnostics> { - Ok(self + pub(super) fn observations(&self) -> &DiscoveryObservations { + &self.observations + } + + /// The journey resolved with what the target said, reused until the + /// state or observations change. + pub(super) fn resolution(&self) -> Result { + if let Some(resolved) = self.resolution.borrow().as_ref() { + return resolved.clone(); + } + let resolved = self .state - .resolve_with_observations(&self.capabilities, &self.observations)? - .next_question() - .cloned()) + .resolve_with_observations(&self.capabilities, &self.observations); + self.resolutions.set(self.resolutions.get() + 1); + *self.resolution.borrow_mut() = Some(resolved.clone()); + resolved + } + + /// How many times the journey was resolved. + #[cfg(test)] + pub(super) fn resolutions(&self) -> usize { + self.resolutions.get() + } + + fn changed(&mut self) { + *self.resolution.get_mut() = None; + } + + pub(crate) fn question(&self) -> Result, Diagnostics> { + Ok(self.resolution()?.next_question().cloned()) } pub(super) fn choice_index(&self, question: &JourneyQuestion) -> usize { @@ -98,8 +144,9 @@ impl JourneyWizard { .question()? .expect("submit requires an active question"); let previous = self.state.clone(); - self.state - .answer(&self.capabilities, question.id(), answer)?; + let answered = self.state.answer(&self.capabilities, question.id(), answer); + self.changed(); + answered?; self.history.push(previous); self.selected = 0; self.selection_changed = false; @@ -117,6 +164,7 @@ impl JourneyWizard { Ok(delegated) => { self.history.push(self.state.clone()); self.state = delegated; + self.changed(); self.error = None; } // The resolver already supplies a catalog credential note. Keep @@ -136,6 +184,7 @@ impl JourneyWizard { pub(super) fn back(&mut self) { if let Some(previous) = self.history.pop() { self.state = previous; + self.changed(); self.selected = 0; self.selection_changed = false; self.custom_answer = false; @@ -226,10 +275,7 @@ impl JourneyWizard { self.started = true; return; } - let resolution = match self - .state - .resolve_with_observations(&self.capabilities, &self.observations) - { + let resolution = match self.resolution() { Ok(resolution) => resolution, Err(error) => { self.error = Some(error.to_string()); @@ -276,8 +322,7 @@ impl JourneyWizard { } pub(super) fn document(&self) -> Result> { - self.state - .resolve_with_observations(&self.capabilities, &self.observations)? + self.resolution()? .ready_document() .cloned() .ok_or_else(|| "the journey is not complete".into()) diff --git a/examples/onboarding-tui/src/tui/terminal.rs b/examples/onboarding-tui/src/tui/terminal.rs index 07085484baa..0f8b2eb05b4 100644 --- a/examples/onboarding-tui/src/tui/terminal.rs +++ b/examples/onboarding-tui/src/tui/terminal.rs @@ -154,14 +154,18 @@ pub(crate) async fn run( if key.code == KeyCode::Char('d') && key.modifiers.contains(KeyModifiers::CONTROL) { if wizard.input.is_empty() && !wizard.selection_changed && !wizard.custom_answer { let document = wizard - .state + .state() .resolve(&wizard.capabilities) .ok() .and_then(|resolution| resolution.assessment().document().cloned()); if let (true, Some(document)) = (discover, document) { let discovery_cancel = cancel.child_token(); let observed = wait_for_discovery( - observe_target(&document, wizard.state.current_route(), &discovery_cancel), + observe_target( + &document, + wizard.state().current_route(), + &discovery_cancel, + ), cancel, &discovery_cancel, &mut queued_events, @@ -195,14 +199,18 @@ pub(crate) async fn run( && matches!(wizard.question(), Ok(None)) && discover && let Some(document) = wizard - .state + .state() .resolve(&wizard.capabilities) .ok() .and_then(|resolution| resolution.materialized_document().cloned()) { let discovery_cancel = cancel.child_token(); let observed = wait_for_discovery( - observe_target(&document, wizard.state.current_route(), &discovery_cancel), + observe_target( + &document, + wizard.state().current_route(), + &discovery_cancel, + ), cancel, &discovery_cancel, &mut queued_events, @@ -302,7 +310,7 @@ pub(super) fn local_engine_probe(wizard: &JourneyWizard) -> Vec .cloned() .map(DiscoveryQuery::Engine) .collect(); - wizard.observations.missing(&queries) + wizard.observations().missing(&queries) } /// The model catalog of the route being asked about, once the journey is at its @@ -313,11 +321,12 @@ pub(super) fn model_catalog_probe(wizard: &JourneyWizard) -> Option { if let Some(document) = resolution.materialized_document() { if let Ok(yaml) = document.yaml() { From 72e023eb27d0dafeb6dfcf6786ed3d7a35e99ae7 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 03:15:42 -0700 Subject: [PATCH 10/18] test(e2e): plan each catalog response once in inference_discovery optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_uncertainty took 50 s on linux_amd64. For both provider protocols it planned four catalog responses twice, through the CLI and the SDK: 16 plans. nemoclaw-discovery's inference tests own how each catalog response is classified. The deployment test now plans each response once through the CLI, split across the Anthropic and OpenAI protocols so both still read their catalog and the Anthropic version header is still sent. The CLI's JSON already shows the plan is complete and unchanged, which the SDK preview repeated. The test takes 22 s locally. Part of #12882. --- .../nemoclaw-e2e/tests/inference_discovery.rs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/nemoclaw-e2e/tests/inference_discovery.rs b/crates/nemoclaw-e2e/tests/inference_discovery.rs index 482cd9c2983..041ff2a0d50 100644 --- a/crates/nemoclaw-e2e/tests/inference_discovery.rs +++ b/crates/nemoclaw-e2e/tests/inference_discovery.rs @@ -96,14 +96,22 @@ async fn optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_u }) .await; let endpoint = format!("{}/v1", server.endpoint); - for (provider, api) in [ + // nemoclaw-discovery's inference tests own how each catalog response is + // classified; here each response reaches a complete plan once, across + // both provider protocols. + for (provider, api, modes) in [ ( InferenceProviderKind::Anthropic, InferenceApi::AnthropicMessages, + [ + (1, "unavailable", "required"), + (3, "available", "not_required"), + ], ), ( InferenceProviderKind::Openai, InferenceApi::OpenaiCompletions, + [(0, "unknown", "unknown"), (2, "unknown", "unknown")], ), ] { mode.store(0, Ordering::SeqCst); @@ -125,12 +133,7 @@ async fn optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_u let state = fs::read(directory.path().join("terraform.tfstate")).unwrap(); let intent = fs::read(directory.path().join("intent.json")).unwrap(); let effects = fixture.state.lock().unwrap().effects; - for (selected, status, auth) in [ - (0, "unknown", "unknown"), - (1, "unavailable", "required"), - (2, "unknown", "unknown"), - (3, "available", "not_required"), - ] { + for (selected, status, auth) in modes { mode.store(selected, Ordering::SeqCst); let output = Command::new( bundle @@ -161,9 +164,6 @@ async fn optional_catalog_failures_preserve_complete_unchanged_plans_and_typed_u assert_eq!(observed["authentication"], auth); assert_eq!(observed["api_verified"], false); assert!(!String::from_utf8_lossy(&output.stdout).contains("private-upstream-message")); - let preview = deployment.plan(&document, &cancel).await.unwrap(); - assert!(preview.deferred.is_empty()); - assert!(preview.changes.is_empty()); assert_eq!( fs::read(directory.path().join("terraform.tfstate")).unwrap(), state From feda3616d1d680b384a989dbc0ff045b36e8c428 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 04:25:19 -0700 Subject: [PATCH 11/18] test(sdk): export every example from the observations it compiles to Export's consistency check ran only inside end-to-end lifecycles, about 30 s each on CI, so whether a configuration exports unchanged was proven one deployment at a time. The check itself is pure: it compares the saved document's compiled provider and sandbox targets with refreshed observations. Export now passes those observations to a pure function, exported. A unit test compiles every example, echoes its targets as observations, and checks that the saved document exports unchanged, and that a drifted sandbox image, a drifted provider endpoint, or a missing observation stops the export. It runs in 0.3 s. Part of #12882. --- crates/nemoclaw-sdk/src/deployment/export.rs | 150 +++++++++++++++---- 1 file changed, 119 insertions(+), 31 deletions(-) diff --git a/crates/nemoclaw-sdk/src/deployment/export.rs b/crates/nemoclaw-sdk/src/deployment/export.rs index 5e1942f46ca..9bf18ad64ec 100644 --- a/crates/nemoclaw-sdk/src/deployment/export.rs +++ b/crates/nemoclaw-sdk/src/deployment/export.rs @@ -176,40 +176,52 @@ impl Deployment { let observations = operation .export_observations(&bundle, &store, &record, false, cancel) .await?; - let mut document = record.document; - consistent_provider_credentials(&document, &record.generations, &observations)?; - for target in compile::targets(&document, &record.generations)? { - if cancel.is_cancelled() { - return Err(Error::Cancelled); - } - if target.address.starts_with("data.") || plan::disposable(&target.address) { - continue; - } - let mut observation = observations[&target.address].clone(); - // Typed OpenShell inputs return to the JSON their rows carry. - for input in nemoclaw_openshell::structured_inputs(&target.kind) { - if let Some(object) = observation.as_object_mut() - && let Some(value) = object.remove(input.attribute) - { - let encoded = input - .row_value(value) - .map_err(|_| Error::State("invalid provider export observation"))?; - object.insert(input.field.into(), json!(encoded.unwrap_or_default())); - } - } - let observed: Row = serde_json::from_value(observation) - .map_err(|_| Error::State("invalid provider export observation"))?; - let mut expected = target.values; - expected.insert("id".into(), observed["id"].clone()); - match target.kind.as_str() { - "provider" => export_provider(&mut document, &expected, &observed)?, - "sandbox" => export_sandbox(&expected, &observed)?, - _ => {} + if cancel.is_cancelled() { + return Err(Error::Cancelled); + } + exported(record.document, &record.generations, &observations) + } +} + +/// The saved document, once the observed OpenShell objects agree with what it +/// compiles to. Observations are the refreshed state's attributes by address. +pub(super) fn exported( + mut document: Document, + generations: &compile::Generations, + observations: &BTreeMap, +) -> Result { + consistent_provider_credentials(&document, generations, observations)?; + for target in compile::targets(&document, generations)? { + if target.address.starts_with("data.") || plan::disposable(&target.address) { + continue; + } + let mut observation = observations + .get(&target.address) + .cloned() + .ok_or(Error::State("incomplete provider export observation"))?; + // Typed OpenShell inputs return to the JSON their rows carry. + for input in nemoclaw_openshell::structured_inputs(&target.kind) { + if let Some(object) = observation.as_object_mut() + && let Some(value) = object.remove(input.attribute) + { + let encoded = input + .row_value(value) + .map_err(|_| Error::State("invalid provider export observation"))?; + object.insert(input.field.into(), json!(encoded.unwrap_or_default())); } } - document.validate()?; - Ok(document) + let observed: Row = serde_json::from_value(observation) + .map_err(|_| Error::State("invalid provider export observation"))?; + let mut expected = target.values; + expected.insert("id".into(), observed["id"].clone()); + match target.kind.as_str() { + "provider" => export_provider(&mut document, &expected, &observed)?, + "sandbox" => export_sandbox(&expected, &observed)?, + _ => {} + } } + document.validate()?; + Ok(document) } fn validate_projection(target: &Target, observed: &Value) -> Result<(), Error> { @@ -415,6 +427,82 @@ fn export_sandbox(expected: &Row, observed: &Row) -> Result<(), Error> { mod tests { use super::*; + /// Observations that echo what `document` compiles to, as providers + /// report a deployment applied from it. + fn echoed(document: &Document, generations: &compile::Generations) -> BTreeMap { + compile::targets(document, generations) + .unwrap() + .into_iter() + .filter(|target| !target.address.starts_with("data.")) + .map(|target| { + let mut row = json!(target.values); + row["id"] = json!(format!("{}-id", target.address)); + (target.address, row) + }) + .collect() + } + + /// A generation for every kind `document` records. + fn generations(document: &Document) -> compile::Generations { + ["workspace", "provider", "sandbox"] + .into_iter() + .chain(crate::services::generation_kinds(document).unwrap()) + .map(|key| (key.into(), "a".repeat(32))) + .collect() + } + + /// Every example's saved document exports unchanged when the providers + /// report what it compiled to, and a drifted sandbox or provider stops the + /// export. + #[test] + fn each_example_exports_its_applied_document_and_stops_on_drift() { + let examples = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../examples"); + let mut exported_examples = 0; + for entry in fs::read_dir(&examples).unwrap() { + let path = entry.unwrap().path(); + if path.extension().and_then(|extension| extension.to_str()) != Some("yaml") { + continue; + } + let mut document = Document::parse(fs::read(&path).unwrap().as_slice()) + .unwrap_or_else(|error| panic!("{}: {error}", path.display())); + document.defaults(); + let generations = generations(&document); + let observations = echoed(&document, &generations); + assert_eq!( + exported(document.clone(), &generations, &observations) + .unwrap_or_else(|error| panic!("{}: {error}", path.display())), + document, + "{}", + path.display() + ); + for (kind, field, value) in [ + ("sandbox", "image", "drifted@sha256:0"), + ("provider", "endpoint", "https://drifted.example/v1"), + ] { + let Some(address) = compile::targets(&document, &generations) + .unwrap() + .into_iter() + .find(|target| target.kind == kind && target.values.contains_key(field)) + .map(|target| target.address) + else { + continue; + }; + let mut drifted = observations.clone(); + drifted.get_mut(&address).unwrap()[field] = json!(value); + assert!( + exported(document.clone(), &generations, &drifted).is_err(), + "{}: {kind}.{field} drift was exported", + path.display() + ); + } + let mut missing = observations.clone(); + missing.pop_first(); + assert!(exported(document.clone(), &generations, &missing).is_err()); + exported_examples += 1; + } + assert!(exported_examples > 20, "examples were not found"); + } + #[tokio::test] #[ignore = "uses the verified bundle named by NEMOCLAW_TEST_BUNDLE"] async fn runtime_export_declares_the_native_helm_provider_inputs() { From b8e0bab604b93b1a9656ba960814fe369206017c Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 04:35:32 -0700 Subject: [PATCH 12/18] test(e2e): keep one system lifecycle per drift kind About 35 system tests repeated the generic lifecycle (export reproduces the document, an unchanged reapply is a no-op, destroy cleans up) for one configuration variant each, about 30 s apiece on CI. - Export round trips for every example now run in the SDK's unit tests. - Drift detection keeps one lifecycle per kind: web search registrations (Tavily only; Brave is the same code path), sandbox policy across sandboxes, and harness native settings (tool_disclosure). - Removed from deployment: explicit_network, inference_settings, execution_settings, observability, openclaw_interfaces, hermes_interfaces, and provider_definitions lifecycles. - Removed from fabric_deployment: eight harnesses' apply, reapply, and export checks; OpenClaw and Pi remain. Every harness example compiles, passes the Fabric planner, and exports in the SDK's tests. - The unsupported ownership annotation check moves to nemoclaw-cli: the schema rejects it, naming the field, before the saved intent or state is read, so it needs no deployment. Whether the fake gateway accepts and reads back each variant unchanged is left to the openshell and fabric contract tests in #12880. Part of #12882. --- crates/nemoclaw-cli/tests/commands.rs | 47 +++++ crates/nemoclaw-e2e/tests/deployment.rs | 167 +----------------- .../nemoclaw-e2e/tests/fabric_deployment.rs | 47 +---- 3 files changed, 59 insertions(+), 202 deletions(-) diff --git a/crates/nemoclaw-cli/tests/commands.rs b/crates/nemoclaw-cli/tests/commands.rs index 098f724a115..96161ca2b36 100644 --- a/crates/nemoclaw-cli/tests/commands.rs +++ b/crates/nemoclaw-cli/tests/commands.rs @@ -176,6 +176,53 @@ fn invalid_configuration_fails_before_creating_state_or_echoing_secrets() { assert!(output.stdout.is_empty()); assert!(!String::from_utf8_lossy(&output.stderr).contains("secret-sentinel")); } +/// An unsupported ownership annotation is rejected by the schema, naming its +/// field, before the existing deployment's saved intent or state is read. +#[test] +fn unsupported_ownership_annotations_leave_an_applied_deployment_unchanged() { + let directory = tempfile::tempdir().unwrap(); + let state = directory.path().join("state"); + fs::create_dir(&state).unwrap(); + let saved = [ + ("intent.json", "saved intent"), + ("terraform.tfstate", "saved state"), + ]; + for (name, contents) in saved { + fs::write(state.join(name), contents).unwrap(); + } + let document = nemoclaw_sdk::config::Document::parse( + include_bytes!("../../../examples/explicit-policy.yaml").as_slice(), + ) + .unwrap(); + let mut invalid = serde_json::to_value(&document).unwrap(); + invalid["spec"]["inferenceProviders"][0]["management"] = serde_json::json!("external"); + let config = directory.path().join("unsupported.yaml"); + fs::write(&config, invalid.to_string()).unwrap(); + let output = Command::new(env!("CARGO_BIN_EXE_nemoclaw")) + .arg("apply") + .arg("--state-dir") + .arg(&state) + .arg("--bundle") + .arg(directory.path().join("missing-bundle")) + .arg(&config) + .output() + .unwrap(); + assert!(!output.status.success()); + let diagnostic = String::from_utf8_lossy(&output.stderr); + assert!( + diagnostic.contains("configuration violates schema"), + "{diagnostic}" + ); + assert!( + diagnostic.contains("spec.inferenceProviders[0]") + && diagnostic.contains("unknown fields are not allowed"), + "{diagnostic}" + ); + for (name, contents) in saved { + assert_eq!(fs::read_to_string(state.join(name)).unwrap(), contents); + } +} + #[test] fn bundle_flag_selects_an_explicit_bundle() { let directory = tempfile::tempdir().unwrap(); diff --git a/crates/nemoclaw-e2e/tests/deployment.rs b/crates/nemoclaw-e2e/tests/deployment.rs index 979e3775745..d403f54971b 100644 --- a/crates/nemoclaw-e2e/tests/deployment.rs +++ b/crates/nemoclaw-e2e/tests/deployment.rs @@ -379,19 +379,6 @@ async fn sdk_apply_cli_export_sdk_reapply_and_cli_destroy_share_state() { .await; } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn explicit_network_sdk_apply_cli_export_reapply_and_destroy_preserve_intent() { - lifecycle(include_str!("../../../examples/explicit-policy.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn inference_settings_sdk_apply_export_reapply_and_drift() { - lifecycle(include_str!("../../../examples/inference-tuning.yaml")).await; - lifecycle(include_str!("../../../examples/hermes-auth.yaml")).await; -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] async fn separate_agent_sandboxes_cli_export_reapply_and_policy_drift() { @@ -434,124 +421,20 @@ async fn tool_disclosure_cli_export_reapply_and_drift() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn execution_settings_cli_export_reapply_and_drift() { - // Heartbeats are opaque native settings, and execution_settings in the SDK - // owns the timeout projection, so one deployment covers both. - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); - let harness = document.spec.sandboxes[0].harness.as_mut().unwrap(); - harness.execution = Some(nemoclaw_sdk::config::AgentExecution { - timeout_seconds: Some(900), - }); - harness.settings = Some( - serde_json::from_value(serde_json::json!({"native_config":{"agents":{"defaults": - {"heartbeat":{"every":"30m","isolatedSession":true}}}}})) - .unwrap(), - ); - lifecycle(&document.yaml().unwrap()).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn observability_cli_export_reapply_and_drift() { +async fn web_search_cli_export_reapply_and_destroy() { + // Every definition scope and provider compiles to the same kind of targets + // (web_search in the SDK), and their registration drift is one code path. let mut document = Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); - document.spec.sandboxes[0] - .harness - .as_mut() - .unwrap() - .settings = Some( - serde_json::from_value(serde_json::json!({ - "native_config":{"diagnostics":{"enabled":true,"otel":{"enabled":true,"endpoint":"http://host.openshell.internal:4318", - "serviceName":"agent ${fixture} %{literal}","sampleRate":0.5}}}})) - .unwrap(), - ); + document.spec.integrations = serde_json::from_value(serde_json::json!({ + "search":{"kind":"webSearch","provider":"tavily","credential":{"env":"SEARCH_KEY"}} + })) + .unwrap(); + document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; lifecycle(&document.yaml().unwrap()).await; } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn openclaw_interfaces_sdk_lifecycle_preserves_intent_and_rejects_drift() { - lifecycle(include_str!("../../../examples/openclaw-dashboard.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn hermes_interfaces_sdk_export_reapply_and_drift() { - lifecycle(include_str!("../../../examples/hermes-interfaces.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn web_search_cli_export_reapply_and_destroy() { - // Every definition scope compiles to the same targets (web_search in the - // SDK), so each provider deploys once, in a different scope. - for (provider, inline) in [("tavily", false), ("brave", true)] { - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()) - .unwrap(); - let definitions = serde_json::from_value(serde_json::json!({ - "search":{"kind":"webSearch","provider":provider,"credential":{"env":"SEARCH_KEY"}} - })) - .unwrap(); - if inline { - document.spec.sandboxes[0].agent.integrations = definitions; - } else { - document.spec.integrations = definitions; - document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; - } - lifecycle(&document.yaml().unwrap()).await; - } -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn provider_definitions_export_reapply_and_destroy_in_their_authored_scope() { - for (input, inline_route) in [ - ( - include_str!("../../../examples/fabric-openclaw.yaml"), - false, - ), - (include_str!("../../../examples/hermes-auth.yaml"), true), - ] { - let mut document = Document::parse(input.as_bytes()).unwrap(); - document.spec.sandboxes[0].inference_providers = - std::mem::take(&mut document.spec.inference_providers); - document.spec.inference_providers.push( - serde_json::from_value(serde_json::json!({ - "name":"unused", "provider":"openai", "endpoint":"https://unused.example.test/v1", - "credential":{"env":"UNUSED_KEY"} - })) - .unwrap(), - ); - // Each harness deploys its providers in one scope; inference_references - // in the SDK owns that both scopes compile and export unchanged. - if inline_route { - let sandbox = &mut document.spec.sandboxes[0]; - let provider = sandbox.inference_providers.remove(0); - let route = &mut sandbox.agent.inference.as_mut().unwrap().routes[0]; - route.provider_ref = None; - route.provider = Some(provider); - } - lifecycle(&document.yaml().unwrap()).await; - } -} - async fn lifecycle(input: &str) { - lifecycle_with_rejected_annotations(input, false).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn unsupported_ownership_annotations_leave_an_applied_deployment_unchanged() { - lifecycle_with_rejected_annotations( - include_str!("../../../examples/explicit-policy.yaml"), - true, - ) - .await; -} - -async fn lifecycle_with_rejected_annotations(input: &str, reject_annotations: bool) { let bundle = PathBuf::from(std::env::var_os("NEMOCLAW_TEST_BUNDLE").expect("explicit bundle path")); assert!(bundle.is_absolute()); @@ -657,40 +540,6 @@ async fn lifecycle_with_rejected_annotations(input: &str, reject_annotations: bo effects, document.spec.sandboxes.len() + if has_search { 5 } else { 3 } ); - if reject_annotations { - let intent_path = directory.path().join("intent.json"); - let state_path = directory.path().join("terraform.tfstate"); - let before_intent = fs::read(&intent_path).unwrap(); - let before_state = fs::read(&state_path).unwrap(); - let mut invalid = serde_json::to_value(&document).unwrap(); - invalid["spec"]["inferenceProviders"][0]["management"] = serde_json::json!("external"); - let input = directory.path().join("unsupported.yaml"); - fs::write(&input, invalid.to_string()).unwrap(); - let rejected = Command::new( - bundle - .join("bin") - .join(nemoclaw_sdk::bundle::executable("nemoclaw")), - ) - .args(["apply", "--state-dir"]) - .arg(directory.path()) - .arg(input) - .output() - .unwrap(); - assert!(!rejected.status.success()); - let diagnostic = String::from_utf8_lossy(&rejected.stderr); - assert!( - diagnostic.contains("configuration violates schema"), - "{diagnostic}" - ); - assert!( - diagnostic.contains("spec.inferenceProviders[0]") - && diagnostic.contains("unknown fields are not allowed"), - "{diagnostic}" - ); - assert_eq!(fs::read(intent_path).unwrap(), before_intent); - assert_eq!(fs::read(state_path).unwrap(), before_state); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - } let exported = Command::new( bundle .join("bin") diff --git a/crates/nemoclaw-e2e/tests/fabric_deployment.rs b/crates/nemoclaw-e2e/tests/fabric_deployment.rs index b2e1c1e8fc7..b97374874d3 100644 --- a/crates/nemoclaw-e2e/tests/fabric_deployment.rs +++ b/crates/nemoclaw-e2e/tests/fabric_deployment.rs @@ -3,7 +3,6 @@ // Deployment planning requires image discovery, whose engine transports are Unix-only. // Windows retains bridge tests that need no engine transport and an unsupported-engine regression. #![cfg(unix)] -use nemoclaw_sdk::config::InferenceProviderKind; use nemoclaw_e2e::openshell::Fixture; use nemoclaw_sdk::{CancellationToken, Deployment, config::Document}; @@ -23,15 +22,10 @@ macro_rules! harness_test { }; } -harness_test!(harness_deepagents, "nvidia.fabric.langchain.deepagents"); -harness_test!(harness_hermes, "nvidia.fabric.hermes"); +// Every harness's example compiles, passes the Fabric planner, and exports +// in the SDK's tests. OpenClaw covers the harness-independent checks here, +// and Pi its route roles. harness_test!(harness_openclaw, "nvidia.fabric.openclaw"); -harness_test!(harness_claude, "nvidia.fabric.claude"); -harness_test!(harness_codex, "nvidia.fabric.codex"); -harness_test!(harness_mini_swe_agent, "nvidia.fabric.mini-swe-agent"); -harness_test!(harness_nooa, "nvidia.fabric.nooa"); -harness_test!(harness_nooa_bench, "nvidia.fabric.nooa.bench-agent"); -harness_test!(harness_remote_agent, "nvidia.fabric.remote-agent"); harness_test!(harness_pi, "nvidia.fabric.pi"); async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: &str) { @@ -46,11 +40,7 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: let _image_engine = nemoclaw_e2e::image_runtime::engine(&mut document).await; // Keep passive discovery deterministic across apply and export. Connection // failures can otherwise vary between transport errors and timeouts. - let catalog_path = if harness == "nvidia.fabric.claude" { - "/v1/models?limit=1000" - } else { - "/v1/models" - }; + let catalog_path = "/v1/models"; let unexpected = Arc::new(Mutex::new(Vec::new())); let seen = unexpected.clone(); let catalog = nemoclaw_e2e::http_fixture::Fixture::start_tcp(move |request| { @@ -86,21 +76,6 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: .overrides .clone(); } - if harness == "nvidia.fabric.claude" { - document.spec.inference_providers[0].provider = InferenceProviderKind::Anthropic; - } - if harness == "nvidia.fabric.codex" { - document.spec.inference_providers[0].api = - Some(nemoclaw_sdk::config::InferenceApi::OpenaiResponses); - } - if harness == "nvidia.fabric.nooa" { - document.spec.sandboxes[0].harness.as_mut().unwrap().config = Some( - serde_json::from_value( - serde_json::json!({"workflow":{"target_id":"nvidia.nooa.coding-agent"}}), - ) - .unwrap(), - ); - } let deployment = Deployment::new(directory.path(), &bundle); let cancel = CancellationToken::new(); fixture.state.lock().unwrap().inference_exit = 1; @@ -171,20 +146,6 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: .iter() .any(|arg| arg == "invoke" || arg == "--message")) ); - // Model changes and the refusal of adapter, image, and observed changes do - // not depend on the harness. OpenClaw covers them, and Pi its route roles; - // every other harness only proves it applies, reapplies, and exports. - if !matches!(harness, "nvidia.fabric.openclaw" | "nvidia.fabric.pi") { - deployment.destroy(&cancel).await.unwrap(); - assert!(fixture.state.lock().unwrap().sandboxes.is_empty()); - assert!(fixture.state.lock().unwrap().providers.is_empty()); - assert_eq!( - *unexpected.lock().unwrap(), - Vec::::new(), - "only the model catalog may be requested" - ); - return; - } if harness != "nvidia.fabric.pi" { let mut changed_model = document.clone(); changed_model.spec.sandboxes[0] From 257713846d07149f21be8509e38ce6715432e1a2 Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 04:45:38 -0700 Subject: [PATCH 13/18] test: keep one system lifecycle per drift kind (#12906) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stacked on #12885. Part of #12876 (finding 1 in [the overlap map](https://github.com/NVIDIA/NemoClaw/issues/12876#issuecomment-6079832170)). ## Failure About 35 system tests repeated the generic lifecycle for one configuration variant each, about 30 s apiece on CI. The lifecycle checks that export reproduces the document, an unchanged reapply is a no-op, and destroy cleans up. Most variants differ only in what they compile to, which unit tests already cover. Export's consistency check could not run without OpenTofu. ## Decision - **Pure export check:** export's consistency check is now a pure function, `exported`. A new unit test compiles every example, echoes its targets back as provider observations, and checks three things: the saved document exports unchanged, a drifted sandbox image or provider endpoint stops the export, and a missing observation stops it too. - **One system lifecycle per drift kind:** - Web search registrations: Tavily only, since Brave uses the same code path. - Sandbox policy across sandboxes: `separate_agent_sandboxes`. - Harness native settings: `tool_disclosure`. - The external-gateway lifecycle (`sdk_apply_cli_export…`) and the remote Podman lifecycles remain. - **Removed system tests:** - From `deployment`: `explicit_network`, `inference_settings`, `execution_settings`, `observability`, `openclaw_interfaces`, `hermes_interfaces`, and `provider_definitions`. - From `fabric_deployment`: the apply, reapply, and export checks for eight harnesses. OpenClaw and Pi remain, and every harness's example compiles, passes the Fabric planner, and exports in the SDK's tests. - **Moved:** the unsupported ownership annotation check now lives in `nemoclaw-cli`. The schema rejects the annotation, naming its field, before the CLI reads saved intent or state, so the check needs no deployment. - **Known gap until #12880:** nothing at the system layer now checks that the fake gateway accepts and reads back each removed variant unchanged. The `openshell` and `fabric` contract tests will own that. ## Validation - **New tests:** the export test covers more than 20 examples in 0.3 s. The CLI annotation test passes in 0.05 s. - **Remaining lifecycles:** locally against a rebuilt bundle, the remaining `deployment` lifecycles and all `fabric_deployment` tests pass, 8 tests in 39 s. - **Checks:** `nemoclaw-sdk`, `nemoclaw-cli`, and `nemoclaw-e2e` clippy at `-D warnings` and fmt are clean. --- crates/nemoclaw-cli/tests/commands.rs | 47 +++++ crates/nemoclaw-e2e/tests/deployment.rs | 167 +----------------- .../nemoclaw-e2e/tests/fabric_deployment.rs | 47 +---- crates/nemoclaw-sdk/src/deployment/export.rs | 150 ++++++++++++---- 4 files changed, 178 insertions(+), 233 deletions(-) diff --git a/crates/nemoclaw-cli/tests/commands.rs b/crates/nemoclaw-cli/tests/commands.rs index 098f724a115..96161ca2b36 100644 --- a/crates/nemoclaw-cli/tests/commands.rs +++ b/crates/nemoclaw-cli/tests/commands.rs @@ -176,6 +176,53 @@ fn invalid_configuration_fails_before_creating_state_or_echoing_secrets() { assert!(output.stdout.is_empty()); assert!(!String::from_utf8_lossy(&output.stderr).contains("secret-sentinel")); } +/// An unsupported ownership annotation is rejected by the schema, naming its +/// field, before the existing deployment's saved intent or state is read. +#[test] +fn unsupported_ownership_annotations_leave_an_applied_deployment_unchanged() { + let directory = tempfile::tempdir().unwrap(); + let state = directory.path().join("state"); + fs::create_dir(&state).unwrap(); + let saved = [ + ("intent.json", "saved intent"), + ("terraform.tfstate", "saved state"), + ]; + for (name, contents) in saved { + fs::write(state.join(name), contents).unwrap(); + } + let document = nemoclaw_sdk::config::Document::parse( + include_bytes!("../../../examples/explicit-policy.yaml").as_slice(), + ) + .unwrap(); + let mut invalid = serde_json::to_value(&document).unwrap(); + invalid["spec"]["inferenceProviders"][0]["management"] = serde_json::json!("external"); + let config = directory.path().join("unsupported.yaml"); + fs::write(&config, invalid.to_string()).unwrap(); + let output = Command::new(env!("CARGO_BIN_EXE_nemoclaw")) + .arg("apply") + .arg("--state-dir") + .arg(&state) + .arg("--bundle") + .arg(directory.path().join("missing-bundle")) + .arg(&config) + .output() + .unwrap(); + assert!(!output.status.success()); + let diagnostic = String::from_utf8_lossy(&output.stderr); + assert!( + diagnostic.contains("configuration violates schema"), + "{diagnostic}" + ); + assert!( + diagnostic.contains("spec.inferenceProviders[0]") + && diagnostic.contains("unknown fields are not allowed"), + "{diagnostic}" + ); + for (name, contents) in saved { + assert_eq!(fs::read_to_string(state.join(name)).unwrap(), contents); + } +} + #[test] fn bundle_flag_selects_an_explicit_bundle() { let directory = tempfile::tempdir().unwrap(); diff --git a/crates/nemoclaw-e2e/tests/deployment.rs b/crates/nemoclaw-e2e/tests/deployment.rs index 979e3775745..d403f54971b 100644 --- a/crates/nemoclaw-e2e/tests/deployment.rs +++ b/crates/nemoclaw-e2e/tests/deployment.rs @@ -379,19 +379,6 @@ async fn sdk_apply_cli_export_sdk_reapply_and_cli_destroy_share_state() { .await; } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn explicit_network_sdk_apply_cli_export_reapply_and_destroy_preserve_intent() { - lifecycle(include_str!("../../../examples/explicit-policy.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn inference_settings_sdk_apply_export_reapply_and_drift() { - lifecycle(include_str!("../../../examples/inference-tuning.yaml")).await; - lifecycle(include_str!("../../../examples/hermes-auth.yaml")).await; -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] async fn separate_agent_sandboxes_cli_export_reapply_and_policy_drift() { @@ -434,124 +421,20 @@ async fn tool_disclosure_cli_export_reapply_and_drift() { #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn execution_settings_cli_export_reapply_and_drift() { - // Heartbeats are opaque native settings, and execution_settings in the SDK - // owns the timeout projection, so one deployment covers both. - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); - let harness = document.spec.sandboxes[0].harness.as_mut().unwrap(); - harness.execution = Some(nemoclaw_sdk::config::AgentExecution { - timeout_seconds: Some(900), - }); - harness.settings = Some( - serde_json::from_value(serde_json::json!({"native_config":{"agents":{"defaults": - {"heartbeat":{"every":"30m","isolatedSession":true}}}}})) - .unwrap(), - ); - lifecycle(&document.yaml().unwrap()).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn observability_cli_export_reapply_and_drift() { +async fn web_search_cli_export_reapply_and_destroy() { + // Every definition scope and provider compiles to the same kind of targets + // (web_search in the SDK), and their registration drift is one code path. let mut document = Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()).unwrap(); - document.spec.sandboxes[0] - .harness - .as_mut() - .unwrap() - .settings = Some( - serde_json::from_value(serde_json::json!({ - "native_config":{"diagnostics":{"enabled":true,"otel":{"enabled":true,"endpoint":"http://host.openshell.internal:4318", - "serviceName":"agent ${fixture} %{literal}","sampleRate":0.5}}}})) - .unwrap(), - ); + document.spec.integrations = serde_json::from_value(serde_json::json!({ + "search":{"kind":"webSearch","provider":"tavily","credential":{"env":"SEARCH_KEY"}} + })) + .unwrap(); + document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; lifecycle(&document.yaml().unwrap()).await; } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn openclaw_interfaces_sdk_lifecycle_preserves_intent_and_rejects_drift() { - lifecycle(include_str!("../../../examples/openclaw-dashboard.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn hermes_interfaces_sdk_export_reapply_and_drift() { - lifecycle(include_str!("../../../examples/hermes-interfaces.yaml")).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn web_search_cli_export_reapply_and_destroy() { - // Every definition scope compiles to the same targets (web_search in the - // SDK), so each provider deploys once, in a different scope. - for (provider, inline) in [("tavily", false), ("brave", true)] { - let mut document = - Document::parse(include_str!("../../../examples/fabric-openclaw.yaml").as_bytes()) - .unwrap(); - let definitions = serde_json::from_value(serde_json::json!({ - "search":{"kind":"webSearch","provider":provider,"credential":{"env":"SEARCH_KEY"}} - })) - .unwrap(); - if inline { - document.spec.sandboxes[0].agent.integrations = definitions; - } else { - document.spec.integrations = definitions; - document.spec.sandboxes[0].agent.integration_refs = vec!["search".into()]; - } - lifecycle(&document.yaml().unwrap()).await; - } -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn provider_definitions_export_reapply_and_destroy_in_their_authored_scope() { - for (input, inline_route) in [ - ( - include_str!("../../../examples/fabric-openclaw.yaml"), - false, - ), - (include_str!("../../../examples/hermes-auth.yaml"), true), - ] { - let mut document = Document::parse(input.as_bytes()).unwrap(); - document.spec.sandboxes[0].inference_providers = - std::mem::take(&mut document.spec.inference_providers); - document.spec.inference_providers.push( - serde_json::from_value(serde_json::json!({ - "name":"unused", "provider":"openai", "endpoint":"https://unused.example.test/v1", - "credential":{"env":"UNUSED_KEY"} - })) - .unwrap(), - ); - // Each harness deploys its providers in one scope; inference_references - // in the SDK owns that both scopes compile and export unchanged. - if inline_route { - let sandbox = &mut document.spec.sandboxes[0]; - let provider = sandbox.inference_providers.remove(0); - let route = &mut sandbox.agent.inference.as_mut().unwrap().routes[0]; - route.provider_ref = None; - route.provider = Some(provider); - } - lifecycle(&document.yaml().unwrap()).await; - } -} - async fn lifecycle(input: &str) { - lifecycle_with_rejected_annotations(input, false).await; -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires a verified NEMOCLAW_TEST_BUNDLE"] -async fn unsupported_ownership_annotations_leave_an_applied_deployment_unchanged() { - lifecycle_with_rejected_annotations( - include_str!("../../../examples/explicit-policy.yaml"), - true, - ) - .await; -} - -async fn lifecycle_with_rejected_annotations(input: &str, reject_annotations: bool) { let bundle = PathBuf::from(std::env::var_os("NEMOCLAW_TEST_BUNDLE").expect("explicit bundle path")); assert!(bundle.is_absolute()); @@ -657,40 +540,6 @@ async fn lifecycle_with_rejected_annotations(input: &str, reject_annotations: bo effects, document.spec.sandboxes.len() + if has_search { 5 } else { 3 } ); - if reject_annotations { - let intent_path = directory.path().join("intent.json"); - let state_path = directory.path().join("terraform.tfstate"); - let before_intent = fs::read(&intent_path).unwrap(); - let before_state = fs::read(&state_path).unwrap(); - let mut invalid = serde_json::to_value(&document).unwrap(); - invalid["spec"]["inferenceProviders"][0]["management"] = serde_json::json!("external"); - let input = directory.path().join("unsupported.yaml"); - fs::write(&input, invalid.to_string()).unwrap(); - let rejected = Command::new( - bundle - .join("bin") - .join(nemoclaw_sdk::bundle::executable("nemoclaw")), - ) - .args(["apply", "--state-dir"]) - .arg(directory.path()) - .arg(input) - .output() - .unwrap(); - assert!(!rejected.status.success()); - let diagnostic = String::from_utf8_lossy(&rejected.stderr); - assert!( - diagnostic.contains("configuration violates schema"), - "{diagnostic}" - ); - assert!( - diagnostic.contains("spec.inferenceProviders[0]") - && diagnostic.contains("unknown fields are not allowed"), - "{diagnostic}" - ); - assert_eq!(fs::read(intent_path).unwrap(), before_intent); - assert_eq!(fs::read(state_path).unwrap(), before_state); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - } let exported = Command::new( bundle .join("bin") diff --git a/crates/nemoclaw-e2e/tests/fabric_deployment.rs b/crates/nemoclaw-e2e/tests/fabric_deployment.rs index b2e1c1e8fc7..b97374874d3 100644 --- a/crates/nemoclaw-e2e/tests/fabric_deployment.rs +++ b/crates/nemoclaw-e2e/tests/fabric_deployment.rs @@ -3,7 +3,6 @@ // Deployment planning requires image discovery, whose engine transports are Unix-only. // Windows retains bridge tests that need no engine transport and an unsupported-engine regression. #![cfg(unix)] -use nemoclaw_sdk::config::InferenceProviderKind; use nemoclaw_e2e::openshell::Fixture; use nemoclaw_sdk::{CancellationToken, Deployment, config::Document}; @@ -23,15 +22,10 @@ macro_rules! harness_test { }; } -harness_test!(harness_deepagents, "nvidia.fabric.langchain.deepagents"); -harness_test!(harness_hermes, "nvidia.fabric.hermes"); +// Every harness's example compiles, passes the Fabric planner, and exports +// in the SDK's tests. OpenClaw covers the harness-independent checks here, +// and Pi its route roles. harness_test!(harness_openclaw, "nvidia.fabric.openclaw"); -harness_test!(harness_claude, "nvidia.fabric.claude"); -harness_test!(harness_codex, "nvidia.fabric.codex"); -harness_test!(harness_mini_swe_agent, "nvidia.fabric.mini-swe-agent"); -harness_test!(harness_nooa, "nvidia.fabric.nooa"); -harness_test!(harness_nooa_bench, "nvidia.fabric.nooa.bench-agent"); -harness_test!(harness_remote_agent, "nvidia.fabric.remote-agent"); harness_test!(harness_pi, "nvidia.fabric.pi"); async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: &str) { @@ -46,11 +40,7 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: let _image_engine = nemoclaw_e2e::image_runtime::engine(&mut document).await; // Keep passive discovery deterministic across apply and export. Connection // failures can otherwise vary between transport errors and timeouts. - let catalog_path = if harness == "nvidia.fabric.claude" { - "/v1/models?limit=1000" - } else { - "/v1/models" - }; + let catalog_path = "/v1/models"; let unexpected = Arc::new(Mutex::new(Vec::new())); let seen = unexpected.clone(); let catalog = nemoclaw_e2e::http_fixture::Fixture::start_tcp(move |request| { @@ -86,21 +76,6 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: .overrides .clone(); } - if harness == "nvidia.fabric.claude" { - document.spec.inference_providers[0].provider = InferenceProviderKind::Anthropic; - } - if harness == "nvidia.fabric.codex" { - document.spec.inference_providers[0].api = - Some(nemoclaw_sdk::config::InferenceApi::OpenaiResponses); - } - if harness == "nvidia.fabric.nooa" { - document.spec.sandboxes[0].harness.as_mut().unwrap().config = Some( - serde_json::from_value( - serde_json::json!({"workflow":{"target_id":"nvidia.nooa.coding-agent"}}), - ) - .unwrap(), - ); - } let deployment = Deployment::new(directory.path(), &bundle); let cancel = CancellationToken::new(); fixture.state.lock().unwrap().inference_exit = 1; @@ -171,20 +146,6 @@ async fn harness_reconciles_configuration_and_protects_sandbox_identity(harness: .iter() .any(|arg| arg == "invoke" || arg == "--message")) ); - // Model changes and the refusal of adapter, image, and observed changes do - // not depend on the harness. OpenClaw covers them, and Pi its route roles; - // every other harness only proves it applies, reapplies, and exports. - if !matches!(harness, "nvidia.fabric.openclaw" | "nvidia.fabric.pi") { - deployment.destroy(&cancel).await.unwrap(); - assert!(fixture.state.lock().unwrap().sandboxes.is_empty()); - assert!(fixture.state.lock().unwrap().providers.is_empty()); - assert_eq!( - *unexpected.lock().unwrap(), - Vec::::new(), - "only the model catalog may be requested" - ); - return; - } if harness != "nvidia.fabric.pi" { let mut changed_model = document.clone(); changed_model.spec.sandboxes[0] diff --git a/crates/nemoclaw-sdk/src/deployment/export.rs b/crates/nemoclaw-sdk/src/deployment/export.rs index 5e1942f46ca..9bf18ad64ec 100644 --- a/crates/nemoclaw-sdk/src/deployment/export.rs +++ b/crates/nemoclaw-sdk/src/deployment/export.rs @@ -176,40 +176,52 @@ impl Deployment { let observations = operation .export_observations(&bundle, &store, &record, false, cancel) .await?; - let mut document = record.document; - consistent_provider_credentials(&document, &record.generations, &observations)?; - for target in compile::targets(&document, &record.generations)? { - if cancel.is_cancelled() { - return Err(Error::Cancelled); - } - if target.address.starts_with("data.") || plan::disposable(&target.address) { - continue; - } - let mut observation = observations[&target.address].clone(); - // Typed OpenShell inputs return to the JSON their rows carry. - for input in nemoclaw_openshell::structured_inputs(&target.kind) { - if let Some(object) = observation.as_object_mut() - && let Some(value) = object.remove(input.attribute) - { - let encoded = input - .row_value(value) - .map_err(|_| Error::State("invalid provider export observation"))?; - object.insert(input.field.into(), json!(encoded.unwrap_or_default())); - } - } - let observed: Row = serde_json::from_value(observation) - .map_err(|_| Error::State("invalid provider export observation"))?; - let mut expected = target.values; - expected.insert("id".into(), observed["id"].clone()); - match target.kind.as_str() { - "provider" => export_provider(&mut document, &expected, &observed)?, - "sandbox" => export_sandbox(&expected, &observed)?, - _ => {} + if cancel.is_cancelled() { + return Err(Error::Cancelled); + } + exported(record.document, &record.generations, &observations) + } +} + +/// The saved document, once the observed OpenShell objects agree with what it +/// compiles to. Observations are the refreshed state's attributes by address. +pub(super) fn exported( + mut document: Document, + generations: &compile::Generations, + observations: &BTreeMap, +) -> Result { + consistent_provider_credentials(&document, generations, observations)?; + for target in compile::targets(&document, generations)? { + if target.address.starts_with("data.") || plan::disposable(&target.address) { + continue; + } + let mut observation = observations + .get(&target.address) + .cloned() + .ok_or(Error::State("incomplete provider export observation"))?; + // Typed OpenShell inputs return to the JSON their rows carry. + for input in nemoclaw_openshell::structured_inputs(&target.kind) { + if let Some(object) = observation.as_object_mut() + && let Some(value) = object.remove(input.attribute) + { + let encoded = input + .row_value(value) + .map_err(|_| Error::State("invalid provider export observation"))?; + object.insert(input.field.into(), json!(encoded.unwrap_or_default())); } } - document.validate()?; - Ok(document) + let observed: Row = serde_json::from_value(observation) + .map_err(|_| Error::State("invalid provider export observation"))?; + let mut expected = target.values; + expected.insert("id".into(), observed["id"].clone()); + match target.kind.as_str() { + "provider" => export_provider(&mut document, &expected, &observed)?, + "sandbox" => export_sandbox(&expected, &observed)?, + _ => {} + } } + document.validate()?; + Ok(document) } fn validate_projection(target: &Target, observed: &Value) -> Result<(), Error> { @@ -415,6 +427,82 @@ fn export_sandbox(expected: &Row, observed: &Row) -> Result<(), Error> { mod tests { use super::*; + /// Observations that echo what `document` compiles to, as providers + /// report a deployment applied from it. + fn echoed(document: &Document, generations: &compile::Generations) -> BTreeMap { + compile::targets(document, generations) + .unwrap() + .into_iter() + .filter(|target| !target.address.starts_with("data.")) + .map(|target| { + let mut row = json!(target.values); + row["id"] = json!(format!("{}-id", target.address)); + (target.address, row) + }) + .collect() + } + + /// A generation for every kind `document` records. + fn generations(document: &Document) -> compile::Generations { + ["workspace", "provider", "sandbox"] + .into_iter() + .chain(crate::services::generation_kinds(document).unwrap()) + .map(|key| (key.into(), "a".repeat(32))) + .collect() + } + + /// Every example's saved document exports unchanged when the providers + /// report what it compiled to, and a drifted sandbox or provider stops the + /// export. + #[test] + fn each_example_exports_its_applied_document_and_stops_on_drift() { + let examples = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../examples"); + let mut exported_examples = 0; + for entry in fs::read_dir(&examples).unwrap() { + let path = entry.unwrap().path(); + if path.extension().and_then(|extension| extension.to_str()) != Some("yaml") { + continue; + } + let mut document = Document::parse(fs::read(&path).unwrap().as_slice()) + .unwrap_or_else(|error| panic!("{}: {error}", path.display())); + document.defaults(); + let generations = generations(&document); + let observations = echoed(&document, &generations); + assert_eq!( + exported(document.clone(), &generations, &observations) + .unwrap_or_else(|error| panic!("{}: {error}", path.display())), + document, + "{}", + path.display() + ); + for (kind, field, value) in [ + ("sandbox", "image", "drifted@sha256:0"), + ("provider", "endpoint", "https://drifted.example/v1"), + ] { + let Some(address) = compile::targets(&document, &generations) + .unwrap() + .into_iter() + .find(|target| target.kind == kind && target.values.contains_key(field)) + .map(|target| target.address) + else { + continue; + }; + let mut drifted = observations.clone(); + drifted.get_mut(&address).unwrap()[field] = json!(value); + assert!( + exported(document.clone(), &generations, &drifted).is_err(), + "{}: {kind}.{field} drift was exported", + path.display() + ); + } + let mut missing = observations.clone(); + missing.pop_first(); + assert!(exported(document.clone(), &generations, &missing).is_err()); + exported_examples += 1; + } + assert!(exported_examples > 20, "examples were not found"); + } + #[tokio::test] #[ignore = "uses the verified bundle named by NEMOCLAW_TEST_BUNDLE"] async fn runtime_export_declares_the_native_helm_provider_inputs() { From 5983679f0ec208817a3819a05baba97967855dca Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 04:59:00 -0700 Subject: [PATCH 14/18] test(openshell): apply every example's OpenShell resources in contract tests #12906 removed system lifecycles that were the only check that the fake gateway accepts each configuration variant's OpenShell resources and reads them back unchanged. Those checks belong to the openshell provider's contract tests, which did not exist: its types were tested only from nemoclaw-e2e, and the provider crate could not use the fake gateway because nemoclaw-e2e depends on the providers. - nemoclaw-test-fixtures now holds the fake OpenShell gateway and the owned OpenTofu workspace; nemoclaw-e2e re-exports them. - openshell-provider's contract binary applies one fixture per example with an external gateway through OpenTofu, checks that the next plan changes no managed resource, and tears down as the SDK does: every sandbox, registration, and profile is removed and the workspace kept. A coverage test requires a test per fixture and a fixture per type. - The fixtures are the OpenShell resources the SDK compiles for each example. nemoclaw-e2e fails when they differ, and NEMOCLAW_REGENERATE_FIXTURES=1 rewrites them. - The lifecycle profile selects the contract binary. Part of #12880. --- .config/nextest.toml | 1 + Cargo.lock | 19 + Cargo.toml | 1 + crates/nemoclaw-e2e/Cargo.toml | 1 + crates/nemoclaw-e2e/src/lib.rs | 3 +- crates/nemoclaw-e2e/tests/main.rs | 2 + .../tests/openshell_contract_fixtures.rs | 145 ++++++ crates/nemoclaw-test-fixtures/Cargo.toml | 29 ++ crates/nemoclaw-test-fixtures/src/lib.rs | 12 + .../src/openshell.rs | 0 .../src/tofu.rs | 44 +- crates/openshell-provider/Cargo.toml | 2 + .../contract/fixtures/explicit-policy.tf.json | 219 +++++++++ .../contract/fixtures/fabric-claude.tf.json | 163 +++++++ .../contract/fixtures/fabric-codex.tf.json | 163 +++++++ .../contract/fixtures/fabric-hermes.tf.json | 163 +++++++ .../fixtures/fabric-mini-swe-agent.tf.json | 163 +++++++ .../fixtures/fabric-nooa-bench.tf.json | 163 +++++++ .../contract/fixtures/fabric-nooa.tf.json | 163 +++++++ .../contract/fixtures/fabric-openclaw.tf.json | 163 +++++++ .../tests/contract/fixtures/fabric-pi.tf.json | 163 +++++++ .../fixtures/fabric-remote-agent.tf.json | 163 +++++++ .../tests/contract/fixtures/fabric.tf.json | 163 +++++++ .../contract/fixtures/hermes-auth.tf.json | 160 +++++++ .../fixtures/hermes-interfaces.tf.json | 163 +++++++ .../fixtures/inference-tuning.tf.json | 160 +++++++ .../fixtures/inline-inference.tf.json | 163 +++++++ .../tests/contract/fixtures/local.tf.json | 163 +++++++ .../contract/fixtures/multiple-models.tf.json | 209 +++++++++ .../fixtures/multiple-providers.tf.json | 268 +++++++++++ .../fixtures/multiple-sandboxes.tf.json | 435 ++++++++++++++++++ .../fixtures/openclaw-dashboard.tf.json | 160 +++++++ .../fixtures/openclaw-web-search.tf.json | 295 ++++++++++++ .../fixtures/tavily-web-search.tf.json | 393 ++++++++++++++++ .../openshell-provider/tests/contract/main.rs | 204 ++++++++ docs/contributing/integration-tests.md | 14 + 36 files changed, 4886 insertions(+), 9 deletions(-) create mode 100644 crates/nemoclaw-e2e/tests/openshell_contract_fixtures.rs create mode 100644 crates/nemoclaw-test-fixtures/Cargo.toml create mode 100644 crates/nemoclaw-test-fixtures/src/lib.rs rename crates/{nemoclaw-e2e => nemoclaw-test-fixtures}/src/openshell.rs (100%) rename crates/{nemoclaw-e2e => nemoclaw-test-fixtures}/src/tofu.rs (76%) create mode 100644 crates/openshell-provider/tests/contract/fixtures/explicit-policy.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-claude.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-codex.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-hermes.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-mini-swe-agent.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-nooa-bench.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-nooa.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-openclaw.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-pi.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric-remote-agent.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/fabric.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/hermes-auth.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/hermes-interfaces.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/inference-tuning.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/inline-inference.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/local.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/multiple-models.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/multiple-providers.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/openclaw-dashboard.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/openclaw-web-search.tf.json create mode 100644 crates/openshell-provider/tests/contract/fixtures/tavily-web-search.tf.json create mode 100644 crates/openshell-provider/tests/contract/main.rs diff --git a/.config/nextest.toml b/.config/nextest.toml index e4cf710a944..5c502218616 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -22,6 +22,7 @@ default-filter = ''' test(native_state_json_preserves_module_and_instance_identity_without_refresh) | (package(nemoclaw-sdk) & test(/^deployment::runtime::helm_recovery::tests::/)) | (package(nemoclaw-sdk) & test(runtime_export_declares_the_native_helm_provider_inputs)) +| (package(openshell-provider) & binary(=contract)) | (package(nemoclaw-e2e) & binary(=integration) & ( test(/^provider_protocol::/) | test(/^service_capacity::/) | test(/^service_readiness::/) | test(/^sandbox_readiness::/) | test(/^opentofu_openshell::/) | test(/^deployment::/) diff --git a/Cargo.lock b/Cargo.lock index 440a2741505..0d4a293731c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2600,6 +2600,7 @@ dependencies = [ "nemoclaw-provider", "nemoclaw-runtime", "nemoclaw-sdk", + "nemoclaw-test-fixtures", "nemoclaw-tofu", "openshell-core", "prost", @@ -2799,6 +2800,23 @@ dependencies = [ "widestring", ] +[[package]] +name = "nemoclaw-test-fixtures" +version = "0.1.0" +dependencies = [ + "http", + "openshell-core", + "prost", + "rustls", + "serde_json", + "tempfile", + "tokio", + "tokio-stream", + "tonic", + "tonic-prost", + "tower", +] + [[package]] name = "nemoclaw-tofu" version = "0.1.0" @@ -3118,6 +3136,7 @@ dependencies = [ "nemoclaw-backend", "nemoclaw-docker", "nemoclaw-openshell", + "nemoclaw-test-fixtures", "nemoclaw-tofu", "openshell-core", "openshell-policy", diff --git a/Cargo.toml b/Cargo.toml index fd9059669e9..f0b7e385fd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ "crates/nemoclaw-discovery", "crates/nemoclaw-provider", "crates/nemoclaw-e2e", + "crates/nemoclaw-test-fixtures", "crates/nemoclaw-cli", "crates/nemoclaw-runtime", "crates/nemoclaw-build", diff --git a/crates/nemoclaw-e2e/Cargo.toml b/crates/nemoclaw-e2e/Cargo.toml index a033d74057f..d52934f7e06 100644 --- a/crates/nemoclaw-e2e/Cargo.toml +++ b/crates/nemoclaw-e2e/Cargo.toml @@ -26,6 +26,7 @@ nemoclaw-provider = { path = "../nemoclaw-provider" } nemoclaw-tofu = { path = "../nemoclaw-tofu" } fabric-provider = { path = "../fabric-provider" } nemoclaw-openshell = { path = "../nemoclaw-openshell" } +nemoclaw-test-fixtures = { path = "../nemoclaw-test-fixtures" } async-trait.workspace = true serde_json.workspace = true serde.workspace = true diff --git a/crates/nemoclaw-e2e/src/lib.rs b/crates/nemoclaw-e2e/src/lib.rs index 4a1c338d5cb..0a74109aff5 100644 --- a/crates/nemoclaw-e2e/src/lib.rs +++ b/crates/nemoclaw-e2e/src/lib.rs @@ -4,8 +4,7 @@ //! Protocol fixtures shared by SDK and bundle lifecycle tests. pub mod hcl; pub mod image_runtime; -pub mod openshell; -pub mod tofu; +pub use nemoclaw_test_fixtures::{openshell, tofu}; #[path = "../../test-support/http.rs"] pub mod http_fixture; diff --git a/crates/nemoclaw-e2e/tests/main.rs b/crates/nemoclaw-e2e/tests/main.rs index 16f58c40fe1..9bd14c93632 100644 --- a/crates/nemoclaw-e2e/tests/main.rs +++ b/crates/nemoclaw-e2e/tests/main.rs @@ -39,6 +39,8 @@ mod model_live; mod multiple_providers; #[path = "openshell.rs"] mod openshell; +#[path = "openshell_contract_fixtures.rs"] +mod openshell_contract_fixtures; #[path = "opentofu_openshell.rs"] mod opentofu_openshell; #[path = "provider_protocol.rs"] diff --git a/crates/nemoclaw-e2e/tests/openshell_contract_fixtures.rs b/crates/nemoclaw-e2e/tests/openshell_contract_fixtures.rs new file mode 100644 index 00000000000..228c0fc0c1e --- /dev/null +++ b/crates/nemoclaw-e2e/tests/openshell_contract_fixtures.rs @@ -0,0 +1,145 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! The openshell provider's contract fixtures are the OpenShell resources the +//! SDK compiles for each example with an external gateway. This test fails +//! when they differ; set NEMOCLAW_REGENERATE_FIXTURES=1 to rewrite them. + +use nemoclaw_sdk::{compile, config::Document}; +use serde_json::{Map, Value, json}; +use std::{collections::BTreeMap, fs, path::Path}; + +const FIXTURES: &str = concat!( + env!("CARGO_MANIFEST_DIR"), + "/../openshell-provider/tests/contract/fixtures" +); + +/// The fixture for `document`, or `None` when its OpenShell resources need +/// more than the fake gateway: a managed gateway, Kubernetes, or a credential +/// read from a managed service's container. +fn fixture(mut document: Document) -> Option { + if document.spec.gateway.as_managed().is_some() + || document.spec.gateway.as_kubernetes().is_some() + { + return None; + } + document.defaults(); + let generations: compile::Generations = ["workspace", "provider", "sandbox"] + .map(|kind| (kind.into(), "a".repeat(32))) + .into(); + let graph = compile::compile(&document, &generations, "0.1.0").ok()?; + // Fabric capabilities supply each sandbox's runtime binding; the fixture + // states the binding the fake images declare. + let mut encoded = serde_json::to_string(&graph["resource"]).unwrap(); + if encoded.contains("managedService") { + return None; + } + for (index, sandbox) in document.spec.sandboxes.iter().enumerate() { + let kind = sandbox.harness.as_ref().map_or_else( + || "nvidia.fabric.openclaw".to_owned(), + |harness| harness.kind.to_string(), + ); + let binding = nemoclaw_e2e::image_runtime::binding(&kind); + let runtime = serde_json::to_string(&serde_json::to_string(&binding).unwrap()).unwrap(); + encoded = encoded + .replace( + &format!( + "\"${{jsondecode(data.fabric_capabilities.sandbox_{index}.binaries_json)}}\"" + ), + &serde_json::to_string(&binding.binaries()).unwrap(), + ) + .replace( + &format!("\"${{data.fabric_capabilities.sandbox_{index}.runtime_json}}\""), + &runtime.replace("${", "$${"), + ); + } + let mut resources = Map::new(); + let compiled: Value = serde_json::from_str(&encoded).unwrap(); + for (kind, bodies) in compiled.as_object().unwrap() { + if !kind.starts_with("openshell_") { + continue; + } + let mut bodies = bodies.clone(); + for body in bodies.as_object_mut().unwrap().values_mut() { + // The contract test tears down as the SDK does, without the + // deployment's protection against accidental destroy. + if let Some(lifecycle) = body.get_mut("lifecycle").and_then(Value::as_object_mut) { + lifecycle.remove("prevent_destroy"); + } + if let Some(depends) = body.get_mut("depends_on").and_then(Value::as_array_mut) { + depends.retain(|address| { + address.as_str().is_some_and(|address| { + address.starts_with("openshell_") || address.starts_with("data.openshell_") + }) + }); + if depends.is_empty() { + body.as_object_mut().unwrap().remove("depends_on"); + } + } + } + resources.insert(kind.clone(), bodies); + } + let resources = Value::Object(resources); + let text = resources.to_string(); + assert!( + !text.contains("data.fabric_") && !text.contains("nemoclaw_"), + "the fixture references types the openshell provider does not serve: {text}" + ); + let mut openshell = graph["terraform"]["required_providers"]["openshell"].clone(); + openshell.as_object_mut().unwrap().remove("version"); + let fixture = json!({ + "terraform": { + "required_version": graph["terraform"]["required_version"], + "required_providers": {"openshell": openshell}, + }, + "variable": {"endpoint": {"type": "string"}, "destroying": {"default": false}}, + "provider": {"openshell": {"endpoint": "${var.endpoint}", "destroy": "${var.destroying}"}}, + "data": {"openshell_gateway": graph["data"]["openshell_gateway"]}, + "resource": resources, + }); + Some(serde_json::to_string_pretty(&fixture).unwrap() + "\n") +} + +#[test] +fn openshell_contract_fixtures_match_what_the_sdk_compiles() { + let examples = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../examples"); + let mut expected = BTreeMap::new(); + for entry in fs::read_dir(examples).unwrap() { + let path = entry.unwrap().path(); + if path.extension().is_none_or(|extension| extension != "yaml") { + continue; + } + let document = Document::parse(fs::read(&path).unwrap().as_slice()).unwrap(); + if let Some(fixture) = fixture(document) { + let name = path.file_stem().unwrap().to_string_lossy().into_owned(); + expected.insert(format!("{name}.tf.json"), fixture); + } + } + if std::env::var_os("NEMOCLAW_REGENERATE_FIXTURES").is_some() { + fs::remove_dir_all(FIXTURES).ok(); + fs::create_dir_all(FIXTURES).unwrap(); + for (name, fixture) in &expected { + fs::write(Path::new(FIXTURES).join(name), fixture).unwrap(); + } + } + let actual: BTreeMap = fs::read_dir(FIXTURES) + .unwrap() + .map(|entry| { + let path = entry.unwrap().path(); + ( + path.file_name().unwrap().to_string_lossy().into_owned(), + fs::read_to_string(&path).unwrap(), + ) + }) + .collect(); + assert_eq!( + actual.keys().collect::>(), + expected.keys().collect::>(), + "regenerate with NEMOCLAW_REGENERATE_FIXTURES=1" + ); + for (name, fixture) in &expected { + assert!( + actual[name] == *fixture, + "{name} is stale; regenerate with NEMOCLAW_REGENERATE_FIXTURES=1" + ); + } +} diff --git a/crates/nemoclaw-test-fixtures/Cargo.toml b/crates/nemoclaw-test-fixtures/Cargo.toml new file mode 100644 index 00000000000..5dc7ca20731 --- /dev/null +++ b/crates/nemoclaw-test-fixtures/Cargo.toml @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Test fixtures shared by the provider contract tests and the end-to-end +# tests. Provider crates use them as development dependencies; nemoclaw-e2e +# depends on the providers, so they cannot live there. +[package] +name = "nemoclaw-test-fixtures" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +publish = false + +[dependencies] +openshell-core.workspace = true +tonic.workspace = true +tonic-prost.workspace = true +prost.workspace = true +tower.workspace = true +http.workspace = true +tokio.workspace = true +tokio-stream.workspace = true +rustls.workspace = true +serde_json.workspace = true +tempfile.workspace = true + +[lints] +workspace = true diff --git a/crates/nemoclaw-test-fixtures/src/lib.rs b/crates/nemoclaw-test-fixtures/src/lib.rs new file mode 100644 index 00000000000..4467343f05e --- /dev/null +++ b/crates/nemoclaw-test-fixtures/src/lib.rs @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +//! A fake OpenShell gateway and owned OpenTofu workspaces, shared by the +//! provider contract tests and the end-to-end tests. +pub mod openshell; +pub mod tofu; + +/// `name` as an executable on this platform. +pub fn executable(name: &str) -> String { + format!("{name}{}", std::env::consts::EXE_SUFFIX) +} diff --git a/crates/nemoclaw-e2e/src/openshell.rs b/crates/nemoclaw-test-fixtures/src/openshell.rs similarity index 100% rename from crates/nemoclaw-e2e/src/openshell.rs rename to crates/nemoclaw-test-fixtures/src/openshell.rs diff --git a/crates/nemoclaw-e2e/src/tofu.rs b/crates/nemoclaw-test-fixtures/src/tofu.rs similarity index 76% rename from crates/nemoclaw-e2e/src/tofu.rs rename to crates/nemoclaw-test-fixtures/src/tofu.rs index c78081ec77c..954bc873e81 100644 --- a/crates/nemoclaw-e2e/src/tofu.rs +++ b/crates/nemoclaw-test-fixtures/src/tofu.rs @@ -22,13 +22,13 @@ impl TofuWorkspace { let provider = provider.as_ref(); fs::copy( provider, - directory.path().join(nemoclaw_sdk::bundle::executable( - "terraform-provider-nemoclaw", - )), + directory + .path() + .join(crate::executable("terraform-provider-nemoclaw")), ) .unwrap(); for name in ["openshell", "fabric"] { - let binary = nemoclaw_sdk::bundle::executable(&format!("terraform-provider-{name}")); + let binary = crate::executable(&format!("terraform-provider-{name}")); let sibling = provider.with_file_name(&binary); if sibling.exists() { fs::copy(sibling, directory.path().join(binary)).unwrap(); @@ -49,6 +49,36 @@ impl TofuWorkspace { } } + /// A workspace whose OpenTofu uses only the given `(name, executable)` + /// providers from `registry.opentofu.org/nvidia`. + pub fn with_providers(tofu: impl AsRef, providers: &[(&str, &Path)]) -> Self { + let directory = tempfile::tempdir().unwrap(); + for (name, executable) in providers { + fs::copy( + executable, + directory + .path() + .join(crate::executable(&format!("terraform-provider-{name}"))), + ) + .unwrap(); + } + let path = serde_json::to_string(directory.path()).unwrap(); + let overrides = providers + .iter() + .map(|(name, _)| format!("\"registry.opentofu.org/nvidia/{name}\" = {path}")) + .collect::>() + .join(" "); + fs::write( + directory.path().join("tofu.rc"), + format!("provider_installation {{ dev_overrides {{ {overrides} }} direct {{}} }}"), + ) + .unwrap(); + Self { + directory, + tofu: tofu.as_ref().to_owned(), + } + } + pub fn path(&self) -> &Path { self.directory.path() } @@ -79,9 +109,9 @@ mod tests { fs::write(&provider, &script).unwrap(); fs::set_permissions(&provider, fs::Permissions::from_mode(0o700)).unwrap(); let workspace = TofuWorkspace::new("/bin/sh", &provider); - let staged = workspace.path().join(nemoclaw_sdk::bundle::executable( - "terraform-provider-nemoclaw", - )); + let staged = workspace + .path() + .join(crate::executable("terraform-provider-nemoclaw")); let output = Command::new(&staged).output().unwrap(); assert!(output.status.success()); assert_eq!(output.stdout, selected.as_bytes()); diff --git a/crates/openshell-provider/Cargo.toml b/crates/openshell-provider/Cargo.toml index ed6477cc468..6d99efba62e 100644 --- a/crates/openshell-provider/Cargo.toml +++ b/crates/openshell-provider/Cargo.toml @@ -31,5 +31,7 @@ tokio-util.workspace = true tonic.workspace = true [dev-dependencies] +nemoclaw-test-fixtures = { path = "../nemoclaw-test-fixtures" } +serde_json.workspace = true prost.workspace = true tokio = { workspace = true, features = ["test-util"] } diff --git a/crates/openshell-provider/tests/contract/fixtures/explicit-policy.tf.json b/crates/openshell-provider/tests/contract/fixtures/explicit-policy.tf.json new file mode 100644 index 00000000000..8aa97f763a2 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/explicit-policy.tf.json @@ -0,0 +1,219 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11436/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "6bf061fe-34ce-492a-9be0-f81182de72b2", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11436/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "6bf061fe-34ce-492a-9be0-f81182de72b2", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "6bf061fe-34ce-492a-9be0-f81182de72b2", + "policy": { + "explicit": { + "filesystem_policy": { + "include_workdir": false, + "read_only": [ + "/usr", + "/bin", + "/sbin", + "/lib", + "/lib64", + "/etc", + "/app", + "/opt", + "/proc" + ], + "read_write": [ + "/sandbox", + "/tmp", + "/dev/null", + "/dev/urandom", + "/home/node" + ] + }, + "landlock": { + "compatibility": "best_effort" + }, + "network_policies": { + "documentation": { + "binaries": [ + { + "path": "/usr/bin/curl" + } + ], + "endpoints": [ + { + "enforcement": "enforce", + "host": "docs.example.com", + "port": 443, + "protocol": "rest", + "rules": [ + { + "allow": { + "method": "GET", + "path": "/docs/**" + } + } + ] + } + ], + "name": "documentation" + } + }, + "process": { + "run_as_group": "10001", + "run_as_user": "10001" + }, + "version": 1 + }, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11436, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-2fdfbc07d02a948e", + "owner": "6bf061fe-34ce-492a-9be0-f81182de72b2" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-claude.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-claude.tf.json new file mode 100644 index 00000000000..a70625e5579 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-claude.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-96b36b51dbfca220bc44484b": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-96b36b51dbfca220bc44484b", + "owner": "efa70976-e992-4a88-86d6-16c7d3e7c872", + "provider_type": "anthropic", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-96b36b51dbfca220bc44484b": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-96b36b51dbfca220bc44484b", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-96b36b51dbfca220bc44484b", + "owner": "efa70976-e992-4a88-86d6-16c7d3e7c872", + "provider_type": "anthropic", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-96b36b51dbfca220bc44484b", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:ad0f0a9bdef6b1d1efd77b850cff8137d257fee03aa29e3b6980d81cd52fb3fb", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "efa70976-e992-4a88-86d6-16c7d3e7c872", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-96b36b51dbfca220bc44484b": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-96b36b51dbfca220bc44484b" + } + } + }, + "provider_names": [ + "local-96b36b51dbfca220bc44484b" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.claude\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.claude\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-5da8a3c5b1d82b55", + "owner": "efa70976-e992-4a88-86d6-16c7d3e7c872" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-codex.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-codex.tf.json new file mode 100644 index 00000000000..ecbc09b5e4a --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-codex.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-864fcf8e4ba83d2f9fe779bf": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-864fcf8e4ba83d2f9fe779bf", + "owner": "47a41128-49bb-4dcc-9d48-f754157b55a1", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-864fcf8e4ba83d2f9fe779bf": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-864fcf8e4ba83d2f9fe779bf", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-864fcf8e4ba83d2f9fe779bf", + "owner": "47a41128-49bb-4dcc-9d48-f754157b55a1", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-864fcf8e4ba83d2f9fe779bf", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:5d7ab97e878116ae728df2a29386345b4214975fa7360c8d091b6eb45cfb1479", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "47a41128-49bb-4dcc-9d48-f754157b55a1", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-864fcf8e4ba83d2f9fe779bf": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-864fcf8e4ba83d2f9fe779bf" + } + } + }, + "provider_names": [ + "local-864fcf8e4ba83d2f9fe779bf" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.codex\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.codex\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-097aa832df9e860e", + "owner": "47a41128-49bb-4dcc-9d48-f754157b55a1" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-hermes.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-hermes.tf.json new file mode 100644 index 00000000000..b7e77a2165a --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-hermes.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-929902000fc175100ecb6a29": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-929902000fc175100ecb6a29", + "owner": "55377f6f-3987-476d-8934-4c95dd385a62", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-929902000fc175100ecb6a29": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-929902000fc175100ecb6a29", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-929902000fc175100ecb6a29", + "owner": "55377f6f-3987-476d-8934-4c95dd385a62", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-929902000fc175100ecb6a29", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:22e0c2ddf37b8ee46c89341af7fd26f913072309630924038b62ad220dff0d40", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "55377f6f-3987-476d-8934-4c95dd385a62", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-929902000fc175100ecb6a29": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-929902000fc175100ecb6a29" + } + } + }, + "provider_names": [ + "local-929902000fc175100ecb6a29" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.hermes\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.hermes\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-d9dbb05d0991d823", + "owner": "55377f6f-3987-476d-8934-4c95dd385a62" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-mini-swe-agent.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-mini-swe-agent.tf.json new file mode 100644 index 00000000000..c2642f604b7 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-mini-swe-agent.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-fbc7a7ff452ab9ce0475ef34": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-fbc7a7ff452ab9ce0475ef34", + "owner": "9b33c13b-516f-4377-bbf1-0019d00a9271", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-fbc7a7ff452ab9ce0475ef34": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-fbc7a7ff452ab9ce0475ef34", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-fbc7a7ff452ab9ce0475ef34", + "owner": "9b33c13b-516f-4377-bbf1-0019d00a9271", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-fbc7a7ff452ab9ce0475ef34", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:b362c65247df2db9fd50f4699df5f2e067f68aabf3e7d2a6800b3ec03a9674f9", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "9b33c13b-516f-4377-bbf1-0019d00a9271", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-fbc7a7ff452ab9ce0475ef34": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-fbc7a7ff452ab9ce0475ef34" + } + } + }, + "provider_names": [ + "local-fbc7a7ff452ab9ce0475ef34" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.mini-swe-agent\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.mini-swe-agent\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-9cb56b5acabe3cd9", + "owner": "9b33c13b-516f-4377-bbf1-0019d00a9271" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-nooa-bench.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-nooa-bench.tf.json new file mode 100644 index 00000000000..5d5599ff37b --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-nooa-bench.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-207e499ab0a3f54cec878921": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-207e499ab0a3f54cec878921", + "owner": "1533935c-7ff1-4c28-9a68-c42ef3dd2fb3", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-207e499ab0a3f54cec878921": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-207e499ab0a3f54cec878921", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-207e499ab0a3f54cec878921", + "owner": "1533935c-7ff1-4c28-9a68-c42ef3dd2fb3", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-207e499ab0a3f54cec878921", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:deaa2580e46f5d27105c7051771d36da36c5879ac2fea98e6b22cd651c910260", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "1533935c-7ff1-4c28-9a68-c42ef3dd2fb3", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-207e499ab0a3f54cec878921": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-207e499ab0a3f54cec878921" + } + } + }, + "provider_names": [ + "local-207e499ab0a3f54cec878921" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.nooa.bench-agent\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.nooa.bench-agent\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-012b77653b27ec99", + "owner": "1533935c-7ff1-4c28-9a68-c42ef3dd2fb3" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-nooa.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-nooa.tf.json new file mode 100644 index 00000000000..161de6702aa --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-nooa.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-d5bd7ef3040f5b112d4677fc": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-d5bd7ef3040f5b112d4677fc", + "owner": "05dc2840-4ae1-40e9-9fd8-85a66113d902", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-d5bd7ef3040f5b112d4677fc": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-d5bd7ef3040f5b112d4677fc", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-d5bd7ef3040f5b112d4677fc", + "owner": "05dc2840-4ae1-40e9-9fd8-85a66113d902", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-d5bd7ef3040f5b112d4677fc", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:c1cf75ce3036c2c438375b8e9921eeca06f302a3f7f42d1e412cd571ffd8323b", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "05dc2840-4ae1-40e9-9fd8-85a66113d902", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-d5bd7ef3040f5b112d4677fc": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-d5bd7ef3040f5b112d4677fc" + } + } + }, + "provider_names": [ + "local-d5bd7ef3040f5b112d4677fc" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.nooa\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.nooa\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-56ad5164b5678df2", + "owner": "05dc2840-4ae1-40e9-9fd8-85a66113d902" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-openclaw.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-openclaw.tf.json new file mode 100644 index 00000000000..efc87e6420c --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-openclaw.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "c892587f-6439-44b5-9a70-a43e8936461f", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "c892587f-6439-44b5-9a70-a43e8936461f", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "c892587f-6439-44b5-9a70-a43e8936461f", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-803817bc4e530090", + "owner": "c892587f-6439-44b5-9a70-a43e8936461f" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-pi.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-pi.tf.json new file mode 100644 index 00000000000..8c0b9189b45 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-pi.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-b95da89e857d01251c2f1583": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-b95da89e857d01251c2f1583", + "owner": "c4a639f3-2bd3-42ba-8f5d-658d7913b0f9", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-b95da89e857d01251c2f1583": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-b95da89e857d01251c2f1583", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-b95da89e857d01251c2f1583", + "owner": "c4a639f3-2bd3-42ba-8f5d-658d7913b0f9", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-b95da89e857d01251c2f1583", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-multi-models@sha256:2ee5e33522a37d3d77bb6381a92e963cb1d5884f2dd28b353b4b7fa0d95f212e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "c4a639f3-2bd3-42ba-8f5d-658d7913b0f9", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-b95da89e857d01251c2f1583": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-b95da89e857d01251c2f1583" + } + } + }, + "provider_names": [ + "local-b95da89e857d01251c2f1583" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.pi\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.pi\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-7d7dd0c26797bf18", + "owner": "c4a639f3-2bd3-42ba-8f5d-658d7913b0f9" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric-remote-agent.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric-remote-agent.tf.json new file mode 100644 index 00000000000..089b237b227 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric-remote-agent.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-253be5534917b23b8a5ab697": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-253be5534917b23b8a5ab697", + "owner": "e1b40bdf-b151-4259-b6b7-63b083ae071b", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-253be5534917b23b8a5ab697": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-253be5534917b23b8a5ab697", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-253be5534917b23b8a5ab697", + "owner": "e1b40bdf-b151-4259-b6b7-63b083ae071b", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-253be5534917b23b8a5ab697", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:a60d580895c1667bddd2063078837134eb5cc7fea73aea7b0b6a55a4fa89204a", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "e1b40bdf-b151-4259-b6b7-63b083ae071b", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-253be5534917b23b8a5ab697": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-253be5534917b23b8a5ab697" + } + } + }, + "provider_names": [ + "local-253be5534917b23b8a5ab697" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.remote-agent\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.remote-agent\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-3d2bf02533772a8d", + "owner": "e1b40bdf-b151-4259-b6b7-63b083ae071b" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/fabric.tf.json b/crates/openshell-provider/tests/contract/fixtures/fabric.tf.json new file mode 100644 index 00000000000..cf4dbe4c1bc --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/fabric.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-3d36801b67957c3bcfa1093b": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-3d36801b67957c3bcfa1093b", + "owner": "07eea4a7-8d1d-4c54-b241-e328eb34ac60", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-3d36801b67957c3bcfa1093b": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-3d36801b67957c3bcfa1093b", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-3d36801b67957c3bcfa1093b", + "owner": "07eea4a7-8d1d-4c54-b241-e328eb34ac60", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-3d36801b67957c3bcfa1093b", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:a6a0e5cf53501e765ae43457212989ff4716c6224352dc109ebd49c3780450cd", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "07eea4a7-8d1d-4c54-b241-e328eb34ac60", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-3d36801b67957c3bcfa1093b": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-3d36801b67957c3bcfa1093b" + } + } + }, + "provider_names": [ + "local-3d36801b67957c3bcfa1093b" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.langchain.deepagents\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.langchain.deepagents\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-ff706566877c6e2a", + "owner": "07eea4a7-8d1d-4c54-b241-e328eb34ac60" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/hermes-auth.tf.json b/crates/openshell-provider/tests/contract/fixtures/hermes-auth.tf.json new file mode 100644 index 00000000000..984ce34fe3c --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/hermes-auth.tf.json @@ -0,0 +1,160 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-7761fdd381c7cf8bfbd7f964": { + "authenticated": "true", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference-api.nousresearch.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-7761fdd381c7cf8bfbd7f964", + "owner": "c659b251-29b2-4666-b191-8b27106f8102", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-7761fdd381c7cf8bfbd7f964": { + "credential_env": "NOUS_API_KEY", + "depends_on": [ + "openshell_provider_profile.inference_local-7761fdd381c7cf8bfbd7f964", + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference-api.nousresearch.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-7761fdd381c7cf8bfbd7f964", + "owner": "c659b251-29b2-4666-b191-8b27106f8102", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-7761fdd381c7cf8bfbd7f964", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "local-fabric-hermes@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "c659b251-29b2-4666-b191-8b27106f8102", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-7761fdd381c7cf8bfbd7f964": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "host": "inference-api.nousresearch.com", + "path": "/v1/**", + "port": 443, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-7761fdd381c7cf8bfbd7f964" + } + } + }, + "provider_names": [ + "local-7761fdd381c7cf8bfbd7f964" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.hermes\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.hermes\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-04008ec2d54ac1a7", + "owner": "c659b251-29b2-4666-b191-8b27106f8102" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/hermes-interfaces.tf.json b/crates/openshell-provider/tests/contract/fixtures/hermes-interfaces.tf.json new file mode 100644 index 00000000000..403ee8b80d3 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/hermes-interfaces.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-d4747d2fc122f9ce28c8c315": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-d4747d2fc122f9ce28c8c315", + "owner": "d4094d68-6798-4550-b4ec-ff242f6f4110", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-d4747d2fc122f9ce28c8c315": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-d4747d2fc122f9ce28c8c315", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-d4747d2fc122f9ce28c8c315", + "owner": "d4094d68-6798-4550-b4ec-ff242f6f4110", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-d4747d2fc122f9ce28c8c315", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "d4094d68-6798-4550-b4ec-ff242f6f4110", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-d4747d2fc122f9ce28c8c315": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-d4747d2fc122f9ce28c8c315" + } + } + }, + "provider_names": [ + "local-d4747d2fc122f9ce28c8c315" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.hermes\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.hermes\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-1a1796b19505085b", + "owner": "d4094d68-6798-4550-b4ec-ff242f6f4110" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/inference-tuning.tf.json b/crates/openshell-provider/tests/contract/fixtures/inference-tuning.tf.json new file mode 100644 index 00000000000..673368acebb --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/inference-tuning.tf.json @@ -0,0 +1,160 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-b2422a7f17e9375479fabdfa": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference.example.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-b2422a7f17e9375479fabdfa", + "owner": "0f4a82ef-0239-49a0-a08a-9a6b1d5d05ae", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-b2422a7f17e9375479fabdfa": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-b2422a7f17e9375479fabdfa", + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference.example.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-b2422a7f17e9375479fabdfa", + "owner": "0f4a82ef-0239-49a0-a08a-9a6b1d5d05ae", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-b2422a7f17e9375479fabdfa", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "local-fabric-openclaw@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "0f4a82ef-0239-49a0-a08a-9a6b1d5d05ae", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-b2422a7f17e9375479fabdfa": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "host": "inference.example.com", + "path": "/v1/**", + "port": 443, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-b2422a7f17e9375479fabdfa" + } + } + }, + "provider_names": [ + "local-b2422a7f17e9375479fabdfa" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-8860982b4bd94b38", + "owner": "0f4a82ef-0239-49a0-a08a-9a6b1d5d05ae" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/inline-inference.tf.json b/crates/openshell-provider/tests/contract/fixtures/inline-inference.tf.json new file mode 100644 index 00000000000..8d2716048dd --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/inline-inference.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-722ee2aa493612fdfe83c788": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-722ee2aa493612fdfe83c788", + "owner": "ef59d17e-569c-45a4-afd4-98b531e2f9d6", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-722ee2aa493612fdfe83c788": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-722ee2aa493612fdfe83c788", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-722ee2aa493612fdfe83c788", + "owner": "ef59d17e-569c-45a4-afd4-98b531e2f9d6", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-722ee2aa493612fdfe83c788", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "ef59d17e-569c-45a4-afd4-98b531e2f9d6", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-722ee2aa493612fdfe83c788": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-722ee2aa493612fdfe83c788" + } + } + }, + "provider_names": [ + "local-722ee2aa493612fdfe83c788" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-db28d1f49ce4c3e5", + "owner": "ef59d17e-569c-45a4-afd4-98b531e2f9d6" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/local.tf.json b/crates/openshell-provider/tests/contract/fixtures/local.tf.json new file mode 100644 index 00000000000..28fe3b77c0b --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/local.tf.json @@ -0,0 +1,163 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11436/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "87d485ad-fba7-4197-9eaa-aa97cc97446b", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11436/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "87d485ad-fba7-4197-9eaa-aa97cc97446b", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "87d485ad-fba7-4197-9eaa-aa97cc97446b", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11436, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-8bb56695710753e3", + "owner": "87d485ad-fba7-4197-9eaa-aa97cc97446b" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/multiple-models.tf.json b/crates/openshell-provider/tests/contract/fixtures/multiple-models.tf.json new file mode 100644 index 00000000000..d322ebfb0d3 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/multiple-models.tf.json @@ -0,0 +1,209 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11434/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "51d3ac63-7e34-4aca-b3e4-13381f1dcb76", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11434/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "51d3ac63-7e34-4aca-b3e4-13381f1dcb76", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "researcher": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "researcher", + "owner": "51d3ac63-7e34-4aca-b3e4-13381f1dcb76", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11434, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "writer": { + "agent_name": "writer", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "writer", + "owner": "51d3ac63-7e34-4aca-b3e4-13381f1dcb76", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11434, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-92065a52a263a4db", + "owner": "51d3ac63-7e34-4aca-b3e4-13381f1dcb76" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/multiple-providers.tf.json b/crates/openshell-provider/tests/contract/fixtures/multiple-providers.tf.json new file mode 100644 index 00000000000..8115298d865 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/multiple-providers.tf.json @@ -0,0 +1,268 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_hosted-4df6a0a09c020309380f8e47": { + "authenticated": "true", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "https://hosted.example/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-hosted-4df6a0a09c020309380f8e47", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "provider_type": "anthropic", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11434/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_hosted-4df6a0a09c020309380f8e47": { + "credential_env": "HOSTED_API_KEY", + "depends_on": [ + "openshell_provider_profile.inference_hosted-4df6a0a09c020309380f8e47", + "data.openshell_gateway.apply" + ], + "endpoint": "https://hosted.example/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "hosted-4df6a0a09c020309380f8e47", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "provider_type": "anthropic", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11434/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "researcher": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_hosted-4df6a0a09c020309380f8e47", + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "researcher", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-hosted-4df6a0a09c020309380f8e47": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "host": "hosted.example", + "path": "/v1/**", + "port": 443, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-hosted-4df6a0a09c020309380f8e47" + }, + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11434, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "hosted-4df6a0a09c020309380f8e47", + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "writer": { + "agent_name": "writer", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "writer", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11434, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-09fae1b508fa21be", + "owner": "cb18eaf0-1a4e-47b8-b254-6fe4e49bc360" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json b/crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json new file mode 100644 index 00000000000..8bfb388b352 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/multiple-sandboxes.tf.json @@ -0,0 +1,435 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-3d36801b67957c3bcfa1093b": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-3d36801b67957c3bcfa1093b", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-5834fdcc94534d6506776906": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-b95da89e857d01251c2f1583": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-b95da89e857d01251c2f1583", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-3d36801b67957c3bcfa1093b": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-3d36801b67957c3bcfa1093b", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-3d36801b67957c3bcfa1093b", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-5834fdcc94534d6506776906": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-5834fdcc94534d6506776906", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-b95da89e857d01251c2f1583": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-b95da89e857d01251c2f1583", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-b95da89e857d01251c2f1583", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "alice": { + "agent_name": "alice", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "alice", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "bob": { + "agent_name": "bob", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-5834fdcc94534d6506776906", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric-owner-20260924@sha256:c4c0d3add3869e49d0ce8d03bd7e41bbe2682d0df285ef6fde5f181b123cf83e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "bob", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-5834fdcc94534d6506776906": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-5834fdcc94534d6506776906" + } + } + }, + "provider_names": [ + "local-5834fdcc94534d6506776906" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "coding": { + "agent_name": "coder", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-b95da89e857d01251c2f1583", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-multi-models@sha256:2ee5e33522a37d3d77bb6381a92e963cb1d5884f2dd28b353b4b7fa0d95f212e", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "coding", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-b95da89e857d01251c2f1583": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-b95da89e857d01251c2f1583" + } + } + }, + "provider_names": [ + "local-b95da89e857d01251c2f1583" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.langchain.deepagents\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.langchain.deepagents\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "research": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-3d36801b67957c3bcfa1093b", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:a6a0e5cf53501e765ae43457212989ff4716c6224352dc109ebd49c3780450cd", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "research", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-3d36801b67957c3bcfa1093b": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-3d36801b67957c3bcfa1093b" + } + } + }, + "provider_names": [ + "local-3d36801b67957c3bcfa1093b" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.langchain.deepagents\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.langchain.deepagents\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "review": { + "agent_name": "reviewer", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-3d36801b67957c3bcfa1093b", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-prototype-fabric@sha256:a6a0e5cf53501e765ae43457212989ff4716c6224352dc109ebd49c3780450cd", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "review", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-3d36801b67957c3bcfa1093b": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-3d36801b67957c3bcfa1093b" + } + } + }, + "provider_names": [ + "local-3d36801b67957c3bcfa1093b" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.pi\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.pi\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-76305e2f2e19a6b1", + "owner": "d21c8698-2b96-49fd-bb17-570c523960d0" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/openclaw-dashboard.tf.json b/crates/openshell-provider/tests/contract/fixtures/openclaw-dashboard.tf.json new file mode 100644 index 00000000000..691d33c416f --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/openclaw-dashboard.tf.json @@ -0,0 +1,160 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-b2422a7f17e9375479fabdfa": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference.example.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-b2422a7f17e9375479fabdfa", + "owner": "d55b73c4-cdd7-48b4-b883-dd7d0e8d37da", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-b2422a7f17e9375479fabdfa": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-b2422a7f17e9375479fabdfa", + "data.openshell_gateway.apply" + ], + "endpoint": "https://inference.example.com/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-b2422a7f17e9375479fabdfa", + "owner": "d55b73c4-cdd7-48b4-b883-dd7d0e8d37da", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "assistant": { + "agent_name": "main", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-b2422a7f17e9375479fabdfa", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "local-fabric-openclaw@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "assistant", + "owner": "d55b73c4-cdd7-48b4-b883-dd7d0e8d37da", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-b2422a7f17e9375479fabdfa": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "host": "inference.example.com", + "path": "/v1/**", + "port": 443, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-b2422a7f17e9375479fabdfa" + } + } + }, + "provider_names": [ + "local-b2422a7f17e9375479fabdfa" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-0f3f79feaa1978fa", + "owner": "d55b73c4-cdd7-48b4-b883-dd7d0e8d37da" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/openclaw-web-search.tf.json b/crates/openshell-provider/tests/contract/fixtures/openclaw-web-search.tf.json new file mode 100644 index 00000000000..dda91a6788e --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/openclaw-web-search.tf.json @@ -0,0 +1,295 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-d6ca74ad95e4f1d5f302f50e": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_54ddc3957cbfbf3583497dae": { + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-brave-54ddc3957cbfbf3583497dae", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-d6ca74ad95e4f1d5f302f50e": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-d6ca74ad95e4f1d5f302f50e", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-d6ca74ad95e4f1d5f302f50e", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_1626583d632727f0192ac4fc": { + "credential_env": "BRAVE_API_KEY", + "depends_on": [ + "openshell_provider_profile.web_search_54ddc3957cbfbf3583497dae", + "data.openshell_gateway.apply" + ], + "endpoint": "https://api.search.brave.com", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "brave-search-1626583d632727f0192ac4fc", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "profile_name": "nemoclaw-brave-54ddc3957cbfbf3583497dae", + "provider_type": "brave", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "researcher": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-d6ca74ad95e4f1d5f302f50e", + "openshell_provider_registration.web_search_1626583d632727f0192ac4fc", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "researcher", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-brave-54ddc3957cbfbf3583497dae": { + "binaries": [], + "endpoints": [ + { + "enforcement": "enforce", + "host": "api.search.brave.com", + "port": 443, + "protocol": "rest", + "rules": [ + { + "allow": { + "method": "GET", + "path": "/res/v1/web/search" + } + } + ] + } + ], + "name": "nemoclaw-brave-54ddc3957cbfbf3583497dae" + }, + "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e" + } + } + }, + "provider_names": [ + "local-d6ca74ad95e4f1d5f302f50e", + "brave-search-1626583d632727f0192ac4fc" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "writer": { + "agent_name": "writer", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-d6ca74ad95e4f1d5f302f50e", + "openshell_provider_registration.web_search_1626583d632727f0192ac4fc", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "writer", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-brave-54ddc3957cbfbf3583497dae": { + "binaries": [], + "endpoints": [ + { + "enforcement": "enforce", + "host": "api.search.brave.com", + "port": 443, + "protocol": "rest", + "rules": [ + { + "allow": { + "method": "GET", + "path": "/res/v1/web/search" + } + } + ] + } + ], + "name": "nemoclaw-brave-54ddc3957cbfbf3583497dae" + }, + "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e" + } + } + }, + "provider_names": [ + "local-d6ca74ad95e4f1d5f302f50e", + "brave-search-1626583d632727f0192ac4fc" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-b46d12e64864ca9c", + "owner": "3a1c6038-a264-48e1-a2b3-1ed10c9f6919" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/fixtures/tavily-web-search.tf.json b/crates/openshell-provider/tests/contract/fixtures/tavily-web-search.tf.json new file mode 100644 index 00000000000..401cfc27567 --- /dev/null +++ b/crates/openshell-provider/tests/contract/fixtures/tavily-web-search.tf.json @@ -0,0 +1,393 @@ +{ + "data": { + "openshell_gateway": { + "apply": { + "lifecycle": { + "postcondition": [ + { + "condition": "${self.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", self.incompatibility)}" + } + ] + }, + "read_trigger": "${timestamp() != \"\"}", + "required_compute_drivers": [ + "docker" + ] + }, + "current": { + "required_compute_drivers": [ + "docker" + ] + } + } + }, + "provider": { + "openshell": { + "destroy": "${var.destroying}", + "endpoint": "${var.endpoint}" + } + }, + "resource": { + "openshell_provider_profile": { + "inference_local-4dcf1b725a48b148ce57287f": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-4dcf1b725a48b148ce57287f", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-d6ca74ad95e4f1d5f302f50e": { + "authenticated": "false", + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_tavily_54ddc3957cbfbf3583497dae": { + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-tavily-54ddc3957cbfbf3583497dae", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_tavily_71458798e8e4200c96ca9bf4": { + "binaries": [ + "/usr/local/bin/python3.99" + ], + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nemoclaw-tavily-71458798e8e4200c96ca9bf4", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_provider_registration": { + "inference_local-4dcf1b725a48b148ce57287f": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-4dcf1b725a48b148ce57287f", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-4dcf1b725a48b148ce57287f", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "inference_local-d6ca74ad95e4f1d5f302f50e": { + "credential_env": "", + "depends_on": [ + "openshell_provider_profile.inference_local-d6ca74ad95e4f1d5f302f50e", + "data.openshell_gateway.apply" + ], + "endpoint": "http://172.20.0.1:11446/v1", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "local-d6ca74ad95e4f1d5f302f50e", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "provider_type": "", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_tavily_64af2c4d05f99c5a04c99cd4": { + "credential_env": "TAVILY_API_KEY", + "depends_on": [ + "openshell_provider_profile.web_search_tavily_71458798e8e4200c96ca9bf4", + "data.openshell_gateway.apply" + ], + "endpoint": "https://api.tavily.com", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "tavily-search-64af2c4d05f99c5a04c99cd4", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "profile_name": "nemoclaw-tavily-71458798e8e4200c96ca9bf4", + "provider_type": "tavily", + "workspace": "${openshell_workspace.deployment.name}" + }, + "web_search_tavily_b834e6dcc9c43c0d32bd2c2f": { + "credential_env": "TAVILY_API_KEY", + "depends_on": [ + "openshell_provider_profile.web_search_tavily_54ddc3957cbfbf3583497dae", + "data.openshell_gateway.apply" + ], + "endpoint": "https://api.tavily.com", + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "tavily-search-b834e6dcc9c43c0d32bd2c2f", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "profile_name": "nemoclaw-tavily-54ddc3957cbfbf3583497dae", + "provider_type": "tavily", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_sandbox": { + "hermes": { + "agent_name": "hermes", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-4dcf1b725a48b148ce57287f", + "openshell_provider_registration.web_search_tavily_64af2c4d05f99c5a04c99cd4", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "hermes", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-4dcf1b725a48b148ce57287f": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-4dcf1b725a48b148ce57287f" + }, + "nemoclaw-tavily-71458798e8e4200c96ca9bf4": { + "binaries": [], + "endpoints": [ + { + "enforcement": "enforce", + "host": "api.tavily.com", + "port": 443, + "protocol": "rest", + "rules": [ + { + "allow": { + "method": "POST", + "path": "/search" + } + }, + { + "allow": { + "method": "POST", + "path": "/extract" + } + } + ] + } + ], + "name": "nemoclaw-tavily-71458798e8e4200c96ca9bf4" + } + } + }, + "provider_names": [ + "local-4dcf1b725a48b148ce57287f", + "tavily-search-64af2c4d05f99c5a04c99cd4" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.openclaw\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.openclaw\"}", + "workspace": "${openshell_workspace.deployment.name}" + }, + "researcher": { + "agent_name": "researcher", + "agent_runtime": "fabric", + "depends_on": [ + "openshell_provider_registration.inference_local-d6ca74ad95e4f1d5f302f50e", + "openshell_provider_registration.web_search_tavily_b834e6dcc9c43c0d32bd2c2f", + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "image": "nc-fabric@sha256:0000000000000000000000000000000000000000000000000000000000000000", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "researcher", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c", + "policy": { + "explicit": null, + "managed": { + "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e": { + "binaries": [], + "endpoints": [ + { + "access": "full", + "allowed_ips": [ + "172.20.0.1/32" + ], + "host": "172.20.0.1", + "path": "/v1/**", + "port": 11446, + "protocol": "rest" + } + ], + "name": "nemoclaw-inference-local-d6ca74ad95e4f1d5f302f50e" + }, + "nemoclaw-tavily-54ddc3957cbfbf3583497dae": { + "binaries": [], + "endpoints": [ + { + "enforcement": "enforce", + "host": "api.tavily.com", + "port": 443, + "protocol": "rest", + "rules": [ + { + "allow": { + "method": "POST", + "path": "/search" + } + }, + { + "allow": { + "method": "POST", + "path": "/extract" + } + } + ] + } + ], + "name": "nemoclaw-tavily-54ddc3957cbfbf3583497dae" + } + } + }, + "provider_names": [ + "local-d6ca74ad95e4f1d5f302f50e", + "tavily-search-b834e6dcc9c43c0d32bd2c2f" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.hermes\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.hermes\"}", + "workspace": "${openshell_workspace.deployment.name}" + } + }, + "openshell_workspace": { + "deployment": { + "depends_on": [ + "data.openshell_gateway.apply" + ], + "generation": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "lifecycle": { + "precondition": [ + { + "condition": "${data.openshell_gateway.current.compatible}", + "error_message": "${format(\"Gateway is incompatible with this configuration: %s. Retain state, correct the gateway or the configuration, and reapply.\", data.openshell_gateway.current.incompatibility)}" + } + ] + }, + "name": "nc-cfb1ee10cdd2da3c", + "owner": "b126fc24-2c7e-4431-9726-29d2abc8597c" + } + } + }, + "terraform": { + "required_providers": { + "openshell": { + "source": "registry.opentofu.org/nvidia/openshell" + } + }, + "required_version": "= 1.12.6" + }, + "variable": { + "destroying": { + "default": false + }, + "endpoint": { + "type": "string" + } + } +} diff --git a/crates/openshell-provider/tests/contract/main.rs b/crates/openshell-provider/tests/contract/main.rs new file mode 100644 index 00000000000..b30575abd49 --- /dev/null +++ b/crates/openshell-provider/tests/contract/main.rs @@ -0,0 +1,204 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Contract tests: each fixture in `fixtures/` applies through pinned +//! OpenTofu against the fake OpenShell gateway, reads back unchanged, and is +//! removed by destroy. The fixtures are the OpenShell resources the SDK +//! compiles for each example; nemoclaw-e2e regenerates them. + +use nemoclaw_test_fixtures::{openshell::Fixture, tofu::TofuWorkspace}; +use serde_json::Value; +use std::{collections::BTreeSet, fs, path::Path, process::Output}; + +const FIXTURES: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contract/fixtures"); + +fn tofu() -> std::path::PathBuf { + let tofu = std::path::PathBuf::from( + std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit pinned OpenTofu path"), + ); + assert!(tofu.is_absolute()); + tofu +} + +/// The openshell provider built beside NEMOCLAW_TEST_PROVIDER, as the +/// lifecycle tests receive it. +fn provider() -> std::path::PathBuf { + let nemoclaw = std::path::PathBuf::from( + std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit provider build path"), + ); + assert!(nemoclaw.is_absolute()); + nemoclaw + .parent() + .unwrap() + .join(nemoclaw_test_fixtures::executable( + "terraform-provider-openshell", + )) +} + +/// Credential variables the fixture's registrations name, with fixture values. +fn credentials(fixture: &Value) -> BTreeSet { + fixture["resource"]["openshell_provider_registration"] + .as_object() + .into_iter() + .flat_map(|registrations| registrations.values()) + .filter_map(|registration| registration["credential_env"].as_str()) + .filter(|name| !name.is_empty()) + .map(str::to_owned) + .collect() +} + +async fn reads_back_unchanged(name: &str) { + let source = fs::read_to_string(Path::new(FIXTURES).join(format!("{name}.tf.json"))).unwrap(); + let parsed: Value = serde_json::from_str(&source).unwrap(); + let gateway = Fixture::start().await; + // The gateway runs the compute driver the configuration requires. + if let Some(driver) = + parsed["data"]["openshell_gateway"]["current"]["required_compute_drivers"][0].as_str() + { + gateway.state.lock().unwrap().driver = Some(driver.to_owned()); + } + let workspace = TofuWorkspace::with_providers(tofu(), &[("openshell", &provider())]); + fs::write(workspace.path().join("main.tf.json"), &source).unwrap(); + let endpoint = format!("endpoint={}", gateway.endpoint); + let run = |args: &[&str]| -> Output { + let mut command = workspace.command(); + command + .args(args) + .args(["-input=false", "-no-color", "-var"]) + .arg(&endpoint); + for credential in credentials(&parsed) { + command.env(credential, "fixture-credential"); + } + command.output().unwrap() + }; + let success = |args: &[&str]| { + let output = run(args); + assert!( + output.status.success(), + "{name}: {args:?}\n{}", + String::from_utf8_lossy(&output.stderr) + ); + }; + success(&["apply", "-auto-approve"]); + // A managed change on the next plan means the provider read back + // something other than what it wrote. Data sources re-read on purpose. + success(&["plan", "-out=unchanged.plan"]); + let shown = workspace + .command() + .args(["show", "-json", "unchanged.plan"]) + .output() + .unwrap(); + let plan: Value = serde_json::from_slice(&shown.stdout).unwrap(); + for change in plan["resource_changes"].as_array().unwrap() { + if change["mode"] == "managed" { + assert_eq!( + change["change"]["actions"], + serde_json::json!(["no-op"]), + "{name}: {} changes after it was applied", + change["address"] + ); + } + } + // Teardown keeps the retained workspace and removes everything else, as + // the SDK's teardown graph does. + let mut retained = parsed.clone(); + retained["resource"] + .as_object_mut() + .unwrap() + .retain(|kind, _| kind == "openshell_workspace"); + for body in retained["resource"]["openshell_workspace"] + .as_object_mut() + .unwrap() + .values_mut() + { + body.as_object_mut().unwrap().remove("depends_on"); + } + fs::write( + workspace.path().join("main.tf.json"), + serde_json::to_string(&retained).unwrap(), + ) + .unwrap(); + success(&["apply", "-auto-approve", "-var", "destroying=true"]); + let state = gateway.state.lock().unwrap(); + assert!(state.sandboxes.is_empty(), "{name}"); + assert!(state.providers.is_empty(), "{name}"); + assert!(state.profiles.is_empty(), "{name}"); +} + +macro_rules! fixtures { + ($($test:ident => $name:literal,)*) => { + $( + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + #[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake OpenShell gateway"] + async fn $test() { + reads_back_unchanged($name).await; + } + )* + + /// Every fixture file has a test, and every OpenShell type has a fixture. + #[test] + fn every_fixture_runs_and_every_type_is_covered() { + let listed: BTreeSet<&str> = [$($name),*].into(); + let files: BTreeSet = fs::read_dir(FIXTURES) + .unwrap() + .map(|entry| entry.unwrap().file_name().to_string_lossy().into_owned()) + .filter_map(|file| file.strip_suffix(".tf.json").map(str::to_owned)) + .collect(); + assert_eq!( + files.iter().map(String::as_str).collect::>(), + listed + ); + let used: BTreeSet = files + .iter() + .flat_map(|file| { + let fixture: Value = serde_json::from_slice( + &fs::read(Path::new(FIXTURES).join(format!("{file}.tf.json"))).unwrap(), + ) + .unwrap(); + ["resource", "data"] + .into_iter() + .flat_map(|block| { + fixture[block] + .as_object() + .map(|types| types.keys().cloned().collect::>()) + .unwrap_or_default() + }) + .collect::>() + }) + .collect(); + for kind in [ + "openshell_workspace", + "openshell_provider_profile", + "openshell_provider_registration", + "openshell_sandbox", + "openshell_gateway", + ] { + assert!(used.contains(kind), "no fixture uses {kind}"); + } + } + }; +} + +fixtures! { + explicit_policy => "explicit-policy", + fabric => "fabric", + fabric_claude => "fabric-claude", + fabric_codex => "fabric-codex", + fabric_hermes => "fabric-hermes", + fabric_mini_swe_agent => "fabric-mini-swe-agent", + fabric_nooa => "fabric-nooa", + fabric_nooa_bench => "fabric-nooa-bench", + fabric_openclaw => "fabric-openclaw", + fabric_pi => "fabric-pi", + fabric_remote_agent => "fabric-remote-agent", + hermes_auth => "hermes-auth", + hermes_interfaces => "hermes-interfaces", + inference_tuning => "inference-tuning", + inline_inference => "inline-inference", + local => "local", + multiple_models => "multiple-models", + multiple_providers => "multiple-providers", + multiple_sandboxes => "multiple-sandboxes", + openclaw_dashboard => "openclaw-dashboard", + openclaw_web_search => "openclaw-web-search", + tavily_web_search => "tavily-web-search", +} diff --git a/docs/contributing/integration-tests.md b/docs/contributing/integration-tests.md index ece8ed77052..b8bd2fa0446 100644 --- a/docs/contributing/integration-tests.md +++ b/docs/contributing/integration-tests.md @@ -82,6 +82,20 @@ The export fixture checks provider refresh failures through OpenTofu, unchanged The web-search lifecycle case covers Brave and Tavily at deployment, sandbox, and agent scope, including profile and sandbox-grant drift. The mixed-search export case checks shared registrations, unused definitions, export without search keys, unchanged reapply, and rejected provider-type or credential-reference drift without changes to saved state. +## OpenShell Provider Contract + +The `openshell-provider` crate's `contract` tests apply each fixture in `crates/openshell-provider/tests/contract/fixtures` through OpenTofu against a fake OpenShell gateway from `nemoclaw-test-fixtures`. +Each fixture must plan no managed changes after it is applied, and teardown must remove every sandbox, provider registration, and profile while the gateway keeps the workspace: + +```sh +NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ +NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ + cargo test -p openshell-provider --test contract -- --ignored +``` + +The fixtures are the OpenShell resources the SDK compiles for each example with an external gateway, excluding examples whose credentials are read from a managed service's container. +`nemoclaw-e2e`'s `openshell_contract_fixtures` test fails when they differ from what the SDK compiles; regenerate them with `NEMOCLAW_REGENERATE_FIXTURES=1 cargo test -p nemoclaw-e2e --test integration openshell_contract_fixtures`. + ## Standalone Sandbox Completion On Unix, build the production provider and supply the explicit OpenTofu and provider paths as above. From b96fce9b67244047c62d3838c18cf217e5d17f7e Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 05:07:45 -0700 Subject: [PATCH 15/18] test(openshell): move OpenShell OpenTofu tests into the provider's contract tests opentofu_openshell and standalone_openshell in nemoclaw-e2e exercised only the openshell provider, but generated their configuration with the SDK and ran beside the system scenarios. - The standalone tests now apply a static authored configuration from tests/contract/standalone; only the Pi configuration test, which also needs the fabric provider, stays in nemoclaw-e2e as standalone_pi until the fabric provider has contract tests. - Gateway capability tests use the local example's contract fixture instead of compiling the reference graph: an incompatible gateway and a failed read stop planning, a failed object read stops the next plan, and a saved plan observes the gateway again, all without changing the gateway or managed state. Teardown is covered by every fixture. - The client-level capability observation test and the bootstrap dependency test move unchanged. Part of #12880. --- .config/nextest.toml | 2 +- crates/nemoclaw-e2e/tests/main.rs | 4 +- .../nemoclaw-e2e/tests/opentofu_openshell.rs | 317 ------------------ crates/nemoclaw-e2e/tests/standalone_pi.rs | 239 +++++++++++++ .../tests/contract/capabilities.rs | 274 +++++++++++++++ .../openshell-provider/tests/contract/main.rs | 3 + .../tests/contract/standalone.rs} | 205 ++--------- .../tests/contract/standalone/main.tf | 67 ++++ .../contract/standalone/terraform.tfvars.json | 6 + docs/contributing/integration-tests.md | 11 +- docs/provider.md | 2 +- 11 files changed, 619 insertions(+), 511 deletions(-) delete mode 100644 crates/nemoclaw-e2e/tests/opentofu_openshell.rs create mode 100644 crates/nemoclaw-e2e/tests/standalone_pi.rs create mode 100644 crates/openshell-provider/tests/contract/capabilities.rs rename crates/{nemoclaw-e2e/tests/fixtures/standalone_openshell.rs => openshell-provider/tests/contract/standalone.rs} (82%) create mode 100644 crates/openshell-provider/tests/contract/standalone/main.tf create mode 100644 crates/openshell-provider/tests/contract/standalone/terraform.tfvars.json diff --git a/.config/nextest.toml b/.config/nextest.toml index 5c502218616..8c245a43004 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -25,7 +25,7 @@ test(native_state_json_preserves_module_and_instance_identity_without_refresh) | (package(openshell-provider) & binary(=contract)) | (package(nemoclaw-e2e) & binary(=integration) & ( test(/^provider_protocol::/) | test(/^service_capacity::/) | test(/^service_readiness::/) - | test(/^sandbox_readiness::/) | test(/^opentofu_openshell::/) | test(/^deployment::/) + | test(/^sandbox_readiness::/) | test(/^standalone_pi::/) | test(/^deployment::/) | test(/^service_storage::/) | test(/^vllm_runtime::/) | test(/^kubernetes_hcl::/) | test(/^runtime_image::/) | test(/^export_observations::/) | test(/^fabric_deployment::/) diff --git a/crates/nemoclaw-e2e/tests/main.rs b/crates/nemoclaw-e2e/tests/main.rs index 9bd14c93632..ddcf47947e7 100644 --- a/crates/nemoclaw-e2e/tests/main.rs +++ b/crates/nemoclaw-e2e/tests/main.rs @@ -41,8 +41,6 @@ mod multiple_providers; mod openshell; #[path = "openshell_contract_fixtures.rs"] mod openshell_contract_fixtures; -#[path = "opentofu_openshell.rs"] -mod opentofu_openshell; #[path = "provider_protocol.rs"] mod provider_protocol; #[path = "remote_service.rs"] @@ -56,6 +54,8 @@ mod sandbox_readiness; mod service_capacity; #[path = "service_readiness.rs"] mod service_readiness; +#[path = "standalone_pi.rs"] +mod standalone_pi; // The fixture engine listens on a Unix socket. #[cfg(unix)] #[path = "service_storage.rs"] diff --git a/crates/nemoclaw-e2e/tests/opentofu_openshell.rs b/crates/nemoclaw-e2e/tests/opentofu_openshell.rs deleted file mode 100644 index c4b49cfd755..00000000000 --- a/crates/nemoclaw-e2e/tests/opentofu_openshell.rs +++ /dev/null @@ -1,317 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#[cfg(unix)] -use nemoclaw_e2e::assert_same_managed_resources; -use nemoclaw_e2e::openshell::Fixture; -use nemoclaw_e2e::tofu::TofuWorkspace; -use nemoclaw_provider::openshell::{EnvironmentSecrets, OpenShell}; -#[cfg(unix)] -use nemoclaw_sdk::{ - compile::{Generations, compile}, - config::Document, -}; -use serde_json::{Value, json}; -use std::{fs, path::PathBuf, process::Output}; - -// Compiled deployment planning requires a currently Unix-only image engine. -#[cfg(unix)] -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER"] -async fn production_provider_applies_refreshes_and_destroys_the_reference_graph() { - let fixture = Fixture::start().await; - let tofu = PathBuf::from( - std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit pinned OpenTofu path"), - ); - let provider = PathBuf::from( - std::env::var_os("NEMOCLAW_TEST_PROVIDER") - .expect("explicit built production provider path"), - ); - assert!(tofu.is_absolute() && provider.is_absolute()); - let directory = TofuWorkspace::new(tofu, provider); - let mut document = Document::parse( - include_str!("../../nemoclaw-sdk/tests/fixtures/config/local.yaml").as_bytes(), - ) - .unwrap(); - *document.spec.gateway.endpoint_mut() = fixture.endpoint.clone(); - let _image_engine = nemoclaw_e2e::image_runtime::engine(&mut document).await; - let generations: Generations = ["workspace", "provider", "sandbox"] - .into_iter() - .map(|k| (k.into(), format!("{k}-generation"))) - .collect(); - let mut graph = compile(&document, &generations, "0.1.0").unwrap(); - fs::write(directory.path().join("main.tf.json"), graph.to_string()).unwrap(); - let run = |args: &[&str]| -> Output { directory.command().args(args).output().unwrap() }; - let success = |args: &[&str]| -> Output { - let output = run(args); - assert!( - output.status.success(), - "{}\n{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); - output - }; - let versions: Value = serde_json::from_str(include_str!("../../../versions.json")).unwrap(); - let version = versions["openshell"].as_str().unwrap(); - // nemoclaw-openshell's observation tests own each incompatibility reason; - // OpenTofu must surface one precondition failure and one failed read. - for failure in ["version", "unavailable"] { - { - let mut state = fixture.state.lock().unwrap(); - if failure == "version" { - state.gateway_info = Some(openshell_core::proto::GetGatewayInfoResponse { - gateway_version: "incompatible-version".into(), - compute_drivers: vec![openshell_core::proto::ComputeDriverInfo { - name: "docker".into(), - ..Default::default() - }], - ..Default::default() - }); - } else { - state.fail_read = Some(("gateway", tonic::Code::Unavailable)); - } - } - let output = run(&["plan", "-input=false", "-no-color"]); - assert!(!output.status.success(), "{failure} gateway was accepted"); - let diagnostic = String::from_utf8_lossy(&output.stderr); - if failure == "version" { - assert!( - diagnostic.contains("Resource precondition failed"), - "{diagnostic}" - ); - let normalized = diagnostic.split_whitespace().collect::>().join(" "); - let expected = format!( - "Gateway is incompatible with this configuration: gateway runs OpenShell \ - incompatible-version, but this build requires {version}." - ); - assert!( - normalized.contains(&expected), - "missing {expected}: {diagnostic}" - ); - } else { - assert!( - diagnostic.contains("Gateway capability observation failed"), - "{diagnostic}" - ); - } - assert!(!diagnostic.contains("secret-sentinel")); - let mut state = fixture.state.lock().unwrap(); - assert_eq!( - state.effects, 0, - "failed capability check mutated the gateway" - ); - state.gateway_info = None; - state.driver = None; - state.fail_read = None; - } - success(&["apply", "-auto-approve", "-input=false", "-no-color"]); - let before = fs::read(directory.path().join("terraform.tfstate")).unwrap(); - let effects = fixture.state.lock().unwrap().effects; - success(&["plan", "-input=false", "-out=plan", "-no-color"]); - let plan: Value = serde_json::from_slice(&success(&["show", "-json", "plan"]).stdout).unwrap(); - for change in plan["resource_changes"].as_array().unwrap() { - if change["mode"] != "data" { - assert_eq!(change["change"]["actions"], json!(["no-op"])); - } - } - assert_eq!(fixture.state.lock().unwrap().effects, effects); - fixture.state.lock().unwrap().driver = Some("podman".into()); - assert!(!run(&["plan", "-input=false", "-no-color"]).status.success()); - assert_eq!( - fs::read(directory.path().join("terraform.tfstate")).unwrap(), - before - ); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - fixture.state.lock().unwrap().driver = None; - fixture.state.lock().unwrap().fail_read = Some(("provider", tonic::Code::Unavailable)); - assert!(!run(&["plan", "-input=false", "-no-color"]).status.success()); - assert_eq!( - fs::read(directory.path().join("terraform.tfstate")).unwrap(), - before - ); - fixture.state.lock().unwrap().fail_read = None; - // A saved plan must re-observe compatibility during apply, even when - // every managed resource is unchanged. No SDK coordinator runs here. - // Each failure kind runs once, unchanged and when creating. - for (create, failure) in [(false, "driver"), (true, "unavailable")] { - if create { - let mut sandbox = document.spec.sandboxes[0].clone(); - sandbox.name = format!("extra-{failure}"); - document.spec.sandboxes.push(sandbox); - graph = compile(&document, &generations, "0.1.0").unwrap(); - fs::write(directory.path().join("main.tf.json"), graph.to_string()).unwrap(); - } - success(&["plan", "-input=false", "-out=fresh.plan", "-no-color"]); - let before = fs::read(directory.path().join("terraform.tfstate")).unwrap(); - let effects = fixture.state.lock().unwrap().effects; - { - let mut state = fixture.state.lock().unwrap(); - if failure == "driver" { - state.driver = Some("podman".into()); - } else { - state.fail_read = Some(("gateway", tonic::Code::Unavailable)); - } - } - let output = run(&["apply", "-input=false", "-no-color", "fresh.plan"]); - assert!( - !output.status.success(), - "saved plan reused stale gateway metadata: create={create}, {failure}" - ); - let diagnostic = String::from_utf8_lossy(&output.stderr); - let normalized = diagnostic.split_whitespace().collect::>().join(" "); - assert!( - normalized.contains(if failure == "driver" { - "Gateway is incompatible with this configuration: gateway compute driver is \ - podman, but spec.gateway.runtime.provider is docker." - } else { - "Gateway capability observation failed" - }), - "{diagnostic}" - ); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - assert_same_managed_resources( - &fs::read(directory.path().join("terraform.tfstate")).unwrap(), - &before, - ); - { - let mut state = fixture.state.lock().unwrap(); - state.driver = None; - state.fail_read = None; - } - success(&["apply", "-auto-approve", "-input=false", "-no-color"]); - assert_eq!( - fixture.state.lock().unwrap().sandboxes.len(), - document.spec.sandboxes.len() - ); - } - - for provider in ["nemoclaw", "openshell", "fabric"] { - graph["provider"][provider]["destroy"] = json!(true); - } - graph.as_object_mut().unwrap().remove("data"); - graph.as_object_mut().unwrap().remove("output"); - graph["resource"]["openshell_workspace"]["deployment"] - .as_object_mut() - .unwrap() - .remove("depends_on"); - graph["resource"]["openshell_workspace"]["deployment"]["lifecycle"] = - json!({"prevent_destroy":true}); - for kind in [ - "fabric_agent_configuration", - "openshell_sandbox", - "openshell_provider_profile", - "openshell_provider_registration", - ] { - graph["resource"].as_object_mut().unwrap().remove(kind); - } - fs::write(directory.path().join("main.tf.json"), graph.to_string()).unwrap(); - success(&["apply", "-auto-approve", "-input=false", "-no-color"]); - let state = fixture.state.lock().unwrap(); - assert!(state.sandboxes.is_empty() && state.providers.is_empty() && state.profiles.is_empty()); - assert_eq!(state.workspaces.len(), 1); -} - -#[tokio::test] -async fn gateway_capability_observations_preserve_metadata_and_fail_closed_without_mutations() { - use nemoclaw_sdk::{ObservationError, config::Gateway}; - let fixture = Fixture::start().await; - let client = OpenShell::connect( - &Gateway::External(nemoclaw_sdk::config::ExternalGateway { - endpoint: fixture.endpoint.clone(), - ..Default::default() - }) - .connection(), - std::sync::Arc::new(EnvironmentSecrets), - ) - .unwrap(); - assert!( - client - .gateway_capabilities() - .await - .unwrap() - .supports("docker") - ); - fixture.state.lock().unwrap().driver = Some("podman".into()); - let observed = client.gateway_capabilities().await.unwrap(); - assert!(observed.supports("podman") && !observed.supports("docker")); - for (code, expected) in [ - ( - tonic::Code::Unauthenticated, - ObservationError::Authentication, - ), - (tonic::Code::PermissionDenied, ObservationError::Permission), - (tonic::Code::Unavailable, ObservationError::Transport), - (tonic::Code::NotFound, ObservationError::Query), - ] { - fixture.state.lock().unwrap().fail_read = Some(("gateway", code)); - assert_eq!(client.gateway_capabilities().await.unwrap_err(), expected); - } - fixture.state.lock().unwrap().fail_read = None; - fixture.state.lock().unwrap().gateway_info = Some(Default::default()); - assert_eq!( - client.gateway_capabilities().await.unwrap_err(), - ObservationError::Incomplete - ); - assert_eq!(fixture.state.lock().unwrap().effects, 0); -} - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER"] -async fn gateway_capability_reads_wait_for_unknown_bootstrap_dependencies() { - let fixture = Fixture::start().await; - fixture.state.lock().unwrap().fail_read = Some(("gateway", tonic::Code::Unavailable)); - let tofu = PathBuf::from( - std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit pinned OpenTofu path"), - ); - let provider = PathBuf::from( - std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit production provider path"), - ); - assert!(tofu.is_absolute() && provider.is_absolute()); - let directory = TofuWorkspace::new(tofu, provider); - fs::write(directory.path().join("main.tf.json"), json!({ - "terraform":{"required_version":"= 1.12.6", "required_providers":{"openshell":{"source":"registry.opentofu.org/nvidia/openshell"}}}, - "provider":{"openshell":{"endpoint":fixture.endpoint}}, - "resource":{"terraform_data":{"bootstrap":{"input":"docker"}}}, - "data":{"openshell_gateway":{"current":{ - "required_compute_drivers":["${terraform_data.bootstrap.output}"], - "lifecycle":{"postcondition":[{"condition":"${self.compatible}", "error_message":"Gateway is incompatible."}]} - }}}, - "output":{"compatible":{"value":"${data.openshell_gateway.current.compatible}"}} - }).to_string()).unwrap(); - let run = |args: &[&str]| { - let output = directory.command().args(args).output().unwrap(); - assert!( - output.status.success(), - "{}\n{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); - output - }; - run(&["validate", "-no-color"]); - run(&["plan", "-input=false", "-out=bootstrap.plan", "-no-color"]); - assert_eq!( - fixture.state.lock().unwrap().gateway_reads, - 0, - "unknown inputs contacted the gateway" - ); - let plan: Value = - serde_json::from_slice(&run(&["show", "-json", "bootstrap.plan"]).stdout).unwrap(); - assert!( - plan["resource_changes"].as_array().unwrap().iter().any( - |change| change["mode"] == "data" && change["change"]["actions"] == json!(["read"]) - ) - ); - fixture.state.lock().unwrap().fail_read = None; - run(&["apply", "-input=false", "-no-color", "bootstrap.plan"]); - let state: Value = - serde_json::from_slice(&fs::read(directory.path().join("terraform.tfstate")).unwrap()) - .unwrap(); - assert_eq!(state["outputs"]["compatible"]["value"], true); - assert!(fixture.state.lock().unwrap().gateway_reads > 0); - assert_eq!(fixture.state.lock().unwrap().effects, 0); -} - -#[path = "fixtures/standalone_openshell.rs"] -mod standalone; diff --git a/crates/nemoclaw-e2e/tests/standalone_pi.rs b/crates/nemoclaw-e2e/tests/standalone_pi.rs new file mode 100644 index 00000000000..3e046f1b060 --- /dev/null +++ b/crates/nemoclaw-e2e/tests/standalone_pi.rs @@ -0,0 +1,239 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Pi configuration through the openshell and fabric providers together. +//! The fabric provider's contract tests will own this. + +use nemoclaw_e2e::tofu::TofuWorkspace; +use nemoclaw_test_fixtures::openshell::Fixture; +use serde_json::{Value, json}; +use std::{fs, path::PathBuf, process::Output}; + +struct Standalone { + root: TofuWorkspace, +} +impl Standalone { + fn new(endpoint: &str) -> Self { + let tofu = + PathBuf::from(std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit OpenTofu")); + let provider = + PathBuf::from(std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit provider")); + assert!(tofu.is_absolute() && provider.is_absolute()); + let root = TofuWorkspace::new(tofu, provider); + let runtime = nemoclaw_e2e::image_runtime::binding("nvidia.fabric.pi"); + let mut document = nemoclaw_sdk::config::Document::parse( + include_str!("../../nemoclaw-sdk/tests/fixtures/config/local.yaml").as_bytes(), + ) + .unwrap(); + document.spec.inference_providers[0].endpoint = "http://127.0.0.1:11434/v1".into(); + let policy = + nemoclaw_sdk::image_runtime::policy_input(&document, &document.spec.sandboxes[0]) + .unwrap(); + // Write the policy as an author would: a typed block, not JSON. + let input = nemoclaw_openshell::structured_inputs("sandbox") + .into_iter() + .find(|input| input.attribute == "policy") + .unwrap(); + let nemoclaw_tofu::shape::Shape::Object(fields) = &input.shape else { + unreachable!("the policy is a block") + }; + let policy = input + .configuration(&serde_json::to_string(&policy).unwrap()) + .unwrap(); + fs::write( + root.path().join("main.tf"), + include_str!("fixtures/openshell_resources.tf").replace( + "@POLICY@\n", + &nemoclaw_e2e::hcl::block("policy", fields, &policy, 2), + ), + ) + .unwrap(); + fs::write( + root.path().join("terraform.tfvars.json"), + json!({ + "endpoint": endpoint, + "runtime_json": serde_json::to_string(&runtime).unwrap(), + "binaries": runtime.binaries(), + }) + .to_string(), + ) + .unwrap(); + Self { root } + } + fn run(&self, args: &[&str], success: bool) -> Output { + let output = self + .root + .command() + .args(args) + .arg("-no-color") + .env("NEMOCLAW_TEST_REGISTRATION_KEY", "fixture-secret") + .env("NEMOCLAW_TEST_ROTATED_KEY", "rotated-fixture-secret") + .output() + .unwrap(); + assert_eq!( + output.status.success(), + success, + "{args:?}\n{}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + output + } + fn state(&self) -> Vec { + fs::read(self.root.path().join("terraform.tfstate")).unwrap() + } + fn apply(&self) { + self.run(&["apply", "-auto-approve", "-input=false"], true); + } + fn noop(&self) { + self.run(&["plan", "-input=false", "-out=noop.plan"], true); + let output = self.run(&["show", "-json", "noop.plan"], true); + let plan: Value = serde_json::from_slice(&output.stdout).unwrap(); + for change in plan["resource_changes"].as_array().unwrap() { + assert_eq!(change["change"]["actions"], json!(["no-op"])); + } + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; isolated Pi fixture"] +async fn standalone_pi_configuration_updates_without_replacing_the_sandbox() { + let fixture = Fixture::start().await; + let tofu = Standalone::new(&fixture.endpoint); + let source = fs::read_to_string(tofu.root.path().join("main.tf")).unwrap(); + fs::write( + tofu.root.path().join("main.tf"), + source + + r#" +variable "model" { default = "first-model" } +resource "fabric_agent_configuration" "agent" { + count = var.enabled ? 1 : 0 + workspace = openshell_sandbox.agent[0].workspace + name = openshell_sandbox.agent[0].name + owner = openshell_sandbox.agent[0].owner + generation = openshell_sandbox.agent[0].generation + sandbox_id = openshell_sandbox.agent[0].id + config_json = jsonencode({ schema_version = "fabric.agent/v1alpha1", runtime = {}, metadata = { name = "assistant" }, harness = { adapter_id = "nvidia.fabric.pi" }, models = { default = { provider = "openai", model = var.model } } }) +} +"#, + ) + .unwrap(); + tofu.run(&["plan", "-input=false"], true); + assert!(fixture.state.lock().unwrap().exec_calls.is_empty()); + tofu.apply(); + let effects = fixture.state.lock().unwrap().effects; + let writes = || { + fixture + .state + .lock() + .unwrap() + .exec_calls + .iter() + .filter(|command| { + command + .get(1) + .is_some_and(|arg| arg == "configure" || arg == "prepare") + }) + .count() + }; + assert_eq!(writes(), 1); + tofu.noop(); + assert_eq!(writes(), 1, "no-op must not reconfigure Pi"); + tofu.run( + &[ + "plan", + "-input=false", + "-var=model=second-model", + "-out=change.plan", + ], + true, + ); + assert_eq!(writes(), 1, "plan must not configure Pi"); + tofu.run(&["apply", "-input=false", "change.plan"], true); + assert_eq!(writes(), 2); + assert_eq!(fixture.state.lock().unwrap().effects, effects); + // A stopped host is observed as drift; explicit apply reconfigures it. + let sandbox_id = fixture + .state + .lock() + .unwrap() + .sandboxes + .values() + .next() + .unwrap() + .metadata + .as_ref() + .unwrap() + .id + .clone(); + fixture + .state + .lock() + .unwrap() + .fabric_stopped + .insert(sandbox_id.clone()); + tofu.run( + &[ + "apply", + "-auto-approve", + "-input=false", + "-var=model=second-model", + ], + true, + ); + assert_eq!(writes(), 3); + assert!( + !fixture + .state + .lock() + .unwrap() + .fabric_stopped + .contains(&sandbox_id) + ); + // Lose the exec response after the host accepted a configuration. Never + // retry the mutation automatically; the next refresh observes the outcome. + tofu.run( + &[ + "plan", + "-input=false", + "-var=model=third-model", + "-out=ambiguous.plan", + ], + true, + ); + fixture.state.lock().unwrap().lose_configure_reply = true; + tofu.run(&["apply", "-input=false", "ambiguous.plan"], false); + assert_eq!(writes(), 4); + assert!(!fixture.state.lock().unwrap().lose_configure_reply); + tofu.run( + &[ + "apply", + "-auto-approve", + "-input=false", + "-var=model=third-model", + ], + true, + ); + assert_eq!( + writes(), + 4, + "confirmed configuration must not be written again" + ); + let prior = tofu.state(); + fixture.state.lock().unwrap().exec_truncated = true; + tofu.run(&["plan", "-input=false", "-var=model=second-model"], false); + assert_eq!(tofu.state(), prior); + assert_eq!(writes(), 4); + assert!(!fixture.state.lock().unwrap().lose_configure_reply); + tofu.run( + &[ + "apply", + "-auto-approve", + "-input=false", + "-var=enabled=false", + "-var=destroying=true", + ], + true, + ); + assert!(fixture.state.lock().unwrap().sandboxes.is_empty()); + assert_eq!(writes(), 4, "destroy must not reconfigure Pi"); +} diff --git a/crates/openshell-provider/tests/contract/capabilities.rs b/crates/openshell-provider/tests/contract/capabilities.rs new file mode 100644 index 00000000000..f13186330f4 --- /dev/null +++ b/crates/openshell-provider/tests/contract/capabilities.rs @@ -0,0 +1,274 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Gateway capability observations, and their preconditions through OpenTofu. + +use super::*; +use nemoclaw_backend::ObservationError; +use openshell_provider::{EnvironmentSecrets, OpenShell}; +use serde_json::json; +use std::process::Output; + +/// The local example's OpenShell resources, applied by one workspace. +struct Local { + workspace: TofuWorkspace, + endpoint: String, +} +impl Local { + fn new(endpoint: &str) -> Self { + let workspace = TofuWorkspace::with_providers(tofu(), &[("openshell", &provider())]); + fs::copy( + Path::new(FIXTURES).join("local.tf.json"), + workspace.path().join("main.tf.json"), + ) + .unwrap(); + Self { + workspace, + endpoint: format!("endpoint={endpoint}"), + } + } + fn run(&self, args: &[&str]) -> Output { + self.workspace + .command() + .args(args) + .args(["-input=false", "-no-color", "-var"]) + .arg(&self.endpoint) + .output() + .unwrap() + } + fn success(&self, args: &[&str]) -> Output { + let output = self.run(args); + assert!( + output.status.success(), + "{args:?}\n{}", + String::from_utf8_lossy(&output.stderr) + ); + output + } + /// Managed resources in state; data sources re-read on every plan. + fn state(&self) -> Value { + let state: Value = fs::read(self.workspace.path().join("terraform.tfstate")) + .ok() + .and_then(|bytes| serde_json::from_slice(&bytes).ok()) + .unwrap_or_default(); + Value::Array( + state["resources"] + .as_array() + .into_iter() + .flatten() + .filter(|resource| resource["mode"] == "managed") + .cloned() + .collect(), + ) + } + /// Declare a second sandbox like the first, so the next plan creates it. + fn add_sandbox(&self) { + let path = self.workspace.path().join("main.tf.json"); + let mut config: Value = serde_json::from_slice(&fs::read(&path).unwrap()).unwrap(); + let sandboxes = config["resource"]["openshell_sandbox"] + .as_object_mut() + .unwrap(); + let mut extra = sandboxes.values().next().unwrap().clone(); + extra["name"] = json!("extra"); + sandboxes.insert("extra".into(), extra); + fs::write(path, config.to_string()).unwrap(); + } +} + +/// An incompatible gateway fails its precondition, a failed read fails the +/// plan, and a saved plan observes the gateway again when applied, all +/// without changing the gateway or state. nemoclaw-openshell's observation +/// tests own each incompatibility reason. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake OpenShell gateway"] +async fn gateway_capabilities_gate_plans_and_saved_plan_applies() { + let gateway = Fixture::start().await; + let local = Local::new(&gateway.endpoint); + let versions: Value = serde_json::from_str(include_str!("../../../../versions.json")).unwrap(); + let version = versions["openshell"].as_str().unwrap(); + for failure in ["version", "unavailable"] { + { + let mut state = gateway.state.lock().unwrap(); + if failure == "version" { + state.gateway_info = Some(openshell_core::proto::GetGatewayInfoResponse { + gateway_version: "incompatible-version".into(), + compute_drivers: vec![openshell_core::proto::ComputeDriverInfo { + name: "docker".into(), + ..Default::default() + }], + ..Default::default() + }); + } else { + state.fail_read = Some(("gateway", tonic::Code::Unavailable)); + } + } + let output = local.run(&["plan"]); + assert!(!output.status.success(), "{failure} gateway was accepted"); + let diagnostic = String::from_utf8_lossy(&output.stderr); + let normalized = diagnostic.split_whitespace().collect::>().join(" "); + let expected = if failure == "version" { + format!( + "Gateway is incompatible with this configuration: gateway runs OpenShell \ + incompatible-version, but this build requires {version}." + ) + } else { + "Gateway capability observation failed".to_owned() + }; + assert!(normalized.contains(&expected), "{diagnostic}"); + assert!(!diagnostic.contains("fixture-secret")); + assert_eq!(gateway.state.lock().unwrap().effects, 0); + let mut state = gateway.state.lock().unwrap(); + state.gateway_info = None; + state.fail_read = None; + } + + // After apply, an incompatible gateway or a failed object read stops the + // next plan without changing state. + local.success(&["apply", "-auto-approve"]); + let applied = local.state(); + let effects = gateway.state.lock().unwrap().effects; + gateway.state.lock().unwrap().driver = Some("podman".into()); + assert!(!local.run(&["plan"]).status.success()); + gateway.state.lock().unwrap().driver = None; + gateway.state.lock().unwrap().fail_read = Some(("provider", tonic::Code::Unavailable)); + assert!(!local.run(&["plan"]).status.success()); + gateway.state.lock().unwrap().fail_read = None; + assert!(local.state() == applied, "a failed plan changed state"); + assert_eq!(gateway.state.lock().unwrap().effects, effects); + + // A saved plan observes the gateway again when applied: a driver change + // for an unchanged plan, and a failed read while creating. + for (create, failure) in [(false, "driver"), (true, "unavailable")] { + if create { + local.add_sandbox(); + } + local.success(&["plan", "-out=fresh.plan"]); + let effects = gateway.state.lock().unwrap().effects; + let before = local.state(); + { + let mut state = gateway.state.lock().unwrap(); + if failure == "driver" { + state.driver = Some("podman".into()); + } else { + state.fail_read = Some(("gateway", tonic::Code::Unavailable)); + } + } + let output = local + .workspace + .command() + .args(["apply", "-input=false", "-no-color", "fresh.plan"]) + .output() + .unwrap(); + assert!( + !output.status.success(), + "saved plan reused stale gateway metadata: create={create}, {failure}" + ); + let diagnostic = String::from_utf8_lossy(&output.stderr); + let normalized = diagnostic.split_whitespace().collect::>().join(" "); + assert!( + normalized.contains(if failure == "driver" { + "Gateway is incompatible with this configuration: gateway compute driver is \ + podman, but spec.gateway.runtime.provider is docker." + } else { + "Gateway capability observation failed" + }), + "{diagnostic}" + ); + assert_eq!(gateway.state.lock().unwrap().effects, effects); + assert!(local.state() == before, "a failed saved plan changed state"); + let mut state = gateway.state.lock().unwrap(); + state.driver = None; + state.fail_read = None; + } +} + +#[tokio::test] +async fn gateway_capability_observations_preserve_metadata_and_fail_closed_without_mutations() { + let gateway = Fixture::start().await; + let client = OpenShell::connect( + &nemoclaw_openshell::Connection { + endpoint: gateway.endpoint.clone(), + ..Default::default() + }, + std::sync::Arc::new(EnvironmentSecrets), + ) + .unwrap(); + assert!( + client + .gateway_capabilities() + .await + .unwrap() + .supports("docker") + ); + gateway.state.lock().unwrap().driver = Some("podman".into()); + let observed = client.gateway_capabilities().await.unwrap(); + assert!(observed.supports("podman") && !observed.supports("docker")); + for (code, expected) in [ + ( + tonic::Code::Unauthenticated, + ObservationError::Authentication, + ), + (tonic::Code::PermissionDenied, ObservationError::Permission), + (tonic::Code::Unavailable, ObservationError::Transport), + (tonic::Code::NotFound, ObservationError::Query), + ] { + gateway.state.lock().unwrap().fail_read = Some(("gateway", code)); + assert_eq!(client.gateway_capabilities().await.unwrap_err(), expected); + } + gateway.state.lock().unwrap().fail_read = None; + gateway.state.lock().unwrap().gateway_info = Some(Default::default()); + assert_eq!( + client.gateway_capabilities().await.unwrap_err(), + ObservationError::Incomplete + ); + assert_eq!(gateway.state.lock().unwrap().effects, 0); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake OpenShell gateway"] +async fn gateway_capability_reads_wait_for_unknown_bootstrap_dependencies() { + let gateway = Fixture::start().await; + gateway.state.lock().unwrap().fail_read = Some(("gateway", tonic::Code::Unavailable)); + let directory = TofuWorkspace::with_providers(tofu(), &[("openshell", &provider())]); + fs::write(directory.path().join("main.tf.json"), json!({ + "terraform":{"required_version":"= 1.12.6", "required_providers":{"openshell":{"source":"registry.opentofu.org/nvidia/openshell"}}}, + "provider":{"openshell":{"endpoint":gateway.endpoint}}, + "resource":{"terraform_data":{"bootstrap":{"input":"docker"}}}, + "data":{"openshell_gateway":{"current":{ + "required_compute_drivers":["${terraform_data.bootstrap.output}"], + "lifecycle":{"postcondition":[{"condition":"${self.compatible}", "error_message":"Gateway is incompatible."}]} + }}}, + "output":{"compatible":{"value":"${data.openshell_gateway.current.compatible}"}} + }).to_string()).unwrap(); + let run = |args: &[&str]| { + let output = directory.command().args(args).output().unwrap(); + assert!( + output.status.success(), + "{}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + output + }; + run(&["validate", "-no-color"]); + run(&["plan", "-input=false", "-out=bootstrap.plan", "-no-color"]); + assert_eq!( + gateway.state.lock().unwrap().gateway_reads, + 0, + "unknown inputs contacted the gateway" + ); + let plan: Value = + serde_json::from_slice(&run(&["show", "-json", "bootstrap.plan"]).stdout).unwrap(); + assert!( + plan["resource_changes"].as_array().unwrap().iter().any( + |change| change["mode"] == "data" && change["change"]["actions"] == json!(["read"]) + ) + ); + gateway.state.lock().unwrap().fail_read = None; + run(&["apply", "-input=false", "-no-color", "bootstrap.plan"]); + let state: Value = + serde_json::from_slice(&fs::read(directory.path().join("terraform.tfstate")).unwrap()) + .unwrap(); + assert_eq!(state["outputs"]["compatible"]["value"], true); + assert!(gateway.state.lock().unwrap().gateway_reads > 0); + assert_eq!(gateway.state.lock().unwrap().effects, 0); +} diff --git a/crates/openshell-provider/tests/contract/main.rs b/crates/openshell-provider/tests/contract/main.rs index b30575abd49..72a88b3ce9f 100644 --- a/crates/openshell-provider/tests/contract/main.rs +++ b/crates/openshell-provider/tests/contract/main.rs @@ -9,6 +9,9 @@ use nemoclaw_test_fixtures::{openshell::Fixture, tofu::TofuWorkspace}; use serde_json::Value; use std::{collections::BTreeSet, fs, path::Path, process::Output}; +mod capabilities; +mod standalone; + const FIXTURES: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contract/fixtures"); fn tofu() -> std::path::PathBuf { diff --git a/crates/nemoclaw-e2e/tests/fixtures/standalone_openshell.rs b/crates/openshell-provider/tests/contract/standalone.rs similarity index 82% rename from crates/nemoclaw-e2e/tests/fixtures/standalone_openshell.rs rename to crates/openshell-provider/tests/contract/standalone.rs index 6fae47c7690..c4cc4d5a20c 100644 --- a/crates/nemoclaw-e2e/tests/fixtures/standalone_openshell.rs +++ b/crates/openshell-provider/tests/contract/standalone.rs @@ -1,54 +1,41 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 +//! Authored OpenShell resources through OpenTofu: lost replies, foreign or +//! missing objects, bootstrap endpoints, and registration rotation. + use super::*; +use serde_json::json; +use std::process::Output; + +const STANDALONE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contract/standalone"); + +/// The OpenTofu type that serves an OpenShell resource kind. +fn resource_type(kind: &str) -> String { + match kind { + "provider" => "openshell_provider_registration".into(), + kind => format!("openshell_{kind}"), + } +} struct Standalone { root: TofuWorkspace, } impl Standalone { fn new(endpoint: &str) -> Self { - let tofu = - PathBuf::from(std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit OpenTofu")); - let provider = - PathBuf::from(std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit provider")); - assert!(tofu.is_absolute() && provider.is_absolute()); - let root = TofuWorkspace::new(tofu, provider); - let runtime = nemoclaw_e2e::image_runtime::binding("nvidia.fabric.pi"); - let mut document = nemoclaw_sdk::config::Document::parse( - include_str!("../../../nemoclaw-sdk/tests/fixtures/config/local.yaml").as_bytes(), + let root = TofuWorkspace::with_providers(tofu(), &[("openshell", &provider())]); + fs::copy( + Path::new(STANDALONE).join("main.tf"), + root.path().join("main.tf"), ) .unwrap(); - document.spec.inference_providers[0].endpoint = "http://127.0.0.1:11434/v1".into(); - let policy = - nemoclaw_sdk::image_runtime::policy_input(&document, &document.spec.sandboxes[0]) - .unwrap(); - // Write the policy as an author would: a typed block, not JSON. - let input = nemoclaw_openshell::structured_inputs("sandbox") - .into_iter() - .find(|input| input.attribute == "policy") - .unwrap(); - let nemoclaw_tofu::shape::Shape::Object(fields) = &input.shape else { - unreachable!("the policy is a block") - }; - let policy = input - .configuration(&serde_json::to_string(&policy).unwrap()) - .unwrap(); - fs::write( - root.path().join("main.tf"), - include_str!("openshell_resources.tf").replace( - "@POLICY@\n", - &nemoclaw_e2e::hcl::block("policy", fields, &policy, 2), - ), + let mut variables: Value = serde_json::from_slice( + &fs::read(Path::new(STANDALONE).join("terraform.tfvars.json")).unwrap(), ) .unwrap(); + variables["endpoint"] = json!(endpoint); fs::write( root.path().join("terraform.tfvars.json"), - json!({ - "endpoint": endpoint, - "runtime_json": serde_json::to_string(&runtime).unwrap(), - "binaries": runtime.binaries(), - }) - .to_string(), + variables.to_string(), ) .unwrap(); Self { root } @@ -137,7 +124,7 @@ async fn standalone_registrations_recreate_confirmed_absence_without_replacing_s for change in plan["resource_changes"].as_array().unwrap() { assert_eq!( change["change"]["actions"], - if change["type"] == nemoclaw_sdk::compile::resource_type(kind) { + if change["type"] == resource_type(kind) { json!(["create"]) } else { json!(["no-op"]) @@ -710,150 +697,6 @@ async fn gateway_readiness_dependency_waits_for_startup_before_workspace_creatio tofu.noop(); } -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; isolated Pi fixture"] -async fn standalone_pi_configuration_updates_without_replacing_the_sandbox() { - let fixture = Fixture::start().await; - let tofu = Standalone::new(&fixture.endpoint); - let source = fs::read_to_string(tofu.root.path().join("main.tf")).unwrap(); - fs::write( - tofu.root.path().join("main.tf"), - source - + r#" -variable "model" { default = "first-model" } -resource "fabric_agent_configuration" "agent" { - count = var.enabled ? 1 : 0 - workspace = openshell_sandbox.agent[0].workspace - name = openshell_sandbox.agent[0].name - owner = openshell_sandbox.agent[0].owner - generation = openshell_sandbox.agent[0].generation - sandbox_id = openshell_sandbox.agent[0].id - config_json = jsonencode({ schema_version = "fabric.agent/v1alpha1", runtime = {}, metadata = { name = "assistant" }, harness = { adapter_id = "nvidia.fabric.pi" }, models = { default = { provider = "openai", model = var.model } } }) -} -"#, - ) - .unwrap(); - tofu.run(&["plan", "-input=false"], true); - assert!(fixture.state.lock().unwrap().exec_calls.is_empty()); - tofu.apply(); - let effects = fixture.state.lock().unwrap().effects; - let writes = || { - fixture - .state - .lock() - .unwrap() - .exec_calls - .iter() - .filter(|command| { - command - .get(1) - .is_some_and(|arg| arg == "configure" || arg == "prepare") - }) - .count() - }; - assert_eq!(writes(), 1); - tofu.noop(); - assert_eq!(writes(), 1, "no-op must not reconfigure Pi"); - tofu.run( - &[ - "plan", - "-input=false", - "-var=model=second-model", - "-out=change.plan", - ], - true, - ); - assert_eq!(writes(), 1, "plan must not configure Pi"); - tofu.run(&["apply", "-input=false", "change.plan"], true); - assert_eq!(writes(), 2); - assert_eq!(fixture.state.lock().unwrap().effects, effects); - // A stopped host is observed as drift; explicit apply reconfigures it. - let sandbox_id = fixture - .state - .lock() - .unwrap() - .sandboxes - .values() - .next() - .unwrap() - .metadata - .as_ref() - .unwrap() - .id - .clone(); - fixture - .state - .lock() - .unwrap() - .fabric_stopped - .insert(sandbox_id.clone()); - tofu.run( - &[ - "apply", - "-auto-approve", - "-input=false", - "-var=model=second-model", - ], - true, - ); - assert_eq!(writes(), 3); - assert!( - !fixture - .state - .lock() - .unwrap() - .fabric_stopped - .contains(&sandbox_id) - ); - // Lose the exec response after the host accepted a configuration. Never - // retry the mutation automatically; the next refresh observes the outcome. - tofu.run( - &[ - "plan", - "-input=false", - "-var=model=third-model", - "-out=ambiguous.plan", - ], - true, - ); - fixture.state.lock().unwrap().lose_configure_reply = true; - tofu.run(&["apply", "-input=false", "ambiguous.plan"], false); - assert_eq!(writes(), 4); - assert!(!fixture.state.lock().unwrap().lose_configure_reply); - tofu.run( - &[ - "apply", - "-auto-approve", - "-input=false", - "-var=model=third-model", - ], - true, - ); - assert_eq!( - writes(), - 4, - "confirmed configuration must not be written again" - ); - let prior = tofu.state(); - fixture.state.lock().unwrap().exec_truncated = true; - tofu.run(&["plan", "-input=false", "-var=model=second-model"], false); - assert_eq!(tofu.state(), prior); - assert_eq!(writes(), 4); - assert!(!fixture.state.lock().unwrap().lose_configure_reply); - tofu.run( - &[ - "apply", - "-auto-approve", - "-input=false", - "-var=enabled=false", - "-var=destroying=true", - ], - true, - ); - assert!(fixture.state.lock().unwrap().sandboxes.is_empty()); - assert_eq!(writes(), 4, "destroy must not reconfigure Pi"); -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; isolated OpenShell fixture"] async fn standalone_create_readback_rejects_substitution_and_retains_established_binding() { diff --git a/crates/openshell-provider/tests/contract/standalone/main.tf b/crates/openshell-provider/tests/contract/standalone/main.tf new file mode 100644 index 00000000000..1ecdcb24175 --- /dev/null +++ b/crates/openshell-provider/tests/contract/standalone/main.tf @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +terraform { + required_version = "= 1.12.6" + required_providers { + openshell = { source = "registry.opentofu.org/nvidia/openshell" } + } +} +variable "endpoint" { type = string } +variable "runtime_json" { type = string } +variable "binaries" { type = list(string) } +variable "enabled" { default = true } +variable "destroying" { default = false } +variable "image" { default = "fixture@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } +provider "openshell" { + endpoint = var.endpoint + destroy = var.destroying +} +resource "openshell_workspace" "example" { + name = "standalone" + owner = "standalone-owner" + generation = "workspace-generation" + lifecycle { prevent_destroy = true } +} +resource "openshell_provider_profile" "inference" { + count = var.enabled ? 1 : 0 + workspace = openshell_workspace.example.name + name = "nemoclaw-inference-local" + owner = openshell_workspace.example.owner + generation = "provider-generation" + endpoint = "http://127.0.0.1:11434/v1" + authenticated = "false" + binaries = var.binaries +} +resource "openshell_provider_registration" "inference" { + count = var.enabled ? 1 : 0 + workspace = openshell_workspace.example.name + name = "local" + owner = openshell_workspace.example.owner + generation = "provider-generation" + endpoint = openshell_provider_profile.inference[0].endpoint +} +resource "openshell_sandbox" "agent" { + count = var.enabled ? 1 : 0 + workspace = openshell_workspace.example.name + name = "assistant" + owner = openshell_workspace.example.owner + generation = "sandbox-generation" + image = var.image + agent_name = "assistant" + agent_runtime = "fabric" + runtime_json = var.runtime_json + provider_names = [openshell_provider_registration.inference[0].name] + policy { + managed "nemoclaw-inference-local-fcb7b1f1af3733764900def4" { + endpoints { + access = "full" + allowed_ips = ["127.0.0.1/32"] + host = "127.0.0.1" + path = "/v1/**" + port = 11434 + protocol = "rest" + } + name = "nemoclaw-inference-local-fcb7b1f1af3733764900def4" + } + } +} diff --git a/crates/openshell-provider/tests/contract/standalone/terraform.tfvars.json b/crates/openshell-provider/tests/contract/standalone/terraform.tfvars.json new file mode 100644 index 00000000000..f077744101e --- /dev/null +++ b/crates/openshell-provider/tests/contract/standalone/terraform.tfvars.json @@ -0,0 +1,6 @@ +{ + "binaries": [ + "/usr/local/bin/python3.99" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.pi\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.pi\"}" +} diff --git a/docs/contributing/integration-tests.md b/docs/contributing/integration-tests.md index b8bd2fa0446..f9e50b62427 100644 --- a/docs/contributing/integration-tests.md +++ b/docs/contributing/integration-tests.md @@ -38,15 +38,7 @@ It uses a built-in OpenTofu resource to exercise the generated precondition and Test the runtime bundle and live serving backend separately. -Test the production provider's full OpenShell resource graph against the local gRPC fixture: - -```sh -NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ -NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ - cargo test -p nemoclaw-e2e --test integration opentofu_openshell:: -- --ignored -``` - -These tests also check gateway version and driver preconditions, failed observations without resource changes, and data-source reads deferred until bootstrap inputs become known. +The [OpenShell provider contract](#openshell-provider-contract) tests also check gateway version and driver preconditions, failed observations without resource changes, and data-source reads deferred until bootstrap inputs become known. The `gateway_readiness::` tests use the same explicit OpenTofu/provider paths with local engine and OpenShell fixtures. It checks prompt managed-gateway exit diagnostics, bootstrap state retained after failure, corrected retry, unchanged-apply rechecks, and teardown with the readiness data source omitted. Its bootstrap identity is a built-in OpenTofu resource; it creates no live container. @@ -93,6 +85,7 @@ NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ cargo test -p openshell-provider --test contract -- --ignored ``` +Its `capabilities` tests check gateway preconditions and saved-plan rechecks, and its `standalone` tests apply authored OpenShell resources from `tests/contract/standalone` through lost replies, foreign or missing objects, bootstrap endpoints, and registration rotation. The fixtures are the OpenShell resources the SDK compiles for each example with an external gateway, excluding examples whose credentials are read from a managed service's container. `nemoclaw-e2e`'s `openshell_contract_fixtures` test fails when they differ from what the SDK compiles; regenerate them with `NEMOCLAW_REGENERATE_FIXTURES=1 cargo test -p nemoclaw-e2e --test integration openshell_contract_fixtures`. diff --git a/docs/provider.md b/docs/provider.md index c8042d4d5d9..5f3a3ab303a 100644 --- a/docs/provider.md +++ b/docs/provider.md @@ -391,7 +391,7 @@ A failed apply may record new observations and condition results while retaining After correcting compatibility or access, reapply the same configuration with its retained state. Teardown omits the capability gates so a version or driver mismatch alone does not prevent cleanup. -[Gateway protocol tests](../crates/nemoclaw-e2e/tests/opentofu_openshell.rs) exercise the production provider and pinned OpenTofu without SDK orchestration: early planning errors, saved-plan drift, unchanged apply, failed observation, recovery, and teardown. +[OpenShell contract tests](../crates/openshell-provider/tests/contract) exercise the production provider and pinned OpenTofu without SDK orchestration: early planning errors, saved-plan drift, unchanged apply, failed observation, recovery, and teardown. [Deployment fixtures](../crates/nemoclaw-e2e/tests/deployment.rs) and [Fabric lifecycle fixtures](../crates/nemoclaw-e2e/tests/fabric_deployment.rs) verify that the SDK uses the same apply-time protection. Fabric configuration writes are owned by `fabric_agent_configuration`; unchanged apply preserves the active runtime handle. Its `config_json` is the canonical public Fabric configuration, separate from immutable sandbox identity. From febbd38a3a943551d10ff51ca320aa652c2017dc Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 05:58:24 -0700 Subject: [PATCH 16/18] test(fabric): run each Fabric type through OpenTofu in contract tests Fabric types were exercised through OpenTofu only by SDK-generated system scenarios and one Pi test in nemoclaw-e2e that needed both the openshell and fabric providers. fabric-provider's contract binary, using the shared fake gateway: - fabric_agent_configuration: the Pi test moves here unchanged, applying a static fixture. Invalid configurations fail at their field without the value; updates keep the sandbox; a stopped host is reconfigured; a lost reply is not retried. - fabric_sandbox_readiness: the configured agent reads ready, failed health reads not ready without failing apply or writing to the sandbox, and recovered health reads ready again. - fabric_capabilities: a fake Docker engine serves an image declaring a Fabric catalog. A compatible image reports its runtime binaries; another platform, or a read policy without the runtime's paths, is unsupported; a missing image is unknown; the engine is only read. - A coverage test requires a contract test for every Fabric type. nemoclaw-e2e no longer tests a single provider type, and the lifecycle profile selects the Fabric contract binary. Part of #12880. --- .config/nextest.toml | 3 +- Cargo.lock | 1 + crates/fabric-provider/Cargo.toml | 1 + .../tests/contract/capabilities.rs | 147 +++++++++++++++++ .../tests/contract/fixtures/main.tf} | 34 +++- .../tests/contract/fixtures/readiness.tf | 19 +++ .../contract/fixtures/terraform.tfvars.json | 6 + .../tests/contract/main.rs} | 150 ++++++++++-------- .../tests/contract/readiness.rs | 31 ++++ crates/nemoclaw-e2e/tests/main.rs | 2 - docs/contributing/integration-tests.md | 15 ++ 11 files changed, 336 insertions(+), 73 deletions(-) create mode 100644 crates/fabric-provider/tests/contract/capabilities.rs rename crates/{nemoclaw-e2e/tests/fixtures/openshell_resources.tf => fabric-provider/tests/contract/fixtures/main.tf} (67%) create mode 100644 crates/fabric-provider/tests/contract/fixtures/readiness.tf create mode 100644 crates/fabric-provider/tests/contract/fixtures/terraform.tfvars.json rename crates/{nemoclaw-e2e/tests/standalone_pi.rs => fabric-provider/tests/contract/main.rs} (65%) create mode 100644 crates/fabric-provider/tests/contract/readiness.rs diff --git a/.config/nextest.toml b/.config/nextest.toml index 8c245a43004..bfe7340b697 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -23,9 +23,10 @@ test(native_state_json_preserves_module_and_instance_identity_without_refresh) | (package(nemoclaw-sdk) & test(/^deployment::runtime::helm_recovery::tests::/)) | (package(nemoclaw-sdk) & test(runtime_export_declares_the_native_helm_provider_inputs)) | (package(openshell-provider) & binary(=contract)) +| (package(fabric-provider) & binary(=contract)) | (package(nemoclaw-e2e) & binary(=integration) & ( test(/^provider_protocol::/) | test(/^service_capacity::/) | test(/^service_readiness::/) - | test(/^sandbox_readiness::/) | test(/^standalone_pi::/) | test(/^deployment::/) + | test(/^sandbox_readiness::/) | test(/^deployment::/) | test(/^service_storage::/) | test(/^vllm_runtime::/) | test(/^kubernetes_hcl::/) | test(/^runtime_image::/) | test(/^export_observations::/) | test(/^fabric_deployment::/) diff --git a/Cargo.lock b/Cargo.lock index f56f28a104d..5fd17398353 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1056,6 +1056,7 @@ dependencies = [ "nemoclaw-docker", "nemoclaw-fabric", "nemoclaw-openshell", + "nemoclaw-test-fixtures", "nemoclaw-tofu", "openshell-provider", "regex", diff --git a/crates/fabric-provider/Cargo.toml b/crates/fabric-provider/Cargo.toml index 53cc17340b9..7700cbe833e 100644 --- a/crates/fabric-provider/Cargo.toml +++ b/crates/fabric-provider/Cargo.toml @@ -32,5 +32,6 @@ tokio.workspace = true tokio-util.workspace = true [dev-dependencies] +nemoclaw-test-fixtures = { path = "../nemoclaw-test-fixtures" } tempfile.workspace = true tokio = { workspace = true, features = ["test-util"] } diff --git a/crates/fabric-provider/tests/contract/capabilities.rs b/crates/fabric-provider/tests/contract/capabilities.rs new file mode 100644 index 00000000000..e5cad03a9c9 --- /dev/null +++ b/crates/fabric-provider/tests/contract/capabilities.rs @@ -0,0 +1,147 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Image capabilities through OpenTofu, read from a fake Docker engine. + +use super::*; +use nemoclaw_fabric::catalog::{BridgeCapabilities, FabricCatalog, IMAGE_CATALOG_LABEL}; + +/// A Docker engine that serves one image declaring the bundled Fabric +/// catalog, and no image for references containing `missing`. +async fn engine(digest: String) -> http::Fixture { + let mut catalog = FabricCatalog::bundled(); + catalog.bridge = Some(BridgeCapabilities { + interface_version: 1, + operations: [ + "validate", + "prepare", + "configure", + "check", + "invoke", + "serve", + ] + .into_iter() + .map(String::from) + .collect(), + health_checks: Vec::new(), + }); + // One adapter, so the image's runtime declares binaries for all of them. + catalog + .adapters + .retain(|adapter| adapter.adapter_id() == "nvidia.fabric.langchain.deepagents"); + let mut runtime: Value = + serde_json::from_str(include_str!("../../../../image/fabric/runtime.json")).unwrap(); + runtime["binaries"] = json!({"nvidia.fabric.langchain.deepagents": ["/srv/python3.99"]}); + catalog.runtime = Some(serde_json::from_value(runtime).unwrap()); + let label = serde_json::to_string(&catalog).unwrap(); + http::Fixture::start(move |request| { + assert_eq!( + request.method, "GET", + "capabilities must not change the engine" + ); + if request.path.contains("missing") { + return Some((404, br#"{"message":"No such image"}"#.to_vec())); + } + let image = json!({"Id": "sha256:config", "Architecture": "arm64", "Os": "linux", + "RepoDigests": [digest], "Config": {"Labels": {IMAGE_CATALOG_LABEL: label}}}); + Some((200, serde_json::to_vec(&image).unwrap())) + }) + .await +} + +fn configuration(image: &str, architecture: &str, reads: &[&str]) -> String { + let configuration = json!({ + "schema_version": "fabric.agent/v1alpha1", "metadata": {"name": "main"}, "runtime": {}, + "harness": {"adapter_id": "nvidia.fabric.langchain.deepagents"}, + "models": {"default": {"provider": "openai", "model": "fixture-model", + "base_url": "http://localhost/v1", "api_key_env": "MODEL_KEY"}}}); + format!( + r#"terraform {{ + required_version = "= 1.12.6" + required_providers {{ + fabric = {{ source = "registry.opentofu.org/nvidia/fabric" }} + }} +}} +variable "engine" {{ type = string }} +provider "fabric" {{}} +data "fabric_capabilities" "agent" {{ + engine = var.engine + image = "{image}" + architecture = "{architecture}" + operating_system = "linux" + config_json = {configuration} + filesystem_read = {reads} +}} +output "compatibility" {{ value = data.fabric_capabilities.agent.compatibility_status }} +output "binaries" {{ value = jsondecode(data.fabric_capabilities.agent.binaries_json) }} +output "observation" {{ value = data.fabric_capabilities.agent.observation_json }} +"#, + configuration = serde_json::to_string(&configuration.to_string()).unwrap(), + reads = serde_json::to_string(reads).unwrap() + ) +} + +/// A compatible image reports its runtime binaries. A different platform, or +/// an explicit read policy that omits the runtime's paths, is unsupported, and +/// a missing image is unknown; none of these fail apply or change the engine. +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake Docker engine"] +async fn capabilities_judge_the_image_for_the_configuration() { + let digest = format!("registry/agent@sha256:{}", "a".repeat(64)); + let engine = engine(digest.clone()).await; + let runtime_reads = ["/opt/fabric", "/opt/nemoclaw", "/sandbox"].as_slice(); + for (image, architecture, reads, expected) in [ + (digest.as_str(), "aarch64", runtime_reads, "supported"), + (digest.as_str(), "amd64", runtime_reads, "unsupported"), + ( + digest.as_str(), + "aarch64", + ["/sandbox"].as_slice(), + "unsupported", + ), + ("missing:image", "aarch64", runtime_reads, "unknown"), + ] { + let workspace = TofuWorkspace::with_providers(tofu(), &[("fabric", &provider("fabric"))]); + fs::write( + workspace.path().join("main.tf"), + configuration(image, architecture, reads), + ) + .unwrap(); + let output = workspace + .command() + .args([ + "apply", + "-auto-approve", + "-input=false", + "-no-color", + "-var", + ]) + .arg(format!("engine={}", engine.endpoint)) + .output() + .unwrap(); + assert!( + output.status.success(), + "{image} {architecture}: {}", + String::from_utf8_lossy(&output.stderr) + ); + let outputs: Value = serde_json::from_slice( + &workspace + .command() + .args(["output", "-json"]) + .output() + .unwrap() + .stdout, + ) + .unwrap(); + assert_eq!( + outputs["compatibility"]["value"], expected, + "{image} {architecture}: {}", + outputs["observation"]["value"] + ); + let binaries = outputs["binaries"]["value"].as_array().unwrap(); + assert_eq!( + binaries.is_empty(), + image.contains("missing"), + "{binaries:?}" + ); + } +} diff --git a/crates/nemoclaw-e2e/tests/fixtures/openshell_resources.tf b/crates/fabric-provider/tests/contract/fixtures/main.tf similarity index 67% rename from crates/nemoclaw-e2e/tests/fixtures/openshell_resources.tf rename to crates/fabric-provider/tests/contract/fixtures/main.tf index a2bfe4d4d48..520b6a475f6 100644 --- a/crates/nemoclaw-e2e/tests/fixtures/openshell_resources.tf +++ b/crates/fabric-provider/tests/contract/fixtures/main.tf @@ -56,5 +56,37 @@ resource "openshell_sandbox" "agent" { agent_runtime = "fabric" runtime_json = var.runtime_json provider_names = [openshell_provider_registration.inference[0].name] -@POLICY@ + policy { + managed "nemoclaw-inference-local-fcb7b1f1af3733764900def4" { + endpoints { + access = "full" + allowed_ips = ["127.0.0.1/32"] + host = "127.0.0.1" + path = "/v1/**" + port = 11434 + protocol = "rest" + } + name = "nemoclaw-inference-local-fcb7b1f1af3733764900def4" + } + } +} +variable "model" { default = "first-model" } +variable "adapter" { + type = any + default = "nvidia.fabric.pi" +} +resource "fabric_agent_configuration" "agent" { + count = var.enabled ? 1 : 0 + workspace = openshell_sandbox.agent[0].workspace + name = openshell_sandbox.agent[0].name + owner = openshell_sandbox.agent[0].owner + generation = openshell_sandbox.agent[0].generation + sandbox_id = openshell_sandbox.agent[0].id + config_json = jsonencode({ + schema_version = "fabric.agent/v1alpha1" + runtime = {} + metadata = { name = "assistant" } + harness = { adapter_id = var.adapter } + models = { default = { provider = "openai", model = var.model } } + }) } diff --git a/crates/fabric-provider/tests/contract/fixtures/readiness.tf b/crates/fabric-provider/tests/contract/fixtures/readiness.tf new file mode 100644 index 00000000000..31227dc0106 --- /dev/null +++ b/crates/fabric-provider/tests/contract/fixtures/readiness.tf @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# Readiness of the configured agent, read after its configuration applies. +data "fabric_sandbox_readiness" "agent" { + count = var.enabled ? 1 : 0 + workspace = openshell_sandbox.agent[0].workspace + name = openshell_sandbox.agent[0].name + id = openshell_sandbox.agent[0].id + owner = openshell_sandbox.agent[0].owner + generation = openshell_sandbox.agent[0].generation + agent_name = openshell_sandbox.agent[0].agent_name + agent_runtime = openshell_sandbox.agent[0].agent_runtime + runtime_json = openshell_sandbox.agent[0].runtime_json + config_json = fabric_agent_configuration.agent[0].config_json + read_trigger = fabric_agent_configuration.agent[0].id +} +output "ready" { + value = var.enabled ? data.fabric_sandbox_readiness.agent[0].ready : null +} diff --git a/crates/fabric-provider/tests/contract/fixtures/terraform.tfvars.json b/crates/fabric-provider/tests/contract/fixtures/terraform.tfvars.json new file mode 100644 index 00000000000..f077744101e --- /dev/null +++ b/crates/fabric-provider/tests/contract/fixtures/terraform.tfvars.json @@ -0,0 +1,6 @@ +{ + "binaries": [ + "/usr/local/bin/python3.99" + ], + "runtime_json": "{\"runtime\":{\"schema_version\":1,\"command\":[\"/usr/local/bin/fabric-agent\"],\"environment\":{\"ADAPTER_PYTHON\":\"/opt/fabric/bin/python\",\"HOME\":\"/sandbox\",\"NEMOCLAW_ANONYMOUS_API_KEY\":\"unused\",\"NODE_EXTRA_CA_CERTS\":\"/etc/ssl/certs/ca-certificates.crt\",\"PATH\":\"/opt/fabric/bin:/usr/local/bin:/usr/bin:/bin\",\"PYTHONDONTWRITEBYTECODE\":\"1\",\"SSL_CERT_FILE\":\"/etc/ssl/certs/ca-certificates.crt\",\"TMPDIR\":\"/sandbox/tmp\",\"XDG_CACHE_HOME\":\"/sandbox/.cache\"},\"required_paths\":[\"/opt/fabric\",\"/opt/nemoclaw\"],\"policy\":{\"version\":1,\"filesystem_policy\":{\"include_workdir\":false,\"read_only\":[\"/usr\",\"/bin\",\"/sbin\",\"/lib\",\"/lib64\",\"/etc\",\"/app\",\"/opt\",\"/proc\"],\"read_write\":[\"/sandbox\",\"/tmp\",\"/dev/null\",\"/dev/urandom\",\"/home/node\"]},\"landlock\":{\"compatibility\":\"best_effort\"},\"process\":{\"run_as_user\":\"10001\",\"run_as_group\":\"10001\"},\"network_policies\":{}},\"binaries\":{\"nvidia.fabric.pi\":[\"/usr/local/bin/python3.99\"]}},\"adapter_id\":\"nvidia.fabric.pi\"}" +} diff --git a/crates/nemoclaw-e2e/tests/standalone_pi.rs b/crates/fabric-provider/tests/contract/main.rs similarity index 65% rename from crates/nemoclaw-e2e/tests/standalone_pi.rs rename to crates/fabric-provider/tests/contract/main.rs index 4fe2debbdeb..f2d2adfb32f 100644 --- a/crates/nemoclaw-e2e/tests/standalone_pi.rs +++ b/crates/fabric-provider/tests/contract/main.rs @@ -1,60 +1,75 @@ // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. // SPDX-License-Identifier: Apache-2.0 -//! Pi configuration through the openshell and fabric providers together. -//! The fabric provider's contract tests will own this. +//! Contract tests: Fabric types through pinned OpenTofu against the fake +//! OpenShell gateway, which runs Fabric's configure, prepare, and status +//! commands, and a fake Docker engine for image capabilities. -use nemoclaw_e2e::tofu::TofuWorkspace; -use nemoclaw_test_fixtures::openshell::Fixture; +mod capabilities; +#[path = "../../../test-support/http.rs"] +mod http; +mod readiness; + +use nemoclaw_test_fixtures::{executable, openshell::Fixture, tofu::TofuWorkspace}; use serde_json::{Value, json}; -use std::{fs, path::PathBuf, process::Output}; +use std::{ + collections::BTreeSet, + fs, + path::{Path, PathBuf}, + process::Output, +}; + +const FIXTURES: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/contract/fixtures"); + +fn tofu() -> PathBuf { + let tofu = PathBuf::from( + std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit pinned OpenTofu path"), + ); + assert!(tofu.is_absolute()); + tofu +} + +/// A provider built beside NEMOCLAW_TEST_PROVIDER, as the lifecycle tests +/// receive it. +fn provider(name: &str) -> PathBuf { + let nemoclaw = PathBuf::from( + std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit provider build path"), + ); + assert!(nemoclaw.is_absolute()); + nemoclaw + .parent() + .unwrap() + .join(executable(&format!("terraform-provider-{name}"))) +} + +/// A workspace with the openshell and fabric providers. +fn workspace() -> TofuWorkspace { + TofuWorkspace::with_providers( + tofu(), + &[ + ("openshell", &provider("openshell")), + ("fabric", &provider("fabric")), + ], + ) +} +/// A sandbox with a Pi configuration, plus `extra` fixture files. struct Standalone { root: TofuWorkspace, } impl Standalone { - fn new(endpoint: &str) -> Self { - let tofu = - PathBuf::from(std::env::var_os("NEMOCLAW_TEST_TOFU").expect("explicit OpenTofu")); - let provider = - PathBuf::from(std::env::var_os("NEMOCLAW_TEST_PROVIDER").expect("explicit provider")); - assert!(tofu.is_absolute() && provider.is_absolute()); - let root = TofuWorkspace::new(tofu, provider); - let runtime = nemoclaw_e2e::image_runtime::binding("nvidia.fabric.pi"); - let mut document = nemoclaw_sdk::config::Document::parse( - include_str!("../../nemoclaw-sdk/tests/fixtures/config/local.yaml").as_bytes(), - ) - .unwrap(); - document.spec.inference_providers[0].endpoint = "http://127.0.0.1:11434/v1".into(); - let policy = - nemoclaw_sdk::image_runtime::policy_input(&document, &document.spec.sandboxes[0]) - .unwrap(); - // Write the policy as an author would: a typed block, not JSON. - let input = nemoclaw_openshell::structured_inputs("sandbox") - .into_iter() - .find(|input| input.attribute == "policy") - .unwrap(); - let nemoclaw_tofu::shape::Shape::Object(fields) = &input.shape else { - unreachable!("the policy is a block") - }; - let policy = input - .configuration(&serde_json::to_string(&policy).unwrap()) - .unwrap(); - fs::write( - root.path().join("main.tf"), - include_str!("fixtures/openshell_resources.tf").replace( - "@POLICY@\n", - &nemoclaw_e2e::hcl::block("policy", fields, &policy, 2), - ), + fn new(endpoint: &str, extra: &[&str]) -> Self { + let root = workspace(); + for file in std::iter::once("main.tf").chain(extra.iter().copied()) { + fs::copy(Path::new(FIXTURES).join(file), root.path().join(file)).unwrap(); + } + let mut variables: Value = serde_json::from_slice( + &fs::read(Path::new(FIXTURES).join("terraform.tfvars.json")).unwrap(), ) .unwrap(); + variables["endpoint"] = json!(endpoint); fs::write( root.path().join("terraform.tfvars.json"), - json!({ - "endpoint": endpoint, - "runtime_json": serde_json::to_string(&runtime).unwrap(), - "binaries": runtime.binaries(), - }) - .to_string(), + variables.to_string(), ) .unwrap(); Self { root } @@ -94,33 +109,30 @@ impl Standalone { } } +/// Every Fabric type has a contract test. +#[test] +fn every_fabric_type_has_a_contract_test() { + let mut sources = String::new(); + for entry in fs::read_dir(FIXTURES).unwrap() { + sources += &fs::read_to_string(entry.unwrap().path()).unwrap(); + } + sources += include_str!("capabilities.rs"); + let used: BTreeSet<&str> = [ + "fabric_agent_configuration", + "fabric_sandbox_readiness", + "fabric_capabilities", + ] + .into_iter() + .filter(|kind| sources.contains(&format!("\"{kind}\""))) + .collect(); + assert_eq!(used.len(), 3, "types with a contract test: {used:?}"); +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] -#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; isolated Pi fixture"] -async fn standalone_pi_configuration_updates_without_replacing_the_sandbox() { +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake OpenShell gateway"] +async fn pi_configuration_updates_without_replacing_the_sandbox() { let fixture = Fixture::start().await; - let tofu = Standalone::new(&fixture.endpoint); - let source = fs::read_to_string(tofu.root.path().join("main.tf")).unwrap(); - fs::write( - tofu.root.path().join("main.tf"), - source - + r#" -variable "model" { default = "first-model" } -variable "adapter" { - type = any - default = "nvidia.fabric.pi" -} -resource "fabric_agent_configuration" "agent" { - count = var.enabled ? 1 : 0 - workspace = openshell_sandbox.agent[0].workspace - name = openshell_sandbox.agent[0].name - owner = openshell_sandbox.agent[0].owner - generation = openshell_sandbox.agent[0].generation - sandbox_id = openshell_sandbox.agent[0].id - config_json = jsonencode({ schema_version = "fabric.agent/v1alpha1", runtime = {}, metadata = { name = "assistant" }, harness = { adapter_id = var.adapter }, models = { default = { provider = "openai", model = var.model } } }) -} -"#, - ) - .unwrap(); + let tofu = Standalone::new(&fixture.endpoint, &[]); // A configuration Fabric rejects fails validation at its field, before // any sandbox call, and the message never repeats the rejected value. let rejected = tofu.run( diff --git a/crates/fabric-provider/tests/contract/readiness.rs b/crates/fabric-provider/tests/contract/readiness.rs new file mode 100644 index 00000000000..b9d47f91918 --- /dev/null +++ b/crates/fabric-provider/tests/contract/readiness.rs @@ -0,0 +1,31 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Agent readiness through OpenTofu. + +use super::*; + +fn output(tofu: &Standalone, name: &str) -> Value { + let output = tofu.run(&["output", "-json", name], true); + serde_json::from_slice(&output.stdout).unwrap() +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +#[ignore = "requires NEMOCLAW_TEST_TOFU and NEMOCLAW_TEST_PROVIDER; fake OpenShell gateway"] +async fn readiness_reports_the_configured_agent_and_its_failed_health() { + let fixture = Fixture::start().await; + let tofu = Standalone::new(&fixture.endpoint, &["readiness.tf"]); + tofu.apply(); + assert_eq!(output(&tofu, "ready"), json!(true)); + // Failed health is an observation, not an apply failure, and reading it + // writes nothing to the sandbox. + let effects = fixture.state.lock().unwrap().effects; + fixture.state.lock().unwrap().health_report = Some( + json!({"supported": true, "report": {"fixture": false}, "reason_code": "fixture_unhealthy"}), + ); + tofu.apply(); + assert_eq!(output(&tofu, "ready"), json!(false)); + fixture.state.lock().unwrap().health_report = None; + tofu.apply(); + assert_eq!(output(&tofu, "ready"), json!(true)); + assert_eq!(fixture.state.lock().unwrap().effects, effects); +} diff --git a/crates/nemoclaw-e2e/tests/main.rs b/crates/nemoclaw-e2e/tests/main.rs index ddcf47947e7..dc220f9f56e 100644 --- a/crates/nemoclaw-e2e/tests/main.rs +++ b/crates/nemoclaw-e2e/tests/main.rs @@ -54,8 +54,6 @@ mod sandbox_readiness; mod service_capacity; #[path = "service_readiness.rs"] mod service_readiness; -#[path = "standalone_pi.rs"] -mod standalone_pi; // The fixture engine listens on a Unix socket. #[cfg(unix)] #[path = "service_storage.rs"] diff --git a/docs/contributing/integration-tests.md b/docs/contributing/integration-tests.md index f9e50b62427..ac10d9cdc89 100644 --- a/docs/contributing/integration-tests.md +++ b/docs/contributing/integration-tests.md @@ -89,6 +89,21 @@ Its `capabilities` tests check gateway preconditions and saved-plan rechecks, an The fixtures are the OpenShell resources the SDK compiles for each example with an external gateway, excluding examples whose credentials are read from a managed service's container. `nemoclaw-e2e`'s `openshell_contract_fixtures` test fails when they differ from what the SDK compiles; regenerate them with `NEMOCLAW_REGENERATE_FIXTURES=1 cargo test -p nemoclaw-e2e --test integration openshell_contract_fixtures`. +## Fabric Provider Contract + +The `fabric-provider` crate's `contract` tests run each Fabric type through OpenTofu with the same paths: + +```sh +NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ +NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ + cargo test -p fabric-provider --test contract -- --ignored +``` + +`fabric_agent_configuration` applies a Pi configuration to a sandbox from `tests/contract/fixtures`. An invalid configuration fails validation at its field without repeating the value. The configuration updates without replacing the sandbox, a stopped host is reconfigured, and a lost reply is not retried. +`fabric_sandbox_readiness` reports the configured agent ready, and not ready while its health fails, without writing to the sandbox. +`fabric_capabilities` reads a fake Docker engine's image metadata. A compatible image reports its runtime binaries, while another platform, or a read policy without the runtime's paths, is unsupported, and a missing image is unknown. +A coverage test requires a contract test for every Fabric type. + ## Standalone Sandbox Completion On Unix, build the production provider and supply the explicit OpenTofu and provider paths as above. From 665db38c375c594a30d2500f92d359161dbedb4d Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 13:26:39 -0700 Subject: [PATCH 17/18] test(provider): move single-type nemoclaw tests into the provider's contract tests The nemoclaw provider's OpenTofu tests sat in nemoclaw-e2e beside the system scenarios, selected by name patterns, and nothing checked that every type had one. - nemoclaw-provider gets a contract binary. service_storage, kubernetes_hcl, runtime_image, vllm_runtime, gateway_readiness, and discovery move into it unchanged. - every_type_has_a_contract_test lists each resource and data source the provider serves and fails for one without a contract test. Its ELSEWHERE list records the five still tested only elsewhere and why, and fails when one of them gains a contract test. - provider_protocol, service_capacity, and service_readiness stay in nemoclaw-e2e: they need that crate's fixture provider and SSH fixture binaries. - The lifecycle profile selects all three providers' contract binaries. Part of #12879. --- .config/nextest.toml | 7 +- Cargo.lock | 1 + crates/nemoclaw-e2e/tests/main.rs | 16 +-- crates/nemoclaw-provider/Cargo.toml | 5 + .../tests/contract}/discovery.rs | 8 +- .../tests/contract}/gateway_readiness.rs | 6 +- .../tests/contract}/kubernetes_hcl.rs | 2 +- .../nemoclaw-provider/tests/contract/main.rs | 109 ++++++++++++++++++ .../tests/contract}/runtime_image.rs | 2 +- .../tests/contract}/service_storage.rs | 2 +- .../tests/contract}/vllm_runtime.rs | 2 +- docs/contributing/integration-tests.md | 21 +++- docs/design/fabric-management.md | 2 +- 13 files changed, 149 insertions(+), 34 deletions(-) rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/discovery.rs (98%) rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/gateway_readiness.rs (95%) rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/kubernetes_hcl.rs (99%) create mode 100644 crates/nemoclaw-provider/tests/contract/main.rs rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/runtime_image.rs (98%) rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/service_storage.rs (99%) rename crates/{nemoclaw-e2e/tests => nemoclaw-provider/tests/contract}/vllm_runtime.rs (99%) diff --git a/.config/nextest.toml b/.config/nextest.toml index bfe7340b697..176bbf14a09 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -22,16 +22,13 @@ default-filter = ''' test(native_state_json_preserves_module_and_instance_identity_without_refresh) | (package(nemoclaw-sdk) & test(/^deployment::runtime::helm_recovery::tests::/)) | (package(nemoclaw-sdk) & test(runtime_export_declares_the_native_helm_provider_inputs)) -| (package(openshell-provider) & binary(=contract)) -| (package(fabric-provider) & binary(=contract)) +| ((package(nemoclaw-provider) | package(openshell-provider) | package(fabric-provider)) & binary(=contract)) | (package(nemoclaw-e2e) & binary(=integration) & ( test(/^provider_protocol::/) | test(/^service_capacity::/) | test(/^service_readiness::/) | test(/^sandbox_readiness::/) | test(/^deployment::/) - | test(/^service_storage::/) | test(/^vllm_runtime::/) - | test(/^kubernetes_hcl::/) | test(/^runtime_image::/) | test(/^export_observations::/) | test(/^fabric_deployment::/) | test(/^multiple_providers::/) | test(/^remote_service::/) - | test(/^discovery::/) | test(/^inference_discovery::/) | test(/^gateway_readiness::/) + | test(/^inference_discovery::/) )) ''' diff --git a/Cargo.lock b/Cargo.lock index 5fd17398353..2977d132024 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2708,6 +2708,7 @@ dependencies = [ "nemoclaw-openshell", "nemoclaw-runtime", "nemoclaw-sdk", + "nemoclaw-test-fixtures", "nemoclaw-tofu", "openshell-core", "openshell-policy", diff --git a/crates/nemoclaw-e2e/tests/main.rs b/crates/nemoclaw-e2e/tests/main.rs index dc220f9f56e..ff24d91a28e 100644 --- a/crates/nemoclaw-e2e/tests/main.rs +++ b/crates/nemoclaw-e2e/tests/main.rs @@ -9,8 +9,6 @@ mod agent_compatibility; mod cache_provider; #[path = "deployment.rs"] mod deployment; -#[path = "discovery.rs"] -mod discovery; #[path = "docker_fixture.rs"] mod docker_fixture; #[path = "docker_provider_proxy.rs"] @@ -21,16 +19,12 @@ mod export_observations; mod fabric_deployment; #[path = "fabric_live.rs"] mod fabric_live; -#[path = "gateway_readiness.rs"] -mod gateway_readiness; #[path = "health.rs"] mod health; #[path = "hosted_parity.rs"] mod hosted_parity; #[path = "inference_discovery.rs"] mod inference_discovery; -#[path = "kubernetes_hcl.rs"] -mod kubernetes_hcl; #[path = "managed.rs"] mod managed; #[path = "model_live.rs"] @@ -46,26 +40,20 @@ mod provider_protocol; #[path = "remote_service.rs"] mod remote_service; #[cfg(unix)] -#[path = "runtime_image.rs"] -mod runtime_image; #[path = "sandbox_readiness.rs"] mod sandbox_readiness; +// The fixture engine listens on a Unix socket. +#[cfg(unix)] #[path = "service_capacity.rs"] mod service_capacity; #[path = "service_readiness.rs"] mod service_readiness; -// The fixture engine listens on a Unix socket. -#[cfg(unix)] -#[path = "service_storage.rs"] -mod service_storage; #[path = "spark.rs"] mod spark; #[path = "tls.rs"] mod tls; // The fixture engine listens on a Unix socket. #[cfg(unix)] -#[path = "vllm_runtime.rs"] -mod vllm_runtime; #[path = "web_search.rs"] mod web_search; diff --git a/crates/nemoclaw-provider/Cargo.toml b/crates/nemoclaw-provider/Cargo.toml index 9ad6ce35dcc..cdc2c44db58 100644 --- a/crates/nemoclaw-provider/Cargo.toml +++ b/crates/nemoclaw-provider/Cargo.toml @@ -12,6 +12,10 @@ autotests = false name = "integration" path = "tests/main.rs" +[[test]] +name = "contract" +path = "tests/contract/main.rs" + [dependencies] nemoclaw-backend = { path = "../nemoclaw-backend" } nemoclaw-tofu = { path = "../nemoclaw-tofu" } @@ -49,6 +53,7 @@ rustix = { workspace = true, features = ["fs"] } [dev-dependencies] fabric-provider = { path = "../fabric-provider" } +nemoclaw-test-fixtures = { path = "../nemoclaw-test-fixtures" } prost.workspace = true tokio = { workspace = true, features = ["test-util"] } tempfile.workspace = true diff --git a/crates/nemoclaw-e2e/tests/discovery.rs b/crates/nemoclaw-provider/tests/contract/discovery.rs similarity index 98% rename from crates/nemoclaw-e2e/tests/discovery.rs rename to crates/nemoclaw-provider/tests/contract/discovery.rs index b3841a80b3c..22de685d76b 100644 --- a/crates/nemoclaw-e2e/tests/discovery.rs +++ b/crates/nemoclaw-provider/tests/contract/discovery.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 #![cfg(unix)] -use nemoclaw_e2e::http_fixture as transport; -use nemoclaw_e2e::tofu::TofuWorkspace; +use crate::http_fixture as transport; +use crate::tofu::TofuWorkspace; use nemoclaw_sdk::fabric_catalog::{FabricCatalog, IMAGE_CATALOG_LABEL}; use serde_json::{Value, json}; use std::{ @@ -195,7 +195,7 @@ async fn compiled_discovery_requires_runtime_metadata_but_allows_unknown_capabil ); assert!(tofu.is_absolute() && provider.is_absolute()); let document = - Document::parse(include_bytes!("../../../examples/onboarding/openclaw.yaml").as_slice()) + Document::parse(include_bytes!("../../../../examples/onboarding/openclaw.yaml").as_slice()) .unwrap(); let image = document.spec.sandboxes[0].image.ref_.clone(); let mode = Arc::new(AtomicUsize::new(0)); @@ -210,7 +210,7 @@ async fn compiled_discovery_requires_runtime_metadata_but_allows_unknown_capabil json!({"ID":"fixture", "Architecture":"arm64", "ServerVersion":"28.0", "OSType":"linux"}) } else { assert!(request.path.starts_with("/images/") && request.path.ends_with("/json")); - let mut catalog=nemoclaw_e2e::image_runtime::catalog(); + let mut catalog=crate::image_runtime::catalog(); match current.load(Ordering::SeqCst) { 1=>{ catalog.adapters.retain(|adapter|adapter.adapter_id()!="nvidia.fabric.openclaw"); diff --git a/crates/nemoclaw-e2e/tests/gateway_readiness.rs b/crates/nemoclaw-provider/tests/contract/gateway_readiness.rs similarity index 95% rename from crates/nemoclaw-e2e/tests/gateway_readiness.rs rename to crates/nemoclaw-provider/tests/contract/gateway_readiness.rs index 071fb64754c..bf22b28c773 100644 --- a/crates/nemoclaw-e2e/tests/gateway_readiness.rs +++ b/crates/nemoclaw-provider/tests/contract/gateway_readiness.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #![cfg(unix)] -use nemoclaw_e2e::{http_fixture as docker, openshell::Fixture, tofu::TofuWorkspace}; +use crate::{http_fixture as docker, openshell::Fixture, tofu::TofuWorkspace}; use serde_json::{Value, json}; use std::{ fs, @@ -98,7 +98,7 @@ async fn managed_gateway_exit_preserves_bootstrap_state_and_allows_recovery_or_t &["apply", "-auto-approve", "-input=false", "-no-color"], true, ); - nemoclaw_e2e::assert_same_managed_resources(&fs::read(&state_path).unwrap(), &first); + crate::assert_same_managed_resources(&fs::read(&state_path).unwrap(), &first); assert!(gateway.state.lock().unwrap().health_reads > 0); assert!(gateway.state.lock().unwrap().gateway_reads > 0); running.store(false, Ordering::SeqCst); @@ -112,7 +112,7 @@ async fn managed_gateway_exit_preserves_bootstrap_state_and_allows_recovery_or_t false, ); assert!(started.elapsed() < Duration::from_secs(5)); - nemoclaw_e2e::assert_same_managed_resources(&fs::read(&state_path).unwrap(), &first); + crate::assert_same_managed_resources(&fs::read(&state_path).unwrap(), &first); graph.as_object_mut().unwrap().remove("data"); fs::write(root.join("main.tf.json"), graph.to_string()).unwrap(); run( diff --git a/crates/nemoclaw-e2e/tests/kubernetes_hcl.rs b/crates/nemoclaw-provider/tests/contract/kubernetes_hcl.rs similarity index 99% rename from crates/nemoclaw-e2e/tests/kubernetes_hcl.rs rename to crates/nemoclaw-provider/tests/contract/kubernetes_hcl.rs index 171fa1f0cbd..e11cd936992 100644 --- a/crates/nemoclaw-e2e/tests/kubernetes_hcl.rs +++ b/crates/nemoclaw-provider/tests/contract/kubernetes_hcl.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //! Managed Kubernetes resources written in HCL, planned without a cluster. -use nemoclaw_e2e::tofu::TofuWorkspace; +use crate::tofu::TofuWorkspace; use serde_json::{Value, json}; use std::{fs, path::PathBuf}; diff --git a/crates/nemoclaw-provider/tests/contract/main.rs b/crates/nemoclaw-provider/tests/contract/main.rs new file mode 100644 index 00000000000..66cf46cc27b --- /dev/null +++ b/crates/nemoclaw-provider/tests/contract/main.rs @@ -0,0 +1,109 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 +//! Contract tests: each nemoclaw type through pinned OpenTofu against fake +//! Docker engines, gateways, and model servers. `every_type_has_a_contract_test` +//! requires one for every type the provider serves. + +#[path = "../../../test-support/http.rs"] +mod http_fixture; +/// Fabric catalog fixtures shared with the end-to-end tests. +#[path = "../../../nemoclaw-e2e/src/image_runtime.rs"] +#[allow(dead_code)] +mod image_runtime; + +mod discovery; +mod gateway_readiness; +mod kubernetes_hcl; +mod runtime_image; +mod service_storage; +mod vllm_runtime; + +pub use nemoclaw_test_fixtures::{openshell, tofu}; + +/// Failed apply may record new data-source observations and condition +/// results; its managed resources and lineage must still be preserved. +pub fn assert_same_managed_resources(actual: &[u8], expected: &[u8]) { + fn managed(bytes: &[u8]) -> (String, Vec) { + let state: serde_json::Value = serde_json::from_slice(bytes).unwrap(); + let resources = state["resources"] + .as_array() + .unwrap() + .iter() + .filter(|resource| resource["mode"] == "managed") + .cloned() + .collect(); + (state["lineage"].as_str().unwrap().into(), resources) + } + assert_eq!(managed(actual), managed(expected)); +} + +/// Types still tested only outside this binary, and why. +const ELSEWHERE: [(&str, &str); 5] = [ + ( + "gateway_storage", + "nemoclaw-e2e managed and the live Docker gateway tests, which need Docker (#12879)", + ), + ( + "managed_gateway", + "nemoclaw-e2e provider_protocol, which needs that crate's fixture provider (#12878)", + ), + ( + "service_capacity", + "nemoclaw-e2e service_capacity, which needs that crate's SSH fixture (#12878)", + ), + ( + "service_readiness", + "nemoclaw-e2e service_readiness, which needs that crate's SSH fixture (#12878)", + ), + ( + "inference_capabilities", + "nemoclaw-e2e inference_discovery, only through SDK deployments (#12879)", + ), +]; + +/// Every resource and data source the provider serves appears in a contract +/// test, or in [`ELSEWHERE`] with the reason it is not here yet. +#[test] +fn every_type_has_a_contract_test() { + use tf_provider::Provider; + let provider = nemoclaw_provider::NemoClawProvider::default(); + let mut diagnostics = tf_provider::Diagnostics::default(); + let types: Vec = provider + .get_resources(&mut diagnostics) + .unwrap() + .into_keys() + .chain( + provider + .get_data_sources(&mut diagnostics) + .unwrap() + .into_keys(), + ) + .collect(); + let sources = [ + include_str!("discovery.rs"), + include_str!("gateway_readiness.rs"), + include_str!("kubernetes_hcl.rs"), + include_str!("runtime_image.rs"), + include_str!("service_storage.rs"), + include_str!("vllm_runtime.rs"), + ] + .concat(); + let missing: Vec<_> = types + .iter() + .filter(|kind| { + !sources.contains(&format!("nemoclaw_{kind}")) + && !sources.contains(&format!("\"{kind}\"")) + && !ELSEWHERE.iter().any(|(elsewhere, _)| elsewhere == kind) + }) + .collect(); + for (kind, _) in ELSEWHERE { + assert!( + !sources.contains(&format!("nemoclaw_{kind}\"")), + "{kind} has a contract test; remove it from ELSEWHERE" + ); + } + assert!( + missing.is_empty(), + "types without a contract test: {missing:?}" + ); +} diff --git a/crates/nemoclaw-e2e/tests/runtime_image.rs b/crates/nemoclaw-provider/tests/contract/runtime_image.rs similarity index 98% rename from crates/nemoclaw-e2e/tests/runtime_image.rs rename to crates/nemoclaw-provider/tests/contract/runtime_image.rs index 2b02ce241f6..4f8dd0af2f4 100644 --- a/crates/nemoclaw-e2e/tests/runtime_image.rs +++ b/crates/nemoclaw-provider/tests/contract/runtime_image.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //! Authored runtime image checks through pinned OpenTofu. -use nemoclaw_e2e::{http_fixture::Fixture, tofu::TofuWorkspace}; +use crate::{http_fixture::Fixture, tofu::TofuWorkspace}; use nemoclaw_sdk::managed::{RUNTIME_SPEC_VERSION, RUNTIME_SPEC_VERSION_LABEL}; use serde_json::{Value, json}; use std::{ diff --git a/crates/nemoclaw-e2e/tests/service_storage.rs b/crates/nemoclaw-provider/tests/contract/service_storage.rs similarity index 99% rename from crates/nemoclaw-e2e/tests/service_storage.rs rename to crates/nemoclaw-provider/tests/contract/service_storage.rs index 4e5d28e26e8..9456d361aee 100644 --- a/crates/nemoclaw-e2e/tests/service_storage.rs +++ b/crates/nemoclaw-provider/tests/contract/service_storage.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //! Authored HCL for retained service storage through pinned OpenTofu. -use nemoclaw_e2e::{http_fixture::Fixture, tofu::TofuWorkspace}; +use crate::{http_fixture::Fixture, tofu::TofuWorkspace}; use serde_json::{Value, json}; use std::{ collections::BTreeMap, diff --git a/crates/nemoclaw-e2e/tests/vllm_runtime.rs b/crates/nemoclaw-provider/tests/contract/vllm_runtime.rs similarity index 99% rename from crates/nemoclaw-e2e/tests/vllm_runtime.rs rename to crates/nemoclaw-provider/tests/contract/vllm_runtime.rs index e9f475b3f62..0522fc5aaab 100644 --- a/crates/nemoclaw-e2e/tests/vllm_runtime.rs +++ b/crates/nemoclaw-provider/tests/contract/vllm_runtime.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //! Authored HCL for a vLLM container whose runtime contract the provider computes. -use nemoclaw_e2e::http_fixture::Fixture; +use crate::http_fixture::Fixture; use serde_json::{Value, json}; use std::{fs, path::PathBuf}; diff --git a/docs/contributing/integration-tests.md b/docs/contributing/integration-tests.md index ac10d9cdc89..68bcdbe21d9 100644 --- a/docs/contributing/integration-tests.md +++ b/docs/contributing/integration-tests.md @@ -17,7 +17,7 @@ Tests install `terraform-provider-openshell` and `terraform-provider-fabric` fro cargo build -p nemoclaw-provider -p openshell-provider -p fabric-provider NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ - cargo test -p nemoclaw-e2e --test integration provider_protocol:: -- --ignored + cargo test -p nemoclaw-provider --test contract provider_protocol:: -- --ignored ``` These tests launch a fixture provider built by that crate and use temporary files. @@ -30,7 +30,7 @@ On Unix, run from the repository root to test combined service capacity through ```sh NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ - cargo test -p nemoclaw-e2e --test integration service_capacity:: -- --ignored + cargo test -p nemoclaw-provider --test contract service_capacity:: -- --ignored ``` This fixture checks shared-host overcommit, deferred reads, preserved state after failed observations, and cleanup without capacity checks. @@ -74,6 +74,21 @@ The export fixture checks provider refresh failures through OpenTofu, unchanged The web-search lifecycle case covers Brave and Tavily at deployment, sandbox, and agent scope, including profile and sandbox-grant drift. The mixed-search export case checks shared registrations, unused definitions, export without search keys, unchanged reapply, and rejected provider-type or credential-reference drift without changes to saved state. +## NemoClaw Provider Contract + +The `nemoclaw-provider` crate's `contract` tests run its types through OpenTofu against fake Docker engines, gateways, and model servers: + +```sh +NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ +NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ +NEMOCLAW_TEST_BUNDLE=/absolute/path/to/bundle \ + cargo test -p nemoclaw-provider --test contract -- --ignored +``` + +They cover service storage, Kubernetes planning, runtime images and runtime contracts, gateway readiness, and engine and hardware discovery. +`every_type_has_a_contract_test` requires a contract test for every type the provider serves. +Its `ELSEWHERE` list names the types still tested only in `nemoclaw-e2e` and why: the managed gateway, service capacity, and service readiness tests need that crate's fixture binaries, gateway storage needs Docker, and inference capabilities are read only through SDK deployments. + ## OpenShell Provider Contract The `openshell-provider` crate's `contract` tests apply each fixture in `crates/openshell-provider/tests/contract/fixtures` through OpenTofu against a fake OpenShell gateway from `nemoclaw-test-fixtures`. @@ -127,7 +142,7 @@ On Unix, build the production provider as above and run from the repository root ```sh NEMOCLAW_TEST_TOFU=/absolute/path/to/tofu \ NEMOCLAW_TEST_PROVIDER=/absolute/path/to/terraform-provider-nemoclaw \ - cargo test -p nemoclaw-e2e --test integration service_readiness:: -- --ignored + cargo test -p nemoclaw-provider --test contract service_readiness:: -- --ignored ``` The fixture uses an isolated SSH/Docker simulator and a builtin OpenTofu consumer, without SDK deployment orchestration or a reachable OpenShell gateway. diff --git a/docs/design/fabric-management.md b/docs/design/fabric-management.md index 0453c9a01a8..f1f9f29c6f2 100644 --- a/docs/design/fabric-management.md +++ b/docs/design/fabric-management.md @@ -156,5 +156,5 @@ The [image command suite](../../image/test_agent_contract.py) exercises the same Its successful dummy health results do not qualify a real adapter’s native health or cleanup through OpenShell. The existing installed Fabric fixture adapter remains authored and packaged in Fabric. The separate dummy backend is authored in NemoClaw and exercises the image interface without Fabric. -The [discovery tests](../../crates/nemoclaw-e2e/tests/discovery.rs) read that installed discovery output and image metadata through the real OpenTofu/provider planner. +The [discovery tests](../../crates/nemoclaw-provider/tests/contract/discovery.rs) read that installed discovery output and image metadata through the real OpenTofu/provider planner. [Bundle fixtures](../contributing/integration-tests.md#opentofu-and-bundle-lifecycle) separately exercise deployment recovery, export/reapply and ownership. From 0b54c493128f32f7dd2e5d5d3d134ba9982bc28c Mon Sep 17 00:00:00 2001 From: Carlos Villela Date: Fri, 9 Oct 2026 15:26:57 -0700 Subject: [PATCH 18/18] test(fabric): build the capabilities contract test only on Unix Its fake Docker engine listens on a Unix socket, which Windows test builds lack. --- crates/fabric-provider/tests/contract/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/fabric-provider/tests/contract/main.rs b/crates/fabric-provider/tests/contract/main.rs index f2d2adfb32f..8257cfba805 100644 --- a/crates/fabric-provider/tests/contract/main.rs +++ b/crates/fabric-provider/tests/contract/main.rs @@ -4,7 +4,10 @@ //! OpenShell gateway, which runs Fabric's configure, prepare, and status //! commands, and a fake Docker engine for image capabilities. +// The fake Docker engine listens on a Unix socket. +#[cfg(unix)] mod capabilities; +#[cfg(unix)] #[path = "../../../test-support/http.rs"] mod http; mod readiness;