Six-Application Control Plane (Research Batch 2)
Source: “Orchestrating Multi-Agent Refactoring at Scale: An Enterprise Blueprint for Legacy Deconstruction” (saved 2026-07-18).
Problem restated
~70M LOC across hundreds of microservices. ~65M LOC = repetitive boilerplate, outdated library wrappers, redundant config frameworks. ~5M LOC = core custom business logic. Manual refactoring economically non-viable; unguided autonomous agents on raw source → catastrophic sequencing errors, elevated defect density, unsustainable token costs.
Core move: transition from unguided AI coding to a structured multi-agent control plane — six specialized applications coordinating via standardized protocols (MCP etc.), orchestrating up to 1,000 parallel agents.
The six applications
| Application | Core tech/protocols | Function | Key metric |
|---|---|---|---|
| Codebase Knowledge Graph Engine | Tree-sitter, SQLite, multi-phase build pipelines, MCP | AST-level definitions, call graphs, cross-service dependencies | Query latency <1ms; token reduction 120× |
| Declarative Code Rewrite Engine | GritQL, Rust AST-matching, spell-synthesis pipeline | Deterministic syntax-aware refactoring of legacy boilerplate | 100% of boilerplate deterministic |
| Multi-Agent Orchestration Engine | Temporal durable execution, LangGraph subgraphs, Git worktrees | Parallel agent execution, state persistence, transaction ordering | 96% workflow recovery after infra crash |
| Intelligent Triage & Routing Gateway | Semantic clustering, vector embeddings, Slack/Jira APIs | Intercepts agent queries, deduplicates roadblocks, alerts owners | Human interruptions 8 → 3 checkpoints |
| Autonomous Quality & Guardrail App | Semgrep, OSV-Scanner, CodeScene MCP, jscpd, CI pipelines | Security flaws, code smells, duplication, code health scores | Code Health target ≥9.5 (AI-ready) |
| Multi-Agent Monitoring Dashboard | LiteLLM proxy, Redis circuit breakers, OpenTelemetry | Token usage, model costs, agent performance, infra health | 100% API availability during cache degradation |
Four-phase execution sequence
- Repository mapping + code health indexing — Tree-sitter codebase-memory MCP nodes across microservices; baseline Code Health scores; identify hotspots.
- Declarative boilerplate elimination — GritQL/ast-grep transformation rules; zero-token AST migrations on the 65M boilerplate LOC.
- High-value core refactoring + verification — deterministic extraction manifests, service boundaries; parallel contract verification via fuzzer harnesses.
- Production-scale 1,000-agent orchestration — Temporal + LangGraph control; clarifying queries through triage gateway.
Actionable recommendations (leadership sequencing)
- Codebase intelligence + health baselines first. Deploy knowledge graph across all target microservices; baseline Code Health; prioritize hotspots (highest ROI). Configure
AGENTS.md/CLAUDE.mdat every repo root: architecture, coding standards, test commands. - Boilerplate elimination before any autonomous model touches business logic. Declarative AST patterns (GritQL/ast-grep): standardize loggers, update deprecated API formats, remove dead code. Local deterministic execution; reduces token consumption for later phases.
- Orchestration layer: Temporal activities for all non-deterministic actions; activity heartbeats for long model generations; strict iteration bounds (history limits); isolated Git worktrees for parallel tasks.
- Triage gateway + monitoring last before scale-up: token-aware TPM/RPM limits + budget attribution keys in LiteLLM; triage integrated with Slack + developer directory routing high-risk questions to microservice owners.