Skip to main content

Module path_mode_memory

Module path_mode_memory 

Source
Expand description

Persistent per-path bounce memory (#496).

The in-process BounceTracker detects bounces (compressed read followed by a full read of the same file within a short window) but forgets everything on restart, and should_force_full only knows per-extension rates. This store remembers which specific files keep bouncing across sessions so mode=auto stops compressing them — compression is a net token loss for a file the agent always re-reads in full.

Storage: ~/.lean-ctx/path_mode_memory.json, atomic write (tmp+rename), loaded once per process, flushed periodically like the heatmap.

Structs§

PathModeMemory
PathModeStats

Functions§

disk_summary
Dashboard summary: (tracked_paths, forced_full_paths). Reads straight from disk so a separate process (the dashboard) sees the same state the MCP/CLI processes persisted (#505).
flush
record_bounce
Process-global: record a confirmed bounce for path (already normalized by the caller — BounceTracker normalizes via pathutil).
record_read_if_tracked
Process-global: count a read for an already-tracked path.
should_force_full
Process-global: should mode=auto resolve to full for this path?