Stats tests set PI_CONFIG_DIR + setAgentDir(home/<config>/agent), which resolves equal to the default agent dir and routes stats.db through $XDG_DATA_HOME/omp/stats.db whenever an XDG var is set, leaking rows across tests. The shared installStatsTestIsolation helper now snapshots and clears XDG_*_HOME with PI_CONFIG_DIR on each test, points the agent dir at a fresh TempDir, closes the DB handle, and restores the prior env after the test.
- Implemented agent type classification and persistence in the database, including a backfill for legacy records.
- Added `AgentType` categorization and aggregated token usage metrics to the backend services.
- Created an `AgentTokenShare` visualization component to display usage distribution on the overview dashboard.
- Integrated agent-based tracking into existing data pipelines, view models, and testing suites.
- Added optional time-range parameters to stats API endpoints and client requests.
- Added dashboard time-range selector controls and wired range updates to stats refresh.
- Implemented range normalization and cutoff calculation for dashboard stat aggregation.
- Updated DB queries to support optional cutoffs and unlimited mode for `range=all`.
- Added tests for 24h, 7d, all, and unknown-range fallback filtering behavior.