Added
- Process concurrency guard — New
process_guardmodule limits concurrentlean-ctxprocesses to 4 viaflock/fcntlslot locks, preventing CPU saturation when multiple agents trigger simultaneous operations. - Terse pipeline input cap & timeout —
compress()now skips inputs >64KB and enforces a 500ms deadline with per-stage budget checks, preventing runaway CPU on large outputs (#210). - Trigram set cap —
scoring.rslimits theseen_trigramsHashSet to 10,000 entries, preventing unbounded memory growth on large inputs. - Property-based compression tests — Added
proptestdev-dependency with invariant tests:safeguard_rationever inflates,entropy_compressnever exceeds original tokens,compress_outputnever inflates, and entropy output is a subset of input lines. - Canonical rules policy — New
rules_canonical.rsmodule provides a single source of truth for all rule generation (MUST USE / NEVER USE tables, MCP instructions) across Hybrid and MCP modes. - Contract tests for rules consistency — 11 cross-IDE contract tests verify generated rules contain MUST/NEVER language, no contradictions between Hybrid/MCP modes, and correct tool mappings.
- MCP JSON
instructionsfield — Editor MCP configs now include aninstructionsfield (where clients support it) with the canonical lean-ctx tool policy, truncated per client constraints.
Changed
- Rules language strengthened — All rule templates,
.cursorrules, MDC files, and SKILL.md now useCRITICAL: ALWAYS,MUST USE, andNEVER USEinstead ofPREFER/should. Ensures agents treat lean-ctx tool usage as mandatory. - Background index throttled —
spawn_index_build_backgroundnow runs withnice -n 19andionice -c 3(Linux) to prevent CPU contention during setup. - env.sh self-heal hardened — Container self-heal logic now includes a 60-second cooldown and PID-lock check (max 4 concurrent), preventing heal loops in multi-shell environments.
- Dictionary optimization —
apply_dictionariesperforms case-insensitivecontains()check beforereplace_whole_word, reducing unnecessary string operations. - Quality gate optimization —
extract_identifierscapped at 200 entries; identifier lookup incheck()uses HashSet instead of linearcontains(). - Entropy compression safeguard —
entropy_compressnow falls back to the original content when compression would inflate token count.
Fixed
- 100% CPU on
tersewith large inputs (#210) — Combination of input cap, timeout budget, trigram cap, and process guard eliminates all known CPU hotspot scenarios. - Stale
include_str!paths in integration tests —security_hardening.rsandsecurity_resolve_path_guard.rsupdated to reference modularized file locations (session/state.rs,tools/server_paths.rs, registry-only dispatch). - Clippy warnings — Fixed
map().flatten()→and_then(), needless borrows, trailing commas, raw string hashes, andlet...elsepatterns across multiple files.
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.5.25...v3.5.25