use crate::brain::memory_recall::recall_from;
const MEMORY: &str = "\
# Memory
## Build workflow
Use clippy with all features. Never plain cargo check.
## Telegram owner gate
Only the owner sees channel commands. Non-owners get an ephemeral rejection.
## Release workflow
Tag builds run on five platforms and publish after all of them pass.
";
#[test]
fn a_relevant_message_recalls_the_matching_section() {
let recall = recall_from(
MEMORY,
"how does the telegram owner gate behave for non-owners?",
)
.expect("a clearly relevant message must recall something");
assert!(recall.contains("ephemeral rejection"), "{recall}");
assert!(
recall.contains("MEMORY.md"),
"recall must be labelled as memory, not read as the user's own words: {recall}"
);
}
#[test]
fn an_unrelated_message_recalls_nothing() {
assert!(recall_from(MEMORY, "what is the weather in Lisbon today?").is_none());
}
#[test]
fn a_single_shared_word_is_not_enough() {
assert!(
recall_from(MEMORY, "tell me about the workflow").is_none(),
"a lone common term must not trigger recall"
);
}
#[test]
fn two_distinct_terms_do_trigger_recall() {
let recall = recall_from(MEMORY, "remind me of the release workflow platforms")
.expect("two matching terms is a real signal");
assert!(recall.contains("five platforms"), "{recall}");
}
#[test]
fn a_system_continuation_never_recalls() {
assert!(
recall_from(
MEMORY,
"[System: Your last response claimed work but produced no tool calls]"
)
.is_none()
);
}
#[test]
fn recall_points_back_at_the_full_read() {
let recall = recall_from(MEMORY, "the telegram owner gate rejection").unwrap();
assert!(
recall.contains("Load MEMORY.md"),
"must offer the deliberate read as a way to get more: {recall}"
);
}
#[test]
fn an_empty_memory_file_recalls_nothing() {
assert!(recall_from("", "the telegram owner gate rejection").is_none());
}
#[test]
fn recall_stays_bounded() {
let mut big = String::new();
for i in 0..40 {
big.push_str(&format!(
"## Telegram rule {i}\n\nTelegram owner gate detail number {i}.\n\n"
));
}
let recall = recall_from(&big, "telegram owner gate").unwrap();
assert!(
recall.chars().count() < 1600,
"recall grew to {} chars",
recall.chars().count()
);
}