Module session_stats

Module session_stats 

Source
Expand description

Session metadata tracking for agent panes (Phase 1.4 — ultra-long-sessions).

Tracks per-session stats as block metadata keys: session:start_ts_ms — Unix ms when the first output line arrived session:last_activity_ms — Unix ms of most recent output line session:line_count — total output lines emitted this session session:token_estimate — rough token count (chars / 4, cumulative)

To avoid a SetMeta write on every output line (which can be very frequent), this module debounces flushes to at most once per second using a local Instant-based timestamp. Accumulators live in SessionStatsAccumulator which each controller instance owns privately.

Structs§

SessionStatsAccumulator
In-memory accumulator for session stats. One per controller instance.

Constants§

FLUSH_DEBOUNCE 🔒
Debounce interval: at most one WaveStore write per second.
META_SESSION_LAST_ACTIVITY_MS
META_SESSION_LINE_COUNT
META_SESSION_START_TS_MS
Keys used for session stats in block metadata.
META_SESSION_TOKEN_ESTIMATE

Functions§

now_ms 🔒
Returns the current Unix timestamp in milliseconds.