use crate::brain::feedback_policy::is_recoverable_tool_failure;
#[test]
fn hashline_stale_hash_is_recoverable() {
assert!(is_recoverable_tool_failure(
"hashline_edit",
Some("Hash #EJ not found in file. The file may have changed since your last read.")
));
assert!(is_recoverable_tool_failure(
"hashline_edit",
Some("Hash collision on #NH across 9 lines")
));
}
#[test]
fn channel_send_not_connected_is_recoverable() {
assert!(is_recoverable_tool_failure(
"telegram_send",
Some("Telegram is not connected. Ask the user to connect Telegram first.")
));
assert!(is_recoverable_tool_failure(
"whatsapp_send",
Some("not connected")
));
assert!(is_recoverable_tool_failure(
"discord_connect",
Some("failed to connect to gateway")
));
}
#[test]
fn follow_up_question_cancel_is_recoverable() {
assert!(is_recoverable_tool_failure(
"follow_up_question",
Some("user cancelled the prompt")
));
assert!(is_recoverable_tool_failure(
"follow_up_question",
Some("timed out waiting for an answer")
));
assert!(is_recoverable_tool_failure(
"follow_up_question",
Some("user declined")
));
}
#[test]
fn genuine_defects_are_not_recoverable() {
assert!(!is_recoverable_tool_failure(
"hashline_edit",
Some("internal panic: index out of bounds")
));
assert!(!is_recoverable_tool_failure(
"bash",
Some("command not found: frobnicate")
));
assert!(!is_recoverable_tool_failure(
"telegram_send",
Some("unknown action 'list_channels'")
));
}
#[test]
fn missing_error_text_is_not_recoverable() {
assert!(!is_recoverable_tool_failure("hashline_edit", None));
assert!(!is_recoverable_tool_failure("follow_up_question", None));
}
#[test]
fn unrelated_tools_are_never_auto_recoverable() {
assert!(!is_recoverable_tool_failure(
"read_file",
Some("file not found")
));
}