agile-context-engineering 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.claude-plugin/marketplace.json +18 -0
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +7 -1
  4. package/README.md +16 -12
  5. package/agents/ace-code-discovery-analyst.md +245 -245
  6. package/agents/ace-code-integration-analyst.md +248 -248
  7. package/agents/ace-code-reviewer.md +375 -375
  8. package/agents/ace-product-owner.md +365 -361
  9. package/agents/ace-project-researcher.md +606 -606
  10. package/agents/ace-technical-application-architect.md +315 -315
  11. package/bin/install.js +587 -173
  12. package/hooks/ace-check-update.js +15 -14
  13. package/hooks/ace-statusline.js +30 -12
  14. package/hooks/hooks.json +14 -0
  15. package/package.json +3 -2
  16. package/shared/lib/ace-core.js +53 -0
  17. package/shared/lib/ace-core.test.js +308 -308
  18. package/shared/lib/ace-story.test.js +250 -250
  19. package/skills/execute-story/SKILL.md +116 -110
  20. package/skills/execute-story/script.js +13 -27
  21. package/skills/execute-story/script.test.js +261 -261
  22. package/skills/execute-story/story-template.xml +451 -451
  23. package/skills/execute-story/workflow.xml +3 -1
  24. package/skills/help/SKILL.md +71 -69
  25. package/skills/help/script.js +32 -35
  26. package/skills/help/script.test.js +183 -183
  27. package/skills/help/workflow.xml +14 -3
  28. package/skills/init-coding-standards/SKILL.md +91 -72
  29. package/skills/init-coding-standards/coding-standards-template.xml +531 -531
  30. package/skills/init-coding-standards/script.js +50 -59
  31. package/skills/init-coding-standards/script.test.js +70 -70
  32. package/skills/init-coding-standards/workflow.xml +1 -1
  33. package/skills/map-cross-cutting/SKILL.md +126 -89
  34. package/skills/map-cross-cutting/workflow.xml +1 -1
  35. package/skills/map-guide/SKILL.md +126 -89
  36. package/skills/map-guide/workflow.xml +1 -1
  37. package/skills/map-pattern/SKILL.md +125 -89
  38. package/skills/map-pattern/workflow.xml +1 -1
  39. package/skills/map-story/SKILL.md +180 -127
  40. package/skills/map-story/templates/tech-debt-index.xml +125 -125
  41. package/skills/map-story/workflow.xml +2 -2
  42. package/skills/map-subsystem/SKILL.md +155 -111
  43. package/skills/map-subsystem/script.js +51 -60
  44. package/skills/map-subsystem/script.test.js +68 -68
  45. package/skills/map-subsystem/templates/subsystem-architecture.xml +343 -343
  46. package/skills/map-subsystem/templates/subsystem-structure.xml +234 -234
  47. package/skills/map-subsystem/workflow.xml +1173 -1173
  48. package/skills/map-sys-doc/SKILL.md +125 -90
  49. package/skills/map-sys-doc/workflow.xml +1 -1
  50. package/skills/map-system/SKILL.md +103 -85
  51. package/skills/map-system/script.js +75 -84
  52. package/skills/map-system/script.test.js +73 -73
  53. package/skills/map-system/templates/system-structure.xml +177 -177
  54. package/skills/map-system/templates/testing-framework.xml +283 -283
  55. package/skills/map-system/workflow.xml +667 -667
  56. package/skills/map-walkthrough/SKILL.md +140 -92
  57. package/skills/map-walkthrough/workflow.xml +457 -457
  58. package/skills/plan-backlog/SKILL.md +93 -75
  59. package/skills/plan-backlog/script.js +121 -136
  60. package/skills/plan-backlog/script.test.js +83 -83
  61. package/skills/plan-backlog/workflow.xml +1348 -1348
  62. package/skills/plan-feature/SKILL.md +99 -76
  63. package/skills/plan-feature/feature-template.xml +361 -361
  64. package/skills/plan-feature/script.js +131 -148
  65. package/skills/plan-feature/script.test.js +80 -80
  66. package/skills/plan-feature/workflow.xml +1 -1
  67. package/skills/plan-product-vision/SKILL.md +91 -75
  68. package/skills/plan-product-vision/product-vision-template.xml +227 -227
  69. package/skills/plan-product-vision/script.js +51 -60
  70. package/skills/plan-product-vision/script.test.js +69 -69
  71. package/skills/plan-product-vision/workflow.xml +337 -337
  72. package/skills/plan-story/SKILL.md +125 -102
  73. package/skills/plan-story/script.js +18 -49
  74. package/skills/plan-story/story-template.xml +8 -1
  75. package/skills/plan-story/workflow.xml +17 -1
  76. package/skills/research-external-solution/SKILL.md +120 -107
  77. package/skills/research-external-solution/external-solution-template.xml +832 -832
  78. package/skills/research-external-solution/script.js +229 -238
  79. package/skills/research-external-solution/script.test.js +134 -134
  80. package/skills/research-external-solution/workflow.xml +657 -657
  81. package/skills/research-integration-solution/SKILL.md +121 -98
  82. package/skills/research-integration-solution/integration-solution-template.xml +1015 -1015
  83. package/skills/research-integration-solution/script.js +223 -231
  84. package/skills/research-integration-solution/script.test.js +134 -134
  85. package/skills/research-integration-solution/workflow.xml +711 -711
  86. package/skills/research-story-wiki/SKILL.md +101 -92
  87. package/skills/research-story-wiki/script.js +223 -231
  88. package/skills/research-story-wiki/script.test.js +138 -138
  89. package/skills/research-story-wiki/story-wiki-template.xml +194 -194
  90. package/skills/research-story-wiki/workflow.xml +473 -473
  91. package/skills/research-technical-solution/SKILL.md +131 -103
  92. package/skills/research-technical-solution/script.js +223 -231
  93. package/skills/research-technical-solution/script.test.js +134 -134
  94. package/skills/research-technical-solution/technical-solution-template.xml +1025 -1025
  95. package/skills/research-technical-solution/workflow.xml +761 -761
  96. package/skills/review-story/SKILL.md +99 -100
  97. package/skills/review-story/script.js +8 -16
  98. package/skills/review-story/script.test.js +169 -169
  99. package/skills/review-story/story-template.xml +451 -451
  100. package/skills/review-story/workflow.xml +1 -1
  101. package/skills/update/SKILL.md +65 -53
  102. package/skills/update/workflow.xml +21 -5
