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
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.
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.
- 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
Summary & Motivation
During recent architecture audits, we noted that
orchestrator/supervisor.py(~1,790 lines) andorchestrator/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
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.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.from orchestrator.supervisor import Supervisorandfrom orchestrator.quality_plane import QualityPlanefully backward-compatible via__init__.pyre-exports.Key Files
orchestrator/supervisor.pyorchestrator/quality_plane.pyorchestrator/__init__.pyAcceptance Criteria