Skip to content

feat: add activity/idle tracking to sessions - #19

Draft
sd2k wants to merge 2 commits into
mainfrom
feature/activity-tracking
Draft

feat: add activity/idle tracking to sessions#19
sd2k wants to merge 2 commits into
mainfrom
feature/activity-tracking

Conversation

@sd2k

@sd2k sd2k commented Jan 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add SessionStats struct with activity metrics
  • Add tracking methods to InProcessSession:
    • last_activity() - time of last execution
    • idle_duration() - duration since last execution
    • execution_count() - total executions (now u64)
    • total_execution_time() - cumulative execution time
    • stats() - full SessionStats snapshot
    • reset_stats() - clear stats without affecting session

Behavior

  • Stats survive clear_state() (only clears Python state)
  • Stats are fully reset on reset() (new WASM instance)
  • 207 lines of implementation with unit tests

Test plan

  • Verify stats accumulate correctly across executions
  • Test reset_stats() preserves creation time
  • Verify clear_state() doesn't reset stats
  • Test reset() clears all stats

🤖 Generated with Claude Code

sd2k added 2 commits January 14, 2026 22:51
Add SessionStats struct and tracking methods to InProcessSession for
monitoring session activity and resource usage:

- SessionStats struct with created_at, last_activity, execution_count,
  total_execution_time, total_callback_invocations, and peak_memory_bytes
- last_activity() - returns the time of last execution completion
- idle_duration() - returns duration since last execution
- execution_count() - returns total number of executions (now u64)
- total_execution_time() - returns cumulative execution time
- stats() - returns complete SessionStats snapshot
- reset_stats() - clears statistics without affecting session state

Statistics behavior:
- Stats survive clear_state() (only clears Python state)
- Stats are fully reset on reset() (new WASM instance)
- reset_stats() preserves original creation time
- reset_full() updates creation time

Includes unit tests for SessionStats default values, reset behavior,
and reset_full timestamp handling.

Closes: eryx-cvr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant