intelligent orchestration plan
Intelligent Orchestration in Drupal — Master Plan
Date: 2026-02-10 | Status: Planning | Owner: Thomas Scola Drupal: 11.3.3 | Site: drupal_testing-php8.2 | Modules: 235 installed, 164 enabled
Vision
Build 100% Drupal-native intelligent orchestration by rebuilding all 20 custom modules to properly extend the contrib ecosystem (drupal/orchestration, drupal/ai, drupal/ai_agents, drupal/eca, drupal/tool, drupal/mcp). Every module stays. Every module gets better. Anti-patterns get replaced with Drupal-native patterns while preserving and enhancing the unique functionality each module provides.
Current State (after 2026-02-10 work)
- 20 custom modules with ~35,000 LOC — all have unique value
- 164 contrib modules now enabled (up from 79) — stack unlocked
- tool_ai_connector enabled — 41+ Tool plugins now visible to agents
- ECA visual editor enabled — eca_ui + eca_modeller_bpmn + event sources
- ai_logging enabled — AI call/token/cost tracking active
- mcp_tools enabled — 222 ready-made MCP tools available
- charts_chartjs + dashboards_views enabled — visualization stack ready
Architecture: Outerloop / Innerloop
EXTERNAL OUTERLOOP (Activepieces / n8n / Zapier)
| orchestration module (REST/webhook bridge)
v
DRUPAL OUTERLOOP: Governance
ai_agents_ossa -> compliance gate
ai_agents_kagent -> deployment topology
eca -> workflow state machine
"Should this run? Where? Under what constraints?"
DRUPAL OUTERLOOP: Orchestration
mcp_registry -> service discovery + health
api_normalization -> API gateway + routing
orchestration -> external platform bridge
"How do services connect? What's healthy?"
INNERLOOP: Execution
ai_agents -> agent lifecycle (task->tools->solve)
tool -> typed tool execution
code_executor -> sandboxed compute
ai -> provider-agnostic LLM calls
"Run the task. Return the result. Nothing else."
PROTOCOL: Transport
mcp / mcp_client -> AI-native clients
orchestration -> automation platforms
http_client_manager -> external HTTP APIs
jsonrpc -> JSON-RPC 2.0
"Move bytes. Authenticate. Serialize."
Separation of Duties
| Module | Loop | Authority | Role |
|---|---|---|---|
| api_normalization | Outer | Schema | What APIs exist, how they're shaped |
| mcp_registry | Outer | Service | What's running, what's healthy |
| ai_agents_ossa | Outer | Compliance | What's allowed to run |
| ai_agents_kagent | Outer | Deployment | Where things run |
| code_executor | Inner | Execution | Sandboxed compute |
Key Insight: drupal/orchestration
Dries-backed (v1.0.0, 47 sites). Already enabled with all 5 submodules. Auto-exposes:
- ALL #[Tool] plugins to external platforms (orchestration_tool)
- ALL AI agents to external platforms (orchestration_ai_agents)
- ALL FunctionCall plugins (orchestration_ai_function)
- ALL ECA workflows (orchestration_eca)
Zero integration code needed. Ship a Tool plugin, it's automatically callable from Activepieces/n8n.
Workstream 1: Enable Critical Contrib — DONE
25+ contrib modules enabled on 2026-02-10. Stack is live.
| Batch | Modules | Status |
|---|---|---|
| Batch 1 | tool_ai_connector, eca_content/form/user/endpoint/queue/ui, ai_logging, ai_integration_eca_agents, charts_chartjs, dashboards_views | DONE |
| Batch 2 | eca_modeller_bpmn, tool_content/entity/explorer/system/user, tamper, ai_observability, openapi | DONE |
| Batch 3 | mcp_tools + 5 submodules, mcp_studio, ai_agents_extra_tools | DONE |
Workstream 2: Rebuild Custom Modules to Extend Contrib (Weeks 2-8)
No modules get removed. Every module gets rebuilt to properly use Drupal plugin patterns and extend the contrib stack. The unique functionality stays — the implementation patterns change.
Anti-Patterns to Convert (inside existing modules)
| Anti-Pattern | Count | Rebuild As |
|---|---|---|
| EventSubscribers | 6 (5 mcp_registry, 1 kagent) | ECA #[EcaEvent] + #[Action] plugins |
| Custom REST Resources | 4 (3 apple, 1 dita_ccms) | #[Tool] plugins exposed via MCP + orchestration |
| Custom Dashboard Blocks | 21+ (12 mcp_registry, 6 kagent, 3 gov_compliance) | Views + Charts style plugin |
| Custom Entities (data containers) | 30+ across modules | ECK entities (keep entities with complex business logic as PHP) |
| Custom Workflow Engines | 2 (langchain, orchestra) | ECA + FlowDrop (keep the orchestration logic, change the engine) |
| QueueWorkers | 5 across modules | advancedqueue or Symfony Messenger |
| Hardcoded Guzzle Clients | 1+ | http_client_manager YAML config |
| Custom Annotations | 9+ (layout_system_converter, mcp_registry) | PHP 8 attributes |
| Dead/Backup Files | 22 (14 langchain, 8 apple) | Delete (dead code only, no functionality lost) |
Per-Module Rebuild Plans
All 20 modules — what changes, what stays:
ai_agents_ossa (KEEP + enhance):
- Stays as-is — core OSSA IP, well-architected
- Minor: replace GuzzleHttpClient wrapper with http_client_manager
- Enhanced: merge cursor tools/generators into this module
ai_agents_kagent (REBUILD internals):
- Keep: K8s deployment logic, FunctionCall plugins, Messenger handlers
- Rebuild: 1 EventSubscriber -> ECA, 6 blocks -> Views+Charts, 5 data entities -> ECK
ai_agents_orchestra (REBUILD internals):
- Keep: agent mesh, consensus orchestration, ECA plugins, MCP bridge
- Rebuild: workflow engine -> ECA+FlowDrop, vector memory -> ai_context, LLM gateway -> ai ProviderProxy
mcp_registry (REBUILD internals — largest module):
- Keep: registry management, fleet orchestration, bulk ops, security layer
- Rebuild: 5 EventSubscribers -> ECA, 12 blocks -> Views+Charts, 8 entities -> ECK, 3 annotations -> attributes, consolidate 20+ controllers
api_normalization (REBUILD internals):
- Keep: AI API transforms (Anthropic->OpenAI, Ollama->OpenAI), circuit breaker, multi-provider routing
- Rebuild: gateway -> extend http_client_manager, schema -> extend openapi, 8 entities -> ECK
gov_compliance (REBUILD internals):
- Keep: all compliance services, Cedar engine, ECA plugins, 10 Tool plugins
- Rebuild: 3 blocks -> Views+Charts, 5 entities -> ECK, consolidate 18 controllers
code_executor (REBUILD internals):
- Keep: Docker execution engine, ECA plugins, Tool plugins
- Rebuild: QueueWorker -> Messenger, controller -> tool/mcp endpoint
ai_agents_crewai (REBUILD to extend ai_agents):
- Keep: crew orchestration patterns, multi-agent coordination logic
- Rebuild: properly extend AiAgentWrapper sub-agent system, use ECA for workflow routing
ai_agents_communication (REBUILD to extend mcp):
- Keep: A2A protocol logic, agent registry, message passing
- Rebuild: use MCP protocol as transport, REST controllers -> Tool plugins
ai_agents_client (REBUILD to extend mcp_client):
- Keep: OSSA client discovery, protocol adapters
- Rebuild: extend mcp_client for transport, QueueWorker -> Messenger
ai_provider_langchain (REBUILD to extend ai + eca):
- Keep: chain/workflow concepts, RAG pipeline, cost tracking
- Rebuild: workflow engine -> ECA+FlowDrop, entities -> ECK, cost tracking -> ai_logging, delete 14 dead backup files
ai_agents_claude (REBUILD to extend ai_provider_anthropic):
- Keep: Claude-specific tool logic
- Rebuild: properly extend ai_provider_anthropic, generic tools as #[Tool] plugins
ai_agents_huggingface (REBUILD to extend ai_provider_huggingface):
- Keep: model management, pipeline execution
- Rebuild: entity -> ECK, MCP server -> #[Mcp] plugin
ai_agents_cursor (MERGE into ai_agents_ossa):
- Keep: 10 MCP tools, 5 generators, AiAgent plugin, ECA events
- Rebuild: tools become standalone #[Tool] plugins, AiAgent moves to ai_agents_ossa
ai_provider_apple (REBUILD internals):
- Keep: 5 AIProvider plugins, ECA events
- Rebuild: 3 REST resources -> Tool plugins, 2 entities -> ECK, delete 8 dead files, consolidate controllers
alternative_services (REBUILD internals):
- Keep: DDEV integration, service discovery, addon management
- Rebuild: 4 entities -> ECK, 3 QueueWorkers -> advancedqueue, 2 blocks -> Views+Charts
layout_system_converter (REBUILD internals):
- Keep: conversion engines (Paragraphs->SDC, Layout Builder->XB, Site Studio->XB)
- Rebuild: 6 annotations -> PHP 8 attributes, consolidate controllers, Views for browsing
external_migration (KEEP as-is):
- Well-integrated with contrib, uses proper migrate patterns
- No anti-patterns found
dita_ccms (REBUILD minor):
- Keep: DITA XML engine, ECA plugins, Feeds parser
- Minor: REST resource -> Tool plugin, QueueWorker -> Messenger
drupal_patch_framework (KEEP as-is):
- Clean architecture, proper separation of concerns
- No anti-patterns found
Workstream 3: Immutable Audit Trail (Weeks 6-10)
Build trace_id propagation across the full outerloop/innerloop stack.
Design
ECK Entity: trace_entry
- Fields: trace_id (UUID), span_id, parent_span_id, layer (governance/orchestration/execution/protocol), module, event_type, timestamp, duration_ms, metadata (JSON), status (success/failure)
- Access control: insert-only (no edit, no delete form)
- Views integration for dashboards
Trace Context Service:
- Generates trace_id at outerloop entry points (orchestration webhook, ECA event, MCP call)
- Propagates via request attributes or DI
- Each layer writes trace entries with its span_id
Trace Points (9 steps):
- External trigger arrives -> orchestration logs source/platform
- OSSA compliance check -> ai_agents_ossa logs pass/fail
- ECA workflow fires -> eca logs event/conditions/actions
- Agent selects tools -> ai_agents logs triage/selection
- Tool executes -> tool logs ExecutableResult
- LLM called -> ai_logging logs tokens/cost/provider
- MCP server called -> mcp_registry logs tool_id/params
- Result returns to agent -> ai_agents logs solve/answer
- Result returns to external -> orchestration logs response
Dashboard:
- Views + Charts for trace visualization
- Filter by trace_id, time range, layer, status
- Aggregate metrics: calls/minute, avg latency, error rate, token costs
All 20 Custom Modules — Final Architecture
| Module | Role | Status |
|---|---|---|
| ai_agents_ossa | OSSA compliance + manifest + cursor tools | Rebuild + merge |
| ai_agents_kagent | K8s deployment topology | Rebuild internals |
| ai_agents_orchestra | Agent mesh + consensus | Rebuild internals |
| ai_agents_crewai | Multi-agent crew orchestration | Rebuild to extend ai_agents |
| ai_agents_communication | A2A protocol | Rebuild to extend mcp |
| ai_agents_client | OSSA client discovery | Rebuild to extend mcp_client |
| ai_agents_claude | Claude-specific tools | Rebuild to extend ai_provider_anthropic |
| ai_agents_huggingface | HF model management | Rebuild to extend ai_provider_huggingface |
| ai_agents_cursor | Developer tools + generators | Merge into ai_agents_ossa |
| ai_provider_apple | Apple Intelligence integration | Rebuild internals |
| ai_provider_langchain | Chain/workflow/RAG | Rebuild to extend ai + eca |
| mcp_registry | MCP service registry | Rebuild internals |
| api_normalization | AI API gateway + transforms | Rebuild internals |
| code_executor | Sandboxed execution | Rebuild internals |
| gov_compliance | Government compliance | Rebuild internals |
| alternative_services | DDEV integration | Rebuild internals |
| layout_system_converter | Layout migration | Rebuild internals |
| external_migration | AI-powered migration | Keep as-is |
| dita_ccms | DITA XML framework | Rebuild minor |
| drupal_patch_framework | Patch tooling | Keep as-is |
Architecture Principles (enforced going forward)
| Need | Use This | NEVER This |
|---|---|---|
| Event handling | ECA #[EcaEvent] + #[Action] | EventSubscriber class |
| AI tool for agents | #[Tool] plugin (auto-bridged to FunctionCall) | Custom FunctionCall |
| Dashboard/charts | Views + Charts style plugin | Custom Block plugin |
| Custom entity type | ECK (UI-based) | Custom PHP entity (unless complex logic) |
| API key storage | Key module | Config or hardcoded |
| MCP tools | #[Mcp] plugin or #[Tool] (auto-exposed) | Custom REST endpoint |
| Async jobs | advancedqueue or Symfony Messenger | Custom QueueWorker |
| External HTTP APIs | http_client_manager YAML config | Hardcoded Guzzle |
| External automation | orchestration (auto-exposes tools) | Custom webhook handlers |
| Workflow automation | ECA + modeler_api + FlowDrop | Custom workflow engines |
| AI call logging | ai_logging (built into ai module) | Custom logging services |
| Visual workflows | ECA + BPMN.io visual editor | Custom form wizards |
Timeline
| Week | Workstream | Outcome |
|---|---|---|
| 1 | Enable contrib + delete dead code only | DONE — 164 modules enabled |
| 2-3 | Rebuild crewai, claude, huggingface, communication | Properly extend contrib base classes |
| 4-5 | Rebuild client, langchain, alternative_services | Extend mcp_client, eca, advancedqueue |
| 6-7 | Rebuild mcp_registry, kagent internals | EventSubscribers->ECA, Blocks->Views |
| 8 | Rebuild orchestra, api_normalization internals | Workflow->ECA, Gateway->http_client_manager |
| 9-10 | Build trace_id propagation + ECK trace entity | Immutable audit trail |
| 11-12 | Dashboard views, integration testing | Production-ready |
Success Metrics
- All 20 custom modules rebuilt to extend contrib properly
- EventSubscribers: 6 -> 0 (all ECA)
- Custom dashboard blocks: 21+ -> 0 (all Views + Charts)
- Custom entities: 30+ data containers -> ECK (keep complex entities as PHP)
- Custom REST resources: 4 -> 0 (all Tool/MCP)
- Dead code files: 22 -> 0
- Enabled contrib modules: 164 (already achieved)
- All 41+ Tool plugins visible to agents via tool_ai_connector (already achieved)
- Full trace_id propagation across outerloop/innerloop
- Visual ECA editor accessible for no-code workflow building (already achieved)
- Every module publishable to drupal.org
Generated 2026-02-10 | Updated 2026-02-10 — rebuild approach, no modules removed