95%+ coverage on orchestrator business logic by splitting pure logic from async event loop.
Current state
- orchestrator/mod.rs (1094 lines, 7 tests) — ~0.6% coverage
- orchestrator/state.rs (90 lines, 0 tests)
Refactor: split mod.rs into testable units
- Extract is_eligible() tests — already public, test all branches (max agents, claimed, completed, state filters)
- Extract apply_agent_update_to_state() — already tested (7 tests), add edge cases
- Extract detect_stalled() — pure function, test with mock timestamps
- Extract calculate_backoff() / should_throttle_continuation() — pure math
- Extract build_snapshot() — pure data transformation
- state.rs: test OrchestratorState methods (running_count, available_global_slots, running_count_by_state)
Key tests needed
- is_eligible: max_agents reached, issue already claimed, issue already running, issue completed, wrong state, correct state
- detect_stalled: no stalled, one stalled, timeout boundary
- calculate_backoff: attempt 0-5, exponential growth
- should_throttle_continuation: below/above threshold
- build_snapshot: empty state, populated state, token totals
- state.rs: all methods on OrchestratorState
Acceptance criteria
95%+ coverage on orchestrator business logic by splitting pure logic from async event loop.
Current state
Refactor: split mod.rs into testable units
Key tests needed
Acceptance criteria