Skip to content

Extract retry and gate helpers from stage_tournament #229

@jayscambler

Description

@jayscambler

Summary

stage_tournament() in mts/src/mts/loop/stages.py mixes evaluation, retry policy, gate selection, prompt rewriting, persistence, and event emission in one control-heavy function. The current structure is harder to test, harder to optimize, and harder to modify safely.

Scope

  1. Split stage_tournament() into focused components/helpers such as:
    • tournament evaluator/runner
    • retry strategy
    • gate decision resolver
    • recovery/event recorder
  2. Reduce broad except Exception blocks by isolating failure boundaries
  3. Preserve current semantics for rapid mode, trend-aware gate, retry learning, and replay generation
  4. Add targeted tests around the extracted pieces instead of only end-to-end stage behavior

Acceptance Criteria

  • stage_tournament() becomes materially smaller and mostly orchestration-only
  • retry logic, gate resolution, and persistence/event side effects are separated into testable units
  • rapid mode and standard mode behavior remain unchanged
  • regression tests cover retry and gate behavior after refactor

Files

  • mts/src/mts/loop/stages.py
  • related generation pipeline tests under mts/tests/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions