use super::*;
#[test]
fn the_ten_names_are_engine_acts_and_nothing_else_is() {
assert_eq!(
NAMES,
[
"write_summary",
"mark_for_deletion",
"dispatch",
"message",
"load_skill",
"cd",
"python",
"remember",
"search_history",
"read_tool_output",
]
);
assert!(NAMES.iter().copied().all(is));
for machine_work in ["bash", "read_file", "apply_patch", "Bash", "Python"] {
assert!(!is(machine_work), "{machine_work} is not an engine act");
}
assert!(!is("write_summary_2"));
}
#[test]
fn an_engine_act_never_reaches_an_enrolled_thralls_mailbox() {
let root = TempDir::new().expect("tmp");
loaded::add(
root.path(),
"home",
"dulcet-mongoose",
&[loaded::Entry {
client: "laptop".to_owned(),
tool: tool("Bash"),
}],
)
.expect("loaded");
let door = front_door(root.path(), "printf marked");
let input = json!({"path": "messages/004-user.md"});
let stop = AtomicBool::new(false);
let capture = Injection::new(
root.path().to_path_buf(),
door,
budget(),
budget(),
FakeClock::new().arc(),
)
.route(act!("mark_for_deletion", root.path(), &input, &stop));
assert_eq!(capture.exit_code, 0);
assert_eq!(capture.stdout, b"marked");
assert!(
deposit::pending(root.path()).is_empty(),
"an engine act queues nothing at the engine"
);
}
#[test]
fn a_foot_never_sees_python_remember_or_search_history() {
let root = TempDir::new().expect("tmp");
loaded::add(
root.path(),
"home",
"dulcet-mongoose",
&[
loaded::Entry {
client: "laptop".to_owned(),
tool: tool("python"),
},
loaded::Entry {
client: "laptop".to_owned(),
tool: tool("remember"),
},
loaded::Entry {
client: "laptop".to_owned(),
tool: tool("search_history"),
},
],
)
.expect("loaded");
let door = front_door(root.path(), "printf '%s|%s' \"$1\" \"$2\"");
let stop = AtomicBool::new(false);
for (name, input) in [
("python", json!({"program": "print(1)"})),
("remember", json!({"fact": "the wire is mutual TLS"})),
("search_history", json!({"pattern": "the wedge"})),
] {
let capture = Injection::new(
root.path().to_path_buf(),
door.clone(),
budget(),
budget(),
FakeClock::new().arc(),
)
.route(act!(name, root.path(), &input, &stop));
assert_eq!(capture.exit_code, 0, "{name}");
assert_eq!(
String::from_utf8_lossy(&capture.stdout),
format!("tool|{name}"),
"{name} is performed at the engine's own front door"
);
assert!(
deposit::pending(root.path()).is_empty(),
"{name} queued something at the engine"
);
}
}
#[test]
fn every_spawn_carries_the_invocations_own_id() {
let root = TempDir::new().expect("tmp");
let door = front_door(root.path(), "printf '%s' \"$LITANY_TOOL_ID\"");
let input = json!({"program": "print(1)"});
let stop = AtomicBool::new(false);
let capture = perform(
&door,
budget().span(),
&act!("python", root.path(), &input, &stop),
);
assert_eq!(capture.exit_code, 0);
assert_eq!(String::from_utf8_lossy(&capture.stdout), "toolu_9");
}