Skip to content

test(rust): orchestrator coverage — event loop logic, eligibility, stall detection #81

@ridermw

Description

@ridermw

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

  1. Extract is_eligible() tests — already public, test all branches (max agents, claimed, completed, state filters)
  2. Extract apply_agent_update_to_state() — already tested (7 tests), add edge cases
  3. Extract detect_stalled() — pure function, test with mock timestamps
  4. Extract calculate_backoff() / should_throttle_continuation() — pure math
  5. Extract build_snapshot() — pure data transformation
  6. 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

  • 20+ new tests for orchestrator pure functions
  • state.rs: 8+ tests
  • All public helper functions have >=95% branch coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    testingTest coverage improvements

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions