qaa-agent 1.6.2 → 1.7.0

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 (78) hide show
  1. package/.mcp.json +8 -8
  2. package/CHANGELOG.md +93 -71
  3. package/CLAUDE.md +553 -553
  4. package/agents/qa-pipeline-orchestrator.md +1378 -1378
  5. package/agents/qaa-analyzer.md +539 -524
  6. package/agents/qaa-bug-detective.md +479 -446
  7. package/agents/qaa-codebase-mapper.md +935 -935
  8. package/agents/qaa-discovery.md +384 -0
  9. package/agents/qaa-e2e-runner.md +416 -415
  10. package/agents/qaa-executor.md +651 -651
  11. package/agents/qaa-planner.md +405 -390
  12. package/agents/qaa-project-researcher.md +319 -319
  13. package/agents/qaa-scanner.md +424 -424
  14. package/agents/qaa-testid-injector.md +643 -585
  15. package/agents/qaa-validator.md +490 -452
  16. package/bin/install.cjs +200 -198
  17. package/bin/lib/commands.cjs +709 -709
  18. package/bin/lib/config.cjs +307 -307
  19. package/bin/lib/core.cjs +497 -497
  20. package/bin/lib/frontmatter.cjs +299 -299
  21. package/bin/lib/init.cjs +989 -989
  22. package/bin/lib/milestone.cjs +241 -241
  23. package/bin/lib/model-profiles.cjs +60 -60
  24. package/bin/lib/phase.cjs +911 -911
  25. package/bin/lib/roadmap.cjs +306 -306
  26. package/bin/lib/state.cjs +748 -748
  27. package/bin/lib/template.cjs +222 -222
  28. package/bin/lib/verify.cjs +842 -842
  29. package/bin/qaa-tools.cjs +607 -607
  30. package/commands/qa-audit.md +119 -0
  31. package/commands/qa-create-test.md +288 -0
  32. package/commands/qa-fix.md +147 -0
  33. package/commands/qa-map.md +137 -0
  34. package/{.claude/commands → commands}/qa-pr.md +23 -23
  35. package/{.claude/commands → commands}/qa-start.md +22 -22
  36. package/{.claude/commands → commands}/qa-testid.md +19 -19
  37. package/docs/COMMANDS.md +341 -341
  38. package/docs/DEMO.md +182 -182
  39. package/docs/TESTING.md +156 -156
  40. package/package.json +6 -7
  41. package/{.claude/settings.json → settings.json} +1 -2
  42. package/templates/failure-classification.md +391 -391
  43. package/templates/gap-analysis.md +409 -409
  44. package/templates/pr-template.md +48 -48
  45. package/templates/qa-analysis.md +381 -381
  46. package/templates/qa-audit-report.md +465 -465
  47. package/templates/qa-repo-blueprint.md +636 -636
  48. package/templates/scan-manifest.md +312 -312
  49. package/templates/test-inventory.md +582 -582
  50. package/templates/testid-audit-report.md +354 -354
  51. package/templates/validation-report.md +243 -243
  52. package/workflows/qa-analyze.md +296 -296
  53. package/workflows/qa-from-ticket.md +536 -536
  54. package/workflows/qa-gap.md +309 -303
  55. package/workflows/qa-pr.md +389 -389
  56. package/workflows/qa-start.md +1192 -1168
  57. package/workflows/qa-testid.md +384 -356
  58. package/workflows/qa-validate.md +299 -295
  59. package/.claude/commands/create-test.md +0 -164
  60. package/.claude/commands/qa-audit.md +0 -37
  61. package/.claude/commands/qa-blueprint.md +0 -54
  62. package/.claude/commands/qa-fix.md +0 -36
  63. package/.claude/commands/qa-from-ticket.md +0 -24
  64. package/.claude/commands/qa-gap.md +0 -20
  65. package/.claude/commands/qa-map.md +0 -47
  66. package/.claude/commands/qa-pom.md +0 -36
  67. package/.claude/commands/qa-pyramid.md +0 -37
  68. package/.claude/commands/qa-report.md +0 -38
  69. package/.claude/commands/qa-research.md +0 -33
  70. package/.claude/commands/qa-validate.md +0 -42
  71. package/.claude/commands/update-test.md +0 -58
  72. package/.claude/skills/qa-learner/SKILL.md +0 -150
  73. /package/{.claude/skills → skills}/qa-bug-detective/SKILL.md +0 -0
  74. /package/{.claude/skills → skills}/qa-repo-analyzer/SKILL.md +0 -0
  75. /package/{.claude/skills → skills}/qa-self-validator/SKILL.md +0 -0
  76. /package/{.claude/skills → skills}/qa-template-engine/SKILL.md +0 -0
  77. /package/{.claude/skills → skills}/qa-testid-injector/SKILL.md +0 -0
  78. /package/{.claude/skills → skills}/qa-workflow-documenter/SKILL.md +0 -0
