codex-genesis-harness 0.1.1 → 0.1.4

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 (180) hide show
  1. package/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -0
  2. package/.codebase/CURRENT_STATE.md +2 -0
  3. package/.codebase/DOMAIN_MODELS.md +5 -3
  4. package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -0
  5. package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -0
  6. package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -0
  7. package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -0
  8. package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -0
  9. package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -0
  10. package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -0
  11. package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -0
  12. package/.codebase/README.md +139 -0
  13. package/.codebase/RECOVERY_POINTS.md +438 -0
  14. package/.codex/skills/genesis-api-sync/SKILL.md +354 -0
  15. package/.codex/skills/genesis-api-sync/agents/openai.yaml +7 -0
  16. package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -0
  17. package/.codex/skills/genesis-api-sync/examples/example.md +68 -0
  18. package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -0
  19. package/.codex/skills/genesis-debug-guide/SKILL.md +479 -0
  20. package/.codex/skills/genesis-debug-guide/agents/openai.yaml +7 -0
  21. package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -0
  22. package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -0
  23. package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -0
  24. package/.codex/skills/genesis-debug-guide/examples/example.md +48 -0
  25. package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -0
  26. package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -0
  27. package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -0
  28. package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -0
  29. package/.codex/skills/genesis-docs-automation/agents/openai.yaml +7 -0
  30. package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -0
  31. package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -0
  32. package/.codex/skills/genesis-docs-automation/examples/example.md +59 -0
  33. package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -0
  34. package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -0
  35. package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -0
  36. package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -0
  37. package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -0
  38. package/.codex/skills/genesis-harness/SKILL.md +734 -82
  39. package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -0
  40. package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -0
  41. package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -0
  42. package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -0
  43. package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -0
  44. package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -0
  45. package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -0
  46. package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -0
  47. package/.codex/skills/genesis-harness/scripts/check-architecture-boundaries.sh +23 -23
  48. package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +24 -24
  49. package/.codex/skills/genesis-harness/scripts/check-no-debug-logs.sh +21 -21
  50. package/.codex/skills/genesis-harness/scripts/check-required-planning-files.sh +46 -46
  51. package/.codex/skills/genesis-harness/scripts/check-spec-changelog.sh +24 -24
  52. package/.codex/skills/genesis-harness/scripts/check-task-tracking.sh +25 -25
  53. package/.codex/skills/genesis-harness/scripts/compact-context.sh +54 -0
  54. package/.codex/skills/genesis-harness/scripts/create-adr.sh +74 -74
  55. package/.codex/skills/genesis-harness/scripts/create-bug.sh +160 -160
  56. package/.codex/skills/genesis-harness/scripts/create-feature.sh +217 -217
  57. package/.codex/skills/genesis-harness/scripts/detect-stack.sh +26 -26
  58. package/.codex/skills/genesis-harness/scripts/init-planning.sh +750 -719
  59. package/.codex/skills/genesis-harness/scripts/list-changed-files.sh +12 -12
  60. package/.codex/skills/genesis-harness/scripts/offload-log.sh +72 -0
  61. package/.codex/skills/genesis-harness/scripts/run-verification.sh +47 -47
  62. package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +75 -0
  63. package/.codex/skills/genesis-harness/scripts/update-state.sh +33 -33
  64. package/.codex/skills/genesis-harness-engineering/SKILL.md +159 -0
  65. package/.codex/skills/genesis-harness-engineering/checklists/checklist.md +48 -0
  66. package/.codex/skills/genesis-harness-engineering/examples/example.md +57 -0
  67. package/.codex/skills/genesis-harness-engineering/playbooks/harness-evolution.md +99 -0
  68. package/.codex/skills/genesis-harness-engineering/templates/harness-change-template.md +37 -0
  69. package/.codex/skills/genesis-observability-automation/SKILL.md +382 -0
  70. package/.codex/skills/genesis-observability-automation/agents/openai.yaml +7 -0
  71. package/.codex/skills/genesis-observability-automation/examples/example.md +86 -0
  72. package/.codex/skills/genesis-performance-profiling/SKILL.md +510 -0
  73. package/.codex/skills/genesis-performance-profiling/agents/openai.yaml +6 -0
  74. package/.codex/skills/genesis-performance-profiling/checklists/optimization-verification.md +199 -0
  75. package/.codex/skills/genesis-performance-profiling/checklists/performance-baseline.md +183 -0
  76. package/.codex/skills/genesis-performance-profiling/examples/example.md +234 -0
  77. package/.codex/skills/genesis-performance-profiling/observability/performance-tracking.md +202 -0
  78. package/.codex/skills/genesis-performance-profiling/playbooks/load-testing-orchestration.md +593 -0
  79. package/.codex/skills/genesis-performance-profiling/playbooks/profiling-playbook.md +601 -0
  80. package/.codex/skills/genesis-performance-profiling/templates/load-test-config-template.md +428 -0
  81. package/.codex/skills/genesis-performance-profiling/templates/performance-report-template.md +238 -0
  82. package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -0
  83. package/.codex/skills/genesis-release-orchestration/agents/openai.yaml +7 -0
  84. package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -0
  85. package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -0
  86. package/.codex/skills/genesis-release-orchestration/examples/example.md +78 -0
  87. package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -0
  88. package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -0
  89. package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -0
  90. package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -0
  91. package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -0
  92. package/.codex/skills/genesis-research-first/SKILL.md +237 -0
  93. package/.codex/skills/genesis-research-first/agents/openai.yaml +7 -0
  94. package/.codex/skills/genesis-research-first/examples/example.md +85 -0
  95. package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -0
  96. package/.codex/skills/genesis-spec-propagation/agents/openai.yaml +7 -0
  97. package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -0
  98. package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -0
  99. package/.codex/skills/genesis-spec-propagation/examples/example.md +63 -0
  100. package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -0
  101. package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -0
  102. package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -0
  103. package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -0
  104. package/.codex/skills/spec-impact-engine/SKILL.md +504 -0
  105. package/.codex/skills/spec-impact-engine/agents/openai.yaml +7 -0
  106. package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +262 -0
  107. package/.codex/skills/spec-impact-engine/examples/example.md +98 -0
  108. package/.codex/skills/spec-impact-engine/templates/impact-report.md +248 -0
  109. package/.codex/skills/spec-impact-engine/templates/migration-guide.md +223 -0
  110. package/.codex-plugin/plugin.json +1 -1
  111. package/README.EN.md +719 -0
  112. package/README.VI.md +712 -0
  113. package/README.md +261 -107
  114. package/VERSION +1 -1
  115. package/bin/genesis-harness.js +20 -11
  116. package/package.json +1 -1
  117. package/scripts/README.md +342 -0
  118. package/scripts/compact-context.sh +54 -0
  119. package/scripts/detect-changes.sh +152 -0
  120. package/scripts/install.sh +50 -41
  121. package/scripts/offload-log.sh +72 -0
  122. package/scripts/run-evals.sh +70 -43
  123. package/scripts/run-verify-loop.sh +75 -0
  124. package/scripts/uninstall.sh +52 -43
  125. package/scripts/verify.sh +165 -73
  126. package/.codex/skills/harness-engineering-skill/SKILL.md +0 -45
  127. package/.codex/skills/harness-engineering-skill/checklists/checklist.md +0 -8
  128. package/.codex/skills/harness-engineering-skill/examples/example.md +0 -4
  129. package/.codex/skills/harness-engineering-skill/templates/harness-change-template.md +0 -8
  130. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/SKILL.md +0 -0
  131. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/agents/openai.yaml +0 -0
  132. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/checklists/checklist.md +0 -0
  133. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/examples/example.md +0 -0
  134. /package/.codex/skills/{ai-provider-skill → genesis-ai-provider}/templates/provider-contract-template.md +0 -0
  135. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/SKILL.md +0 -0
  136. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/agents/openai.yaml +0 -0
  137. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/checklists/checklist.md +0 -0
  138. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/examples/example.md +0 -0
  139. /package/.codex/skills/{api-contract-skill → genesis-api-contract}/templates/api-contract-template.md +0 -0
  140. /package/.codex/skills/{architecture-skill → genesis-architecture}/SKILL.md +0 -0
  141. /package/.codex/skills/{architecture-skill → genesis-architecture}/agents/openai.yaml +0 -0
  142. /package/.codex/skills/{architecture-skill → genesis-architecture}/checklists/checklist.md +0 -0
  143. /package/.codex/skills/{architecture-skill → genesis-architecture}/examples/example.md +0 -0
  144. /package/.codex/skills/{architecture-skill → genesis-architecture}/templates/architecture-decision-template.md +0 -0
  145. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/SKILL.md +0 -0
  146. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/agents/openai.yaml +0 -0
  147. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/checklists/checklist.md +0 -0
  148. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/examples/example.md +0 -0
  149. /package/.codex/skills/{codebase-map-skill → genesis-codebase-map}/templates/map-update-template.md +0 -0
  150. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/SKILL.md +0 -0
  151. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/agents/openai.yaml +0 -0
  152. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/checklists/checklist.md +0 -0
  153. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/examples/example.md +0 -0
  154. /package/.codex/skills/{design-spec-skill → genesis-design-spec}/templates/design-spec-template.md +0 -0
  155. /package/.codex/skills/{docs-skill → genesis-docs}/SKILL.md +0 -0
  156. /package/.codex/skills/{docs-skill → genesis-docs}/agents/openai.yaml +0 -0
  157. /package/.codex/skills/{docs-skill → genesis-docs}/checklists/checklist.md +0 -0
  158. /package/.codex/skills/{docs-skill → genesis-docs}/examples/example.md +0 -0
  159. /package/.codex/skills/{docs-skill → genesis-docs}/templates/docs-update-template.md +0 -0
  160. /package/.codex/skills/{harness-engineering-skill → genesis-harness-engineering}/agents/openai.yaml +0 -0
  161. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/SKILL.md +0 -0
  162. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/agents/openai.yaml +0 -0
  163. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/checklists/checklist.md +0 -0
  164. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/examples/example.md +0 -0
  165. /package/.codex/skills/{pipeline-orchestration-skill → genesis-pipeline-orchestration}/templates/orchestration-template.md +0 -0
  166. /package/.codex/skills/{planning-skill → genesis-planning}/SKILL.md +0 -0
  167. /package/.codex/skills/{planning-skill → genesis-planning}/agents/openai.yaml +0 -0
  168. /package/.codex/skills/{planning-skill → genesis-planning}/checklists/checklist.md +0 -0
  169. /package/.codex/skills/{planning-skill → genesis-planning}/examples/example.md +0 -0
  170. /package/.codex/skills/{planning-skill → genesis-planning}/templates/plan-template.md +0 -0
  171. /package/.codex/skills/{release-skill → genesis-release}/SKILL.md +0 -0
  172. /package/.codex/skills/{release-skill → genesis-release}/agents/openai.yaml +0 -0
  173. /package/.codex/skills/{release-skill → genesis-release}/checklists/checklist.md +0 -0
  174. /package/.codex/skills/{release-skill → genesis-release}/examples/example.md +0 -0
  175. /package/.codex/skills/{release-skill → genesis-release}/templates/release-checklist-template.md +0 -0
  176. /package/.codex/skills/{research-skill → genesis-research}/SKILL.md +0 -0
  177. /package/.codex/skills/{research-skill → genesis-research}/agents/openai.yaml +0 -0
  178. /package/.codex/skills/{research-skill → genesis-research}/checklists/checklist.md +0 -0
  179. /package/.codex/skills/{research-skill → genesis-research}/examples/example.md +0 -0
  180. /package/.codex/skills/{research-skill → genesis-research}/templates/research-note-template.md +0 -0
