From 9e39eb9bca541d668e865abfef736f1e12b2a2c5 Mon Sep 17 00:00:00 2001 From: Dmitriy Date: Tue, 22 Sep 2026 01:53:30 +0300 Subject: [PATCH] fix: opt in to coding-agent network access --- Cargo.lock | 6 +- Cargo.toml | 6 +- README.md | 6 + docs/how-to/serve-a-model-on-spark.md | 13 +++ docs/reference/spark.md | 49 +++++++- specs/bugs/BUG-20260922-0144.md | 79 +++++++++++++ src/spark/cli.rs | 7 +- src/spark/client.rs | 3 +- src/spark/launch.rs | 158 +++++++++++++++++++++++++- tests/standalone_cli.rs | 56 +++++++++ 10 files changed, 371 insertions(+), 12 deletions(-) create mode 100644 specs/bugs/BUG-20260922-0144.md diff --git a/Cargo.lock b/Cargo.lock index 1b4ebd8..053a430 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3063,7 +3063,7 @@ dependencies = [ [[package]] name = "sparkplane" -version = "0.1.4" +version = "0.1.5" dependencies = [ "anyhow", "arc-swap", @@ -3118,7 +3118,7 @@ dependencies = [ [[package]] name = "sparkplane-core" -version = "0.1.4" +version = "0.1.5" dependencies = [ "anyhow", "sd-notify", @@ -3132,7 +3132,7 @@ dependencies = [ [[package]] name = "sparkplane-ipc" -version = "0.1.4" +version = "0.1.5" dependencies = [ "anyhow", "bytes", diff --git a/Cargo.toml b/Cargo.toml index e17dcc9..5b05824 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [".", "crates/sparkplane-core", "crates/sparkplane-ipc"] resolver = "3" [workspace.package] -version = "0.1.4" +version = "0.1.5" edition = "2024" rust-version = "1.95" license = "MIT" @@ -22,8 +22,8 @@ tracing = "0.1" tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt", "json", "registry", "std"] } metrics = "0.24" tempfile = "3" -sparkplane-core = { path = "crates/sparkplane-core", version = "=0.1.4" } -sparkplane-ipc = { path = "crates/sparkplane-ipc", version = "=0.1.4" } +sparkplane-core = { path = "crates/sparkplane-core", version = "=0.1.5" } +sparkplane-ipc = { path = "crates/sparkplane-ipc", version = "=0.1.5" } [package] name = "sparkplane" diff --git a/README.md b/README.md index f57967a..18cf2cd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ cargo build --locked --release ./target/release/sparkplane --help ./target/release/sparkplane dgx-spark status --json ./target/release/sparkplane dgx-spark serve qwen3.8:flash-next --dry-run --json +./target/release/sparkplane dgx-spark launch codex --allow-network -- --sandbox workspace-write ``` Use the pinned Rust 1.95.0 toolchain (selected automatically by rustup), a @@ -18,6 +19,11 @@ Install the Minisign executable for the encrypted release-signing tests. The client runs on Linux x86-64/ARM64; the appliance targets Linux ARM64 with NVIDIA GB10, Docker and the NVIDIA container toolkit already installed. +Enable sandboxed internet access with `launch --allow-network`; +[agent-specific network controls](docs/reference/spark.md#internet-access-for-development) +leave filesystem and approval policies intact. Without the flag, agents retain +their existing permissions. + ## Architecture The unprivileged HTTPS agent owns state and protocol translation. A separate, diff --git a/docs/how-to/serve-a-model-on-spark.md b/docs/how-to/serve-a-model-on-spark.md index 38e66a9..9475452 100644 --- a/docs/how-to/serve-a-model-on-spark.md +++ b/docs/how-to/serve-a-model-on-spark.md @@ -84,6 +84,19 @@ healthy, and confirm the OpenAI-compatible gateway path answers. remediation. `launch` does not edit the primary Claude/OpenCode config or the main Codex config. + Add `--allow-network` when development commands need internet access: + + ```bash + sparkplane dgx-spark launch codex --allow-network -- --sandbox workspace-write + sparkplane dgx-spark launch claude --allow-network + ``` + + This is a per-launch opt-in, also available as + `SPARKPLANE_LAUNCH_ALLOW_NETWORK=true`; it does not disable filesystem + sandboxing or change approval policy. OpenCode already has network access, + so its existing tool permissions are left alone. See + [network controls and limitations](../reference/spark.md#internet-access-for-development). + 7. Stop when you are done. An already-absent instance is an idempotent success: ```bash diff --git a/docs/reference/spark.md b/docs/reference/spark.md index 2700ace..2643591 100644 --- a/docs/reference/spark.md +++ b/docs/reference/spark.md @@ -37,7 +37,7 @@ sparkplane status --json sparkplane doctor --json sparkplane qualify --manifest --signature (--dry-run | --yes) [--detach] [--json] sparkplane serve [--name ] [--detach] [--dry-run] [--json] -sparkplane launch [--model ] [--config] [--restore] [-y] [-- ...] +sparkplane launch [--model ] [--allow-network] [--config] [--restore] [-y] [-- ...] sparkplane ls [--json] sparkplane ps [--json] sparkplane logs [--limit N] @@ -253,6 +253,53 @@ inference-only token and pinned CA, never the administrator credential. Claude uses the native Anthropic route, Codex uses a Sparkplane-owned Responses profile and catalog, and OpenCode uses process-local `OPENCODE_CONFIG_CONTENT`. +### Internet access for development + +Use `--allow-network` (or `SPARKPLANE_LAUNCH_ALLOW_NETWORK=true`) when the +agent needs to download dependencies, fetch documentation or use remote APIs: + +```bash +sparkplane dgx-spark launch codex --allow-network +sparkplane dgx-spark launch claude --allow-network +``` + +The grant applies only to this invocation. It is not saved in launch state or +agent configuration, and cannot be combined with `--config` or `--restore`. +`--dry-run --json` reports the requested `allow_network` value without changing +anything. Without the flag, the agent's existing permissions remain unchanged; +Sparkplane does not impose its own workstation sandbox. + +| Agent | Effect of `--allow-network` | +| --- | --- | +| Codex | Sets `sandbox_workspace_write.network_access=true`. Filesystem sandbox mode and approval policy are unchanged. | +| Claude Code | Passes session-only `sandbox.network.allowedDomains=["*"]` through `--settings`. Filesystem restrictions and explicit domain denials remain in force. | +| OpenCode | No extra permission override: OpenCode already has direct network access. Existing shell, web-fetch and other tool approval rules remain in force. | + +For Codex, the network setting applies to `workspace-write` sessions. If the +workspace is not trusted or Codex is configured read-only, explicitly select +the development sandbox with `-- --sandbox workspace-write`. Named permission +profiles, managed organization restrictions and explicit forwarded overrides +can impose different policies; this flag does not bypass them. It does not +enable the hosted Responses web-search tool, which the model gateway does not +provide. Commands such as `curl`, package managers and Git can use the network. + +Do not combine Claude's forwarded `--settings` with `--allow-network`: the +launcher rejects that ambiguous combination before contacting the appliance. +Use normal Claude settings files for other settings, or omit the flag and pass +your complete session settings yourself. + +Codex receives its pinned Spark CA through `CODEX_CA_CERTIFICATE`, not a +launcher-supplied `SSL_CERT_FILE`. This keeps private inference TLS verification +separate from the public/system CA trust used by development subprocesses. +Existing user-supplied certificate and proxy settings are not erased. + +Internet access lets subprocesses transmit data they can read; opt in only for +trusted work. This option changes neither the inference-token scope nor the +appliance's private engine networking. Agent controls are documented in the +[Codex sandbox configuration](https://developers.openai.com/codex/security), +[Claude sandbox guide](https://code.claude.com/docs/en/sandboxing), and +[OpenCode permissions reference](https://opencode.ai/docs/permissions/). + ## Examples ```bash diff --git a/specs/bugs/BUG-20260922-0144.md b/specs/bugs/BUG-20260922-0144.md new file mode 100644 index 0000000..f619564 --- /dev/null +++ b/specs/bugs/BUG-20260922-0144.md @@ -0,0 +1,79 @@ +# BUG-20260922-0144: Coding-agent launches cannot reach the internet + +## Summary + +Sparkplane needs an explicit per-launch internet opt-in without disabling the +coding agent's filesystem sandbox or weakening the appliance's private network. + +## Reproduction + +On Codex 0.155.1, run from a development checkout: + +```sh +codex sandbox -c 'sandbox_mode="workspace-write"' -- \ + curl --fail --max-time 10 https://example.com +``` + +The command fails with `Could not resolve host: example.com`. Adding +`-c sandbox_workspace_write.network_access=true` succeeds. With Sparkplane's +inherited `SSL_CERT_FILE` pointing at the Spark CA, the network-enabled command +instead fails with `unable to get local issuer certificate`. Using +`CODEX_CA_CERTIFICATE` for that CA succeeds without replacing curl's trust store. + +## Expected + +`sparkplane dgx-spark launch codex --allow-network` permits network access for +workspace-sandboxed development commands. Default launch permissions are +unchanged. The option also configures Claude's sandbox domain allowlist; +OpenCode already has direct network access and retains its tool permissions. + +## Actual + +The launcher has no network opt-in and exports a process-wide private trust store. + +## Root cause + +The launcher directly executes local agents, which own their sandbox policy. +Codex disables network access in its workspace sandbox by default. Additionally, +exporting `SSL_CERT_FILE` to the entire child process tree replaces public CA +trust for development tools. Neither failure is in the GPU engine network. + +## Fix + +Add invocation-only `--allow-network` / `SPARKPLANE_LAUNCH_ALLOW_NETWORK`. +Use each agent's narrow network setting, leave filesystem and approval policy +alone, and retain managed policy restrictions. Reject configuration-only and +restore combinations rather than silently persisting an access grant. Use +`CODEX_CA_CERTIFICATE` for Codex-specific private CA trust. + +## Traceability + +- CLI regressions: `tests/standalone_cli.rs`. +- Adapter and CA regressions: `src/spark/launch.rs`, `src/spark/client.rs`. +- Manual verification: the Codex sandbox commands above (no model invocation). + +## Verification + +- CLI tests cover the flag, environment equivalent, forwarded arguments, + conflicting Claude settings, and rejection of persistent/restore grants. +- Adapter tests cover default permissions, Codex/Claude network-only overrides, + unchanged OpenCode permissions, and Codex-specific CA scoping. +- The optional native sandbox regression was executed successfully on Codex + 0.155.1: default DNS is blocked, opted-in public HTTPS returns 200, and attempted + writes outside the workspace fail in both cases. + +```sh +cargo test --locked --lib native_codex_network_opt_in_keeps_filesystem_confinement -- --ignored +make lint +make test +make test-client +make audit +``` + +The live launch dry-run reused the healthy `qwen38-vllm` instance and reported +`allow_network: true`; the environment-variable form was checked separately. +The production launch path also delivered the scoped CA to a Codex sandbox +diagnostic: HTTPS returned 200 and the workstation configuration remained +read-only. Codex's `sandbox` diagnostic reads subcommand-local configuration, +so this particular probe repeats the network override after `sandbox`; ordinary +TUI/exec launches receive the root-level override directly. diff --git a/src/spark/cli.rs b/src/spark/cli.rs index f1a228d..0d82ca5 100644 --- a/src/spark/cli.rs +++ b/src/spark/cli.rs @@ -123,7 +123,7 @@ pub enum SparkCommand { Serve(ServeArgs), /// Configure and launch a local coding agent against a managed Spark model. #[command( - after_help = "Examples:\n sparkplane dgx-spark launch codex --model ornith-1.5:35b\n sparkplane dgx-spark launch claude --model ornith-1.5:35b -- --permission-mode plan\n sparkplane dgx-spark launch opencode --config --model ornith-1.5:35b\n sparkplane dgx-spark launch codex --model ornith-1.5:35b --dry-run --json\n\nArguments after `--` are passed directly to the selected local agent without a shell. The Spark administrator credential is never given to the child process.\n\nEnvironment:\n SPARKPLANE_LAUNCH_MODEL, SPARKPLANE_LAUNCH_CONFIG, SPARKPLANE_LAUNCH_RESTORE, SPARKPLANE_YES, SPARKPLANE_DRY_RUN, SPARKPLANE_JSON, SPARKPLANE_CONFIG_DIR" + after_help = "Examples:\n sparkplane dgx-spark launch codex --model ornith-1.5:35b\n sparkplane dgx-spark launch codex --allow-network -- --sandbox workspace-write\n sparkplane dgx-spark launch claude --model ornith-1.5:35b -- --permission-mode plan\n sparkplane dgx-spark launch opencode --config --model ornith-1.5:35b\n sparkplane dgx-spark launch codex --model ornith-1.5:35b --dry-run --json\n\nArguments after `--` are passed directly to the selected local agent without a shell. The Spark administrator credential is never given to the child process.\n\n--allow-network requests invocation-only network access: Codex workspace-write networking, or Claude sandbox domains. OpenCode already has network access; its tool permissions remain unchanged. Filesystem sandboxing and approval policies are not disabled. Managed restrictions still apply. Claude --settings cannot be forwarded with this flag.\n\nEnvironment:\n SPARKPLANE_LAUNCH_MODEL, SPARKPLANE_LAUNCH_ALLOW_NETWORK, SPARKPLANE_LAUNCH_CONFIG, SPARKPLANE_LAUNCH_RESTORE, SPARKPLANE_YES, SPARKPLANE_DRY_RUN, SPARKPLANE_JSON, SPARKPLANE_CONFIG_DIR" )] Launch(LaunchArgs), /// List currently active managed model processes. @@ -427,6 +427,9 @@ impl LaunchIntegration { pub struct LaunchArgs { #[arg(value_enum)] pub integration: LaunchIntegration, + /// Allow this agent session's sandbox network access; keep filesystem and approval policies. + #[arg(long, env = "SPARKPLANE_LAUNCH_ALLOW_NETWORK", conflicts_with_all = ["configure", "restore"])] + pub allow_network: bool, #[arg(long, env = "SPARKPLANE_LAUNCH_MODEL")] pub model: Option, #[arg(long = "config", env = "SPARKPLANE_LAUNCH_CONFIG")] @@ -2723,6 +2726,7 @@ mod tests { "codex", "--model", "ornith-1.5:9b", + "--allow-network", "--", "--sandbox", "workspace-write", @@ -2732,6 +2736,7 @@ mod tests { panic!("launch command should parse"); }; assert_eq!(args.extra_args, ["--sandbox", "workspace-write"]); + assert!(args.allow_network); } #[test] diff --git a/src/spark/client.rs b/src/spark/client.rs index 39ed1d7..9b870cc 100644 --- a/src/spark/client.rs +++ b/src/spark/client.rs @@ -183,7 +183,7 @@ fn build_codex_config( base_url, env_key: ENV_KEY.into(), wire_api: "responses".into(), - ca_env_key: "SSL_CERT_FILE".into(), + ca_env_key: "CODEX_CA_CERTIFICATE".into(), ca_path: config_dir.join("spark").join(format!("{host}.ca.pem")), config_path: "$CODEX_HOME/config.toml (defaults to ~/.codex/config.toml)".into(), toml, @@ -1037,6 +1037,7 @@ mod tests { let parsed: toml::Value = toml::from_str(&config.toml).unwrap(); assert_eq!(parsed["web_search"].as_str(), Some("disabled")); assert_eq!(config.base_url, "https://10.1.30.143:9843/openai/ornith/v1"); + assert_eq!(config.ca_env_key, "CODEX_CA_CERTIFICATE"); } #[test] diff --git a/src/spark/launch.rs b/src/spark/launch.rs index 9211535..5bc91c4 100644 --- a/src/spark/launch.rs +++ b/src/spark/launch.rs @@ -43,6 +43,7 @@ struct LaunchPlan { action: &'static str, token_id: Option, extra_argument_count: usize, + allow_network: bool, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -178,6 +179,7 @@ pub fn run(host: &str, config_dir: &Path, args: LaunchArgs) -> Result<(), Client action: if reused_instance { "reuse" } else { "serve" }, token_id: None, extra_argument_count: args.extra_args.len(), + allow_network: args.allow_network, }, args.json, ); @@ -251,6 +253,7 @@ pub fn run(host: &str, config_dir: &Path, args: LaunchArgs) -> Result<(), Client }, token_id: Some(token_id), extra_argument_count: args.extra_args.len(), + allow_network: args.allow_network, }; if args.configure { return render_plan(&plan, args.json); @@ -262,9 +265,15 @@ pub fn run(host: &str, config_dir: &Path, args: LaunchArgs) -> Result<(), Client model.canonical, instance.name ); + if args.allow_network { + eprintln!( + "Network access requested for this invocation; filesystem and approval policies are unchanged." + ); + } launch_child( args.integration, args.yes, + args.allow_network, ReadyLaunch { config_dir, host, @@ -277,6 +286,22 @@ pub fn run(host: &str, config_dir: &Path, args: LaunchArgs) -> Result<(), Client } fn validate_args(args: &LaunchArgs) -> Result<(), ClientError> { + if args.allow_network && (args.configure || args.restore) { + return Err(usage( + "--allow-network is invocation-only; it cannot be combined with --config or --restore", + )); + } + if args.allow_network + && args.integration == LaunchIntegration::Claude + && args + .extra_args + .iter() + .any(|arg| arg == "--settings" || arg.starts_with("--settings=")) + { + return Err(usage( + "--allow-network manages Claude --settings; put other settings in your normal Claude settings file, or omit --allow-network and pass the complete --settings yourself", + )); + } if args.restore && (args.model.is_some() || args.configure @@ -610,14 +635,35 @@ fn codex_catalog(model: &ModelDocument, context_window: u64) -> Value { }) } +fn configure_network_access(command: &mut Command, integration: LaunchIntegration, allow: bool) { + if !allow { + return; + } + match integration { + LaunchIntegration::Codex => { + command.args(["-c", "sandbox_workspace_write.network_access=true"]); + } + LaunchIntegration::Claude => { + command.args([ + "--settings", + r#"{"sandbox":{"network":{"allowedDomains":["*"]}}}"#, + ]); + } + // OpenCode has no network sandbox; retain its independent tool permissions. + LaunchIntegration::Opencode => {} + } +} + fn launch_child( integration: LaunchIntegration, yes: bool, + allow_network: bool, launch: ReadyLaunch<'_>, extra_args: &[String], ) -> Result<(), ClientError> { let executable = ensure_executable(integration, yes)?; let mut command = Command::new(executable); + configure_network_access(&mut command, integration, allow_network); command .stdin(Stdio::inherit()) .stdout(Stdio::inherit()) @@ -739,7 +785,7 @@ fn configure_codex_command( .args(extra_args) .env("SPARKPLANE_INFERENCE_TOKEN", token.expose()) .env("OPENAI_API_KEY", token.expose()) - .env("SSL_CERT_FILE", config.ca_path); + .env(&config.ca_env_key, config.ca_path); Ok(()) } @@ -1127,8 +1173,17 @@ fn render_plan(plan: &LaunchPlan, json: bool) -> Result<(), ClientError> { ); } else { println!( - "{} {} with {} on {} ({})", - plan.action, plan.integration, plan.model, plan.instance, plan.host + "{} {} with {} on {} ({}; network={})", + plan.action, + plan.integration, + plan.model, + plan.instance, + plan.host, + if plan.allow_network { + "requested" + } else { + "agent-default" + } ); } Ok(()) @@ -1228,6 +1283,95 @@ mod tests { } } + #[test] + fn network_opt_in_only_changes_codex_network_setting() { + let mut command = Command::new("codex"); + configure_network_access(&mut command, LaunchIntegration::Codex, true); + let args: Vec<_> = command.get_args().collect(); + assert_eq!(args, ["-c", "sandbox_workspace_write.network_access=true"]); + } + + #[test] + fn network_opt_in_only_changes_claude_domain_allowlist() { + let mut command = Command::new("claude"); + configure_network_access(&mut command, LaunchIntegration::Claude, true); + let args: Vec<_> = command.get_args().collect(); + assert_eq!( + args, + [ + "--settings", + r#"{"sandbox":{"network":{"allowedDomains":["*"]}}}"# + ] + ); + } + + #[test] + fn default_launch_does_not_override_any_agents_permissions() { + for integration in [ + LaunchIntegration::Codex, + LaunchIntegration::Claude, + LaunchIntegration::Opencode, + ] { + let mut command = Command::new(integration.as_str()); + configure_network_access(&mut command, integration, false); + assert_eq!(command.get_args().count(), 0); + } + } + + #[test] + fn opencode_network_opt_in_preserves_existing_tool_permissions() { + let mut command = Command::new("opencode"); + configure_network_access(&mut command, LaunchIntegration::Opencode, true); + assert_eq!(command.get_args().count(), 0); + assert_eq!(command.get_envs().count(), 0); + } + + #[cfg(target_os = "linux")] + #[test] + #[ignore = "requires Codex 0.155.1+, curl, Linux sandbox support and public HTTPS access"] + fn native_codex_network_opt_in_keeps_filesystem_confinement() { + let root = tempfile::tempdir().unwrap(); + let workspace = root.path().join("workspace"); + let outside = root.path().join("outside-workspace"); + let codex_config = root.path().join("codex"); + fs::create_dir(&workspace).unwrap(); + fs::create_dir(&codex_config).unwrap(); + for allow in [false, true] { + let mut command = Command::new("codex"); + // The diagnostic subcommand reads its own overrides, unlike TUI/exec. + command.arg("sandbox"); + configure_network_access(&mut command, LaunchIntegration::Codex, allow); + let output = command.current_dir(&workspace) + .env("CODEX_HOME", &codex_config) + .env_remove("SSL_CERT_FILE").env_remove("CODEX_CA_CERTIFICATE") + .args(["-c", "sandbox_mode=\"workspace-write\"", + "-c", "sandbox_workspace_write.exclude_slash_tmp=true", + "-c", "sandbox_workspace_write.exclude_tmpdir_env_var=true", "--", "sh", "-c", + "if touch \"$1\" 2>/dev/null; then exit 99; fi; curl --silent --show-error --fail --max-time 15 --output /dev/null --write-out '%{http_code}' https://example.com", + "network-probe"]) + .arg(&outside).output().unwrap(); + assert!( + !outside.exists(), + "network permission must not grant outside writes" + ); + if allow { + assert!( + output.status.success(), + "{}", + String::from_utf8_lossy(&output.stderr) + ); + assert_eq!(output.stdout, b"200"); + } else { + assert_eq!( + output.status.code(), + Some(6), + "{}", + String::from_utf8_lossy(&output.stderr) + ); + } + } + } + #[test] fn exact_alias_resolves_one_verified_model() { let expected = model("m_one", "ornith-1.5:9b"); @@ -1351,6 +1495,13 @@ mod tests { .get_args() .map(|value| value.to_string_lossy().into_owned()) .collect::>(); + assert_eq!(command_env(&command, "SSL_CERT_FILE"), None); + assert_eq!( + command_env(&command, "CODEX_CA_CERTIFICATE"), + Some(Some( + root.path().join("spark/dgx.ca.pem").display().to_string() + )) + ); assert!( arguments .windows(2) @@ -1499,6 +1650,7 @@ mod tests { fn restore_flags_cannot_be_combined() { let args = LaunchArgs { integration: LaunchIntegration::Codex, + allow_network: false, model: Some("ornith".into()), configure: false, restore: true, diff --git a/tests/standalone_cli.rs b/tests/standalone_cli.rs index 1603de4..a42e615 100644 --- a/tests/standalone_cli.rs +++ b/tests/standalone_cli.rs @@ -1,5 +1,61 @@ use std::process::Command; +#[test] +fn launch_help_exposes_opt_in_network_access() { + let output = Command::new(env!("CARGO_BIN_EXE_sparkplane")) + .args(["dgx-spark", "launch", "codex", "--help"]) + .output() + .unwrap(); + assert!(String::from_utf8_lossy(&output.stdout).contains("--allow-network")); +} + +#[test] +fn network_opt_in_rejects_shadowing_claude_settings_before_contacting_spark() { + let root = tempfile::tempdir().unwrap(); + let output = Command::new(env!("CARGO_BIN_EXE_sparkplane")) + .env_clear() + .env("SPARKPLANE_CONFIG_DIR", root.path()) + .args([ + "dgx-spark", + "launch", + "claude", + "--allow-network", + "--", + "--settings", + "{}", + ]) + .output() + .unwrap(); + assert_eq!(output.status.code(), Some(2)); + assert!( + String::from_utf8_lossy(&output.stderr) + .contains("--allow-network manages Claude --settings") + ); +} + +#[test] +fn network_grants_cannot_be_saved_or_combined_with_restore() { + for mode in ["--config", "--restore"] { + for flag in [true, false] { + let root = tempfile::tempdir().unwrap(); + let mut command = Command::new(env!("CARGO_BIN_EXE_sparkplane")); + command + .env_clear() + .env("SPARKPLANE_CONFIG_DIR", root.path()) + .args(["dgx-spark", "launch", "codex", mode]); + if flag { + command.arg("--allow-network"); + } else { + command.env("SPARKPLANE_LAUNCH_ALLOW_NETWORK", "true"); + } + let output = command.output().unwrap(); + assert_eq!(output.status.code(), Some(2)); + assert!(String::from_utf8_lossy(&output.stderr).contains("--allow-network")); + assert_eq!(std::fs::read_dir(root.path()).unwrap().count(), 0); + } + } +} + #[test] fn bridge_protocol_is_available_without_a_host_or_configuration() { let output = Command::new(env!("CARGO_BIN_EXE_sparkplane"))