Skip to main content

Module data_dir

Module data_dir 

Source

Structs§

TestEnvGuard
RAII guard for test_env_lock. Dropping the outermost one releases the underlying mutex; nested guards just decrement the depth.

Functions§

all_data_dirs_with_stats
Returns all known data directories that contain stats data, in resolution priority order (legacy → mixed config → XDG data). Used by the dual-dir consolidation (crate::core::data_consolidate) and doctor diagnostics.
candidate_data_dirs
Every location a LeanCTX data directory can resolve to for this user, in resolution priority order (legacy → mixed config → XDG data), whether or not it exists. Used to keep one telemetry identity per installation when processes resolve different directories.
lean_ctx_data_dir
Resolve the lean-ctx data directory.
sandboxed
Whether this process is a test harness that must stay inside the per-process data sandbox (GL #512). The engine’s own unit tests are compiled with cfg(test); the composition root (lean_ctx_cli) runs its unit tests against an engine with the additive test-support feature, and there the sandbox applies only to that unit-test harness (executable lean_ctx_cli-<hash>), never to the lean-ctx binary that integration tests spawn.
test_env_lock
Reentrant test env lock. Serializes env-mutating tests across threads (the point — std::env::set_var is not thread-safe) while letting the SAME thread re-acquire without deadlocking. A test and a setup() helper (or isolated_data_dir) can both take it; only the outermost acquisition holds the underlying mutex, nested ones just bump a per-thread depth. Other threads still block, so cross-test serialization is unchanged.