pub struct Config {Show 89 fields
pub ultra_compact: bool,
pub tee_mode: TeeMode,
pub output_density: OutputDensity,
pub checkpoint_interval: u32,
pub excluded_commands: Vec<String>,
pub passthrough_urls: Vec<String>,
pub custom_aliases: Vec<AliasEntry>,
pub preserve_compact_formats: Vec<String>,
pub slow_command_threshold_ms: u64,
pub theme: String,
pub cloud: CloudConfig,
pub gain: GainConfig,
pub cost: CostConfig,
pub autonomy: AutonomyConfig,
pub providers: ProvidersConfig,
pub proxy: ProxyConfig,
pub proxy_enabled: Option<bool>,
pub proxy_port: Option<u16>,
pub proxy_timeout_ms: Option<u64>,
pub buddy_enabled: bool,
pub enable_wakeup_ctx: bool,
pub redirect_exclude: Vec<String>,
pub disabled_tools: Vec<String>,
pub default_tool_categories: Vec<String>,
pub no_degrade: bool,
pub profile: Option<String>,
pub tool_profile: Option<String>,
pub tools_enabled: Vec<String>,
pub persona: Option<String>,
pub loop_detection: LoopDetectionConfig,
pub rules_scope: Option<String>,
pub rules_injection: Option<String>,
pub permission_inheritance: Option<String>,
pub extra_ignore_patterns: Vec<String>,
pub terse_agent: TerseAgent,
pub compression_level: CompressionLevel,
pub archive: ArchiveConfig,
pub memory: MemoryPolicy,
pub allow_paths: Vec<String>,
pub allow_ide_config_dirs: bool,
pub extra_roots: Vec<String>,
pub content_defined_chunking: bool,
pub minimal_overhead: bool,
pub symbol_map_auto: bool,
pub structure_first: bool,
pub team_url: Option<String>,
pub team_token: Option<String>,
pub team_auto_push: bool,
pub journal_enabled: bool,
pub auto_capture: bool,
pub search: HybridConfig,
pub graph: GraphConfig,
pub skillify: SkillifyConfig,
pub summaries: SummariesConfig,
pub llm: LlmConfig,
pub embedding: EmbeddingConfig,
pub shell_hook_disabled: bool,
pub shadow_mode: bool,
pub shell_activation: ShellActivation,
pub update_check_disabled: bool,
pub updates: UpdatesConfig,
pub bm25_max_cache_mb: u64,
pub graph_index_max_files: u64,
pub memory_profile: MemoryProfile,
pub memory_cleanup: MemoryCleanup,
pub max_ram_percent: u8,
pub max_disk_mb: u64,
pub max_staleness_days: u32,
pub savings_footer: SavingsFooter,
pub project_root: Option<String>,
pub lsp: HashMap<String, String>,
pub ide_paths: HashMap<String, Vec<String>>,
pub model_context_windows: HashMap<String, usize>,
pub response_verbosity: ResponseVerbosity,
pub bypass_hints: Option<String>,
pub cache_policy: Option<String>,
pub boundary_policy: BoundaryPolicy,
pub secret_detection: SecretDetectionConfig,
pub sensitivity: SensitivityConfig,
pub gateway: GatewayConfig,
pub allow_auto_reroot: bool,
pub path_jail: Option<bool>,
pub sandbox_level: u8,
pub reference_results: bool,
pub agent_token_budget: usize,
pub shell_allowlist: Vec<String>,
pub shell_allowlist_extra: Vec<String>,
pub shell_strict_mode: bool,
pub setup: SetupConfig,
}Expand description
Global lean-ctx configuration loaded from config.toml, merged with project-local overrides.
Fields§
§ultra_compact: bool§tee_mode: TeeMode§output_density: OutputDensity§checkpoint_interval: u32§excluded_commands: Vec<String>§passthrough_urls: Vec<String>§custom_aliases: Vec<AliasEntry>§preserve_compact_formats: Vec<String>Output formats that are already compact/token-oriented and must be
preserved verbatim instead of being recompressed (#342). Matched against
the output shape (not the command name), so any tool emitting the
format is covered without enumerating commands in excluded_commands.
Default: ["toon"]. Set to [] to disable and always recompress.
slow_command_threshold_ms: u64Commands taking longer than this threshold (ms) are recorded in the slow log. Set to 0 to disable slow logging.
theme: String§cloud: CloudConfig§gain: GainConfig§cost: CostConfigModel declaration for measured-vs-estimated cost reporting (MCP-only IDEs).
autonomy: AutonomyConfig§providers: ProvidersConfig§proxy: ProxyConfig§proxy_enabled: Option<bool>Whether the API proxy is enabled. Tri-state:
- None: undecided (fresh install, will prompt on interactive setup)
- Some(true): user opted in, proxy managed by lean-ctx
- Some(false): user opted out, never touch proxy or endpoints
proxy_port: Option<u16>§proxy_timeout_ms: Option<u64>Proxy reachability timeout in milliseconds. Default: 200. Override via LEAN_CTX_PROXY_TIMEOUT_MS env var.
buddy_enabled: bool§enable_wakeup_ctx: bool§redirect_exclude: Vec<String>§disabled_tools: Vec<String>Tools to exclude from the MCP tool list returned by list_tools.
Accepts exact tool names (e.g. ["ctx_graph", "ctx_agent"]).
Empty by default — all tools listed, no behaviour change.
default_tool_categories: Vec<String>Tool categories to activate by default for dynamic-tool-capable clients.
Values: “core” (always on), “arch”, “debug”, “memory”, “metrics”, “session”.
Example: default_tool_categories = ["core", "arch", "memory"]
Override via LCTX_DEFAULT_CATEGORIES env var (comma-separated).
Empty = lean-ctx default (core + session).
no_degrade: boolDisable all automatic read-mode degradation (auto_degrade + context_gate pressure). When true, lean-ctx never downgrades requested read modes regardless of pressure. Override via LCTX_NO_DEGRADE=1 env var.
profile: Option<String>Persistent profile name. Checked after LEAN_CTX_PROFILE env var.
Set via lean-ctx config set profile passthrough or editing config.toml.
tool_profile: Option<String>Tool visibility profile: “minimal” (6), “standard” (22), or “power” (all). Override via LEAN_CTX_TOOL_PROFILE env var. Existing installs default to “power” (backward compat).
tools_enabled: Vec<String>Explicit list of enabled tool names (overrides tool_profile when non-empty).
Example: tools_enabled = ["ctx_read", "ctx_shell", "ctx_search"]
persona: Option<String>Active context persona (persona-spec-v1). Selects the domain bundle —
tool surface, read-mode/compressor/chunker defaults, intent taxonomy,
sensitivity floor. Override via LEAN_CTX_PERSONA. Defaults to coding.
loop_detection: LoopDetectionConfig§rules_scope: Option<String>Controls where lean-ctx installs agent rule files. Values: “both” (default), “global” (home-dir only), “project” (repo-local only). Override via LEAN_CTX_RULES_SCOPE env var.
rules_injection: Option<String>Controls how rules are injected for shared-instruction-file agents. Values: “shared” (default, marker block in CLAUDE.md/CODEBUDDY.md/AGENTS.md/GEMINI.md), “dedicated” (never touch those files; use each agent’s config-driven auto-load: SessionStart hook / instructions[] / context.fileName, #343), or “off” (write no rules file at all — for hosts that supply their own tool-steering workflow or phase-isolated/non-caching harnesses, #361). Override via LEAN_CTX_RULES_INJECTION env var.
permission_inheritance: Option<String>Mirror the host IDE’s tool-permission rules onto lean-ctx’s own MCP tools.
Values: “off” (default) or “on”. When “on”, lean-ctx reads the active
IDE’s permission config (v1: OpenCode) and applies the equivalent
deny/ask/allow decision to the matching lean-ctx tool — so ctx_shell
honors your bash/rm * rules instead of bypassing them.
Override via LEAN_CTX_PERMISSION_INHERITANCE env var.
extra_ignore_patterns: Vec<String>Extra glob patterns to ignore in graph/overview/preload (repo-local).
Example: ["externals/**", "target/**", "temp/**"]
terse_agent: TerseAgentControls agent output verbosity via instructions injection. Values: “off” (default), “lite”, “full”, “ultra”. Override via LEAN_CTX_TERSE_AGENT env var.
compression_level: CompressionLevelUnified compression level (replaces separate terse_agent + output_density). Values: “off” (default), “lite”, “standard”, “max”. Override via LEAN_CTX_COMPRESSION env var.
archive: ArchiveConfigArchive configuration for zero-loss compression.
memory: MemoryPolicyMemory policy (knowledge/episodic/procedural/lifecycle budgets & thresholds).
allow_paths: Vec<String>Additional paths allowed by PathJail (absolute). Useful for multi-project workspaces where the jail root is a parent directory. Override via LEAN_CTX_ALLOW_PATH env var (path-list separator).
allow_ide_config_dirs: boolAllow jailed tool access to home-level IDE config dirs (~/.cursor,
~/.claude, ~/.codebuddy, …). Default false: those dirs expose other projects’
sessions, MCP configs and credentials. ~/.lean-ctx (own data dir)
is always allowed. Override via LEAN_CTX_ALLOW_IDE_DIRS=1.
extra_roots: Vec<String>Extra project roots for multi-root workspaces. Tools like ctx_tree and ctx_search can scan across all roots in a single call. These paths are automatically added to PathJail’s allow-list. Override via LEAN_CTX_EXTRA_ROOTS env var (path-list separator).
content_defined_chunking: boolEnable content-defined chunking (Rabin-Karp) for cache-optimal output ordering. Stable chunks are emitted first to maximize prompt cache hits.
minimal_overhead: boolSkip session/knowledge/gotcha blocks in MCP instructions to minimize token overhead. Override via LEAN_CTX_MINIMAL env var.
symbol_map_auto: boolOpt-in: substitute long identifiers with short α-codes (+ a §MAP table)
in aggressive reads for projects with >50 source files. Off by default —
the abbreviated form is confusing for editing/refactoring, where the agent
needs the real package and symbol names. Enable for max exploration savings.
structure_first: boolOpt-in: bias auto toward structure-first reads (map) for medium code
files on a cold read. Off by default — interactive sessions keep the
conservative full floor that avoids a follow-up body read. Enable for
phase-isolated harnesses (no warm-session cache payback), where a cold
full read is pure overhead and structure-first reads aid localization.
Override via the LEAN_CTX_STRUCTURE_FIRST env var.
team_url: Option<String>Team server URL for opt-in savings roll-up.
Set via lean-ctx config set team_url https://... or [team] url in config.toml.
Override via LEAN_CTX_TEAM_URL env var.
team_token: Option<String>Bearer token for the team server (Authorization header on savings push /
pull). Set via lean-ctx config set team_token <tok> or team_token in
config.toml. Override via the LEAN_CTX_TEAM_TOKEN env var.
team_auto_push: boolOpt-in: when true, the running daemon periodically pushes this machine’s
signed savings batch to team_url so the team roll-up fills itself (no
manual savings push per dev). Off by default; requires team_url +
team_token. Set via lean-ctx config set team_auto_push true.
journal_enabled: boolEnable human-readable activity journal (~/.lean-ctx/journal.md).
auto_capture: boolOpt-in: auto-persist interesting findings as knowledge facts.
search: HybridConfigHybrid search weights (BM25/dense/candidates).
graph: GraphConfigCode-graph settings, including traversal (co-access) edges (#289).
skillify: SkillifyConfigSkillify miner settings (#290): codify recurring patterns into rules.
summaries: SummariesConfigAI session-summary settings (#292): periodic, semantically-recallable summaries.
llm: LlmConfigOptional LLM enhancement (query expansion, contradiction explanation).
embedding: EmbeddingConfigSemantic-embedding engine settings (which local ONNX model to use).
shell_hook_disabled: boolDisable shell hook injection (the _lc() function that wraps CLI commands). Override via LEAN_CTX_NO_HOOK env var.
shadow_mode: boolShadow mode: transparently intercepts native tool calls (Read/Grep/Shell) via hooks, strengthens MCP instructions to MUST-level, and activates immediate bypass hints on first native tool use. Enables “transparent replacement” so agents use ctx_* without explicit opt-in.
shell_activation: ShellActivationControls when the shell hook auto-activates aliases.
always: (Default) Aliases active in every interactive shell.agents-only: Aliases only active when an AI agent env var is detected.off: Aliases never auto-activate (user must calllean-ctx-onmanually).
Override via LEAN_CTX_SHELL_ACTIVATION env var.
update_check_disabled: boolDisable the daily version check against leanctx.com/version.txt. Override via LEAN_CTX_NO_UPDATE_CHECK env var.
updates: UpdatesConfig§bm25_max_cache_mb: u64Maximum BM25 cache file size in MB. Indexes exceeding this are quarantined on load and refused on save. Override via LEAN_CTX_BM25_MAX_CACHE_MB env var.
graph_index_max_files: u64Maximum number of files scanned by the lightweight JSON graph index. 0 = unlimited (default). Set >0 to cap for constrained systems.
memory_profile: MemoryProfileControls RAM vs feature trade-off. Values: “low”, “balanced” (default), “performance”. Override via LEAN_CTX_MEMORY_PROFILE env var.
memory_cleanup: MemoryCleanupControls how aggressively memory is freed when idle. Values: “aggressive” (default, 5 min TTL), “shared” (30 min TTL for multi-IDE use). Override via LEAN_CTX_MEMORY_CLEANUP env var.
max_ram_percent: u8Maximum percentage of system RAM that lean-ctx may use (default: 5). Override via LEAN_CTX_MAX_RAM_PERCENT env var.
max_disk_mb: u64Simplified disk budget (MB). When set and detail values are at defaults, distributes proportionally: archive=25%, bm25=10%, remainder for stores. 0 = disabled (use individual settings). Override via LEAN_CTX_MAX_DISK_MB.
max_staleness_days: u32Auto-purge data older than this many days. 0 = disabled. Flows into archive.max_age_hours and lifecycle idle TTL.
Controls visibility of token savings footers in tool output. Values: “always” (default, show on every response), “never”, “auto” (legacy compatibility). Override via LEAN_CTX_SAVINGS_FOOTER or LEAN_CTX_SHOW_SAVINGS=1|0 env var.
project_root: Option<String>Explicit project root override. When set, lean-ctx uses this instead of auto-detection. This prevents accidental home-directory scans when running from $HOME. Override via LEAN_CTX_PROJECT_ROOT env var.
lsp: HashMap<String, String>LSP server overrides. Map language name to custom binary path.
Example: [lsp]\nrust = "/opt/rust-analyzer"\npython = "~/.venvs/main/bin/pylsp"
ide_paths: HashMap<String, Vec<String>>Per-IDE allowed paths. Restricts which directories lean-ctx will scan/index for each IDE.
Example: [ide_paths]\ncursor = ["/home/user/projects/app1"]\ncodex = ["/home/user/codex"]
When set, only these paths are indexed for the matching agent. Global allow_paths still applies.
model_context_windows: HashMap<String, usize>Custom model context window overrides.
Example: [model_context_windows]\n"my-custom-model" = 500000
response_verbosity: ResponseVerbosityControls how much detail tool responses include.
full(default): complete compressed outputheaders_only: metadata line only (path, mode, token count)
Override via LEAN_CTX_RESPONSE_VERBOSITY env var.
bypass_hints: Option<String>Bypass hint mode. When agents use native Read/Grep instead of lean-ctx tools, a hint is appended to the next tool response. Values: “on” (default), “off”, “aggressive” (hint on every call, no cooldown). Override via LEAN_CTX_BYPASS_HINTS env var.
cache_policy: Option<String>Cache policy for ctx_read. Controls behavior on cache hits. Values: “aggressive” (default, 13-tok stubs + compaction-aware reset), “safe” (delivers map instead of stub), “off” (no caching, always disk read). Override via LEAN_CTX_CACHE_POLICY env var.
boundary_policy: BoundaryPolicyCross-project boundary policy. Controls whether cross-project search/import is allowed and whether access is audited.
secret_detection: SecretDetectionConfig§sensitivity: SensitivityConfigPer-item sensitivity model with a uniform policy floor (#212).
Disabled by default → fully no-op until sensitivity.enabled = true.
gateway: GatewayConfigMCP Tool-Catalog Gateway (#210): aggregate + query-route downstream MCP
servers. Global-only (never merged from project-local config) and a full
no-op until gateway.enabled = true.
allow_auto_reroot: boolAllow automatic project-root re-rooting when absolute paths outside the jail are seen. When false (default), absolute paths outside the jail are rejected without re-rooting. Override via LEAN_CTX_ALLOW_REROOT env var.
path_jail: Option<bool>Disable PathJail entirely by setting path_jail = false in config.toml.
Useful in container/Docker environments where the sandbox is the boundary.
(The former LEAN_CTX_NO_JAIL=1 env override was removed in v3.7.3.)
sandbox_level: u8Sandbox level for code execution (ctx_exec). 0 = subprocess only (current), 1 = OS-level restriction (Seatbelt/Landlock). Override via LEAN_CTX_SANDBOX_LEVEL env var.
reference_results: boolWhen true, large tool outputs (>4000 chars) are stored as references and a short URI is returned instead of the full content. Override via LEAN_CTX_REFERENCE_RESULTS env var.
agent_token_budget: usizeDefault per-agent token budget. 0 means unlimited. Override per-agent via ctx_session or programmatically.
shell_allowlist: Vec<String>Optional shell command allowlist. When non-empty, only commands whose base binary
is in this list are permitted by ctx_shell. Empty = disable allowlist (allow all).
Default includes common dev tools. Set to [] to disable.
Override via LEAN_CTX_SHELL_ALLOWLIST env var (comma-separated).
shell_allowlist_extra: Vec<String>Extra commands MERGED on top of the effective shell_allowlist without replacing
the defaults. Setting shell_allowlist replaces the whole built-in list (a common
footgun); entries here are purely additive, which is what lean-ctx allow <cmd>
writes. Only applied in restricted mode (when the base allowlist is non-empty).
shell_strict_mode: boolWhen true, block command substitution ($(), backticks) and process substitution (<(), >()) in shell arguments. When false (default), only warn via tracing. Default false preserves backward compatibility — set true for maximum security.
setup: SetupConfigSetup behavior: controls what gets injected during setup and updates.
Implementations§
Source§impl Config
impl Config
Sourcepub fn provenance() -> ConfigProvenance
pub fn provenance() -> ConfigProvenance
Snapshot the provenance of the editable settings (GH #450).
Reads the same sources as Config::load (honoring the #356 TCC guard
for the project-local file) plus the live environment, so the result
matches what a fresh load() would resolve. Pure: it never mutates the
config cache or writes to disk.
Source§impl Config
impl Config
Sourcepub fn rules_scope_effective(&self) -> RulesScope
pub fn rules_scope_effective(&self) -> RulesScope
Returns the effective rules scope, preferring env var over config file.
Sourcepub fn rules_injection_effective(&self) -> RulesInjection
pub fn rules_injection_effective(&self) -> RulesInjection
Returns the effective rules injection mode, preferring env var over config.
Default is Shared (zero-config discovery via a CLAUDE.md/CODEBUDDY.md/AGENTS.md block).
Sourcepub fn permission_inheritance_effective(&self) -> PermissionInheritance
pub fn permission_inheritance_effective(&self) -> PermissionInheritance
Returns the effective permission-inheritance mode, preferring the
LEAN_CTX_PERMISSION_INHERITANCE env var over config. Default is Off.
Accepts on/true/1 as enabled.
Sourcepub fn dedicated_session_context_active(&self) -> bool
pub fn dedicated_session_context_active(&self) -> bool
True when lean-ctx should inject its rules via each agent’s dedicated, non-polluting auto-load path and global rules are in scope.
Gates the Claude/Codex SessionStart additionalContext summary: it
stands in for the (now-skipped) shared CLAUDE.md/CODEBUDDY.md/AGENTS.md block, so it
only fires when injection is Dedicated and the scope isn’t project-only.
Sourcepub fn disabled_tools_effective(&self) -> Vec<String>
pub fn disabled_tools_effective(&self) -> Vec<String>
Returns the effective disabled tools list, preferring env var over config file.
Sourcepub fn minimal_overhead_effective(&self) -> bool
pub fn minimal_overhead_effective(&self) -> bool
Returns true if minimal overhead is enabled via env var or config.
Sourcepub fn structure_first_effective(&self) -> bool
pub fn structure_first_effective(&self) -> bool
Returns true if structure-first auto reads are enabled.
The LEAN_CTX_STRUCTURE_FIRST env var wins over the config field, and
accepts the usual truthy/falsy spellings so a harness can flip it per run
(LEAN_CTX_STRUCTURE_FIRST=0 forces it off even if config enables it).
Sourcepub fn minimal_overhead_effective_for_client(&self, client_name: &str) -> bool
pub fn minimal_overhead_effective_for_client(&self, client_name: &str) -> bool
Returns true if minimal overhead should be enabled for this MCP client.
This is a superset of minimal_overhead_effective():
LEAN_CTX_OVERHEAD_MODE=minimalforces minimal overheadLEAN_CTX_OVERHEAD_MODE=fulldisables client/model heuristics (still honors LEAN_CTX_MINIMAL / config)- In auto mode (default), certain low-context clients/models are treated as minimal to prevent large metadata blocks from destabilizing smaller context windows (e.g. Hermes + MiniMax).
Sourcepub fn shell_hook_disabled_effective(&self) -> bool
pub fn shell_hook_disabled_effective(&self) -> bool
Returns true if shell hook injection is disabled via env var or config.
Sourcepub fn shell_activation_effective(&self) -> ShellActivation
pub fn shell_activation_effective(&self) -> ShellActivation
Returns the effective shell activation mode (env var > config > default).
Sourcepub fn update_check_disabled_effective(&self) -> bool
pub fn update_check_disabled_effective(&self) -> bool
Returns true if the daily update check is disabled via env var or config.
pub fn memory_policy_effective(&self) -> Result<MemoryPolicy, String>
Sourcepub fn default_tool_categories_effective(&self) -> Vec<String>
pub fn default_tool_categories_effective(&self) -> Vec<String>
Returns the effective set of default tool categories. Priority: LCTX_DEFAULT_CATEGORIES env var > config.toml > hardcoded default.
Sourcepub fn tool_profile_effective(&self) -> ToolProfile
pub fn tool_profile_effective(&self) -> ToolProfile
Returns the effective tool profile. Priority: LEAN_CTX_TOOL_PROFILE env > config tool_profile > config tools_enabled > active persona’s tool surface > power.
Explicit settings win (backward compatible); when none are set, the
active persona supplies the tool surface (the coding default resolves
to power, so existing installs are unaffected).
Sourcepub fn no_degrade_effective(&self) -> bool
pub fn no_degrade_effective(&self) -> bool
Returns true if all automatic read-mode degradation is disabled.
Checks LCTX_NO_DEGRADE env var first, then config.toml field.
Sourcepub fn max_disk_mb_effective(&self) -> u64
pub fn max_disk_mb_effective(&self) -> u64
Effective max_disk_mb from env or config.
Sourcepub fn max_staleness_days_effective(&self) -> u32
pub fn max_staleness_days_effective(&self) -> u32
Effective max_staleness_days from env or config.
Sourcepub fn archive_max_disk_mb_effective(&self) -> u64
pub fn archive_max_disk_mb_effective(&self) -> u64
Archive max_disk_mb derived from simplified max_disk_mb if the detail value is still at its default. Explicit overrides take priority.
Sourcepub fn archive_max_age_hours_effective(&self) -> u64
pub fn archive_max_age_hours_effective(&self) -> u64
Archive max_age_hours derived from max_staleness_days if the detail value is still at its default. Explicit overrides take priority.
Sourcepub fn bm25_max_cache_mb_effective(&self) -> u64
pub fn bm25_max_cache_mb_effective(&self) -> u64
Effective on-disk ceiling (MB) for the persisted BM25 index. Single source
of truth for save/load, cache prune, and the doctor health check.
Priority: explicit bm25_max_cache_mb › max_disk_mb budget (10%) ›
generous default (DEFAULT_BM25_PERSIST_MB). The default is decoupled
from the RAM profile so large repos persist instead of rebuilding forever
(issue #249).
Source§impl Config
impl Config
Sourcepub fn path() -> Option<PathBuf>
pub fn path() -> Option<PathBuf>
Returns the path to the global config file ($XDG_CONFIG_HOME/lean-ctx/config.toml).
Resolves via crate::core::paths::config_dir so config lives in the
RO-safe config category. Behavior-neutral today: config_dir() equals the
legacy data dir for existing/single-dir installs (GH #408 / GL #602).
Sourcepub fn local_path(project_root: &str) -> PathBuf
pub fn local_path(project_root: &str) -> PathBuf
Returns the path to the project-local config override file.
Sourcepub fn load() -> Self
pub fn load() -> Self
Loads config from disk with caching, merging global + project-local overrides.
The cache is keyed on a content hash of the global + project-local
files, not their mtime. mtime-only invalidation silently served a stale
Config whenever a content edit preserved the mtime (coarse filesystem
mtime resolution, cp -p, atomic save-then-rename, two edits within the
same second). A long-lived MCP server then kept the old value (e.g.
path_jail) while a fresh lean-ctx doctor process — with an empty
cache — saw the new one (#406). Config files are tiny, so reading +
hashing them on every load is negligible and guarantees liveness.
Sourcepub fn load_global() -> Self
pub fn load_global() -> Self
Loads ONLY the global config file — never merging project-local
.lean-ctx.toml overrides, and bypassing the in-memory cache. Every
PERSIST path must use this (or Config::update_global): Config::load
folds per-project overrides into the struct, and Config::save writes
the whole struct back to the GLOBAL file — so a load → mutate → save
round-trip silently leaks per-project values (and, historically, reset
customized keys) into the global config (#443). Reading global-only makes
the save leak-free by construction.
Sourcepub fn update_global<F>(f: F) -> Result<Self, LeanCtxError>where
F: FnOnce(&mut Self),
pub fn update_global<F>(f: F) -> Result<Self, LeanCtxError>where
F: FnOnce(&mut Self),
Safely mutate and persist the GLOBAL config. Reads the global file only
(no project-local merge), applies f, then writes minimally. Refuses
(returns Err) when the file exists but is unparseable, so a typo can
never clobber a customized config (#443). Returns the saved Config.
This is the canonical persistence entry point: prefer it over
Config::load() followed by save(), which leaks project-local
overrides into the global file.
Sourcepub fn save(&self) -> Result<(), LeanCtxError>
pub fn save(&self) -> Result<(), LeanCtxError>
Persists the current config to the global config file.
Preserves user comments, formatting, and unknown keys, keeps the file
minimal (defaults that were never set on disk stay implicit), and writes
atomically with a .bak backup so customizations are always recoverable.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more