Files
stack/apps/coordinator/tests
Jason Woltje 698b13330a feat(#152): Implement session rotation (TDD)
Implement session rotation that spawns fresh agents when context reaches
95% threshold.

TDD Process:
1. RED: Write comprehensive tests (all initially fail)
2. GREEN: Implement trigger_rotation method (all tests pass)

Changes:
- Add SessionRotation dataclass to track rotation metrics
- Implement trigger_rotation method in ContextMonitor
- Add 6 new unit tests covering all acceptance criteria

Rotation process:
1. Get current context usage metrics
2. Close current agent session
3. Spawn new agent with same type
4. Transfer next issue to new agent
5. Log rotation event with metrics

Test Results:
- All 47 tests pass (34 context_monitor + 13 context_compaction)
- 97% coverage on context_monitor.py (exceeds 85% requirement)
- 97% coverage on context_compaction.py (exceeds 85% requirement)

Prevents context exhaustion by starting fresh when compaction is insufficient.

Acceptance Criteria (All Met):
✓ Rotation triggered at 95% context threshold
✓ Current session closed cleanly
✓ New agent spawned with same type
✓ Next issue transferred to new agent
✓ Rotation logged with session IDs and context metrics
✓ Unit tests with 85%+ coverage

Fixes #152

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 20:36:52 -06:00
..