Expand description
Maintenance for the on-disk knowledge stores.
A store at <data_dir>/knowledge/<hash>/ is keyed to a project_root. When
that root is deleted (a removed git worktree, a thrown-away temp project) the
store can never be written again — its per-store eviction cap can therefore
never self-heal (the memory lifecycle only runs on write) and the directory
is pure accumulated bloat. This module finds and prunes those orphaned
stores.
Pruning is only ever invoked from the explicit lean-ctx doctor --fix path;
the background lifecycle must never delete a store, since a missing root can
also mean a temporarily-unmounted drive rather than a deleted project.
Structs§
- Orphaned
Store - A knowledge store whose recorded
project_rootno longer exists on disk. - Prune
Report - Outcome of a prune pass.
Functions§
- find_
orphaned_ stores - Scan every knowledge store under the real data dir and return the orphaned
ones. See
find_orphaned_stores_infor the detection rules. - find_
orphaned_ stores_ in - Detect orphaned stores under an explicit
data_dir(the testable core). - prune_
orphaned_ stores - Remove every orphaned store under the real data dir. Best-effort.
- prune_
orphaned_ stores_ in - Prune orphaned stores under an explicit
data_dir(the testable core). Removes each orphanedknowledge/<hash>/directory plus the matching episodic-memory file (memory/episodes/<hash>.json). A failure on one store never aborts the rest.