Skip to content

feat(modularization): Decompose Monolithic Modules (supervisor.py & quality_plane.py) #9

Description

@sdageltc

Summary & Motivation

During recent architecture audits, we noted that orchestrator/supervisor.py (~1,790 lines) and orchestrator/quality_plane.py (~1,100 lines) handle multiple cross-cutting responsibilities within single files. While their internal cohesion is strong, modularizing auxiliary functions into dedicated sub-packages will significantly improve readability, simplify unit testing, and reduce cognitive load for new contributors.


Proposed Refactoring Plan

  1. orchestrator/supervisor.py -> orchestrator/supervisor/ Package:
    • supervisor/core.py: The core state machine and event loop (execute_plan, _execute_single_contract).
    • supervisor/recovery.py: State graph recovery, checkpoint hydration, and orphan lease recovery.
    • supervisor/reporting.py: Console summary formatting (_print_run_summary), result aggregation.
    • supervisor/cleanup.py: Artifact directory cleanup and helper file pruning.
  2. orchestrator/quality_plane.py -> orchestrator/qc/ Package:
    • qc/lenses.py: Individual lens evaluators (Spec, Safety, Performance, Regression).
    • qc/aggregator.py: Verdict weighting, panel majority calculations, and overrule defense parsing.
  3. Public API Invariance:
    • Keep from orchestrator.supervisor import Supervisor and from orchestrator.quality_plane import QualityPlane fully backward-compatible via __init__.py re-exports.

Key Files

  • orchestrator/supervisor.py
  • orchestrator/quality_plane.py
  • orchestrator/__init__.py

Acceptance Criteria

  • All 1,122 existing unit and integration tests continue to pass 100% green without modification.
  • File sizes for individual modules remain under 500 lines.
  • Strict type annotations and zero circular import cycles.
  • Clean re-exports maintaining complete backward compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureCore control loop and system architectureenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions