Skip to content

refactor(backend): complete orchestrator consolidation (7→4 target) #4048

Closed

Description

@mrveiss

Status

Continuation of #3393. Orchestrator consolidation is ~40% complete.

Current State

  • Still 7 orchestrator files (target: 4)
  • Backward-compat shims added in first pass
  • Full consolidation deferred

Remaining Files

autobot-backend/agents/agent_orchestrator.py
autobot-backend/api/orchestration.py
autobot-backend/enhanced_multi_agent_orchestrator.py
autobot-backend/enhanced_orchestration/orchestrator.py
autobot-backend/orchestrator.py
autobot-backend/services/advanced_workflow/orchestrator.py
autobot-backend/services/slm/deployment_orchestrator.py

Consolidation Plan

  1. Phase 2: Remove backward-compat shims (breaking change for 1-2 releases)
  2. Phase 3: Evaluate remaining specialized orchestrators (agent_orchestration, advanced_workflow, slm deployment)
  3. Phase 4: Consolidate into single canonical pattern or justified service-specific variants

Related: #3393

Activity

  1. mrveiss commented on May 4, 2026

    @mrveiss
    OwnerAuthor

    ✅ Closing with proof — 7→4 target exceeded (now 2 production files, 1 actual Orchestrator class)

    Exact commit chain that resolved the 7-file consolidation

    Original file Resolution commit Date PR
    agents/agent_orchestrator.py acf060502 refactor(backend): remove backward-compat shim orchestrator files (#3393) (#4869) 2026-04-16 #4869
    enhanced_multi_agent_orchestrator.py 8493bb7f8 refactor(orchestrator): merge EnhancedMultiAgentOrchestrator into ConsolidatedOrchestrator (#5040) 2026-04-17 #5040
    enhanced_orchestration/orchestrator.py 2d9e4d61f refactor(orchestrator): decompose god class into collaborators (#5058) 2026-04-27 #5058
    services/advanced_workflow/orchestrator.py 27d704020 refactor(services): rename specialized orchestrators (#5040) 2026-04-17 #5040
    services/slm/deployment_orchestrator.py 27d704020 (same commit, same PR) 2026-04-17 #5040
    orchestrator.py kept as canonical single conductor — 00919e750 rename ConsolidatedOrchestrator → Orchestrator 2026-04-17 #5040
    api/orchestration.py kept as FastAPI router only (delegates to canonical Orchestrator) — —

    This issue's own work: 350e5d511 refactor(backend): consolidate orchestrator files 5→4 (#4048) — landed via PR #5027 on 2026-04-17. Plus dc413f324 cleanup of stale EnhancedOrchestrator docstrings (also #4048).

    Subsequent cleanup: dc5342f70 refactor(orchestration): 5 targeted fixes from discovery audit (#6404, 2026-04-28).

    Final state — verified 2026-05-04

    $ grep -rn "^class.*Orchestrator" autobot-backend --include="*.py" | grep -v __pycache__ | grep -v test
    autobot-backend/models/settings.py:207:class OrchestratorSettings(BaseSettings):     # config dataclass
    autobot-backend/orchestrator.py:146:class OrchestratorConfig:                          # internal config
    autobot-backend/orchestrator.py:175:class Orchestrator:                                # ← ONLY actual orchestrator class

    Of the 7 originally-listed files, 5 are gone, 1 is the canonical (orchestrator.py), and 1 is a thin FastAPI router (api/orchestration.py). Production-orchestrator-class count = 1. Original target was 4. Target exceeded.

    Phase 2 / Phase 3 / Phase 4 status (from original plan)

    Deep-audit follow-ups filed today (2026-05-04)

    A read-only deep-audit of the four remaining orchestration packages (agents/agent_orchestration/, enhanced_orchestration/, orchestration/, services/orchestration/) surfaced 7 separate consolidation opportunities. None of these are part of issue #4048's scope — they are new tech debt found during closure verification:

    # Severity Finding
    #6816 P1 Wire in or retire abandoned causal subsystem (5 files, 1,722 LOC, 0 production callers)
    #6817 P2 Dual WorkflowPlanner name collision — orphaned canonical vs live StrategyPlanner
    #6818 P2 Dual AgentCapability definitions — Enum vs dataclass, same name
    #6819 P2 Dual AgentRouter classes (522 LOC vs 68 LOC) — same name, different scope
    #6820 P2 4 orphaned orchestration modules (1,260 LOC, 0 production callers)
    #6821 P3 Topology modules unwired (336 LOC, #2137/#2138)
    #6822 P3 subagent_dispatcher.py lives in services/, test-only — layering violation

    Total tech debt surfaced: ~3,654 LOC of unwired or duplicated orchestration code, scoped into discrete actionable issues.

    Acceptance criteria — final check

  2. mrveiss commented on May 4, 2026

    @mrveiss
    OwnerAuthor

    Self-audit follow-up — 7 additional discovery issues filed

    After the user pushed back on whether the deep-audit findings were fully captured, I cross-checked the 4 audit reports against the 7 issues already filed and found I had missed 7 more. Filed now:

    # Sev Topic
    #6826 P1 #3228 closed prematurely — executor fragmentation persists (5 files, 3,223 LOC, no unified strategy)
    #6827 P2 WorkflowExecutor god class (1,178 LOC) — decompose into StepOrchestrator/ParallelCoordinator/CheckpointResumer
    #6828 P2 AgentRegistry fragmentation — 4 implementations + 1 Protocol with same name
    #6829 P2 RLRouter (Issue #2092) infrastructure-complete but unreachable in production
    #6830 P2 ExecutionStrategyHandler god class — 6 strategies in one 317-LOC class
    #6831 P3 TYPE_CHECKING import cycle: orchestration.performance_tracker ↔ enhanced_orchestration.types
    #6832 P3 Composability gap — SuccessCriteriaEvaluator + CollaborationCoordinator are single-caller modules

    Total tech debt surfaced by this issue's closure audit: 14 follow-up issues (#6816–#6822 + #6826–#6832).

    The most actionable: #6826 (P1) reveals that #3228 was closed before the migration was complete — code comments still reference it as "tracked in #3228" for work that hasn't happened.

  3. mrveiss commented on May 4, 2026

    @mrveiss
    OwnerAuthor

    Framing correction — "orphans" was wrong; these are unwired-by-design completed features

    User pushed back: the modules I called "orphans" all have explicit tracker issue references in their docstrings. Checking each:

    Module Tracker Tracker state
    causal_executor.py + 4 siblings #2154 CLOSED
    workflow_planner.py, workflow_documentation.py, agent_registry.py #381 CLOSED
    workflow_memory.py #3019 CLOSED
    topology.py #2137 CLOSED
    topology_routing.py #2138 CLOSED
    rl_router.py #2092 CLOSED
    success_criteria.py #3293 CLOSED

    Every tracker is closed but the code is not reachable from a production path. That's not orphan code — that's systemic premature-closure, the same pattern this very issue (#4048) almost fell into until the user pushed back on my first proposed closure.

    Filed as #6836 (P1) with all 3,906 LOC of evidence and recommended CLAUDE.md updates to the closure verification gate.

    The 14 follow-up issues (#6816–#6822, #6826–#6832) remain valid — they describe the wire-in work for each module — but their framing should be "complete the integration that the prematurely-closed parent tracker missed," not "audit and remove orphan." The issue bodies use "wire it in or retire," which is correct; only my user-facing summary used the wrong word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions