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,1015 +1,1015 @@
1
- <integration-solution>
2
-
3
- <purpose>
4
- Template for `.ace/artifacts/product/&lt;id-epic_name&gt;/&lt;id-feature_name&gt;/&lt;id-story_name&gt;/integration-analysis.md` —
5
- a COMPREHENSIVE, IN-DEPTH System Integration Analysis that ensures new story
6
- implementations integrate seamlessly with existing systems without breaking
7
- functionality or violating architectural principles.
8
-
9
- This is pass 4 of the story specification pipeline (see story.xml composition).
10
- It produces a separate artifact in the story directory — NOT appended to the story file.
11
- The analysis is consumed by pass 5 (technical solution) as input for designing
12
- the implementation approach with full codebase integration context.
13
-
14
- **[MANDATORY]** Identify how a new story would PROPERLY integrate with the existing
15
- codebase while maintaining architectural integrity, maintainability, and extensibility
16
- while strictly following CODING STANDARDS.
17
-
18
- You are operating within a PRODUCTION-GRADE, CLEAN, COMPLEX CODEBASE — new code
19
- must be added thoughtfully and systematically. The purpose is to analyze HOW TO ADD
20
- NEW FUNCTIONALITY WHILE KEEPING THE CODE MAINTAINABLE AND EXTENSIBLE.
21
-
22
- This document does NOT modify the story file. It lives as a separate artifact
23
- in the story directory. Only the technical solution (pass 5) consumes it.
24
-
25
- CRITICAL: This analysis output will be used as PROMPT CONTEXT for the AI agent
26
- implementing this feature. Therefore:
27
- - INCLUDE ALL FINDINGS — don't summarize or omit details
28
- - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
29
- - BE EXPLICIT — don't assume the implementing AI will know anything not explicitly stated
30
- </purpose>
31
-
32
- <output-format>
33
-
34
- <section name="header">
35
- # System Integration Analysis: [Story Name]
36
-
37
- ## Analysis Context
38
- - **Story**: [Story ID] — [Story Title]
39
- - **Feature**: [Feature ID] — [Feature Title]
40
- - **Epic**: [Epic ID] — [Epic Title]
41
- - **Analysis Date**: [Current date]
42
- - **Wiki Documents Loaded**: [N] files
43
- - **External Analysis**: [Available/Not available]
44
- - **Code References**: [N] references documented
45
- - **Hardcoded Values Found**: [N] items
46
- - **Refactoring Items**: [N] items
47
- </section>
48
-
49
- <section name="use-case-overview">
50
- ## 1. Use Case Overview
51
-
52
- [Brief description of what needs to be implemented — extracted from the story's
53
- User Story statement, Description, and Acceptance Criteria.
54
-
55
- Include:
56
- - What the user can do when this story is done
57
- - Key behaviors and requirements from acceptance criteria
58
- - How this story relates to other stories in the feature
59
- - What the parent feature context provides]
60
- </section>
61
-
62
- <section name="architecture-compatibility">
63
- ## 2. Architecture Compatibility
64
-
65
- &lt;!-- How this story fits into the Clean Architecture layers.
66
- For EACH layer, document what new components are needed
67
- and how they integrate with existing components. --&gt;
68
-
69
- ### Domain Layer
70
- &lt;!-- New entities, value objects, constants, business rules needed.
71
- How they relate to existing domain objects.
72
- Domain events that may be needed.
73
- File paths to relevant existing domain code. --&gt;
74
- - **New Entities**: [entities to create with proposed file paths]
75
- - **Value Objects**: [value objects needed]
76
- - **Constants**: [new constants or extensions to existing constant files]
77
- - **Business Rules**: [domain rules this story introduces]
78
- - **Existing Domain Code**: [relevant existing domain files with paths]
79
-
80
- ### Application Layer
81
- &lt;!-- Use cases, interfaces, DTOs to create.
82
- How they interact with existing application services.
83
- Dependency injection registrations needed. --&gt;
84
- - **Use Cases**: [use cases to create]
85
- - **Interfaces**: [interfaces to define or extend]
86
- - **DTOs**: [data transfer objects needed]
87
- - **Existing Services**: [application services that will be affected]
88
-
89
- ### Infrastructure Layer
90
- &lt;!-- Services, implementations, repositories required.
91
- External service integrations.
92
- How they implement application layer interfaces. --&gt;
93
- - **Services**: [infrastructure services to implement]
94
- - **Implementations**: [interface implementations needed]
95
- - **Repositories**: [data access patterns to follow]
96
- - **Existing Infrastructure**: [existing infrastructure code affected]
97
-
98
- ### Presentation Layer
99
- &lt;!-- UI components, API endpoints, view models needed.
100
- How they connect to application layer.
101
- User interaction patterns to follow. --&gt;
102
- - **Components**: [UI components or API endpoints needed]
103
- - **View Models**: [presentation models needed]
104
- - **Existing Presentation Code**: [existing presentation code affected]
105
-
106
- ### Dependency Rule Compliance
107
- &lt;!-- Verify that all proposed changes maintain the dependency rule:
108
- dependencies point inward (Presentation → Application → Domain).
109
- Infrastructure implements Application interfaces.
110
- No layer knows about outer layers. --&gt;
111
- - [Compliance verification for each proposed change]
112
- </section>
113
-
114
- <section name="existing-patterns">
115
- ## 3. Existing Patterns to Follow
116
-
117
- &lt;!-- Specific patterns found in the codebase that this story MUST follow.
118
- Each pattern includes file references with line numbers.
119
- The implementing agent must study these files before coding. --&gt;
120
-
121
- ### Similar Implementations
122
- &lt;!-- Reference existing code that implements similar functionality.
123
- The new implementation should follow these as examples. --&gt;
124
- - **[Implementation Name]** at `[file:line-range]` — [what to learn from it]
125
-
126
- ### Established Conventions
127
- &lt;!-- Naming patterns, file organization, code structure conventions. --&gt;
128
- - **Naming**: [naming conventions with examples from codebase]
129
- - **File Organization**: [how files are organized with examples]
130
- - **Code Structure**: [class/function structure patterns]
131
-
132
- ### Design Patterns in Use
133
- &lt;!-- Which design patterns are already used that must be followed. --&gt;
134
-
135
- #### [Pattern Name] (e.g., Strategy, Factory, Observer)
136
- - **Where**: [File/component where pattern is used — with path]
137
- - **Why**: [Why this pattern was chosen]
138
- - **Implementation Example**:
139
- ```typescript
140
- // From [file:line-range]
141
- [Code example showing the pattern]
142
- ```
143
- - **How to Follow**: [How the new code should use this pattern]
144
-
145
- &lt;!-- Repeat for each identified pattern --&gt;
146
-
147
- ### Error Handling Patterns
148
- - [How errors are handled — with code references]
149
-
150
- ### Logging Patterns
151
- - [How logging is done — with code references]
152
-
153
- ### Constants &amp; Configuration Patterns
154
- - [How constants are organized — with code references]
155
- - [Where to add new constants]
156
- </section>
157
-
158
- <section name="required-refactoring">
159
- ## 4. Required Refactoring
160
-
161
- &lt;!-- List any existing code that needs refactoring to support the new implementation.
162
- Include justification for each refactoring decision.
163
- Impact assessment of changes.
164
- Even if no refactoring is needed, complete this section with that conclusion. --&gt;
165
-
166
- ### Refactoring Items
167
-
168
- &lt;!-- For each item:
169
- - What code needs to change (file path, line numbers)
170
- - Current state (what it is now)
171
- - Proposed change (what it should become)
172
- - Justification (why this refactoring is needed)
173
- - Impact (what else is affected by this change)
174
-
175
- Common scenarios:
176
- - Pattern violations: Direct implementations that should use Strategy/Factory
177
- - Constants chaos: Magic strings/numbers that should be centralized
178
- - Model proliferation: Duplicate models that should be unified
179
- - Method duplication: Duplicate logic that should be extracted
180
- - Layer violations: Business logic in wrong architectural layer
181
- - Service sprawl: Services that should be extended vs. duplicated
182
- - Event handler inconsistencies: Inconsistent event handling patterns
183
- - State management violations: State managed inconsistently
184
- - API integration inconsistencies: Direct API calls instead of services
185
- - Type definition duplication: Redefined types that should be imported --&gt;
186
-
187
- #### [Refactoring Item Name]
188
- - **File**: `[file:line-range]`
189
- - **Current State**: [what it is now]
190
- - **Proposed Change**: [what it should become]
191
- - **Justification**: [why this is needed for the new implementation]
192
- - **Impact**: [what else is affected]
193
-
194
- &lt;!-- Repeat for each refactoring item.
195
- If no refactoring needed, state: "No refactoring required. [justification]." --&gt;
196
- </section>
197
-
198
- <section name="hardcoded-values-critical">
199
- ## 5. CRITICAL: Hardcoded Values &amp; Placeholder Code That MUST Be Replaced
200
-
201
- &lt;!-- THIS IS THE MOST CRITICAL SECTION OF THE INTEGRATION ANALYSIS!
202
-
203
- THE #1 REASON INTEGRATION ANALYSES FAIL:
204
- The analysis identifies what NEW code to create but FAILS to identify
205
- what EXISTING code must be MODIFIED or REPLACED.
206
-
207
- For every new entity/service being created, ask:
208
- - "What existing code currently does this job (probably poorly/hardcoded)?"
209
- - "Where should this entity be INJECTED that it currently ISN'T?"
210
- - "What hardcoded values exist that this entity should REPLACE?"
211
-
212
- MANDATORY SEARCHES:
213
- - Hardcoded numeric ranges, dimensions, colors, sizes
214
- - TODO comments mentioning the feature
215
- - "temporary", "placeholder", "stub", "mock" in comments
216
- - Methods returning hardcoded values instead of computed ones
217
- - Classes/services that exist but aren't used where they should be
218
- - Inline calculations that should use the new service
219
- - Manager/Service classes with hardcoded defaults
220
- - Renderers/handlers not using the new entity
221
-
222
- This section MUST be filled with ACTUAL CODE SNIPPETS from the codebase!
223
- The implementing AI agent NEEDS to know EXACTLY what to change and WHERE. --&gt;
224
-
225
- ### Hardcoded Values to Replace
226
-
227
- ```yaml
228
- FILE: [exact file path]
229
- LINE: [line number(s)]
230
- CURRENT CODE: |
231
- [actual code snippet from the file]
232
- PROBLEM: [why this is wrong]
233
- SHOULD BE: [what it should become after implementation]
234
- FIX REQUIRED: [specific action to take]
235
- ```
236
-
237
- &lt;!-- Repeat for EACH hardcoded value found --&gt;
238
-
239
- ### Disconnected Wiring to Fix
240
-
241
- ```yaml
242
- ENTITY/SERVICE EXISTS: [path to entity/service that should be used]
243
- CURRENTLY NOT CONNECTED TO:
244
- - [File 1]: [what it uses instead]
245
- - [File 2]: [what it uses instead]
246
- REQUIRED CONNECTIONS:
247
- - [Where to inject and how]
248
- ```
249
-
250
- &lt;!-- Repeat for EACH disconnected wiring found --&gt;
251
-
252
- ### Placeholder/TODO Code to Implement
253
-
254
- ```yaml
255
- FILE: [file path]
256
- LINE: [line number]
257
- TODO COMMENT: "[exact TODO text]"
258
- CURRENT IMPLEMENTATION: [what it does now — probably hardcoded]
259
- REQUIRED IMPLEMENTATION: [what needs to be implemented]
260
- ```
261
-
262
- &lt;!-- Repeat for EACH placeholder found --&gt;
263
-
264
- ### Renderers/Services Not Using New Entity
265
-
266
- ```yaml
267
- NEW ENTITY: [entity name and path]
268
- RENDERERS/HANDLERS THAT MUST USE IT:
269
- - [Renderer/Handler 1]: Currently uses [X], must use [new entity]
270
- - [Renderer/Handler 2]: Currently uses [X], must use [new entity]
271
- SERVICES THAT MUST USE IT:
272
- - [Service 1]: Currently [behavior], must [new behavior]
273
- ```
274
-
275
- &lt;!-- Repeat for EACH new entity --&gt;
276
- </section>
277
-
278
- <section name="integration-points">
279
- ## 6. Integration Points
280
-
281
- &lt;!-- All touchpoints between the new implementation and the existing system.
282
- Categorize by architectural layer and component type. --&gt;
283
-
284
- ### Domain Layer Integration
285
- - [Integration point — how the new domain code connects with existing domain]
286
-
287
- ### Application Layer Integration
288
- - [Integration point — new use cases, service interfaces, DI registrations]
289
-
290
- ### Infrastructure Layer Integration
291
- - [Integration point — new service implementations, repository patterns]
292
-
293
- ### Presentation Layer Integration
294
- - [Integration point — new UI components, API endpoints, event handlers]
295
-
296
- ### Cross-Cutting Integration
297
- &lt;!-- Event systems, middleware, DI container, logging, error handling --&gt;
298
- - [Integration point — cross-cutting concerns this story must respect]
299
- </section>
300
-
301
- <section name="impact-analysis">
302
- ## 7. Impact Analysis
303
-
304
- &lt;!-- ALL code flows that might be impacted by the new implementation.
305
- Include specific file references for each impacted flow. --&gt;
306
-
307
- ### Affected Code Flows
308
- - **[Flow Name]**: [description of impact] — `[file:line-range]`
309
-
310
- ### Affected Tests
311
- &lt;!-- Tests that may need modification due to the new implementation --&gt;
312
- - `[test-file:line-range]` — [what needs to change and why]
313
-
314
- ### Affected Documentation
315
- &lt;!-- Documentation files/wiki docs that may need updates --&gt;
316
- - `[doc-file]` — [what needs updating]
317
-
318
- ### Performance Implications
319
- - [Performance consideration — with mitigation strategy]
320
-
321
- ### Breaking Change Risks
322
- - [Risk — with mitigation strategy]
323
- </section>
324
-
325
- <section name="codebase-tree">
326
- ## 8. Codebase Structure
327
-
328
- ### Current Structure (Relevant Files)
329
- &lt;!-- Tree structure showing ACTUAL current files relevant to this story.
330
- NOT the entire codebase — only files that are involved.
331
- Include file paths and one-line purpose. --&gt;
332
-
333
- ```
334
- [Current relevant file tree]
335
- ```
336
-
337
- ### Proposed Structure (With New Files)
338
- &lt;!-- Tree structure showing what the codebase will look like
339
- after implementing this story. Mark new files clearly. --&gt;
340
-
341
- ```
342
- [Proposed file tree with new files marked]
343
- ```
344
- </section>
345
-
346
- <section name="implementation-guidelines">
347
- ## 9. Implementation Guidelines
348
-
349
- &lt;!-- Step-by-step approach following coding standards.
350
- The implementing agent should follow this order. --&gt;
351
-
352
- ### Recommended Implementation Order
353
-
354
- 1. **[Step 1]**: [What to implement first and why]
355
- - Files to create/modify: [list]
356
- - Pattern to follow: [reference to existing pattern]
357
-
358
- 2. **[Step 2]**: [What to implement next]
359
- - Files to create/modify: [list]
360
- - Pattern to follow: [reference]
361
-
362
- &lt;!-- Continue for all implementation steps --&gt;
363
-
364
- ### Dependency Management
365
- - [How to manage dependencies — DI registrations, imports, etc.]
366
-
367
- ### Error Handling Approach
368
- - [Error handling strategy for the new implementation]
369
-
370
- ### State Management Strategy
371
- - [How state should be managed in the new implementation]
372
- </section>
373
-
374
- <section name="testing-strategy">
375
- ## 10. Testing Strategy
376
-
377
- &lt;!-- How to test without breaking existing tests.
378
- Follow the testing framework patterns from wiki. --&gt;
379
-
380
- ### Test Types Required
381
- - **Unit Tests**: [what to unit test, mocking strategy]
382
- - **Integration Tests**: [what integration scenarios to cover]
383
- - **E2E Tests**: [end-to-end scenarios if applicable]
384
-
385
- ### Existing Test Patterns to Follow
386
- - [Pattern 1 — with reference to existing test file]
387
- - [Pattern 2 — with reference to existing test file]
388
-
389
- ### Test Data Patterns
390
- - [How test data is managed in existing tests]
391
-
392
- ### Ensuring Existing Tests Pass
393
- - [Steps to verify existing tests still pass after changes]
394
- - [Tests that may need adjustment and why]
395
- </section>
396
-
397
- <section name="complete-findings">
398
- ## 11. Complete Analysis Findings
399
-
400
- &lt;!-- INCLUDE ALL FINDINGS from the deep analysis.
401
- This is the comprehensive dump of everything discovered.
402
- The implementing AI needs every piece of information.
403
-
404
- Include:
405
- - Every discovered pattern with file references
406
- - Every relevant code snippet
407
- - Every architectural decision
408
- - Every potential issue
409
- - Every integration consideration --&gt;
410
-
411
- ### Discovered Patterns
412
- - [Pattern — file reference — relevance to this story]
413
-
414
- ### Relevant Code Snippets
415
- ```typescript
416
- // From [file:line-range]
417
- // [Why this snippet is relevant]
418
- [actual code]
419
- ```
420
-
421
- ### Architectural Constraints
422
- - [Constraint — source (coding standards, ADR, etc.) — impact on implementation]
423
-
424
- ### Potential Issues
425
- - [Issue — likelihood — mitigation]
426
- </section>
427
-
428
- <section name="implementation-references">
429
- ## 12. Implementation References
430
-
431
- ### Internal Documentation
432
- &lt;!-- All relevant internal docs with full paths --&gt;
433
- - `[path]` — [what to learn from this doc]
434
-
435
- ### Code References
436
- &lt;!-- All files that should be studied before implementation --&gt;
437
- - `[file:line-range]` — [what to learn from this code]
438
-
439
- ### Design Patterns &amp; Best Practices
440
- &lt;!-- Links to pattern documentation --&gt;
441
- - [Pattern Name] — [link to documentation, e.g., refactoring.guru]
442
-
443
- ### External Resources
444
- &lt;!-- Official documentation links for libraries used --&gt;
445
- - [Resource] — [link]
446
- </section>
447
-
448
- <section name="ai-implementation-context">
449
- ## 13. AI Implementation Context
450
-
451
- &lt;!-- CRITICAL SECTION — This will be the primary context for the implementing AI.
452
- Everything the implementing agent needs to know in one place. --&gt;
453
-
454
- ### Domain Knowledge
455
- - [All domain-specific knowledge the implementing agent needs]
456
-
457
- ### Constraints &amp; Limitations
458
- - [All constraints from coding standards, architecture, ADRs]
459
-
460
- ### Naming Conventions
461
- - [All naming conventions observed in the codebase with examples]
462
-
463
- ### Error Handling Standards
464
- - [Error handling patterns with code references]
465
-
466
- ### Logging Standards
467
- - [Logging approach with code references]
468
-
469
- ### Performance Considerations
470
- - [Performance requirements and optimization approaches]
471
-
472
- ### Example Code Snippets
473
- &lt;!-- Code snippets from similar implementations that serve as templates --&gt;
474
- ```typescript
475
- // From [file:line-range]
476
- // [This serves as a template for implementing [component]]
477
- [actual code from similar implementation]
478
- ```
479
- </section>
480
-
481
- </output-format>
482
-
483
- <analysis-process>
484
-
485
- &lt;!-- This section defines the analysis methodology that the code-integration-analyst
486
- agent must follow. It mirrors the workflow steps but provides detailed
487
- instructions for each analysis phase.
488
-
489
- MANDATORY COMPLETION REQUIREMENTS:
490
- - Phase 1: ALL 4 items (Context Loading) — MANDATORY
491
- - Phase 2: ALL 8 items (Deep Codebase Analysis) — MANDATORY
492
- - Phase 3: ALL 4 items (Refactoring &amp; Strategy) — MANDATORY
493
- - Phase 4: ALL 2 items (AI Implementation Context) — MANDATORY
494
- - Total: 18 mandatory analysis items — SKIP NONE --&gt;
495
-
496
- <phase name="context-loading" order="1">
497
- &lt;!-- ALL 4 items are MANDATORY --&gt;
498
-
499
- <item name="understand-story" mandatory="true">
500
- **[MANDATORY] Understand the story requirements:**
501
- - Read the story thoroughly: User Story, Description, all AC scenarios
502
- - These define WHAT functionality needs to integrate into the codebase
503
- - Extract key behaviors, components, and patterns needed
504
- - The story's acceptance criteria define the SCOPE of the analysis
505
- - **Requirements come from the story** — do NOT seek requirements
506
- from other sources. The story IS the source of truth.
507
- - If a parent feature document is available, read it to understand:
508
- - The broader feature context
509
- - What other stories exist and how they relate
510
- - Dependencies and shared components between stories
511
- </item>
512
-
513
- <item name="load-wiki-documents" mandatory="true">
514
- **[MANDATORY] Load and study ALL wiki documents from the story's Relevant Wiki section:**
515
-
516
- These wiki documents provide the COMPLETE codebase context:
517
-
518
- - **System-Wide** (always present):
519
- - `system-structure.md` — High-level codebase tree and organization
520
- - `system-architecture.md` — Complete architectural overview
521
- - `coding-standards.md` — CRITICAL: coding standards — NO EXCEPTIONS!
522
- - `testing-framework.md` — Testing patterns and frameworks
523
-
524
- - **Subsystem Documents** (as referenced by story):
525
- - **Systems**: System descriptions, boundaries, APIs
526
- - **Patterns**: Design patterns in use with examples
527
- - **Cross-Cutting Concerns**: Shared concerns (auth, logging, errors, etc.)
528
- - **Guides**: How-to guides for common implementation tasks
529
- - **Walkthroughs**: Deep tutorial-style flow explanations with actual code snippets
530
- - **Decisions (ADRs)**: Architecture decisions that constrain design
531
- - **Architecture**: Subsystem architecture documents
532
-
533
- Read EVERY document. These replace the obsolete command's separate parameters:
534
- - sourcecode → system-structure.md (high-level tree)
535
- - high-level-architecture → system-architecture.md
536
- - documentation → all wiki documents combined
537
- - related-stories-implementations → wiki documents capture story knowledge
538
- - documented-features → wiki documents catalog feature implementations
539
- </item>
540
-
541
- <item name="load-external-analysis" mandatory="true">
542
- **[MANDATORY] Check and load external analysis if available:**
543
- - Automatically check for `{STORY_DIR}/external-analysis.md`
544
- - This is the artifact from pass 3 (`/ace:research-external-solution`)
545
- - If present, study it for:
546
- - How industry-standard systems implement this functionality
547
- - Algorithms and formulas to reuse
548
- - Design patterns from external implementations
549
- - Best practices that should inform our integration
550
- - If not present, proceed without — note this in the analysis
551
- </item>
552
-
553
- <item name="load-feature-document" mandatory="true">
554
- **[MANDATORY] Load the parent feature document:**
555
- - The feature file path can be extracted from the story metadata
556
- - Understand the feature planning context
557
- - Identify how this story fits within the broader feature
558
- - Identify dependencies and integration points with other stories
559
- - If not found, proceed without — the analysis can still be done
560
- </item>
561
- </phase>
562
-
563
- <phase name="deep-codebase-analysis" order="2">
564
- &lt;!-- ALL 8 items are MANDATORY — skip NONE --&gt;
565
-
566
- <item name="architecture-compatibility" mandatory="true">
567
- **[MANDATORY] Architecture Compatibility Analysis:**
568
-
569
- Map how the new story fits into Clean Architecture layers:
570
-
571
- - **Domain Layer**: New entities, value objects, constants needed.
572
- How they relate to existing domain objects. Domain events needed.
573
- - **Application Layer**: Use cases and interfaces to create.
574
- How they interact with existing application services. DI registrations.
575
- - **Infrastructure Layer**: Services and implementations required.
576
- External service integrations. How they implement application interfaces.
577
- - **Presentation Layer**: UI components and API endpoints needed.
578
- How they connect to application layer. User interaction patterns.
579
-
580
- Verify Clean Architecture compliance:
581
- - Dependencies point inward toward domain
582
- - Each layer knows only about inner layers
583
- - Depend on abstractions, not concretions
584
- - All business logic independently testable
585
- </item>
586
-
587
- <item name="pattern-recognition" mandatory="true">
588
- **[MANDATORY] Pattern Recognition &amp; Existing Patterns:**
589
-
590
- Search for similar features/patterns in the codebase and reference them
591
- with specific file paths and line numbers:
592
-
593
- - **Similar Implementations**: Find existing code that does something similar
594
- - **Naming Conventions**: Document exact naming patterns with examples
595
- - **Design Patterns**: Catalog patterns in use (Strategy, Factory, Observer, etc.)
596
- - **Error Handling**: Document error handling approaches with code references
597
- - **Logging**: Document logging approaches
598
- - **Constants Organization**: How constants are organized and where to add new ones
599
- </item>
600
-
601
- <item name="integration-points" mandatory="true">
602
- **[MANDATORY] Integration Point Discovery (Layer-by-Layer):**
603
-
604
- Examine each architectural layer for integration opportunities:
605
-
606
- - **Domain Layer**: Entity extensions, value objects, business rules
607
- - **Application Layer**: Service interfaces, use cases, DTOs
608
- - **Infrastructure Layer**: Repository patterns, external services
609
- - **Presentation Layer**: UI components, view models, controllers
610
-
611
- Find:
612
- - Existing interfaces that can be extended
613
- - Abstract classes available for inheritance
614
- - Event systems for loose coupling
615
- - Middleware or pipeline patterns
616
- - Plugin or extension points
617
- - Configuration-based feature toggles
618
- - DI container registrations needed
619
- </item>
620
-
621
- <item name="file-dependencies" mandatory="true">
622
- **[MANDATORY] File Dependency Analysis:**
623
-
624
- - Identify ALL files that will be referenced or modified
625
- - Document supporting files for the new implementation
626
- - Map import chains and dependency graphs
627
- - Identify potential circular dependency risks
628
- - List all current files that will support the new implementation
629
- </item>
630
-
631
- <item name="convention-compliance" mandatory="true">
632
- **[MANDATORY] Convention Compliance Analysis:**
633
-
634
- - Document existing conventions that MUST be followed
635
- - Verify the new implementation doesn't violate CODING STANDARDS
636
- - Check naming conventions, file organization, error handling
637
- - Verify SOLID principles compliance
638
- - Verify Clean Architecture layer boundaries
639
- </item>
640
-
641
- <item name="testing-patterns" mandatory="true">
642
- **[MANDATORY] Testing Pattern Analysis:**
643
-
644
- - Analyze current test patterns for consistent validation approach
645
- - Identify test utilities and helpers available for reuse
646
- - Document testing conventions (unit, integration, e2e)
647
- - Identify tests that need modification due to the new implementation
648
- - Extract mocking strategies used
649
- </item>
650
-
651
- <item name="hardcoded-values-discovery" mandatory="true">
652
- **[MANDATORY] CRITICAL: Hardcoded Values &amp; Placeholder Code Discovery:**
653
-
654
- THIS IS THE MOST CRITICAL PART OF THE INTEGRATION ANALYSIS!
655
-
656
- When a new story implements a feature, there are ALWAYS existing hardcoded
657
- values or placeholder implementations that the new feature is MEANT TO REPLACE.
658
-
659
- YOU MUST EXHAUSTIVELY SEARCH FOR:
660
-
661
- <search-category name="hardcoded-domain-values">
662
- **Hardcoded Domain/Range Values:**
663
- - Search for hardcoded number ranges, dimensions, colors, sizes, offsets
664
- - Search for values that should come from the new entity/service
665
- - Grep patterns: `domain\(\[`, `= 0;`, `= 100`, `MIN_`, `MAX_`, `DEFAULT_`
666
- </search-category>
667
-
668
- <search-category name="placeholder-stubs">
669
- **Placeholder/Stub Implementations:**
670
- - Search for TODO comments mentioning the feature being implemented
671
- - Search for "temporary", "placeholder", "stub", "mock" in comments
672
- - Search for methods returning hardcoded values instead of computed ones
673
- - Grep patterns: `TODO`, `TEMPORARY`, `placeholder`, `HARDCODED`
674
- </search-category>
675
-
676
- <search-category name="disconnected-wiring">
677
- **Disconnected Wiring:**
678
- - Classes/services that EXIST but are NOT USED where they should be
679
- - Find where the NEW entity/service SHOULD be injected but currently isn't
680
- - For every new entity/service, ask:
681
- - "What existing code currently does this job?"
682
- - "Where should this entity be INJECTED?"
683
- - "What hardcoded values exist that this entity should REPLACE?"
684
- </search-category>
685
-
686
- <search-category name="inline-calculations">
687
- **Inline Calculations That Should Use New Service:**
688
- - Inline calculations done manually instead of using the new entity
689
- - Duplicate calculation logic across multiple files
690
- - Grep patterns: `Math.min`, `Math.max`, inline formulas
691
- </search-category>
692
-
693
- <search-category name="manager-service-defaults">
694
- **Manager/Service Classes with Hardcoded Defaults:**
695
- - Manager/service classes initializing with dummy values
696
- - These MUST be updated to receive values from the new entity
697
- - Search: `*Manager`, `*Service` classes in Infrastructure layer
698
- </search-category>
699
-
700
- <search-category name="renderers-not-using-entity">
701
- **Renderers/Handlers Not Using New Entity:**
702
- - When implementing a new feature, ALL relevant renderers/handlers must be checked
703
- - Verify they use the new entity instead of hardcoded values
704
- - Search: `*Renderer`, `*Handler`, `*Controller` classes
705
- </search-category>
706
-
707
- Output format for EACH discovered item:
708
- ```yaml
709
- FILE: [exact file path]
710
- LINE: [line number(s)]
711
- CURRENT CODE: |
712
- [actual code snippet from the file]
713
- PROBLEM: [why this is wrong]
714
- SHOULD BE: [what it should become after implementation]
715
- FIX REQUIRED: [specific action to take]
716
- ```
717
-
718
- CRITICAL: This section MUST be filled with ACTUAL CODE SNIPPETS from the codebase!
719
- The implementing AI agent NEEDS to know EXACTLY what to change and WHERE.
720
- </item>
721
-
722
- <item name="impact-analysis" mandatory="true">
723
- **[MANDATORY] Impact Analysis:**
724
-
725
- - Discover ALL code flows that might be impacted by the new implementation
726
- - Include specific file references for each impacted flow
727
- - Identify tests that need modification (include file paths)
728
- - Document documentation files/flows requiring updates
729
- - Assess performance implications
730
- - Identify breaking change risks
731
- </item>
732
- </phase>
733
-
734
- <phase name="refactoring-strategy" order="3">
735
- &lt;!-- ALL 4 items are MANDATORY --&gt;
736
-
737
- <item name="refactoring-requirements" mandatory="true">
738
- **[MANDATORY] Refactoring Requirements:**
739
-
740
- Determine if existing code needs refactoring for the new implementation
741
- to be MAINTAINABLE / EXTENSIBLE. Check for:
742
-
743
- <refactoring-scenario name="consolidation">
744
- Duplicate code that should be unified before adding more
745
- </refactoring-scenario>
746
- <refactoring-scenario name="abstraction">
747
- Concrete implementations that need interfaces for extensibility
748
- </refactoring-scenario>
749
- <refactoring-scenario name="separation">
750
- Mixed concerns that need splitting before adding new functionality
751
- </refactoring-scenario>
752
- <refactoring-scenario name="generalization">
753
- Specific code that could be made reusable by the new implementation
754
- </refactoring-scenario>
755
- <refactoring-scenario name="simplification">
756
- Complex code that could be streamlined
757
- </refactoring-scenario>
758
- <refactoring-scenario name="standardization">
759
- Inconsistent patterns needing alignment before extending
760
- </refactoring-scenario>
761
-
762
- Common refactoring scenarios to check:
763
- - Pattern violations (adding a new type when Strategy pattern should be used)
764
- - Constants scattered across files (centralize in Domain layer)
765
- - Model proliferation (extend existing vs. create duplicate)
766
- - Method duplication (reuse existing methods)
767
- - Layer violations (business logic in wrong layer)
768
- - Service sprawl (extend existing services if cohesive)
769
- - Event handler inconsistencies
770
- - State management violations
771
- - API integration inconsistencies
772
- - Type definition duplication
773
-
774
- **Even if no refactoring is needed, this section MUST be completed
775
- with the conclusion "no refactoring required" and justification.**
776
- </item>
777
-
778
- <item name="implementation-guidelines" mandatory="true">
779
- **[MANDATORY] Implementation Guidelines:**
780
-
781
- - Step-by-step implementation approach following coding standards
782
- - Optimal architectural placement for new code
783
- - Interface design for maximum flexibility
784
- - Dependency management approach (DI registrations)
785
- - State management strategy
786
- - Error handling patterns to follow
787
- - Recommended implementation order
788
- </item>
789
-
790
- <item name="testing-strategy" mandatory="true">
791
- **[MANDATORY] Testing Strategy:**
792
-
793
- - How to test without breaking existing tests
794
- - Test patterns to follow (from testing framework doc)
795
- - Required test types (unit, integration, e2e)
796
- - Mocking strategies based on existing patterns
797
- - Edge cases to cover from acceptance criteria
798
- - Test data patterns to follow
799
- </item>
800
-
801
- <item name="risk-mitigation" mandatory="true">
802
- **[MANDATORY] Risk Mitigation:**
803
-
804
- - Backward compatibility considerations
805
- - Migration path for existing functionality
806
- - What existing functionality might be impacted
807
- - Performance implications
808
- - Breaking change risks
809
- - Rollback strategies if needed
810
- </item>
811
- </phase>
812
-
813
- <phase name="ai-context" order="4">
814
- &lt;!-- ALL 2 items are MANDATORY --&gt;
815
-
816
- <item name="complete-findings" mandatory="true">
817
- **[MANDATORY] Complete Analysis Findings:**
818
-
819
- Include ALL findings from the deep analysis:
820
- - Every discovered pattern with file references
821
- - Every relevant code snippet
822
- - Every architectural decision
823
- - Every potential issue
824
- - Every integration consideration
825
-
826
- CRITICAL REQUIREMENT: This analysis output will be used as PROMPT CONTEXT
827
- for the AI agent implementing this feature. Therefore:
828
- - INCLUDE ALL FINDINGS — don't summarize or omit details
829
- - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
830
- - BE EXPLICIT — don't assume the implementing AI will know anything not stated
831
- </item>
832
-
833
- <item name="implementation-references" mandatory="true">
834
- **[MANDATORY] Implementation References:**
835
-
836
- - **Internal Documentation**: All relevant internal docs with full paths,
837
- including architecture diagrams and ADRs
838
- - **Code References**: All files to study before implementation,
839
- specific functions/classes as examples, utility functions to reuse
840
- - **Design Patterns &amp; Best Practices**: Links to pattern documentation
841
- (e.g., https://refactoring.guru/design-patterns/strategy)
842
- - **External Resources**: Official docs for libraries used, best practice guides
843
- - **Domain Knowledge**: All naming conventions, error handling patterns,
844
- logging standards, performance considerations
845
- </item>
846
- </phase>
847
-
848
- </analysis-process>
849
-
850
- <validation-checklist>
851
- &lt;!-- Mark each item as complete before finishing.
852
- Total: 22 mandatory items — DO NOT PROCEED until ALL are verified.
853
-
854
- COMMON MISTAKE PREVENTION:
855
- - Tree structures must show ACTUAL current files, not placeholders
856
- - Refactoring analysis is required even if conclusion is "no refactoring needed"
857
- - Integration points must reference actual existing code with file paths
858
- - Testing strategy must ensure existing tests continue to pass
859
- - Hardcoded values section MUST have actual code snippets, not descriptions
860
- - All output goes ONLY to the analysis file — NO GitHub updates --&gt;
861
-
862
- <category name="file-creation">
863
- <check>[MANDATORY] Analysis file created at story-directory/integration-analysis.md</check>
864
- <check>[MANDATORY] Story directory created if it didn't exist</check>
865
- <check>[MANDATORY] File contains all required sections from template</check>
866
- </category>
867
-
868
- <category name="core-analysis">
869
- <check>[MANDATORY] Tree structure showing current codebase structure</check>
870
- <check>[MANDATORY] Tree structure showing proposed changes with new files</check>
871
- <check>[MANDATORY] Architecture compatibility analysis completed (layer-by-layer)</check>
872
- <check>[MANDATORY] All existing patterns identified with file references</check>
873
- <check>[MANDATORY] Integration points clearly documented</check>
874
- <check>[MANDATORY] Impact analysis showing affected components</check>
875
- </category>
876
-
877
- <category name="architecture">
878
- <check>[MANDATORY] Clean Architecture compliance verified</check>
879
- <check>[MANDATORY] Dependency injection strategy documented</check>
880
- <check>[MANDATORY] Design patterns identified and documented</check>
881
- <check>[MANDATORY] Coding standards compliance verified</check>
882
- <check>[MANDATORY] Testing strategy that preserves existing tests</check>
883
- </category>
884
-
885
- <category name="hardcoded-values-critical">
886
- <check>[MANDATORY &amp; CRITICAL] Searched for hardcoded domain/range values</check>
887
- <check>[MANDATORY &amp; CRITICAL] Searched for placeholder/TODO comments related to the feature</check>
888
- <check>[MANDATORY &amp; CRITICAL] Identified ALL renderers/handlers that should use new entity but don't</check>
889
- <check>[MANDATORY &amp; CRITICAL] Identified ALL manager/service classes with hardcoded defaults</check>
890
- <check>[MANDATORY &amp; CRITICAL] Found disconnected wiring (entity exists but not injected where needed)</check>
891
- <check>[MANDATORY &amp; CRITICAL] Section 5 filled with ACTUAL CODE SNIPPETS (not placeholders!)</check>
892
- <check>[MANDATORY &amp; CRITICAL] Every hardcoded value includes: file path, line number, current code, fix required</check>
893
- </category>
894
- </validation-checklist>
895
-
896
- <guidelines>
897
-
898
- <guideline name="accuracy-first">
899
- NO ASSUMPTIONS are tolerated. The analysis must reflect 100% accurate code.
900
- Only document what you actually find in the code. Never infer behavior
901
- that isn't explicitly implemented. Every claim must be traceable to
902
- actual code references with file paths and line numbers.
903
- </guideline>
904
-
905
- <guideline name="story-scope">
906
- Focus exclusively on code paths related to the story.
907
- Do NOT document the entire codebase — only files, functions,
908
- and constants that are directly involved in implementing the story's
909
- functionality as defined by its acceptance criteria.
910
- </guideline>
911
-
912
- <guideline name="coding-standards-first">
913
- STRONG EMPHASIS ON CODING STANDARDS — NO EXCEPTIONS!
914
- Every proposed change, new file, and integration point must be verified
915
- against the project's coding standards (from wiki system-wide docs).
916
- Standards compliance is not optional — it is the primary quality gate.
917
- </guideline>
918
-
919
- <guideline name="code-level-depth">
920
- This is a DEEP TECHNICAL ANALYSIS, not a summary:
921
- - ACTUAL CODE SNIPPETS must be included, not descriptions
922
- - COMPLETE FILE PATHS WITH LINE NUMBERS for every reference
923
- - EXACT INTEGRATION POINTS with specific method signatures
924
- - NO HIGH-LEVEL SUMMARIES — only detailed, code-level analysis
925
-
926
- This output will be used as the PRIMARY TECHNICAL REFERENCE for
927
- implementing this story. Without complete code-level detail, the
928
- analysis is USELESS.
929
- </guideline>
930
-
931
- <guideline name="thoroughness">
932
- THOROUGH &amp; COMPREHENSIVE: Cover every aspect of the integration.
933
- 100% SUBSTANTIVE: Only include relevant, actionable information.
934
- TAKE ALL TIME NEEDED: Read EVERY line of relevant code.
935
- ACCURACY IS PARAMOUNT: This will guide the implementation.
936
- </guideline>
937
-
938
- <guideline name="hardcoded-values-critical">
939
- The hardcoded values discovery is the MOST IMPORTANT section.
940
- THE #1 REASON INTEGRATION ANALYSES FAIL is identifying what NEW code
941
- to create but FAILING to identify what EXISTING code must be MODIFIED.
942
-
943
- For EVERY new entity/service being created:
944
- 1. "What existing code currently does this job (probably poorly/hardcoded)?"
945
- 2. "Where should this entity be INJECTED that it currently ISN'T?"
946
- 3. "What hardcoded values exist that this entity should REPLACE?"
947
-
948
- This section MUST contain ACTUAL CODE SNIPPETS with file paths and line numbers.
949
- </guideline>
950
-
951
- <guideline name="wiki-as-context">
952
- Wiki documents are the SINGLE SOURCE of codebase knowledge.
953
- They replace all obsolete separate parameters (sourcecode, high-level-architecture,
954
- documentation, related-stories-implementations, documented-features).
955
- Read ALL wiki documents referenced in the story's Relevant Wiki section.
956
- </guideline>
957
-
958
- <guideline name="no-github-updates">
959
- All output is written ONLY to the integration-analysis.md file.
960
- NO GitHub updates, NO modifications to the story file.
961
- This is a standalone artifact consumed by pass 5 (technical solution).
962
- </guideline>
963
-
964
- <guideline name="github-compatibility">
965
- The analysis document must render cleanly in GitHub markdown viewers.
966
- - Use markdown tables (no HTML tables)
967
- - No custom CSS or HTML styling
968
- - Code blocks with language hints for syntax highlighting
969
- - YAML blocks for structured data (hardcoded values, wiring)
970
- </guideline>
971
-
972
- <guideline name="refactoring-always-addressed">
973
- The refactoring section MUST be completed even if the conclusion is
974
- "no refactoring required." The analysis must explicitly state whether
975
- refactoring is needed and provide justification either way.
976
- </guideline>
977
-
978
- <guideline name="common-mistakes">
979
- Common mistakes to avoid:
980
- - Tree structures must show ACTUAL current files, not placeholders
981
- - Refactoring analysis is required even if "no refactoring needed"
982
- - Integration points must reference actual existing code with file paths
983
- - Testing strategy must ensure existing tests continue to pass
984
- - Hardcoded values section MUST have actual code snippets
985
- - Don't identify only NEW code — also identify what EXISTING code must CHANGE
986
- - Don't miss disconnected wiring (entities that exist but aren't injected)
987
- </guideline>
988
-
989
- </guidelines>
990
-
991
- <evolution>
992
-
993
- **Creation (research-integration-solution — pass 4):**
994
- This is pass 4 of the story specification pipeline.
995
- A single run produces the complete integration-analysis.md document.
996
- All sections must be filled, all checklist items verified.
997
-
998
- **Consumption (story-technical-solution — pass 5):**
999
- The integration-analysis.md is consumed as input by pass 5 (technical solution).
1000
- The technical solution uses insights from this analysis to design the
1001
- implementation approach — file changes, integration points, refactoring,
1002
- hardcoded values to replace, testing strategy.
1003
-
1004
- **Re-analysis (exception, not norm):**
1005
- Only when the story scope changes significantly or the codebase changes
1006
- substantially. Re-running overwrites the existing analysis.
1007
-
1008
- **This analysis does NOT modify the story file.**
1009
- It lives as a separate artifact in the story directory.
1010
- The story.xml template has no sections that reference this analysis directly.
1011
- Only the technical solution (pass 5) consumes it.
1012
-
1013
- </evolution>
1014
-
1015
- </integration-solution>
1
+ <integration-solution>
2
+
3
+ <purpose>
4
+ Template for `.ace/artifacts/product/&lt;id-epic_name&gt;/&lt;id-feature_name&gt;/&lt;id-story_name&gt;/integration-analysis.md` —
5
+ a COMPREHENSIVE, IN-DEPTH System Integration Analysis that ensures new story
6
+ implementations integrate seamlessly with existing systems without breaking
7
+ functionality or violating architectural principles.
8
+
9
+ This is pass 4 of the story specification pipeline (see story.xml composition).
10
+ It produces a separate artifact in the story directory — NOT appended to the story file.
11
+ The analysis is consumed by pass 5 (technical solution) as input for designing
12
+ the implementation approach with full codebase integration context.
13
+
14
+ **[MANDATORY]** Identify how a new story would PROPERLY integrate with the existing
15
+ codebase while maintaining architectural integrity, maintainability, and extensibility
16
+ while strictly following CODING STANDARDS.
17
+
18
+ You are operating within a PRODUCTION-GRADE, CLEAN, COMPLEX CODEBASE — new code
19
+ must be added thoughtfully and systematically. The purpose is to analyze HOW TO ADD
20
+ NEW FUNCTIONALITY WHILE KEEPING THE CODE MAINTAINABLE AND EXTENSIBLE.
21
+
22
+ This document does NOT modify the story file. It lives as a separate artifact
23
+ in the story directory. Only the technical solution (pass 5) consumes it.
24
+
25
+ CRITICAL: This analysis output will be used as PROMPT CONTEXT for the AI agent
26
+ implementing this feature. Therefore:
27
+ - INCLUDE ALL FINDINGS — don't summarize or omit details
28
+ - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
29
+ - BE EXPLICIT — don't assume the implementing AI will know anything not explicitly stated
30
+ </purpose>
31
+
32
+ <output-format>
33
+
34
+ <section name="header">
35
+ # System Integration Analysis: [Story Name]
36
+
37
+ ## Analysis Context
38
+ - **Story**: [Story ID] — [Story Title]
39
+ - **Feature**: [Feature ID] — [Feature Title]
40
+ - **Epic**: [Epic ID] — [Epic Title]
41
+ - **Analysis Date**: [Current date]
42
+ - **Wiki Documents Loaded**: [N] files
43
+ - **External Analysis**: [Available/Not available]
44
+ - **Code References**: [N] references documented
45
+ - **Hardcoded Values Found**: [N] items
46
+ - **Refactoring Items**: [N] items
47
+ </section>
48
+
49
+ <section name="use-case-overview">
50
+ ## 1. Use Case Overview
51
+
52
+ [Brief description of what needs to be implemented — extracted from the story's
53
+ User Story statement, Description, and Acceptance Criteria.
54
+
55
+ Include:
56
+ - What the user can do when this story is done
57
+ - Key behaviors and requirements from acceptance criteria
58
+ - How this story relates to other stories in the feature
59
+ - What the parent feature context provides]
60
+ </section>
61
+
62
+ <section name="architecture-compatibility">
63
+ ## 2. Architecture Compatibility
64
+
65
+ &lt;!-- How this story fits into the Clean Architecture layers.
66
+ For EACH layer, document what new components are needed
67
+ and how they integrate with existing components. --&gt;
68
+
69
+ ### Domain Layer
70
+ &lt;!-- New entities, value objects, constants, business rules needed.
71
+ How they relate to existing domain objects.
72
+ Domain events that may be needed.
73
+ File paths to relevant existing domain code. --&gt;
74
+ - **New Entities**: [entities to create with proposed file paths]
75
+ - **Value Objects**: [value objects needed]
76
+ - **Constants**: [new constants or extensions to existing constant files]
77
+ - **Business Rules**: [domain rules this story introduces]
78
+ - **Existing Domain Code**: [relevant existing domain files with paths]
79
+
80
+ ### Application Layer
81
+ &lt;!-- Use cases, interfaces, DTOs to create.
82
+ How they interact with existing application services.
83
+ Dependency injection registrations needed. --&gt;
84
+ - **Use Cases**: [use cases to create]
85
+ - **Interfaces**: [interfaces to define or extend]
86
+ - **DTOs**: [data transfer objects needed]
87
+ - **Existing Services**: [application services that will be affected]
88
+
89
+ ### Infrastructure Layer
90
+ &lt;!-- Services, implementations, repositories required.
91
+ External service integrations.
92
+ How they implement application layer interfaces. --&gt;
93
+ - **Services**: [infrastructure services to implement]
94
+ - **Implementations**: [interface implementations needed]
95
+ - **Repositories**: [data access patterns to follow]
96
+ - **Existing Infrastructure**: [existing infrastructure code affected]
97
+
98
+ ### Presentation Layer
99
+ &lt;!-- UI components, API endpoints, view models needed.
100
+ How they connect to application layer.
101
+ User interaction patterns to follow. --&gt;
102
+ - **Components**: [UI components or API endpoints needed]
103
+ - **View Models**: [presentation models needed]
104
+ - **Existing Presentation Code**: [existing presentation code affected]
105
+
106
+ ### Dependency Rule Compliance
107
+ &lt;!-- Verify that all proposed changes maintain the dependency rule:
108
+ dependencies point inward (Presentation → Application → Domain).
109
+ Infrastructure implements Application interfaces.
110
+ No layer knows about outer layers. --&gt;
111
+ - [Compliance verification for each proposed change]
112
+ </section>
113
+
114
+ <section name="existing-patterns">
115
+ ## 3. Existing Patterns to Follow
116
+
117
+ &lt;!-- Specific patterns found in the codebase that this story MUST follow.
118
+ Each pattern includes file references with line numbers.
119
+ The implementing agent must study these files before coding. --&gt;
120
+
121
+ ### Similar Implementations
122
+ &lt;!-- Reference existing code that implements similar functionality.
123
+ The new implementation should follow these as examples. --&gt;
124
+ - **[Implementation Name]** at `[file:line-range]` — [what to learn from it]
125
+
126
+ ### Established Conventions
127
+ &lt;!-- Naming patterns, file organization, code structure conventions. --&gt;
128
+ - **Naming**: [naming conventions with examples from codebase]
129
+ - **File Organization**: [how files are organized with examples]
130
+ - **Code Structure**: [class/function structure patterns]
131
+
132
+ ### Design Patterns in Use
133
+ &lt;!-- Which design patterns are already used that must be followed. --&gt;
134
+
135
+ #### [Pattern Name] (e.g., Strategy, Factory, Observer)
136
+ - **Where**: [File/component where pattern is used — with path]
137
+ - **Why**: [Why this pattern was chosen]
138
+ - **Implementation Example**:
139
+ ```typescript
140
+ // From [file:line-range]
141
+ [Code example showing the pattern]
142
+ ```
143
+ - **How to Follow**: [How the new code should use this pattern]
144
+
145
+ &lt;!-- Repeat for each identified pattern --&gt;
146
+
147
+ ### Error Handling Patterns
148
+ - [How errors are handled — with code references]
149
+
150
+ ### Logging Patterns
151
+ - [How logging is done — with code references]
152
+
153
+ ### Constants &amp; Configuration Patterns
154
+ - [How constants are organized — with code references]
155
+ - [Where to add new constants]
156
+ </section>
157
+
158
+ <section name="required-refactoring">
159
+ ## 4. Required Refactoring
160
+
161
+ &lt;!-- List any existing code that needs refactoring to support the new implementation.
162
+ Include justification for each refactoring decision.
163
+ Impact assessment of changes.
164
+ Even if no refactoring is needed, complete this section with that conclusion. --&gt;
165
+
166
+ ### Refactoring Items
167
+
168
+ &lt;!-- For each item:
169
+ - What code needs to change (file path, line numbers)
170
+ - Current state (what it is now)
171
+ - Proposed change (what it should become)
172
+ - Justification (why this refactoring is needed)
173
+ - Impact (what else is affected by this change)
174
+
175
+ Common scenarios:
176
+ - Pattern violations: Direct implementations that should use Strategy/Factory
177
+ - Constants chaos: Magic strings/numbers that should be centralized
178
+ - Model proliferation: Duplicate models that should be unified
179
+ - Method duplication: Duplicate logic that should be extracted
180
+ - Layer violations: Business logic in wrong architectural layer
181
+ - Service sprawl: Services that should be extended vs. duplicated
182
+ - Event handler inconsistencies: Inconsistent event handling patterns
183
+ - State management violations: State managed inconsistently
184
+ - API integration inconsistencies: Direct API calls instead of services
185
+ - Type definition duplication: Redefined types that should be imported --&gt;
186
+
187
+ #### [Refactoring Item Name]
188
+ - **File**: `[file:line-range]`
189
+ - **Current State**: [what it is now]
190
+ - **Proposed Change**: [what it should become]
191
+ - **Justification**: [why this is needed for the new implementation]
192
+ - **Impact**: [what else is affected]
193
+
194
+ &lt;!-- Repeat for each refactoring item.
195
+ If no refactoring needed, state: "No refactoring required. [justification]." --&gt;
196
+ </section>
197
+
198
+ <section name="hardcoded-values-critical">
199
+ ## 5. CRITICAL: Hardcoded Values &amp; Placeholder Code That MUST Be Replaced
200
+
201
+ &lt;!-- THIS IS THE MOST CRITICAL SECTION OF THE INTEGRATION ANALYSIS!
202
+
203
+ THE #1 REASON INTEGRATION ANALYSES FAIL:
204
+ The analysis identifies what NEW code to create but FAILS to identify
205
+ what EXISTING code must be MODIFIED or REPLACED.
206
+
207
+ For every new entity/service being created, ask:
208
+ - "What existing code currently does this job (probably poorly/hardcoded)?"
209
+ - "Where should this entity be INJECTED that it currently ISN'T?"
210
+ - "What hardcoded values exist that this entity should REPLACE?"
211
+
212
+ MANDATORY SEARCHES:
213
+ - Hardcoded numeric ranges, dimensions, colors, sizes
214
+ - TODO comments mentioning the feature
215
+ - "temporary", "placeholder", "stub", "mock" in comments
216
+ - Methods returning hardcoded values instead of computed ones
217
+ - Classes/services that exist but aren't used where they should be
218
+ - Inline calculations that should use the new service
219
+ - Manager/Service classes with hardcoded defaults
220
+ - Renderers/handlers not using the new entity
221
+
222
+ This section MUST be filled with ACTUAL CODE SNIPPETS from the codebase!
223
+ The implementing AI agent NEEDS to know EXACTLY what to change and WHERE. --&gt;
224
+
225
+ ### Hardcoded Values to Replace
226
+
227
+ ```yaml
228
+ FILE: [exact file path]
229
+ LINE: [line number(s)]
230
+ CURRENT CODE: |
231
+ [actual code snippet from the file]
232
+ PROBLEM: [why this is wrong]
233
+ SHOULD BE: [what it should become after implementation]
234
+ FIX REQUIRED: [specific action to take]
235
+ ```
236
+
237
+ &lt;!-- Repeat for EACH hardcoded value found --&gt;
238
+
239
+ ### Disconnected Wiring to Fix
240
+
241
+ ```yaml
242
+ ENTITY/SERVICE EXISTS: [path to entity/service that should be used]
243
+ CURRENTLY NOT CONNECTED TO:
244
+ - [File 1]: [what it uses instead]
245
+ - [File 2]: [what it uses instead]
246
+ REQUIRED CONNECTIONS:
247
+ - [Where to inject and how]
248
+ ```
249
+
250
+ &lt;!-- Repeat for EACH disconnected wiring found --&gt;
251
+
252
+ ### Placeholder/TODO Code to Implement
253
+
254
+ ```yaml
255
+ FILE: [file path]
256
+ LINE: [line number]
257
+ TODO COMMENT: "[exact TODO text]"
258
+ CURRENT IMPLEMENTATION: [what it does now — probably hardcoded]
259
+ REQUIRED IMPLEMENTATION: [what needs to be implemented]
260
+ ```
261
+
262
+ &lt;!-- Repeat for EACH placeholder found --&gt;
263
+
264
+ ### Renderers/Services Not Using New Entity
265
+
266
+ ```yaml
267
+ NEW ENTITY: [entity name and path]
268
+ RENDERERS/HANDLERS THAT MUST USE IT:
269
+ - [Renderer/Handler 1]: Currently uses [X], must use [new entity]
270
+ - [Renderer/Handler 2]: Currently uses [X], must use [new entity]
271
+ SERVICES THAT MUST USE IT:
272
+ - [Service 1]: Currently [behavior], must [new behavior]
273
+ ```
274
+
275
+ &lt;!-- Repeat for EACH new entity --&gt;
276
+ </section>
277
+
278
+ <section name="integration-points">
279
+ ## 6. Integration Points
280
+
281
+ &lt;!-- All touchpoints between the new implementation and the existing system.
282
+ Categorize by architectural layer and component type. --&gt;
283
+
284
+ ### Domain Layer Integration
285
+ - [Integration point — how the new domain code connects with existing domain]
286
+
287
+ ### Application Layer Integration
288
+ - [Integration point — new use cases, service interfaces, DI registrations]
289
+
290
+ ### Infrastructure Layer Integration
291
+ - [Integration point — new service implementations, repository patterns]
292
+
293
+ ### Presentation Layer Integration
294
+ - [Integration point — new UI components, API endpoints, event handlers]
295
+
296
+ ### Cross-Cutting Integration
297
+ &lt;!-- Event systems, middleware, DI container, logging, error handling --&gt;
298
+ - [Integration point — cross-cutting concerns this story must respect]
299
+ </section>
300
+
301
+ <section name="impact-analysis">
302
+ ## 7. Impact Analysis
303
+
304
+ &lt;!-- ALL code flows that might be impacted by the new implementation.
305
+ Include specific file references for each impacted flow. --&gt;
306
+
307
+ ### Affected Code Flows
308
+ - **[Flow Name]**: [description of impact] — `[file:line-range]`
309
+
310
+ ### Affected Tests
311
+ &lt;!-- Tests that may need modification due to the new implementation --&gt;
312
+ - `[test-file:line-range]` — [what needs to change and why]
313
+
314
+ ### Affected Documentation
315
+ &lt;!-- Documentation files/wiki docs that may need updates --&gt;
316
+ - `[doc-file]` — [what needs updating]
317
+
318
+ ### Performance Implications
319
+ - [Performance consideration — with mitigation strategy]
320
+
321
+ ### Breaking Change Risks
322
+ - [Risk — with mitigation strategy]
323
+ </section>
324
+
325
+ <section name="codebase-tree">
326
+ ## 8. Codebase Structure
327
+
328
+ ### Current Structure (Relevant Files)
329
+ &lt;!-- Tree structure showing ACTUAL current files relevant to this story.
330
+ NOT the entire codebase — only files that are involved.
331
+ Include file paths and one-line purpose. --&gt;
332
+
333
+ ```
334
+ [Current relevant file tree]
335
+ ```
336
+
337
+ ### Proposed Structure (With New Files)
338
+ &lt;!-- Tree structure showing what the codebase will look like
339
+ after implementing this story. Mark new files clearly. --&gt;
340
+
341
+ ```
342
+ [Proposed file tree with new files marked]
343
+ ```
344
+ </section>
345
+
346
+ <section name="implementation-guidelines">
347
+ ## 9. Implementation Guidelines
348
+
349
+ &lt;!-- Step-by-step approach following coding standards.
350
+ The implementing agent should follow this order. --&gt;
351
+
352
+ ### Recommended Implementation Order
353
+
354
+ 1. **[Step 1]**: [What to implement first and why]
355
+ - Files to create/modify: [list]
356
+ - Pattern to follow: [reference to existing pattern]
357
+
358
+ 2. **[Step 2]**: [What to implement next]
359
+ - Files to create/modify: [list]
360
+ - Pattern to follow: [reference]
361
+
362
+ &lt;!-- Continue for all implementation steps --&gt;
363
+
364
+ ### Dependency Management
365
+ - [How to manage dependencies — DI registrations, imports, etc.]
366
+
367
+ ### Error Handling Approach
368
+ - [Error handling strategy for the new implementation]
369
+
370
+ ### State Management Strategy
371
+ - [How state should be managed in the new implementation]
372
+ </section>
373
+
374
+ <section name="testing-strategy">
375
+ ## 10. Testing Strategy
376
+
377
+ &lt;!-- How to test without breaking existing tests.
378
+ Follow the testing framework patterns from wiki. --&gt;
379
+
380
+ ### Test Types Required
381
+ - **Unit Tests**: [what to unit test, mocking strategy]
382
+ - **Integration Tests**: [what integration scenarios to cover]
383
+ - **E2E Tests**: [end-to-end scenarios if applicable]
384
+
385
+ ### Existing Test Patterns to Follow
386
+ - [Pattern 1 — with reference to existing test file]
387
+ - [Pattern 2 — with reference to existing test file]
388
+
389
+ ### Test Data Patterns
390
+ - [How test data is managed in existing tests]
391
+
392
+ ### Ensuring Existing Tests Pass
393
+ - [Steps to verify existing tests still pass after changes]
394
+ - [Tests that may need adjustment and why]
395
+ </section>
396
+
397
+ <section name="complete-findings">
398
+ ## 11. Complete Analysis Findings
399
+
400
+ &lt;!-- INCLUDE ALL FINDINGS from the deep analysis.
401
+ This is the comprehensive dump of everything discovered.
402
+ The implementing AI needs every piece of information.
403
+
404
+ Include:
405
+ - Every discovered pattern with file references
406
+ - Every relevant code snippet
407
+ - Every architectural decision
408
+ - Every potential issue
409
+ - Every integration consideration --&gt;
410
+
411
+ ### Discovered Patterns
412
+ - [Pattern — file reference — relevance to this story]
413
+
414
+ ### Relevant Code Snippets
415
+ ```typescript
416
+ // From [file:line-range]
417
+ // [Why this snippet is relevant]
418
+ [actual code]
419
+ ```
420
+
421
+ ### Architectural Constraints
422
+ - [Constraint — source (coding standards, ADR, etc.) — impact on implementation]
423
+
424
+ ### Potential Issues
425
+ - [Issue — likelihood — mitigation]
426
+ </section>
427
+
428
+ <section name="implementation-references">
429
+ ## 12. Implementation References
430
+
431
+ ### Internal Documentation
432
+ &lt;!-- All relevant internal docs with full paths --&gt;
433
+ - `[path]` — [what to learn from this doc]
434
+
435
+ ### Code References
436
+ &lt;!-- All files that should be studied before implementation --&gt;
437
+ - `[file:line-range]` — [what to learn from this code]
438
+
439
+ ### Design Patterns &amp; Best Practices
440
+ &lt;!-- Links to pattern documentation --&gt;
441
+ - [Pattern Name] — [link to documentation, e.g., refactoring.guru]
442
+
443
+ ### External Resources
444
+ &lt;!-- Official documentation links for libraries used --&gt;
445
+ - [Resource] — [link]
446
+ </section>
447
+
448
+ <section name="ai-implementation-context">
449
+ ## 13. AI Implementation Context
450
+
451
+ &lt;!-- CRITICAL SECTION — This will be the primary context for the implementing AI.
452
+ Everything the implementing agent needs to know in one place. --&gt;
453
+
454
+ ### Domain Knowledge
455
+ - [All domain-specific knowledge the implementing agent needs]
456
+
457
+ ### Constraints &amp; Limitations
458
+ - [All constraints from coding standards, architecture, ADRs]
459
+
460
+ ### Naming Conventions
461
+ - [All naming conventions observed in the codebase with examples]
462
+
463
+ ### Error Handling Standards
464
+ - [Error handling patterns with code references]
465
+
466
+ ### Logging Standards
467
+ - [Logging approach with code references]
468
+
469
+ ### Performance Considerations
470
+ - [Performance requirements and optimization approaches]
471
+
472
+ ### Example Code Snippets
473
+ &lt;!-- Code snippets from similar implementations that serve as templates --&gt;
474
+ ```typescript
475
+ // From [file:line-range]
476
+ // [This serves as a template for implementing [component]]
477
+ [actual code from similar implementation]
478
+ ```
479
+ </section>
480
+
481
+ </output-format>
482
+
483
+ <analysis-process>
484
+
485
+ &lt;!-- This section defines the analysis methodology that the code-integration-analyst
486
+ agent must follow. It mirrors the workflow steps but provides detailed
487
+ instructions for each analysis phase.
488
+
489
+ MANDATORY COMPLETION REQUIREMENTS:
490
+ - Phase 1: ALL 4 items (Context Loading) — MANDATORY
491
+ - Phase 2: ALL 8 items (Deep Codebase Analysis) — MANDATORY
492
+ - Phase 3: ALL 4 items (Refactoring &amp; Strategy) — MANDATORY
493
+ - Phase 4: ALL 2 items (AI Implementation Context) — MANDATORY
494
+ - Total: 18 mandatory analysis items — SKIP NONE --&gt;
495
+
496
+ <phase name="context-loading" order="1">
497
+ &lt;!-- ALL 4 items are MANDATORY --&gt;
498
+
499
+ <item name="understand-story" mandatory="true">
500
+ **[MANDATORY] Understand the story requirements:**
501
+ - Read the story thoroughly: User Story, Description, all AC scenarios
502
+ - These define WHAT functionality needs to integrate into the codebase
503
+ - Extract key behaviors, components, and patterns needed
504
+ - The story's acceptance criteria define the SCOPE of the analysis
505
+ - **Requirements come from the story** — do NOT seek requirements
506
+ from other sources. The story IS the source of truth.
507
+ - If a parent feature document is available, read it to understand:
508
+ - The broader feature context
509
+ - What other stories exist and how they relate
510
+ - Dependencies and shared components between stories
511
+ </item>
512
+
513
+ <item name="load-wiki-documents" mandatory="true">
514
+ **[MANDATORY] Load and study ALL wiki documents from the story's Relevant Wiki section:**
515
+
516
+ These wiki documents provide the COMPLETE codebase context:
517
+
518
+ - **System-Wide** (always present):
519
+ - `system-structure.md` — High-level codebase tree and organization
520
+ - `system-architecture.md` — Complete architectural overview
521
+ - `coding-standards.md` — CRITICAL: coding standards — NO EXCEPTIONS!
522
+ - `testing-framework.md` — Testing patterns and frameworks
523
+
524
+ - **Subsystem Documents** (as referenced by story):
525
+ - **Systems**: System descriptions, boundaries, APIs
526
+ - **Patterns**: Design patterns in use with examples
527
+ - **Cross-Cutting Concerns**: Shared concerns (auth, logging, errors, etc.)
528
+ - **Guides**: How-to guides for common implementation tasks
529
+ - **Walkthroughs**: Deep tutorial-style flow explanations with actual code snippets
530
+ - **Decisions (ADRs)**: Architecture decisions that constrain design
531
+ - **Architecture**: Subsystem architecture documents
532
+
533
+ Read EVERY document. These replace the obsolete command's separate parameters:
534
+ - sourcecode → system-structure.md (high-level tree)
535
+ - high-level-architecture → system-architecture.md
536
+ - documentation → all wiki documents combined
537
+ - related-stories-implementations → wiki documents capture story knowledge
538
+ - documented-features → wiki documents catalog feature implementations
539
+ </item>
540
+
541
+ <item name="load-external-analysis" mandatory="true">
542
+ **[MANDATORY] Check and load external analysis if available:**
543
+ - Automatically check for `{STORY_DIR}/external-analysis.md`
544
+ - This is the artifact from pass 3 (`/ace:research-external-solution`)
545
+ - If present, study it for:
546
+ - How industry-standard systems implement this functionality
547
+ - Algorithms and formulas to reuse
548
+ - Design patterns from external implementations
549
+ - Best practices that should inform our integration
550
+ - If not present, proceed without — note this in the analysis
551
+ </item>
552
+
553
+ <item name="load-feature-document" mandatory="true">
554
+ **[MANDATORY] Load the parent feature document:**
555
+ - The feature file path can be extracted from the story metadata
556
+ - Understand the feature planning context
557
+ - Identify how this story fits within the broader feature
558
+ - Identify dependencies and integration points with other stories
559
+ - If not found, proceed without — the analysis can still be done
560
+ </item>
561
+ </phase>
562
+
563
+ <phase name="deep-codebase-analysis" order="2">
564
+ &lt;!-- ALL 8 items are MANDATORY — skip NONE --&gt;
565
+
566
+ <item name="architecture-compatibility" mandatory="true">
567
+ **[MANDATORY] Architecture Compatibility Analysis:**
568
+
569
+ Map how the new story fits into Clean Architecture layers:
570
+
571
+ - **Domain Layer**: New entities, value objects, constants needed.
572
+ How they relate to existing domain objects. Domain events needed.
573
+ - **Application Layer**: Use cases and interfaces to create.
574
+ How they interact with existing application services. DI registrations.
575
+ - **Infrastructure Layer**: Services and implementations required.
576
+ External service integrations. How they implement application interfaces.
577
+ - **Presentation Layer**: UI components and API endpoints needed.
578
+ How they connect to application layer. User interaction patterns.
579
+
580
+ Verify Clean Architecture compliance:
581
+ - Dependencies point inward toward domain
582
+ - Each layer knows only about inner layers
583
+ - Depend on abstractions, not concretions
584
+ - All business logic independently testable
585
+ </item>
586
+
587
+ <item name="pattern-recognition" mandatory="true">
588
+ **[MANDATORY] Pattern Recognition &amp; Existing Patterns:**
589
+
590
+ Search for similar features/patterns in the codebase and reference them
591
+ with specific file paths and line numbers:
592
+
593
+ - **Similar Implementations**: Find existing code that does something similar
594
+ - **Naming Conventions**: Document exact naming patterns with examples
595
+ - **Design Patterns**: Catalog patterns in use (Strategy, Factory, Observer, etc.)
596
+ - **Error Handling**: Document error handling approaches with code references
597
+ - **Logging**: Document logging approaches
598
+ - **Constants Organization**: How constants are organized and where to add new ones
599
+ </item>
600
+
601
+ <item name="integration-points" mandatory="true">
602
+ **[MANDATORY] Integration Point Discovery (Layer-by-Layer):**
603
+
604
+ Examine each architectural layer for integration opportunities:
605
+
606
+ - **Domain Layer**: Entity extensions, value objects, business rules
607
+ - **Application Layer**: Service interfaces, use cases, DTOs
608
+ - **Infrastructure Layer**: Repository patterns, external services
609
+ - **Presentation Layer**: UI components, view models, controllers
610
+
611
+ Find:
612
+ - Existing interfaces that can be extended
613
+ - Abstract classes available for inheritance
614
+ - Event systems for loose coupling
615
+ - Middleware or pipeline patterns
616
+ - Plugin or extension points
617
+ - Configuration-based feature toggles
618
+ - DI container registrations needed
619
+ </item>
620
+
621
+ <item name="file-dependencies" mandatory="true">
622
+ **[MANDATORY] File Dependency Analysis:**
623
+
624
+ - Identify ALL files that will be referenced or modified
625
+ - Document supporting files for the new implementation
626
+ - Map import chains and dependency graphs
627
+ - Identify potential circular dependency risks
628
+ - List all current files that will support the new implementation
629
+ </item>
630
+
631
+ <item name="convention-compliance" mandatory="true">
632
+ **[MANDATORY] Convention Compliance Analysis:**
633
+
634
+ - Document existing conventions that MUST be followed
635
+ - Verify the new implementation doesn't violate CODING STANDARDS
636
+ - Check naming conventions, file organization, error handling
637
+ - Verify SOLID principles compliance
638
+ - Verify Clean Architecture layer boundaries
639
+ </item>
640
+
641
+ <item name="testing-patterns" mandatory="true">
642
+ **[MANDATORY] Testing Pattern Analysis:**
643
+
644
+ - Analyze current test patterns for consistent validation approach
645
+ - Identify test utilities and helpers available for reuse
646
+ - Document testing conventions (unit, integration, e2e)
647
+ - Identify tests that need modification due to the new implementation
648
+ - Extract mocking strategies used
649
+ </item>
650
+
651
+ <item name="hardcoded-values-discovery" mandatory="true">
652
+ **[MANDATORY] CRITICAL: Hardcoded Values &amp; Placeholder Code Discovery:**
653
+
654
+ THIS IS THE MOST CRITICAL PART OF THE INTEGRATION ANALYSIS!
655
+
656
+ When a new story implements a feature, there are ALWAYS existing hardcoded
657
+ values or placeholder implementations that the new feature is MEANT TO REPLACE.
658
+
659
+ YOU MUST EXHAUSTIVELY SEARCH FOR:
660
+
661
+ <search-category name="hardcoded-domain-values">
662
+ **Hardcoded Domain/Range Values:**
663
+ - Search for hardcoded number ranges, dimensions, colors, sizes, offsets
664
+ - Search for values that should come from the new entity/service
665
+ - Grep patterns: `domain\(\[`, `= 0;`, `= 100`, `MIN_`, `MAX_`, `DEFAULT_`
666
+ </search-category>
667
+
668
+ <search-category name="placeholder-stubs">
669
+ **Placeholder/Stub Implementations:**
670
+ - Search for TODO comments mentioning the feature being implemented
671
+ - Search for "temporary", "placeholder", "stub", "mock" in comments
672
+ - Search for methods returning hardcoded values instead of computed ones
673
+ - Grep patterns: `TODO`, `TEMPORARY`, `placeholder`, `HARDCODED`
674
+ </search-category>
675
+
676
+ <search-category name="disconnected-wiring">
677
+ **Disconnected Wiring:**
678
+ - Classes/services that EXIST but are NOT USED where they should be
679
+ - Find where the NEW entity/service SHOULD be injected but currently isn't
680
+ - For every new entity/service, ask:
681
+ - "What existing code currently does this job?"
682
+ - "Where should this entity be INJECTED?"
683
+ - "What hardcoded values exist that this entity should REPLACE?"
684
+ </search-category>
685
+
686
+ <search-category name="inline-calculations">
687
+ **Inline Calculations That Should Use New Service:**
688
+ - Inline calculations done manually instead of using the new entity
689
+ - Duplicate calculation logic across multiple files
690
+ - Grep patterns: `Math.min`, `Math.max`, inline formulas
691
+ </search-category>
692
+
693
+ <search-category name="manager-service-defaults">
694
+ **Manager/Service Classes with Hardcoded Defaults:**
695
+ - Manager/service classes initializing with dummy values
696
+ - These MUST be updated to receive values from the new entity
697
+ - Search: `*Manager`, `*Service` classes in Infrastructure layer
698
+ </search-category>
699
+
700
+ <search-category name="renderers-not-using-entity">
701
+ **Renderers/Handlers Not Using New Entity:**
702
+ - When implementing a new feature, ALL relevant renderers/handlers must be checked
703
+ - Verify they use the new entity instead of hardcoded values
704
+ - Search: `*Renderer`, `*Handler`, `*Controller` classes
705
+ </search-category>
706
+
707
+ Output format for EACH discovered item:
708
+ ```yaml
709
+ FILE: [exact file path]
710
+ LINE: [line number(s)]
711
+ CURRENT CODE: |
712
+ [actual code snippet from the file]
713
+ PROBLEM: [why this is wrong]
714
+ SHOULD BE: [what it should become after implementation]
715
+ FIX REQUIRED: [specific action to take]
716
+ ```
717
+
718
+ CRITICAL: This section MUST be filled with ACTUAL CODE SNIPPETS from the codebase!
719
+ The implementing AI agent NEEDS to know EXACTLY what to change and WHERE.
720
+ </item>
721
+
722
+ <item name="impact-analysis" mandatory="true">
723
+ **[MANDATORY] Impact Analysis:**
724
+
725
+ - Discover ALL code flows that might be impacted by the new implementation
726
+ - Include specific file references for each impacted flow
727
+ - Identify tests that need modification (include file paths)
728
+ - Document documentation files/flows requiring updates
729
+ - Assess performance implications
730
+ - Identify breaking change risks
731
+ </item>
732
+ </phase>
733
+
734
+ <phase name="refactoring-strategy" order="3">
735
+ &lt;!-- ALL 4 items are MANDATORY --&gt;
736
+
737
+ <item name="refactoring-requirements" mandatory="true">
738
+ **[MANDATORY] Refactoring Requirements:**
739
+
740
+ Determine if existing code needs refactoring for the new implementation
741
+ to be MAINTAINABLE / EXTENSIBLE. Check for:
742
+
743
+ <refactoring-scenario name="consolidation">
744
+ Duplicate code that should be unified before adding more
745
+ </refactoring-scenario>
746
+ <refactoring-scenario name="abstraction">
747
+ Concrete implementations that need interfaces for extensibility
748
+ </refactoring-scenario>
749
+ <refactoring-scenario name="separation">
750
+ Mixed concerns that need splitting before adding new functionality
751
+ </refactoring-scenario>
752
+ <refactoring-scenario name="generalization">
753
+ Specific code that could be made reusable by the new implementation
754
+ </refactoring-scenario>
755
+ <refactoring-scenario name="simplification">
756
+ Complex code that could be streamlined
757
+ </refactoring-scenario>
758
+ <refactoring-scenario name="standardization">
759
+ Inconsistent patterns needing alignment before extending
760
+ </refactoring-scenario>
761
+
762
+ Common refactoring scenarios to check:
763
+ - Pattern violations (adding a new type when Strategy pattern should be used)
764
+ - Constants scattered across files (centralize in Domain layer)
765
+ - Model proliferation (extend existing vs. create duplicate)
766
+ - Method duplication (reuse existing methods)
767
+ - Layer violations (business logic in wrong layer)
768
+ - Service sprawl (extend existing services if cohesive)
769
+ - Event handler inconsistencies
770
+ - State management violations
771
+ - API integration inconsistencies
772
+ - Type definition duplication
773
+
774
+ **Even if no refactoring is needed, this section MUST be completed
775
+ with the conclusion "no refactoring required" and justification.**
776
+ </item>
777
+
778
+ <item name="implementation-guidelines" mandatory="true">
779
+ **[MANDATORY] Implementation Guidelines:**
780
+
781
+ - Step-by-step implementation approach following coding standards
782
+ - Optimal architectural placement for new code
783
+ - Interface design for maximum flexibility
784
+ - Dependency management approach (DI registrations)
785
+ - State management strategy
786
+ - Error handling patterns to follow
787
+ - Recommended implementation order
788
+ </item>
789
+
790
+ <item name="testing-strategy" mandatory="true">
791
+ **[MANDATORY] Testing Strategy:**
792
+
793
+ - How to test without breaking existing tests
794
+ - Test patterns to follow (from testing framework doc)
795
+ - Required test types (unit, integration, e2e)
796
+ - Mocking strategies based on existing patterns
797
+ - Edge cases to cover from acceptance criteria
798
+ - Test data patterns to follow
799
+ </item>
800
+
801
+ <item name="risk-mitigation" mandatory="true">
802
+ **[MANDATORY] Risk Mitigation:**
803
+
804
+ - Backward compatibility considerations
805
+ - Migration path for existing functionality
806
+ - What existing functionality might be impacted
807
+ - Performance implications
808
+ - Breaking change risks
809
+ - Rollback strategies if needed
810
+ </item>
811
+ </phase>
812
+
813
+ <phase name="ai-context" order="4">
814
+ &lt;!-- ALL 2 items are MANDATORY --&gt;
815
+
816
+ <item name="complete-findings" mandatory="true">
817
+ **[MANDATORY] Complete Analysis Findings:**
818
+
819
+ Include ALL findings from the deep analysis:
820
+ - Every discovered pattern with file references
821
+ - Every relevant code snippet
822
+ - Every architectural decision
823
+ - Every potential issue
824
+ - Every integration consideration
825
+
826
+ CRITICAL REQUIREMENT: This analysis output will be used as PROMPT CONTEXT
827
+ for the AI agent implementing this feature. Therefore:
828
+ - INCLUDE ALL FINDINGS — don't summarize or omit details
829
+ - PROVIDE COMPLETE CONTEXT — the implementing AI needs every piece of information
830
+ - BE EXPLICIT — don't assume the implementing AI will know anything not stated
831
+ </item>
832
+
833
+ <item name="implementation-references" mandatory="true">
834
+ **[MANDATORY] Implementation References:**
835
+
836
+ - **Internal Documentation**: All relevant internal docs with full paths,
837
+ including architecture diagrams and ADRs
838
+ - **Code References**: All files to study before implementation,
839
+ specific functions/classes as examples, utility functions to reuse
840
+ - **Design Patterns &amp; Best Practices**: Links to pattern documentation
841
+ (e.g., https://refactoring.guru/design-patterns/strategy)
842
+ - **External Resources**: Official docs for libraries used, best practice guides
843
+ - **Domain Knowledge**: All naming conventions, error handling patterns,
844
+ logging standards, performance considerations
845
+ </item>
846
+ </phase>
847
+
848
+ </analysis-process>
849
+
850
+ <validation-checklist>
851
+ &lt;!-- Mark each item as complete before finishing.
852
+ Total: 22 mandatory items — DO NOT PROCEED until ALL are verified.
853
+
854
+ COMMON MISTAKE PREVENTION:
855
+ - Tree structures must show ACTUAL current files, not placeholders
856
+ - Refactoring analysis is required even if conclusion is "no refactoring needed"
857
+ - Integration points must reference actual existing code with file paths
858
+ - Testing strategy must ensure existing tests continue to pass
859
+ - Hardcoded values section MUST have actual code snippets, not descriptions
860
+ - All output goes ONLY to the analysis file — NO GitHub updates --&gt;
861
+
862
+ <category name="file-creation">
863
+ <check>[MANDATORY] Analysis file created at story-directory/integration-analysis.md</check>
864
+ <check>[MANDATORY] Story directory created if it didn't exist</check>
865
+ <check>[MANDATORY] File contains all required sections from template</check>
866
+ </category>
867
+
868
+ <category name="core-analysis">
869
+ <check>[MANDATORY] Tree structure showing current codebase structure</check>
870
+ <check>[MANDATORY] Tree structure showing proposed changes with new files</check>
871
+ <check>[MANDATORY] Architecture compatibility analysis completed (layer-by-layer)</check>
872
+ <check>[MANDATORY] All existing patterns identified with file references</check>
873
+ <check>[MANDATORY] Integration points clearly documented</check>
874
+ <check>[MANDATORY] Impact analysis showing affected components</check>
875
+ </category>
876
+
877
+ <category name="architecture">
878
+ <check>[MANDATORY] Clean Architecture compliance verified</check>
879
+ <check>[MANDATORY] Dependency injection strategy documented</check>
880
+ <check>[MANDATORY] Design patterns identified and documented</check>
881
+ <check>[MANDATORY] Coding standards compliance verified</check>
882
+ <check>[MANDATORY] Testing strategy that preserves existing tests</check>
883
+ </category>
884
+
885
+ <category name="hardcoded-values-critical">
886
+ <check>[MANDATORY &amp; CRITICAL] Searched for hardcoded domain/range values</check>
887
+ <check>[MANDATORY &amp; CRITICAL] Searched for placeholder/TODO comments related to the feature</check>
888
+ <check>[MANDATORY &amp; CRITICAL] Identified ALL renderers/handlers that should use new entity but don't</check>
889
+ <check>[MANDATORY &amp; CRITICAL] Identified ALL manager/service classes with hardcoded defaults</check>
890
+ <check>[MANDATORY &amp; CRITICAL] Found disconnected wiring (entity exists but not injected where needed)</check>
891
+ <check>[MANDATORY &amp; CRITICAL] Section 5 filled with ACTUAL CODE SNIPPETS (not placeholders!)</check>
892
+ <check>[MANDATORY &amp; CRITICAL] Every hardcoded value includes: file path, line number, current code, fix required</check>
893
+ </category>
894
+ </validation-checklist>
895
+
896
+ <guidelines>
897
+
898
+ <guideline name="accuracy-first">
899
+ NO ASSUMPTIONS are tolerated. The analysis must reflect 100% accurate code.
900
+ Only document what you actually find in the code. Never infer behavior
901
+ that isn't explicitly implemented. Every claim must be traceable to
902
+ actual code references with file paths and line numbers.
903
+ </guideline>
904
+
905
+ <guideline name="story-scope">
906
+ Focus exclusively on code paths related to the story.
907
+ Do NOT document the entire codebase — only files, functions,
908
+ and constants that are directly involved in implementing the story's
909
+ functionality as defined by its acceptance criteria.
910
+ </guideline>
911
+
912
+ <guideline name="coding-standards-first">
913
+ STRONG EMPHASIS ON CODING STANDARDS — NO EXCEPTIONS!
914
+ Every proposed change, new file, and integration point must be verified
915
+ against the project's coding standards (from wiki system-wide docs).
916
+ Standards compliance is not optional — it is the primary quality gate.
917
+ </guideline>
918
+
919
+ <guideline name="code-level-depth">
920
+ This is a DEEP TECHNICAL ANALYSIS, not a summary:
921
+ - ACTUAL CODE SNIPPETS must be included, not descriptions
922
+ - COMPLETE FILE PATHS WITH LINE NUMBERS for every reference
923
+ - EXACT INTEGRATION POINTS with specific method signatures
924
+ - NO HIGH-LEVEL SUMMARIES — only detailed, code-level analysis
925
+
926
+ This output will be used as the PRIMARY TECHNICAL REFERENCE for
927
+ implementing this story. Without complete code-level detail, the
928
+ analysis is USELESS.
929
+ </guideline>
930
+
931
+ <guideline name="thoroughness">
932
+ THOROUGH &amp; COMPREHENSIVE: Cover every aspect of the integration.
933
+ 100% SUBSTANTIVE: Only include relevant, actionable information.
934
+ TAKE ALL TIME NEEDED: Read EVERY line of relevant code.
935
+ ACCURACY IS PARAMOUNT: This will guide the implementation.
936
+ </guideline>
937
+
938
+ <guideline name="hardcoded-values-critical">
939
+ The hardcoded values discovery is the MOST IMPORTANT section.
940
+ THE #1 REASON INTEGRATION ANALYSES FAIL is identifying what NEW code
941
+ to create but FAILING to identify what EXISTING code must be MODIFIED.
942
+
943
+ For EVERY new entity/service being created:
944
+ 1. "What existing code currently does this job (probably poorly/hardcoded)?"
945
+ 2. "Where should this entity be INJECTED that it currently ISN'T?"
946
+ 3. "What hardcoded values exist that this entity should REPLACE?"
947
+
948
+ This section MUST contain ACTUAL CODE SNIPPETS with file paths and line numbers.
949
+ </guideline>
950
+
951
+ <guideline name="wiki-as-context">
952
+ Wiki documents are the SINGLE SOURCE of codebase knowledge.
953
+ They replace all obsolete separate parameters (sourcecode, high-level-architecture,
954
+ documentation, related-stories-implementations, documented-features).
955
+ Read ALL wiki documents referenced in the story's Relevant Wiki section.
956
+ </guideline>
957
+
958
+ <guideline name="no-github-updates">
959
+ All output is written ONLY to the integration-analysis.md file.
960
+ NO GitHub updates, NO modifications to the story file.
961
+ This is a standalone artifact consumed by pass 5 (technical solution).
962
+ </guideline>
963
+
964
+ <guideline name="github-compatibility">
965
+ The analysis document must render cleanly in GitHub markdown viewers.
966
+ - Use markdown tables (no HTML tables)
967
+ - No custom CSS or HTML styling
968
+ - Code blocks with language hints for syntax highlighting
969
+ - YAML blocks for structured data (hardcoded values, wiring)
970
+ </guideline>
971
+
972
+ <guideline name="refactoring-always-addressed">
973
+ The refactoring section MUST be completed even if the conclusion is
974
+ "no refactoring required." The analysis must explicitly state whether
975
+ refactoring is needed and provide justification either way.
976
+ </guideline>
977
+
978
+ <guideline name="common-mistakes">
979
+ Common mistakes to avoid:
980
+ - Tree structures must show ACTUAL current files, not placeholders
981
+ - Refactoring analysis is required even if "no refactoring needed"
982
+ - Integration points must reference actual existing code with file paths
983
+ - Testing strategy must ensure existing tests continue to pass
984
+ - Hardcoded values section MUST have actual code snippets
985
+ - Don't identify only NEW code — also identify what EXISTING code must CHANGE
986
+ - Don't miss disconnected wiring (entities that exist but aren't injected)
987
+ </guideline>
988
+
989
+ </guidelines>
990
+
991
+ <evolution>
992
+
993
+ **Creation (research-integration-solution — pass 4):**
994
+ This is pass 4 of the story specification pipeline.
995
+ A single run produces the complete integration-analysis.md document.
996
+ All sections must be filled, all checklist items verified.
997
+
998
+ **Consumption (story-technical-solution — pass 5):**
999
+ The integration-analysis.md is consumed as input by pass 5 (technical solution).
1000
+ The technical solution uses insights from this analysis to design the
1001
+ implementation approach — file changes, integration points, refactoring,
1002
+ hardcoded values to replace, testing strategy.
1003
+
1004
+ **Re-analysis (exception, not norm):**
1005
+ Only when the story scope changes significantly or the codebase changes
1006
+ substantially. Re-running overwrites the existing analysis.
1007
+
1008
+ **This analysis does NOT modify the story file.**
1009
+ It lives as a separate artifact in the story directory.
1010
+ The story.xml template has no sections that reference this analysis directly.
1011
+ Only the technical solution (pass 5) consumes it.
1012
+
1013
+ </evolution>
1014
+
1015
+ </integration-solution>