From 9a9165d4f1d14720700b73c05897eb3881fbe056 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 9 Oct 2026 16:05:51 +0200 Subject: [PATCH] mind-body: pin the --instance guard and the binary's refusal exit Two cargo-mutants survivors from the first run (main -> (), and the --instance match guard -> true) are killed by a malformed-command table row and a process-level test of the refused invocation. Co-Authored-By: Claude Opus 5.5 --- crates/mind-body/tests/cli.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/mind-body/tests/cli.rs b/crates/mind-body/tests/cli.rs index 3e175d2..1c01625 100644 --- a/crates/mind-body/tests/cli.rs +++ b/crates/mind-body/tests/cli.rs @@ -83,6 +83,8 @@ fn malformed_commands_are_refused_and_write_nothing() { &["--instance", "eureka", "dial", "set", "--heat", "1", "--base-cooldown-s", "60", "--base-run-usd", "1", "--extra", "1"], &["--instance", "eureka", "dial", "set", "--heat"], &["--instance", "../evil", "brake", "release"], + &["--instances", "eureka", "brake", "release"], + &["eureka", "eureka", "brake", "release"], ]; for args in bad { assert!(go(root.path(), args, "op", 0).0.is_err(), "{args:?}"); @@ -99,3 +101,12 @@ fn the_operator_is_sudo_user_then_user_then_unknown() { assert_eq!(operator_name(None, s("")), "unknown"); assert_eq!(operator_name(None, None), "unknown"); } + +#[test] +fn the_binary_exits_nonzero_with_the_usage_when_refused() { + // A refusal before any path is derived, so this never reaches /etc. + let output = std::process::Command::new(env!("CARGO_BIN_EXE_mind-control")).output().unwrap(); + assert_eq!(output.status.code(), Some(2)); + assert!(String::from_utf8_lossy(&output.stderr).contains("usage: mind-control")); + assert!(output.stdout.is_empty()); +}