Add Session State Transition tracking model and repository
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## User Story
As a system administrator, I want to track all session state transitions with timestamps so that I can analyze session lifecycle patterns and debug scheduling issues.
## Description
Implement historical tracking of session state changes:
- Record each state transition (PENDING → SCHEDULED → PREPARING → RUNNING → TERMINATED)
- Store transition timestamp and reason
- Track duration in each state
- Enable query by session ID, time range, or state
## Acceptance Criteria
- [ ] Create `SessionStateTransitionRow` model
- [ ] Include fields: session_id, from_state, to_state, timestamp, reason, metadata
- [ ] Create Alembic migration
- [ ] Implement repository with query methods (by session, by state, by time range)
- [ ] Integrate with existing KernelStateEngine to emit transition events
- [ ] Add indexes for performance (session_id, timestamp)
- [ ] Write unit tests
## Technical Notes
- Consider using event sourcing pattern for state transitions
- May need to hook into `KernelStateEngine` in `sokovan/scheduler/kernel/state_engine.py`
- Useful for calculating average queue wait time, scheduling latency metrics
## Dependencies
- Part of Epic: BA-3060
JIRA Issue: BA-3062
Contributor guide
Assessment
This issue has not been assessed yet.