codex-genesis-harness 0.1.7 → 0.1.8

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 (93) hide show
  1. package/.codebase/COMPRESSED_CONTEXT.md +80 -0
  2. package/.codebase/CURRENT_STATE.md +37 -11
  3. package/.codebase/DEPENDENCY_GRAPH.md +14 -1
  4. package/.codebase/IMPLEMENTATION_HANDOFF.md +34 -336
  5. package/.codebase/KNOWN_PROBLEMS.md +54 -3
  6. package/.codebase/MODULE_INDEX.md +8 -0
  7. package/.codebase/PIPELINE_FLOW.md +7 -5
  8. package/.codebase/RECOVERY_POINTS.md +17 -78
  9. package/.codebase/TECH_DEBT.md +6 -0
  10. package/.codebase/TEST_MATRIX.md +4 -3
  11. package/.codebase/VISUAL_GRAPH.md +127 -0
  12. package/.codebase/context-policy.json +68 -0
  13. package/.codebase/memories/lessons_learned.md +21 -0
  14. package/.codebase/memories/preferences.md +17 -0
  15. package/.codebase/state.json +45 -24
  16. package/.codex/skills/genesis-architecture/SKILL.md +5 -0
  17. package/.codex/skills/genesis-debug-guide/SKILL.md +10 -4
  18. package/.codex/skills/genesis-docs-automation/SKILL.md +52 -973
  19. package/.codex/skills/genesis-executing-plans/SKILL.md +54 -0
  20. package/.codex/skills/genesis-executing-plans/agents/openai.yaml +6 -0
  21. package/.codex/skills/genesis-executing-plans/checklists/.gitkeep +0 -0
  22. package/.codex/skills/genesis-executing-plans/examples/.gitkeep +0 -0
  23. package/.codex/skills/genesis-executing-plans/templates/.gitkeep +0 -0
  24. package/.codex/skills/genesis-harness/SKILL.md +64 -1385
  25. package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +3 -3
  26. package/.codex/skills/genesis-harness/scripts/init-planning.sh +1 -1
  27. package/.codex/skills/genesis-new-design/SKILL.md +4 -1
  28. package/.codex/skills/genesis-new-design/agents/openai.yaml +2 -0
  29. package/.codex/skills/genesis-observability-automation/SKILL.md +69 -303
  30. package/.codex/skills/genesis-observability-automation/references/common-mistakes-and-recovery.md +84 -0
  31. package/.codex/skills/genesis-observability-automation/references/workflow-phases.md +78 -0
  32. package/.codex/skills/genesis-performance-profiling/SKILL.md +1 -22
  33. package/.codex/skills/genesis-performance-profiling/agents/openai.yaml +1 -1
  34. package/.codex/skills/genesis-planning/SKILL.md +6 -1
  35. package/.codex/skills/genesis-release/SKILL.md +5 -0
  36. package/.codex/skills/genesis-research-first/SKILL.md +6 -0
  37. package/.codex/skills/genesis-spec-propagation/SKILL.md +52 -504
  38. package/.codex/skills/genesis-test-driven-development/SKILL.md +55 -0
  39. package/.codex/skills/genesis-test-driven-development/agents/openai.yaml +6 -0
  40. package/.codex/skills/genesis-test-driven-development/checklists/.gitkeep +0 -0
  41. package/.codex/skills/genesis-test-driven-development/examples/.gitkeep +0 -0
  42. package/.codex/skills/genesis-test-driven-development/templates/.gitkeep +0 -0
  43. package/.codex/skills/genesis-upgrade-design/SKILL.md +4 -2
  44. package/.codex/skills/genesis-upgrade-design/agents/openai.yaml +2 -0
  45. package/.codex/skills/genesis-using-git-worktrees/SKILL.md +54 -0
  46. package/.codex/skills/genesis-using-git-worktrees/agents/openai.yaml +6 -0
  47. package/.codex/skills/genesis-using-git-worktrees/checklists/.gitkeep +0 -0
  48. package/.codex/skills/genesis-using-git-worktrees/examples/.gitkeep +0 -0
  49. package/.codex/skills/genesis-using-git-worktrees/templates/.gitkeep +0 -0
  50. package/.codex/skills/genesis-verification-before-completion/SKILL.md +53 -0
  51. package/.codex/skills/genesis-verification-before-completion/agents/openai.yaml +6 -0
  52. package/.codex/skills/genesis-verification-before-completion/checklists/.gitkeep +0 -0
  53. package/.codex/skills/genesis-verification-before-completion/examples/.gitkeep +0 -0
  54. package/.codex/skills/genesis-verification-before-completion/templates/.gitkeep +0 -0
  55. package/.codex/skills/spec-impact-engine/SKILL.md +77 -500
  56. package/.codex/skills/spec-impact-engine/checklists/checklist.md +10 -0
  57. package/.codex-plugin/plugin.json +3 -4
  58. package/CHANGELOG.md +4 -1
  59. package/README.EN.md +32 -17
  60. package/README.VI.md +35 -19
  61. package/README.md +48 -10
  62. package/VERSION +1 -1
  63. package/bin/genesis-harness.js +735 -5
  64. package/contracts/features/registry-schema.json +15 -0
  65. package/contracts/observability/agent-run-schema.json +34 -0
  66. package/contracts/observability/failure-schema.json +35 -0
  67. package/contracts/ui/auth/login-screen-contract.json +43 -0
  68. package/features/REGISTRY.md +63 -0
  69. package/features/SCOPE-template.md +65 -0
  70. package/fixtures/planning/MOCKUP_PROMPT_TEMPLATE.md +16 -0
  71. package/observability/agent-runs/sample-run.json +13 -0
  72. package/observability/decision-logs/sample-decision.md +43 -0
  73. package/observability/failures/sample-failure.json +12 -0
  74. package/package.json +9 -3
  75. package/playwright/e2e/app-template.spec.js +37 -0
  76. package/playwright/e2e/auth/login-screen.spec.js +65 -0
  77. package/playwright/e2e/web-template.spec.js +28 -0
  78. package/scripts/check-scope.sh +100 -0
  79. package/scripts/cold-start-check.js +133 -0
  80. package/scripts/install.sh +4 -0
  81. package/scripts/prompt_sentinel.js +35 -4
  82. package/scripts/run-evals.sh +119 -3
  83. package/scripts/scratch_parser.js +49 -0
  84. package/scripts/spec_visual_sync.js +1 -1
  85. package/scripts/test_generator.js +2 -2
  86. package/scripts/uninstall.sh +4 -0
  87. package/scripts/verify.sh +16 -1
  88. package/tests/integration/cli-smoke.test.js +103 -0
  89. package/tests/unit/feature_registry.test.js +152 -0
  90. package/tests/unit/prompt_sentinel.test.js +1 -1
  91. package/tests/unit/spec_visual_sync.test.js +1 -1
  92. package/tests/unit/test_generator.test.js +1 -1
  93. package/playwright/e2e/e2e-template.md +0 -4
