--- name: Orchestration Planner description: Plan multi-step workflows using capability graph and Codex-powered goal decomposition with HTN-style hierarchical task planning. version: 1.0.0 category: ai-native tags: - codex - planning - orchestration - htn --- # Orchestration Planner **Plan multi-step workflows using capability graph and Codex-powered goal decomposition** ## Purpose Takes high-level goals and decomposes them into executable workflows using the capability graph. Uses Codex to understand goal semantics, find matching capabilities, validate preconditions, and generate Hierarchical Task Network (HTN) plans with alternatives and scoring. ## When to Use - Converting user goals into executable plans (e.g., "build RAG system") - Finding optimal capability sequences for complex tasks - Validating that project state supports a capability - Generating alternatives when primary path is blocked - Explaining why certain capabilities are recommended ## Key Capabilities - **Goal Decomposition**: Uses Codex to break goals into required effects - **Capability Matching**: Finds capabilities that produce desired effects - **Precondition Validation**: Checks if current project state satisfies requirements - **HTN Planning**: Builds hierarchical task networks with subtasks - **Scoring & Ranking**: Evaluates paths by cost, latency, risk, diversity - **Alternative Generation**: Provides fallback options when primary path fails - **Decision Logging**: Captures rationale for capability selection ## Inputs ```yaml inputs: goal: string # User goal (e.g., "implement RAG") project_state: object # Current project state (files, dependencies, env vars) capability_graph: string # Path to capability-graph.json preferences: object # User preferences (cost_weight, risk_tolerance, etc.) context: array # Recently used capabilities (for cooldown) ``` ## Process ### Step 1: Goal Analysis with Codex ```bash # Use Codex to understand goal and extract required effects codex exec " Analyze this goal and determine what effects are needed: GOAL: ${USER_GOAL} Examples of effects: - creates_vector_index - adds_auth_middleware - configures_database - implements_api_endpoint - adds_tests Task: Extract the effects needed to achieve this goal. Output JSON: { \"goal\": \"original goal\", \"required_effects\": [\"effect1\", \"effect2\"], \"optional_effects\": [\"effect3\"], \"domains\": [\"rag\", \"api\"], \"reasoning\": \"explanation\" } " > /tmp/goal-analysis.json ``` ### Step 2: Find Candidate Capabilities ```bash # Query capability graph for matching capabilities python3 < /tmp/htn-plan.json ``` ### Step 5: Score and Rank Plans ```bash # Score plan using utility function python3 < /tmp/decision-log.json <