--- nextStep: './step-03a-execute-review.md' dataFileIndex: '../data/data-file-index.md' scriptsDir: '../bin/story-automator' outputFolder: '{output_folder}/story-automator' stateFilePattern: '{outputFolder}/orchestration-*.md' outputFile: '{outputFolder}/orchestration-{epic_id}-{timestamp}.md' retryStrategy: '../data/retry-fallback-strategy.md' executionPatterns: '../data/execution-patterns.md' subagentPrompts: '../data/subagent-prompts.md' --- ## 🚨 CRITICAL: Load Data File Index FIRST **BEFORE ANY EXECUTION**, load and read `{dataFileIndex}` completely. **DO NOT proceed until you have read the index and loaded the required files.** --- Set: `scripts="{scriptsDir}"` ## 🚨 CRITICAL: CLI Contract Check (Interface Drift Guard) Before running any story loop logic, verify required helper commands/flags still exist. ```bash # Core command availability "$scripts" tmux-wrapper --help >/dev/null "$scripts" monitor-session --help >/dev/null "$scripts" orchestrator-helper --help >/dev/null # Required spawn contract: --command must exist "$scripts" tmux-wrapper spawn --help | grep -q -- "--command" # Build command contract must be available "$scripts" tmux-wrapper build-cmd --help >/dev/null ``` If any check fails: **STOP and escalate immediately** with "helper CLI contract changed". --- # Step 3: Execute Build Cycle **Goal:** Autonomously execute all stories. Escalate only when decisions needed. **Interaction mode:** Deterministic autonomous execution. --- ## Setup Load from state document (located via `{stateFilePattern}`; output folder `{outputFolder}`; resolved path stored as `{outputFile}` for this run): - `storyRange`, `currentStory`, `currentStep` - `overrides` (skipAutomate, maxParallel) - `customInstructions` Resolve agent configuration using deterministic agents file (see `{retryStrategy}` for full function): ```bash state_file="{outputFile}" # resolve_agent_for_task "{task}" "$state_file" "{story_id}" -> sets primary_agent,fallback_agent ``` **IF resuming** (currentStory set): Skip to that point in loop. **IF fresh**: Display "**Starting build cycle for {count} stories...**" ## 🚨 CRITICAL: Execution Patterns **BEFORE executing any steps, read `{executionPatterns}` for:** - FORBIDDEN patterns (never chain multiple workflow steps) - REQUIRED patterns (verify state after each step) - Monitoring failure fallback sequence **Key rule:** Each step (create/dev/auto/review) MUST be executed and monitored separately. NEVER chain steps in loops. ## Story Loop > **⚠️ SPAWN PATTERN - READ THIS:** > Every `story-automator tmux-wrapper spawn` call **MUST** include `--command` with the built command: > ```bash > session=$("$scripts" tmux-wrapper spawn {step} {epic} {story_id} \ > --agent "$agent" \ > --command "$("$scripts" tmux-wrapper build-cmd {step} {story_id} --agent "$agent")") > ``` > **Missing `--command` = session sits idle → `never_active` failure!** **FOR EACH story in range:** ```bash "$scripts" orchestrator-helper state-update "$state_file" \ --set currentStory={story_id} --set currentStep=step-03-execute \ --set lastUpdated="$(date -u +%Y-%m-%dT%H:%M:%SZ)" echo "- **[$(date -u +%Y-%m-%dT%H:%M:%SZ)]** Starting story {story_id}" >> "$state_file" # Initialize Story Progress row sed -i '' "/