use crate::brain::agent::service::phantom::{all_calls_were_null_effect, is_null_effect_command};
fn call(command: &str) -> String {
serde_json::json!({ "command": command }).to_string()
}
#[test]
fn the_observed_theatre_is_recognised() {
let turn = vec![
call("echo \"calling telegram_send send_document next\""),
call("true"),
call("echo \"attempting telegram_send\""),
];
assert!(all_calls_were_null_effect(&turn));
}
#[test]
fn one_real_call_is_enough_to_vouch() {
let turn = vec![
call("true"),
call("ls -la /srv/app"),
call("echo \"about to run tests\""),
];
assert!(!all_calls_were_null_effect(&turn));
}
#[test]
fn a_turn_with_no_calls_is_not_reported_here() {
assert!(!all_calls_were_null_effect(&[]));
}
#[test]
fn a_non_shell_tool_is_always_real_work() {
let turn = vec![serde_json::json!({ "path": "src/main.rs" }).to_string()];
assert!(!all_calls_were_null_effect(&turn));
}
#[test]
fn no_ops_are_null() {
assert!(is_null_effect_command("true"));
assert!(is_null_effect_command(":"));
assert!(is_null_effect_command(" "));
}
#[test]
fn a_bare_echo_of_a_literal_is_null() {
assert!(is_null_effect_command("echo \"attempting telegram_send\""));
assert!(is_null_effect_command("echo hello"));
}
#[test]
fn an_echo_that_writes_a_file_is_real_work() {
assert!(!is_null_effect_command("echo \"content\" > out.txt"));
assert!(!is_null_effect_command("echo \"a\" >> log.txt"));
assert!(!is_null_effect_command("echo hi | tee f.txt"));
}
#[test]
fn an_echo_whose_output_is_consumed_is_real_work() {
assert!(!is_null_effect_command("echo hi && cargo test"));
assert!(!is_null_effect_command("echo hi; ls"));
assert!(!is_null_effect_command("echo $(git rev-parse HEAD)"));
}
#[test]
fn an_echo_reading_state_is_real_work() {
assert!(!is_null_effect_command("echo $HOME"));
}
#[test]
fn ordinary_commands_are_never_null() {
for cmd in [
"ls -la",
"cargo test --all-features",
"git status --short",
"grep -rn foo src/",
] {
assert!(!is_null_effect_command(cmd), "must be real work: {cmd}");
}
}