graph TD
Start((Start:
Execute Story)) --> Phase1[Phase 1: Discovery
Auto-discover Team ID]
Phase1 --> Phase2[Phase 2: Story + Tasks Overview
Load Story FULL description
❌ Tasks metadata ONLY from kanban_board.md]
Phase2 --> KanbanCheck{kanban_board.md
exists?}
KanbanCheck -->|No| SyncLinear[Fallback: Sync with Linear
Fetch tasks metadata ONLY
NO descriptions!]
SyncLinear --> LoopEntry
KanbanCheck -->|Yes| LoopEntry
%% Phase 3: Task Orchestration Loop
subgraph Phase3_Loop [⚙️ Phase 3: Task Orchestration Loop - Priority-Based (3 levels)]
direction TB
LoopEntry((Loop
Entry)) --> Phase3
Phase3[Read kanban_board.md
Count tasks by status]
Phase3 --> Priority0{🔴 PRIORITY 0
Has To Review?}
Priority0 -->|Yes| InvokeReviewer[[ln-332-task-reviewer
via Skill tool]]
InvokeReviewer -->|Task reviewed| ReloadAfterReview[Reload state]
ReloadAfterReview ==> LoopEntry
Priority0 -->|No| Priority1{🟡 PRIORITY 1
Has To Rework?}
Priority1 -->|Yes| InvokeRework[[ln-333-task-rework
via Skill tool]]
InvokeRework -->|Task fixed| ReloadAfterRework[Reload state]
ReloadAfterRework ==> LoopEntry
Priority1 -->|No| Priority2{🟢 PRIORITY 2
Has Todo?}
Priority2 -->|Yes| InvokeExecutor[[ln-331-task-executor
or ln-334-test-executor
via Skill tool]]
InvokeExecutor -->|Task executed| ReloadAfterExec[Reload state]
ReloadAfterExec ==> LoopEntry
Priority2 -->|No| StopCondition{{Stop Condition:
All Tasks Done}}
end
%% Phase 4: Story Review & Finalization (Delegation Pattern)
subgraph Phase4_Review [✅ Phase 4: Story Quality Delegation - Pass 1 & Pass 2]
direction TB
Phase4Start[All implementation tasks Done]
Phase4Start --> InvokePass1[Invoke ln-340-story-quality-gate Pass 1
via Skill tool]
InvokePass1 --> Pass1Execution[Pass 1 executes:
Code Quality → Regression → Manual Testing]
Pass1Execution --> Pass1Verdict{Pass 1 Verdict?}
Pass1Verdict -->|Test task created| AutoVerifyTest[Auto-verify via ln-320-story-validator
Backlog → Todo]
Pass1Verdict -->|Fix/refactor task created| AutoVerifyFix[Auto-verify via ln-320-story-validator
Backlog → Todo]
AutoVerifyTest --> LoopBackTest[GOTO Phase 3
Execute test task]
AutoVerifyFix --> LoopBackFix[GOTO Phase 3
Execute fix/refactor task]
LoopBackTest -.->|Test task Done| InvokePass2
LoopBackFix -.->|Fix Done| InvokePass1
InvokePass2[Update Story: In Progress → To Review
Invoke ln-340-story-quality-gate Pass 2
via Skill tool]
InvokePass2 --> Pass2Execution[Pass 2 executes:
Test verification Priority ≥15]
Pass2Execution --> Pass2Verdict{Pass 2 Verdict?}
Pass2Verdict -->|PASS| StoryDone[Story status: To Review → Done
Delete temp script
Workflow complete]
Pass2Verdict -->|FAIL| CreatePass2Fix[Create fix tasks in Backlog
Auto-verify → GOTO Phase 3]
end
StopCondition -.->|Trigger| Phase4Start
%% Self-healing: Return points
LoopBackTest -.-> ReturnToLoop
LoopBackFix -.-> ReturnToLoop
CreatePass2Fix -.-> ReturnToLoop
ReturnToLoop((Return to
Orchestration)) ==> LoopEntry
StoryDone --> End((End))
%% Styling
classDef discovery fill:#E3F2FD,stroke:#1976D2,stroke-width:2px
classDef loop fill:#FFF9C4,stroke:#F57C00,stroke-width:2px
classDef decision fill:#FFE0B2,stroke:#E64A19,stroke-width:2px
classDef action fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
classDef critical fill:#FFCDD2,stroke:#C62828,stroke-width:3px
classDef loopControl fill:#E1BEE7,stroke:#7B1FA2,stroke-width:2px
class Phase1,Phase2 discovery
class Phase3,InvokeReviewer,InvokeRework,InvokeExecutor,ReloadAfterReview,ReloadAfterRework,ReloadAfterExec loop
class Priority0,Priority1,Priority2,KanbanCheck,Pass1Verdict,Pass2Verdict decision
class Phase4Start,InvokePass1,Pass1Execution,InvokePass2,Pass2Execution,AutoVerifyTest,AutoVerifyFix,LoopBackTest,LoopBackFix,CreatePass2Fix,StoryDone action
class StopCondition critical
class LoopEntry,ReturnToLoop loopControl