Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:37:27 +08:00
commit 37774aa937
131 changed files with 31137 additions and 0 deletions

View File

@@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ln-220-story-coordinator Workflow</title>
<link rel="stylesheet" href="../shared/css/diagram.css">
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<script>
mermaid.initialize({
startOnLoad: true,
theme: 'base',
themeVariables: {
primaryColor: '#4A90E2',
primaryTextColor: '#fff',
primaryBorderColor: '#2E5C8A',
lineColor: '#5C6BC0',
secondaryColor: '#7E57C2',
tertiaryColor: '#26A69A'
}
});
</script>
</head>
<body>
<div class="container">
<h1>ln-220-story-coordinator: Story Coordinator</h1>
<div class="diagram-section">
<h2>Workflow Diagram</h2>
<div class="mermaid">
graph TD
Start([Input: Epic Number]) --> Phase1[Phase 1: Context Assembly]
Phase1 --> Step1Discovery[Step 1: Discovery<br/>Team ID, Epic, Story Number]
Step1Discovery --> Step2Extract[Step 2: Extract Planning Info<br/>Q1-Q6 from Epic]
Step2Extract --> CheckQ2Q5{Q2 or Q5<br/>missing?}
CheckQ2Q5 -->|Yes| Step3HTML[Step 3: Frontend Research<br/>Scan HTML for AC/capabilities]
CheckQ2Q5 -->|No| Step4Fallback
Step3HTML --> Step4Fallback[Step 4: Fallback Search<br/>requirements.md, tech_stack.md]
Step4Fallback --> CheckMissing{Still<br/>missing?}
CheckMissing -->|Yes| Step5User[Step 5: User Input<br/>Ask for remaining info]
CheckMissing -->|No| Phase2
Step5User --> Phase2[Phase 2: Standards Research]
Phase2 --> ParseDomains[Parse Epic for domain keywords<br/>standards mentions]
ParseDomains --> SkipResearch{Standards<br/>mentioned?}
SkipResearch -->|No| EmptyResearch[Empty Standards Research]
SkipResearch -->|Yes| DelegateLN221[DELEGATE: ln-221-standards-researcher<br/>epic_description, story_domain]
DelegateLN221 --> WaitResearch[Wait for Standards Research]
WaitResearch --> CacheResearch[Cache Standards Research<br/>for workers Phase 5a/5b]
EmptyResearch --> Phase3[Phase 3: Planning]
CacheResearch --> Phase3
Phase3 --> BuildIDEAL[Build IDEAL Plan "in mind"<br/>Analyze Scope, 5-10 Stories<br/>Vertical Slicing, INVEST Checklist]
BuildIDEAL --> Phase4[Phase 4: Check Existing]
Phase4 --> QueryLinear[Query Linear for existing Stories<br/>list_issues project=Epic label=user-story<br/>Metadata ONLY ID, title, status]
QueryLinear --> CountCheck{Count = 0?}
CountCheck -->|Yes| Phase5a[Phase 5a: Delegate CREATE]
CountCheck -->|No| Phase5b[Phase 5b: Delegate REPLAN]
Phase5a --> DelegateLN222[DELEGATE: ln-222-story-creator<br/>epicData, idealPlan<br/>standardsResearch, teamId<br/>autoApprove]
DelegateLN222 --> WaitCREATE[Wait for worker output:<br/>Created Story URLs<br/>Summary + Next Steps]
WaitCREATE --> End([Done])
Phase5b --> DelegateLN223[DELEGATE: ln-223-story-replanner<br/>epicData, idealPlan<br/>standardsResearch, existingCount<br/>teamId, autoApprove]
DelegateLN223 --> WaitREPLAN[Wait for worker output:<br/>Operation results<br/>Warnings + URLs + Next Steps]
WaitREPLAN --> End
style Start fill:#4A90E2,stroke:#2E5C8A,color:#fff
style End fill:#26A69A,stroke:#1B5E20,color:#fff
style Phase1 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase2 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase3 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase4 fill:#7E57C2,stroke:#4A148C,color:#fff
style Phase5a fill:#26A69A,stroke:#1B5E20,color:#fff
style Phase5b fill:#FF9800,stroke:#E65100,color:#fff
style CountCheck fill:#FF9800,stroke:#E65100,color:#fff
style SkipResearch fill:#FF9800,stroke:#E65100,color:#fff
style CheckQ2Q5 fill:#FF9800,stroke:#E65100,color:#fff
style CheckMissing fill:#FF9800,stroke:#E65100,color:#fff
style DelegateLN221 fill:#FFC107,stroke:#F57C00,color:#000
style DelegateLN222 fill:#FFC107,stroke:#F57C00,color:#000
style DelegateLN223 fill:#FFC107,stroke:#F57C00,color:#000
style WaitResearch fill:#FFC107,stroke:#F57C00,color:#000
style WaitCREATE fill:#FFC107,stroke:#F57C00,color:#000
style WaitREPLAN fill:#FFC107,stroke:#F57C00,color:#000
</div>
</div>
<div class="info-section">
<h2>Key Information</h2>
<ul>
<li><strong>Type:</strong> Domain Coordinator (L2)</li>
<li><strong>Phases:</strong> 5 phases (Context Assembly → Standards Research → Planning → Check Existing → Delegate)</li>
<li><strong>Pattern:</strong> Decompose-First (build IDEAL → check existing → CREATE/REPLAN)</li>
<li><strong>Delegates to:</strong> ln-221-standards-researcher (Phase 2), ln-222-story-creator (Phase 5a), ln-223-story-replanner (Phase 5b)</li>
<li><strong>Output:</strong> Worker output (5-10 Stories with Standards Research in Technical Notes)</li>
<li><strong>Modes:</strong> Phase 5a: Delegate CREATE (no existing) / Phase 5b: Delegate REPLAN (KEEP/UPDATE/OBSOLETE/CREATE)</li>
<li><strong>Version:</strong> 4.0.0 (BREAKING - Orchestrator-Worker pattern, Phase 5a/5b delegation)</li>
</ul>
</div>
<div class="delegation-section">
<h2>Delegation Flow</h2>
<ul>
<li><strong>Phase 2:</strong> ln-221-standards-researcher v2.0.0
<ul>
<li><strong>Input:</strong> Epic description + Story domain</li>
<li><strong>Output:</strong> Standards Research (RFCs, industry standards, architectural patterns)</li>
<li><strong>Time-box:</strong> 15-20 minutes</li>
</ul>
</li>
<li><strong>Phase 5a:</strong> ln-222-story-creator v1.0.0
<ul>
<li><strong>Input:</strong> epicData, idealPlan, standardsResearch, teamId, autoApprove</li>
<li><strong>Output:</strong> Created Story URLs + summary + next steps</li>
<li><strong>Handles:</strong> Generate documents, validate INVEST, create in Linear, update kanban</li>
</ul>
</li>
<li><strong>Phase 5b:</strong> ln-223-story-replanner v1.0.0
<ul>
<li><strong>Input:</strong> epicData, idealPlan, standardsResearch, existingCount, teamId, autoApprove</li>
<li><strong>Output:</strong> Operation results + warnings + affected URLs + next steps</li>
<li><strong>Handles:</strong> Load existing (Progressive Loading), compare, show diffs, execute operations, update kanban</li>
</ul>
</li>
</ul>
</div>
<div class="notes-section">
<h2>Important Notes</h2>
<ul>
<li><strong>Phase 1 (5 Steps):</strong> Context Assembly with Sequential Numbering
<ul>
<li>Step 1: Discovery (Team ID, Epic, Next Story Number from kanban_board.md)</li>
<li>Step 2: Extract Planning Info (Q1-Q6 from Epic Goal, Scope In/Out, Success Criteria)</li>
<li>Step 3: Frontend Research (Optional - scan HTML for AC/capabilities if Q2/Q5 missing)</li>
<li>Step 4: Fallback Search (requirements.md, tech_stack.md for missing Q1/Q3/Q6)</li>
<li>Step 5: User Input (Only if still missing after Step 2-4)</li>
</ul>
</li>
<li><strong>Phase 2:</strong> Standards Research - delegates to ln-221, caches for workers. Focus: RFCs, architectural patterns (NOT libraries)</li>
<li><strong>Phase 3:</strong> Planning - ALWAYS build IDEAL plan FIRST (5-10 vertical Stories), INVEST checklist. Story Grouping: 1 Story = 1 vertical slice (UI → API → DB)</li>
<li><strong>Phase 4:</strong> Check Existing - query Linear for metadata ONLY (ID, title, status ~50 tokens/Story). Workers load FULL descriptions (~5,000 tokens/Story) for token efficiency</li>
<li><strong>Phase 5a:</strong> Delegate CREATE - ln-222-story-creator handles document generation, INVEST validation, Linear creation, kanban update</li>
<li><strong>Phase 5b:</strong> Delegate REPLAN - ln-223-story-replanner handles Progressive Loading (ONE BY ONE), comparison, diffs (AC, Standards Research), Story Split/Merge warnings, operations execution</li>
<li><strong>Token Efficiency:</strong> Coordinator loads metadata only (~500 tokens for 10 Stories), workers load full descriptions when needed (~50,000 tokens)</li>
<li><strong>Story Numbering:</strong> No Story 0 reserved (Stories start from US001). Epic 0 = Infrastructure Epic (contains US001-US010)</li>
<li><strong>Epic Numbering:</strong> Epic N = Linear Project number (global), NOT initiative-internal index (Epic 0-N)</li>
</ul>
</div>
<div class="changes-section">
<h2>Changes in v4.0.0 (BREAKING)</h2>
<ul>
<li><strong>Orchestrator-Worker Pattern:</strong> Decomposed to coordinator + 2 workers (ln-222, ln-223)</li>
<li><strong>Phase 4a/4b Removed:</strong> Replaced with Phase 5a/5b delegation</li>
<li><strong>Coordinator loads metadata only:</strong> ID, title, status (~50 tokens/Story)</li>
<li><strong>Workers load full descriptions:</strong> 8 sections (~5,000 tokens/Story)</li>
<li><strong>Progressive Loading:</strong> Now handled by ln-223-story-replanner, not coordinator</li>
<li><strong>Story execution logic:</strong> Moved to workers (ln-222, ln-223)</li>
<li><strong>Coordinator focuses on:</strong> Context assembly, standards research, planning, mode determination, delegation</li>
<li><strong>Token Efficiency:</strong> 10 Stories: 500 tokens (coordinator) vs 50,000 tokens (workers load when needed)</li>
</ul>
</div>
</div>
</body>
</html>