maestro-flow 0.3.4 → 0.3.6

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 (105) hide show
  1. package/.claude/commands/maestro-brainstorm.md +10 -1
  2. package/.claude/commands/maestro-milestone-audit.md +1 -1
  3. package/.claude/commands/maestro-milestone-complete.md +2 -1
  4. package/.claude/commands/maestro-milestone-release.md +96 -0
  5. package/.claude/commands/maestro-phase-add.md +9 -1
  6. package/.claude/commands/maestro-phase-transition.md +9 -1
  7. package/.claude/commands/maestro.md +6 -0
  8. package/.claude/commands/manage-codebase-rebuild.md +76 -50
  9. package/.claude/commands/manage-codebase-refresh.md +9 -1
  10. package/.claude/commands/quality-refactor.md +1 -1
  11. package/.claude/commands/quality-sync.md +9 -1
  12. package/.claude/commands/spec-setup.md +1 -1
  13. package/.codex/skills/maestro-coordinate/SKILL.md +20 -6
  14. package/.codex/skills/maestro-init/SKILL.md +167 -167
  15. package/.codex/skills/maestro-phase-add/SKILL.md +154 -154
  16. package/.codex/skills/maestro-phase-transition/SKILL.md +173 -173
  17. package/.codex/skills/maestro-verify/SKILL.md +566 -566
  18. package/.codex/skills/manage-codebase-rebuild/SKILL.md +5 -5
  19. package/.codex/skills/manage-codebase-refresh/SKILL.md +5 -5
  20. package/.codex/skills/manage-issue/SKILL.md +7 -7
  21. package/.codex/skills/manage-issue-analyze/SKILL.md +8 -8
  22. package/.codex/skills/manage-issue-discover/SKILL.md +503 -503
  23. package/.codex/skills/manage-issue-execute/SKILL.md +9 -9
  24. package/.codex/skills/manage-issue-plan/SKILL.md +8 -8
  25. package/.codex/skills/manage-learn/SKILL.md +7 -7
  26. package/.codex/skills/manage-memory/SKILL.md +72 -72
  27. package/.codex/skills/manage-memory-capture/SKILL.md +86 -86
  28. package/.codex/skills/manage-status/SKILL.md +2 -2
  29. package/.codex/skills/quality-business-test/SKILL.md +8 -8
  30. package/.codex/skills/quality-debug/SKILL.md +5 -5
  31. package/.codex/skills/quality-integration-test/SKILL.md +544 -544
  32. package/.codex/skills/quality-refactor/SKILL.md +6 -6
  33. package/.codex/skills/quality-retrospective/SKILL.md +13 -13
  34. package/.codex/skills/quality-review/SKILL.md +408 -408
  35. package/.codex/skills/quality-sync/SKILL.md +6 -6
  36. package/.codex/skills/quality-test/SKILL.md +5 -5
  37. package/.codex/skills/quality-test-gen/SKILL.md +447 -447
  38. package/.codex/skills/spec-add/SKILL.md +5 -5
  39. package/.codex/skills/spec-load/SKILL.md +5 -5
  40. package/.codex/skills/spec-map/SKILL.md +5 -5
  41. package/.codex/skills/spec-setup/SKILL.md +2 -2
  42. package/.codex/skills/team-coordinate/SKILL.md +1 -1
  43. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +19 -10
  44. package/.codex/skills/team-coordinate/roles/coordinator/role.md +2 -2
  45. package/.codex/skills/team-executor/SKILL.md +1 -1
  46. package/.codex/skills/team-executor/roles/executor/commands/monitor.md +20 -9
  47. package/.codex/skills/team-lifecycle-v4/SKILL.md +2 -2
  48. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +31 -12
  49. package/.codex/skills/team-lifecycle-v4/roles/coordinator/role.md +1 -1
  50. package/.codex/skills/team-quality-assurance/SKILL.md +1 -1
  51. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +20 -9
  52. package/.codex/skills/team-quality-assurance/roles/coordinator/role.md +1 -1
  53. package/.codex/skills/team-review/SKILL.md +1 -1
  54. package/.codex/skills/team-review/roles/coordinator/commands/monitor.md +20 -9
  55. package/.codex/skills/team-review/roles/coordinator/role.md +1 -1
  56. package/.codex/skills/team-tech-debt/SKILL.md +1 -1
  57. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +20 -9
  58. package/.codex/skills/team-tech-debt/roles/coordinator/role.md +1 -1
  59. package/.codex/skills/team-testing/SKILL.md +2 -2
  60. package/.codex/skills/team-testing/roles/coordinator/commands/monitor.md +20 -9
  61. package/.codex/skills/team-testing/roles/coordinator/role.md +1 -1
  62. package/chains/singles/spec-map.json +2 -2
  63. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.d.ts +4 -0
  64. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js +47 -1
  65. package/dashboard/dist-server/dashboard/src/server/agents/codex-app-server-adapter.js.map +1 -1
  66. package/dashboard/dist-server/src/commands/delegate.d.ts +23 -0
  67. package/dashboard/dist-server/src/commands/delegate.js +91 -55
  68. package/dashboard/dist-server/src/commands/delegate.js.map +1 -1
  69. package/dist/src/brainstorm-visualize/frame.d.ts +8 -0
  70. package/dist/src/brainstorm-visualize/frame.d.ts.map +1 -0
  71. package/dist/src/brainstorm-visualize/frame.js +655 -0
  72. package/dist/src/brainstorm-visualize/frame.js.map +1 -0
  73. package/dist/src/brainstorm-visualize/server.d.ts +2 -0
  74. package/dist/src/brainstorm-visualize/server.d.ts.map +1 -0
  75. package/dist/src/brainstorm-visualize/server.js +180 -0
  76. package/dist/src/brainstorm-visualize/server.js.map +1 -0
  77. package/dist/src/cli.js +11 -1
  78. package/dist/src/cli.js.map +1 -1
  79. package/dist/src/commands/brainstorm-visualize.d.ts +3 -0
  80. package/dist/src/commands/brainstorm-visualize.d.ts.map +1 -0
  81. package/dist/src/commands/brainstorm-visualize.js +337 -0
  82. package/dist/src/commands/brainstorm-visualize.js.map +1 -0
  83. package/dist/src/commands/core-memory.d.ts +3 -0
  84. package/dist/src/commands/core-memory.d.ts.map +1 -0
  85. package/dist/src/commands/core-memory.js +101 -0
  86. package/dist/src/commands/core-memory.js.map +1 -0
  87. package/dist/src/commands/delegate.d.ts +23 -0
  88. package/dist/src/commands/delegate.d.ts.map +1 -1
  89. package/dist/src/commands/delegate.js +91 -55
  90. package/dist/src/commands/delegate.js.map +1 -1
  91. package/dist/src/commands/install-backend.d.ts.map +1 -1
  92. package/dist/src/commands/install-backend.js +5 -2
  93. package/dist/src/commands/install-backend.js.map +1 -1
  94. package/dist/src/mcp/delegate-channel-relay.d.ts.map +1 -1
  95. package/dist/src/mcp/delegate-channel-relay.js +6 -0
  96. package/dist/src/mcp/delegate-channel-relay.js.map +1 -1
  97. package/dist/src/mcp/server.d.ts.map +1 -1
  98. package/dist/src/mcp/server.js +28 -1
  99. package/dist/src/mcp/server.js.map +1 -1
  100. package/dist/src/tools/index.d.ts +1 -6
  101. package/dist/src/tools/index.d.ts.map +1 -1
  102. package/dist/src/tools/index.js +1 -460
  103. package/dist/src/tools/index.js.map +1 -1
  104. package/package.json +2 -1
  105. package/.claude/commands/spec-map.md +0 -82
