The one-line usage result, “N calls, X tokens saved”. Shown by
lean-ctx status, lean-ctx doctor and once on MCP server exit; never
part of a tool output body (#498).
Classifies normalized stats keys, with an explicit passthrough default for
control/listing tools so only read, shell, and search output drives the
effective-compression denominator.
The stderr line an exiting MCP server prints once per install, after the
first session that recorded calls. None when it was printed before, when
nothing was recorded yet, or on any I/O error (silently). The numbers use
the same data-dir resolution as status, doctor and gain
(load_for_display), so all four show the same result.
Debounced flush: persists at most once per FLUSH_INTERVAL_SECS.
Call from post_dispatch on every tool call to bound data loss
on abrupt MCP termination to at most 2 seconds of events.
The dashboard body without the trailing footer (tips / Context OS / hints).
Used to compose gain --deep, where the extra themed sections must appear
before the footer instead of in the middle of the output.
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.