pub fn load_for_display() -> StatsStoreExpand description
Loads stats for display, summing across every auto-resolved data dir that
holds a stats.json (#500). When the MCP server process and the CLI resolve
different XDG dirs — the documented #408/#414 split, common when an agent host
(e.g. a containerised Hermes) launches the MCP server with a different HOME
or XDG_* than the user’s shell — the bulk of the savings can land in a
sibling tree. Reading only the primary dir then makes gain report 0 while
the real data sits one directory over. Folding the siblings in keeps the
headline honest regardless of which process wrote where.
Safe by construction:
- No-op without a split — when only the primary dir has stats (the
overwhelmingly common case) the result equals
load. - Respects an explicit pin — when
LEAN_CTX_DATA_DIRis set the user has chosen exactly one dir, so nothing is auto-merged. - Read-only — never writes back; recording still targets the primary dir.