Skip to main content

Module session_stats

Module session_stats 

Source
Expand description

The session’s runtime counters (ultron/session-stats.ts): what the runtime sees while a session runs and no other session value keeps, for the session report (/usage, ultron usage). They are the session value ultron.module/stats, written as the TypeScript recorder writes it, so either implementation reads the other’s.

Cells are counted where they run (every lane’s rlm tool), host requests where the kernels make them, guard outcomes as the file hooks record them, steers as they are queued for the root, refused work as the usage ledger refuses it, merges and subagent models as the delegation host settles them. Nothing here holds code, output, paths or prompts: only counts, API names, task ids and times.

Recording never fails and never blocks on the store: changes are counted in memory and saved flush_ms (500 ms) after the first unsaved one, and on SessionStats::flush. A store that cannot be written keeps the counters in memory and the next change tries again; a stored document in a format this build does not know is left as it is.

Structs§

GuardOutcome
One guard outcome (GuardRecord, the fields counted here).
SessionStats
SessionStatsRecorder: counts in memory and saves the document shortly after a change.
SessionStore
The session value ultron.module/stats of a session journal (createSessionModuleStore(session, "stats")).

Enums§

Stored
What the store holds, read as readVersioned reads it.

Constants§

DEFAULT_FLUSH
How long after the first unsaved change the counters are saved.

Traits§

StatsStore
Where the counters are kept (HostModuleStore).

Functions§

empty_session_stats
emptySessionStats(root, now).
parse_session_stats
parseSessionStats: a stored document with every field present, or None when saved is not one (not an object, or another version). Unknown fields are dropped and malformed counters read as zero.
read_stored
parseSessionStats(readVersioned("ultron.module/stats", saved)).

Type Aliases§

Clock
Milliseconds since the epoch (tests: a fake clock).