chati-dev 1.4.0 → 2.0.2

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 (208) hide show
  1. package/README.md +40 -24
  2. package/framework/agents/build/dev.md +343 -0
  3. package/framework/agents/clarity/architect.md +112 -0
  4. package/framework/agents/clarity/brief.md +182 -0
  5. package/framework/agents/clarity/brownfield-wu.md +181 -0
  6. package/framework/agents/clarity/detail.md +110 -0
  7. package/framework/agents/clarity/greenfield-wu.md +153 -0
  8. package/framework/agents/clarity/ux.md +112 -0
  9. package/framework/config.yaml +3 -3
  10. package/framework/constitution.md +31 -1
  11. package/framework/context/governance.md +37 -0
  12. package/framework/context/protocols.md +34 -0
  13. package/framework/context/quality.md +27 -0
  14. package/framework/context/root.md +24 -0
  15. package/framework/data/entity-registry.yaml +1 -1
  16. package/framework/domains/agents/architect.yaml +51 -0
  17. package/framework/domains/agents/brief.yaml +47 -0
  18. package/framework/domains/agents/brownfield-wu.yaml +49 -0
  19. package/framework/domains/agents/detail.yaml +47 -0
  20. package/framework/domains/agents/dev.yaml +49 -0
  21. package/framework/domains/agents/devops.yaml +43 -0
  22. package/framework/domains/agents/greenfield-wu.yaml +47 -0
  23. package/framework/domains/agents/orchestrator.yaml +49 -0
  24. package/framework/domains/agents/phases.yaml +47 -0
  25. package/framework/domains/agents/qa-implementation.yaml +43 -0
  26. package/framework/domains/agents/qa-planning.yaml +44 -0
  27. package/framework/domains/agents/tasks.yaml +48 -0
  28. package/framework/domains/agents/ux.yaml +50 -0
  29. package/framework/domains/constitution.yaml +77 -0
  30. package/framework/domains/global.yaml +64 -0
  31. package/framework/domains/workflows/brownfield-discovery.yaml +16 -0
  32. package/framework/domains/workflows/brownfield-fullstack.yaml +26 -0
  33. package/framework/domains/workflows/brownfield-service.yaml +22 -0
  34. package/framework/domains/workflows/brownfield-ui.yaml +22 -0
  35. package/framework/domains/workflows/greenfield-fullstack.yaml +26 -0
  36. package/framework/hooks/constitution-guard.js +101 -0
  37. package/framework/hooks/mode-governance.js +92 -0
  38. package/framework/hooks/model-governance.js +76 -0
  39. package/framework/hooks/prism-engine.js +89 -0
  40. package/framework/hooks/session-digest.js +60 -0
  41. package/framework/hooks/settings.json +44 -0
  42. package/framework/i18n/en.yaml +3 -3
  43. package/framework/i18n/es.yaml +3 -3
  44. package/framework/i18n/fr.yaml +3 -3
  45. package/framework/i18n/pt.yaml +3 -3
  46. package/framework/intelligence/decision-engine.md +1 -1
  47. package/framework/migrations/v1.4-to-v2.0.yaml +167 -0
  48. package/framework/migrations/v2.0-to-v2.0.1.yaml +132 -0
  49. package/framework/orchestrator/chati.md +284 -6
  50. package/framework/tasks/architect-api-design.md +63 -0
  51. package/framework/tasks/architect-consolidate.md +47 -0
  52. package/framework/tasks/architect-db-design.md +73 -0
  53. package/framework/tasks/architect-design.md +95 -0
  54. package/framework/tasks/architect-security-review.md +62 -0
  55. package/framework/tasks/architect-stack-selection.md +53 -0
  56. package/framework/tasks/brief-consolidate.md +249 -0
  57. package/framework/tasks/brief-constraint-identify.md +277 -0
  58. package/framework/tasks/brief-extract-requirements.md +339 -0
  59. package/framework/tasks/brief-stakeholder-map.md +176 -0
  60. package/framework/tasks/brief-validate-completeness.md +121 -0
  61. package/framework/tasks/brownfield-wu-architecture-map.md +394 -0
  62. package/framework/tasks/brownfield-wu-deep-discovery.md +312 -0
  63. package/framework/tasks/brownfield-wu-dependency-scan.md +359 -0
  64. package/framework/tasks/brownfield-wu-migration-plan.md +483 -0
  65. package/framework/tasks/brownfield-wu-report.md +325 -0
  66. package/framework/tasks/brownfield-wu-risk-assess.md +424 -0
  67. package/framework/tasks/detail-acceptance-criteria.md +372 -0
  68. package/framework/tasks/detail-consolidate.md +138 -0
  69. package/framework/tasks/detail-edge-case-analysis.md +300 -0
  70. package/framework/tasks/detail-expand-prd.md +389 -0
  71. package/framework/tasks/detail-nfr-extraction.md +223 -0
  72. package/framework/tasks/dev-code-review.md +404 -0
  73. package/framework/tasks/dev-consolidate.md +543 -0
  74. package/framework/tasks/dev-debug.md +322 -0
  75. package/framework/tasks/dev-implement.md +252 -0
  76. package/framework/tasks/dev-iterate.md +411 -0
  77. package/framework/tasks/dev-pr-prepare.md +497 -0
  78. package/framework/tasks/dev-refactor.md +342 -0
  79. package/framework/tasks/dev-test-write.md +306 -0
  80. package/framework/tasks/devops-ci-setup.md +412 -0
  81. package/framework/tasks/devops-consolidate.md +712 -0
  82. package/framework/tasks/devops-deploy-config.md +598 -0
  83. package/framework/tasks/devops-monitoring-setup.md +658 -0
  84. package/framework/tasks/devops-release-prepare.md +673 -0
  85. package/framework/tasks/greenfield-wu-analyze-empty.md +169 -0
  86. package/framework/tasks/greenfield-wu-report.md +266 -0
  87. package/framework/tasks/greenfield-wu-scaffold-detection.md +203 -0
  88. package/framework/tasks/greenfield-wu-tech-stack-assess.md +255 -0
  89. package/framework/tasks/orchestrator-deviation.md +260 -0
  90. package/framework/tasks/orchestrator-escalate.md +276 -0
  91. package/framework/tasks/orchestrator-handoff.md +243 -0
  92. package/framework/tasks/orchestrator-health.md +372 -0
  93. package/framework/tasks/orchestrator-mode-switch.md +262 -0
  94. package/framework/tasks/orchestrator-resume.md +189 -0
  95. package/framework/tasks/orchestrator-route.md +169 -0
  96. package/framework/tasks/orchestrator-spawn-terminal.md +358 -0
  97. package/framework/tasks/orchestrator-status.md +260 -0
  98. package/framework/tasks/orchestrator-suggest-mode.md +372 -0
  99. package/framework/tasks/phases-breakdown.md +91 -0
  100. package/framework/tasks/phases-dependency-mapping.md +67 -0
  101. package/framework/tasks/phases-mvp-scoping.md +94 -0
  102. package/framework/tasks/qa-impl-consolidate.md +522 -0
  103. package/framework/tasks/qa-impl-performance-test.md +487 -0
  104. package/framework/tasks/qa-impl-regression-check.md +413 -0
  105. package/framework/tasks/qa-impl-sast-scan.md +402 -0
  106. package/framework/tasks/qa-impl-test-execute.md +344 -0
  107. package/framework/tasks/qa-impl-verdict.md +339 -0
  108. package/framework/tasks/qa-planning-consolidate.md +309 -0
  109. package/framework/tasks/qa-planning-coverage-plan.md +338 -0
  110. package/framework/tasks/qa-planning-gate-define.md +339 -0
  111. package/framework/tasks/qa-planning-risk-matrix.md +631 -0
  112. package/framework/tasks/qa-planning-test-strategy.md +217 -0
  113. package/framework/tasks/tasks-acceptance-write.md +75 -0
  114. package/framework/tasks/tasks-consolidate.md +57 -0
  115. package/framework/tasks/tasks-decompose.md +80 -0
  116. package/framework/tasks/tasks-estimate.md +66 -0
  117. package/framework/tasks/ux-a11y-check.md +49 -0
  118. package/framework/tasks/ux-component-map.md +55 -0
  119. package/framework/tasks/ux-consolidate.md +46 -0
  120. package/framework/tasks/ux-user-flow.md +46 -0
  121. package/framework/tasks/ux-wireframe.md +76 -0
  122. package/package.json +2 -2
  123. package/scripts/bundle-framework.js +2 -0
  124. package/scripts/changelog-generator.js +222 -0
  125. package/scripts/codebase-mapper.js +728 -0
  126. package/scripts/commit-message-generator.js +167 -0
  127. package/scripts/coverage-analyzer.js +260 -0
  128. package/scripts/dependency-analyzer.js +280 -0
  129. package/scripts/framework-analyzer.js +308 -0
  130. package/scripts/generate-constitution-domain.js +253 -0
  131. package/scripts/health-check.js +481 -0
  132. package/scripts/ide-sync.js +327 -0
  133. package/scripts/performance-analyzer.js +325 -0
  134. package/scripts/plan-tracker.js +278 -0
  135. package/scripts/populate-entity-registry.js +481 -0
  136. package/scripts/pr-review.js +317 -0
  137. package/scripts/rollback-manager.js +310 -0
  138. package/scripts/stuck-detector.js +343 -0
  139. package/scripts/test-quality-assessment.js +257 -0
  140. package/scripts/validate-agents.js +367 -0
  141. package/scripts/validate-tasks.js +465 -0
  142. package/src/autonomy/autonomous-gate.js +293 -0
  143. package/src/autonomy/index.js +51 -0
  144. package/src/autonomy/mode-manager.js +225 -0
  145. package/src/autonomy/mode-suggester.js +283 -0
  146. package/src/autonomy/progress-reporter.js +268 -0
  147. package/src/autonomy/safety-net.js +320 -0
  148. package/src/context/bracket-tracker.js +79 -0
  149. package/src/context/domain-loader.js +107 -0
  150. package/src/context/engine.js +144 -0
  151. package/src/context/formatter.js +184 -0
  152. package/src/context/index.js +4 -0
  153. package/src/context/layers/l0-constitution.js +28 -0
  154. package/src/context/layers/l1-global.js +37 -0
  155. package/src/context/layers/l2-agent.js +39 -0
  156. package/src/context/layers/l3-workflow.js +42 -0
  157. package/src/context/layers/l4-task.js +24 -0
  158. package/src/decision/analyzer.js +167 -0
  159. package/src/decision/engine.js +270 -0
  160. package/src/decision/index.js +38 -0
  161. package/src/decision/registry-healer.js +450 -0
  162. package/src/decision/registry-updater.js +330 -0
  163. package/src/gates/circuit-breaker.js +119 -0
  164. package/src/gates/g1-planning-complete.js +153 -0
  165. package/src/gates/g2-qa-planning.js +153 -0
  166. package/src/gates/g3-implementation.js +188 -0
  167. package/src/gates/g4-qa-implementation.js +207 -0
  168. package/src/gates/g5-deploy-ready.js +180 -0
  169. package/src/gates/gate-base.js +144 -0
  170. package/src/gates/index.js +46 -0
  171. package/src/installer/brownfield-upgrader.js +249 -0
  172. package/src/installer/core.js +82 -11
  173. package/src/installer/file-hasher.js +51 -0
  174. package/src/installer/manifest.js +117 -0
  175. package/src/installer/templates.js +17 -15
  176. package/src/installer/transaction.js +229 -0
  177. package/src/installer/validator.js +18 -1
  178. package/src/intelligence/registry-manager.js +2 -2
  179. package/src/memory/agent-memory.js +255 -0
  180. package/src/memory/gotchas-injector.js +72 -0
  181. package/src/memory/gotchas.js +361 -0
  182. package/src/memory/index.js +35 -0
  183. package/src/memory/search.js +233 -0
  184. package/src/memory/session-digest.js +239 -0
  185. package/src/merger/env-merger.js +112 -0
  186. package/src/merger/index.js +56 -0
  187. package/src/merger/replace-merger.js +51 -0
  188. package/src/merger/yaml-merger.js +127 -0
  189. package/src/orchestrator/agent-selector.js +285 -0
  190. package/src/orchestrator/deviation-handler.js +350 -0
  191. package/src/orchestrator/handoff-engine.js +271 -0
  192. package/src/orchestrator/index.js +67 -0
  193. package/src/orchestrator/intent-classifier.js +264 -0
  194. package/src/orchestrator/pipeline-manager.js +492 -0
  195. package/src/orchestrator/pipeline-state.js +223 -0
  196. package/src/orchestrator/session-manager.js +409 -0
  197. package/src/tasks/executor.js +195 -0
  198. package/src/tasks/handoff.js +226 -0
  199. package/src/tasks/index.js +4 -0
  200. package/src/tasks/loader.js +210 -0
  201. package/src/tasks/router.js +182 -0
  202. package/src/terminal/collector.js +216 -0
  203. package/src/terminal/index.js +30 -0
  204. package/src/terminal/isolation.js +129 -0
  205. package/src/terminal/monitor.js +277 -0
  206. package/src/terminal/spawner.js +269 -0
  207. package/src/upgrade/checker.js +1 -1
  208. package/src/wizard/i18n.js +3 -3