@@ -1,534 +1,82 @@
1
1
  ---
2
2
  name: genesis-spec-propagation
3
- description: "Automated specification propagation across project phases. Detects spec changes and automatically cascades updates to all affected downstream phases, preventing stale contracts, misaligned tests, and late-stage rework."
3
+ description: "Automated specification propagation across project phases. Use after spec changes to update affected tests, contracts, client expectations, E2E scenarios, docs, and migration guidance."
4
4
  ---
5
5
 
6
- # genesis-spec-propagation
6
+ # Genesis Spec Propagation
7
7
 
8
8
  ## Purpose
9
-
10
- Automate cascade propagation of spec changes across all project phases. When Phase 1 API changes, automatically detect affected phases (2-5), update downstream tests, contracts, client SDK types, and E2E scenarios, and generate migration guides for breaking changes. Reduces 45+ min manual update work to 5 min automated propagation.
9
+ Prevent downstream phase drift after a spec change by identifying affected phases, updating dependent artifacts, and validating alignment.
11
10
 
12
11
  ## When to use
13
-
14
- ### Auto-Triggers
15
- After `/spec-change` command completes Detects impact, auto-updates downstream phases
16
- After `/contract-update` for API/DB schema → Propagates to dependent contracts
17
- ✅ After SPEC_CHANGELOG.md entry created → Identifies affected phases (from notes)
18
- ✅ Before release/deployment → Validates all phases still aligned
12
+ - After `/spec-change` or a contract/spec edit.
13
+ - When API, database, UI, auth, config, or integration shape changes.
14
+ - Before starting downstream work that depends on an updated upstream phase.
15
+ - When `spec-impact-engine` reports affected phases.
19
16
 
20
17
  ## When NOT to use
21
-
22
- - For documentation-only changes with no structural impact (field descriptions, examples only)
23
- - When changing a single isolated file with no cross-phase dependencies
24
- - For internal refactoring that preserves all public contracts
18
+ - Pure prose edits that do not alter behavior, schemas, routes, or phase dependencies.
19
+ - One-off implementation bugs where no public or phase contract changed.
20
+ - Cosmetic docs edits with no downstream dependency.
25
21
 
26
22
  ## Inputs required
27
-
28
- - Path to changed spec file (e.g., `contracts/api/response.json`)
29
- - Current `.codebase/PHASE_DEPENDENCY_MAP.md`
30
- - Current `SPEC_CHANGELOG.md`
31
- - Old vs new spec content (for diff analysis)
23
+ - Changed spec or contract files.
24
+ - Impact report from `spec-impact-engine` when available.
25
+ - `.codebase/PHASE_DEPENDENCY_MAP.md` or equivalent dependency notes.
26
+ - Current tests, fixtures, and docs for affected phases.
32
27
 
