lean-ctx 3.5.7

Context Runtime for AI Agents with CCP. 57 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing + diaries, LITM-aware positioning, AAAK compact format, adaptive compression with Thompson Sampling bandits. Supports 24 AI tools. Reduces LLM token consumption by up to 99%.
Documentation
use crate::core::memory_policy::MemoryPolicy;

pub fn load_policy_or_error() -> Result<MemoryPolicy, String> {
    let cfg = crate::core::config::Config::load();
    let path = crate::core::config::Config::path().map_or_else(
        || "~/.lean-ctx/config.toml".to_string(),
        |p| p.display().to_string(),
    );

    let mut policy = cfg
        .memory_policy_effective()
        .map_err(|e| format!("Error: invalid memory policy: {e}\nFix: edit {path}"))?;

    let profile = crate::core::profiles::active_profile();
    policy.apply_overrides(&profile.memory);
    policy
        .validate()
        .map_err(|e| format!("Error: invalid memory policy: {e}\nFix: edit {path}"))?;

    Ok(policy)
}