Fixed
- RAM Guardian now performs real cache eviction under memory pressure (#300): Previously, the
memory_guardeviction callback only calledjemalloc_purge(), which returns already-freed pages to the OS but never evicts actual data (SessionCache, BM25 index, etc.). Now a newEvictionOrchestratorbridges the RSS-based memory guardian to theHomeostasisController, enabling 5-stage graduated eviction: trim compressed outputs → evict probationary entries → unload BM25 index → evict protected entries → emergency full cache clear. jemalloc_purge()error handling: Previously swallowed errors withlet _ =. Now logs failures viatracing::debugfor diagnosability.is_under_pressure()no longer expensive in hot loops: Was callingMemorySnapshot::capture()(which doesConfig::load()+ syscalls) on every invocation in BM25/graph index builders. Now reads a cachedAtomicU8flag set by the guardian thread — O(1) with zero allocations.
Added
EvictionOrchestrator(core/eviction_orchestrator.rs): New module connectingmemory_guard(RSS monitoring) toHomeostasisController(graduated eviction). HoldsArcreferences toSessionCacheandSharedBm25Cache, executes eviction actions with non-blockingtry_read/try_writeto avoid stalling the guardian thread.- SessionCache eviction methods:
trim_compressed_outputs(),evict_probationary(),evict_to_budget(),approximate_bytes(),trim_shared_blocks()— enable fine-grained memory reclamation under pressure. - BM25 cache management:
bm25_cache::unload()drops the cached index (rebuilt on next search),bm25_cache::memory_usage()reports current heap usage. - Doctor pressure hints: RAM Guardian check now shows the active pressure level and recommends
memory_profile = "low"or increasingmax_ram_percentwhen under pressure.
Upgrade
lean-ctx update # recommended (auto-downloads + refreshes shell hooks)
cargo install lean-ctx # or
npm update -g lean-ctx-bin # or
brew upgrade lean-ctxNote: After upgrading via cargo/npm/brew, run
lean-ctx setupto refresh shell aliases.lean-ctx updatedoes this automatically.
Full Changelog: v3.6.21...v3.6.21