gaia-framework 1.65.1 → 1.66.0

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 (31) hide show
  1. package/CLAUDE.md +16 -1
  2. package/README.md +2 -2
  3. package/_gaia/_config/global.yaml +1 -1
  4. package/_gaia/core/engine/workflow.xml +6 -0
  5. package/_gaia/core/protocols/review-gate-check.xml +29 -1
  6. package/_gaia/lifecycle/knowledge/brownfield/config-contradiction-scan.md +137 -0
  7. package/_gaia/lifecycle/knowledge/brownfield/dead-code-scan.md +179 -0
  8. package/_gaia/lifecycle/knowledge/brownfield/test-execution-scan.md +209 -0
  9. package/_gaia/lifecycle/skills/document-rulesets.md +91 -6
  10. package/_gaia/lifecycle/templates/brownfield-scan-doc-code-prompt.md +219 -0
  11. package/_gaia/lifecycle/templates/brownfield-scan-hardcoded-prompt.md +169 -0
  12. package/_gaia/lifecycle/templates/brownfield-scan-integration-seam-prompt.md +127 -0
  13. package/_gaia/lifecycle/templates/brownfield-scan-runtime-behavior-prompt.md +141 -0
  14. package/_gaia/lifecycle/templates/brownfield-scan-security-prompt.md +212 -0
  15. package/_gaia/lifecycle/templates/gap-entry-schema.md +247 -0
  16. package/_gaia/lifecycle/templates/infra-prd-template.md +356 -0
  17. package/_gaia/lifecycle/templates/platform-prd-template.md +431 -0
  18. package/_gaia/lifecycle/templates/prd-template.md +70 -0
  19. package/_gaia/lifecycle/workflows/4-implementation/add-feature/checklist.md +1 -1
  20. package/_gaia/lifecycle/workflows/4-implementation/add-feature/instructions.xml +2 -3
  21. package/_gaia/lifecycle/workflows/4-implementation/add-stories/checklist.md +5 -0
  22. package/_gaia/lifecycle/workflows/4-implementation/add-stories/instructions.xml +73 -1
  23. package/_gaia/lifecycle/workflows/4-implementation/create-story/instructions.xml +1 -1
  24. package/_gaia/lifecycle/workflows/4-implementation/retrospective/instructions.xml +21 -1
  25. package/_gaia/lifecycle/workflows/4-implementation/retrospective/workflow.yaml +1 -1
  26. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/checklist.md +12 -0
  27. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/instructions.xml +244 -4
  28. package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/workflow.yaml +1 -0
  29. package/bin/gaia-framework.js +8 -6
  30. package/gaia-install.sh +28 -20
  31. package/package.json +1 -1
