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,223 @@
1
+ ---
2
+ id: detail-nfr-extraction
3
+ agent: detail
4
+ trigger: detail-expand-prd
5
+ phase: clarity
6
+ requires_input: false
7
+ parallelizable: true
8
+ outputs: [nfr.yaml]
9
+ handoff_to: detail-edge-case-analysis
10
+ autonomous_gate: true
11
+ criteria:
12
+ - All NFR categories covered (performance, security, scalability, usability, reliability)
13
+ - Measurable metrics defined for each NFR
14
+ - Implementation approach outlined
15
+ ---
16
+ # Extract and Detail Non-Functional Requirements
17
+
18
+ ## Purpose
19
+ Expand high-level NFRs from brief into detailed, measurable technical specifications.
20
+
21
+ ## Prerequisites
22
+ - `brief.yaml` with initial NFRs
23
+ - `prd-draft.yaml` for context
24
+
25
+ ## Steps
26
+
27
+ ### 1. Analyze Brief NFRs
28
+ Load and categorize existing NFRs into standard categories.
29
+
30
+ ### 2. Define Performance NFRs
31
+ - **Response Time**: API endpoints <200ms p50, <500ms p95
32
+ - **Page Load**: Initial load <2s, subsequent <1s
33
+ - **Time to Interactive**: <3s on 3G network
34
+ - **Database Queries**: <100ms for simple queries, <500ms for complex
35
+ - **Search**: Results in <1s for 100k posts
36
+ - **Concurrent Users**: 10k concurrent without degradation
37
+
38
+ ### 3. Define Security NFRs
39
+ - **Authentication**: JWT with 7-day expiration, refresh token support
40
+ - **Password Storage**: Bcrypt with 12 rounds
41
+ - **HTTPS**: All traffic encrypted (TLS 1.3)
42
+ - **XSS Protection**: Content Security Policy headers
43
+ - **SQL Injection**: Parameterized queries only
44
+ - **CSRF**: Token-based protection
45
+ - **Rate Limiting**: 100 req/min per IP, 1000 req/min per user
46
+ - **GDPR**: Data export, deletion, consent management
47
+
48
+ ### 4. Define Scalability NFRs
49
+ - **Horizontal Scaling**: Stateless API for easy scaling
50
+ - **Database**: Connection pooling, read replicas (future)
51
+ - **Caching**: Redis for frequently accessed data
52
+ - **CDN**: Static assets served from CDN
53
+ - **Data Growth**: Support 1M posts, 100k users
54
+
55
+ ### 5. Define Usability NFRs
56
+ - **Accessibility**: WCAG 2.1 AA compliance
57
+ - **Mobile**: Responsive design, works on screens ≥320px
58
+ - **Browser Support**: Chrome, Firefox, Safari, Edge (last 2 versions)
59
+ - **Internationalization**: UI prepared for i18n (future)
60
+ - **Error Messages**: Clear, actionable, user-friendly
61
+
62
+ ### 6. Define Reliability NFRs
63
+ - **Uptime**: 99.5% (43 hours downtime/year)
64
+ - **Backup**: Daily automated backups, 30-day retention
65
+ - **Error Recovery**: Graceful degradation, retry logic
66
+ - **Data Integrity**: Transactions for critical operations
67
+ - **Monitoring**: Uptime checks every minute
68
+
69
+ ### 7. Define Maintainability NFRs
70
+ - **Code Coverage**: >80% test coverage
71
+ - **Documentation**: API docs, README, architecture docs
72
+ - **Logging**: Structured logging with correlation IDs
73
+ - **Deployment**: Zero-downtime deployments
74
+ - **Observability**: Metrics, traces, logs
75
+
76
+ ### 8. Add Measurable Metrics
77
+ For each NFR, define:
78
+ - Metric name (response_time_p95)
79
+ - Target value (500ms)
80
+ - Measurement method (APM tool)
81
+ - Acceptance criteria (pass/fail threshold)
82
+
83
+ ### 9. Outline Implementation Approaches
84
+ For each NFR category, suggest technical approaches.
85
+
86
+ ### 10. Generate NFR Document
87
+ Comprehensive, measurable NFR specifications.
88
+
89
+ ## Decision Points
90
+ None - autonomous based on best practices.
91
+
92
+ ## Error Handling
93
+ - **Conflicting NFRs**: Note conflict and recommend resolution
94
+
95
+ ## Output Format
96
+ ```yaml
97
+ # nfr.yaml
98
+ timestamp: 2026-02-13T15:00:00Z
99
+
100
+ performance:
101
+ - id: NFR-PERF-001
102
+ requirement: API response time <200ms (p50), <500ms (p95)
103
+ metric: api_response_time
104
+ target_p50: 200ms
105
+ target_p95: 500ms
106
+ measurement: APM tool (Datadog, New Relic, or Prometheus)
107
+ implementation:
108
+ - Optimize database queries with indexes
109
+ - Use connection pooling
110
+ - Implement caching for frequently accessed data
111
+ - Use efficient data serialization (JSON)
112
+ - id: NFR-PERF-002
113
+ requirement: Initial page load <2s, subsequent <1s
114
+ metric: page_load_time
115
+ target_initial: 2s
116
+ target_subsequent: 1s
117
+ measurement: Lighthouse, WebPageTest
118
+ implementation:
119
+ - Code splitting and lazy loading
120
+ - Image optimization and lazy loading
121
+ - Asset minification and compression (gzip/brotli)
122
+ - CDN for static assets
123
+ - Service Worker caching
124
+
125
+ security:
126
+ - id: NFR-SEC-001
127
+ requirement: All connections use HTTPS with TLS 1.3
128
+ implementation: Configure hosting provider for HTTPS, redirect HTTP → HTTPS
129
+ - id: NFR-SEC-002
130
+ requirement: Passwords hashed with bcrypt (12 rounds)
131
+ implementation: Use bcrypt library, never store plaintext passwords
132
+ - id: NFR-SEC-003
133
+ requirement: JWT authentication with 7-day expiration
134
+ implementation: Use jsonwebtoken library, include expiration claim
135
+ - id: NFR-SEC-004
136
+ requirement: Rate limiting (100 req/min per IP, 1000/min per user)
137
+ implementation: Use express-rate-limit middleware
138
+ - id: NFR-SEC-005
139
+ requirement: GDPR compliance (data export, deletion, consent)
140
+ implementation:
141
+ - API endpoint for data export (JSON format)
142
+ - Soft delete with cascading to related data
143
+ - Consent management UI
144
+ - Cookie banner for analytics (future)
145
+
146
+ scalability:
147
+ - id: NFR-SCALE-001
148
+ requirement: Support 10,000 concurrent users
149
+ metric: concurrent_users
150
+ target: 10000
151
+ implementation:
152
+ - Stateless API design
153
+ - Database connection pooling (max 100 connections)
154
+ - Horizontal scaling via load balancer
155
+ - id: NFR-SCALE-002
156
+ requirement: Handle 1M posts, 100k users
157
+ metric: data_volume
158
+ target: 1M posts, 100k users
159
+ implementation:
160
+ - Database indexing on frequently queried columns
161
+ - Pagination for list endpoints
162
+ - Archive old data (posts >3 years)
163
+
164
+ usability:
165
+ - id: NFR-USA-001
166
+ requirement: WCAG 2.1 AA accessibility compliance
167
+ measurement: Lighthouse accessibility score >90, manual testing
168
+ implementation:
169
+ - Semantic HTML
170
+ - ARIA labels on interactive elements
171
+ - Keyboard navigation support
172
+ - Sufficient color contrast (4.5:1)
173
+ - Alt text for all images
174
+ - id: NFR-USA-002
175
+ requirement: Mobile responsive (320px+)
176
+ measurement: Test on real devices and browser DevTools
177
+ implementation:
178
+ - Mobile-first CSS
179
+ - Responsive breakpoints (320, 768, 1024, 1440)
180
+ - Touch-friendly targets (44×44px minimum)
181
+
182
+ reliability:
183
+ - id: NFR-REL-001
184
+ requirement: 99.5% uptime (max 43 hours downtime/year)
185
+ metric: uptime_percentage
186
+ target: 99.5%
187
+ measurement: Uptime monitoring service (UptimeRobot, Pingdom)
188
+ implementation:
189
+ - Health check endpoint (/api/health)
190
+ - Automated failover
191
+ - Zero-downtime deployments
192
+ - id: NFR-REL-002
193
+ requirement: Daily automated backups with 30-day retention
194
+ implementation: Supabase automated backups, test recovery quarterly
195
+
196
+ maintainability:
197
+ - id: NFR-MAINT-001
198
+ requirement: >80% test coverage
199
+ metric: code_coverage
200
+ target: 80%
201
+ measurement: Coverage tool (Istanbul, c8)
202
+ - id: NFR-MAINT-002
203
+ requirement: Zero-downtime deployments
204
+ implementation: Blue-green deployment or rolling updates
205
+
206
+ implementation_priority:
207
+ p0_must_have:
208
+ - HTTPS encryption
209
+ - Password hashing
210
+ - JWT authentication
211
+ - Rate limiting
212
+ - WCAG compliance
213
+ - Mobile responsive
214
+ p1_should_have:
215
+ - Performance targets
216
+ - Backup strategy
217
+ - Monitoring
218
+ - Test coverage
219
+ p2_nice_to_have:
220
+ - Advanced caching
221
+ - CDN
222
+ - Read replicas
223
+ ```
@@ -0,0 +1,404 @@
1
+ ---
2
+ id: dev-code-review
3
+ agent: dev
4
+ trigger: dev-debug
5
+ phase: build
6
+ requires_input: false
7
+ parallelizable: false
8
+ outputs: [review-report.yaml]
9
+ handoff_to: dev-pr-prepare
10
+ autonomous_gate: true
11
+ criteria:
12
+ - Follows architecture
13
+ - No security issues
14
+ - Code style consistent
15
+ ---
16
+ # Self Code Review
17
+
18
+ ## Purpose
19
+ Perform thorough self-review of implementation against architecture decisions, security best practices, and code quality standards before preparing PR.
20
+
21
+ ## Prerequisites
22
+ - All tests passing
23
+ - Debugging complete
24
+ - Architecture artifacts available at `.chati/artifacts/architecture/`
25
+ - Security checklist available
26
+ - Code style guide accessible
27
+
28
+ ## Steps
29
+
30
+ ### 1. Review Against Architecture
31
+ Verify implementation aligns with architectural decisions:
32
+ - Read architecture artifacts
33
+ - Check folder structure matches conventions
34
+ - Verify module boundaries respected
35
+ - Confirm design patterns applied correctly
36
+ - Validate technology choices followed
37
+
38
+ ### 2. Check API Contracts
39
+ Ensure interfaces match specifications:
40
+ - Review API endpoint signatures
41
+ - Verify request/response formats
42
+ - Check status codes
43
+ - Validate error responses
44
+ - Confirm backward compatibility
45
+
46
+ ### 3. Review Data Models
47
+ Validate data structures and schemas:
48
+ - Check database schema alignment
49
+ - Verify type definitions complete
50
+ - Ensure validation rules implemented
51
+ - Review relationships and constraints
52
+ - Confirm migrations needed (if applicable)
53
+
54
+ ### 4. Security Review
55
+ Audit code for security vulnerabilities:
56
+
57
+ **Input Validation**
58
+ - All user input validated
59
+ - Sanitization applied where needed
60
+ - Type checking enforced
61
+ - Length limits imposed
62
+ - Format validation present
63
+
64
+ **Authentication/Authorization**
65
+ - Authentication checks in place
66
+ - Authorization verified before operations
67
+ - Tokens handled securely
68
+ - Session management correct
69
+ - No hardcoded credentials
70
+
71
+ **Data Protection**
72
+ - Sensitive data encrypted
73
+ - Passwords hashed (never plain text)
74
+ - SQL injection prevented (parameterized queries)
75
+ - XSS prevented (output sanitization)
76
+ - CSRF protection if applicable
77
+
78
+ **Dependencies**
79
+ - No known vulnerable dependencies
80
+ - Minimal dependency footprint
81
+ - Dependencies from trusted sources
82
+ - Lock file committed
83
+
84
+ ### 5. Performance Review
85
+ Check for obvious performance issues:
86
+ - No N+1 query problems
87
+ - Appropriate use of indexes
88
+ - Efficient algorithms chosen
89
+ - No unnecessary loops
90
+ - Lazy loading where appropriate
91
+ - Caching considered
92
+
93
+ ### 6. Error Handling Review
94
+ Verify robust error management:
95
+ - Try-catch around risky operations
96
+ - Meaningful error messages
97
+ - Proper error propagation
98
+ - No swallowed errors
99
+ - Cleanup in finally blocks
100
+ - Graceful degradation
101
+
102
+ ### 7. Code Style Review
103
+ Ensure consistency with codebase:
104
+ - Naming conventions followed
105
+ - Indentation consistent
106
+ - File organization standard
107
+ - Comment style matches
108
+ - Import order correct
109
+ - No dead code
110
+
111
+ ### 8. Documentation Review
112
+ Check for adequate documentation:
113
+ - Public APIs documented
114
+ - Complex logic explained
115
+ - Type definitions clear
116
+ - README updated if needed
117
+ - Breaking changes noted
118
+ - Migration guide if needed
119
+
120
+ ### 9. Testing Review
121
+ Validate test quality:
122
+ - All acceptance criteria tested
123
+ - Edge cases covered
124
+ - Error scenarios tested
125
+ - Test names descriptive
126
+ - No redundant tests
127
+ - Tests are maintainable
128
+
129
+ ### 10. Accessibility Review (if UI)
130
+ For user-facing components:
131
+ - Semantic HTML used
132
+ - ARIA labels present
133
+ - Keyboard navigation works
134
+ - Color contrast sufficient
135
+ - Screen reader friendly
136
+ - Focus management correct
137
+
138
+ ### 11. Create Review Checklist
139
+ Score implementation against criteria:
140
+
141
+ ```yaml
142
+ architecture_compliance: 9/10
143
+ security_score: 10/10
144
+ performance_score: 8/10
145
+ code_quality_score: 9/10
146
+ testing_score: 9/10
147
+ documentation_score: 7/10
148
+ ```
149
+
150
+ ### 12. Document Findings
151
+ Record issues and improvements:
152
+ - List critical issues (must fix)
153
+ - List improvements (should fix)
154
+ - List nice-to-haves (optional)
155
+ - Note strengths
156
+ - Identify tech debt
157
+
158
+ ## Decision Points
159
+
160
+ ### When Critical Issues Found
161
+ If security or architecture violations discovered:
162
+ 1. Fix immediately
163
+ 2. Re-run tests
164
+ 3. Update affected documentation
165
+ 4. Note in review report
166
+ 5. Don't proceed to PR until resolved
167
+
168
+ ### When Performance Concerns Arise
169
+ If performance issues identified:
170
+ 1. Assess severity
171
+ 2. Profile if needed
172
+ 3. Fix if critical
173
+ 4. Document if acceptable
174
+ 5. Plan optimization if needed later
175
+
176
+ ### When Documentation is Lacking
177
+ If docs are insufficient:
178
+ 1. Add missing documentation
179
+ 2. Update README if needed
180
+ 3. Add code comments
181
+ 4. Create examples
182
+ 5. Note in review report
183
+
184
+ ## Error Handling
185
+
186
+ ### Architecture Violations Found
187
+ - Document the violation
188
+ - Understand the impact
189
+ - Propose fix
190
+ - May need to loop back to architect
191
+ - Get approval for major changes
192
+
193
+ ### Security Issues Discovered
194
+ - Fix immediately
195
+ - Don't compromise on security
196
+ - Research best practices
197
+ - Add tests for security scenarios
198
+ - Document security measures
199
+
200
+ ### Style Inconsistencies
201
+ - Run auto-formatter
202
+ - Apply lint fixes
203
+ - Manually adjust remaining issues
204
+ - Update style guide if needed
205
+ - Ensure consistency
206
+
207
+ ### Test Coverage Gaps
208
+ - Add missing tests
209
+ - Update test report
210
+ - Verify new tests pass
211
+ - Check coverage metrics
212
+ - Document test strategy
213
+
214
+ ## Output Format
215
+
216
+ Create `.chati/artifacts/build/review-report.yaml`:
217
+
218
+ ```yaml
219
+ task_id: "3.2.1"
220
+ agent: dev
221
+ action: code-review
222
+ timestamp: "2026-02-13T13:30:00Z"
223
+ duration_minutes: 45
224
+
225
+ reviewer: dev
226
+ review_type: self-review
227
+ scope: complete_implementation
228
+
229
+ architecture_review:
230
+ score: 9
231
+ compliant: true
232
+ findings:
233
+ - aspect: "Module structure"
234
+ status: pass
235
+ notes: "Follows established patterns"
236
+ - aspect: "Design patterns"
237
+ status: pass
238
+ notes: "Repository pattern correctly applied"
239
+ - aspect: "Dependency injection"
240
+ status: pass
241
+ notes: "Clean dependency management"
242
+ issues: []
243
+
244
+ security_review:
245
+ score: 10
246
+ critical_issues: 0
247
+ findings:
248
+ - category: "Input Validation"
249
+ status: pass
250
+ notes: "All inputs validated using Zod schemas"
251
+ - category: "SQL Injection"
252
+ status: pass
253
+ notes: "Parameterized queries used throughout"
254
+ - category: "XSS Prevention"
255
+ status: pass
256
+ notes: "HTML sanitization applied to message content"
257
+ - category: "Authentication"
258
+ status: pass
259
+ notes: "JWT validation on protected routes"
260
+ - category: "Secrets Management"
261
+ status: pass
262
+ notes: "No hardcoded credentials, uses environment variables"
263
+ recommendations:
264
+ - "Consider adding rate limiting for message endpoints"
265
+ - "Add CORS configuration for production"
266
+
267
+ performance_review:
268
+ score: 8
269
+ findings:
270
+ - aspect: "Database queries"
271
+ status: good
272
+ notes: "Efficient queries, proper indexing considered"
273
+ - aspect: "Algorithm complexity"
274
+ status: good
275
+ notes: "O(n) or better for all operations"
276
+ - aspect: "Memory usage"
277
+ status: good
278
+ notes: "No obvious memory leaks"
279
+ concerns:
280
+ - description: "Message list pagination not implemented"
281
+ impact: medium
282
+ plan: "Will add in Phase 4"
283
+ optimizations_applied:
284
+ - "Used database indexes for message queries"
285
+ - "Implemented connection pooling"
286
+
287
+ code_quality_review:
288
+ score: 9
289
+ maintainability_index: 82
290
+ findings:
291
+ - aspect: "Code duplication"
292
+ status: excellent
293
+ metric: "2.3% duplication"
294
+ - aspect: "Function length"
295
+ status: excellent
296
+ metric: "Average 18 lines, max 45 lines"
297
+ - aspect: "Complexity"
298
+ status: good
299
+ metric: "Cyclomatic complexity < 10"
300
+ - aspect: "Naming"
301
+ status: excellent
302
+ notes: "Clear, descriptive names throughout"
303
+ minor_issues:
304
+ - description: "Could extract message formatting to utility"
305
+ severity: low
306
+ file: "chat-service.ts"
307
+
308
+ testing_review:
309
+ score: 9
310
+ coverage: 89.2
311
+ findings:
312
+ - aspect: "Unit tests"
313
+ status: excellent
314
+ count: 12
315
+ - aspect: "Integration tests"
316
+ status: good
317
+ count: 8
318
+ - aspect: "Edge cases"
319
+ status: excellent
320
+ notes: "Null, empty, max length all tested"
321
+ - aspect: "Error scenarios"
322
+ status: excellent
323
+ notes: "All error paths tested"
324
+ improvements:
325
+ - "Could add performance tests for large message volumes"
326
+
327
+ documentation_review:
328
+ score: 7
329
+ findings:
330
+ - aspect: "Code comments"
331
+ status: good
332
+ notes: "Complex logic documented"
333
+ - aspect: "API documentation"
334
+ status: adequate
335
+ notes: "JSDoc present for public methods"
336
+ - aspect: "README"
337
+ status: needs_update
338
+ notes: "Should document new chat module"
339
+ action_items:
340
+ - "Add chat module section to README"
341
+ - "Document WebSocket event schema"
342
+ - "Add usage examples"
343
+
344
+ style_consistency:
345
+ score: 10
346
+ lint_status: pass
347
+ prettier_status: pass
348
+ findings:
349
+ - "Code style consistent with project conventions"
350
+ - "Import order follows ESLint rules"
351
+ - "File organization matches project structure"
352
+
353
+ critical_issues: []
354
+
355
+ recommended_improvements:
356
+ - description: "Add README section for chat module"
357
+ priority: should_fix
358
+ effort: small
359
+ - description: "Extract message formatting utility"
360
+ priority: nice_to_have
361
+ effort: small
362
+ - description: "Add rate limiting"
363
+ priority: should_fix
364
+ effort: medium
365
+ timing: "Before production deployment"
366
+
367
+ strengths:
368
+ - "Excellent test coverage"
369
+ - "Clean separation of concerns"
370
+ - "Strong type safety"
371
+ - "Good error handling"
372
+ - "Security best practices followed"
373
+
374
+ technical_debt:
375
+ - description: "Message pagination will be needed at scale"
376
+ severity: low
377
+ planned_fix: "Phase 4"
378
+ - description: "WebSocket reconnection logic could be more robust"
379
+ severity: low
380
+ planned_fix: "Future iteration"
381
+
382
+ overall_assessment: |
383
+ Implementation is production-ready. Code quality is high, security
384
+ practices are solid, and testing is comprehensive. Minor documentation
385
+ improvements recommended but not blocking. Architecture compliance
386
+ is excellent.
387
+
388
+ ready_for_pr: true
389
+
390
+ next_steps:
391
+ - "Add README documentation for chat module"
392
+ - "Prepare pull request description"
393
+ - "Create changelog entry"
394
+ ```
395
+
396
+ ## Success Criteria
397
+ - Architecture compliance verified
398
+ - No critical security issues
399
+ - Code style is consistent
400
+ - All review categories scored
401
+ - Issues categorized by severity
402
+ - Strengths identified
403
+ - Ready for PR confirmed
404
+ - Review report is complete and thorough