lean-ctx 3.9.18

Context Runtime for AI Agents with CCP. 71 MCP tools, 10 read modes, 95+ compression patterns, cross-session memory (CCP), persistent AI knowledge with temporal facts + contradiction detection, multi-agent context sharing, 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 super::*;
use crate::core::data_dir::isolated_data_dir;

/// #406 regression: `Config::load()` must reflect a content change even when
/// the file mtime is unchanged. A mtime-only cache (the old behaviour) kept a
/// long-lived MCP server on a stale `path_jail` while a fresh `doctor`
/// process — with an empty cache — saw the new value. The cache is now keyed
/// on a content hash, so this scenario stays live.
#[test]
fn load_honors_content_change_with_preserved_mtime() {
    let _iso = isolated_data_dir();
    let path = Config::path().expect("config path under isolated data dir");
    if let Some(parent) = path.parent() {
        std::fs::create_dir_all(parent).unwrap();
    }

    // Warm the cache with jail unset (default None).
    std::fs::write(&path, "# initial\n").unwrap();
    let mtime0 = std::fs::metadata(&path).unwrap().modified().unwrap();
    assert_eq!(Config::load().path_jail, None);

    // Flip path_jail=false but restore the original mtime, so any mtime-only
    // cache would serve the stale value (#406).
    std::fs::write(&path, "path_jail = false\n").unwrap();
    filetime::set_file_mtime(&path, filetime::FileTime::from_system_time(mtime0)).unwrap();

    assert_eq!(
        Config::load().path_jail,
        Some(false),
        "Config::load() must honor a content change with unchanged mtime (#406)"
    );
}