use std::path::Path;
#[test]
fn session_assembles_tools_in_one_place() {
let p = Path::new(env!("CARGO_MANIFEST_DIR")).join("src/app/chat/session.rs");
if !p.exists() {
eprintln!("skip: {} not present (packaged crate?)", p.display());
return;
}
let src = std::fs::read_to_string(&p).expect("read src/app/chat/session.rs");
let with_tool_sites = src.matches(".with_tool(").count();
assert_eq!(
with_tool_sites, 1,
"session.rs must register tools ONLY via the wire_shared_session! loop \
(found {with_tool_sites} `.with_tool(` sites) — add new chat tools to \
chat_toolset(), not to a backend branch"
);
assert_eq!(src.matches("fn chat_toolset(").count(), 1, "one chat_toolset definition");
let mentions = src.matches("chat_toolset(").count();
assert!(
mentions >= 3, "both backend branches must build their tools via chat_toolset() \
(found {mentions} `chat_toolset(` occurrences, need the def + 2 calls)"
);
for t in ["create_subdomain_tool()", "spawn_recursive_subagent_tool(key"] {
assert_eq!(src.matches(t).count(), 1, "`{t}` must appear exactly once (in chat_toolset)");
}
}