33
28
  ## Outputs required
34
-
35
- - Updated downstream phase files (tests, contracts, SDK types, E2E scenarios)
36
- - `SPEC_CHANGE_PROPAGATION.md` investigation log
37
- - `SPEC_CHANGELOG.md` entry (auto-appended)
38
- - Migration guide (for breaking changes only)
39
- - Cross-phase validation report
29
+ - Updated downstream phase specs, mocks, tests, contracts, and E2E scenarios.
30
+ - Migration guide for breaking changes.
31
+ - Propagation summary in `.codebase` or observability logs.
32
+ - Verification evidence for affected phases.
40
33
 
41
34
  ## Required tests
42
-
43
- - Each downstream phase's tests must pass after auto-update
44
- - Cross-phase type consistency check (Phase 3 types ⊆ Phase 4 client types)
45
- - Syntax validation of all updated files (JSON, TS, MD)
46
- - Contract alignment test (Phase 3 response schema ⊂ Phase 4 type definitions)
35
+ - Run affected unit/integration/E2E checks where executable tests exist.
36
+ - Run `scripts/run-evals.sh` after changing propagation skill behavior.
37
+ - Validate all updated contracts and fixtures.
47
38
 
48
39
  ## Required fixtures
49
-
50
- - `fixtures/spec-propagation/` with before/after contract files
51
- - Sample `SPEC_CHANGE_PROPAGATION.md` showing format
52
- - Sample migration guide for a breaking field removal
40
+ - Update affected request/response, UI, agent, pipeline, or render fixtures.
41
+ - Add expected-output fixtures for generated migration or impact reports.
53
42
 
54
43
  ## Required contract updates
55
-
56
- - Update `contracts/api/*/response.json` when response schema changes
57
- - Update `.codebase/API_CONTRACTS.md` with change record
58
- - Update `SPEC_CHANGELOG.md` with propagation result
44
+ - Update `contracts/` before dependent tests or implementation.
45
+ - Mark breaking changes explicitly and include migration instructions.
46
+ - Keep `.codebase/API_CONTRACTS.md` and phase docs aligned.
59
47
 
60
48
  ## Required codebase map updates
61
-
62
- - `.codebase/CURRENT_STATE.md`: Mark spec propagation complete
63
- - `.codebase/PHASE_DEPENDENCY_MAP.md`: Update if phase dependencies change
64
- - `.codebase/KNOWN_PROBLEMS.md`: Document any propagation failures
49
+ - Update `.codebase/CURRENT_STATE.md` with propagation status.
50
+ - Update `.codebase/TEST_MATRIX.md` if validation coverage changes.
51
+ - Update `.codebase/RECOVERY_POINTS.md` for unresolved propagation risks.
65
52
 
66
53
  ## Token saving rules
67
-
68
- - Cache PHASE_DEPENDENCY_MAP.md at session start (rarely changes)
69
- - Show before/after diffs, not full file content
70
- - Report "Phase 2,3,4,5 affected" summary, not full impact text
71
- - When validating: report only failing checks, not passing ones
72
- - Reuse dependency graph across multiple operations in same session
54
+ - Read the impact report and phase dependency map before full specs.
55
+ - Load only affected phase files.
56
+ - Report failing or changed checks, not all passing detail.
73
57
 
74
58
  ## Acceptance criteria
75
-
76
- - All downstream phases identified (no phase missed)
77
- - All affected files updated (mocks, types, assertions, E2E)
78
- - All updated files syntactically valid
79
- - Cross-phase validation passes
80
- - SPEC_CHANGELOG.md entry created
81
- - Migration guide present for all breaking changes
82
- - Pre-commit gate passes
59
+ - Every impacted downstream artifact is updated or explicitly marked non-applicable.
60
+ - Breaking changes have migration guidance.
61
+ - Affected verification passes.
62
+ - `.codebase` records propagation status and remaining risks.
83
63
 
84
64
  ## Common mistakes
85
-
86
- - Missing a downstream phase (only updating Phase 2 but not Phase 4 client SDK)
87
- - Auto-updating Phase 5 E2E tests without semantic review (may require manual design)
88
- - Forgetting to run tests in each updated phase after auto-update
89
- - Treating non-breaking changes as breaking (causes unnecessary migration guides)
90
- - Committing breaking changes without human approval
65
+ - Updating Phase 1 contracts without Phase 2-5 dependent tests.
66
+ - Auto-updating E2E expectations without semantic review.
67
+ - Omitting migration notes for breaking changes.
68
+ - Treating low severity as no-op without documenting why.
91
69
 
92
70
  ## Recovery workflow
