pi-maestro-flow 0.2.0 → 0.3.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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +13 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -7
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +9 -10
  28. package/skills/maestro-amend/SKILL.md +3 -3
  29. package/skills/maestro-analyze/SKILL.md +10 -13
  30. package/skills/maestro-blueprint/SKILL.md +8 -11
  31. package/skills/maestro-brainstorm/SKILL.md +11 -14
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +11 -12
  35. package/skills/maestro-execute/SKILL.md +9 -12
  36. package/skills/maestro-fork/SKILL.md +8 -11
  37. package/skills/maestro-grill/SKILL.md +13 -16
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +9 -12
  42. package/skills/maestro-merge/SKILL.md +6 -8
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -5
  44. package/skills/maestro-milestone-complete/SKILL.md +9 -12
  45. package/skills/maestro-milestone-release/SKILL.md +9 -11
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +16 -16
  48. package/skills/maestro-plan/SKILL.md +9 -12
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -7
  51. package/skills/maestro-ralph/SKILL.md +16 -17
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +18 -19
  56. package/skills/maestro-roadmap/SKILL.md +8 -9
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -7
  59. package/skills/maestro-tools-register/SKILL.md +7 -9
  60. package/skills/maestro-ui-codify/SKILL.md +9 -10
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -6
  64. package/skills/manage-drift-realign/SKILL.md +8 -11
  65. package/skills/manage-harvest/SKILL.md +6 -9
  66. package/skills/manage-issue/SKILL.md +5 -8
  67. package/skills/manage-issue-discover/SKILL.md +8 -11
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -5
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -6
  71. package/skills/manage-knowledge-audit/SKILL.md +6 -9
  72. package/skills/manage-status/SKILL.md +3 -5
  73. package/skills/manage-wiki/SKILL.md +5 -7
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -5
  81. package/skills/quality-debug/SKILL.md +3 -5
  82. package/skills/quality-refactor/SKILL.md +3 -5
  83. package/skills/quality-retrospective/SKILL.md +10 -13
  84. package/skills/quality-review/SKILL.md +5 -8
  85. package/skills/quality-sync/SKILL.md +3 -5
  86. package/skills/quality-test/SKILL.md +4 -6
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -4
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -7
  102. package/skills/spec-load/SKILL.md +3 -5
  103. package/skills/spec-remove/SKILL.md +4 -6
  104. package/skills/spec-setup/SKILL.md +6 -8
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,574 @@
1
+ # Business Test Workflow (PRD-Forward)
2
+
3
+ Validate built features against PRD acceptance criteria through automated multi-layer business testing with requirement traceability, fixture generation, and feedback loop.
4
+
5
+ PRD-forward: starts from REQ-*.md acceptance criteria, not from code coverage gaps.
6
+ Progressive layers: L1 Interface Contract -> L2 Business Rule -> L3 Business Scenario (E2E).
7
+ Generator-Critic loop: max 3 iterations per layer to distinguish test defects from code defects.
8
+
9
+ **Philosophy: Business rules are the source of truth. Code must satisfy them, not the other way around.**
10
+
11
+ ---
12
+
13
+ ### Step 1: Resolve Target & Load Spec Package
14
+
15
+ **Parse arguments:**
16
+
17
+ | Input | Result |
18
+ |-------|--------|
19
+ | No arguments | Error E001 |
20
+ | Phase number | Resolve `.workflow/phases/{NN}-{slug}/` |
21
+ | `--spec SPEC-xxx` | Explicit spec reference |
22
+ | `--layer L1\|L2\|L3` | Run only specific layer |
23
+ | `--gen-code` | Generate framework-specific test classes |
24
+ | `--dry-run` | Extract scenarios only, don't execute |
25
+ | `--re-run` | Re-run only previously failed scenarios |
26
+ | `--auto` | Skip interactive confirmations |
27
+
28
+ **Load spec package:**
29
+
30
+ ```
31
+ 1. Read ${PHASE_DIR}/index.json -> extract blueprint_ref (if present)
32
+ 2. IF --spec provided: SPEC_DIR = .workflow/blueprint/{blueprint_ref}/
33
+ ELSE IF index.json.blueprint_ref: SPEC_DIR = .workflow/blueprint/{blueprint_ref}/
34
+ ELSE: try .workflow/blueprint/SPEC-*/ (most recent)
35
+
36
+ 3. IF SPEC_DIR found:
37
+ - Read requirements/_index.md (requirement summary + traceability matrix)
38
+ - Read all requirements/REQ-*.md (functional requirements with acceptance criteria)
39
+ - Read all requirements/NFR-*.md (non-functional requirements)
40
+ - Read architecture/_index.md (API endpoints, data model, state machines)
41
+ - Read epics/EPIC-*.md (user stories -> E2E scenario source)
42
+ SPEC_MODE = "full"
43
+
44
+ 4. IF no spec package found (DEGRADED MODE):
45
+ - Read index.json.success_criteria
46
+ - Read plan.json tasks with convergence.criteria
47
+ - Read .summaries/TASK-*-summary.md for implemented behavior
48
+ SPEC_MODE = "degraded"
49
+ Display: "No spec package found. Using success_criteria + plan.json for scenario extraction (degraded mode)."
50
+ ```
51
+
52
+ Check for existing business test session:
53
+ ```bash
54
+ ls ${PHASE_DIR}/.tests/business/business-test-report.json 2>/dev/null
55
+ ```
56
+
57
+ If session exists AND `--re-run`: load previous report, filter to failed/blocked scenarios only.
58
+ If session exists AND no `--re-run`: offer resume or restart.
59
+
60
+ ---
61
+
62
+ ### Step 2: Extract Business Test Scenarios from PRD
63
+
64
+ **Full mode (SPEC_MODE = "full"):**
65
+
66
+ For each `REQ-NNN-{slug}.md`:
67
+
68
+ 1. Parse `## Acceptance Criteria` section
69
+ 2. Extract each numbered criterion as a test scenario seed
70
+ 3. Map RFC 2119 keywords to test priority:
71
+
72
+ | Keyword | Priority | Failure Severity |
73
+ |---------|----------|-----------------|
74
+ | MUST / MUST NOT / SHALL / SHALL NOT | critical | blocker |
75
+ | SHOULD / SHOULD NOT / RECOMMENDED | high | major |
76
+ | MAY / OPTIONAL | medium | minor |
77
+
78
+ 4. Classify scenario into layer:
79
+
80
+ | Source | Layer | Category |
81
+ |--------|-------|----------|
82
+ | Architecture API endpoints + REQ AC about request/response | L1 | api_contract |
83
+ | REQ AC about business logic, validation, state changes | L2 | business_rule |
84
+ | REQ AC about state transitions (from architecture state machines) | L2 | state_transition |
85
+ | Epic user stories (multi-step flows) | L3 | user_flow |
86
+ | NFR performance/security constraints | L2 | non_functional |
87
+
88
+ 5. Generate scenario:
89
+ ```json
90
+ {
91
+ "id": "BT-{NNN}",
92
+ "req_ref": "REQ-{NNN}:AC-{N}",
93
+ "layer": "L1|L2|L3",
94
+ "priority": "critical|high|medium",
95
+ "name": "descriptive name derived from AC text",
96
+ "category": "api_contract|business_rule|state_transition|user_flow|non_functional",
97
+ "endpoint": "METHOD /path (if L1)",
98
+ "input": { "$fixture_ref": "REQ-{NNN}/valid|invalid|boundary/name" },
99
+ "expected": {
100
+ "status": 200,
101
+ "body_contains": [],
102
+ "behavior": "description of expected outcome"
103
+ },
104
+ "preconditions": ["list of required state"],
105
+ "postconditions": ["list of expected state changes"],
106
+ "mock_services": ["list of services to mock for isolation"]
107
+ }
108
+ ```
109
+
110
+ **Degraded mode (SPEC_MODE = "degraded"):**
111
+
112
+ - Extract scenarios from `index.json.success_criteria` (each criterion -> one L2 scenario)
113
+ - Extract from `plan.json` task convergence criteria (each criterion -> one L1 or L2 scenario)
114
+ - Extract from summaries (each implemented behavior -> one L1 scenario)
115
+ - All scenarios default to priority: "high"
116
+ - No L3 scenarios in degraded mode (no Epic stories available)
117
+
118
+ ---
119
+
120
+ ### Step 3: Generate Test Data (Fixtures)
121
+
122
+ For each REQ with data model definitions:
123
+
124
+ **Tier 1: Schema-derived fixtures**
125
+ ```
126
+ FOR each entity in REQ data model:
127
+ valid: object satisfying all field constraints
128
+ invalid: one variant per constraint violation:
129
+ - null_required: set required field to null
130
+ - empty_string: set string field to ""
131
+ - overflow: exceed max length or max value
132
+ - wrong_type: provide string where number expected, etc.
133
+ boundary: edge value variants:
134
+ - min_value: exact minimum
135
+ - max_value: exact maximum
136
+ - min_minus_one: minimum - 1
137
+ - max_plus_one: maximum + 1
138
+ ```
139
+
140
+ **Tier 2: Acceptance-criteria-derived expectations**
141
+ ```
142
+ FOR each "MUST return X when Y" in acceptance criteria:
143
+ fixture: { input: Y, expected: X }
144
+ FOR each "MUST validate Z":
145
+ fixture: { input: invalid_Z, expected: validation_error }
146
+ FOR each "SHOULD support W":
147
+ fixture: { input: W_params, expected: W_result }
148
+ ```
149
+
150
+ **Tier 3: Business-scenario-derived data sets (L3 only)**
151
+ ```
152
+ FOR each Epic user story:
153
+ scenario_pack: coordinated data set across story steps
154
+ Example: { user: registered_user, order: valid_order, payment: valid_card }
155
+ Entity IDs and relationships pre-coordinated across steps
156
+ ```
157
+
158
+ **Microservice mock data:**
159
+ ```
160
+ FOR each API endpoint in architecture/_index.md:
161
+ mock_contract: { request_pattern, response_fixture }
162
+ Used for: L2 WireMock stubs, L3 service isolation
163
+ ```
164
+
165
+ Organize fixtures by REQ:
166
+ ```json
167
+ {
168
+ "REQ-001": {
169
+ "valid": [{ "name": "standard_user", "data": {...} }],
170
+ "invalid": [{ "name": "missing_email", "data": {...}, "expected_error": "email is required" }],
171
+ "boundary": [{ "name": "max_length_name", "data": {...} }]
172
+ }
173
+ }
174
+ ```
175
+
176
+ ---
177
+
178
+ ### Step 4: Write Test Plan & Confirm
179
+
180
+ **Archive previous business test artifacts** before writing:
181
+ ```
182
+ IF file exists "${PHASE_DIR}/.tests/business/business-test-plan.json":
183
+ mkdir -p "${PHASE_DIR}/.history"
184
+ TIMESTAMP = format(now(), "YYYY-MM-DDTHH-mm-ss")
185
+ mv "${PHASE_DIR}/.tests/business/business-test-plan.json" "${PHASE_DIR}/.history/business-test-plan-${TIMESTAMP}.json"
186
+ ```
187
+
188
+ Write `business-test-plan.json` to `.tests/business/`:
189
+ ```json
190
+ {
191
+ "phase": "{phase}",
192
+ "blueprint_ref": "{SPEC_DIR name or 'degraded'}",
193
+ "spec_mode": "full|degraded",
194
+ "generated_at": "{ISO timestamp}",
195
+ "layers": {
196
+ "L1": { "scenario_count": N, "priority_distribution": { "critical": X, "high": Y, "medium": Z } },
197
+ "L2": { "scenario_count": N, "priority_distribution": {...} },
198
+ "L3": { "scenario_count": N, "priority_distribution": {...} }
199
+ },
200
+ "scenarios": [ ... ],
201
+ "fixtures": { ... },
202
+ "mock_contracts": [ ... ],
203
+ "requirement_coverage_plan": {
204
+ "requirements_targeted": ["REQ-001", "REQ-002"],
205
+ "requirements_skipped": [],
206
+ "skip_reasons": {}
207
+ }
208
+ }
209
+ ```
210
+
211
+ **If not `--auto`:**
212
+
213
+ Display plan summary:
214
+ ```
215
+ === BUSINESS TEST PLAN ===
216
+ Spec mode: {full|degraded}
217
+ Requirements: {N} targeted, {M} skipped
218
+
219
+ Layer Distribution:
220
+ L1 Interface: {N} scenarios ({X} critical, {Y} high)
221
+ L2 Business: {N} scenarios ({X} critical, {Y} high)
222
+ L3 E2E: {N} scenarios ({X} critical, {Y} high)
223
+
224
+ Fixtures: {N} REQs × {avg} variants = {total} data sets
225
+
226
+ Proceed? (yes/edit/cancel)
227
+ ```
228
+
229
+ Wait for user confirmation. If "edit": let user modify plan interactively.
230
+
231
+ **If `--dry-run`:** Stop here, report plan.
232
+
233
+ ---
234
+
235
+ **GATE Step 4→5**: REQUIRED `business-test-plan.json` written and user-confirmed before test generation; BLOCKED if plan missing or unconfirmed.
236
+
237
+ ### Step 5: Generate Test Code (if --gen-code)
238
+
239
+ **Detect project tech stack:**
240
+ ```
241
+ IF file exists ".workflow/project.md":
242
+ tech = parse Tech Stack section from project.md
243
+ ELSE:
244
+ Scan project for indicators (pom.xml -> Java, package.json -> Node, etc.)
245
+ ```
246
+
247
+ **Generate framework-specific test classes:**
248
+
249
+ | Stack | L1 | L2 | L3 |
250
+ |-------|----|----|-----|
251
+ | Java/Spring Boot | RestAssured + MockMvc | JUnit 5 Parameterized + WireMock | TestContainers |
252
+ | TypeScript/Node | supertest + vitest | vitest + nock | playwright/cypress |
253
+ | Python | httpx + pytest | pytest + responses | pytest + selenium |
254
+
255
+ **Generation rules:**
256
+ - Follow existing test patterns (discover from codebase, same as test-gen Step 1)
257
+ - Each test method has `@DisplayName` (or equivalent) with REQ-NNN:AC-N reference
258
+ - Each test class has layer marker (`@Tag("business-L1")` or equivalent)
259
+ - Test files placed in `.tests/business/{layer}/` directory
260
+
261
+ **If no `--gen-code`:** Scenarios remain as structured JSON for AI agent execution mode (Step 6).
262
+
263
+ ---
264
+
265
+ ### Step 6: Execute Tests (Progressive L1 -> L2 -> L3)
266
+
267
+ **Fail-fast rule:**
268
+ - If L1 has ANY "critical" priority failure -> STOP. Do not proceed to L2.
269
+ - If L2 has ANY "critical" priority failure -> STOP. Do not proceed to L3.
270
+ - "high" and "medium" failures do NOT block next layer.
271
+
272
+ **For each layer (starting from `--layer` if specified, else L1):**
273
+
274
+ Run Generator-Critic loop (max 3 iterations):
275
+
276
+ **Iteration 1: Execute all scenarios**
277
+
278
+ `--gen-code` mode:
279
+ ```bash
280
+ # Run generated test classes for current layer
281
+ {test_command} --testPathPattern="business-{layer}" 2>&1 | tail -50
282
+ ```
283
+
284
+ Agent execution mode:
285
+ ```
286
+ FOR each scenario in current layer:
287
+ Execute scenario against running application
288
+ Record: { status, actual_response, duration_ms, error_detail }
289
+ ```
290
+
291
+ **Critic phase: Classify failures**
292
+
293
+ For each failed scenario:
294
+ ```
295
+ Analyze failure evidence -> classify as:
296
+
297
+ | Classification | Meaning | Action |
298
+ |---------------|---------|--------|
299
+ | test_defect | Test itself is wrong (wrong endpoint, bad fixture) | Auto-fix test in next iteration |
300
+ | code_defect | Business rule violated (actual != expected per REQ) | Record as failure |
301
+ | env_issue | Service down, config missing, timeout | Record as blocked |
302
+ ```
303
+
304
+ **Iteration 2: Re-run with fixed tests**
305
+ - Fix test_defects from iteration 1
306
+ - Re-run ALL scenarios (not just failed ones — catch regressions)
307
+
308
+ **Iteration 3: Final confirmation**
309
+ - Remaining failures = confirmed code_defects
310
+ - All test_defects should be resolved
311
+ - Blocked scenarios marked with env_issue reason
312
+
313
+ Record results per iteration in `.tests/business/test-results-iter-{N}.json`.
314
+
315
+ ---
316
+
317
+ ### Step 7: Build Traceability Matrix
318
+
319
+ Map each scenario result back to requirement:
320
+
321
+ ```
322
+ FOR each REQ in requirements targeted:
323
+ req_results = {
324
+ req_id: "REQ-NNN",
325
+ title: REQ.title,
326
+ total_criteria: count of AC in REQ,
327
+ criteria_results: []
328
+ }
329
+
330
+ FOR each AC in REQ:
331
+ scenarios_for_ac = filter scenarios where req_ref == "REQ-NNN:AC-{N}"
332
+ ac_status = "passed" if ALL scenarios passed
333
+ "failed" if ANY scenario failed
334
+ "blocked" if ANY blocked and none failed
335
+ "untested" if no scenarios mapped
336
+
337
+ req_results.criteria_results.push({
338
+ ac_id: "AC-{N}",
339
+ description: AC text,
340
+ priority: mapped from RFC 2119 keyword,
341
+ status: ac_status,
342
+ tests: [scenario IDs],
343
+ failure: { expected, actual, evidence } if failed
344
+ })
345
+
346
+ req_results.coverage_pct = passed_criteria / total_criteria * 100
347
+ req_results.verdict = "verified" if all MUST+SHOULD passed
348
+ "partial" if some failed
349
+ "unverified" if all failed or untested
350
+ ```
351
+
352
+ ---
353
+
354
+ ### Step 8: Generate Reports
355
+
356
+ **Archive previous reports:**
357
+ ```
358
+ IF file exists "${PHASE_DIR}/.tests/business/business-test-report.json":
359
+ mkdir -p "${PHASE_DIR}/.history"
360
+ TIMESTAMP = format(now(), "YYYY-MM-DDTHH-mm-ss")
361
+ mv report and summary to .history/
362
+ ```
363
+
364
+ Write `.tests/business/business-test-report.json`:
365
+ ```json
366
+ {
367
+ "phase": "{phase}",
368
+ "blueprint_ref": "{spec reference}",
369
+ "spec_mode": "full|degraded",
370
+ "completed_at": "{ISO timestamp}",
371
+ "execution_mode": "gen-code|agent",
372
+ "iterations": {
373
+ "L1": { "count": N, "converged": true },
374
+ "L2": { "count": N, "converged": true },
375
+ "L3": { "count": N, "converged": false }
376
+ },
377
+ "layers": {
378
+ "L1": { "total": N, "passed": P, "failed": F, "blocked": B, "pass_rate": 95.0 },
379
+ "L2": { "total": N, "passed": P, "failed": F, "blocked": B, "pass_rate": 87.5 },
380
+ "L3": { "total": N, "passed": P, "failed": F, "blocked": B, "pass_rate": 100.0 }
381
+ },
382
+ "requirement_coverage": [
383
+ {
384
+ "req_id": "REQ-001",
385
+ "title": "...",
386
+ "total_criteria": 5,
387
+ "criteria_results": [
388
+ {
389
+ "ac_id": "AC-1",
390
+ "description": "...",
391
+ "priority": "critical",
392
+ "status": "passed|failed|blocked|untested",
393
+ "tests": ["BT-001", "BT-002"],
394
+ "failure": null
395
+ }
396
+ ],
397
+ "coverage_pct": 80.0,
398
+ "verdict": "verified|partial|unverified"
399
+ }
400
+ ],
401
+ "failures": [
402
+ {
403
+ "id": "BF-001",
404
+ "test_id": "BT-005",
405
+ "req_ref": "REQ-001:AC-3",
406
+ "layer": "L1",
407
+ "severity": "critical",
408
+ "classification": "code_defect",
409
+ "description": "...",
410
+ "expected": "...",
411
+ "actual": "...",
412
+ "fix_suggestion": {
413
+ "file": "src/...",
414
+ "line": 42,
415
+ "direction": "Add null guard for..."
416
+ }
417
+ }
418
+ ],
419
+ "summary": {
420
+ "total_requirements": 10,
421
+ "fully_verified": 8,
422
+ "partially_verified": 1,
423
+ "unverified": 1,
424
+ "coverage_pct": 85.0,
425
+ "total_scenarios": 30,
426
+ "total_passed": 26,
427
+ "total_failed": 3,
428
+ "total_blocked": 1
429
+ }
430
+ }
431
+ ```
432
+
433
+ Write `.tests/business/business-test-summary.md`:
434
+ ```markdown
435
+ ---
436
+ phase: {phase}
437
+ blueprint_ref: {spec reference}
438
+ completed_at: {ISO timestamp}
439
+ verdict: passed|gaps_found
440
+ ---
441
+
442
+ # Business Test Results
443
+
444
+ ## Requirement Coverage
445
+
446
+ | REQ | Title | AC Total | Passed | Failed | Coverage | Verdict |
447
+ |-----|-------|----------|--------|--------|----------|---------|
448
+ | REQ-001 | ... | 5 | 4 | 1 | 80% | partial |
449
+ | REQ-002 | ... | 3 | 3 | 0 | 100% | verified |
450
+
451
+ ## Layer Results
452
+
453
+ | Layer | Total | Passed | Failed | Blocked | Pass Rate |
454
+ |-------|-------|--------|--------|---------|-----------|
455
+ | L1 Interface | 10 | 9 | 1 | 0 | 90.0% |
456
+ | L2 Business | 15 | 13 | 1 | 1 | 86.7% |
457
+ | L3 E2E | 5 | 5 | 0 | 0 | 100.0% |
458
+
459
+ ## Failures
460
+
461
+ ### BF-001: REQ-001:AC-3 (critical)
462
+ - Layer: L1
463
+ - Expected: 201 Created with user object
464
+ - Actual: 400 Bad Request
465
+ - Fix: Add email validation bypass for internal accounts (src/auth.ts:42)
466
+
467
+ ## Next Steps
468
+ {routing suggestion}
469
+ ```
470
+
471
+ Update `index.json` with business_test section:
472
+ ```json
473
+ {
474
+ "business_test": {
475
+ "status": "passed|gaps_found",
476
+ "spec_mode": "full|degraded",
477
+ "req_coverage_pct": 85.0,
478
+ "layers": {
479
+ "L1": { "pass_rate": 90.0 },
480
+ "L2": { "pass_rate": 86.7 },
481
+ "L3": { "pass_rate": 100.0 }
482
+ },
483
+ "failures": [
484
+ { "id": "BF-001", "req_ref": "REQ-001:AC-3", "severity": "critical" }
485
+ ]
486
+ }
487
+ }
488
+ ```
489
+
490
+ ---
491
+
492
+ **GATE Step 8→9**: Glob `${PHASE_DIR}/.tests/business/business-test-report.json` MUST exist before Step 9 issue creation; BLOCKED if missing.
493
+
494
+ ### Step 9: Feedback Loop
495
+
496
+ **Auto-create issues from failures:**
497
+ ```
498
+ FOR each failure in report.failures:
499
+ mkdir -p ".workflow/issues"
500
+
501
+ today = format(now(), "YYYYMMDD")
502
+ counter = next available sequence for today
503
+
504
+ issue = {
505
+ id: "ISS-{today}-{counter:03d}",
506
+ title: "Business Test: " + failure.req_ref + " - " + failure.description (truncated 100 chars),
507
+ status: "registered",
508
+ priority: severity_to_priority(failure.severity),
509
+ severity: failure.severity,
510
+ source: "business-test",
511
+ phase_ref: PHASE_NUM,
512
+ gap_ref: failure.id,
513
+ description: "Business test failed for " + failure.req_ref + ". Expected: " + failure.expected + ". Actual: " + failure.actual,
514
+ fix_direction: failure.fix_suggestion.direction,
515
+ context: {
516
+ location: failure.fix_suggestion.file + ":" + failure.fix_suggestion.line,
517
+ suggested_fix: failure.fix_suggestion.direction,
518
+ notes: "req_ref: " + failure.req_ref + ", layer: " + failure.layer
519
+ },
520
+ tags: ["business-test", failure.layer],
521
+ affected_components: [failure.fix_suggestion.file],
522
+ feedback: [],
523
+ issue_history: [],
524
+ created_at: now(),
525
+ updated_at: now(),
526
+ resolved_at: null,
527
+ resolution: null
528
+ }
529
+ Append JSON line to .workflow/issues/issues.jsonl
530
+ ```
531
+
532
+ **Report:**
533
+ ```
534
+ === BUSINESS TEST RESULTS ===
535
+ Phase: {phase_name}
536
+ Spec mode: {full|degraded}
537
+
538
+ Requirement Coverage: {coverage_pct}%
539
+ Verified: {fully_verified}/{total_requirements}
540
+ Partial: {partially_verified}
541
+ Unverified: {unverified}
542
+
543
+ Layer Results:
544
+ L1 Interface: {pass_rate}% ({passed}/{total})
545
+ L2 Business: {pass_rate}% ({passed}/{total})
546
+ L3 E2E: {pass_rate}% ({passed}/{total})
547
+
548
+ Failures: {failure_count} ({blocker_count} blockers)
549
+ Issues: {issue_count} auto-created
550
+
551
+ Files:
552
+ {PHASE_DIR}/.tests/business/business-test-plan.json
553
+ {PHASE_DIR}/.tests/business/business-test-report.json
554
+ {PHASE_DIR}/.tests/business/business-test-summary.md
555
+
556
+ Next steps:
557
+ {suggested_next_command}
558
+ ```
559
+
560
+ **Next step routing:**
561
+
562
+ | Result | Suggestion |
563
+ |--------|------------|
564
+ | All requirements verified | Skill({ skill: "maestro-phase-transition", args: "{phase}" }) |
565
+ | Failures found | Skill({ skill: "quality-debug", args: "--from-business-test {phase}" }) |
566
+ | `--re-run` all pass after fix | Skill({ skill: "maestro-execute", args: "{phase}" }) |
567
+ | Low coverage (< 60%) | Skill({ skill: "quality-auto-test", args: "{phase}" }) |
568
+ | Need integration tests | Skill({ skill: "quality-auto-test", args: "{phase}" }) |
569
+
570
+ **Closure criteria:**
571
+ A requirement is marked "verified" ONLY when:
572
+ - ALL acceptance criteria with MUST/SHALL keywords: passed
573
+ - ALL acceptance criteria with SHOULD keywords: passed
574
+ - No blocker-severity failures remain for this requirement
@@ -0,0 +1,25 @@
1
+ # 中文回复准则
2
+
3
+ ## 核心原则
4
+
5
+ - 所有回复使用简体中文
6
+ - 技术术语保留英文,首次出现可添加中文解释
7
+ - 代码变量名保持英文,注释使用中文
8
+
9
+ ## 格式规范
10
+
11
+ - 中英文/数字间加空格:`使用 TypeScript 开发`、`共 3 个文件`
12
+ - 使用中文标点:,。!?:;
13
+ - 代码/命令用反引号:`npm install`
14
+
15
+ ## Git Commit
16
+
17
+ - 使用中文提交信息
18
+ - 格式:`类型: 简短描述`
19
+ - 类型:feat/fix/refactor/docs/test/chore
20
+
21
+ ## 保持英文
22
+
23
+ - 代码文件内容
24
+ - 错误信息和日志
25
+ - 文件路径和命令