@@ -0,0 +1,372 @@
1
+ ---
2
+ id: orchestrator-health
3
+ agent: orchestrator
4
+ trigger: user-input
5
+ phase: all
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [health-report]
9
+ handoff_to: null
10
+ autonomous_gate: true
11
+ criteria:
12
+ - Framework installation validated
13
+ - Critical files verified
14
+ - Agent definitions checked
15
+ - System dependencies assessed
16
+ ---
17
+
18
+ # Orchestrator Health Task
19
+
20
+ ## Purpose
21
+ Validate the chati.dev framework installation, check system dependencies, verify agent definitions, and report overall health status.
22
+
23
+ ## Prerequisites
24
+ - chati.dev framework installed
25
+ - Access to framework directories
26
+ - Session file (optional, for session-specific checks)
27
+
28
+ ## Steps
29
+
30
+ ### 1. Check Core Framework Files
31
+ Verify essential framework files exist and are valid:
32
+ - `chati.dev/constitution.md` (Article I through XI)
33
+ - `chati.dev/config.yaml` (framework configuration)
34
+ - `chati.dev/installer/install.js` (installer script)
35
+ - `.chati/` directory structure
36
+
37
+ ### 2. Validate Agent Definitions
38
+ Check all 12 agent YAML files in `chati.dev/agents/`:
39
+ - greenfield-wu.yaml
40
+ - brownfield-wu.yaml
41
+ - brief.yaml
42
+ - detail.yaml
43
+ - architect.yaml
44
+ - ux.yaml
45
+ - phases.yaml
46
+ - tasks.yaml
47
+ - qa-planning.yaml
48
+ - dev.yaml
49
+ - qa-implementation.yaml
50
+ - devops.yaml
51
+
52
+ For each agent, verify:
53
+ - Valid YAML syntax
54
+ - Required fields present (name, role, phase, outputs)
55
+ - MCP requirements listed
56
+ - Success criteria defined
57
+
58
+ ### 3. Check Task Definitions
59
+ Verify task files in `chati.dev/tasks/`:
60
+ - Count of task files
61
+ - Valid frontmatter (YAML)
62
+ - Proper structure (agent, trigger, outputs)
63
+ - No syntax errors
64
+
65
+ ### 4. Validate Schema Files
66
+ Check schema definitions in `chati.dev/schemas/`:
67
+ - session.yaml
68
+ - handoff.yaml
69
+ - config.yaml
70
+ - Agent-specific schemas
71
+
72
+ Verify:
73
+ - Valid YAML/JSON schema syntax
74
+ - Required fields documented
75
+ - Data types specified
76
+
77
+ ### 5. Test Session File
78
+ If session exists at `.chati/session.yaml`:
79
+ - Validate YAML syntax
80
+ - Check schema compliance
81
+ - Verify referenced artifacts exist
82
+ - Check for corruption indicators
83
+
84
+ ### 6. Verify Directory Structure
85
+ Ensure required directories exist:
86
+ - `.chati/artifacts/`
87
+ - `.chati/artifacts/handoffs/`
88
+ - `.chati/logs/`
89
+ - `.chati/backups/`
90
+ - `chati.dev/agents/`
91
+ - `chati.dev/tasks/`
92
+ - `chati.dev/schemas/`
93
+
94
+ ### 7. Check System Dependencies
95
+ Validate external requirements:
96
+ - Node.js version (>= 18)
97
+ - IDE environment (Claude Code, VS Code, etc.)
98
+ - MCP support available
99
+ - File system permissions
100
+
101
+ ### 8. Test Context Engine
102
+ Verify context loading works:
103
+ - Load constitution
104
+ - Parse agent definitions
105
+ - Read config values
106
+ - Test YAML parsing
107
+
108
+ ### 9. Validate Constitution
109
+ Check Article XI governance rules:
110
+ - Mode definitions present
111
+ - Transition rules defined
112
+ - Scope restrictions specified
113
+ - Quality gates documented
114
+
115
+ ### 10. Generate Health Report
116
+ Compile results into comprehensive report:
117
+ - Overall status (healthy/degraded/critical)
118
+ - Per-component status
119
+ - Issues found
120
+ - Recommendations
121
+ - Quick fixes (if available)
122
+
123
+ ## Decision Points
124
+
125
+ ### When Core Files are Missing
126
+ If essential files (constitution, config) are absent:
127
+ 1. Check if framework is partially installed
128
+ 2. Suggest running installer
129
+ 3. Offer to create minimal viable files
130
+
131
+ ### When Agent Definitions are Invalid
132
+ If agent YAML files have errors:
133
+ 1. Identify specific validation failures
134
+ 2. Show line numbers and error details
135
+ 3. Offer to restore from framework defaults
136
+
137
+ ### When Session is Corrupted
138
+ If session file is malformed:
139
+ 1. Attempt recovery from backups
140
+ 2. Reconstruct from handoff chain
141
+ 3. Suggest fresh initialization
142
+
143
+ ### When Dependencies are Missing
144
+ If system requirements not met:
145
+ 1. Identify missing dependencies
146
+ 2. Provide installation instructions
147
+ 3. Assess if partial operation is possible
148
+
149
+ ## Error Handling
150
+
151
+ ### File Read Failure
152
+ If framework files can't be accessed:
153
+ - Check file permissions
154
+ - Verify installation path
155
+ - Suggest permission fix or reinstall
156
+
157
+ ### YAML Parse Error
158
+ If any YAML file is malformed:
159
+ - Show parse error with line number
160
+ - Attempt to identify syntax issue
161
+ - Suggest validation tool
162
+
163
+ ### Directory Creation Failure
164
+ If required directories can't be created:
165
+ - Check filesystem permissions
166
+ - Verify disk space
167
+ - Suggest manual directory creation
168
+
169
+ ### Schema Validation Failure
170
+ If files don't match schema:
171
+ - Show validation errors
172
+ - Identify out-of-spec fields
173
+ - Suggest schema migration
174
+
175
+ ### Partial Installation Detected
176
+ If some components present, others missing:
177
+ - List missing components
178
+ - Assess if framework can function
179
+ - Recommend complete reinstall vs. repair
180
+
181
+ ## Output Format
182
+
183
+ ```yaml
184
+ health_report:
185
+ timestamp: "2026-02-13T10:30:00Z"
186
+ overall_status: "healthy" # or "degraded", "critical"
187
+ framework_version: "1.0.0"
188
+
189
+ core_files:
190
+ status: "healthy"
191
+ checks:
192
+ - file: "chati.dev/constitution.md"
193
+ status: "ok"
194
+ size_kb: 45
195
+ articles_count: 11
196
+ - file: "chati.dev/config.yaml"
197
+ status: "ok"
198
+ valid_yaml: true
199
+ - file: "chati.dev/installer/install.js"
200
+ status: "ok"
201
+ executable: true
202
+ - file: ".chati/session.yaml"
203
+ status: "ok"
204
+ valid: true
205
+ schema_compliant: true
206
+
207
+ agent_definitions:
208
+ status: "healthy"
209
+ total_agents: 12
210
+ valid_agents: 12
211
+ issues: []
212
+ agents:
213
+ - name: "greenfield-wu"
214
+ file: "chati.dev/agents/greenfield-wu.yaml"
215
+ status: "ok"
216
+ valid_yaml: true
217
+ required_fields: true
218
+ mcps_defined: true
219
+ - name: "brownfield-wu"
220
+ file: "chati.dev/agents/brownfield-wu.yaml"
221
+ status: "ok"
222
+ # ... (all 12 agents)
223
+
224
+ task_definitions:
225
+ status: "healthy"
226
+ total_tasks: 35 # example count
227
+ valid_tasks: 35
228
+ issues: []
229
+ sample_tasks:
230
+ - "orchestrator-route.md"
231
+ - "orchestrator-status.md"
232
+ - "detail-analyze-requirements.md"
233
+
234
+ schemas:
235
+ status: "healthy"
236
+ total_schemas: 8
237
+ valid_schemas: 8
238
+ issues: []
239
+ schemas:
240
+ - "session.yaml"
241
+ - "handoff.yaml"
242
+ - "config.yaml"
243
+
244
+ directory_structure:
245
+ status: "healthy"
246
+ all_present: true
247
+ directories:
248
+ - path: ".chati/"
249
+ exists: true
250
+ writable: true
251
+ - path: ".chati/artifacts/"
252
+ exists: true
253
+ writable: true
254
+ - path: ".chati/artifacts/handoffs/"
255
+ exists: true
256
+ writable: true
257
+ files_count: 5
258
+ - path: ".chati/logs/"
259
+ exists: true
260
+ writable: true
261
+ - path: "chati.dev/agents/"
262
+ exists: true
263
+ files_count: 12
264
+
265
+ system_dependencies:
266
+ status: "healthy"
267
+ node_version: "22.22.0"
268
+ node_required: ">=18.0.0"
269
+ node_ok: true
270
+ ide: "Claude Code"
271
+ mcp_support: true
272
+ filesystem_permissions: "ok"
273
+
274
+ context_engine:
275
+ status: "healthy"
276
+ constitution_loadable: true
277
+ config_parsable: true
278
+ agents_loadable: true
279
+ yaml_parser: "ok"
280
+
281
+ constitution_validation:
282
+ status: "healthy"
283
+ articles_present: 11
284
+ article_xi_valid: true
285
+ mode_definitions: ["clarity", "build", "deploy"]
286
+ transition_rules_defined: true
287
+ quality_gates_specified: true
288
+
289
+ session_health:
290
+ status: "healthy"
291
+ session_exists: true
292
+ valid_yaml: true
293
+ schema_compliant: true
294
+ age_hours: 8
295
+ last_activity: "2026-02-13T02:15:00Z"
296
+ corruption_indicators: []
297
+
298
+ issues_found: []
299
+
300
+ recommendations:
301
+ - "Framework is healthy and ready for use"
302
+ - "Session is active and recent (8 hours old)"
303
+ - "All 12 agents are properly defined"
304
+
305
+ quick_fixes: []
306
+
307
+ summary: |
308
+ ✓ Framework Health: HEALTHY
309
+
310
+ All core components validated successfully:
311
+ - Constitution with 11 articles
312
+ - 12 agent definitions
313
+ - 35 task definitions
314
+ - 8 schema files
315
+ - Session active and valid
316
+
317
+ System dependencies met:
318
+ - Node.js 22.22.0 (>= 18.0.0 required)
319
+ - IDE: Claude Code with MCP support
320
+ - Filesystem permissions: OK
321
+
322
+ No issues found. Framework ready for use.
323
+ ```
324
+
325
+ ### Example: Degraded State
326
+
327
+ ```yaml
328
+ health_report:
329
+ overall_status: "degraded"
330
+
331
+ issues_found:
332
+ - severity: "warning"
333
+ component: "agent-definitions"
334
+ issue: "architect.yaml has deprecated MCP 'gdrive' listed as required"
335
+ impact: "Agent may fail if gdrive MCP not configured"
336
+ fix: "Update agent definition or install gdrive MCP"
337
+
338
+ - severity: "warning"
339
+ component: "session"
340
+ issue: "Session is 15 days old"
341
+ impact: "Configuration may be stale"
342
+ fix: "Validate session or start fresh"
343
+
344
+ recommendations:
345
+ - "Update architect.yaml MCP requirements"
346
+ - "Consider refreshing stale session"
347
+ - "Framework functional but has minor issues"
348
+ ```
349
+
350
+ ### Example: Critical State
351
+
352
+ ```yaml
353
+ health_report:
354
+ overall_status: "critical"
355
+
356
+ issues_found:
357
+ - severity: "critical"
358
+ component: "constitution"
359
+ issue: "constitution.md not found"
360
+ impact: "Framework cannot operate without governance rules"
361
+ fix: "Run installer or restore from framework source"
362
+
363
+ - severity: "error"
364
+ component: "agent-definitions"
365
+ issue: "5 of 12 agent files missing"
366
+ impact: "Pipeline cannot execute"
367
+ fix: "Reinstall framework"
368
+
369
+ recommendations:
370
+ - "CRITICAL: Run framework installer immediately"
371
+ - "Framework is not operational"
372
+ ```
@@ -0,0 +1,262 @@
1
+ ---
2
+ id: orchestrator-mode-switch
3
+ agent: orchestrator
4
+ trigger: orchestrator-internal
5
+ phase: all
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [mode-transition]
9
+ handoff_to: null
10
+ autonomous_gate: true
11
+ criteria:
12
+ - Transition conditions validated
13
+ - Article XI rules enforced
14
+ - Session mode updated
15
+ - New scope applied
16
+ ---
17
+
18
+ # Orchestrator Mode Switch Task
19
+
20
+ ## Purpose
21
+ Execute transitions between modes (clarity, build, deploy) while enforcing Article XI governance rules and validating quality gates.
22
+
23
+ ## Prerequisites
24
+ - Session state at `.chati/session.yaml`
25
+ - Constitution Article XI at `chati.dev/constitution.md`
26
+ - Quality scores from QA agents
27
+ - Agent completion statuses
28
+
29
+ ## Steps
30
+
31
+ ### 1. Receive Transition Trigger
32
+ Identify the transition request:
33
+ - **Autonomous**: Quality gate met, auto-transition enabled
34
+ - **Suggested**: Conditions met, awaiting user confirmation
35
+ - **Manual**: User explicitly requests mode change
36
+ - **Backward**: QA-Implementation found spec issues, reverting to clarity
37
+
38
+ ### 2. Load Current Mode State
39
+ Read session to understand current position:
40
+ - Current mode (clarity/build/deploy)
41
+ - Last completed agent in current mode
42
+ - Quality scores
43
+ - Mode transition history
44
+
45
+ ### 3. Validate Transition Direction
46
+ Check if transition is valid per Article XI:
47
+ - **Forward transitions**: clarity → build, build → validate, validate → deploy
48
+ - **Backward transitions**: build/validate → clarity (on spec issues)
49
+ - **Invalid**: deploy → build, build → clarity (except on QA failure)
50
+
51
+ ### 4. Check Transition Preconditions
52
+ Verify mode-specific requirements are met:
53
+
54
+ **For clarity → build**:
55
+ - QA-Planning agent completed
56
+ - QA-Planning score >= 95%
57
+ - All CLARITY agents complete or skipped
58
+ - No blocking issues
59
+
60
+ **For build → validate**:
61
+ - Dev agent completed
62
+ - All build outputs present
63
+ - No critical errors
64
+
65
+ **For validate → deploy**:
66
+ - QA-Implementation agent completed
67
+ - QA-Implementation approved (score >= 8.0)
68
+ - No deployment blockers
69
+
70
+ **For backward to clarity**:
71
+ - QA-Implementation found spec/architecture issues
72
+ - Issues documented in handoff
73
+ - User confirmation obtained (if manual)
74
+
75
+ ### 5. Evaluate Autonomous Gate
76
+ Check if transition should be automatic:
77
+ - Article XI specifies autonomous transitions for forward moves when gates met
78
+ - Backward transitions require user confirmation
79
+ - Manual overrides require deviation protocol
80
+
81
+ ### 6. Calculate Confidence Score
82
+ Assess readiness for transition:
83
+ - Quality scores from QA agents
84
+ - Completeness of artifacts
85
+ - Number of open questions
86
+ - Blocker status
87
+ - Return confidence: high (>90%), medium (70-90%), low (<70%)
88
+
89
+ ### 7. Execute or Suggest Transition
90
+ Based on autonomous_gate and confidence:
91
+ - **Auto-transition**: confidence high + autonomous enabled → execute
92
+ - **Suggest**: confidence medium OR manual trigger → ask user
93
+ - **Block**: confidence low → escalate with issues
94
+
95
+ ### 8. Update Session Mode
96
+ If transition approved:
97
+ - Change `mode` field in session.yaml
98
+ - Set `current_agent` to first agent of new mode
99
+ - Log transition in `mode_transitions` array
100
+ - Update `pipeline_position`
101
+
102
+ ### 9. Apply Mode Scope Restrictions
103
+ Enforce Article XI scope rules for new mode:
104
+ - **clarity**: Read all, write only to `chati.dev/` directory
105
+ - **build**: Full filesystem access
106
+ - **deploy**: Full access + infrastructure operations
107
+
108
+ ### 10. Dispatch to Next Agent
109
+ Route to first agent of new mode:
110
+ - **build mode**: Route to `dev` agent
111
+ - **deploy mode**: Route to `devops` agent
112
+ - **clarity mode** (backward): Route to agent that needs rework
113
+
114
+ ## Decision Points
115
+
116
+ ### When Quality Gate is Borderline
117
+ If QA score is 94% (just under 95% threshold):
118
+ 1. Check if issues are minor vs. critical
119
+ 2. For minor: Suggest override with warning
120
+ 3. For critical: Block transition, require rework
121
+
122
+ ### When User Requests Override
123
+ If user wants to force transition despite low confidence:
124
+ 1. Trigger deviation protocol
125
+ 2. Document override in audit trail
126
+ 3. Require explicit confirmation
127
+ 4. Proceed with warning flags
128
+
129
+ ### When Backward Transition is Needed
130
+ If QA-Implementation finds fundamental spec problems:
131
+ 1. Identify which CLARITY agent needs to re-run
132
+ 2. Mark affected agents as `needs_revalidation`
133
+ 3. Set mode to `clarity`
134
+ 4. Route to earliest affected agent
135
+
136
+ ### When Multiple Transitions are Eligible
137
+ If conditions for multiple transitions are met (edge case):
138
+ 1. Follow pipeline sequence (clarity → build → deploy)
139
+ 2. Execute one transition at a time
140
+ 3. Re-evaluate after each transition
141
+
142
+ ## Error Handling
143
+
144
+ ### Invalid Transition Request
145
+ If transition violates Article XI:
146
+ - Block the transition
147
+ - Explain the violation
148
+ - Show valid transitions from current state
149
+
150
+ ### Quality Gate Data Missing
151
+ If QA score is not available:
152
+ - Assume gate not met
153
+ - Block autonomous transition
154
+ - Suggest running QA agent first
155
+
156
+ ### Session Update Failure
157
+ If mode can't be written to session:
158
+ - Retry with backup creation
159
+ - If persistent: Escalate, don't proceed
160
+ - Risk of mode desync is high
161
+
162
+ ### Agent Routing Failure
163
+ If first agent of new mode can't be loaded:
164
+ - Rollback mode change
165
+ - Escalate with agent definition error
166
+ - Validate framework integrity
167
+
168
+ ### Concurrent Transition Attempt
169
+ If another process is changing mode:
170
+ - Wait for lock (up to 30 seconds)
171
+ - If timeout: Escalate with lock conflict
172
+ - Suggest retry
173
+
174
+ ## Output Format
175
+
176
+ ```yaml
177
+ mode_transition:
178
+ timestamp: "2026-02-13T15:45:00Z"
179
+ transition_id: "MT-001"
180
+ type: "autonomous" # or "suggested", "manual", "backward"
181
+
182
+ from_state:
183
+ mode: "clarity"
184
+ current_agent: "qa-planning"
185
+ pipeline_position: "CLARITY/qa-planning"
186
+
187
+ to_state:
188
+ mode: "build"
189
+ current_agent: "dev"
190
+ pipeline_position: "BUILD/dev"
191
+
192
+ trigger:
193
+ source: "qa-planning-completion"
194
+ condition: "QA-Planning score >= 95%"
195
+ autonomous_gate: true
196
+
197
+ validation:
198
+ transition_direction: "forward" # clarity → build
199
+ preconditions_met: true
200
+ quality_gate:
201
+ required_score: 95
202
+ actual_score: 97.5
203
+ passed: true
204
+ artifacts_complete: true
205
+ blockers: []
206
+
207
+ confidence:
208
+ score: 95
209
+ level: "high"
210
+ factors:
211
+ - "All CLARITY agents completed"
212
+ - "QA-Planning score excellent (97.5%)"
213
+ - "Only 2 minor open questions"
214
+ - "No blockers"
215
+
216
+ execution:
217
+ approved_by: "autonomous" # or "user"
218
+ approved_at: "2026-02-13T15:45:00Z"
219
+ session_updated: true
220
+ mode_changed: true
221
+ agent_routed: true
222
+
223
+ scope_enforcement:
224
+ previous_scope: "read-all, write chati.dev/ only"
225
+ new_scope: "full filesystem access"
226
+ restrictions_applied: true
227
+
228
+ routing:
229
+ next_agent: "dev"
230
+ context_package:
231
+ - ".chati/artifacts/handoffs/2026-02-13-qa-planning.md"
232
+ - ".chati/artifacts/planning/phases.yaml"
233
+ - ".chati/artifacts/planning/tasks.yaml"
234
+
235
+ session_updates:
236
+ mode: "build"
237
+ current_agent: "dev"
238
+ pipeline_position: "BUILD/dev"
239
+ mode_transitions:
240
+ - type: "autonomous-forward"
241
+ from: "clarity"
242
+ to: "build"
243
+ timestamp: "2026-02-13T15:45:00Z"
244
+ trigger: "qa-planning-score-97.5"
245
+ approved_by: "autonomous"
246
+
247
+ audit_trail:
248
+ article_xi_compliance: true
249
+ quality_gate_met: true
250
+ user_confirmation: false # not required for autonomous
251
+ deviation_protocol: false
252
+
253
+ user_notification: |
254
+ ✓ Mode Transition: CLARITY → BUILD
255
+
256
+ QA-Planning completed with score 97.5% (>= 95% required).
257
+ Autonomous transition to BUILD mode approved.
258
+
259
+ Next: Dev agent will begin implementation.
260
+
261
+ Scope updated: Full filesystem access now enabled.
262
+ ```