93
-
94
- If propagation breaks tests or introduces inconsistencies:
95
- 1. Run `git revert <propagation-commit>` to restore pre-propagation state
96
- 2. Identify which phase update caused the failure
97
- 3. Manually review the spec change requirements
98
- 4. Re-run propagation with `--dry-run` to preview changes first
99
- 5. Apply updates phase-by-phase, testing after each
100
- 6. Document edge case in `observability/` for future automation improvement
101
-
102
- ---
103
-
104
- ## 3-Phase Propagation Workflow
105
-
106
- ### Phase 1: Change Detection (5 min)
107
-
108
- **Input**: Spec change location (e.g., `contracts/api/response.json`)
109
-
110
- **Process**:
111
- 1. **Identify Change Type**
112
- - Breaking change? (field removed, type changed, required added)
113
- - Feature change? (new field, new endpoint, new validation rule)
114
- - Non-impact change? (doc update, example update, no structural change)
115
-
116
- 2. **Parse Change Impact**
117
- - Old spec vs new spec comparison
118
- - Breaking: List removed/changed fields, endpoints, validations
119
- - Feature: List added fields, endpoints, optional extensions
120
-
121
- 3. **Identify Affected Phases** (using PHASE_DEPENDENCY_MAP.md)
122
- ```
123
- Phase 1 API spec change →
124
- Phase 2 tests need API response type updates
125
- Phase 3 backend implementation affected
126
- Phase 4 client SDK needs updates
127
- Phase 5 integration tests need new scenarios
128
- ```
129
-
130
- 4. **Record in SPEC_CHANGELOG.md** (auto-append if not done)
131
- ```
132
- - 2026-05-31T14:32:00Z | BREAKING | API response field 'user.avatar' removed
133
- Affected: Phase 2 (test mocks), Phase 3 (API contract), Phase 4 (client SDK), Phase 5 (e2e tests)
134
- ```
135
-
136
- **Output**: Change detection report (type, impact, affected phases)
137
-
138
- ---
139
-
140
- ### Phase 2: Downstream Impact Analysis (10 min)
141
-
142
- **Input**: Change detection report + PHASE_DEPENDENCY_MAP.md
143
-
144
- **Process**:
145
-
146
- 1. **Build Dependency Graph**
147
- ```
148
- Phase 1 (API Contract)
149
- ├─→ Phase 2 (Tests)
150
- ├─→ Phase 3 (Backend Implementation)
151
- └─→ Phase 4 (Client SDK)
152
-
153
- Phase 2 (Tests)
154
- ├─→ Phase 3 (Implementation must pass tests)
155
- └─→ Phase 5 (E2E tests)
156
-
157
- Phase 3 (Backend Implementation)
158
- ├─→ Phase 4 (Client SDK)
159
- └─→ Phase 5 (E2E tests)
160
- ```
161
-
162
- 2. **Trace Propagation Path** (DFS from change point)
163
- - Direct dependents: Phase 2, 3, 4
164
- - Transitive dependents: Phase 5
165
- - List order of updates needed (topological sort)
166
-
167
- 3. **Identify Update Type Per Phase**
168
- - Phase 2: Update mocks, test data, assertions
169
- - Phase 3: Update API handler, response builder, validation
170
- - Phase 4: Update client method signatures, serialization
171
- - Phase 5: Add new scenarios, update expectations
172
-
173
- 4. **Check for Conflicts**
174
- - Does this breaking change conflict with Phase 3 implementation?
175
- - Does Phase 4 client have workarounds we need to update?
176
- - Are there Phase 5 tests that would break?
177
-
178
- 5. **Estimate Manual Work**
179
- - Breaking change: 2-4 hours (requires design decisions)
180
- - Feature change: 30-60 minutes
181
- - Non-impact: 5-10 minutes
182
-
183
- **Output**: Impact analysis (affected phases, update type per phase, conflict flags, time estimate)
184
-
185
- ---
186
-
187
- ### Phase 3: Automatic Phase Updates (15 min)
188
-
189
- **Input**: Impact analysis + affected contract files
190
-
191
- **Process**:
192
-
193
- 1. **Update Phase 2 (Tests)**
194
- - Read current test files (e.g., `tests/api-mocks.test.js`)
195
- - Update mock data to match new API spec
196
- - Update assertions to match new field types/presence
197
- - Update test descriptions for new scenarios
198
- - Output: Updated test file + change summary
199
-
200
- 2. **Update Phase 3 (Backend Implementation)**
201
- - Read current API contract (`contracts/api/response.json`)
202
- - Update response schema to match API spec
203
- - Add migration notes (if breaking change)
204
- - Update backend handler docstring
205
- - Output: Updated contract + handler docs
206
-
207
- 3. **Update Phase 4 (Client SDK)**
208
- - Read current client types (`types/api.ts`)
209
- - Update interface definitions
210
- - Update serialization logic if needed
211
- - Add deprecation warnings for removed fields
212
- - Output: Updated types + deprecation notice
213
-
214
- 4. **Update Phase 5 (E2E Tests)**
215
- - Read current e2e scenarios (`playwright/e2e/scenarios.md`)
216
- - Add new test scenarios for new fields
217
- - Update assertions for changed fields
218
- - Output: Updated scenarios + new test cases
219
-
220
- 5. **Generate Migration Guide** (for breaking changes only)
221
- - What changed & why
222
- - Migration steps for downstream consumers
223
- - Backward compatibility period (if any)
224
- - Rollback procedure
225
-
226
- **Automatic Updates**: Use text replacement templates to update files systematically
227
- **Manual Review Point**: Breaking changes require human approval before commit
228
-
229
- **Output**: Updated phase files + migration guide (if needed)
230
-
231
- ---
232
-
233
- ## Implementation Strategy
234
-
235
- ### Change Detection Logic
236
-
237
- ```javascript
238
- // Pseudocode: Detect spec change type
239
- function analyzeSpecChange(oldSpec, newSpec) {
240
- const changes = {
241
- breaking: [],
242
- feature: [],
243
- nonImpact: []
244
- };
245
-
246
- // Check for removed/modified fields (BREAKING)
247
- for (const field in oldSpec.properties) {
248
- if (!newSpec.properties[field]) {
249
- changes.breaking.push(`Removed field: ${field}`);
250
- } else if (oldSpec.properties[field].type !== newSpec.properties[field].type) {
251
- changes.breaking.push(`Changed type: ${field}`);
252
- }
253
- }
254
-
255
- // Check for new fields (FEATURE)
256
- for (const field in newSpec.properties) {
257
- if (!oldSpec.properties[field]) {
258
- changes.feature.push(`Added field: ${field}`);
259
- }
260
- }
261
-
262
- // Check for non-structural changes (NON-IMPACT)
263
- if (oldSpec.description !== newSpec.description) {
264
- changes.nonImpact.push(`Updated description`);
265
- }
266
-
267
- return changes;
268
- }
269
- ```
270
-
271
- ### Phase Dependency Mapping
272
-
273
- **File**: `.codebase/PHASE_DEPENDENCY_MAP.md`
274
-
275
- ```
276
- # Phase Dependency Map
277
-
278
- ## Direct Dependencies
279
- - Phase 1 (Contracts) → Phase 2, 3, 4
280
- - Phase 2 (Tests) → Phase 3, 5
281
- - Phase 3 (Implementation) → Phase 4, 5
282
- - Phase 4 (SDK) → Phase 5
283
- - Phase 5 (E2E) → Release
284
-
285
- ## Change Impact Rules
286
- - API contract change → Tests, Backend, Client, E2E
287
- - DB schema change → Backend, Migrations, Tests
288
- - UI spec change → Frontend, E2E tests
289
- - Breaking change → Higher priority, requires review
290
- ```
291
-
292
- ### Auto-Update Templates
293
-
294
- **Pattern 1: Mock Data Update**
295
- ```javascript
296
- // OLD
297
- const mockUser = { id: 1, name: 'John', avatar: '/avatar.png' };
298
-
299
- // AUTO-UPDATED (after avatar field removed)
300
- const mockUser = { id: 1, name: 'John' };
301
- ```
302
-
303
- **Pattern 2: Type Definition Update**
304
- ```typescript
305
- // OLD
306
- interface User {
307
- id: number;
308
- name: string;
309
- avatar: string; // URL to user avatar
310
- }
311
-
312
- // AUTO-UPDATED
313
- interface User {
314
- id: number;
315
- name: string;
316
- // avatar field removed in API v2
317
- }
318
- ```
319
-
320
- **Pattern 3: Assertion Update**
321
- ```javascript
322
- // OLD
323
- expect(response.avatar).toBeDefined();
324
-
325
- // AUTO-UPDATED (if field removed)
326
- expect(response).not.toHaveProperty('avatar');
327
- ```
328
-
329
- ---
330
-
331
- ## Validation Workflow (After Auto-Update)
332
-
333
- ### Pre-Commit Validation (MANDATORY)
334
-
335
- 1. **Syntax Check**: All updated files are valid JSON/JS/TS
336
- 2. **Contract Alignment**: Updated contracts match actual changes
337
- 3. **Test Consistency**: Updated tests still make sense semantically
338
- 4. **Type Safety**: Types defined in Phase 4 match Phase 3 API contract
339
- 5. **Cross-Phase Validation**:
340
- - Phase 3 types ⊆ Phase 4 client types ✓
341
- - Phase 2 test data matches Phase 3 API contract ✓
342
- - Phase 5 tests reference existing Phase 4 client methods ✓
343
-
344
- ### Validation Checklist
345
-
346
- ```markdown
347
- ## Spec Propagation Validation
348
-
349
- - [ ] Change detection correct? (type identified)
350
- - [ ] Affected phases identified? (no missing phases)
351
- - [ ] Phase 2 tests updated?
352
- - [ ] Mocks match new spec
353
- - [ ] Assertions updated
354
- - [ ] No broken assertions
355
- - [ ] Phase 3 contract updated?
356
- - [ ] Schema matches API spec
357
- - [ ] Docstrings accurate
358
- - [ ] Phase 4 SDK updated?
359
- - [ ] Types match API contract
360
- - [ ] No type mismatches
361
- - [ ] Phase 5 E2E updated?
362
- - [ ] Scenarios reference updated SDK
363
- - [ ] No broken references
364
- - [ ] Cross-phase validation passes?
365
- - [ ] All files are syntactically valid
366
- - [ ] No circular dependencies
367
- - [ ] Migration guide complete (if breaking)
368
- - [ ] SPEC_CHANGELOG.md entry added?
369
- ```
370
-
371
- ---
372
-
373
- ## Auto-Trigger Integration
374
-
375
- ### Hook: PreToolUse for `/spec-change`
376
-
377
- **Location**: `.instructions.md` (PreToolUse Hook #5)
378
-
379
- ```yaml
380
- BEFORE /spec-change executes:
381
- 1. Verify change is documented
382
- 2. Confirm change type (breaking/feature/non-impact)
383
- 3. Preview affected phases
384
-
385
- AFTER /spec-change completes successfully:
386
- → Activate genesis-spec-propagation skill
387
-
388
- 1. Change Detection (5 min)
389
- - Analyze spec difference
390
- - Identify breaking vs feature
391
- - Map affected phases
392
- - Record in SPEC_CHANGELOG.md
393
-
394
- 2. Impact Analysis (10 min)
395
- - Build dependency graph
396
- - Trace propagation paths
397
- - Identify update types
398
- - Estimate effort
399
-
400
- 3. Auto-Update (15 min)
401
- - Update Phase 2 tests
402
- - Update Phase 3 backend contract
403
- - Update Phase 4 client SDK
404
- - Update Phase 5 E2E tests
405
- - Generate migration guide
406
-
407
- 4. Validation (5 min)
408
- - Syntax check all files
409
- - Cross-phase validation
410
- - Run affected test suites
411
- - Confirm all phases aligned
412
-
413
- 5. Completion (2 min)
414
- - Create SPEC_CHANGE_PROPAGATION.md log
415
- - Update CURRENT_STATE.md
416
- - Ready for commit
417
-
418
- **CRITICAL**: No breaking change commits without review
419
- **CRITICAL**: All downstream phases must be updated
420
- **Non-optional**: Part of /spec-change completion criteria
421
- ```
422
-
423
- ---
424
-
425
- ## Integration with Other Skills
426
-
427
- | Skill | Integration Point |
428
- |-------|-------------------|
429
- | **genesis-research** | Research best practices for API changes |
430
- | **genesis-api-contract** | Generate new API contracts after change |
431
- | **genesis-ui-ux-test** | Update test scenarios based on spec |
432
- | **genesis-harness-engineering** | Orchestrate multi-phase updates |
433
- | **genesis-docs** | Auto-update API docs after propagation |
434
- | **genesis-release** | Use SPEC_CHANGELOG for release notes |
435
- | **spec-impact-engine** | Base dependency tracking |
436
-
437
- ---
438
-
439
- ## Token Efficiency Rules
440
-
441
- ### Cache Aggressively
442
- - Cache PHASE_DEPENDENCY_MAP.md (rarely changes)
443
- - Cache contract templates (reusable)
444
- - Cache update patterns (pattern matching)
445
-
446
- ### Summarize, Don't Repeat
447
- - When reporting changes: "Phase 2,3,4,5 affected" not full text
448
- - When proposing updates: Show before/after, not full file
449
- - When validating: Report issues only, not passing checks
450
-
451
- ### Reuse Analysis
452
- - Store dependency graph in session memory (use across operations)
453
- - Reuse contract analysis within same session
454
- - Link to previous propagation logs (avoid re-analyzing)
455
-
456
- **Target**: 40-50 min for medium change with caching (vs 45+ min manual)
457
-
458
- ---
459
-
460
- ## Success Criteria
461
-
462
- ✅ **Automated**: /spec-change auto-triggers propagation (zero manual steps)
463
- ✅ **Complete**: All affected phases updated (2-5 scanned)
464
- ✅ **Validated**: Cross-phase consistency verified before commit
465
- ✅ **Documented**: SPEC_CHANGELOG.md + migration guides complete
466
- ✅ **Reversible**: Rollback procedure documented for breaking changes
467
- ✅ **Efficient**: 25-30 min execution vs 45+ min manual (40% time savings)
468
- ✅ **Enforced**: Pre-commit gate prevents misaligned phases
469
-
470
- ---
471
-
472
- ## Output Artifacts
473
-
474
- ### Per Spec Change
475
-
476
- 1. **SPEC_CHANGE_PROPAGATION.md** (Investigation log)
477
- - Change detected
478
- - Affected phases
479
- - Updates applied
480
- - Validation results
481
- - Migration guide (if breaking)
482
-
483
- 2. **Updated Contract Files**
484
- - Phase 2: `tests/api-mocks.test.js` (updated mocks)
485
- - Phase 3: `contracts/api/response.json` (updated schema)
486
- - Phase 4: `types/api.ts` (updated types)
487
- - Phase 5: `playwright/e2e/scenarios.md` (updated scenarios)
488
-
489
- 3. **SPEC_CHANGELOG.md Entry** (auto-append)
490
- ```
491
- - 2026-05-31T14:32:00Z | BREAKING | API field change
492
- Auto-updated phases: 2, 3, 4, 5 | Migration guide: /docs/migration-v2-to-v3.md
493
- ```
494
-
495
- 4. **Migration Guide** (for breaking changes)
496
- - What changed & why
497
- - Impact for consumers
498
- - Migration steps
499
- - Timeline & deadlines
500
- - Rollback procedure
501
-
502
- ---
503
-
504
- ## Recovery & Rollback
505
-
506
- ### If Propagation Breaks Tests
507
-
508
- 1. **Identify Breaking Phase**: Which phase fails?
509
- 2. **Root Cause**: Is it auto-update error or actual incompatibility?
510
- 3. **Recover**:
511
- - If auto-update error: Revert change, fix pattern, re-run propagation
512
- - If incompatibility: Manual review + design decision needed
513
- 4. **Document**: Add to RECOVERY_POINTS.md with solution
514
-
515
- ### Rollback to Previous Spec State
516
-
517
- ```bash
518
- # If propagation introduced bugs:
519
- git revert <propagation-commit>
520
-
521
- # Verify all phases revert correctly
522
- npm test
523
-
524
- # Then manually review the spec change requirement
525
- ```
526
-
527
- ---
528
-
529
- ## Related Documentation
530
-
531
- - [PHASE_DEPENDENCY_MAP.md](.codebase/PHASE_DEPENDENCY_MAP.md) - Phase dependencies
532
- - [SPEC_CHANGELOG.md](.codebase/SPEC_CHANGELOG.md) - Change history
533
- - [Contract Management](contracts/README.md) - Contract structures
534
- - [Database Schema Evolution](docs/schema-evolution.md) - Migration patterns
71
+ 1. Re-read the impact report and dependency map.
72
+ 2. Restore the last known aligned contracts/fixtures if propagation fails.
73
+ 3. Re-apply changes one affected phase at a time.
74
+ 4. Record unresolved risk in `.codebase/RECOVERY_POINTS.md`.
75
+
76
+ ## Workflow references
77
+ - `checklists/spec-change-detection.md`: impact classification checklist.
78
+ - `checklists/phase-update-verification.md`: downstream update checklist.
79
+ - `playbooks/feature-change-propagation.md`: additive change workflow.
80
+ - `playbooks/breaking-change-propagation.md`: breaking change workflow.
81
+ - `templates/migration-guide-template.md`: migration guide shape.
82
+ - `observability/propagation-tracking.md`: tracking and metrics format.
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: genesis-test-driven-development
3
+ description: Đảm bảo viết Test trước, Implement sau (Red -> Green -> Refactor). Bắt buộc phải có verification cycle ở mọi bước thay đổi logic.
4
+ ---
5
+
6
+ # Genesis Test Driven Development
7
+
8
+ ## Purpose
9
+ Bắt buộc tuân thủ nguyên tắc TDD (Test-Driven Development) nhằm giữ cho chất lượng codebase luôn ở mức cao nhất. Cụ thể, Agent phải chứng minh được test fail (Red) trước khi sửa code, sau đó pass (Green) sau khi implement, và cuối cùng là dọn dẹp mã (Refactor) để duy trì cấu trúc sạch sẽ.
10
+
11
+ ## When to use
12
+ Bất cứ khi nào thêm tính năng mới (feature), sửa lỗi logic (bug fix), hoặc thay đổi luồng nghiệp vụ của ứng dụng/API.
13
+
14
+ ## When NOT to use
15
+ Khi chỉ thay đổi tài liệu (README, docs), thay đổi cấu trúc thư mục không ảnh hưởng logic (như move file), cấu hình CI/CD, hoặc thuần tuý design UI không có logic nghiệp vụ phức tạp.
16
+
17
+ ## Inputs required
18
+ - Lỗi cụ thể từ người dùng hoặc requirement chi tiết từ bản kế hoạch.
19
+ - Khung test framework của dự án (Jest, Mocha, Playwright, v.v.).
20
+
21
+ ## Outputs required
22
+ - Test file mới hoặc được cập nhật.
23
+ - Kết quả chạy test báo lỗi (Red phase) phản ánh đúng phần logic chưa có hoặc bị hỏng.
24
+ - Source code được implement hoặc chỉnh sửa.
25
+ - Kết quả chạy test pass (Green phase).
26
+
27
+ ## Required tests
28
+ Mọi chức năng, API endpoint hoặc module mới phải được bao phủ bởi Unit Test (và Integration Test nếu có tương tác giữa các service) trước khi code chính được hoàn thiện.
29
+
30
+ ## Required fixtures
31
+ Các bài test bắt buộc phải sử dụng dữ liệu từ mục `fixtures/` thay vì hardcode trực tiếp trong nội dung test, nhằm đảm bảo tính tái sử dụng và dễ theo dõi.
32
+
33
+ ## Required contract updates
34
+ Trong quá trình TDD, nếu nhận thấy cần thay đổi đầu vào (request) hoặc đầu ra (response) của API, hãy cập nhật ngay lập tức các file trong mục `contracts/` rồi mới tiến hành sửa test.
35
+
36
+ ## Required codebase map updates
37
+ Đảm bảo thêm module test mới vào file `TEST_MATRIX.md` để hệ thống nắm được phạm vi kiểm thử (coverage).
38
+
39
+ ## Token saving rules
40
+ Hạn chế chạy toàn bộ test suite lớn của dự án nhiều lần liên tiếp. Thay vào đó, hãy chạy riêng lẻ file test hoặc block test đang được implement (`npm test -- path/to/file.test.js`).
41
+
42
+ ## Acceptance criteria
43
+ 1. Quá trình Red -> Green -> Refactor được chứng minh bằng lịch sử dòng lệnh (CLI output).
44
+ 2. Codebase sau khi Refactor không bị trùng lặp mã (DRY).
45
+ 3. Test phải pass 100% khi chạy lẻ và chạy chung với toàn hệ thống.
46
+
47
+ ## Common mistakes
48
+ - **Viết code trước, viết test sau**: Đi ngược lại với triết lý TDD, dẫn đến test thiếu chính xác hoặc "test để pass".
49
+ - **Test không ý nghĩa (Trivial Tests)**: Viết test chỉ kiểm tra biến bằng chính nó (vd: `expect(true).toBe(true)`), không có giá trị bảo vệ logic.
50
+ - **Bỏ quên Refactor**: Đạt được Green (test pass) nhưng bỏ lại source code rối rắm, lộn xộn.
51
+
52
+ ## Recovery workflow
53
+ 1. Nếu quá trình Refactor làm test đỏ (fail) trở lại, tuyệt đối KHÔNG đổi mã của bài test.
54
+ 2. Hãy khôi phục source code về trạng thái Green gần nhất bằng `git restore` hoặc undo các thay đổi.
55
+ 3. Tiến hành Refactor lại từng bước nhỏ hơn (baby steps).
@@ -0,0 +1,6 @@
1
+ interface:
2
+ display_name: "Genesis TDD"
3
+ short_description: "Đảm bảo tuân thủ TDD loop"
4
+ default_prompt: "Viết test (Red), implement (Green) và Refactor. Phải có test fail trước khi sửa code."
5
+ policy:
6
+ allow_implicit_invocation: true
@@ -74,8 +74,10 @@ If behavior changes unintentionally, restore the contract expectation, add a reg
74
74
  5. Verify and compare:
75
75
  - Run lint/typecheck/tests/build that are available for the project.
76
76
  - Start the dev server when visual validation requires it.
77
- - Capture screenshots after changes and inspect important states and viewports.
78
- - If reference screenshots or a target design are provided, compare against them before claiming completion.
77
+ - **Automated Visual Verification Loop**:
78
+ 1. Use the `@modelcontextprotocol/server-puppeteer` tool to automatically navigate to the local dev server (e.g., `http://localhost:3000`) and capture a screenshot of the current UI.
79
+ 2. **Target Matching**: If a reference design is provided, use your Vision capabilities to compare your screenshot against the target. Iterate and update the code until the UI matches 100%.
80
+ 3. **Aesthetic Audit**: If no target design exists, analyze your screenshot for aesthetic flaws (alignment, spacing, typography, bad AI-generated slop, inconsistent styles) and autonomously update the code to fix them. Repeat the screenshot capture until the UI looks premium.
79
81
 
80
82
  ## Upgrade Heuristics
81
83
 
@@ -2,3 +2,5 @@ interface:
2
2
  display_name: "Genesis Upgrade Design"
3
3
  short_description: "— Nâng cấp UI/UX của giao diện Web có sẵn"
4
4
  default_prompt: "Use $genesis-upgrade-design to improve the existing frontend UI without changing behavior."
5
+ policy:
6
+ allow_implicit_invocation: true