@@ -1,1025 +1,1025 @@
1
- <technical-solution>
2
-
3
- <purpose>
4
- Template for the `## Technical Solution` section that is APPENDED directly into
5
- the story file (`.ace/artifacts/product/&lt;id-epic_name&gt;/&lt;id-feature_name&gt;/&lt;id-story_name&gt;/&lt;id-story_name&gt;.md`).
6
-
7
- This is pass 5 of the story specification pipeline (see story.xml composition).
8
- Unlike passes 3-4 which produce separate artifacts, pass 5 writes directly into the
9
- story file. The entire technical solution (1000-2000+ lines) is appended as the
10
- `## Technical Solution` section.
11
-
12
- The technical solution uses:
13
- - Business requirements from the story (User Story, Description, AC — passes 1-2)
14
- - Wiki references from the story's Relevant Wiki section (pass 2)
15
- - Integration analysis from the story directory (pass 4 — MANDATORY)
16
- - External analysis from the story directory (pass 3 — OPTIONAL)
17
- - Feature file for broader context
18
-
19
- To create a concrete technical solution design following Clean Architecture principles,
20
- SOLID patterns, OOP best practices, considering the external analysis for approach,
21
- algorithms and formulas (when most efficient and performant), while following the
22
- integration analysis so that we don't break our already complex codebase.
23
-
24
- **CRITICAL**: The technical solution MUST include detailed sequence diagrams for EVERY
25
- scenario in the Acceptance Criteria, showing the complete flow of data and control
26
- through all architectural layers.
27
-
28
- This document serves as both a local markdown section in the story file and a
29
- GitHub issue section. All formatting must render cleanly in GitHub issue bodies.
30
-
31
- CRITICAL: This technical solution output will be used as PROMPT CONTEXT for the AI agent
32
- implementing this feature. Therefore:
33
- - INCLUDE ALL DETAILS — don't summarize or omit
34
- - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
35
- - BE EXPLICIT — don't assume the implementing AI will know anything not explicitly stated
36
- - INCLUDE ALL DIAGRAMS — class, sequence, component diagrams are essential
37
- </purpose>
38
-
39
- <output-format>
40
-
41
- <!-- ═══════════════════════════════════════════════════════════════════ -->
42
- <!-- SECTION 1: HEADER -->
43
- <!-- ═══════════════════════════════════════════════════════════════════ -->
44
-
45
- <section name="header">
46
- ## Technical Solution
47
-
48
- ### Solution Context
49
- - **Story**: [Story ID] — [Story Title]
50
- - **Feature**: [Feature ID] — [Feature Title]
51
- - **Epic**: [Epic ID] — [Epic Title]
52
- - **Design Date**: [Current date]
53
- - **Wiki Documents Loaded**: [N] files
54
- - **Integration Analysis**: Incorporated
55
- - **External Analysis**: [Incorporated / Not available]
56
- - **AC Scenarios**: [N] (each with sequence diagram)
57
- - **New Files**: [N] | **Modified Files**: [N]
58
- </section>
59
-
60
- <!-- ═══════════════════════════════════════════════════════════════════ -->
61
- <!-- SECTION 2: ARCHITECTURE OVERVIEW -->
62
- <!-- ═══════════════════════════════════════════════════════════════════ -->
63
-
64
- <section name="architecture-overview">
65
- ### Architecture Overview
66
-
67
- [Brief description of the technical approach — 3-5 sentences covering:
68
- - What the solution implements
69
- - Key architectural decisions
70
- - How it integrates with the existing codebase
71
- - Clean Architecture compliance]
72
-
73
- #### Clean Architecture Compliance
74
- - **Domain Layer**: [Key domain entities and value objects]
75
- - **Application Layer**: [Use cases and service interfaces]
76
- - **Infrastructure Layer**: [Technical implementations]
77
- - **Presentation Layer**: [API/UI components]
78
-
79
- #### Key Technical Decisions
80
- 1. [Decision 1 with rationale]
81
- 2. [Decision 2 with rationale]
82
- 3. [Additional decisions...]
83
- </section>
84
-
85
- <!-- ═══════════════════════════════════════════════════════════════════ -->
86
- <!-- SECTION 3: COMPONENT & BOUNDARY ARCHITECTURE -->
87
- <!-- ═══════════════════════════════════════════════════════════════════ -->
88
-
89
- <section name="component-boundary-architecture">
90
- ### V.1. Component &amp; Boundary Architecture
91
-
92
- &lt;!-- Document the comprehensive component architecture and system boundaries
93
- SPECIFIC to this story. --&gt;
94
-
95
- #### Story Boundary Diagram
96
-
97
- &lt;!-- Map ALL components, their boundaries, and external interactions for THIS STORY.
98
- Use Mermaid diagrams — GitHub renders them natively. --&gt;
99
-
100
- ```mermaid
101
- graph TB
102
- subgraph "Story: [Name] Boundary"
103
- subgraph "Presentation Layer"
104
- P1[ComponentName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: exact purpose]
105
- end
106
-
107
- subgraph "Application Layer"
108
- A1[UseCaseName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: orchestration]
109
- end
110
-
111
- subgraph "Domain Layer"
112
- D1[EntityName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: business logic]
113
- end
114
-
115
- subgraph "Infrastructure Layer"
116
- I1[ServiceName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: external integration]
117
- end
118
- end
119
-
120
- External1[External System/Actor]
121
- External1 -->|protocol/format| P1
122
- ```
123
-
124
- #### Component Documentation
125
- - Each component's EXACT responsibility in this story
126
- - Communication protocols between components
127
- - Data formats exchanged
128
- - State management requirements
129
- - Error propagation paths
130
-
131
- #### Layer Architecture Analysis
132
-
133
- ```mermaid
134
- graph TD
135
- subgraph "Clean Architecture Placement"
136
- direction TB
137
- A[Domain: Story Entities &amp; Business Rules]
138
- B[Application: Story Use Cases &amp; Orchestration]
139
- C[Infrastructure: Story Technical Implementations]
140
- D[Presentation: Story UI/API Components]
141
- end
142
- ```
143
-
144
- **Layer Responsibilities for This Story:**
145
- - **Domain**: [Specific entities, value objects, business rules]
146
- - **Application**: [Specific use cases, service interfaces]
147
- - **Infrastructure**: [Specific implementations, external services]
148
- - **Presentation**: [Specific controllers, views, DTOs]
149
- </section>
150
-
151
- <!-- ═══════════════════════════════════════════════════════════════════ -->
152
- <!-- SECTION 4: DESIGN PATTERNS & TECHNICAL DECISIONS -->
153
- <!-- ═══════════════════════════════════════════════════════════════════ -->
154
-
155
- <section name="design-patterns-decisions">
156
- ### V.2. Design Patterns &amp; Technical Decisions
157
-
158
- &lt;!-- Document ALL design patterns required for THIS STORY and technical decisions. --&gt;
159
-
160
- #### Identified Design Patterns
161
-
162
- &lt;!-- For EACH pattern: --&gt;
163
-
164
- **Pattern: [Pattern Name]**
165
- - **Purpose in This Story**: Why needed for this specific story
166
- - **Problem Solved**: What story-specific problem it addresses
167
- - **Implementation**:
168
- ```typescript
169
- // Exact implementation for this story
170
- interface IStoryPattern {
171
- method(): void;
172
- }
173
-
174
- class ConcreteImplementation implements IStoryPattern {
175
- // Story-specific implementation
176
- }
177
- ```
178
- - **Integration Points**: Where this pattern connects in the story flow
179
- - **Rationale**: Why this pattern over alternatives
180
-
181
- &lt;!-- Repeat for each identified pattern --&gt;
182
-
183
- #### Technical Decisions
184
-
185
- &lt;!-- For EACH decision: --&gt;
186
-
187
- **Decision: [Technology/Approach Choice]**
188
- - **Options Considered**: [List alternatives evaluated]
189
- - **Decision**: [What was chosen]
190
- - **Rationale**: [Why this choice for this story]
191
- - **Trade-offs**: [Pros and cons]
192
- - **Impact**: [How it affects implementation]
193
-
194
- &lt;!-- Repeat for each decision --&gt;
195
- </section>
196
-
197
- <!-- ═══════════════════════════════════════════════════════════════════ -->
198
- <!-- SECTION 5: CLASS DIAGRAMS & INTERFACES -->
199
- <!-- ═══════════════════════════════════════════════════════════════════ -->
200
-
201
- <section name="class-diagrams-interfaces">
202
- ### V.3. Complete Class Diagrams &amp; Interfaces
203
-
204
- &lt;!-- CRITICAL CODING STANDARDS ENFORCEMENT:
205
- EVERY interface, class, type, enum MUST be in its OWN SEPARATE FILE!
206
- NEVER put multiple interfaces/classes/types in one file!
207
- Each code block below represents a SEPARATE FILE!
208
-
209
- File naming: Each interface/class/type gets its own file named exactly after it:
210
- IChartApi interface → IChartApi.ts
211
- ChartOptions interface → ChartOptions.ts
212
- LineStyle type → LineStyle.ts
213
- ChartType enum → ChartType.ts --&gt;
214
-
215
- ```mermaid
216
- classDiagram
217
- class StoryMainClass {
218
- -privateField: Type
219
- +publicField: Type
220
- +constructor(params)
221
- +publicMethod(param: Type): ReturnType
222
- -privateMethod(): void
223
- }
224
-
225
- class IStoryInterface {
226
- &lt;&lt;interface&gt;&gt;
227
- +requiredMethod(): Type
228
- +property: Type
229
- }
230
-
231
- StoryMainClass ..|> IStoryInterface : implements
232
- ```
233
-
234
- #### Domain Layer Interfaces
235
- &lt;!-- Each interface in its OWN FILE --&gt;
236
-
237
- ```typescript
238
- // File: domain/interfaces/IStoryEntity.ts
239
- export interface IStoryEntity {
240
- // Properties with exact types
241
- id: string;
242
- data: StoryData;
243
-
244
- // Methods with full signatures
245
- process(input: Input): Output;
246
- validate(): ValidationResult;
247
- }
248
- ```
249
-
250
- #### Application Layer Interfaces
251
- &lt;!-- Each interface in its OWN FILE --&gt;
252
-
253
- ```typescript
254
- // File: application/interfaces/IStoryUseCase.ts
255
- export interface IStoryUseCase {
256
- execute(command: StoryCommand): Promise&lt;StoryResult&gt;;
257
- }
258
- ```
259
-
260
- &lt;!-- Repeat for ALL interfaces, classes, types needed --&gt;
261
- </section>
262
-
263
- <!-- ═══════════════════════════════════════════════════════════════════ -->
264
- <!-- SECTION 6: DATA MODELS & STRUCTURES -->
265
- <!-- ═══════════════════════════════════════════════════════════════════ -->
266
-
267
- <section name="data-models">
268
- ### V.4. Data Models &amp; Structures
269
-
270
- &lt;!-- EACH MODEL/INTERFACE IN SEPARATE FILE
271
- - domain/interfaces/IChartApi.ts (ONE interface)
272
- - domain/types/ChartOptions.ts (ONE type)
273
- - domain/enums/ChartType.ts (ONE enum)
274
- - NEVER: domain/interfaces/AllInterfaces.ts (MULTIPLE - VIOLATION!) --&gt;
275
-
276
- #### Core Data Models
277
- ```typescript
278
- // File: domain/models/StoryData.ts
279
- export interface StoryData {
280
- id: string;
281
- timestamp: number;
282
- payload: {
283
- // Complete structure
284
- };
285
- }
286
- ```
287
-
288
- #### DTOs
289
- ```typescript
290
- // File: application/dtos/StoryRequestDTO.ts
291
- export interface StoryRequestDTO {
292
- // Input structure
293
- }
294
-
295
- // File: application/dtos/StoryResponseDTO.ts
296
- export interface StoryResponseDTO {
297
- // Output structure
298
- }
299
- ```
300
-
301
- #### State Management Structure
302
- ```typescript
303
- // File: [appropriate layer]/state/StoryState.ts
304
- interface StoryState {
305
- // Component state
306
- data: StoryData[];
307
- loading: boolean;
308
- error: Error | null;
309
-
310
- // UI state
311
- selectedItem: string | null;
312
- filters: FilterOptions;
313
- }
314
- ```
315
- </section>
316
-
317
- <!-- ═══════════════════════════════════════════════════════════════════ -->
318
- <!-- SECTION 7: ALGORITHMS & BUSINESS LOGIC -->
319
- <!-- ═══════════════════════════════════════════════════════════════════ -->
320
-
321
- <section name="algorithms-business-logic">
322
- ### V.5. Algorithms &amp; Business Logic
323
-
324
- &lt;!-- If external analysis is available:
325
- Consider the external system's algorithms and formulas as REFERENCE.
326
- Use them when they are the MOST EFFICIENT AND PERFORMANT approach.
327
- If you can identify a better approach, use the better approach.
328
- DO NOT blindly copy — USE JUDGMENT.
329
-
330
- If no external analysis:
331
- Design algorithms based on requirements, industry best practices,
332
- and Clean Architecture principles. --&gt;
333
-
334
- #### Constants &amp; Configuration
335
- ```typescript
336
- // File: domain/constants/StoryConstants.ts
337
- // ALL constants centralized — NO hardcoding anywhere in the codebase!
338
- export const STORY_CONSTANTS = {
339
- // Configuration values with clear names
340
- MAX_ITEMS: 10000,
341
- BATCH_SIZE: 100,
342
- THROTTLE_MS: 16, // 60 FPS
343
- DEBOUNCE_MS: 300,
344
-
345
- // Calculation constants
346
- SMOOTHING_FACTOR: 0.3,
347
- WEIGHT_COEFFICIENT: 2.5,
348
- NORMALIZATION_BASE: 100,
349
-
350
- // Thresholds
351
- MIN_ZOOM: 0.1,
352
- MAX_ZOOM: 1000,
353
- VISIBILITY_THRESHOLD: 0.01,
354
- } as const;
355
- ```
356
-
357
- #### Core Algorithms
358
-
359
- &lt;!-- For EACH algorithm: --&gt;
360
-
361
- **Algorithm: [Name]**
362
- - **Source**: [Designed from requirements / Adapted from external analysis section X.Y]
363
- - **Purpose**: [What this algorithm achieves]
364
- - **Mathematical Formula**:
365
- ```
366
- result = (value * SMOOTHING_FACTOR + previousValue * (1 - SMOOTHING_FACTOR)) / NORMALIZATION_BASE
367
- ```
368
- - **Implementation**:
369
- ```typescript
370
- // File: domain/services/[ServiceName].ts
371
- function algorithmName(input: Input): Output {
372
- // Step 1: [description]
373
- const smoothed = input.value * STORY_CONSTANTS.SMOOTHING_FACTOR +
374
- this.previousValue * (1 - STORY_CONSTANTS.SMOOTHING_FACTOR);
375
-
376
- // Step 2: [description]
377
- const normalized = smoothed / STORY_CONSTANTS.NORMALIZATION_BASE;
378
-
379
- // Step 3: Edge case handling
380
- if (normalized > MAX_VALUE) return MAX_VALUE;
381
- if (normalized < MIN_VALUE) return MIN_VALUE;
382
-
383
- // Step 4: Precision
384
- return Math.round(normalized * 100) / 100;
385
- }
386
- ```
387
- - **Example Calculation**:
388
- ```
389
- Input: value = 150, previousValue = 100
390
- Step 1: 150 * 0.3 = 45
391
- Step 2: 100 * 0.7 = 70
392
- Step 3: 45 + 70 = 115
393
- Step 4: 115 / 100 = 1.15
394
- Output: 1.15
395
- ```
396
-
397
- &lt;!-- Repeat for each algorithm --&gt;
398
-
399
- #### Business Rules
400
- ```typescript
401
- // File: domain/rules/StoryBusinessRules.ts
402
- class StoryBusinessRules {
403
- // Validation rules
404
- validateInput(input: Input): boolean {
405
- if (!input?.value) return false;
406
- if (input.value < STORY_CONSTANTS.MIN_THRESHOLD) return false;
407
- if (input.value > STORY_CONSTANTS.MAX_THRESHOLD) return false;
408
- return true;
409
- }
410
-
411
- // Business constraints
412
- checkConstraints(data: Data): ConstraintResult {
413
- const validTransitions = STATE_TRANSITIONS[data.currentState];
414
- return validTransitions.includes(data.nextState);
415
- }
416
- }
417
- ```
418
- </section>
419
-
420
- <!-- ═══════════════════════════════════════════════════════════════════ -->
421
- <!-- SECTION 8: EVENT FLOW & ENTRY POINTS -->
422
- <!-- ═══════════════════════════════════════════════════════════════════ -->
423
-
424
- <section name="event-flow-entry-points">
425
- ### V.6. Event Flow &amp; Entry Points
426
-
427
- &lt;!-- Map ALL event flows and entry points for THIS STORY. --&gt;
428
-
429
- #### Entry Points
430
- 1. **User Actions**:
431
- - [Action type]: `methodName()` at [file:line]
432
-
433
- 2. **API Endpoints**:
434
- - [Protocol]: `[endpoint]` at [file:line]
435
-
436
- 3. **Event Triggers**:
437
- - [Event type]: `on('[event-name]')` at [file:line]
438
-
439
- #### Event Flow Sequences
440
- ```mermaid
441
- sequenceDiagram
442
- participant User
443
- participant UI
444
- participant App
445
- participant Domain
446
-
447
- User->>UI: Trigger Action
448
- UI->>App: Process Command
449
- App->>Domain: Execute Business Logic
450
- Domain-->>App: Return Result
451
- App-->>UI: Update View
452
- UI-->>User: Show Result
453
- ```
454
- </section>
455
-
456
- <!-- ═══════════════════════════════════════════════════════════════════ -->
457
- <!-- SECTION 9: MANDATORY SEQUENCE DIAGRAMS FOR ALL AC -->
458
- <!-- ═══════════════════════════════════════════════════════════════════ -->
459
-
460
- <section name="sequence-diagrams-mandatory">
461
- ### V.7. MANDATORY Sequence Diagrams for ALL Acceptance Criteria
462
-
463
- &lt;!-- CRITICAL REQUIREMENTS:
464
- - One detailed sequence diagram for EVERY AC scenario
465
- - FULL FLOW from entry point to exit through ALL layers
466
- - Include EVERY step — no skipping intermediate steps
467
- - ALL LAYERS: Presentation → Application → Domain → Infrastructure and back
468
- - REAL METHOD NAMES from the design
469
- - EXACT DATA STRUCTURES passed at each step
470
- - Include error handling paths (alt blocks)
471
- - Include flow documentation with Given/When/Then from AC --&gt;
472
-
473
- &lt;!-- For EACH acceptance criteria scenario: --&gt;
474
-
475
- #### Scenario: [Exact AC Scenario Title]
476
-
477
- **AC Reference:**
478
- - **Given**: [exact given clause from AC]
479
- - **When**: [exact when clause from AC]
480
- - **Then**: [exact then clause from AC]
481
-
482
- ```mermaid
483
- sequenceDiagram
484
- participant User as User/External System
485
- participant UI as Presentation Layer&lt;br/&gt;[ComponentName]
486
- participant UseCase as Application Layer&lt;br/&gt;[UseCaseName]
487
- participant Service as Application Service&lt;br/&gt;[ServiceName]
488
- participant Domain as Domain Layer&lt;br/&gt;[EntityName]
489
- participant Repo as Infrastructure&lt;br/&gt;[RepositoryName]
490
- participant DB as Database/External Service
491
-
492
- Note over User: FULL FLOW START
493
- Note over User: Given: [Exact given clause from AC]
494
-
495
- %% Entry Point
496
- User->>UI: [Initial Trigger: click/submit/event]
497
- Note over UI: Entry Point: ComponentName.method()
498
-
499
- %% Presentation Layer Processing
500
- UI->>UI: validateInput(formData)
501
- UI->>UI: transformToDTO(formData)
502
-
503
- %% Application Layer Orchestration
504
- UI->>UseCase: execute(command: CommandDTO)
505
- UseCase->>UseCase: validateCommand(command)
506
- UseCase->>Service: processBusinessLogic(data)
507
-
508
- %% Domain Layer Business Logic
509
- Service->>Domain: applyBusinessRules(data)
510
- Domain->>Domain: validateInvariants()
511
- Domain->>Domain: calculateDerivedValues()
512
-
513
- %% Infrastructure Layer
514
- Service->>Repo: save(entity)
515
- Repo->>DB: INSERT/UPDATE
516
- DB-->>Repo: result
517
-
518
- %% Return Path Through Layers
519
- Repo-->>Service: savedEntity
520
- Service-->>UseCase: processedResult
521
- UseCase-->>UI: ResponseDTO
522
-
523
- %% Final UI Update
524
- UI->>UI: updateState(response)
525
- UI->>UI: renderChanges()
526
- UI-->>User: [Expected result from Then clause]
527
-
528
- Note over User: FULL FLOW END
529
-
530
- %% Error Handling Paths
531
- alt Validation Error
532
- Domain-->>Service: ValidationException
533
- Service-->>UseCase: HandleValidationError
534
- UseCase-->>UI: ErrorResponse(400)
535
- UI-->>User: Display validation message
536
- else Infrastructure Error
537
- DB-->>Repo: Exception
538
- Repo-->>Service: RepositoryException
539
- Service-->>UseCase: HandleError
540
- UseCase-->>UI: ErrorResponse(500)
541
- UI-->>User: Display error message
542
- end
543
- ```
544
-
545
- **Flow Documentation:**
546
- - **Entry Point**: [ComponentName.methodName()] at [file:line]
547
- - **Data In**: [exact DTO/type passed in]
548
- - **Processing Steps**: [numbered list of key processing steps]
549
- - **Data Out**: [exact DTO/type returned]
550
- - **State Changes**: [what state is modified and where]
551
- - **Events Emitted**: [events fired during this flow]
552
- - **Error Paths**: [validation errors, infrastructure errors]
553
-
554
- &lt;!-- Repeat for EVERY AC scenario. No scenario may be skipped. --&gt;
555
- </section>
556
-
557
- <!-- ═══════════════════════════════════════════════════════════════════ -->
558
- <!-- SECTION 10: COMPLETE FILE STRUCTURE -->
559
- <!-- ═══════════════════════════════════════════════════════════════════ -->
560
-
561
- <section name="file-structure">
562
- ### V.8. Complete File Structure
563
-
564
- &lt;!-- Tree showing ALL files to be created/modified.
565
- Mark new files vs modified files clearly.
566
- Include brief purpose for each file. --&gt;
567
-
568
- #### New Files to Create
569
- ```
570
- src/
571
- ├── domain/
572
- │ ├── entities/
573
- │ │ └── StoryEntity.ts # [purpose]
574
- │ ├── interfaces/
575
- │ │ └── IStoryEntity.ts # [purpose]
576
- │ ├── value-objects/
577
- │ │ └── StoryValueObject.ts # [purpose]
578
- │ └── constants/
579
- │ └── StoryConstants.ts # [purpose]
580
- ├── application/
581
- │ ├── interfaces/
582
- │ │ └── IStoryUseCase.ts # [purpose]
583
- │ ├── use-cases/
584
- │ │ └── StoryUseCase.ts # [purpose]
585
- │ └── dtos/
586
- │ ├── StoryRequestDTO.ts # [purpose]
587
- │ └── StoryResponseDTO.ts # [purpose]
588
- ├── infrastructure/
589
- │ └── services/
590
- │ └── StoryService.ts # [purpose]
591
- └── presentation/
592
- └── components/
593
- └── StoryComponent.ts # [purpose]
594
- ```
595
-
596
- #### Existing Files to Modify
597
- ```
598
- src/
599
- ├── infrastructure/
600
- │ └── di/
601
- │ └── container.ts # [MODIFY] Add new service registrations
602
- ├── [layer]/
603
- │ └── [file].ts # [MODIFY] [reason for modification]
604
- ```
605
-
606
- #### Implementation Statistics
607
- - **New files**: [N]
608
- - **Modified files**: [N]
609
- - **Total files touched**: [N]
610
- </section>
611
-
612
- <!-- ═══════════════════════════════════════════════════════════════════ -->
613
- <!-- SECTION 11: DI CONTAINER CONFIGURATION -->
614
- <!-- ═══════════════════════════════════════════════════════════════════ -->
615
-
616
- <section name="di-container">
617
- ### V.9. DI Container Configuration
618
-
619
- &lt;!-- All new service registrations, interface-to-implementation bindings,
620
- and lifecycle management. --&gt;
621
-
622
- ```typescript
623
- // File: infrastructure/di/container.ts (MODIFY — add these registrations)
624
-
625
- // New service registrations for this story
626
- container.register&lt;IStoryEntity&gt;('IStoryEntity', StoryEntity, Lifecycle.Transient);
627
- container.register&lt;IStoryUseCase&gt;('IStoryUseCase', StoryUseCase, Lifecycle.Singleton);
628
- container.register&lt;IStoryService&gt;('IStoryService', StoryService, Lifecycle.Singleton);
629
- ```
630
-
631
- #### Registration Details
632
- | Interface | Implementation | Lifecycle | Justification |
633
- |-----------|---------------|-----------|---------------|
634
- | IStoryEntity | StoryEntity | Transient | New instance per use |
635
- | IStoryUseCase | StoryUseCase | Singleton | Stateless orchestrator |
636
- | IStoryService | StoryService | Singleton | Shared infrastructure |
637
- </section>
638
-
639
- <!-- ═══════════════════════════════════════════════════════════════════ -->
640
- <!-- SECTION 12: REFACTORING PLAN -->
641
- <!-- ═══════════════════════════════════════════════════════════════════ -->
642
-
643
- <section name="refactoring-plan">
644
- ### V.10. Refactoring Plan
645
-
646
- &lt;!-- From integration analysis: all refactoring items.
647
- Include refactoring order, dependencies, and impact assessment.
648
- Even if no refactoring needed, document why. --&gt;
649
-
650
- #### Refactoring Items from Integration Analysis
651
-
652
- &lt;!-- For each refactoring item identified: --&gt;
653
-
654
- **Refactoring: [Item Name]**
655
- - **File**: `[file:line-range]`
656
- - **Current State**: [what it is now]
657
- - **Proposed Change**: [what it should become]
658
- - **Justification**: [why this is needed — from integration analysis]
659
- - **Impact**: [what else is affected]
660
- - **Order**: [when to do this relative to other refactorings]
661
-
662
- &lt;!-- Repeat for each refactoring item.
663
- If no refactoring needed, state: "No refactoring required. [justification]." --&gt;
664
-
665
- #### Hardcoded Values to Replace
666
-
667
- &lt;!-- From integration analysis: all hardcoded values and placeholder code
668
- that MUST be replaced as part of this implementation.
669
- Include exact file paths, line numbers, and replacement code. --&gt;
670
-
671
- ```yaml
672
- FILE: [exact file path]
673
- LINE: [line number(s)]
674
- CURRENT CODE: |
675
- [actual code snippet]
676
- SHOULD BE: |
677
- [replacement code using new entities/constants]
678
- FIX REQUIRED: [specific action]
679
- ```
680
-
681
- &lt;!-- Repeat for each hardcoded value --&gt;
682
- </section>
683
-
684
- <!-- ═══════════════════════════════════════════════════════════════════ -->
685
- <!-- SECTION 13: TESTING STRATEGY -->
686
- <!-- ═══════════════════════════════════════════════════════════════════ -->
687
-
688
- <section name="testing-strategy">
689
- ### V.11. Testing Strategy
690
-
691
- &lt;!-- Follow testing-framework.md from wiki. --&gt;
692
-
693
- #### Unit Tests
694
- - **What to test**: [components, services, use cases to unit test]
695
- - **Mocking strategy**: [what to mock and how]
696
- - **Test patterns**: [patterns to follow from testing-framework.md]
697
-
698
- #### Integration Tests
699
- - **Scenarios**: [integration scenarios to cover]
700
- - **Test utilities**: [existing test utilities available for reuse]
701
-
702
- #### E2E Tests
703
- - **Scenarios**: [end-to-end scenarios covering ALL AC scenarios]
704
- - **Test framework**: [framework to use from testing-framework.md]
705
-
706
- #### Ensuring Existing Tests Pass
707
- - [Steps to verify existing tests still pass]
708
- - [Tests that may need adjustment and why]
709
-
710
- #### Test File Structure
711
- ```
712
- tests/
713
- ├── unit/
714
- │ ├── domain/
715
- │ │ └── StoryEntity.test.ts
716
- │ └── application/
717
- │ └── StoryUseCase.test.ts
718
- ├── integration/
719
- │ └── StoryIntegration.test.ts
720
- └── e2e/
721
- └── StoryE2E.test.ts
722
- ```
723
- </section>
724
-
725
- <!-- ═══════════════════════════════════════════════════════════════════ -->
726
- <!-- SECTION 14: IMPLEMENTATION ORDER -->
727
- <!-- ═══════════════════════════════════════════════════════════════════ -->
728
-
729
- <section name="implementation-order">
730
- ### V.12. Implementation Order
731
-
732
- &lt;!-- Step-by-step implementation approach following coding standards.
733
- Dependencies between steps clearly marked.
734
- Build verification points after each major step. --&gt;
735
-
736
- 1. **[Step 1: Domain Layer]**: [What to implement first and why]
737
- - Files to create/modify: [list]
738
- - Pattern to follow: [reference to existing pattern from wiki]
739
- - **Build verification**: Run build after this step
740
-
741
- 2. **[Step 2: Application Layer]**: [What to implement next]
742
- - Files to create/modify: [list]
743
- - Pattern to follow: [reference]
744
- - **Depends on**: Step 1
745
-
746
- 3. **[Step 3: Infrastructure Layer]**: [implementation details]
747
- - Files to create/modify: [list]
748
- - **Depends on**: Steps 1, 2
749
-
750
- 4. **[Step 4: Presentation Layer]**: [implementation details]
751
- - Files to create/modify: [list]
752
- - **Depends on**: Steps 1, 2, 3
753
-
754
- 5. **[Step 5: DI Configuration]**: Wire up all new services
755
- - Files to modify: [DI container file]
756
- - **Depends on**: Steps 1-4
757
-
758
- 6. **[Step 6: Refactoring]**: Execute refactoring items from integration analysis
759
- - Files to modify: [from refactoring plan]
760
- - **Build verification**: Run build + tests after each refactoring
761
-
762
- 7. **[Step 7: Testing]**: Write and run all tests
763
- - Files to create: [test files]
764
- - **Depends on**: Steps 1-6
765
-
766
- &lt;!-- Adjust steps based on actual story requirements --&gt;
767
- </section>
768
-
769
- <!-- ═══════════════════════════════════════════════════════════════════ -->
770
- <!-- SECTION 15: IMPLEMENTATION CHECKLIST -->
771
- <!-- ═══════════════════════════════════════════════════════════════════ -->
772
-
773
- <section name="implementation-checklist">
774
- ### V.13. Implementation Checklist
775
-
776
- - [ ] Create domain entities
777
- - [ ] Define application interfaces
778
- - [ ] Implement infrastructure services
779
- - [ ] Add presentation components
780
- - [ ] Configure dependency injection
781
- - [ ] Replace hardcoded values identified in integration analysis
782
- - [ ] Execute refactoring items from integration analysis
783
- - [ ] Write unit tests
784
- - [ ] Integration testing
785
- - [ ] E2E testing covering ALL Acceptance Criteria Scenarios
786
- - [ ] Documentation
787
-
788
- For complete technical design details, see the sections above.
789
- </section>
790
-
791
- </output-format>
792
-
793
- <analysis-process>
794
-
795
- &lt;!-- This section defines the analysis methodology that the technical-application-architect
796
- agent must follow. It mirrors the workflow steps but provides detailed
797
- instructions for each analysis phase.
798
-
799
- MANDATORY COMPLETION REQUIREMENTS:
800
- - Phase 1: ALL 4 items (Initial Discovery) — MANDATORY
801
- - Phase 2: ALL 3 items (System Architecture Understanding) — MANDATORY
802
- - Phase 3: ALL 2 items (Codebase Analysis) — MANDATORY
803
- - Phase 4: Solution Design (generate ALL output sections) — MANDATORY
804
- - Total: 9 mandatory analysis items + 13 output sections — SKIP NONE --&gt;
805
-
806
- <phase name="initial-discovery" order="1">
807
- &lt;!-- ALL 4 items are MANDATORY --&gt;
808
-
809
- <item name="understand-story" mandatory="true">
810
- **[MANDATORY] Understand the Story:**
811
- - Read the story thoroughly: User Story, Description, all AC scenarios
812
- - These define WHAT functionality needs to be implemented
813
- - Extract key behaviors, components, and patterns needed
814
- - The story's acceptance criteria define the SCOPE of the solution
815
- - Identify ALL AC scenarios — each will need a sequence diagram
816
- </item>
817
-
818
- <item name="extract-business-requirements" mandatory="true">
819
- **[MANDATORY] Extract Business Requirements:**
820
- - Requirements come from the story's User Story, Description, and AC
821
- - The story IS the source of truth for business requirements
822
- - Extract all constraints, behaviors, and expected outcomes
823
- - Map each AC scenario to the technical components needed
824
- </item>
825
-
826
- <item name="study-external-analysis" mandatory="false">
827
- **[CONDITIONAL] Study External/Industry-Standard Analysis:**
828
- - Only if external analysis exists in story directory
829
- - Use algorithms and formulas IF they are the MOST EFFICIENT AND PERFORMANT
830
- - If you can identify a better approach, use the better approach
831
- - The external analysis is a REFERENCE, not a blueprint
832
- </item>
833
-
834
- <item name="feature-planning-context" mandatory="true">
835
- **[MANDATORY] Feature Planning Context:**
836
- - Read the parent feature document for broader context
837
- - Understand story dependencies and shared components
838
- - Design with the complete feature in mind
839
- - Never design in isolation
840
- </item>
841
- </phase>
842
-
843
- <phase name="system-architecture-understanding" order="2">
844
- &lt;!-- ALL 3 items are MANDATORY --&gt;
845
-
846
- <item name="wiki-system-architecture" mandatory="true">
847
- **[MANDATORY] System Architecture from Wiki:**
848
- - Study system-architecture.md for complete architectural overview
849
- - Study system-structure.md for codebase layout
850
- - Map where this story's components fit in the overall architecture
851
- </item>
852
-
853
- <item name="wiki-subsystem-knowledge" mandatory="true">
854
- **[MANDATORY] Subsystem Knowledge from Wiki:**
855
- - Study ALL subsystem wiki documents referenced by the story
856
- - Extract interfaces to extend, classes to compose, patterns to follow
857
- - Identify constants to reuse and conventions to respect
858
- - These replace: related-stories-implementations, documented-features, documentation
859
- </item>
860
-
861
- <item name="integration-analysis-study" mandatory="true">
862
- **[MANDATORY] Deep Study of Integration Analysis:**
863
- - THOROUGHLY analyze the integration analysis document
864
- - Extract ALL integration points, refactoring needs, patterns to follow
865
- - Extract ALL hardcoded values and placeholder code to replace
866
- - This tells you EXACTLY how to integrate without breaking the codebase
867
- - NEVER SKIP REFACTORING if the integration analysis identifies it's needed
868
- </item>
869
- </phase>
870
-
871
- <phase name="codebase-analysis" order="3">
872
- &lt;!-- ALL 2 items are MANDATORY --&gt;
873
-
874
- <item name="coding-standards" mandatory="true">
875
- **[MANDATORY] Coding Standards Review:**
876
- - Read coding-standards.md BEFORE generating ANY solution code
877
- - Enforce: zero hardcoding, single responsibility, interface-first design
878
- - One class/interface/type per file — NO EXCEPTIONS
879
- - Every piece of code in the solution MUST comply
880
- </item>
881
-
882
- <item name="source-code-exploration" mandatory="true">
883
- **[MANDATORY] Source Code Exploration:**
884
- - Guided by wiki system-structure.md and integration analysis
885
- - Identify existing patterns, reusable components, naming conventions
886
- - Focus on files identified by the integration analysis
887
- </item>
888
- </phase>
889
-
890
- <phase name="solution-design" order="4">
891
- &lt;!-- Generate ALL 13 output sections --&gt;
892
-
893
- <item name="generate-all-sections" mandatory="true">
894
- **[MANDATORY] Generate Complete Technical Solution:**
895
- Using all context from phases 1-3, generate ALL output sections:
896
- 1. Header with solution context
897
- 2. Architecture Overview with Clean Architecture compliance
898
- 3. V.1. Component &amp; Boundary Architecture with Mermaid diagrams
899
- 4. V.2. Design Patterns &amp; Technical Decisions
900
- 5. V.3. Complete Class Diagrams &amp; Interfaces (one per file!)
901
- 6. V.4. Data Models &amp; Structures (one per file!)
902
- 7. V.5. Algorithms &amp; Business Logic with formulas and examples
903
- 8. V.6. Event Flow &amp; Entry Points
904
- 9. V.7. MANDATORY Sequence Diagrams for ALL AC scenarios
905
- 10. V.8. Complete File Structure tree
906
- 11. V.9. DI Container Configuration
907
- 12. V.10. Refactoring Plan (from integration analysis)
908
- 13. V.11. Testing Strategy (unit, integration, e2e)
909
- 14. V.12. Implementation Order with dependencies
910
- 15. V.13. Implementation Checklist
911
- </item>
912
- </phase>
913
-
914
- </analysis-process>
915
-
916
- <validation-checklist>
917
-
918
- &lt;!-- The workflow uses this checklist to validate completeness.
919
- ALL 25 items MUST pass before the solution is considered complete. --&gt;
920
-
921
- **Story File Requirements:**
922
- - [ ] Technical solution section exists in the story file
923
- - [ ] Section contains all required subsections from template
924
-
925
- **Architecture Requirements:**
926
- - [ ] Component &amp; Boundary Architecture with Mermaid diagram
927
- - [ ] Layer Architecture Analysis (Domain, Application, Infrastructure, Presentation)
928
- - [ ] Clean Architecture compliance verified (dependencies point inward)
929
- - [ ] Dependency injection strategy documented
930
-
931
- **Design Requirements:**
932
- - [ ] Design patterns documented with purpose and implementation
933
- - [ ] Technical decisions documented with rationale and trade-offs
934
- - [ ] Class diagrams with complete interface definitions
935
- - [ ] EVERY interface/class/type in its OWN SEPARATE FILE (coding standards!)
936
- - [ ] Data models and structures defined with TypeScript types
937
-
938
- **Algorithm Requirements:**
939
- - [ ] Algorithms documented with mathematical formulas
940
- - [ ] Constants and configuration values defined (NO hardcoding!)
941
- - [ ] Business rules documented with implementations
942
- - [ ] Example calculations provided
943
-
944
- **Sequence Diagram Requirements (CRITICAL!):**
945
- - [ ] Sequence diagram for EVERY AC scenario
946
- - [ ] Full flow from entry point to exit through ALL layers
947
- - [ ] Real method names used (not generic placeholders)
948
- - [ ] Error handling paths included (alt blocks)
949
- - [ ] Data structures shown at each step
950
-
951
- **Implementation Requirements:**
952
- - [ ] Complete file structure tree (new + modified files)
953
- - [ ] DI container configuration specified
954
- - [ ] Refactoring plan from integration analysis incorporated
955
- - [ ] Testing strategy (unit, integration, e2e)
956
- - [ ] Implementation order with dependencies
957
- - [ ] Implementation checklist
958
-
959
- **Compliance Requirements:**
960
- - [ ] Coding standards compliance verified throughout
961
- - [ ] Integration analysis findings incorporated
962
- - [ ] No hardcoded values in any code snippets
963
- - [ ] All code follows Clean Architecture layers
964
-
965
- **Total: 25 mandatory checklist items**
966
-
967
- </validation-checklist>
968
-
969
- <guidelines>
970
-
971
- <guideline name="external-analysis-philosophy">
972
- When external analysis IS available:
973
- - Use external algorithms and formulas IF they are the MOST EFFICIENT AND PERFORMANT
974
- - If you can identify a better approach, use the better approach
975
- - The external analysis is a REFERENCE, not a mandatory blueprint
976
- - Adapt external patterns to fit Clean Architecture properly
977
- - Constants from external systems are starting points, not mandates
978
- </guideline>
979
-
980
- <guideline name="integration-analysis-mandatory">
981
- The integration analysis (pass 4) is ALWAYS required:
982
- - It tells you exactly how to integrate without breaking the codebase
983
- - All refactoring items MUST be incorporated into the solution
984
- - All hardcoded values MUST be addressed in the refactoring plan
985
- - Patterns identified MUST be followed
986
- - Do not design in ways that contradict the integration analysis
987
- </guideline>
988
-
989
- <guideline name="coding-standards-first">
990
- Coding standards are NON-NEGOTIABLE:
991
- - Read coding-standards.md BEFORE generating any code
992
- - One class/interface/type per file — ALWAYS
993
- - Zero hardcoding — ALL values in constants files
994
- - Interface-first design — EVERY implementation has an interface
995
- - No dead code — clean, complete implementations only
996
- </guideline>
997
-
998
- <guideline name="sequence-diagram-completeness">
999
- Every AC scenario MUST have a sequence diagram:
1000
- - Full flow from entry point to exit through ALL architectural layers
1001
- - Real method names, not generic placeholders
1002
- - Exact data structures passed at each step
1003
- - Error handling paths (alt blocks)
1004
- - No scenario may be skipped
1005
- </guideline>
1006
-
1007
- <guideline name="github-compatibility">
1008
- The technical solution is written into the story file which is also a GitHub issue:
1009
- - Mermaid diagrams render natively in GitHub
1010
- - Use markdown tables (not HTML)
1011
- - No custom CSS or HTML styling
1012
- - Keep formatting clean for GitHub rendering
1013
- </guideline>
1014
-
1015
- <guideline name="solution-size">
1016
- The technical solution will typically be 1000-2000+ lines:
1017
- - This is expected and necessary for comprehensive coverage
1018
- - Do not truncate or summarize — the implementing AI needs every detail
1019
- - Include ALL diagrams, ALL code snippets, ALL configurations
1020
- - Completeness is more important than brevity
1021
- </guideline>
1022
-
1023
- </guidelines>
1024
-
1025
- </technical-solution>
1
+ <technical-solution>
2
+
3
+ <purpose>
4
+ Template for the `## Technical Solution` section that is APPENDED directly into
5
+ the story file (`.ace/artifacts/product/&lt;id-epic_name&gt;/&lt;id-feature_name&gt;/&lt;id-story_name&gt;/&lt;id-story_name&gt;.md`).
6
+
7
+ This is pass 5 of the story specification pipeline (see story.xml composition).
8
+ Unlike passes 3-4 which produce separate artifacts, pass 5 writes directly into the
9
+ story file. The entire technical solution (1000-2000+ lines) is appended as the
10
+ `## Technical Solution` section.
11
+
12
+ The technical solution uses:
13
+ - Business requirements from the story (User Story, Description, AC — passes 1-2)
14
+ - Wiki references from the story's Relevant Wiki section (pass 2)
15
+ - Integration analysis from the story directory (pass 4 — MANDATORY)
16
+ - External analysis from the story directory (pass 3 — OPTIONAL)
17
+ - Feature file for broader context
18
+
19
+ To create a concrete technical solution design following Clean Architecture principles,
20
+ SOLID patterns, OOP best practices, considering the external analysis for approach,
21
+ algorithms and formulas (when most efficient and performant), while following the
22
+ integration analysis so that we don't break our already complex codebase.
23
+
24
+ **CRITICAL**: The technical solution MUST include detailed sequence diagrams for EVERY
25
+ scenario in the Acceptance Criteria, showing the complete flow of data and control
26
+ through all architectural layers.
27
+
28
+ This document serves as both a local markdown section in the story file and a
29
+ GitHub issue section. All formatting must render cleanly in GitHub issue bodies.
30
+
31
+ CRITICAL: This technical solution output will be used as PROMPT CONTEXT for the AI agent
32
+ implementing this feature. Therefore:
33
+ - INCLUDE ALL DETAILS — don't summarize or omit
34
+ - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
35
+ - BE EXPLICIT — don't assume the implementing AI will know anything not explicitly stated
36
+ - INCLUDE ALL DIAGRAMS — class, sequence, component diagrams are essential
37
+ </purpose>
38
+
39
+ <output-format>
40
+
41
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
42
+ <!-- SECTION 1: HEADER -->
43
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
44
+
45
+ <section name="header">
46
+ ## Technical Solution
47
+
48
+ ### Solution Context
49
+ - **Story**: [Story ID] — [Story Title]
50
+ - **Feature**: [Feature ID] — [Feature Title]
51
+ - **Epic**: [Epic ID] — [Epic Title]
52
+ - **Design Date**: [Current date]
53
+ - **Wiki Documents Loaded**: [N] files
54
+ - **Integration Analysis**: Incorporated
55
+ - **External Analysis**: [Incorporated / Not available]
56
+ - **AC Scenarios**: [N] (each with sequence diagram)
57
+ - **New Files**: [N] | **Modified Files**: [N]
58
+ </section>
59
+
60
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
61
+ <!-- SECTION 2: ARCHITECTURE OVERVIEW -->
62
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
63
+
64
+ <section name="architecture-overview">
65
+ ### Architecture Overview
66
+
67
+ [Brief description of the technical approach — 3-5 sentences covering:
68
+ - What the solution implements
69
+ - Key architectural decisions
70
+ - How it integrates with the existing codebase
71
+ - Clean Architecture compliance]
72
+
73
+ #### Clean Architecture Compliance
74
+ - **Domain Layer**: [Key domain entities and value objects]
75
+ - **Application Layer**: [Use cases and service interfaces]
76
+ - **Infrastructure Layer**: [Technical implementations]
77
+ - **Presentation Layer**: [API/UI components]
78
+
79
+ #### Key Technical Decisions
80
+ 1. [Decision 1 with rationale]
81
+ 2. [Decision 2 with rationale]
82
+ 3. [Additional decisions...]
83
+ </section>
84
+
85
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
86
+ <!-- SECTION 3: COMPONENT & BOUNDARY ARCHITECTURE -->
87
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
88
+
89
+ <section name="component-boundary-architecture">
90
+ ### V.1. Component &amp; Boundary Architecture
91
+
92
+ &lt;!-- Document the comprehensive component architecture and system boundaries
93
+ SPECIFIC to this story. --&gt;
94
+
95
+ #### Story Boundary Diagram
96
+
97
+ &lt;!-- Map ALL components, their boundaries, and external interactions for THIS STORY.
98
+ Use Mermaid diagrams — GitHub renders them natively. --&gt;
99
+
100
+ ```mermaid
101
+ graph TB
102
+ subgraph "Story: [Name] Boundary"
103
+ subgraph "Presentation Layer"
104
+ P1[ComponentName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: exact purpose]
105
+ end
106
+
107
+ subgraph "Application Layer"
108
+ A1[UseCaseName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: orchestration]
109
+ end
110
+
111
+ subgraph "Domain Layer"
112
+ D1[EntityName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: business logic]
113
+ end
114
+
115
+ subgraph "Infrastructure Layer"
116
+ I1[ServiceName&lt;br/&gt;file-path:lines&lt;br/&gt;Responsibility: external integration]
117
+ end
118
+ end
119
+
120
+ External1[External System/Actor]
121
+ External1 -->|protocol/format| P1
122
+ ```
123
+
124
+ #### Component Documentation
125
+ - Each component's EXACT responsibility in this story
126
+ - Communication protocols between components
127
+ - Data formats exchanged
128
+ - State management requirements
129
+ - Error propagation paths
130
+
131
+ #### Layer Architecture Analysis
132
+
133
+ ```mermaid
134
+ graph TD
135
+ subgraph "Clean Architecture Placement"
136
+ direction TB
137
+ A[Domain: Story Entities &amp; Business Rules]
138
+ B[Application: Story Use Cases &amp; Orchestration]
139
+ C[Infrastructure: Story Technical Implementations]
140
+ D[Presentation: Story UI/API Components]
141
+ end
142
+ ```
143
+
144
+ **Layer Responsibilities for This Story:**
145
+ - **Domain**: [Specific entities, value objects, business rules]
146
+ - **Application**: [Specific use cases, service interfaces]
147
+ - **Infrastructure**: [Specific implementations, external services]
148
+ - **Presentation**: [Specific controllers, views, DTOs]
149
+ </section>
150
+
151
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
152
+ <!-- SECTION 4: DESIGN PATTERNS & TECHNICAL DECISIONS -->
153
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
154
+
155
+ <section name="design-patterns-decisions">
156
+ ### V.2. Design Patterns &amp; Technical Decisions
157
+
158
+ &lt;!-- Document ALL design patterns required for THIS STORY and technical decisions. --&gt;
159
+
160
+ #### Identified Design Patterns
161
+
162
+ &lt;!-- For EACH pattern: --&gt;
163
+
164
+ **Pattern: [Pattern Name]**
165
+ - **Purpose in This Story**: Why needed for this specific story
166
+ - **Problem Solved**: What story-specific problem it addresses
167
+ - **Implementation**:
168
+ ```typescript
169
+ // Exact implementation for this story
170
+ interface IStoryPattern {
171
+ method(): void;
172
+ }
173
+
174
+ class ConcreteImplementation implements IStoryPattern {
175
+ // Story-specific implementation
176
+ }
177
+ ```
178
+ - **Integration Points**: Where this pattern connects in the story flow
179
+ - **Rationale**: Why this pattern over alternatives
180
+
181
+ &lt;!-- Repeat for each identified pattern --&gt;
182
+
183
+ #### Technical Decisions
184
+
185
+ &lt;!-- For EACH decision: --&gt;
186
+
187
+ **Decision: [Technology/Approach Choice]**
188
+ - **Options Considered**: [List alternatives evaluated]
189
+ - **Decision**: [What was chosen]
190
+ - **Rationale**: [Why this choice for this story]
191
+ - **Trade-offs**: [Pros and cons]
192
+ - **Impact**: [How it affects implementation]
193
+
194
+ &lt;!-- Repeat for each decision --&gt;
195
+ </section>
196
+
197
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
198
+ <!-- SECTION 5: CLASS DIAGRAMS & INTERFACES -->
199
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
200
+
201
+ <section name="class-diagrams-interfaces">
202
+ ### V.3. Complete Class Diagrams &amp; Interfaces
203
+
204
+ &lt;!-- CRITICAL CODING STANDARDS ENFORCEMENT:
205
+ EVERY interface, class, type, enum MUST be in its OWN SEPARATE FILE!
206
+ NEVER put multiple interfaces/classes/types in one file!
207
+ Each code block below represents a SEPARATE FILE!
208
+
209
+ File naming: Each interface/class/type gets its own file named exactly after it:
210
+ IChartApi interface → IChartApi.ts
211
+ ChartOptions interface → ChartOptions.ts
212
+ LineStyle type → LineStyle.ts
213
+ ChartType enum → ChartType.ts --&gt;
214
+
215
+ ```mermaid
216
+ classDiagram
217
+ class StoryMainClass {
218
+ -privateField: Type
219
+ +publicField: Type
220
+ +constructor(params)
221
+ +publicMethod(param: Type): ReturnType
222
+ -privateMethod(): void
223
+ }
224
+
225
+ class IStoryInterface {
226
+ &lt;&lt;interface&gt;&gt;
227
+ +requiredMethod(): Type
228
+ +property: Type
229
+ }
230
+
231
+ StoryMainClass ..|> IStoryInterface : implements
232
+ ```
233
+
234
+ #### Domain Layer Interfaces
235
+ &lt;!-- Each interface in its OWN FILE --&gt;
236
+
237
+ ```typescript
238
+ // File: domain/interfaces/IStoryEntity.ts
239
+ export interface IStoryEntity {
240
+ // Properties with exact types
241
+ id: string;
242
+ data: StoryData;
243
+
244
+ // Methods with full signatures
245
+ process(input: Input): Output;
246
+ validate(): ValidationResult;
247
+ }
248
+ ```
249
+
250
+ #### Application Layer Interfaces
251
+ &lt;!-- Each interface in its OWN FILE --&gt;
252
+
253
+ ```typescript
254
+ // File: application/interfaces/IStoryUseCase.ts
255
+ export interface IStoryUseCase {
256
+ execute(command: StoryCommand): Promise&lt;StoryResult&gt;;
257
+ }
258
+ ```
259
+
260
+ &lt;!-- Repeat for ALL interfaces, classes, types needed --&gt;
261
+ </section>
262
+
263
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
264
+ <!-- SECTION 6: DATA MODELS & STRUCTURES -->
265
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
266
+
267
+ <section name="data-models">
268
+ ### V.4. Data Models &amp; Structures
269
+
270
+ &lt;!-- EACH MODEL/INTERFACE IN SEPARATE FILE
271
+ - domain/interfaces/IChartApi.ts (ONE interface)
272
+ - domain/types/ChartOptions.ts (ONE type)
273
+ - domain/enums/ChartType.ts (ONE enum)
274
+ - NEVER: domain/interfaces/AllInterfaces.ts (MULTIPLE - VIOLATION!) --&gt;
275
+
276
+ #### Core Data Models
277
+ ```typescript
278
+ // File: domain/models/StoryData.ts
279
+ export interface StoryData {
280
+ id: string;
281
+ timestamp: number;
282
+ payload: {
283
+ // Complete structure
284
+ };
285
+ }
286
+ ```
287
+
288
+ #### DTOs
289
+ ```typescript
290
+ // File: application/dtos/StoryRequestDTO.ts
291
+ export interface StoryRequestDTO {
292
+ // Input structure
293
+ }
294
+
295
+ // File: application/dtos/StoryResponseDTO.ts
296
+ export interface StoryResponseDTO {
297
+ // Output structure
298
+ }
299
+ ```
300
+
301
+ #### State Management Structure
302
+ ```typescript
303
+ // File: [appropriate layer]/state/StoryState.ts
304
+ interface StoryState {
305
+ // Component state
306
+ data: StoryData[];
307
+ loading: boolean;
308
+ error: Error | null;
309
+
310
+ // UI state
311
+ selectedItem: string | null;
312
+ filters: FilterOptions;
313
+ }
314
+ ```
315
+ </section>
316
+
317
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
318
+ <!-- SECTION 7: ALGORITHMS & BUSINESS LOGIC -->
319
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
320
+
321
+ <section name="algorithms-business-logic">
322
+ ### V.5. Algorithms &amp; Business Logic
323
+
324
+ &lt;!-- If external analysis is available:
325
+ Consider the external system's algorithms and formulas as REFERENCE.
326
+ Use them when they are the MOST EFFICIENT AND PERFORMANT approach.
327
+ If you can identify a better approach, use the better approach.
328
+ DO NOT blindly copy — USE JUDGMENT.
329
+
330
+ If no external analysis:
331
+ Design algorithms based on requirements, industry best practices,
332
+ and Clean Architecture principles. --&gt;
333
+
334
+ #### Constants &amp; Configuration
335
+ ```typescript
336
+ // File: domain/constants/StoryConstants.ts
337
+ // ALL constants centralized — NO hardcoding anywhere in the codebase!
338
+ export const STORY_CONSTANTS = {
339
+ // Configuration values with clear names
340
+ MAX_ITEMS: 10000,
341
+ BATCH_SIZE: 100,
342
+ THROTTLE_MS: 16, // 60 FPS
343
+ DEBOUNCE_MS: 300,
344
+
345
+ // Calculation constants
346
+ SMOOTHING_FACTOR: 0.3,
347
+ WEIGHT_COEFFICIENT: 2.5,
348
+ NORMALIZATION_BASE: 100,
349
+
350
+ // Thresholds
351
+ MIN_ZOOM: 0.1,
352
+ MAX_ZOOM: 1000,
353
+ VISIBILITY_THRESHOLD: 0.01,
354
+ } as const;
355
+ ```
356
+
357
+ #### Core Algorithms
358
+
359
+ &lt;!-- For EACH algorithm: --&gt;
360
+
361
+ **Algorithm: [Name]**
362
+ - **Source**: [Designed from requirements / Adapted from external analysis section X.Y]
363
+ - **Purpose**: [What this algorithm achieves]
364
+ - **Mathematical Formula**:
365
+ ```
366
+ result = (value * SMOOTHING_FACTOR + previousValue * (1 - SMOOTHING_FACTOR)) / NORMALIZATION_BASE
367
+ ```
368
+ - **Implementation**:
369
+ ```typescript
370
+ // File: domain/services/[ServiceName].ts
371
+ function algorithmName(input: Input): Output {
372
+ // Step 1: [description]
373
+ const smoothed = input.value * STORY_CONSTANTS.SMOOTHING_FACTOR +
374
+ this.previousValue * (1 - STORY_CONSTANTS.SMOOTHING_FACTOR);
375
+
376
+ // Step 2: [description]
377
+ const normalized = smoothed / STORY_CONSTANTS.NORMALIZATION_BASE;
378
+
379
+ // Step 3: Edge case handling
380
+ if (normalized > MAX_VALUE) return MAX_VALUE;
381
+ if (normalized < MIN_VALUE) return MIN_VALUE;
382
+
383
+ // Step 4: Precision
384
+ return Math.round(normalized * 100) / 100;
385
+ }
386
+ ```
387
+ - **Example Calculation**:
388
+ ```
389
+ Input: value = 150, previousValue = 100
390
+ Step 1: 150 * 0.3 = 45
391
+ Step 2: 100 * 0.7 = 70
392
+ Step 3: 45 + 70 = 115
393
+ Step 4: 115 / 100 = 1.15
394
+ Output: 1.15
395
+ ```
396
+
397
+ &lt;!-- Repeat for each algorithm --&gt;
398
+
399
+ #### Business Rules
400
+ ```typescript
401
+ // File: domain/rules/StoryBusinessRules.ts
402
+ class StoryBusinessRules {
403
+ // Validation rules
404
+ validateInput(input: Input): boolean {
405
+ if (!input?.value) return false;
406
+ if (input.value < STORY_CONSTANTS.MIN_THRESHOLD) return false;
407
+ if (input.value > STORY_CONSTANTS.MAX_THRESHOLD) return false;
408
+ return true;
409
+ }
410
+
411
+ // Business constraints
412
+ checkConstraints(data: Data): ConstraintResult {
413
+ const validTransitions = STATE_TRANSITIONS[data.currentState];
414
+ return validTransitions.includes(data.nextState);
415
+ }
416
+ }
417
+ ```
418
+ </section>
419
+
420
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
421
+ <!-- SECTION 8: EVENT FLOW & ENTRY POINTS -->
422
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
423
+
424
+ <section name="event-flow-entry-points">
425
+ ### V.6. Event Flow &amp; Entry Points
426
+
427
+ &lt;!-- Map ALL event flows and entry points for THIS STORY. --&gt;
428
+
429
+ #### Entry Points
430
+ 1. **User Actions**:
431
+ - [Action type]: `methodName()` at [file:line]
432
+
433
+ 2. **API Endpoints**:
434
+ - [Protocol]: `[endpoint]` at [file:line]
435
+
436
+ 3. **Event Triggers**:
437
+ - [Event type]: `on('[event-name]')` at [file:line]
438
+
439
+ #### Event Flow Sequences
440
+ ```mermaid
441
+ sequenceDiagram
442
+ participant User
443
+ participant UI
444
+ participant App
445
+ participant Domain
446
+
447
+ User->>UI: Trigger Action
448
+ UI->>App: Process Command
449
+ App->>Domain: Execute Business Logic
450
+ Domain-->>App: Return Result
451
+ App-->>UI: Update View
452
+ UI-->>User: Show Result
453
+ ```
454
+ </section>
455
+
456
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
457
+ <!-- SECTION 9: MANDATORY SEQUENCE DIAGRAMS FOR ALL AC -->
458
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
459
+
460
+ <section name="sequence-diagrams-mandatory">
461
+ ### V.7. MANDATORY Sequence Diagrams for ALL Acceptance Criteria
462
+
463
+ &lt;!-- CRITICAL REQUIREMENTS:
464
+ - One detailed sequence diagram for EVERY AC scenario
465
+ - FULL FLOW from entry point to exit through ALL layers
466
+ - Include EVERY step — no skipping intermediate steps
467
+ - ALL LAYERS: Presentation → Application → Domain → Infrastructure and back
468
+ - REAL METHOD NAMES from the design
469
+ - EXACT DATA STRUCTURES passed at each step
470
+ - Include error handling paths (alt blocks)
471
+ - Include flow documentation with Given/When/Then from AC --&gt;
472
+
473
+ &lt;!-- For EACH acceptance criteria scenario: --&gt;
474
+
475
+ #### Scenario: [Exact AC Scenario Title]
476
+
477
+ **AC Reference:**
478
+ - **Given**: [exact given clause from AC]
479
+ - **When**: [exact when clause from AC]
480
+ - **Then**: [exact then clause from AC]
481
+
482
+ ```mermaid
483
+ sequenceDiagram
484
+ participant User as User/External System
485
+ participant UI as Presentation Layer&lt;br/&gt;[ComponentName]
486
+ participant UseCase as Application Layer&lt;br/&gt;[UseCaseName]
487
+ participant Service as Application Service&lt;br/&gt;[ServiceName]
488
+ participant Domain as Domain Layer&lt;br/&gt;[EntityName]
489
+ participant Repo as Infrastructure&lt;br/&gt;[RepositoryName]
490
+ participant DB as Database/External Service
491
+
492
+ Note over User: FULL FLOW START
493
+ Note over User: Given: [Exact given clause from AC]
494
+
495
+ %% Entry Point
496
+ User->>UI: [Initial Trigger: click/submit/event]
497
+ Note over UI: Entry Point: ComponentName.method()
498
+
499
+ %% Presentation Layer Processing
500
+ UI->>UI: validateInput(formData)
501
+ UI->>UI: transformToDTO(formData)
502
+
503
+ %% Application Layer Orchestration
504
+ UI->>UseCase: execute(command: CommandDTO)
505
+ UseCase->>UseCase: validateCommand(command)
506
+ UseCase->>Service: processBusinessLogic(data)
507
+
508
+ %% Domain Layer Business Logic
509
+ Service->>Domain: applyBusinessRules(data)
510
+ Domain->>Domain: validateInvariants()
511
+ Domain->>Domain: calculateDerivedValues()
512
+
513
+ %% Infrastructure Layer
514
+ Service->>Repo: save(entity)
515
+ Repo->>DB: INSERT/UPDATE
516
+ DB-->>Repo: result
517
+
518
+ %% Return Path Through Layers
519
+ Repo-->>Service: savedEntity
520
+ Service-->>UseCase: processedResult
521
+ UseCase-->>UI: ResponseDTO
522
+
523
+ %% Final UI Update
524
+ UI->>UI: updateState(response)
525
+ UI->>UI: renderChanges()
526
+ UI-->>User: [Expected result from Then clause]
527
+
528
+ Note over User: FULL FLOW END
529
+
530
+ %% Error Handling Paths
531
+ alt Validation Error
532
+ Domain-->>Service: ValidationException
533
+ Service-->>UseCase: HandleValidationError
534
+ UseCase-->>UI: ErrorResponse(400)
535
+ UI-->>User: Display validation message
536
+ else Infrastructure Error
537
+ DB-->>Repo: Exception
538
+ Repo-->>Service: RepositoryException
539
+ Service-->>UseCase: HandleError
540
+ UseCase-->>UI: ErrorResponse(500)
541
+ UI-->>User: Display error message
542
+ end
543
+ ```
544
+
545
+ **Flow Documentation:**
546
+ - **Entry Point**: [ComponentName.methodName()] at [file:line]
547
+ - **Data In**: [exact DTO/type passed in]
548
+ - **Processing Steps**: [numbered list of key processing steps]
549
+ - **Data Out**: [exact DTO/type returned]
550
+ - **State Changes**: [what state is modified and where]
551
+ - **Events Emitted**: [events fired during this flow]
552
+ - **Error Paths**: [validation errors, infrastructure errors]
553
+
554
+ &lt;!-- Repeat for EVERY AC scenario. No scenario may be skipped. --&gt;
555
+ </section>
556
+
557
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
558
+ <!-- SECTION 10: COMPLETE FILE STRUCTURE -->
559
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
560
+
561
+ <section name="file-structure">
562
+ ### V.8. Complete File Structure
563
+
564
+ &lt;!-- Tree showing ALL files to be created/modified.
565
+ Mark new files vs modified files clearly.
566
+ Include brief purpose for each file. --&gt;
567
+
568
+ #### New Files to Create
569
+ ```
570
+ src/
571
+ ├── domain/
572
+ │ ├── entities/
573
+ │ │ └── StoryEntity.ts # [purpose]
574
+ │ ├── interfaces/
575
+ │ │ └── IStoryEntity.ts # [purpose]
576
+ │ ├── value-objects/
577
+ │ │ └── StoryValueObject.ts # [purpose]
578
+ │ └── constants/
579
+ │ └── StoryConstants.ts # [purpose]
580
+ ├── application/
581
+ │ ├── interfaces/
582
+ │ │ └── IStoryUseCase.ts # [purpose]
583
+ │ ├── use-cases/
584
+ │ │ └── StoryUseCase.ts # [purpose]
585
+ │ └── dtos/
586
+ │ ├── StoryRequestDTO.ts # [purpose]
587
+ │ └── StoryResponseDTO.ts # [purpose]
588
+ ├── infrastructure/
589
+ │ └── services/
590
+ │ └── StoryService.ts # [purpose]
591
+ └── presentation/
592
+ └── components/
593
+ └── StoryComponent.ts # [purpose]
594
+ ```
595
+
596
+ #### Existing Files to Modify
597
+ ```
598
+ src/
599
+ ├── infrastructure/
600
+ │ └── di/
601
+ │ └── container.ts # [MODIFY] Add new service registrations
602
+ ├── [layer]/
603
+ │ └── [file].ts # [MODIFY] [reason for modification]
604
+ ```
605
+
606
+ #### Implementation Statistics
607
+ - **New files**: [N]
608
+ - **Modified files**: [N]
609
+ - **Total files touched**: [N]
610
+ </section>
611
+
612
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
613
+ <!-- SECTION 11: DI CONTAINER CONFIGURATION -->
614
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
615
+
616
+ <section name="di-container">
617
+ ### V.9. DI Container Configuration
618
+
619
+ &lt;!-- All new service registrations, interface-to-implementation bindings,
620
+ and lifecycle management. --&gt;
621
+
622
+ ```typescript
623
+ // File: infrastructure/di/container.ts (MODIFY — add these registrations)
624
+
625
+ // New service registrations for this story
626
+ container.register&lt;IStoryEntity&gt;('IStoryEntity', StoryEntity, Lifecycle.Transient);
627
+ container.register&lt;IStoryUseCase&gt;('IStoryUseCase', StoryUseCase, Lifecycle.Singleton);
628
+ container.register&lt;IStoryService&gt;('IStoryService', StoryService, Lifecycle.Singleton);
629
+ ```
630
+
631
+ #### Registration Details
632
+ | Interface | Implementation | Lifecycle | Justification |
633
+ |-----------|---------------|-----------|---------------|
634
+ | IStoryEntity | StoryEntity | Transient | New instance per use |
635
+ | IStoryUseCase | StoryUseCase | Singleton | Stateless orchestrator |
636
+ | IStoryService | StoryService | Singleton | Shared infrastructure |
637
+ </section>
638
+
639
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
640
+ <!-- SECTION 12: REFACTORING PLAN -->
641
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
642
+
643
+ <section name="refactoring-plan">
644
+ ### V.10. Refactoring Plan
645
+
646
+ &lt;!-- From integration analysis: all refactoring items.
647
+ Include refactoring order, dependencies, and impact assessment.
648
+ Even if no refactoring needed, document why. --&gt;
649
+
650
+ #### Refactoring Items from Integration Analysis
651
+
652
+ &lt;!-- For each refactoring item identified: --&gt;
653
+
654
+ **Refactoring: [Item Name]**
655
+ - **File**: `[file:line-range]`
656
+ - **Current State**: [what it is now]
657
+ - **Proposed Change**: [what it should become]
658
+ - **Justification**: [why this is needed — from integration analysis]
659
+ - **Impact**: [what else is affected]
660
+ - **Order**: [when to do this relative to other refactorings]
661
+
662
+ &lt;!-- Repeat for each refactoring item.
663
+ If no refactoring needed, state: "No refactoring required. [justification]." --&gt;
664
+
665
+ #### Hardcoded Values to Replace
666
+
667
+ &lt;!-- From integration analysis: all hardcoded values and placeholder code
668
+ that MUST be replaced as part of this implementation.
669
+ Include exact file paths, line numbers, and replacement code. --&gt;
670
+
671
+ ```yaml
672
+ FILE: [exact file path]
673
+ LINE: [line number(s)]
674
+ CURRENT CODE: |
675
+ [actual code snippet]
676
+ SHOULD BE: |
677
+ [replacement code using new entities/constants]
678
+ FIX REQUIRED: [specific action]
679
+ ```
680
+
681
+ &lt;!-- Repeat for each hardcoded value --&gt;
682
+ </section>
683
+
684
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
685
+ <!-- SECTION 13: TESTING STRATEGY -->
686
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
687
+
688
+ <section name="testing-strategy">
689
+ ### V.11. Testing Strategy
690
+
691
+ &lt;!-- Follow testing-framework.md from wiki. --&gt;
692
+
693
+ #### Unit Tests
694
+ - **What to test**: [components, services, use cases to unit test]
695
+ - **Mocking strategy**: [what to mock and how]
696
+ - **Test patterns**: [patterns to follow from testing-framework.md]
697
+
698
+ #### Integration Tests
699
+ - **Scenarios**: [integration scenarios to cover]
700
+ - **Test utilities**: [existing test utilities available for reuse]
701
+
702
+ #### E2E Tests
703
+ - **Scenarios**: [end-to-end scenarios covering ALL AC scenarios]
704
+ - **Test framework**: [framework to use from testing-framework.md]
705
+
706
+ #### Ensuring Existing Tests Pass
707
+ - [Steps to verify existing tests still pass]
708
+ - [Tests that may need adjustment and why]
709
+
710
+ #### Test File Structure
711
+ ```
712
+ tests/
713
+ ├── unit/
714
+ │ ├── domain/
715
+ │ │ └── StoryEntity.test.ts
716
+ │ └── application/
717
+ │ └── StoryUseCase.test.ts
718
+ ├── integration/
719
+ │ └── StoryIntegration.test.ts
720
+ └── e2e/
721
+ └── StoryE2E.test.ts
722
+ ```
723
+ </section>
724
+
725
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
726
+ <!-- SECTION 14: IMPLEMENTATION ORDER -->
727
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
728
+
729
+ <section name="implementation-order">
730
+ ### V.12. Implementation Order
731
+
732
+ &lt;!-- Step-by-step implementation approach following coding standards.
733
+ Dependencies between steps clearly marked.
734
+ Build verification points after each major step. --&gt;
735
+
736
+ 1. **[Step 1: Domain Layer]**: [What to implement first and why]
737
+ - Files to create/modify: [list]
738
+ - Pattern to follow: [reference to existing pattern from wiki]
739
+ - **Build verification**: Run build after this step
740
+
741
+ 2. **[Step 2: Application Layer]**: [What to implement next]
742
+ - Files to create/modify: [list]
743
+ - Pattern to follow: [reference]
744
+ - **Depends on**: Step 1
745
+
746
+ 3. **[Step 3: Infrastructure Layer]**: [implementation details]
747
+ - Files to create/modify: [list]
748
+ - **Depends on**: Steps 1, 2
749
+
750
+ 4. **[Step 4: Presentation Layer]**: [implementation details]
751
+ - Files to create/modify: [list]
752
+ - **Depends on**: Steps 1, 2, 3
753
+
754
+ 5. **[Step 5: DI Configuration]**: Wire up all new services
755
+ - Files to modify: [DI container file]
756
+ - **Depends on**: Steps 1-4
757
+
758
+ 6. **[Step 6: Refactoring]**: Execute refactoring items from integration analysis
759
+ - Files to modify: [from refactoring plan]
760
+ - **Build verification**: Run build + tests after each refactoring
761
+
762
+ 7. **[Step 7: Testing]**: Write and run all tests
763
+ - Files to create: [test files]
764
+ - **Depends on**: Steps 1-6
765
+
766
+ &lt;!-- Adjust steps based on actual story requirements --&gt;
767
+ </section>
768
+
769
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
770
+ <!-- SECTION 15: IMPLEMENTATION CHECKLIST -->
771
+ <!-- ═══════════════════════════════════════════════════════════════════ -->
772
+
773
+ <section name="implementation-checklist">
774
+ ### V.13. Implementation Checklist
775
+
776
+ - [ ] Create domain entities
777
+ - [ ] Define application interfaces
778
+ - [ ] Implement infrastructure services
779
+ - [ ] Add presentation components
780
+ - [ ] Configure dependency injection
781
+ - [ ] Replace hardcoded values identified in integration analysis
782
+ - [ ] Execute refactoring items from integration analysis
783
+ - [ ] Write unit tests
784
+ - [ ] Integration testing
785
+ - [ ] E2E testing covering ALL Acceptance Criteria Scenarios
786
+ - [ ] Documentation
787
+
788
+ For complete technical design details, see the sections above.
789
+ </section>
790
+
791
+ </output-format>
792
+
793
+ <analysis-process>
794
+
795
+ &lt;!-- This section defines the analysis methodology that the technical-application-architect
796
+ agent must follow. It mirrors the workflow steps but provides detailed
797
+ instructions for each analysis phase.
798
+
799
+ MANDATORY COMPLETION REQUIREMENTS:
800
+ - Phase 1: ALL 4 items (Initial Discovery) — MANDATORY
801
+ - Phase 2: ALL 3 items (System Architecture Understanding) — MANDATORY
802
+ - Phase 3: ALL 2 items (Codebase Analysis) — MANDATORY
803
+ - Phase 4: Solution Design (generate ALL output sections) — MANDATORY
804
+ - Total: 9 mandatory analysis items + 13 output sections — SKIP NONE --&gt;
805
+
806
+ <phase name="initial-discovery" order="1">
807
+ &lt;!-- ALL 4 items are MANDATORY --&gt;
808
+
809
+ <item name="understand-story" mandatory="true">
810
+ **[MANDATORY] Understand the Story:**
811
+ - Read the story thoroughly: User Story, Description, all AC scenarios
812
+ - These define WHAT functionality needs to be implemented
813
+ - Extract key behaviors, components, and patterns needed
814
+ - The story's acceptance criteria define the SCOPE of the solution
815
+ - Identify ALL AC scenarios — each will need a sequence diagram
816
+ </item>
817
+
818
+ <item name="extract-business-requirements" mandatory="true">
819
+ **[MANDATORY] Extract Business Requirements:**
820
+ - Requirements come from the story's User Story, Description, and AC
821
+ - The story IS the source of truth for business requirements
822
+ - Extract all constraints, behaviors, and expected outcomes
823
+ - Map each AC scenario to the technical components needed
824
+ </item>
825
+
826
+ <item name="study-external-analysis" mandatory="false">
827
+ **[CONDITIONAL] Study External/Industry-Standard Analysis:**
828
+ - Only if external analysis exists in story directory
829
+ - Use algorithms and formulas IF they are the MOST EFFICIENT AND PERFORMANT
830
+ - If you can identify a better approach, use the better approach
831
+ - The external analysis is a REFERENCE, not a blueprint
832
+ </item>
833
+
834
+ <item name="feature-planning-context" mandatory="true">
835
+ **[MANDATORY] Feature Planning Context:**
836
+ - Read the parent feature document for broader context
837
+ - Understand story dependencies and shared components
838
+ - Design with the complete feature in mind
839
+ - Never design in isolation
840
+ </item>
841
+ </phase>
842
+
843
+ <phase name="system-architecture-understanding" order="2">
844
+ &lt;!-- ALL 3 items are MANDATORY --&gt;
845
+
846
+ <item name="wiki-system-architecture" mandatory="true">
847
+ **[MANDATORY] System Architecture from Wiki:**
848
+ - Study system-architecture.md for complete architectural overview
849
+ - Study system-structure.md for codebase layout
850
+ - Map where this story's components fit in the overall architecture
851
+ </item>
852
+
853
+ <item name="wiki-subsystem-knowledge" mandatory="true">
854
+ **[MANDATORY] Subsystem Knowledge from Wiki:**
855
+ - Study ALL subsystem wiki documents referenced by the story
856
+ - Extract interfaces to extend, classes to compose, patterns to follow
857
+ - Identify constants to reuse and conventions to respect
858
+ - These replace: related-stories-implementations, documented-features, documentation
859
+ </item>
860
+
861
+ <item name="integration-analysis-study" mandatory="true">
862
+ **[MANDATORY] Deep Study of Integration Analysis:**
863
+ - THOROUGHLY analyze the integration analysis document
864
+ - Extract ALL integration points, refactoring needs, patterns to follow
865
+ - Extract ALL hardcoded values and placeholder code to replace
866
+ - This tells you EXACTLY how to integrate without breaking the codebase
867
+ - NEVER SKIP REFACTORING if the integration analysis identifies it's needed
868
+ </item>
869
+ </phase>
870
+
871
+ <phase name="codebase-analysis" order="3">
872
+ &lt;!-- ALL 2 items are MANDATORY --&gt;
873
+
874
+ <item name="coding-standards" mandatory="true">
875
+ **[MANDATORY] Coding Standards Review:**
876
+ - Read coding-standards.md BEFORE generating ANY solution code
877
+ - Enforce: zero hardcoding, single responsibility, interface-first design
878
+ - One class/interface/type per file — NO EXCEPTIONS
879
+ - Every piece of code in the solution MUST comply
880
+ </item>
881
+
882
+ <item name="source-code-exploration" mandatory="true">
883
+ **[MANDATORY] Source Code Exploration:**
884
+ - Guided by wiki system-structure.md and integration analysis
885
+ - Identify existing patterns, reusable components, naming conventions
886
+ - Focus on files identified by the integration analysis
887
+ </item>
888
+ </phase>
889
+
890
+ <phase name="solution-design" order="4">
891
+ &lt;!-- Generate ALL 13 output sections --&gt;
892
+
893
+ <item name="generate-all-sections" mandatory="true">
894
+ **[MANDATORY] Generate Complete Technical Solution:**
895
+ Using all context from phases 1-3, generate ALL output sections:
896
+ 1. Header with solution context
897
+ 2. Architecture Overview with Clean Architecture compliance
898
+ 3. V.1. Component &amp; Boundary Architecture with Mermaid diagrams
899
+ 4. V.2. Design Patterns &amp; Technical Decisions
900
+ 5. V.3. Complete Class Diagrams &amp; Interfaces (one per file!)
901
+ 6. V.4. Data Models &amp; Structures (one per file!)
902
+ 7. V.5. Algorithms &amp; Business Logic with formulas and examples
903
+ 8. V.6. Event Flow &amp; Entry Points
904
+ 9. V.7. MANDATORY Sequence Diagrams for ALL AC scenarios
905
+ 10. V.8. Complete File Structure tree
906
+ 11. V.9. DI Container Configuration
907
+ 12. V.10. Refactoring Plan (from integration analysis)
908
+ 13. V.11. Testing Strategy (unit, integration, e2e)
909
+ 14. V.12. Implementation Order with dependencies
910
+ 15. V.13. Implementation Checklist
911
+ </item>
912
+ </phase>
913
+
914
+ </analysis-process>
915
+
916
+ <validation-checklist>
917
+
918
+ &lt;!-- The workflow uses this checklist to validate completeness.
919
+ ALL 25 items MUST pass before the solution is considered complete. --&gt;
920
+
921
+ **Story File Requirements:**
922
+ - [ ] Technical solution section exists in the story file
923
+ - [ ] Section contains all required subsections from template
924
+
925
+ **Architecture Requirements:**
926
+ - [ ] Component &amp; Boundary Architecture with Mermaid diagram
927
+ - [ ] Layer Architecture Analysis (Domain, Application, Infrastructure, Presentation)
928
+ - [ ] Clean Architecture compliance verified (dependencies point inward)
929
+ - [ ] Dependency injection strategy documented
930
+
931
+ **Design Requirements:**
932
+ - [ ] Design patterns documented with purpose and implementation
933
+ - [ ] Technical decisions documented with rationale and trade-offs
934
+ - [ ] Class diagrams with complete interface definitions
935
+ - [ ] EVERY interface/class/type in its OWN SEPARATE FILE (coding standards!)
936
+ - [ ] Data models and structures defined with TypeScript types
937
+
938
+ **Algorithm Requirements:**
939
+ - [ ] Algorithms documented with mathematical formulas
940
+ - [ ] Constants and configuration values defined (NO hardcoding!)
941
+ - [ ] Business rules documented with implementations
942
+ - [ ] Example calculations provided
943
+
944
+ **Sequence Diagram Requirements (CRITICAL!):**
945
+ - [ ] Sequence diagram for EVERY AC scenario
946
+ - [ ] Full flow from entry point to exit through ALL layers
947
+ - [ ] Real method names used (not generic placeholders)
948
+ - [ ] Error handling paths included (alt blocks)
949
+ - [ ] Data structures shown at each step
950
+
951
+ **Implementation Requirements:**
952
+ - [ ] Complete file structure tree (new + modified files)
953
+ - [ ] DI container configuration specified
954
+ - [ ] Refactoring plan from integration analysis incorporated
955
+ - [ ] Testing strategy (unit, integration, e2e)
956
+ - [ ] Implementation order with dependencies
957
+ - [ ] Implementation checklist
958
+
959
+ **Compliance Requirements:**
960
+ - [ ] Coding standards compliance verified throughout
961
+ - [ ] Integration analysis findings incorporated
962
+ - [ ] No hardcoded values in any code snippets
963
+ - [ ] All code follows Clean Architecture layers
964
+
965
+ **Total: 25 mandatory checklist items**
966
+
967
+ </validation-checklist>
968
+
969
+ <guidelines>
970
+
971
+ <guideline name="external-analysis-philosophy">
972
+ When external analysis IS available:
973
+ - Use external algorithms and formulas IF they are the MOST EFFICIENT AND PERFORMANT
974
+ - If you can identify a better approach, use the better approach
975
+ - The external analysis is a REFERENCE, not a mandatory blueprint
976
+ - Adapt external patterns to fit Clean Architecture properly
977
+ - Constants from external systems are starting points, not mandates
978
+ </guideline>
979
+
980
+ <guideline name="integration-analysis-mandatory">
981
+ The integration analysis (pass 4) is ALWAYS required:
982
+ - It tells you exactly how to integrate without breaking the codebase
983
+ - All refactoring items MUST be incorporated into the solution
984
+ - All hardcoded values MUST be addressed in the refactoring plan
985
+ - Patterns identified MUST be followed
986
+ - Do not design in ways that contradict the integration analysis
987
+ </guideline>
988
+
989
+ <guideline name="coding-standards-first">
990
+ Coding standards are NON-NEGOTIABLE:
991
+ - Read coding-standards.md BEFORE generating any code
992
+ - One class/interface/type per file — ALWAYS
993
+ - Zero hardcoding — ALL values in constants files
994
+ - Interface-first design — EVERY implementation has an interface
995
+ - No dead code — clean, complete implementations only
996
+ </guideline>
997
+
998
+ <guideline name="sequence-diagram-completeness">
999
+ Every AC scenario MUST have a sequence diagram:
1000
+ - Full flow from entry point to exit through ALL architectural layers
1001
+ - Real method names, not generic placeholders
1002
+ - Exact data structures passed at each step
1003
+ - Error handling paths (alt blocks)
1004
+ - No scenario may be skipped
1005
+ </guideline>
1006
+
1007
+ <guideline name="github-compatibility">
1008
+ The technical solution is written into the story file which is also a GitHub issue:
1009
+ - Mermaid diagrams render natively in GitHub
1010
+ - Use markdown tables (not HTML)
1011
+ - No custom CSS or HTML styling
1012
+ - Keep formatting clean for GitHub rendering
1013
+ </guideline>
1014
+
1015
+ <guideline name="solution-size">
1016
+ The technical solution will typically be 1000-2000+ lines:
1017
+ - This is expected and necessary for comprehensive coverage
1018
+ - Do not truncate or summarize — the implementing AI needs every detail
1019
+ - Include ALL diagrams, ALL code snippets, ALL configurations
1020
+ - Completeness is more important than brevity
1021
+ </guideline>
1022
+
1023
+ </guidelines>
1024
+
1025
+ </technical-solution>