@@ -0,0 +1,851 @@
1
+ # Playbook: Automated Docs Update Flow
2
+
3
+ **Purpose**: Complete walkthrough of the automatic documentation update process
4
+
5
+ **Time Estimate**: 35 minutes total execution (mostly automated)
6
+
7
+ **Trigger**: After tests pass (PostToolUse Hook #6) or manual `/update-docs` command
8
+
9
+ ---
10
+
11
+ ## 🎯 Complete Workflow
12
+
13
+ ### Phase 1: Change Detection (5 min)
14
+
15
+ **Step 1.1: Identify Changed Files**
16
+
17
+ ```bash
18
+ # Git diff since last stable state
19
+ $ git diff HEAD~1 --name-only
20
+
21
+ contracts/api/UserRegistration/request.json # CHANGED: Phase 1
22
+ contracts/api/UserRegistration/response.json # CHANGED: Phase 1
23
+ src/api/handlers/registerHandler.ts # CHANGED: Phase 3
24
+ src/client/AuthService.ts # CHANGED: Phase 4
25
+ tests/integration/auth.test.ts # CHANGED: Phase 2
26
+ playwright/e2e/registration.spec.ts # CHANGED: Phase 5
27
+ ```
28
+
29
+ **Step 1.2: Categorize by Phase**
30
+
31
+ ```
32
+ PHASE 1 (API Contract):
33
+ - contracts/api/UserRegistration/request.json
34
+ - contracts/api/UserRegistration/response.json
35
+
36
+ PHASE 2 (Tests):
37
+ - tests/integration/auth.test.ts
38
+
39
+ PHASE 3 (Backend Implementation):
40
+ - src/api/handlers/registerHandler.ts
41
+
42
+ PHASE 4 (SDK/Client):
43
+ - src/client/AuthService.ts
44
+
45
+ PHASE 5 (E2E Tests):
46
+ - playwright/e2e/registration.spec.ts
47
+ ```
48
+
49
+ **Step 1.3: Determine Doc Update Types**
50
+
51
+ ```
52
+ Phase 1 API Contract changed:
53
+ → Trigger: API_REFERENCE.md update
54
+
55
+ Phase 3 Backend handler changed:
56
+ → Trigger: IMPLEMENTATION.md update
57
+ → Trigger: ARCHITECTURE.md update
58
+
59
+ Phase 4 SDK changed:
60
+ → Trigger: Client SDK Reference update
61
+
62
+ All phases changed:
63
+ → Trigger: SPEC_CHANGELOG.md entry
64
+ → Trigger: IMPLEMENTATION_HANDOFF.md update
65
+
66
+ Initial detection complete ✓
67
+ ```
68
+
69
+ ---
70
+
71
+ ### Phase 2: Doc Type Analysis (10 min)
72
+
73
+ **Step 2.1: Analyze Each Changed File**
74
+
75
+ **File 1: contracts/api/UserRegistration/request.json**
76
+
77
+ ```json
78
+ {
79
+ "type": "object",
80
+ "properties": {
81
+ "email": { "type": "string", "format": "email" },
82
+ "password": { "type": "string", "minLength": 8 },
83
+ "name": { "type": "string" }
84
+ },
85
+ "required": ["email", "password"]
86
+ }
87
+ ```
88
+
89
+ **Analysis**:
90
+ - New required fields: `email`, `password`
91
+ - Optional fields: `name`
92
+ - No fields removed (FEATURE change)
93
+ - Backward compatible: ✓
94
+
95
+ **Action**: Generate API docs section
96
+
97
+ **File 2: contracts/api/UserRegistration/response.json**
98
+
99
+ ```json
100
+ {
101
+ "type": "object",
102
+ "properties": {
103
+ "id": { "type": "string", "format": "uuid" },
104
+ "email": { "type": "string" },
105
+ "name": { "type": "string" },
106
+ "createdAt": { "type": "string", "format": "date-time" }
107
+ },
108
+ "required": ["id", "email", "createdAt"]
109
+ }
110
+ ```
111
+
112
+ **Analysis**:
113
+ - Response includes user object
114
+ - Contains timestamps
115
+ - No sensitive fields (password not included)
116
+
117
+ **Action**: Generate API docs section
118
+
119
+ **File 3: src/api/handlers/registerHandler.ts**
120
+
121
+ ```typescript
122
+ export async function registerHandler(req: Request): Promise<Response> {
123
+ const { email, password, name } = req.body;
124
+
125
+ // Validation
126
+ if (!isValidEmail(email)) return response(400, { error: "Invalid email" });
127
+ if (password.length < 8) return response(422, { error: "Password too weak" });
128
+
129
+ // Check existence
130
+ const existing = await User.findByEmail(email);
131
+ if (existing) return response(409, { error: "Email already registered" });
132
+
133
+ // Create user
134
+ const user = await User.create({
135
+ email,
136
+ passwordHash: await hash(password),
137
+ name
138
+ });
139
+
140
+ return response(200, user);
141
+ }
142
+ ```
143
+
144
+ **Analysis**:
145
+ - Implements all fields from Phase 1 contract
146
+ - Error handling matches contract (400, 409, 422)
147
+ - No extra fields in response
148
+ - Password properly hashed
149
+
150
+ **Action**: Generate IMPLEMENTATION.md section
151
+
152
+ **File 4: src/client/AuthService.ts**
153
+
154
+ ```typescript
155
+ export class AuthService {
156
+ async register(email: string, password: string, name?: string): Promise<User> {
157
+ const response = await fetch('/api/users/register', {
158
+ method: 'POST',
159
+ body: JSON.stringify({ email, password, name })
160
+ });
161
+
162
+ if (response.status === 409) {
163
+ throw new EmailAlreadyUsedError("Email already registered");
164
+ }
165
+
166
+ return response.json();
167
+ }
168
+ }
169
+ ```
170
+
171
+ **Analysis**:
172
+ - Method signature matches Phase 1 contract parameters
173
+ - Return type is User (from Phase 1 response)
174
+ - Error handling matches Phase 3 error codes
175
+ - Backward compatible
176
+
177
+ **Action**: Generate SDK Reference section
178
+
179
+ **Step 2.2: Determine Change Severity**
180
+
181
+ ```
182
+ Change Type Analysis:
183
+
184
+ Is this BREAKING?
185
+ - Removed required field? NO
186
+ - Changed field type? NO
187
+ - Changed behavior significantly? NO
188
+
189
+ → NOT BREAKING
190
+
191
+ Is this FEATURE?
192
+ - New optional parameter? NO
193
+ - New endpoint? YES (POST /api/users/register)
194
+ - New method? YES (register method)
195
+
196
+ → FEATURE CHANGE
197
+
198
+ Severity: MEDIUM (New endpoint/feature)
199
+ Requires manual review: ❌ NO
200
+ Needs migration guide: ❌ NO
201
+ ```
202
+
203
+ **Step 2.3: Compile Change Summary**
204
+
205
+ ```
206
+ 📋 CHANGE SUMMARY
207
+ Generated: May 31, 2026, 10:15 AM
208
+
209
+ CHANGE TYPE: FEATURE
210
+ SEVERITY: MEDIUM
211
+ PHASES AFFECTED: 1, 2, 3, 4, 5 (all phases)
212
+
213
+ SUMMARY:
214
+ Added new user registration endpoint and SDK method.
215
+ - New POST /api/users/register endpoint
216
+ - Email validation + password hashing
217
+ - SDK method: AuthService.register(email, password, name?)
218
+
219
+ BACKWARD COMPATIBLE: ✅ YES
220
+ BREAKING CHANGE: ❌ NO
221
+ MANUAL REVIEW REQUIRED: ❌ NO
222
+
223
+ AFFECTED FILES:
224
+ - contracts/api/UserRegistration/* (Phase 1)
225
+ - tests/integration/auth.test.ts (Phase 2)
226
+ - src/api/handlers/registerHandler.ts (Phase 3)
227
+ - src/client/AuthService.ts (Phase 4)
228
+ - playwright/e2e/registration.spec.ts (Phase 5)
229
+
230
+ DOCUMENTATION NEEDED:
231
+ - ✅ API Reference (endpoint + parameters + response)
232
+ - ✅ Implementation Guide (how it works internally)
233
+ - ✅ SDK Reference (method + types + examples)
234
+ - ✅ Changelog entry (what's new)
235
+ - ✅ Handoff document (next steps for UI/integration)
236
+ ```
237
+
238
+ ---
239
+
240
+ ### Phase 3: Auto-Update Documents (15-20 min)
241
+
242
+ **Step 3.1: Generate API_REFERENCE.md Section**
243
+
244
+ ```markdown
245
+ ### POST /api/users/register
246
+
247
+ **Description**: Register a new user account
248
+
249
+ **Parameters**:
250
+ | Name | Type | Required | Description |
251
+ |------|------|----------|-------------|
252
+ | email | string | Yes | Valid email address |
253
+ | password | string | Yes | Password (8+ characters) |
254
+ | name | string | No | User's display name |
255
+
256
+ **Response** (200 OK):
257
+ ```json
258
+ {
259
+ "id": "550e8400-e29b-41d4-a716-446655440000",
260
+ "email": "user@example.com",
261
+ "name": "John Doe",
262
+ "createdAt": "2026-05-31T10:15:00Z"
263
+ }
264
+ ```
265
+
266
+ **Error Responses**:
267
+ | Code | Error | Cause | Recovery |
268
+ |------|-------|-------|----------|
269
+ | 400 | Invalid email format | Email syntax invalid | Check format (user@domain.com) |
270
+ | 409 | Email already registered | Email taken | Try password reset instead |
271
+ | 422 | Password too weak | <8 chars, no variety | Use 8+ chars with uppercase, number |
272
+ | 500 | Internal server error | Server error | Retry after 1 minute |
273
+
274
+ **Example Request**:
275
+ ```bash
276
+ curl -X POST http://localhost:3000/api/users/register \
277
+ -H "Content-Type: application/json" \
278
+ -d '{
279
+ "email": "user@example.com",
280
+ "password": "SecurePassword123",
281
+ "name": "John Doe"
282
+ }'
283
+ ```
284
+
285
+ **Example Response**:
286
+ ```json
287
+ {
288
+ "id": "550e8400-e29b-41d4-a716-446655440000",
289
+ "email": "user@example.com",
290
+ "name": "John Doe",
291
+ "createdAt": "2026-05-31T10:15:00Z"
292
+ }
293
+ ```
294
+
295
+ ---
296
+
297
+ **Generated**: May 31, 2026 | **Source**: contracts/api/UserRegistration
298
+ ```
299
+
300
+ **Step 3.2: Generate IMPLEMENTATION.md Section**
301
+
302
+ ```markdown
303
+ ## User Registration Implementation
304
+
305
+ ### Handler: `src/api/handlers/registerHandler.ts`
306
+
307
+ The register handler processes new user signups:
308
+
309
+ ```typescript
310
+ export async function registerHandler(req: Request): Promise<Response> {
311
+ const { email, password, name } = req.body;
312
+
313
+ // 1. Input Validation (lines 12-20)
314
+ if (!isValidEmail(email)) {
315
+ return response(400, { error: "Invalid email format" });
316
+ }
317
+ if (password.length < 8) {
318
+ return response(422, { error: "Password too weak" });
319
+ }
320
+
321
+ // 2. Uniqueness Check (lines 21-25)
322
+ const existing = await User.findByEmail(email);
323
+ if (existing) {
324
+ return response(409, { error: "Email already registered" });
325
+ }
326
+
327
+ // 3. User Creation (lines 26-34)
328
+ const user = await User.create({
329
+ email,
330
+ passwordHash: await hash(password),
331
+ name
332
+ });
333
+
334
+ return response(200, user);
335
+ }
336
+ ```
337
+
338
+ ### Service: `src/services/UserService.ts`
339
+
340
+ The UserService orchestrates business logic:
341
+
342
+ - **createUser(email, password, name)**: Creates new user record
343
+ - **Validation**: Deferred to handler (single responsibility)
344
+ - **Database**: Async insert with error handling
345
+ - **Transaction**: Single write (no rollback needed)
346
+
347
+ ### Data Flow
348
+
349
+ 1. Client calls: POST /api/users/register
350
+ 2. Express router → registerHandler
351
+ 3. Handler validates input
352
+ 4. Handler checks uniqueness
353
+ 5. UserService.createUser() called
354
+ 6. Database insert
355
+ 7. Response returned (user object, no password)
356
+
357
+ ### Performance Characteristics
358
+
359
+ - **Email validation**: O(1) regex
360
+ - **Uniqueness check**: O(1) indexed lookup (email unique index)
361
+ - **Password hashing**: O(1) bcrypt ~100ms
362
+ - **Database insert**: O(1) ~10ms average
363
+ - **Total P50**: ~30ms
364
+ - **Total P95**: ~150ms (hashing delays)
365
+
366
+ ### Error Handling Strategy
367
+
368
+ | Error | Source | Recovery |
369
+ |-------|--------|----------|
370
+ | 400 Invalid email | Handler validation | Client should fix format |
371
+ | 409 Email exists | DB uniqueness check | Client should suggest password reset |
372
+ | 422 Weak password | Handler validation | Client should suggest stronger password |
373
+ | 500 Server error | Unexpected exception | Client should retry with backoff |
374
+
375
+ ### Security Considerations
376
+
377
+ - ✅ Passwords hashed with bcrypt (not stored plaintext)
378
+ - ✅ Email validated (RFC format check)
379
+ - ✅ Rate limiting: 5 requests per hour per IP
380
+ - ✅ Error messages don't leak user existence (409 is only for existing email)
381
+ - ✅ No stack traces in error responses
382
+
383
+ ---
384
+
385
+ **Generated**: May 31, 2026 | **Source**: src/api/handlers/registerHandler.ts
386
+ ```
387
+
388
+ **Step 3.3: Generate SDK Reference Section**
389
+
390
+ ```markdown
391
+ ## AuthService.register()
392
+
393
+ **Signature**:
394
+ ```typescript
395
+ async register(email: string, password: string, name?: string): Promise<User>
396
+ ```
397
+
398
+ **Parameters**:
399
+ - `email`: User email address (required)
400
+ - `password`: User password (required, 8+ characters)
401
+ - `name`: User's display name (optional)
402
+
403
+ **Return**: Promise resolving to `User` object
404
+
405
+ **Errors**: Throws appropriate Error subclass
406
+ - `EmailAlreadyUsedError`: Email already registered (409)
407
+ - `InvalidEmailError`: Invalid email format (400)
408
+ - `WeakPasswordError`: Password too weak (422)
409
+ - `ServerError`: Internal server error (500)
410
+
411
+ **Example**:
412
+ ```typescript
413
+ import { AuthService } from '@myapp/client';
414
+
415
+ const auth = new AuthService();
416
+
417
+ try {
418
+ const user = await auth.register(
419
+ 'user@example.com',
420
+ 'SecurePassword123',
421
+ 'John Doe'
422
+ );
423
+
424
+ console.log(`User registered: ${user.id}`);
425
+ // User registered: 550e8400-e29b-41d4-a716-446655440000
426
+ } catch (error) {
427
+ if (error instanceof EmailAlreadyUsedError) {
428
+ console.log('Email already in use, try password reset');
429
+ } else if (error instanceof WeakPasswordError) {
430
+ console.log('Password too weak, try 8+ chars with uppercase and numbers');
431
+ }
432
+ }
433
+ ```
434
+
435
+ **Type Definitions**:
436
+ ```typescript
437
+ interface User {
438
+ id: string; // UUID
439
+ email: string; // Valid email
440
+ name?: string; // Optional display name
441
+ createdAt: Date; // Account creation timestamp
442
+ }
443
+
444
+ class EmailAlreadyUsedError extends Error { code: 409; }
445
+ class InvalidEmailError extends Error { code: 400; }
446
+ class WeakPasswordError extends Error { code: 422; }
447
+ ```
448
+
449
+ ---
450
+
451
+ **Generated**: May 31, 2026 | **Source**: src/client/AuthService.ts
452
+ ```
453
+
454
+ **Step 3.4: Generate SPEC_CHANGELOG.md Entry**
455
+
456
+ ```markdown
457
+ ## [v2.1] - 2026-05-31
458
+
459
+ ### ✨ Added
460
+
461
+ **User Registration Endpoint** [#NEW]
462
+ - New `POST /api/users/register` endpoint
463
+ - Email validation + password hashing with bcrypt
464
+ - Returns user object with UUID, email, name, createdAt
465
+ - Rate limited: 5 requests per hour per IP
466
+ - Tests: 12 integration tests, 4 E2E test scenarios
467
+ - **See**: [API Reference - POST /api/users/register](API_REFERENCE.md#post-apiusersregister)
468
+ - **Implementation**: [User Registration Implementation Guide](IMPLEMENTATION.md#user-registration-implementation)
469
+ - **SDK**: [AuthService.register()](CLIENT_SDK.md#authserviceregister)
470
+
471
+ ### 📝 Error Codes
472
+
473
+ | Code | Meaning | When |
474
+ |------|---------|------|
475
+ | 400 | Invalid email format | Email syntax invalid |
476
+ | 409 | Email already registered | Duplicate signup attempt |
477
+ | 422 | Password too weak | <8 chars or weak combination |
478
+
479
+ ### 🧪 Test Coverage
480
+
481
+ **New Tests**:
482
+ - ✅ Register with valid data → 200 with user ID
483
+ - ✅ Register with duplicate email → 409
484
+ - ✅ Register with invalid email → 400
485
+ - ✅ Register with weak password → 422
486
+ - ✅ Retrieve user after registration → correct data
487
+ - ✅ Performance: Response time < 150ms P95
488
+
489
+ **Coverage**: 94% of registration feature
490
+
491
+ ---
492
+
493
+ **Timestamp**: May 31, 2026 10:30 AM UTC
494
+ **Changed Files**: 5 | **Docs Files**: 3 | **Tests**: 12
495
+ ```
496
+
497
+ **Step 3.5: Generate IMPLEMENTATION_HANDOFF.md Update**
498
+
499
+ ```markdown
500
+ # Handoff: User Registration Feature → Phase 4 (SDK/Client)
501
+
502
+ **Status**: ✅ Ready for Phase 4 (E2E/Frontend Implementation)
503
+ **From**: Phase 3 Backend | **To**: Phase 4 SDK/Client
504
+ **Date**: May 31, 2026
505
+
506
+ ---
507
+
508
+ ## ✅ What's Implemented (Phase 1-3)
509
+
510
+ ### Phase 1: API Contract ✅
511
+ - [x] POST /api/users/register endpoint defined
512
+ - [x] Request schema: { email, password, name? }
513
+ - [x] Response schema: { id, email, name?, createdAt }
514
+ - [x] Error codes defined: 400, 409, 422, 500
515
+ - [x] Rate limiting rule: 5 req/hour per IP
516
+
517
+ ### Phase 2: Tests ✅
518
+ - [x] 12 integration tests written
519
+ - [x] All error cases covered (400, 409, 422)
520
+ - [x] Performance tests passing
521
+ - [x] Coverage: 94%
522
+
523
+ ### Phase 3: Backend ✅
524
+ - [x] Handler: `src/api/handlers/registerHandler.ts`
525
+ - [x] Service: `src/services/UserService.ts`
526
+ - [x] Database: Users table with email index
527
+ - [x] Password hashing: bcrypt cost factor 10
528
+ - [x] Error handling: All error codes mapped
529
+ - [x] Tests: ALL PASSING (12/12)
530
+
531
+ ---
532
+
533
+ ## ⏳ What Needs Phase 4 (SDK/Client)
534
+
535
+ ### Immediate Tasks
536
+
537
+ 1. **Create AuthService Class** (30 min)
538
+ - Method: `register(email, password, name?): Promise<User>`
539
+ - Error handling: Throw appropriate Error subclasses
540
+ - Tests: Unit tests for AuthService
541
+
542
+ 2. **Implement Type Definitions** (20 min)
543
+ - `User` interface: { id, email, name?, createdAt }
544
+ - Error types: EmailAlreadyUsedError, InvalidEmailError, etc.
545
+ - Validation: client-side input validation
546
+
547
+ 3. **Build Registration Form Component** (1 hour)
548
+ - Input fields: email, password, confirmPassword, name
549
+ - Validation: Match server-side rules (8+ chars, email format)
550
+ - Error display: Show error messages from server
551
+ - Success: Redirect to login or dashboard
552
+
553
+ 4. **Write E2E Tests** (45 min)
554
+ - Happy path: Register with valid data
555
+ - Error case: Duplicate email
556
+ - Error case: Weak password
557
+ - Error case: Invalid email
558
+ - Accessibility: Form properly labeled
559
+
560
+ ---
561
+
562
+ ## 🔑 Key Behaviors
563
+
564
+ ### Successful Registration (200)
565
+ ```json
566
+ {
567
+ "id": "550e8400-e29b-41d4-a716-446655440000",
568
+ "email": "user@example.com",
569
+ "name": "John Doe",
570
+ "createdAt": "2026-05-31T10:15:00Z"
571
+ }
572
+ ```
573
+ → Save user ID to session, redirect to dashboard
574
+
575
+ ### Duplicate Email (409)
576
+ ```json
577
+ {
578
+ "error": "Email already registered"
579
+ }
580
+ ```
581
+ → Show error to user, suggest "Forgot Password?"
582
+
583
+ ### Weak Password (422)
584
+ ```json
585
+ {
586
+ "error": "Password too weak"
587
+ }
588
+ ```
589
+ → Show error, provide password strength hints (8+, uppercase, numbers)
590
+
591
+ ### Invalid Email (400)
592
+ ```json
593
+ {
594
+ "error": "Invalid email format"
595
+ }
596
+ ```
597
+ → Show validation error, client-side validation should catch first
598
+
599
+ ---
600
+
601
+ ## 🎯 Design Questions for Phase 4 Team
602
+
603
+ Before starting implementation:
604
+
605
+ 1. **Session Management**
606
+ - Where to store auth token? (localStorage, sessionStorage, cookie?)
607
+ - Auto-logout after 24 hours?
608
+
609
+ 2. **Validation**
610
+ - Should we validate email/password client-side before sending?
611
+ - Benefit: Faster UX feedback, reduced server load
612
+ - Or trust server-side validation only?
613
+
614
+ 3. **Success Flow**
615
+ - Auto-login after registration, or redirect to login?
616
+ - Show welcome screen or go straight to dashboard?
617
+
618
+ 4. **Error UI**
619
+ - Show error toast notification, inline error, or modal?
620
+ - Should we log errors for analytics?
621
+
622
+ ---
623
+
624
+ ## 📋 Phase 4 Testing Checklist
625
+
626
+ Before marking E2E complete:
627
+ - [ ] Happy path test passing (register → 200)
628
+ - [ ] Duplicate email test passing (register → 409)
629
+ - [ ] Weak password test passing (register → 422)
630
+ - [ ] Invalid email test passing (register → 400)
631
+ - [ ] Form validation tests (client-side)
632
+ - [ ] Error messages display correctly
633
+ - [ ] Success screen shows correct user data
634
+ - [ ] Performance acceptable (form submit < 2 sec)
635
+ - [ ] Accessibility: Form properly labeled, keyboard navigable
636
+
637
+ ---
638
+
639
+ ## ⚠️ Known Issues
640
+
641
+ ### 🟢 Low Priority
642
+
643
+ 1. **Avatar placeholder**: Currently null, real image upload not implemented
644
+ - Will be implemented in v2.2
645
+ - Workaround: Use default avatar URL for now
646
+
647
+ 2. **Email verification**: Not implemented
648
+ - User can register with any email address
649
+ - Will add verification email in v2.2
650
+ - For now: Works for alpha testing
651
+
652
+ 3. **Password reset**: Skeleton only
653
+ - UI button exists, backend not connected
654
+ - Will be implemented in v2.2
655
+
656
+ ---
657
+
658
+ ## 🚀 Next Phase (Phase 5: E2E/Frontend)
659
+
660
+ After Phase 4 SDK complete:
661
+ 1. Build registration form component
662
+ 2. Add E2E tests for registration flow
663
+ 3. Integration with auth state management
664
+ 4. Session persistence
665
+
666
+ ---
667
+
668
+ ## 📞 Questions? Contact
669
+
670
+ - **Backend Lead**: [name] (registerHandler questions)
671
+ - **API Owner**: [name] (endpoint contract questions)
672
+ - **QA Lead**: [name] (test results questions)
673
+
674
+ ---
675
+
676
+ **Sign-Off**
677
+ - Backend Lead: ✅ Ready for handoff
678
+ - QA: ✅ All tests passing
679
+ - Architecture: ✅ Approved for Phase 4
680
+ - Date: May 31, 2026 10:30 AM
681
+ ```
682
+
683
+ ---
684
+
685
+ ### Phase 4: Validation (5 min)
686
+
687
+ **Step 4.1: Syntax Validation**
688
+
689
+ ```bash
690
+ ✓ Markdown files compile without errors
691
+ ✓ Code examples are valid TypeScript
692
+ ✓ JSON examples are valid JSON
693
+ ✓ All links are internal references
694
+ ✓ No broken file references
695
+ ```
696
+
697
+ **Step 4.2: Reference Validation**
698
+
699
+ ```bash
700
+ ✓ contracts/api/UserRegistration/request.json exists
701
+ ✓ contracts/api/UserRegistration/response.json exists
702
+ ✓ src/api/handlers/registerHandler.ts exists (lines 12-34 valid)
703
+ ✓ src/services/UserService.ts exists
704
+ ✓ src/client/AuthService.ts exists
705
+ ✓ tests/integration/auth.test.ts exists
706
+ ✓ playwright/e2e/registration.spec.ts exists
707
+ ```
708
+
709
+ **Step 4.3: Cross-Phase Alignment**
710
+
711
+ ```bash
712
+ ✓ Phase 1 contract fields ⊂ Phase 3 handler response
713
+ ✓ Phase 3 handler response ⊂ Phase 4 SDK types
714
+ ✓ Phase 4 SDK types ⊂ Phase 5 E2E tests
715
+ ✓ Error codes consistent across all phases
716
+ ✓ No required/optional field mismatches
717
+ ```
718
+
719
+ **Step 4.4: Completeness Check**
720
+
721
+ ```bash
722
+ ✓ All endpoints have documentation
723
+ ✓ All error codes documented
724
+ ✓ All examples tested (syntax valid)
725
+ ✓ No TODO markers remain
726
+ ✓ All tests reference from contract and implementation
727
+ ```
728
+
729
+ ---
730
+
731
+ ### Phase 5: Completion (2 min)
732
+
733
+ **Step 5.1: Create Update Log Entry**
734
+
735
+ ```
736
+ 📋 DOCS_UPDATE_LOG.md
737
+
738
+ Entry #42 | May 31, 2026 10:35 AM
739
+
740
+ CHANGE: Added user registration endpoint
741
+ TYPE: FEATURE
742
+ SEVERITY: MEDIUM
743
+
744
+ UPDATED FILES:
745
+ - ✅ .docs/API_REFERENCE.md (added POST /api/users/register)
746
+ - ✅ .docs/IMPLEMENTATION.md (added handler explanation)
747
+ - ✅ .docs/CLIENT_SDK.md (added AuthService.register)
748
+ - ✅ SPEC_CHANGELOG.md (new entry for v2.1)
749
+ - ✅ IMPLEMENTATION_HANDOFF.md (Phase 4 handoff prepared)
750
+
751
+ VALIDATION: ✅ PASSED
752
+ - Syntax: Valid
753
+ - References: All valid
754
+ - Alignment: All phases aligned
755
+ - Completeness: 100%
756
+
757
+ MANUAL REVIEW GATE: ❌ NOT NEEDED
758
+ - Breaking change: NO
759
+ - Security issue: NO
760
+ - Architecture change: NO
761
+
762
+ STATUS: ✅ READY FOR COMMIT
763
+
764
+ Changes by: genesis-docs-automation (auto-generated)
765
+ Commit ready: YES
766
+ ```
767
+
768
+ **Step 5.2: Update CURRENT_STATE.md**
769
+
770
+ ```
771
+ ## Documentation Status
772
+
773
+ LAST UPDATED: May 31, 2026 10:35 AM
774
+
775
+ ### Up-to-Date Docs ✅
776
+ - API_REFERENCE.md: Current (v2.1 with user registration)
777
+ - IMPLEMENTATION.md: Current (handler explanation added)
778
+ - ARCHITECTURE.md: Current (no changes)
779
+ - CLIENT_SDK.md: Current (AuthService.register added)
780
+ - SPEC_CHANGELOG.md: Current (v2.1 entry added)
781
+
782
+ ### Handoff Documents ✅
783
+ - IMPLEMENTATION_HANDOFF.md: Phase 3→4 complete
784
+
785
+ ### Test Coverage ✅
786
+ - Integration: 12/12 passing
787
+ - E2E: 4/4 ready
788
+
789
+ ### Next Steps
790
+ → Phase 4: Build registration form component
791
+ → Phase 5: Run E2E tests
792
+ ```
793
+
794
+ **Step 5.3: Final Status**
795
+
796
+ ```
797
+ ✅ DOCS UPDATE COMPLETE
798
+
799
+ Summary:
800
+ - 5 docs files updated
801
+ - 1 log entry created
802
+ - 3 checklists verified
803
+ - All phases aligned
804
+ - Ready for commit
805
+
806
+ Time: 35 minutes
807
+ Manual review: Not required
808
+ Status: READY FOR COMMIT
809
+
810
+ Next: `/commit-docs` to finalize
811
+ ```
812
+
813
+ ---
814
+
815
+ ## 🎓 Common Patterns
816
+
817
+ ### Pattern 1: Optional Field Addition
818
+
819
+ **File Changed**: Phase 1 contract (added optional `description` field)
820
+
821
+ **Auto-Updates Triggered**:
822
+ 1. API_REFERENCE.md: Add field to documentation
823
+ 2. IMPLEMENTATION.md: Note where default value set (if any)
824
+ 3. CLIENT_SDK.md: Update type definition
825
+ 4. SPEC_CHANGELOG.md: Add under "Added"
826
+ 5. IMPLEMENTATION_HANDOFF.md: Note for next phase
827
+
828
+ ### Pattern 2: Error Code Addition
829
+
830
+ **File Changed**: Phase 1 contract (new error 429: Rate Limit Exceeded)
831
+
832
+ **Auto-Updates Triggered**:
833
+ 1. API_REFERENCE.md: Add to error codes table
834
+ 2. IMPLEMENTATION.md: Note implementation location
835
+ 3. CLIENT_SDK.md: Add to error type definitions
836
+ 4. SPEC_CHANGELOG.md: Add under "Added"
837
+ 5. Tests: Verify Phase 2/5 handle 429
838
+
839
+ ### Pattern 3: Breaking Change
840
+
841
+ **File Changed**: Phase 1 contract (removed `legacyId` field)
842
+
843
+ **Auto-Updates Triggered**:
844
+ 1. 🔴 MANUAL REVIEW GATE (breaking change detected)
845
+ 2. Generation of migration guide template
846
+ 3. SPEC_CHANGELOG.md entry in "Deprecated" or "Removed" section
847
+ 4. IMPLEMENTATION_HANDOFF.md: Special attention to migration
848
+
849
+ ---
850
+
851
+ **Version**: v2.3 | **Last Updated**: May 31, 2026 | **Status**: ACTIVE