@@ -1,447 +1,447 @@
1
- ---
2
- name: maestro-test-gen
3
- description: Test generation via CSV wave pipeline. Decomposes source files into independent parallel agents, each generating tests with TDD/E2E classification and RED-GREEN methodology. Replaces quality-test-gen command.
4
- argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--type unit|integration|e2e] [--framework jest|vitest|...]\""
5
- allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- ---
7
-
8
- ## Auto Mode
9
-
10
- When `--yes` or `-y`: Auto-confirm test plan, skip interactive validation, use defaults for framework detection.
11
-
12
- # Maestro Test Gen (CSV Wave)
13
-
14
- ## Usage
15
-
16
- ```bash
17
- $maestro-test-gen "3"
18
- $maestro-test-gen -c 4 "3 --type unit"
19
- $maestro-test-gen -y "3 --type e2e --framework vitest"
20
- $maestro-test-gen --continue "test-gen-phase3-20260318"
21
- ```
22
-
23
- **Flags**:
24
- - `-y, --yes`: Skip all confirmations (auto mode)
25
- - `-c, --concurrency N`: Max concurrent agents within the wave (default: 6)
26
- - `--continue`: Resume existing session
27
-
28
- **Output Directory**: `.workflow/.csv-wave/{session-id}/`
29
- **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `test-gen-report.json` (structured output for downstream)
30
-
31
- ---
32
-
33
- ## Overview
34
-
35
- Wave-based test generation using `spawn_agents_on_csv`. Each source file/module gets an independent agent that classifies, plans, and writes tests using RED-GREEN methodology. All agents run in a single parallel wave.
36
-
37
- **Core workflow**: Discover Infrastructure → Identify Gaps → Classify Files → Decompose to CSV → Parallel Test Gen → Aggregate Results
38
-
39
- ```
40
- ┌─────────────────────────────────────────────────────────────────────────┐
41
- │ TEST GENERATION CSV WAVE WORKFLOW │
42
- ├─────────────────────────────────────────────────────────────────────────┤
43
- │ │
44
- │ Phase 1: Gap Analysis → CSV │
45
- │ ├─ Resolve phase directory from arguments │
46
- │ ├─ Discover test infrastructure (framework, patterns, conventions) │
47
- │ ├─ Identify gaps from verification.json + coverage-report.json │
48
- │ ├─ Classify changed files into unit/integration/e2e/skip │
49
- │ ├─ Apply --type filter if set │
50
- │ ├─ Generate tasks.csv with one row per source file │
51
- │ └─ User validates test plan breakdown (skip if -y) │
52
- │ │
53
- │ Phase 2: Wave Execution Engine │
54
- │ ├─ Wave 1: Test Generation (independent parallel) │
55
- │ │ ├─ Each agent generates tests for its assigned source file │
56
- │ │ ├─ RED phase: write failing test targeting real behavior │
57
- │ │ ├─ GREEN assessment: check if source already satisfies │
58
- │ │ ├─ Discoveries shared via board (test patterns, fixtures) │
59
- │ │ └─ Results: tests_created + coverage_delta per source file │
60
- │ └─ discoveries.ndjson shared across all agents (append-only) │
61
- │ │
62
- │ Phase 3: Results Aggregation │
63
- │ ├─ Export results.csv + test-gen-report.json │
64
- │ ├─ Run full test suite to verify no regressions │
65
- │ ├─ Generate context.md with all findings │
66
- │ ├─ Update validation.json with new coverage status │
67
- │ └─ Display summary with next steps │
68
- │ │
69
- └─────────────────────────────────────────────────────────────────────────┘
70
- ```
71
-
72
- ---
73
-
74
- ## CSV Schema
75
-
76
- ### tasks.csv (Master State)
77
-
78
- ```csv
79
- id,title,description,source_file,test_type,test_framework,deps,context_from,wave,status,findings,tests_created,coverage_delta,error
80
- "1","Test validate.ts","Generate unit tests for src/utils/validate.ts: email validation, input sanitization. RED-GREEN methodology. Follow existing vitest patterns. Gap: SC-002 MISSING coverage.","src/utils/validate.ts","unit","vitest","","","1","","","","",""
81
- "2","Test ChatWindow.tsx","Generate e2e tests for src/components/ChatWindow.tsx: message rendering, scroll behavior, input handling. Follow existing Playwright patterns. Gap: SC-005 PARTIAL coverage.","src/components/ChatWindow.tsx","e2e","playwright","","","1","","","","",""
82
- "3","Test comments.ts","Generate integration tests for src/api/comments.ts: CRUD endpoints, auth middleware, error responses. Follow existing supertest patterns. Gap: SC-003 MISSING coverage.","src/api/comments.ts","integration","vitest","","","1","","","","",""
83
- "4","Test useChat.ts","Generate unit tests for src/hooks/useChat.ts: state management, WebSocket connection, message queue. RED-GREEN methodology. Gap: SC-004 MISSING coverage.","src/hooks/useChat.ts","unit","vitest","","","1","","","","",""
84
- "5","Test auth.ts","Generate unit tests for src/auth/auth.ts: token verification, session management, password hashing. Follow existing test patterns. Gap: SC-001 MISSING coverage.","src/auth/auth.ts","unit","vitest","","","1","","","","",""
85
- ```
86
-
87
- **Columns**:
88
-
89
- | Column | Phase | Description |
90
- |--------|-------|-------------|
91
- | `id` | Input | Unique task identifier (string) |
92
- | `title` | Input | Short task title |
93
- | `description` | Input | Detailed test generation instructions for this source file, including gap refs and pattern guidance |
94
- | `source_file` | Input | Source file path to generate tests for |
95
- | `test_type` | Input | Test category: unit/integration/e2e |
96
- | `test_framework` | Input | Detected or specified framework: jest/vitest/pytest/mocha/playwright/cypress |
97
- | `deps` | Input | Semicolon-separated dependency task IDs (empty for independent parallel) |
98
- | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs (empty for wave 1) |
99
- | `wave` | Computed | Wave number (always 1 — independent parallel topology) |
100
- | `status` | Output | `pending` → `completed` / `failed` / `skipped` |
101
- | `findings` | Output | Key findings summary: bugs discovered, patterns used (max 500 chars) |
102
- | `tests_created` | Output | Semicolon-separated paths to generated test files |
103
- | `coverage_delta` | Output | Coverage improvement estimate: `+N%` or `N new cases` |
104
- | `error` | Output | Error message if failed |
105
-
106
- ### Per-Wave CSV (Temporary)
107
-
108
- Each wave generates `wave-{N}.csv` with extra `prev_context` column (empty for wave 1).
109
-
110
- ---
111
-
112
- ## Output Artifacts
113
-
114
- | File | Purpose | Lifecycle |
115
- |------|---------|-----------|
116
- | `tasks.csv` | Master state — all tasks with status/findings | Updated after wave completes |
117
- | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
118
- | `results.csv` | Final export of all task results | Created in Phase 3 |
119
- | `discoveries.ndjson` | Shared exploration board | Append-only, carries across agents |
120
- | `context.md` | Human-readable test generation report | Created in Phase 3 |
121
- | `test-gen-report.json` | Structured output for downstream commands | Created in Phase 3 |
122
-
123
- ---
124
-
125
- ## Session Structure
126
-
127
- ```
128
- .workflow/.csv-wave/test-gen-{phase}-{date}/
129
- ├── tasks.csv
130
- ├── results.csv
131
- ├── discoveries.ndjson
132
- ├── context.md
133
- ├── test-gen-report.json
134
- └── wave-{N}.csv (temporary)
135
- ```
136
-
137
- ---
138
-
139
- ## Implementation
140
-
141
- ### Session Initialization
142
-
143
- ```javascript
144
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
145
-
146
- // Parse flags
147
- const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
148
- const continueMode = $ARGUMENTS.includes('--continue')
149
- const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
150
- const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 6
151
-
152
- // Parse test-gen-specific flags
153
- const typeMatch = $ARGUMENTS.match(/--type\s+(unit|integration|e2e)/)
154
- const frameworkMatch = $ARGUMENTS.match(/--framework\s+([\w]+)/)
155
-
156
- // Clean phase text
157
- const phaseArg = $ARGUMENTS
158
- .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+|--type\s+\w+|--framework\s+[\w]+/g, '')
159
- .trim()
160
-
161
- const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
162
- const sessionId = `test-gen-phase${phaseArg}-${dateStr}`
163
- const sessionFolder = `.workflow/.csv-wave/${sessionId}`
164
-
165
- Bash(`mkdir -p ${sessionFolder}`)
166
- ```
167
-
168
- ---
169
-
170
- ### Phase 1: Gap Analysis → CSV
171
-
172
- **Objective**: Discover test infrastructure, identify coverage gaps, classify files, generate tasks.csv.
173
-
174
- **Decomposition Rules**:
175
-
176
- 1. **Phase resolution**: Resolve `{phaseArg}` to `.workflow/phases/{NN}-{slug}/`
177
-
178
- 2. **Test infrastructure discovery**:
179
- - Find config files: `jest.config.*`, `vitest.config.*`, `pytest.ini`, `.mocharc.*`
180
- - Find existing test files: `*.test.*`, `*.spec.*`, `test_*`
181
- - Find test utilities: `test-utils.*`, `testHelper*`, `conftest.py`
182
- - Read 2-3 existing tests to learn patterns (imports, assertions, mocking)
183
- - If no framework detected: Error E003
184
-
185
- 3. **Gap identification**:
186
-
187
- | Source | Gap Type | Priority |
188
- |--------|----------|----------|
189
- | `verification.json` gaps where status = MISSING | No test at all | HIGH |
190
- | `coverage-report.json` requirements_uncovered | Untested requirement | HIGH |
191
- | `verification.json` gaps where status = PARTIAL | Incomplete test | MEDIUM |
192
- | Task summaries (modified files) | Changed code | LOW |
193
-
194
- 4. **File classification**:
195
-
196
- | File Type | Test Category | Rationale |
197
- |-----------|---------------|-----------|
198
- | Pure function / utility | unit | Isolated, no side effects |
199
- | React component | unit + e2e | Unit for logic, E2E for rendering |
200
- | API route / handler | integration | Needs request context |
201
- | Database model / query | integration | Needs DB connection |
202
- | CLI command | e2e | Needs process execution |
203
- | Config / types / constants | skip | No behavior to test |
204
- | CSS / styles | skip | Visual, not testable |
205
- | Test files themselves | skip | Don't test tests |
206
-
207
- 5. **Filter application**: If `--type` flag set, include only matching test type.
208
-
209
- 6. **Framework resolution**: Use `--framework` if provided, otherwise auto-detected framework.
210
-
211
- 7. **CSV generation**: One row per source file (skip category excluded).
212
-
213
- **Wave computation**: Single wave — all tasks are independent parallel (wave = 1).
214
-
215
- **User validation**: Display test plan breakdown (skip if AUTO_YES).
216
-
217
- ---
218
-
219
- ### Phase 2: Wave Execution Engine
220
-
221
- **Objective**: Execute test generation agents in parallel via spawn_agents_on_csv.
222
-
223
- #### Wave 1: Test Generation (Independent Parallel)
224
-
225
- 1. Read master `tasks.csv`
226
- 2. Filter rows where `wave == 1` AND `status == pending`
227
- 3. No prev_context needed (single wave, no predecessors)
228
- 4. Write `wave-1.csv`
229
- 5. Execute:
230
-
231
- ```javascript
232
- spawn_agents_on_csv({
233
- csv_path: `${sessionFolder}/wave-1.csv`,
234
- id_column: "id",
235
- instruction: buildTestGenInstruction(sessionFolder),
236
- max_concurrency: maxConcurrency,
237
- max_runtime_seconds: 600,
238
- output_csv_path: `${sessionFolder}/wave-1-results.csv`,
239
- output_schema: {
240
- type: "object",
241
- properties: {
242
- id: { type: "string" },
243
- status: { type: "string", enum: ["completed", "failed"] },
244
- findings: { type: "string" },
245
- tests_created: { type: "string" },
246
- coverage_delta: { type: "string" },
247
- error: { type: "string" }
248
- },
249
- required: ["id", "status", "findings"]
250
- }
251
- })
252
- ```
253
-
254
- 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
255
- 7. Delete `wave-1.csv`
256
-
257
- **Agent Instruction Template** (`buildTestGenInstruction`):
258
-
259
- Each agent receives:
260
- - Source file path and test type classification
261
- - Detected framework and existing test patterns
262
- - Gap references (requirement IDs, descriptions)
263
- - RED-GREEN methodology rules:
264
- 1. **RED**: Write test that fails if behavior is broken (not trivially passing)
265
- 2. **Verify RED**: Run test — if passes, strengthen; if fails with expected error, good
266
- 3. **GREEN assessment**: If source satisfies, gap was missing test; if fails, record as bug discovery
267
- - Discovery board protocol for sharing test patterns and fixtures
268
- - Instruction to NOT fix source code — failing tests are valuable bug documentation
269
-
270
- ---
271
-
272
- ### Phase 3: Results Aggregation
273
-
274
- **Objective**: Run full suite, generate final results and human-readable report.
275
-
276
- 1. Read final master `tasks.csv`
277
- 2. Export as `results.csv`
278
-
279
- 3. **Run full test suite** to verify no regressions:
280
- ```bash
281
- {test_run_command} 2>&1 | tail -50
282
- ```
283
- Categorize: new passing (gap filled), new failing (bug discovered), existing broken (regression).
284
-
285
- 4. **Archive previous artifacts** before writing:
286
- ```
287
- IF file exists "{phase_dir}/.tests/test-gen-report.json":
288
- mkdir -p "{phase_dir}/.history"
289
- mv to "{phase_dir}/.history/test-gen-report-{TIMESTAMP}.json"
290
- ```
291
-
292
- 5. Build `test-gen-report.json`:
293
-
294
- ```json
295
- {
296
- "phase": "<phase>",
297
- "generated_at": "<ISO>",
298
- "session_id": "<session-id>",
299
- "infrastructure": {
300
- "framework": "vitest",
301
- "test_dir": "__tests__/",
302
- "run_command": "npm test"
303
- },
304
- "classification": {
305
- "unit": ["src/utils/validate.ts", "src/hooks/useChat.ts"],
306
- "integration": ["src/api/comments.ts"],
307
- "e2e": ["src/components/ChatWindow.tsx"],
308
- "skip": ["src/types/index.ts"]
309
- },
310
- "generated": [
311
- {
312
- "id": "1",
313
- "source_file": "src/utils/validate.ts",
314
- "test_file": "src/utils/__tests__/validate.test.ts",
315
- "test_type": "unit",
316
- "test_cases": 4,
317
- "status": "passing|failing|mixed",
318
- "bugs_discovered": []
319
- }
320
- ],
321
- "summary": {
322
- "files_generated": 5,
323
- "test_cases_total": 22,
324
- "passing": 18,
325
- "failing": 4,
326
- "bugs_discovered": 2,
327
- "coverage_delta": "+12%"
328
- }
329
- }
330
- ```
331
-
332
- 6. Generate `context.md`:
333
-
334
- ```markdown
335
- # Test Generation Report — Phase {phase}
336
-
337
- ## Summary
338
- - Framework: {framework}
339
- - Source files analyzed: {file_count}
340
- - Test type filter: {type_filter or "all"}
341
-
342
- ## Classification
343
- | Category | Files |
344
- |----------|-------|
345
- | Unit | {N} |
346
- | Integration | {N} |
347
- | E2E | {N} |
348
- | Skipped | {N} |
349
-
350
- ## Generation Results
351
- | # | Source File | Type | Tests | Status | Bugs |
352
- |---|-----------|------|-------|--------|------|
353
- | 1 | validate.ts | unit | 4 | passing | 0 |
354
- | 2 | ChatWindow.tsx | e2e | 3 | mixed | 1 |
355
-
356
- ## Test Suite Verification
357
- - New tests passing: {N} (coverage gaps filled)
358
- - New tests failing: {N} (bugs discovered)
359
- - Existing tests broken: {N} (regressions)
360
-
361
- ## Bugs Discovered
362
- {list of failing tests with descriptions — NOT fixed, documented only}
363
-
364
- ## Next Steps
365
- {suggested_next_command}
366
- ```
367
-
368
- 7. Update `validation.json` gaps: change MISSING → COVERED for gaps that now have tests.
369
-
370
- 8. Copy `test-gen-report.json` to phase `.tests/` directory.
371
-
372
- 9. Display summary.
373
-
374
- **Next step routing**:
375
-
376
- | Result | Suggestion |
377
- |--------|------------|
378
- | All tests passing | `maestro-verify {phase}` to update Nyquist coverage |
379
- | Bugs discovered (failing tests) | `quality-debug --from-uat {phase}` to investigate |
380
- | Regressions found | `quality-debug` immediately |
381
- | Coverage still low | Run again with `--type` for uncovered layers |
382
-
383
- ---
384
-
385
- ## Shared Discovery Board Protocol
386
-
387
- ### Standard Discovery Types
388
-
389
- | Type | Dedup Key | Data Schema | Description |
390
- |------|-----------|-------------|-------------|
391
- | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
392
- | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
393
- | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
394
- | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
395
- | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
396
-
397
- ### Domain Discovery Types
398
-
399
- | Type | Dedup Key | Data Schema | Description |
400
- |------|-----------|-------------|-------------|
401
- | `test_pattern` | `data.name` | `{name, file, framework, description}` | Reusable test pattern (describe structure, assertion style) |
402
- | `test_fixture` | `data.name` | `{name, file, setup, teardown}` | Shared test fixture or factory |
403
- | `mock_strategy` | `data.module` | `{module, strategy, file}` | How a dependency is mocked |
404
- | `bug_discovered` | `data.location` | `{location, test_file, description, severity}` | Bug found via failing test |
405
-
406
- ### Protocol
407
-
408
- 1. **Read** `{session_folder}/discoveries.ndjson` before own test generation
409
- 2. **Skip covered**: If discovery of same type + dedup key exists, skip
410
- 3. **Write immediately**: Append findings as found
411
- 4. **Append-only**: Never modify or delete
412
- 5. **Deduplicate**: Check before writing
413
-
414
- ```bash
415
- echo '{"ts":"<ISO>","worker":"{id}","type":"test_pattern","data":{"name":"api-endpoint-test","file":"src/api/__tests__/users.test.ts","framework":"vitest","description":"supertest + vitest pattern for REST endpoints"}}' >> {session_folder}/discoveries.ndjson
416
- ```
417
-
418
- ---
419
-
420
- ## Error Handling
421
-
422
- | Error | Resolution |
423
- |-------|------------|
424
- | Phase directory not found | Abort with error: "Phase {N} not found" |
425
- | No verification results found | Abort with error: "No verification results — run maestro-verify first" |
426
- | No test framework detected | Abort with error: "No test framework detected (E003)" |
427
- | No gaps identified | Info: "No coverage gaps found — phase fully tested" |
428
- | Agent timeout | Mark as failed, continue with remaining agents |
429
- | Test file write conflict | Agent checks for existing test, extends rather than overwrites |
430
- | CSV parse error | Validate format, show line number |
431
- | discoveries.ndjson corrupt | Ignore malformed lines |
432
- | Continue mode: no session found | List available sessions |
433
- | Regression detected in existing tests | Flag as blocker (W002), do not fix source code |
434
-
435
- ---
436
-
437
- ## Core Rules
438
-
439
- 1. **Start Immediately**: First action is session initialization, then Phase 1
440
- 2. **Single Wave**: All test generation agents run in one parallel wave (independent topology)
441
- 3. **CSV is Source of Truth**: Master tasks.csv holds all state
442
- 4. **RED-GREEN Methodology**: Write failing test first, then assess — never write trivially passing tests
443
- 5. **Tests Expose, Not Fix**: Failing tests document bugs; source code changes are NOT permitted
444
- 6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
445
- 7. **Follow Existing Patterns**: Generated tests must match project's test conventions (imports, structure, assertions)
446
- 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
447
- 9. **DO NOT STOP**: Continuous execution until all agents complete and results are aggregated
1
+ ---
2
+ name: quality-test-gen
3
+ description: Test generation via CSV wave pipeline. Decomposes source files into independent parallel agents, each generating tests with TDD/E2E classification and RED-GREEN methodology. Replaces quality-test-gen command.
4
+ argument-hint: "[-y|--yes] [-c|--concurrency N] [--continue] \"<phase> [--type unit|integration|e2e] [--framework jest|vitest|...]\""
5
+ allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm test plan, skip interactive validation, use defaults for framework detection.
11
+
12
+ # Maestro Test Gen (CSV Wave)
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $quality-test-gen "3"
18
+ $quality-test-gen -c 4 "3 --type unit"
19
+ $quality-test-gen -y "3 --type e2e --framework vitest"
20
+ $quality-test-gen --continue "test-gen-phase3-20260318"
21
+ ```
22
+
23
+ **Flags**:
24
+ - `-y, --yes`: Skip all confirmations (auto mode)
25
+ - `-c, --concurrency N`: Max concurrent agents within the wave (default: 6)
26
+ - `--continue`: Resume existing session
27
+
28
+ **Output Directory**: `.workflow/.csv-wave/{session-id}/`
29
+ **Core Output**: `tasks.csv` (master state) + `results.csv` (final) + `discoveries.ndjson` (shared exploration) + `context.md` (human-readable report) + `test-gen-report.json` (structured output for downstream)
30
+
31
+ ---
32
+
33
+ ## Overview
34
+
35
+ Wave-based test generation using `spawn_agents_on_csv`. Each source file/module gets an independent agent that classifies, plans, and writes tests using RED-GREEN methodology. All agents run in a single parallel wave.
36
+
37
+ **Core workflow**: Discover Infrastructure → Identify Gaps → Classify Files → Decompose to CSV → Parallel Test Gen → Aggregate Results
38
+
39
+ ```
40
+ ┌─────────────────────────────────────────────────────────────────────────┐
41
+ │ TEST GENERATION CSV WAVE WORKFLOW │
42
+ ├─────────────────────────────────────────────────────────────────────────┤
43
+ │ │
44
+ │ Phase 1: Gap Analysis → CSV │
45
+ │ ├─ Resolve phase directory from arguments │
46
+ │ ├─ Discover test infrastructure (framework, patterns, conventions) │
47
+ │ ├─ Identify gaps from verification.json + coverage-report.json │
48
+ │ ├─ Classify changed files into unit/integration/e2e/skip │
49
+ │ ├─ Apply --type filter if set │
50
+ │ ├─ Generate tasks.csv with one row per source file │
51
+ │ └─ User validates test plan breakdown (skip if -y) │
52
+ │ │
53
+ │ Phase 2: Wave Execution Engine │
54
+ │ ├─ Wave 1: Test Generation (independent parallel) │
55
+ │ │ ├─ Each agent generates tests for its assigned source file │
56
+ │ │ ├─ RED phase: write failing test targeting real behavior │
57
+ │ │ ├─ GREEN assessment: check if source already satisfies │
58
+ │ │ ├─ Discoveries shared via board (test patterns, fixtures) │
59
+ │ │ └─ Results: tests_created + coverage_delta per source file │
60
+ │ └─ discoveries.ndjson shared across all agents (append-only) │
61
+ │ │
62
+ │ Phase 3: Results Aggregation │
63
+ │ ├─ Export results.csv + test-gen-report.json │
64
+ │ ├─ Run full test suite to verify no regressions │
65
+ │ ├─ Generate context.md with all findings │
66
+ │ ├─ Update validation.json with new coverage status │
67
+ │ └─ Display summary with next steps │
68
+ │ │
69
+ └─────────────────────────────────────────────────────────────────────────┘
70
+ ```
71
+
72
+ ---
73
+
74
+ ## CSV Schema
75
+
76
+ ### tasks.csv (Master State)
77
+
78
+ ```csv
79
+ id,title,description,source_file,test_type,test_framework,deps,context_from,wave,status,findings,tests_created,coverage_delta,error
80
+ "1","Test validate.ts","Generate unit tests for src/utils/validate.ts: email validation, input sanitization. RED-GREEN methodology. Follow existing vitest patterns. Gap: SC-002 MISSING coverage.","src/utils/validate.ts","unit","vitest","","","1","","","","",""
81
+ "2","Test ChatWindow.tsx","Generate e2e tests for src/components/ChatWindow.tsx: message rendering, scroll behavior, input handling. Follow existing Playwright patterns. Gap: SC-005 PARTIAL coverage.","src/components/ChatWindow.tsx","e2e","playwright","","","1","","","","",""
82
+ "3","Test comments.ts","Generate integration tests for src/api/comments.ts: CRUD endpoints, auth middleware, error responses. Follow existing supertest patterns. Gap: SC-003 MISSING coverage.","src/api/comments.ts","integration","vitest","","","1","","","","",""
83
+ "4","Test useChat.ts","Generate unit tests for src/hooks/useChat.ts: state management, WebSocket connection, message queue. RED-GREEN methodology. Gap: SC-004 MISSING coverage.","src/hooks/useChat.ts","unit","vitest","","","1","","","","",""
84
+ "5","Test auth.ts","Generate unit tests for src/auth/auth.ts: token verification, session management, password hashing. Follow existing test patterns. Gap: SC-001 MISSING coverage.","src/auth/auth.ts","unit","vitest","","","1","","","","",""
85
+ ```
86
+
87
+ **Columns**:
88
+
89
+ | Column | Phase | Description |
90
+ |--------|-------|-------------|
91
+ | `id` | Input | Unique task identifier (string) |
92
+ | `title` | Input | Short task title |
93
+ | `description` | Input | Detailed test generation instructions for this source file, including gap refs and pattern guidance |
94
+ | `source_file` | Input | Source file path to generate tests for |
95
+ | `test_type` | Input | Test category: unit/integration/e2e |
96
+ | `test_framework` | Input | Detected or specified framework: jest/vitest/pytest/mocha/playwright/cypress |
97
+ | `deps` | Input | Semicolon-separated dependency task IDs (empty for independent parallel) |
98
+ | `context_from` | Input | Semicolon-separated task IDs whose findings this task needs (empty for wave 1) |
99
+ | `wave` | Computed | Wave number (always 1 — independent parallel topology) |
100
+ | `status` | Output | `pending` → `completed` / `failed` / `skipped` |
101
+ | `findings` | Output | Key findings summary: bugs discovered, patterns used (max 500 chars) |
102
+ | `tests_created` | Output | Semicolon-separated paths to generated test files |
103
+ | `coverage_delta` | Output | Coverage improvement estimate: `+N%` or `N new cases` |
104
+ | `error` | Output | Error message if failed |
105
+
106
+ ### Per-Wave CSV (Temporary)
107
+
108
+ Each wave generates `wave-{N}.csv` with extra `prev_context` column (empty for wave 1).
109
+
110
+ ---
111
+
112
+ ## Output Artifacts
113
+
114
+ | File | Purpose | Lifecycle |
115
+ |------|---------|-----------|
116
+ | `tasks.csv` | Master state — all tasks with status/findings | Updated after wave completes |
117
+ | `wave-{N}.csv` | Per-wave input (temporary) | Created before wave, deleted after |
118
+ | `results.csv` | Final export of all task results | Created in Phase 3 |
119
+ | `discoveries.ndjson` | Shared exploration board | Append-only, carries across agents |
120
+ | `context.md` | Human-readable test generation report | Created in Phase 3 |
121
+ | `test-gen-report.json` | Structured output for downstream commands | Created in Phase 3 |
122
+
123
+ ---
124
+
125
+ ## Session Structure
126
+
127
+ ```
128
+ .workflow/.csv-wave/test-gen-{phase}-{date}/
129
+ ├── tasks.csv
130
+ ├── results.csv
131
+ ├── discoveries.ndjson
132
+ ├── context.md
133
+ ├── test-gen-report.json
134
+ └── wave-{N}.csv (temporary)
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Implementation
140
+
141
+ ### Session Initialization
142
+
143
+ ```javascript
144
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
145
+
146
+ // Parse flags
147
+ const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
148
+ const continueMode = $ARGUMENTS.includes('--continue')
149
+ const concurrencyMatch = $ARGUMENTS.match(/(?:--concurrency|-c)\s+(\d+)/)
150
+ const maxConcurrency = concurrencyMatch ? parseInt(concurrencyMatch[1]) : 6
151
+
152
+ // Parse test-gen-specific flags
153
+ const typeMatch = $ARGUMENTS.match(/--type\s+(unit|integration|e2e)/)
154
+ const frameworkMatch = $ARGUMENTS.match(/--framework\s+([\w]+)/)
155
+
156
+ // Clean phase text
157
+ const phaseArg = $ARGUMENTS
158
+ .replace(/--yes|-y|--continue|--concurrency\s+\d+|-c\s+\d+|--type\s+\w+|--framework\s+[\w]+/g, '')
159
+ .trim()
160
+
161
+ const dateStr = getUtc8ISOString().substring(0, 10).replace(/-/g, '')
162
+ const sessionId = `test-gen-phase${phaseArg}-${dateStr}`
163
+ const sessionFolder = `.workflow/.csv-wave/${sessionId}`
164
+
165
+ Bash(`mkdir -p ${sessionFolder}`)
166
+ ```
167
+
168
+ ---
169
+
170
+ ### Phase 1: Gap Analysis → CSV
171
+
172
+ **Objective**: Discover test infrastructure, identify coverage gaps, classify files, generate tasks.csv.
173
+
174
+ **Decomposition Rules**:
175
+
176
+ 1. **Phase resolution**: Resolve `{phaseArg}` to `.workflow/phases/{NN}-{slug}/`
177
+
178
+ 2. **Test infrastructure discovery**:
179
+ - Find config files: `jest.config.*`, `vitest.config.*`, `pytest.ini`, `.mocharc.*`
180
+ - Find existing test files: `*.test.*`, `*.spec.*`, `test_*`
181
+ - Find test utilities: `test-utils.*`, `testHelper*`, `conftest.py`
182
+ - Read 2-3 existing tests to learn patterns (imports, assertions, mocking)
183
+ - If no framework detected: Error E003
184
+
185
+ 3. **Gap identification**:
186
+
187
+ | Source | Gap Type | Priority |
188
+ |--------|----------|----------|
189
+ | `verification.json` gaps where status = MISSING | No test at all | HIGH |
190
+ | `coverage-report.json` requirements_uncovered | Untested requirement | HIGH |
191
+ | `verification.json` gaps where status = PARTIAL | Incomplete test | MEDIUM |
192
+ | Task summaries (modified files) | Changed code | LOW |
193
+
194
+ 4. **File classification**:
195
+
196
+ | File Type | Test Category | Rationale |
197
+ |-----------|---------------|-----------|
198
+ | Pure function / utility | unit | Isolated, no side effects |
199
+ | React component | unit + e2e | Unit for logic, E2E for rendering |
200
+ | API route / handler | integration | Needs request context |
201
+ | Database model / query | integration | Needs DB connection |
202
+ | CLI command | e2e | Needs process execution |
203
+ | Config / types / constants | skip | No behavior to test |
204
+ | CSS / styles | skip | Visual, not testable |
205
+ | Test files themselves | skip | Don't test tests |
206
+
207
+ 5. **Filter application**: If `--type` flag set, include only matching test type.
208
+
209
+ 6. **Framework resolution**: Use `--framework` if provided, otherwise auto-detected framework.
210
+
211
+ 7. **CSV generation**: One row per source file (skip category excluded).
212
+
213
+ **Wave computation**: Single wave — all tasks are independent parallel (wave = 1).
214
+
215
+ **User validation**: Display test plan breakdown (skip if AUTO_YES).
216
+
217
+ ---
218
+
219
+ ### Phase 2: Wave Execution Engine
220
+
221
+ **Objective**: Execute test generation agents in parallel via spawn_agents_on_csv.
222
+
223
+ #### Wave 1: Test Generation (Independent Parallel)
224
+
225
+ 1. Read master `tasks.csv`
226
+ 2. Filter rows where `wave == 1` AND `status == pending`
227
+ 3. No prev_context needed (single wave, no predecessors)
228
+ 4. Write `wave-1.csv`
229
+ 5. Execute:
230
+
231
+ ```javascript
232
+ spawn_agents_on_csv({
233
+ csv_path: `${sessionFolder}/wave-1.csv`,
234
+ id_column: "id",
235
+ instruction: buildTestGenInstruction(sessionFolder),
236
+ max_concurrency: maxConcurrency,
237
+ max_runtime_seconds: 600,
238
+ output_csv_path: `${sessionFolder}/wave-1-results.csv`,
239
+ output_schema: {
240
+ type: "object",
241
+ properties: {
242
+ id: { type: "string" },
243
+ status: { type: "string", enum: ["completed", "failed"] },
244
+ findings: { type: "string" },
245
+ tests_created: { type: "string" },
246
+ coverage_delta: { type: "string" },
247
+ error: { type: "string" }
248
+ },
249
+ required: ["id", "status", "findings"]
250
+ }
251
+ })
252
+ ```
253
+
254
+ 6. Read `wave-1-results.csv`, merge into master `tasks.csv`
255
+ 7. Delete `wave-1.csv`
256
+
257
+ **Agent Instruction Template** (`buildTestGenInstruction`):
258
+
259
+ Each agent receives:
260
+ - Source file path and test type classification
261
+ - Detected framework and existing test patterns
262
+ - Gap references (requirement IDs, descriptions)
263
+ - RED-GREEN methodology rules:
264
+ 1. **RED**: Write test that fails if behavior is broken (not trivially passing)
265
+ 2. **Verify RED**: Run test — if passes, strengthen; if fails with expected error, good
266
+ 3. **GREEN assessment**: If source satisfies, gap was missing test; if fails, record as bug discovery
267
+ - Discovery board protocol for sharing test patterns and fixtures
268
+ - Instruction to NOT fix source code — failing tests are valuable bug documentation
269
+
270
+ ---
271
+
272
+ ### Phase 3: Results Aggregation
273
+
274
+ **Objective**: Run full suite, generate final results and human-readable report.
275
+
276
+ 1. Read final master `tasks.csv`
277
+ 2. Export as `results.csv`
278
+
279
+ 3. **Run full test suite** to verify no regressions:
280
+ ```bash
281
+ {test_run_command} 2>&1 | tail -50
282
+ ```
283
+ Categorize: new passing (gap filled), new failing (bug discovered), existing broken (regression).
284
+
285
+ 4. **Archive previous artifacts** before writing:
286
+ ```
287
+ IF file exists "{phase_dir}/.tests/test-gen-report.json":
288
+ mkdir -p "{phase_dir}/.history"
289
+ mv to "{phase_dir}/.history/test-gen-report-{TIMESTAMP}.json"
290
+ ```
291
+
292
+ 5. Build `test-gen-report.json`:
293
+
294
+ ```json
295
+ {
296
+ "phase": "<phase>",
297
+ "generated_at": "<ISO>",
298
+ "session_id": "<session-id>",
299
+ "infrastructure": {
300
+ "framework": "vitest",
301
+ "test_dir": "__tests__/",
302
+ "run_command": "npm test"
303
+ },
304
+ "classification": {
305
+ "unit": ["src/utils/validate.ts", "src/hooks/useChat.ts"],
306
+ "integration": ["src/api/comments.ts"],
307
+ "e2e": ["src/components/ChatWindow.tsx"],
308
+ "skip": ["src/types/index.ts"]
309
+ },
310
+ "generated": [
311
+ {
312
+ "id": "1",
313
+ "source_file": "src/utils/validate.ts",
314
+ "test_file": "src/utils/__tests__/validate.test.ts",
315
+ "test_type": "unit",
316
+ "test_cases": 4,
317
+ "status": "passing|failing|mixed",
318
+ "bugs_discovered": []
319
+ }
320
+ ],
321
+ "summary": {
322
+ "files_generated": 5,
323
+ "test_cases_total": 22,
324
+ "passing": 18,
325
+ "failing": 4,
326
+ "bugs_discovered": 2,
327
+ "coverage_delta": "+12%"
328
+ }
329
+ }
330
+ ```
331
+
332
+ 6. Generate `context.md`:
333
+
334
+ ```markdown
335
+ # Test Generation Report — Phase {phase}
336
+
337
+ ## Summary
338
+ - Framework: {framework}
339
+ - Source files analyzed: {file_count}
340
+ - Test type filter: {type_filter or "all"}
341
+
342
+ ## Classification
343
+ | Category | Files |
344
+ |----------|-------|
345
+ | Unit | {N} |
346
+ | Integration | {N} |
347
+ | E2E | {N} |
348
+ | Skipped | {N} |
349
+
350
+ ## Generation Results
351
+ | # | Source File | Type | Tests | Status | Bugs |
352
+ |---|-----------|------|-------|--------|------|
353
+ | 1 | validate.ts | unit | 4 | passing | 0 |
354
+ | 2 | ChatWindow.tsx | e2e | 3 | mixed | 1 |
355
+
356
+ ## Test Suite Verification
357
+ - New tests passing: {N} (coverage gaps filled)
358
+ - New tests failing: {N} (bugs discovered)
359
+ - Existing tests broken: {N} (regressions)
360
+
361
+ ## Bugs Discovered
362
+ {list of failing tests with descriptions — NOT fixed, documented only}
363
+
364
+ ## Next Steps
365
+ {suggested_next_command}
366
+ ```
367
+
368
+ 7. Update `validation.json` gaps: change MISSING → COVERED for gaps that now have tests.
369
+
370
+ 8. Copy `test-gen-report.json` to phase `.tests/` directory.
371
+
372
+ 9. Display summary.
373
+
374
+ **Next step routing**:
375
+
376
+ | Result | Suggestion |
377
+ |--------|------------|
378
+ | All tests passing | `maestro-verify {phase}` to update Nyquist coverage |
379
+ | Bugs discovered (failing tests) | `quality-debug --from-uat {phase}` to investigate |
380
+ | Regressions found | `quality-debug` immediately |
381
+ | Coverage still low | Run again with `--type` for uncovered layers |
382
+
383
+ ---
384
+
385
+ ## Shared Discovery Board Protocol
386
+
387
+ ### Standard Discovery Types
388
+
389
+ | Type | Dedup Key | Data Schema | Description |
390
+ |------|-----------|-------------|-------------|
391
+ | `code_pattern` | `data.name` | `{name, file, description}` | Reusable code pattern found |
392
+ | `integration_point` | `data.file` | `{file, description, exports[]}` | Module connection point |
393
+ | `convention` | singleton | `{naming, imports, formatting}` | Project code conventions |
394
+ | `blocker` | `data.issue` | `{issue, severity, impact}` | Blocking issue found |
395
+ | `tech_stack` | singleton | `{framework, language, tools[]}` | Technology stack info |
396
+
397
+ ### Domain Discovery Types
398
+
399
+ | Type | Dedup Key | Data Schema | Description |
400
+ |------|-----------|-------------|-------------|
401
+ | `test_pattern` | `data.name` | `{name, file, framework, description}` | Reusable test pattern (describe structure, assertion style) |
402
+ | `test_fixture` | `data.name` | `{name, file, setup, teardown}` | Shared test fixture or factory |
403
+ | `mock_strategy` | `data.module` | `{module, strategy, file}` | How a dependency is mocked |
404
+ | `bug_discovered` | `data.location` | `{location, test_file, description, severity}` | Bug found via failing test |
405
+
406
+ ### Protocol
407
+
408
+ 1. **Read** `{session_folder}/discoveries.ndjson` before own test generation
409
+ 2. **Skip covered**: If discovery of same type + dedup key exists, skip
410
+ 3. **Write immediately**: Append findings as found
411
+ 4. **Append-only**: Never modify or delete
412
+ 5. **Deduplicate**: Check before writing
413
+
414
+ ```bash
415
+ echo '{"ts":"<ISO>","worker":"{id}","type":"test_pattern","data":{"name":"api-endpoint-test","file":"src/api/__tests__/users.test.ts","framework":"vitest","description":"supertest + vitest pattern for REST endpoints"}}' >> {session_folder}/discoveries.ndjson
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Error Handling
421
+
422
+ | Error | Resolution |
423
+ |-------|------------|
424
+ | Phase directory not found | Abort with error: "Phase {N} not found" |
425
+ | No verification results found | Abort with error: "No verification results — run maestro-verify first" |
426
+ | No test framework detected | Abort with error: "No test framework detected (E003)" |
427
+ | No gaps identified | Info: "No coverage gaps found — phase fully tested" |
428
+ | Agent timeout | Mark as failed, continue with remaining agents |
429
+ | Test file write conflict | Agent checks for existing test, extends rather than overwrites |
430
+ | CSV parse error | Validate format, show line number |
431
+ | discoveries.ndjson corrupt | Ignore malformed lines |
432
+ | Continue mode: no session found | List available sessions |
433
+ | Regression detected in existing tests | Flag as blocker (W002), do not fix source code |
434
+
435
+ ---
436
+
437
+ ## Core Rules
438
+
439
+ 1. **Start Immediately**: First action is session initialization, then Phase 1
440
+ 2. **Single Wave**: All test generation agents run in one parallel wave (independent topology)
441
+ 3. **CSV is Source of Truth**: Master tasks.csv holds all state
442
+ 4. **RED-GREEN Methodology**: Write failing test first, then assess — never write trivially passing tests
443
+ 5. **Tests Expose, Not Fix**: Failing tests document bugs; source code changes are NOT permitted
444
+ 6. **Discovery Board is Append-Only**: Never clear, modify, or recreate discoveries.ndjson
445
+ 7. **Follow Existing Patterns**: Generated tests must match project's test conventions (imports, structure, assertions)
446
+ 8. **Cleanup Temp Files**: Remove wave-{N}.csv after results are merged
447
+ 9. **DO NOT STOP**: Continuous execution until all agents complete and results are aggregated