/// Hydrate context strings with matching vault facts.
pub fn hydrate(context: &str, facts: &[crate::fact::MemoFact]) -> String {
    if facts.is_empty() {
        return context.to_string();
    }
    let fact_section: Vec<String> = facts
        .iter()
        .map(|f| format!("[memory:{}] {}: {}", f.tier_name(), f.key, f.value))
        .collect();
    format!(
        "{}\n\n--- vault context ---\n{}",
        context,
        fact_section.join("\n")
    )
}

impl crate::fact::MemoFact {
    pub fn tier_name(&self) -> &'static str {
        match self.tier {
            crate::fact::MemoryTier::Immediate => "immediate",
            crate::fact::MemoryTier::Resonant => "resonant",
            crate::fact::MemoryTier::Crystallized => "crystallized",
            crate::fact::MemoryTier::Dormant => "dormant",
            crate::fact::MemoryTier::Phantom => "phantom",
        }
    }
}