@@ -1,295 +1,299 @@
1
- <purpose>
2
- Validate existing test files against CLAUDE.md QA standards using a 4-layer check (Syntax, Structure, Dependencies, Logic). Runs a fix loop (validate, fix, re-validate) up to 3 times. If failures remain after the fix loop, optionally spawns the bug-detective agent to classify failures. Produces VALIDATION_REPORT.md and optionally FAILURE_CLASSIFICATION_REPORT.md. Use this workflow to audit test quality in any test suite -- whether generated by the QA pipeline or hand-written.
3
- </purpose>
4
-
5
- <required_reading>
6
- - `CLAUDE.md` -- QA automation standards, quality gates, locator strategy, POM rules, assertion specificity rules
7
- - `agents/qaa-validator.md` -- Validator agent definition (4-layer validation, fix loop, confidence assessment)
8
- - `agents/qaa-bug-detective.md` -- Bug detective agent definition (failure classification, auto-fix for test errors)
9
- - `templates/validation-report.md` -- VALIDATION_REPORT.md format contract
10
- - `templates/failure-classification.md` -- FAILURE_CLASSIFICATION_REPORT.md format contract
11
- </required_reading>
12
-
13
- <process>
14
-
15
- <step name="parse_arguments">
16
- ## Step 1: Parse Arguments
17
-
18
- Parse `$ARGUMENTS` for the test directory path and optional flags.
19
-
20
- **Supported arguments:**
21
- - `<path>` -- Path to the test directory to validate (positional)
22
- - `--classify` -- If set, spawn bug-detective after validation to classify remaining failures
23
- - No arguments -- auto-detect test directories
24
-
25
- **Parsing logic:**
26
-
27
- ```bash
28
- TEST_DIR=""
29
- CLASSIFY_FAILURES=false
30
-
31
- # Parse positional path argument
32
- # Parse --classify flag
33
- ```
34
-
35
- **Validation:**
36
- - If a path is provided, verify it exists and is a directory. If not, print error: `"Error: Test directory does not exist: {path}"` and STOP.
37
- - If no path provided, proceed to auto-detection in the next step.
38
- </step>
39
-
40
- <step name="detect_test_directories">
41
- ## Step 2: Detect Test Directories
42
-
43
- If no test directory was specified, auto-detect by searching for common test directory patterns.
44
-
45
- **Detection order (check each, use the first match):**
46
-
47
- 1. `tests/` -- Standard test directory
48
- 2. `__tests__/` -- Jest convention
49
- 3. `cypress/` -- Cypress test directory
50
- 4. `e2e/` -- E2E test directory
51
- 5. `test/` -- Alternative singular form
52
- 6. `spec/` -- RSpec/generic spec directory
53
-
54
- **Detection logic:**
55
-
56
- ```bash
57
- if TEST_DIR is empty:
58
- for dir in tests __tests__ cypress e2e test spec:
59
- if directory exists at "${dir}":
60
- TEST_DIR="${dir}"
61
- break
62
- ```
63
-
64
- **If no test directory found:**
65
-
66
- Print error and STOP:
67
- ```
68
- Error: No test directory found.
69
- Searched for: tests/, __tests__/, cypress/, e2e/, test/, spec/
70
- Provide the test directory path as an argument: /qa-validate <path>
71
- ```
72
-
73
- **Count test files:**
74
-
75
- ```bash
76
- TEST_FILE_COUNT=$(find "${TEST_DIR}" -type f \( -name "*.test.*" -o -name "*.spec.*" -o -name "*.cy.*" -o -name "*.e2e.*" \) | wc -l)
77
- ```
78
-
79
- If `TEST_FILE_COUNT` is 0, print error: `"Error: No test files found in {TEST_DIR}. Expected files matching *.test.*, *.spec.*, *.cy.*, or *.e2e.*"` and STOP.
80
-
81
- **Print detection results:**
82
-
83
- ```
84
- Test directory: {TEST_DIR}
85
- Test files found: {TEST_FILE_COUNT}
86
- ```
87
- </step>
88
-
89
- <step name="build_file_list">
90
- ## Step 3: Build File List for Validation
91
-
92
- Enumerate all test files and supporting files (page objects, fixtures) to validate.
93
-
94
- **File discovery:**
95
-
96
- Glob for test-related files in the detected directory:
97
- - Test specs: `**/*.test.*`, `**/*.spec.*`, `**/*.cy.*`, `**/*.e2e.*`
98
- - Page objects: `**/pages/**/*`, `**/page-objects/**/*`, `**/support/page-objects/**/*`
99
- - Fixtures: `**/fixtures/**/*`
100
- - Config files: test framework configs at the project root
101
-
102
- **Build a generation-plan-equivalent file list:**
103
-
104
- The validator agent expects a file list (normally from the generation plan). For this workflow, construct a synthetic file list from the discovered files:
105
-
106
- ```markdown
107
- ## Files to Validate
108
-
109
- | File Path | Type |
110
- |-----------|------|
111
- | tests/unit/auth.unit.spec.ts | test_spec |
112
- | tests/api/users.api.spec.ts | test_spec |
113
- | pages/auth/LoginPage.ts | page_object |
114
- | fixtures/auth-data.ts | fixture |
115
- | ... | ... |
116
- ```
117
-
118
- **Set output directory:**
119
-
120
- ```bash
121
- OUTPUT_DIR=".qa-output"
122
- mkdir -p "${OUTPUT_DIR}"
123
- ```
124
- </step>
125
-
126
- <step name="run_validator">
127
- ## Step 4: Spawn Validator Agent
128
-
129
- Spawn the validator agent to perform 4-layer validation with fix loop.
130
-
131
- ```
132
- Task(
133
- prompt="
134
- <objective>Validate test files against CLAUDE.md standards across 4 layers (Syntax, Structure, Dependencies, Logic)</objective>
135
- <execution_context>@agents/qaa-validator.md</execution_context>
136
- <files_to_read>
137
- - CLAUDE.md
138
- - {synthetic file list or generation plan path}
139
- </files_to_read>
140
- <parameters>
141
- test_dir: {TEST_DIR}
142
- output_path: {OUTPUT_DIR}/VALIDATION_REPORT.md
143
- file_list: {list of test file paths}
144
- mode: validation
145
- </parameters>
146
- "
147
- )
148
- ```
149
-
150
- **Handle validator return:**
151
-
152
- Extract from the validator's return values:
153
- - `overall_status` -- PASS, PASS_WITH_WARNINGS, or FAIL
154
- - `confidence` -- HIGH, MEDIUM, or LOW
155
- - `layers_summary` -- per-layer PASS/FAIL status
156
- - `fix_loops_used` -- number of fix iterations (1-3)
157
- - `issues_found` -- total issues discovered
158
- - `issues_fixed` -- issues auto-fixed (HIGH confidence only)
159
- - `unresolved_count` -- issues remaining after fix loops
160
-
161
- **Verify VALIDATION_REPORT.md exists:**
162
-
163
- ```bash
164
- [ -f "${OUTPUT_DIR}/VALIDATION_REPORT.md" ] && echo "FOUND" || echo "MISSING"
165
- ```
166
-
167
- If missing, print error: `"Error: Validator did not produce VALIDATION_REPORT.md."` and STOP.
168
- </step>
169
-
170
- <step name="classify_failures">
171
- ## Step 5: Optionally Spawn Bug Detective
172
-
173
- If the `--classify` flag was set AND the validator reported failures (unresolved_count > 0), spawn the bug-detective agent to classify the remaining failures.
174
-
175
- **Gate check:**
176
-
177
- ```
178
- if CLASSIFY_FAILURES is false:
179
- Skip this step -- print note: "Skipping failure classification. Use --classify flag to enable."
180
-
181
- if unresolved_count is 0:
182
- Skip this step -- print note: "No unresolved failures to classify."
183
- ```
184
-
185
- **Spawn bug-detective agent:**
186
-
187
- ```
188
- Task(
189
- prompt="
190
- <objective>Run test suite and classify failures into APPLICATION BUG, TEST CODE ERROR, ENVIRONMENT ISSUE, or INCONCLUSIVE</objective>
191
- <execution_context>@agents/qaa-bug-detective.md</execution_context>
192
- <files_to_read>
193
- - CLAUDE.md
194
- - {test file paths with failures}
195
- </files_to_read>
196
- <parameters>
197
- test_dir: {TEST_DIR}
198
- output_path: {OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md
199
- </parameters>
200
- "
201
- )
202
- ```
203
-
204
- **Handle detective return:**
205
-
206
- Extract from the detective's return values:
207
- - `total_failures` -- number of failures analyzed
208
- - `classification_breakdown` -- counts per category (app_bug, test_error, env_issue, inconclusive)
209
- - `auto_fixes_applied` -- count of TEST CODE ERROR fixes at HIGH confidence
210
- - `auto_fixes_verified` -- count of fixes that passed re-verification
211
-
212
- **Verify FAILURE_CLASSIFICATION_REPORT.md exists (if detective was spawned):**
213
-
214
- ```bash
215
- [ -f "${OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md" ] && echo "FOUND" || echo "MISSING"
216
- ```
217
- </step>
218
-
219
- <step name="print_summary">
220
- ## Step 6: Print Validation Summary
221
-
222
- Print a human-readable summary of the validation results.
223
-
224
- ```
225
- === Validation Complete ===
226
-
227
- Test Directory: {TEST_DIR}
228
- Files Validated: {file_count}
229
- Fix Loops Used: {fix_loops_used} of 3
230
-
231
- Layer Results:
232
- Syntax: {PASS|FAIL}
233
- Structure: {PASS|FAIL}
234
- Dependencies: {PASS|FAIL}
235
- Logic: {PASS|FAIL}
236
-
237
- Issues:
238
- Found: {issues_found}
239
- Auto-fixed: {issues_fixed}
240
- Unresolved: {unresolved_count}
241
-
242
- Overall Status: {PASS|PASS_WITH_WARNINGS|FAIL}
243
- Confidence: {HIGH|MEDIUM|LOW}
244
-
245
- Artifacts Produced:
246
- - {OUTPUT_DIR}/VALIDATION_REPORT.md
247
- - {OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md (if --classify used)
248
- ```
249
-
250
- **If bug detective ran, add classification summary:**
251
-
252
- ```
253
- Failure Classification:
254
- APPLICATION BUG: {app_bug_count}
255
- TEST CODE ERROR: {test_error_count}
256
- ENVIRONMENT ISSUE: {env_issue_count}
257
- INCONCLUSIVE: {inconclusive_count}
258
- Auto-fixed: {auto_fixes_applied}
259
- ```
260
-
261
- ```
262
- ===========================
263
- ```
264
- </step>
265
-
266
- </process>
267
-
268
- <output>
269
- This workflow validates existing test files and produces quality reports.
270
-
271
- **Artifacts produced:**
272
-
273
- | Artifact | When Produced | Description |
274
- |----------|---------------|-------------|
275
- | VALIDATION_REPORT.md | Always | 4-layer validation results (Syntax, Structure, Dependencies, Logic) with fix loop history and confidence level |
276
- | FAILURE_CLASSIFICATION_REPORT.md | When --classify flag set AND failures exist | Per-failure classification (APPLICATION BUG, TEST CODE ERROR, ENVIRONMENT ISSUE, INCONCLUSIVE) with evidence and auto-fix log |
277
-
278
- **Side effects:**
279
- - Test files may be modified in-place by HIGH-confidence auto-fixes from the validator
280
- - Test files may be modified by HIGH-confidence TEST CODE ERROR fixes from the bug detective
281
- - No git branches created (fixes applied to working tree)
282
- - No PRs created
283
- </output>
284
-
285
- <error_handling>
286
- | Error | Cause | Action |
287
- |-------|-------|--------|
288
- | Test directory does not exist | Invalid path argument | Print error with path, STOP |
289
- | No test directory found | No common test dirs in project | Print error listing searched dirs, suggest providing path, STOP |
290
- | No test files found in directory | Directory exists but contains no test files | Print error with expected patterns, STOP |
291
- | VALIDATION_REPORT.md missing | Validator failed silently | Print error, STOP |
292
- | Fix loop exhausted (3 loops) | Issues cannot be auto-resolved | Validator checkpoints with unresolved issue details |
293
- | Test runner not detected | No test framework config found | Bug detective checkpoints for user to specify runner |
294
- | Test runner fails to start | Missing dependencies or broken config | Bug detective classifies as ENVIRONMENT ISSUE |
295
- </error_handling>
1
+ <purpose>
2
+ Validate existing test files against CLAUDE.md QA standards using a 4-layer check (Syntax, Structure, Dependencies, Logic). Runs a fix loop (validate, fix, re-validate) up to 3 times. If failures remain after the fix loop, optionally spawns the bug-detective agent to classify failures. Produces VALIDATION_REPORT.md and optionally FAILURE_CLASSIFICATION_REPORT.md. Use this workflow to audit test quality in any test suite -- whether generated by the QA pipeline or hand-written.
3
+ </purpose>
4
+
5
+ <required_reading>
6
+ - `CLAUDE.md` -- QA automation standards, quality gates, locator strategy, POM rules, assertion specificity rules
7
+ - `agents/qaa-validator.md` -- Validator agent definition (4-layer validation, fix loop, confidence assessment)
8
+ - `agents/qaa-bug-detective.md` -- Bug detective agent definition (failure classification, auto-fix for test errors)
9
+ - `templates/validation-report.md` -- VALIDATION_REPORT.md format contract
10
+ - `templates/failure-classification.md` -- FAILURE_CLASSIFICATION_REPORT.md format contract
11
+ </required_reading>
12
+
13
+ <process>
14
+
15
+ <step name="parse_arguments">
16
+ ## Step 1: Parse Arguments
17
+
18
+ Parse `$ARGUMENTS` for the test directory path and optional flags.
19
+
20
+ **Supported arguments:**
21
+ - `<path>` -- Path to the test directory to validate (positional)
22
+ - `--classify` -- If set, spawn bug-detective after validation to classify remaining failures
23
+ - No arguments -- auto-detect test directories
24
+
25
+ **Parsing logic:**
26
+
27
+ ```bash
28
+ TEST_DIR=""
29
+ CLASSIFY_FAILURES=false
30
+
31
+ # Parse positional path argument
32
+ # Parse --classify flag
33
+ ```
34
+
35
+ **Validation:**
36
+ - If a path is provided, verify it exists and is a directory. If not, print error: `"Error: Test directory does not exist: {path}"` and STOP.
37
+ - If no path provided, proceed to auto-detection in the next step.
38
+ </step>
39
+
40
+ <step name="detect_test_directories">
41
+ ## Step 2: Detect Test Directories
42
+
43
+ If no test directory was specified, auto-detect by searching for common test directory patterns.
44
+
45
+ **Detection order (check each, use the first match):**
46
+
47
+ 1. `tests/` -- Standard test directory
48
+ 2. `__tests__/` -- Jest convention
49
+ 3. `cypress/` -- Cypress test directory
50
+ 4. `e2e/` -- E2E test directory
51
+ 5. `test/` -- Alternative singular form
52
+ 6. `spec/` -- RSpec/generic spec directory
53
+
54
+ **Detection logic:**
55
+
56
+ ```bash
57
+ if TEST_DIR is empty:
58
+ for dir in tests __tests__ cypress e2e test spec:
59
+ if directory exists at "${dir}":
60
+ TEST_DIR="${dir}"
61
+ break
62
+ ```
63
+
64
+ **If no test directory found:**
65
+
66
+ Print error and STOP:
67
+ ```
68
+ Error: No test directory found.
69
+ Searched for: tests/, __tests__/, cypress/, e2e/, test/, spec/
70
+ Provide the test directory path as an argument: /qa-validate <path>
71
+ ```
72
+
73
+ **Count test files:**
74
+
75
+ ```bash
76
+ TEST_FILE_COUNT=$(find "${TEST_DIR}" -type f \( -name "*.test.*" -o -name "*.spec.*" -o -name "*.cy.*" -o -name "*.e2e.*" \) | wc -l)
77
+ ```
78
+
79
+ If `TEST_FILE_COUNT` is 0, print error: `"Error: No test files found in {TEST_DIR}. Expected files matching *.test.*, *.spec.*, *.cy.*, or *.e2e.*"` and STOP.
80
+
81
+ **Print detection results:**
82
+
83
+ ```
84
+ Test directory: {TEST_DIR}
85
+ Test files found: {TEST_FILE_COUNT}
86
+ ```
87
+ </step>
88
+
89
+ <step name="build_file_list">
90
+ ## Step 3: Build File List for Validation
91
+
92
+ Enumerate all test files and supporting files (page objects, fixtures) to validate.
93
+
94
+ **File discovery:**
95
+
96
+ Glob for test-related files in the detected directory:
97
+ - Test specs: `**/*.test.*`, `**/*.spec.*`, `**/*.cy.*`, `**/*.e2e.*`
98
+ - Page objects: `**/pages/**/*`, `**/page-objects/**/*`, `**/support/page-objects/**/*`
99
+ - Fixtures: `**/fixtures/**/*`
100
+ - Config files: test framework configs at the project root
101
+
102
+ **Build a generation-plan-equivalent file list:**
103
+
104
+ The validator agent expects a file list (normally from the generation plan). For this workflow, construct a synthetic file list from the discovered files:
105
+
106
+ ```markdown
107
+ ## Files to Validate
108
+
109
+ | File Path | Type |
110
+ |-----------|------|
111
+ | tests/unit/auth.unit.spec.ts | test_spec |
112
+ | tests/api/users.api.spec.ts | test_spec |
113
+ | pages/auth/LoginPage.ts | page_object |
114
+ | fixtures/auth-data.ts | fixture |
115
+ | ... | ... |
116
+ ```
117
+
118
+ **Set output directory:**
119
+
120
+ ```bash
121
+ OUTPUT_DIR=".qa-output"
122
+ mkdir -p "${OUTPUT_DIR}"
123
+ ```
124
+ </step>
125
+
126
+ <step name="run_validator">
127
+ ## Step 4: Spawn Validator Agent
128
+
129
+ Spawn the validator agent to perform 4-layer validation with fix loop.
130
+
131
+ ```
132
+ Task(
133
+ prompt="
134
+ <objective>Validate test files against CLAUDE.md standards across 4 layers (Syntax, Structure, Dependencies, Logic). Use codebase map for context and locator registry to verify locator accuracy.</objective>
135
+ <execution_context>@agents/qaa-validator.md</execution_context>
136
+ <files_to_read>
137
+ - CLAUDE.md
138
+ - {synthetic file list or generation plan path}
139
+ - .qa-output/locators/LOCATOR_REGISTRY.md (if exists -- real locators for cross-checking POM accuracy)
140
+ - .qa-output/codebase/CODE_PATTERNS.md (if exists -- naming conventions for structure validation)
141
+ - .qa-output/codebase/TEST_SURFACE.md (if exists -- function signatures for target verification)
142
+ - .qa-output/codebase/API_CONTRACTS.md (if exists -- API shapes for assertion verification)
143
+ </files_to_read>
144
+ <parameters>
145
+ test_dir: {TEST_DIR}
146
+ output_path: {OUTPUT_DIR}/VALIDATION_REPORT.md
147
+ file_list: {list of test file paths}
148
+ mode: validation
149
+ </parameters>
150
+ "
151
+ )
152
+ ```
153
+
154
+ **Handle validator return:**
155
+
156
+ Extract from the validator's return values:
157
+ - `overall_status` -- PASS, PASS_WITH_WARNINGS, or FAIL
158
+ - `confidence` -- HIGH, MEDIUM, or LOW
159
+ - `layers_summary` -- per-layer PASS/FAIL status
160
+ - `fix_loops_used` -- number of fix iterations (1-3)
161
+ - `issues_found` -- total issues discovered
162
+ - `issues_fixed` -- issues auto-fixed (HIGH confidence only)
163
+ - `unresolved_count` -- issues remaining after fix loops
164
+
165
+ **Verify VALIDATION_REPORT.md exists:**
166
+
167
+ ```bash
168
+ [ -f "${OUTPUT_DIR}/VALIDATION_REPORT.md" ] && echo "FOUND" || echo "MISSING"
169
+ ```
170
+
171
+ If missing, print error: `"Error: Validator did not produce VALIDATION_REPORT.md."` and STOP.
172
+ </step>
173
+
174
+ <step name="classify_failures">
175
+ ## Step 5: Optionally Spawn Bug Detective
176
+
177
+ If the `--classify` flag was set AND the validator reported failures (unresolved_count > 0), spawn the bug-detective agent to classify the remaining failures.
178
+
179
+ **Gate check:**
180
+
181
+ ```
182
+ if CLASSIFY_FAILURES is false:
183
+ Skip this step -- print note: "Skipping failure classification. Use --classify flag to enable."
184
+
185
+ if unresolved_count is 0:
186
+ Skip this step -- print note: "No unresolved failures to classify."
187
+ ```
188
+
189
+ **Spawn bug-detective agent:**
190
+
191
+ ```
192
+ Task(
193
+ prompt="
194
+ <objective>Run test suite and classify failures into APPLICATION BUG, TEST CODE ERROR, ENVIRONMENT ISSUE, or INCONCLUSIVE</objective>
195
+ <execution_context>@agents/qaa-bug-detective.md</execution_context>
196
+ <files_to_read>
197
+ - CLAUDE.md
198
+ - {test file paths with failures}
199
+ </files_to_read>
200
+ <parameters>
201
+ test_dir: {TEST_DIR}
202
+ output_path: {OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md
203
+ </parameters>
204
+ "
205
+ )
206
+ ```
207
+
208
+ **Handle detective return:**
209
+
210
+ Extract from the detective's return values:
211
+ - `total_failures` -- number of failures analyzed
212
+ - `classification_breakdown` -- counts per category (app_bug, test_error, env_issue, inconclusive)
213
+ - `auto_fixes_applied` -- count of TEST CODE ERROR fixes at HIGH confidence
214
+ - `auto_fixes_verified` -- count of fixes that passed re-verification
215
+
216
+ **Verify FAILURE_CLASSIFICATION_REPORT.md exists (if detective was spawned):**
217
+
218
+ ```bash
219
+ [ -f "${OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md" ] && echo "FOUND" || echo "MISSING"
220
+ ```
221
+ </step>
222
+
223
+ <step name="print_summary">
224
+ ## Step 6: Print Validation Summary
225
+
226
+ Print a human-readable summary of the validation results.
227
+
228
+ ```
229
+ === Validation Complete ===
230
+
231
+ Test Directory: {TEST_DIR}
232
+ Files Validated: {file_count}
233
+ Fix Loops Used: {fix_loops_used} of 3
234
+
235
+ Layer Results:
236
+ Syntax: {PASS|FAIL}
237
+ Structure: {PASS|FAIL}
238
+ Dependencies: {PASS|FAIL}
239
+ Logic: {PASS|FAIL}
240
+
241
+ Issues:
242
+ Found: {issues_found}
243
+ Auto-fixed: {issues_fixed}
244
+ Unresolved: {unresolved_count}
245
+
246
+ Overall Status: {PASS|PASS_WITH_WARNINGS|FAIL}
247
+ Confidence: {HIGH|MEDIUM|LOW}
248
+
249
+ Artifacts Produced:
250
+ - {OUTPUT_DIR}/VALIDATION_REPORT.md
251
+ - {OUTPUT_DIR}/FAILURE_CLASSIFICATION_REPORT.md (if --classify used)
252
+ ```
253
+
254
+ **If bug detective ran, add classification summary:**
255
+
256
+ ```
257
+ Failure Classification:
258
+ APPLICATION BUG: {app_bug_count}
259
+ TEST CODE ERROR: {test_error_count}
260
+ ENVIRONMENT ISSUE: {env_issue_count}
261
+ INCONCLUSIVE: {inconclusive_count}
262
+ Auto-fixed: {auto_fixes_applied}
263
+ ```
264
+
265
+ ```
266
+ ===========================
267
+ ```
268
+ </step>
269
+
270
+ </process>
271
+
272
+ <output>
273
+ This workflow validates existing test files and produces quality reports.
274
+
275
+ **Artifacts produced:**
276
+
277
+ | Artifact | When Produced | Description |
278
+ |----------|---------------|-------------|
279
+ | VALIDATION_REPORT.md | Always | 4-layer validation results (Syntax, Structure, Dependencies, Logic) with fix loop history and confidence level |
280
+ | FAILURE_CLASSIFICATION_REPORT.md | When --classify flag set AND failures exist | Per-failure classification (APPLICATION BUG, TEST CODE ERROR, ENVIRONMENT ISSUE, INCONCLUSIVE) with evidence and auto-fix log |
281
+
282
+ **Side effects:**
283
+ - Test files may be modified in-place by HIGH-confidence auto-fixes from the validator
284
+ - Test files may be modified by HIGH-confidence TEST CODE ERROR fixes from the bug detective
285
+ - No git branches created (fixes applied to working tree)
286
+ - No PRs created
287
+ </output>
288
+
289
+ <error_handling>
290
+ | Error | Cause | Action |
291
+ |-------|-------|--------|
292
+ | Test directory does not exist | Invalid path argument | Print error with path, STOP |
293
+ | No test directory found | No common test dirs in project | Print error listing searched dirs, suggest providing path, STOP |
294
+ | No test files found in directory | Directory exists but contains no test files | Print error with expected patterns, STOP |
295
+ | VALIDATION_REPORT.md missing | Validator failed silently | Print error, STOP |
296
+ | Fix loop exhausted (3 loops) | Issues cannot be auto-resolved | Validator checkpoints with unresolved issue details |
297
+ | Test runner not detected | No test framework config found | Bug detective checkpoints for user to specify runner |
298
+ | Test runner fails to start | Missing dependencies or broken config | Bug detective classifies as ENVIRONMENT ISSUE |
299
+ </error_handling>