@@ -0,0 +1,431 @@
1
+ ---
2
+ template: 'platform-prd'
3
+ version: 1.0.0
4
+ used_by: ['create-prd']
5
+ domain: '{domain}'
6
+ ---
7
+
8
+ # Platform PRD: {product_name}
9
+
10
+ > **Project:** {project_name}
11
+ > **Domain:** {domain}
12
+ > **Date:** {date}
13
+ > **Author:** {agent_name}
14
+ > **Status:** Draft | In Review | Approved
15
+ > **Project Type:** Platform (application + infrastructure)
16
+
17
+ > Requirement IDs use prefixes to disambiguate scope: FR-### and NFR-### for application requirements, IR-###, OR-###, and SR-### for infrastructure requirements. IDs are globally unique within a project — each prefix defines a separate namespace.
18
+
19
+ ---
20
+
21
+ # Part I: Application Requirements
22
+
23
+ ## 1. Overview
24
+
25
+ {Brief product overview and context. What is being built and why.}
26
+
27
+ ## 2. Goals and Non-Goals
28
+
29
+ ### Goals
30
+ - {Goal 1}
31
+ - {Goal 2}
32
+
33
+ ### Non-Goals
34
+ - {Explicitly out of scope item 1}
35
+
36
+ ## 3. User Stories
37
+
38
+ | ID | As a... | I want to... | So that... | Priority |
39
+ |----|---------|-------------|-----------|----------|
40
+ | US-01 | {role} | {action} | {benefit} | {P0-P3} |
41
+
42
+ ## 4. Functional Requirements
43
+
44
+ ### 4.1 {Feature Area}
45
+
46
+ - **FR-01:** {Requirement description}
47
+ - **FR-02:** {Requirement description}
48
+
49
+ ## 5. Non-Functional Requirements
50
+
51
+ | ID | Category | Requirement | Target |
52
+ |----|----------|------------|--------|
53
+ | NFR-001 | Performance | {requirement} | {target} |
54
+ | NFR-002 | Security | {requirement} | {target} |
55
+ | NFR-003 | Accessibility | {requirement} | {target} |
56
+
57
+ ## 6. Out of Scope
58
+
59
+ | Exclusion | Reason |
60
+ |-----------|--------|
61
+ | {feature or integration} | {deferred / not needed / separate product} |
62
+
63
+ ## 7. UX Requirements
64
+
65
+ {Key interaction patterns, wireframe references, accessibility needs.}
66
+
67
+ ## 8. Technical Constraints
68
+
69
+ - {Platform, language, or integration constraint}
70
+
71
+ ## 9. Dependencies
72
+
73
+ | Dependency | Type | Failure Mode | Fallback Behavior | SLA Expectation |
74
+ |------------|------|-------------|-------------------|-----------------|
75
+ | {service or system} | {API / Database / Message Queue / CDN / Auth Provider} | {What happens when it's unavailable} | {Graceful degradation / Retry / Queue / Circuit breaker / Hard fail} | {Expected uptime / latency / throughput} |
76
+
77
+ ## 10. Milestones
78
+
79
+ | Milestone | Target Date | Deliverables |
80
+ |-----------|------------|-------------|
81
+ | {milestone} | {date} | {deliverables} |
82
+
83
+ ---
84
+
85
+ # Part II: Infrastructure Requirements
86
+
87
+ ## 11. Platform Overview & Scope
88
+
89
+ {Platform purpose, target environments, and team ownership.}
90
+
91
+ ### Platform Purpose
92
+
93
+ {What this infrastructure provides and why it exists.}
94
+
95
+ ### Target Environments
96
+
97
+ | Environment | Purpose | Region(s) | Owner |
98
+ |-------------|---------|-----------|-------|
99
+ | {env_name} | {purpose} | {regions} | {team} |
100
+
101
+ ### Team Ownership
102
+
103
+ | Component | Owning Team | Escalation |
104
+ |-----------|-------------|------------|
105
+ | {component} | {team} | {contact} |
106
+
107
+ ## 12. Platform Capabilities
108
+
109
+ {What the infrastructure enables. Each capability follows the format below.}
110
+
111
+ | ID | Capability | SLO |
112
+ |----|-----------|-----|
113
+ | PC-01 | Enable {team/service} to {capability} with {SLO} | {target} |
114
+ | PC-02 | Enable {team/service} to {capability} with {SLO} | {target} |
115
+
116
+ ## 13. Resource Specifications
117
+
118
+ {Compute, storage, networking, IAM provisioning. Per-environment breakdown.}
119
+
120
+ ### Compute
121
+
122
+ | Resource | Environment | Spec | Scaling |
123
+ |----------|-------------|------|---------|
124
+ | {resource} | {env} | {cpu/memory} | {auto/manual, min-max} |
125
+
126
+ ### Storage
127
+
128
+ | Store | Type | Size | IOPS | Backup |
129
+ |-------|------|------|------|--------|
130
+ | {store} | {block/object/file} | {size} | {iops} | {policy} |
131
+
132
+ ### Networking
133
+
134
+ | Component | CIDR/Range | Protocol | Purpose |
135
+ |-----------|-----------|----------|---------|
136
+ | {component} | {cidr} | {protocol} | {purpose} |
137
+
138
+ ### IAM Provisioning
139
+
140
+ | Role/Policy | Scope | Permissions | Lifecycle |
141
+ |-------------|-------|-------------|-----------|
142
+ | {role} | {scope} | {permissions} | {create/rotate/revoke} |
143
+
144
+ ### State Management
145
+
146
+ {State backend strategy — e.g., Terraform remote state, locking, encryption.}
147
+
148
+ | Backend | Lock Provider | Encryption | Workspace Strategy |
149
+ |---------|--------------|------------|-------------------|
150
+ | {backend} | {lock} | {encryption} | {workspace} |
151
+
152
+ ### Data Persistence Requirements
153
+
154
+ | Data Store | Durability | Replication | Retention |
155
+ |------------|-----------|-------------|-----------|
156
+ | {store} | {durability} | {replication} | {retention} |
157
+
158
+ ## 14. Operational SLOs
159
+
160
+ {Availability targets, MTTR, RTO/RPO, error budgets, resource utilization targets.}
161
+
162
+ ### Availability & Recovery
163
+
164
+ | Metric | Target | Measurement |
165
+ |--------|--------|-------------|
166
+ | Availability | {99.x%} | {how measured} |
167
+ | MTTR | {minutes} | {how measured} |
168
+ | RTO | {minutes} | {recovery time objective} |
169
+ | RPO | {minutes} | {recovery point objective} |
170
+ | Error Budget | {x% per month} | {how calculated} |
171
+
172
+ ### Resource Utilization Targets
173
+
174
+ | Resource | Target Utilization | Alert Threshold |
175
+ |----------|-------------------|-----------------|
176
+ | CPU | {target%} | {alert%} |
177
+ | Memory | {target%} | {alert%} |
178
+ | Storage IOPS | {target} | {threshold} |
179
+ | Network Bandwidth | {target Gbps} | {threshold} |
180
+ | Network Latency | {target ms} | {threshold} |
181
+
182
+ ## 15. Security Posture
183
+
184
+ {Security requirements tailored for infrastructure projects.}
185
+
186
+ ### IAM/RBAC
187
+
188
+ {Identity and access management, role-based access control policies.}
189
+
190
+ | Principal | Role | Scope | MFA Required | Review Cadence |
191
+ |-----------|------|-------|-------------|----------------|
192
+ | {principal} | {role} | {scope} | {yes/no} | {quarterly/annually} |
193
+
194
+ ### Network Segmentation
195
+
196
+ {Network isolation, security groups, firewall rules, zero-trust boundaries.}
197
+
198
+ | Zone | CIDR | Ingress Rules | Egress Rules | Purpose |
199
+ |------|------|---------------|-------------|---------|
200
+ | {zone} | {cidr} | {rules} | {rules} | {purpose} |
201
+
202
+ ### Secrets Management
203
+
204
+ {Secrets storage, rotation, injection, and audit strategy.}
205
+
206
+ | Secret Type | Store | Rotation | Injection Method |
207
+ |-------------|-------|----------|-----------------|
208
+ | {type} | {vault/kms/ssm} | {cadence} | {env var/sidecar/init container} |
209
+
210
+ ### Image Provenance
211
+
212
+ {Container image signing, scanning, and supply chain verification.}
213
+
214
+ | Registry | Signing | Scanning | Admission Policy |
215
+ |----------|---------|----------|-----------------|
216
+ | {registry} | {cosign/notary} | {trivy/grype} | {policy} |
217
+
218
+ ### Compliance Mapping
219
+
220
+ {Regulatory and compliance framework alignment.}
221
+
222
+ | Framework | Controls | Evidence | Audit Frequency |
223
+ |-----------|----------|----------|----------------|
224
+ | {SOC2/HIPAA/PCI/ISO} | {control IDs} | {how demonstrated} | {cadence} |
225
+
226
+ ## 16. Environment Strategy & Developer Experience
227
+
228
+ {Environment parity, promotion pipeline, drift detection, self-service provisioning.}
229
+
230
+ ### Environment Parity
231
+
232
+ | Dimension | Dev | Staging | Production |
233
+ |-----------|-----|---------|-----------|
234
+ | {dimension} | {dev config} | {staging config} | {prod config} |
235
+
236
+ ### Promotion Pipeline
237
+
238
+ {How changes flow from dev to production.}
239
+
240
+ ```
241
+ {dev} → {staging} → {production}
242
+ ```
243
+
244
+ ### Drift Detection
245
+
246
+ {How configuration drift is detected and remediated.}
247
+
248
+ | Tool | Schedule | Remediation | Notification |
249
+ |------|----------|-------------|-------------|
250
+ | {tool} | {cron} | {auto/manual} | {channel} |
251
+
252
+ ### Self-Service Provisioning
253
+
254
+ {Developer self-service capabilities and guardrails.}
255
+
256
+ | Capability | Interface | Guardrails | Approval |
257
+ |------------|-----------|-----------|----------|
258
+ | {capability} | {CLI/portal/API} | {policy} | {auto/manual} |
259
+
260
+ ### Onboarding
261
+
262
+ {New team member and new service onboarding procedures.}
263
+
264
+ ### Observability
265
+
266
+ {Monitoring, logging, tracing, and alerting strategy.}
267
+
268
+ | Signal | Tool | Retention | Alerting |
269
+ |--------|------|-----------|---------|
270
+ | Metrics | {prometheus/cloudwatch} | {retention} | {pagerduty/slack} |
271
+ | Logs | {elk/cloudwatch} | {retention} | {rules} |
272
+ | Traces | {jaeger/xray} | {retention} | {rules} |
273
+
274
+ ## 17. Dependencies & Provider Constraints
275
+
276
+ {Cloud provider limits, Terraform provider versions, upstream service contracts.}
277
+
278
+ ### Cloud Provider Limits
279
+
280
+ | Provider | Service | Limit | Current Usage | Headroom |
281
+ |----------|---------|-------|--------------|----------|
282
+ | {provider} | {service} | {limit} | {current} | {remaining} |
283
+
284
+ ### Terraform Provider Versions
285
+
286
+ | Provider | Version | Constraint | Notes |
287
+ |----------|---------|-----------|-------|
288
+ | {provider} | {version} | {~> x.y} | {notes} |
289
+
290
+ ### Upstream Service Contracts
291
+
292
+ | Service | SLA | API Version | Deprecation |
293
+ |---------|-----|------------|-------------|
294
+ | {service} | {sla} | {version} | {date or N/A} |
295
+
296
+ ## 18. Cost Model
297
+
298
+ {Per-environment resource cost estimates, scaling cost projections, and cost-per-unit efficiency metrics.}
299
+
300
+ ### Per-Environment Resource Cost Estimates
301
+
302
+ | Resource | Dev (monthly) | Staging (monthly) | Production (monthly) |
303
+ |----------|--------------|-------------------|---------------------|
304
+ | Compute | ${cost} | ${cost} | ${cost} |
305
+ | Storage | ${cost} | ${cost} | ${cost} |
306
+ | Networking | ${cost} | ${cost} | ${cost} |
307
+ | Monitoring | ${cost} | ${cost} | ${cost} |
308
+ | **Total** | **${total}** | **${total}** | **${total}** |
309
+
310
+ ### Scaling Cost Projections
311
+
312
+ | Scenario | Trigger | Additional Cost | Timeline |
313
+ |----------|---------|----------------|----------|
314
+ | {scenario} | {trigger condition} | ${projection} | {timeframe} |
315
+
316
+ ### Cost-Per-Unit Efficiency Metrics
317
+
318
+ | Metric | Current | Target | Optimization |
319
+ |--------|---------|--------|-------------|
320
+ | Cost per request | ${cost} | ${target} | {strategy} |
321
+ | Cost per GB stored | ${cost} | ${target} | {strategy} |
322
+ | Cost per environment | ${cost} | ${target} | {strategy} |
323
+
324
+ ## 19. Verification Strategy
325
+
326
+ {Policy-as-code (OPA/Rego, Checkov, tfsec), plan validation, smoke tests, drift detection, chaos testing.}
327
+
328
+ ### Policy-as-Code
329
+
330
+ | Tool | Scope | Rules | Enforcement |
331
+ |------|-------|-------|-------------|
332
+ | OPA/Rego | {scope} | {rule count} | {warn/deny} |
333
+ | Checkov | {scope} | {rule count} | {warn/deny} |
334
+ | tfsec | {scope} | {rule count} | {warn/deny} |
335
+
336
+ ### Plan Validation
337
+
338
+ {Terraform plan review, cost estimation, blast radius analysis.}
339
+
340
+ | Check | Tool | Gate | Threshold |
341
+ |-------|------|------|-----------|
342
+ | {check} | {tool} | {CI/manual} | {threshold} |
343
+
344
+ ### Smoke Tests
345
+
346
+ {Post-deployment verification tests.}
347
+
348
+ | Test | Target | Expected | Timeout |
349
+ |------|--------|----------|---------|
350
+ | {test} | {endpoint/resource} | {result} | {timeout} |
351
+
352
+ ### Drift Detection
353
+
354
+ {Scheduled plan diffs, state file monitoring, compliance scanning.}
355
+
356
+ ### Chaos Testing
357
+
358
+ {Failure injection, resilience validation.}
359
+
360
+ | Experiment | Target | Hypothesis | Blast Radius |
361
+ |-----------|--------|-----------|-------------|
362
+ | {experiment} | {target} | {hypothesis} | {scope} |
363
+
364
+ ## 20. Operational Runbooks
365
+
366
+ {Scaling, failover, incident response, rollback procedures.}
367
+
368
+ ### Scaling Procedures
369
+
370
+ | Trigger | Action | Rollback | Owner |
371
+ |---------|--------|----------|-------|
372
+ | {trigger} | {action} | {rollback} | {team} |
373
+
374
+ ### Failover Procedures
375
+
376
+ | Scenario | Detection | Response | RTO |
377
+ |----------|-----------|----------|-----|
378
+ | {scenario} | {detection} | {response steps} | {rto} |
379
+
380
+ ### Incident Response
381
+
382
+ | Severity | Notification | Escalation | Runbook |
383
+ |----------|-------------|------------|---------|
384
+ | P1 | {channel} | {escalation path} | {link} |
385
+ | P2 | {channel} | {escalation path} | {link} |
386
+
387
+ ### Rollback Procedures
388
+
389
+ | Change Type | Rollback Method | Verification | Duration |
390
+ |-------------|----------------|-------------|----------|
391
+ | {type} | {method} | {verification} | {estimate} |
392
+
393
+ ---
394
+
395
+ # Part III: Combined Requirements Summary
396
+
397
+ ## 21. Requirements Summary
398
+
399
+ > IDs are globally unique within a project. The prefix disambiguates the requirement scope: FR/NFR for application, IR/OR/SR for infrastructure.
400
+
401
+ ### Application Requirements
402
+
403
+ | ID | Description | Priority | Status |
404
+ |----|------------|----------|--------|
405
+ | FR-001 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
406
+ | NFR-001 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
407
+
408
+ ### Infrastructure Requirements
409
+
410
+ | ID | Description | Priority | Status |
411
+ |----|------------|----------|--------|
412
+ | IR-001 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
413
+ | IR-002 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
414
+
415
+ ### Operational Requirements
416
+
417
+ | ID | Description | Priority | Status |
418
+ |----|------------|----------|--------|
419
+ | OR-001 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
420
+ | OR-002 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
421
+
422
+ ### Security Requirements
423
+
424
+ | ID | Description | Priority | Status |
425
+ |----|------------|----------|--------|
426
+ | SR-001 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
427
+ | SR-002 | {description} | {Must-Have/Should-Have/Nice-to-Have} | {Draft/Approved} |
428
+
429
+ ## 22. Open Questions
430
+
431
+ - [ ] {Unresolved question}
@@ -81,3 +81,73 @@ used_by: ['create-prd']
81
81
  ## 12. Open Questions
82
82
 
83
83
  - [ ] {Unresolved question}
84
+
85
+ <!-- BROWNFIELD-ONLY-START -->
86
+
87
+ ## Gap Analysis Summary
88
+
89
+ | Category | Critical | High | Medium | Low | Total |
90
+ |----------|----------|------|--------|-----|-------|
91
+ | Config Contradictions | {count} | {count} | {count} | {count} | {count} |
92
+ | Dead Code & Dead State | {count} | {count} | {count} | {count} | {count} |
93
+ | Hard-Coded Business Logic | {count} | {count} | {count} | {count} | {count} |
94
+ | Security Endpoints | {count} | {count} | {count} | {count} | {count} |
95
+ | Runtime Behaviors | {count} | {count} | {count} | {count} | {count} |
96
+ | Documentation Drift | {count} | {count} | {count} | {count} | {count} |
97
+ | Integration Seams | {count} | {count} | {count} | {count} | {count} |
98
+ | **Overall** | **{count}** | **{count}** | **{count}** | **{count}** | **{count}** |
99
+
100
+ ## Gap Analysis by Category
101
+
102
+ ### Config Contradictions (`configuration`)
103
+
104
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
105
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
106
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
107
+
108
+ ### Dead Code & Dead State (`functional`)
109
+
110
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
111
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
112
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
113
+
114
+ ### Hard-Coded Business Logic (`functional`, `behavioral`)
115
+
116
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
117
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
118
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
119
+
120
+ ### Security Endpoints (`security`)
121
+
122
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
123
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
124
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
125
+
126
+ ### Runtime Behaviors (`behavioral`, `operational`)
127
+
128
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
129
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
130
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
131
+
132
+ ### Documentation Drift (`documentation`)
133
+
134
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
135
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
136
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
137
+
138
+ ### Integration Seams (`data-integrity`, `operational`)
139
+
140
+ | ID | Severity | Title | Description | Evidence | Recommendation | Verified By | Confidence |
141
+ |----|----------|-------|-------------|----------|----------------|-------------|------------|
142
+ | — | — | No gaps detected in this category. | — | — | — | — | — |
143
+
144
+ ### Verified By Legend
145
+
146
+ | Value | Description |
147
+ |-------|-------------|
148
+ | `machine-detected` | Gap found by automated scan subagent |
149
+ | `adversarial-review-detected` | Gap found during adversarial review |
150
+ | `code-verified` | Gap confirmed by code-verified review step |
151
+ | `human-reported` | Gap reported manually by a human reviewer |
152
+
153
+ <!-- BROWNFIELD-ONLY-END -->
@@ -32,7 +32,7 @@ validation-target: 'Feature/Enhancement/Patch Triage and Cascade'
32
32
  - [ ] Failed steps handled with retry/skip/abort options
33
33
  - [ ] Checkpoint saved for /gaia-resume recovery
34
34
  ## Story
35
- - [ ] Implementation stories created (or patch story recommended)
35
+ - [ ] Implementation stories created (patch, enhancement, and feature all create stories via subagent)
36
36
  - [ ] Story keys captured
37
37
  ## Assessment Doc
38
38
  - [ ] Assessment document generated at {planning_artifacts}/add-feature-{feature_id}.md
@@ -148,7 +148,7 @@
148
148
  <action>If classification is 'feature' or 'enhancement': spawn subagent to create implementation stories.</action>
149
149
  <action>Spawn subagent: "Load {project-root}/_gaia/core/engine/workflow.xml, then process {project-root}/_gaia/lifecycle/workflows/4-implementation/add-stories/workflow.yaml as workflow-config. Run in YOLO mode. Context: {classification} — {description}. New requirements: {prd_diff}. Architecture changes: {arch_diff}. Feature ID: {feature_id}."</action>
150
150
  <action>When subagent returns: capture new story keys and epic assignments.</action>
151
- <action>If classification is 'patch': create a single fix story inline or recommend /gaia-create-story.</action>
151
+ <action>If classification is 'patch': spawn subagent to create a fix story. Spawn subagent: "Load {project-root}/_gaia/core/engine/workflow.xml, then process {project-root}/_gaia/lifecycle/workflows/4-implementation/create-story/workflow.yaml as workflow-config. Run in YOLO mode. Context: patch fix — {description}. Feature ID: {feature_id}." When subagent returns: capture the new story key.</action>
152
152
  <action>Priority flag integration: if the feature driver is high-urgency (P0 priority, business-critical, or regulatory driver), set priority_flag: "next-sprint" in each created story's frontmatter. This signals sprint planning to auto-include these stories in the next sprint cycle. For non-urgent features, priority_flag remains null (default).</action>
153
153
  </step>
154
154
 
@@ -181,8 +181,7 @@
181
181
  <action>Present summary and recommended next actions based on classification and outcome:
182
182
 
183
183
  **Patch:**
184
- - If story created: "Run /gaia-dev-story {story_key} to implement the fix."
185
- - If no story: "The patch is straightforward — apply directly or create a story with /gaia-create-story."
184
+ - "Run `/gaia-dev-story {story_key}` to implement the fix."
186
185
 
187
186
  **Enhancement:**
188
187
  - "New stories created: {story_keys}. Run /gaia-sprint-plan or /gaia-correct-course to schedule."
@@ -22,6 +22,11 @@ validation-target: 'Updated epics-and-stories.md'
22
22
  - [ ] Source: CR-{cr_id} added (if change request linked)
23
23
  ## Change Log
24
24
  - [ ] Change log entry added with date, feature name, and CR ID
25
+ ## Inline Validation
26
+ - [ ] Inline validation invoked for each new story
27
+ - [ ] Fix loop executed if CRITICAL/WARNING findings found (max 3 attempts)
28
+ - [ ] Validation results recorded per story (validated / validating / degraded)
29
+ - [ ] Graceful degradation handled if Val unavailable (prerequisites missing or invocation failure)
25
30
  ## Existing Content
26
31
  - [ ] Existing stories not modified
27
32
  - [ ] Existing epic structure preserved
@@ -88,9 +88,81 @@
88
88
  If new epic: include epic header with name, description, goal, success criteria before its stories.
89
89
  Prepend a Change Log entry if not already present.
90
90
  </template-output>
91
+ <action>Recount epic overview table story counts and update in-place:
92
+ 1. Parse all `### Story (E\d+)-S\d+:` headers in the saved epics-and-stories.md file
93
+ 2. Group and count story headers per epic key (E1, E2, etc.)
94
+ 3. Locate the Epic Overview table in epics-and-stories.md (the markdown table with columns: epic ID, name, goal, count, priority)
95
+ 4. For each epic row in the table, update the count column to match the actual count of story headers for that epic
96
+ 5. If a new epic was created in Step 4 and does not yet have a row in the Epic Overview table, insert a new row with the correct initial story count
97
+ 6. If an existing epic row in the overview table has zero matching story headers after recount, preserve the row as-is (do not delete it) — log a warning: "Epic {EN} has 0 story headers but overview row preserved"
98
+ 7. Table format: `| E{N} | {name} | {goal} | {count} | {priority} |` — only the `{count}` column cell is updated; do not modify other columns
99
+ 8. Save the updated epics-and-stories.md file</action>
91
100
  </step>
92
101
 
93
- <step n="8" title="Next Steps">
102
+ <step n="8" title="Inline Validation">
103
+ <action>Check Val prerequisites: verify {project-root}/_gaia/lifecycle/agents/validator.md exists AND {project-root}/_memory/validator-sidecar/ directory exists. If either prerequisite is missing, log warning "Val prerequisites unavailable — skipping inline validation. Stories will be marked as validating." Set val_available = false.</action>
104
+
105
+ <action>For each newly created story from Step 5 (batch iteration — each story validated independently):
106
+ Set story_validation_status = "pending"
107
+ Set validation_attempt = 0
108
+
109
+ If val_available == false:
110
+ Set story_validation_status = "degraded"
111
+ Mark story status as 'validating' in the story entry
112
+ Log: "Story {story_key}: Val unavailable — marked as validating"
113
+ Continue to next story
114
+ End If
115
+
116
+ VALIDATION LOOP (maximum 3 attempts):
117
+ Increment validation_attempt
118
+
119
+ Invoke Val validation directly within workflow context (no subagent nesting — works at both standalone level 1 and subagent level 2 from add-feature, never exceeding 2-level nesting max):
120
+ <invoke-workflow
121
+ target="{project-root}/_gaia/lifecycle/workflows/4-implementation/val-validate-artifact/workflow.yaml"
122
+ input_artifact="{planning_artifacts}/epics-and-stories.md"
123
+ story_scope="{story_key}"
124
+ on_error="warn_and_continue" />
125
+
126
+ If Val invocation fails (timeout, context overflow, crash, or missing prerequisites):
127
+ Log warning: "Val validation failed for {story_key}: {reason}"
128
+ Set story_validation_status = "degraded"
129
+ Mark story status as 'validating'
130
+ Break loop — continue to next story
131
+ End If
132
+
133
+ Separate findings by severity:
134
+ - CRITICAL and WARNING findings → actionable_findings (trigger fix loop)
135
+ - INFO findings → info_findings (do not trigger fix loop, non-blocking — log only)
136
+
137
+ Log all INFO findings to output (INFO does not block progression and does not trigger re-validation)
138
+
139
+ If actionable_findings is empty:
140
+ Set story_validation_status = "validated"
141
+ Note story as "validated" in output validation summary
142
+ Break loop — continue to next story
143
+ End If
144
+
145
+ If validation_attempt less than 3:
146
+ Auto-fix each CRITICAL and WARNING finding in the story content
147
+ Re-invoke Val validation (loop continues)
148
+ Else (validation_attempt == 3, maximum reached):
149
+ Set story_validation_status = "failed"
150
+ Mark story status as 'validating' (not 'ready-for-dev')
151
+ Log remaining unresolved findings
152
+ Break loop — continue to next story
153
+ End If
154
+ END VALIDATION LOOP
155
+ End For Each
156
+
157
+ Report batch validation summary:
158
+ - Stories validated successfully: {count} ({list})
159
+ - Stories marked validating (failed after 3 attempts): {count} ({list})
160
+ - Stories marked validating (Val unavailable/degraded): {count} ({list})
161
+ - INFO findings logged: {count}
162
+ </action>
163
+ </step>
164
+
165
+ <step n="9" title="Next Steps">
94
166
  <action>Report summary: new epic(s) created (if any), stories added with IDs and epic assignments</action>
95
167
  <action>For each new story: "Run /gaia-create-story {story_key} to elaborate before development"</action>
96
168
  <action>If stories should enter current sprint: "Run /gaia-correct-course to inject into sprint"</action>
@@ -92,7 +92,7 @@
92
92
  <action>Append DoD checklist: all AC met, tests pass, code reviewed, docs updated</action>
93
93
  </step>
94
94
  <step n="6" title="Generate Output">
95
- <action>Read the story template from {project-root}/_gaia/lifecycle/templates/story-template.md</action>
95
+ <action>Read the story template from the engine-resolved template path. The engine resolves this in Step 1 (Load and Resolve Config): if {project-root}/custom/templates/story-template.md exists and is non-empty, the custom template is used; otherwise it falls back to {project-root}/_gaia/lifecycle/templates/story-template.md. Use whichever path the engine resolved.</action>
96
96
  <action>Read sizing_map from {project-root}/_gaia/_config/global.yaml to resolve T-shirt size to story points (S→2, M→5, L→8, XL→13).</action>
97
97
  <action>Populate ALL YAML frontmatter fields from epics-and-stories.md data:
98
98
  - key: story key from epics (e.g., E1-S1)
@@ -96,7 +96,27 @@
96
96
  <action>For each related skill, propose a concrete addition or modification: what section should change, what content to add, and why (link back to the retro finding)</action>
97
97
  <action if="yolo_mode">In YOLO mode: auto-approve all recommended skill improvements. Skip the user prompt below.</action>
98
98
  <ask>Here are the proposed skill improvements based on this sprint's findings. Approve, modify, or skip each. [approve all / select / skip]</ask>
99
- <action>If approved: append to the relevant skill file with comment: "<!-- Added from retro-{sprint_id}: {reason} -->"</action>
99
+ <action>If approved: write the skill improvement to {project-root}/custom/skills/{skill-name}.md (NOT _gaia/dev/skills/).
100
+ Follow this sequence for each approved skill improvement:
101
+
102
+ 1. Ensure directory exists: create {project-root}/custom/skills/ if it does not already exist (mkdir -p equivalent).
103
+
104
+ 2. Base-skill copy guard: check if {project-root}/custom/skills/{skill-name}.md already exists.
105
+ - If the custom skill file does NOT exist: copy the base skill from _gaia/dev/skills/{skill-name}.md (resolved at {project-root}) to {project-root}/custom/skills/{skill-name}.md, preserving all &lt;!-- SECTION: xxx --&gt; markers intact. This ensures the engine's sectioned loading continues to work for the custom copy.
106
+ - If the base skill does NOT exist at _gaia/dev/skills/{skill-name}.md (e.g., removed in a framework update): log a warning ("Base skill {skill-name} not found at _gaia/dev/skills/ — creating custom skill from scratch") and write the improvement content directly to custom/skills/{skill-name}.md without a base copy.
107
+ - If the custom skill file already exists: preserve existing content and apply the improvement on top.
108
+
109
+ 3. Apply the improvement: append to or modify the relevant section in custom/skills/{skill-name}.md with comment "<!-- Added from retro-{sprint_id}: {reason} -->".
110
+
111
+ 4. Register in .customize.yaml: after writing the custom skill file, register it in {project-root}/_gaia/_config/agents/all-dev.customize.yaml so the engine loads from the custom path on subsequent runs.
112
+ - If all-dev.customize.yaml does not exist: create it with proper YAML structure:
113
+ ```yaml
114
+ skill_overrides:
115
+ {skill-name}:
116
+ source: "custom/skills/{skill-name}.md"
117
+ ```
118
+ - If all-dev.customize.yaml already exists: read current content, check if a skill_overrides entry for this skill already exists. If it does not exist, append the new entry under skill_overrides. Preserve all existing entries — only add the new one. If it already exists (duplicate), skip registration to prevent duplicate entries.
119
+ </action>
100
120
  <action>If no skill improvements identified, state: "No skill improvements identified this sprint."</action>
101
121
  </step>
102
122
  <step n="7" title="Cross-Retro Pattern Detection">
@@ -28,4 +28,4 @@ output:
28
28
  sidecar_updates:
29
29
  - "{memory_path}/*-sidecar/*.md"
30
30
  skill_updates:
31
- - "{project-root}/_gaia/dev/skills/*.md"
31
+ - "{project-root}/custom/skills/*.md"