Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. ---
  2. name: 'step-04c-aggregate'
  3. description: 'Aggregate subagent outputs and complete ATDD test infrastructure'
  4. outputFile: '{test_artifacts}/atdd-checklist-{story_key}.md'
  5. nextStepFile: '{skill-root}/steps-c/step-05-validate-and-complete.md'
  6. ---
  7. # Step 4C: Aggregate ATDD Test Generation Results
  8. ## STEP GOAL
  9. Read outputs from parallel subagents (API + E2E red-phase test generation), aggregate results, verify TDD red phase compliance, and create supporting infrastructure.
  10. ---
  11. ## MANDATORY EXECUTION RULES
  12. - 📖 Read the entire step file before acting
  13. - ✅ Speak in `{communication_language}`
  14. - ✅ Read subagent outputs from temp files
  15. - ✅ Verify all tests are marked with test.skip() (TDD red phase)
  16. - ✅ Generate shared fixtures based on fixture needs
  17. - ✅ Write all generated test files to disk
  18. - ❌ Do NOT remove test.skip() (that's done after feature implementation)
  19. - ❌ Do NOT run tests yet (that's step 5 - verify scaffolds and optional RED activation)
  20. ---
  21. ## EXECUTION PROTOCOLS:
  22. - 🎯 Follow the MANDATORY SEQUENCE exactly
  23. - 💾 Record outputs before proceeding
  24. - 📖 Load the next step only when instructed
  25. ## CONTEXT BOUNDARIES:
  26. - Available context: config, subagent outputs from temp files
  27. - Focus: aggregation and TDD validation
  28. - Limits: do not execute future steps
  29. - Dependencies: Step 4A and 4B subagent outputs
  30. ---
  31. ## MANDATORY SEQUENCE
  32. **CRITICAL:** Follow this sequence exactly. Do not skip, reorder, or improvise.
  33. ### 1. Read Subagent Outputs
  34. **Read API test subagent output:**
  35. ```javascript
  36. const apiTestsPath = '/tmp/tea-atdd-api-tests-{{timestamp}}.json';
  37. const apiTestsOutput = JSON.parse(fs.readFileSync(apiTestsPath, 'utf8'));
  38. ```
  39. **Read E2E test subagent output:**
  40. ```javascript
  41. const e2eTestsPath = '/tmp/tea-atdd-e2e-tests-{{timestamp}}.json';
  42. const e2eTestsOutput = JSON.parse(fs.readFileSync(e2eTestsPath, 'utf8'));
  43. ```
  44. **Verify both subagents succeeded:**
  45. - Check `apiTestsOutput.success === true`
  46. - Check `e2eTestsOutput.success === true`
  47. - If either failed, report error and stop (don't proceed)
  48. ---
  49. ### 2. Verify TDD Red Phase Compliance
  50. **CRITICAL TDD Validation:**
  51. **Check API tests:**
  52. ```javascript
  53. apiTestsOutput.tests.forEach((test) => {
  54. // Verify test.skip() is present
  55. if (!test.content.includes('test.skip(')) {
  56. throw new Error(`ATDD ERROR: ${test.file} missing test.skip() - tests MUST be skipped in red phase!`);
  57. }
  58. // Verify not placeholder assertions
  59. if (test.content.includes('expect(true).toBe(true)')) {
  60. throw new Error(`ATDD ERROR: ${test.file} has placeholder assertions - must assert EXPECTED behavior!`);
  61. }
  62. // Verify expected_to_fail flag
  63. if (!test.expected_to_fail) {
  64. throw new Error(`ATDD ERROR: ${test.file} not marked as expected_to_fail!`);
  65. }
  66. });
  67. ```
  68. **Check E2E tests:**
  69. ```javascript
  70. e2eTestsOutput.tests.forEach((test) => {
  71. // Same validation as API tests
  72. if (!test.content.includes('test.skip(')) {
  73. throw new Error(`ATDD ERROR: ${test.file} missing test.skip() - tests MUST be skipped in red phase!`);
  74. }
  75. if (test.content.includes('expect(true).toBe(true)')) {
  76. throw new Error(`ATDD ERROR: ${test.file} has placeholder assertions!`);
  77. }
  78. if (!test.expected_to_fail) {
  79. throw new Error(`ATDD ERROR: ${test.file} not marked as expected_to_fail!`);
  80. }
  81. });
  82. ```
  83. **If validation passes:**
  84. ```
  85. ✅ TDD Red Phase Validation: PASS
  86. - All tests use test.skip()
  87. - All tests assert expected behavior (not placeholders)
  88. - All tests marked as expected_to_fail
  89. ```
  90. ---
  91. ### 3. Write All Test Files to Disk
  92. **Write API test files:**
  93. ```javascript
  94. apiTestsOutput.tests.forEach((test) => {
  95. fs.writeFileSync(test.file, test.content, 'utf8');
  96. console.log(`✅ Created (RED): ${test.file}`);
  97. });
  98. ```
  99. **Write E2E test files:**
  100. ```javascript
  101. e2eTestsOutput.tests.forEach((test) => {
  102. fs.writeFileSync(test.file, test.content, 'utf8');
  103. console.log(`✅ Created (RED): ${test.file}`);
  104. });
  105. ```
  106. ---
  107. ### 4. Aggregate Fixture Needs
  108. **Collect all fixture needs from both subagents:**
  109. ```javascript
  110. const allFixtureNeeds = [...apiTestsOutput.fixture_needs, ...e2eTestsOutput.fixture_needs];
  111. // Remove duplicates
  112. const uniqueFixtures = [...new Set(allFixtureNeeds)];
  113. ```
  114. ---
  115. ### 5. Generate Fixture Infrastructure
  116. **Create fixtures needed by ATDD tests:**
  117. (Similar to automate workflow, but may be simpler for ATDD since feature not implemented)
  118. **Minimal fixtures for TDD red phase:**
  119. ```typescript
  120. // tests/fixtures/test-data.ts
  121. export const testUserData = {
  122. email: 'test@example.com',
  123. password: 'SecurePass123!',
  124. };
  125. ```
  126. Note: More complete fixtures will be needed when moving to green phase.
  127. ---
  128. ### 6. Generate ATDD Checklist
  129. **Create ATDD checklist document:**
  130. ```markdown
  131. # ATDD Checklist: [Story Name]
  132. ## TDD Red Phase (Current)
  133. ✅ Red-phase test scaffolds generated
  134. - API Tests: {api_test_count} tests (all skipped)
  135. - E2E Tests: {e2e_test_count} tests (all skipped)
  136. ## Acceptance Criteria Coverage
  137. {list all acceptance criteria with test coverage}
  138. ## Next Steps (Task-by-Task Activation)
  139. During implementation of each task:
  140. 1. Remove `test.skip()` from the current test file or scenario
  141. 2. Run tests: `npm test`
  142. 3. Verify the activated test fails first, then passes after implementation (green phase)
  143. 4. If any activated tests still fail unexpectedly:
  144. - Either fix implementation (feature bug)
  145. - Or fix test (test bug)
  146. 5. Commit passing tests
  147. ## Implementation Guidance
  148. Feature endpoints to implement:
  149. {list endpoints from API tests}
  150. UI components to implement:
  151. {list UI flows from E2E tests}
  152. ```
  153. **Save checklist:**
  154. ```javascript
  155. fs.writeFileSync(`{test_artifacts}/atdd-checklist-{story_key}.md`, checklistContent, 'utf8');
  156. ```
  157. **If `{story_file}` exists and is writable, attempt to link artifacts back into the story:**
  158. - Add or update a `### ATDD Artifacts` subsection under `## Dev Notes`
  159. - Record:
  160. - `Checklist: {test_artifacts}/atdd-checklist-{story_key}.md`
  161. - `API tests: {api_test_file_path}` when present
  162. - `E2E tests: {e2e_test_file_path}` when present
  163. - `Component tests: {component_test_file_path}` when present
  164. - Preserve all other story content verbatim
  165. - The checklist template already contains the manual handoff instructions if story linking is not possible
  166. - If the story file cannot be updated safely, continue without failing the workflow and keep the checklist's manual handoff instructions intact
  167. ---
  168. ### 7. Calculate Summary Statistics
  169. **Aggregate test counts:**
  170. ```javascript
  171. const resolvedMode = subagentContext?.execution?.resolvedMode; // Provided by Step 4's orchestration context
  172. const subagentExecutionLabel =
  173. resolvedMode === 'sequential'
  174. ? 'SEQUENTIAL (API → E2E)'
  175. : resolvedMode === 'agent-team'
  176. ? 'AGENT-TEAM (API + E2E)'
  177. : resolvedMode === 'subagent'
  178. ? 'SUBAGENT (API + E2E)'
  179. : 'PARALLEL (API + E2E)';
  180. const performanceGainLabel =
  181. resolvedMode === 'sequential'
  182. ? 'baseline (no parallel speedup)'
  183. : resolvedMode === 'agent-team' || resolvedMode === 'subagent'
  184. ? '~50% faster than sequential'
  185. : 'mode-dependent';
  186. const summary = {
  187. tdd_phase: 'RED',
  188. total_tests: apiTestsOutput.test_count + e2eTestsOutput.test_count,
  189. api_tests: apiTestsOutput.test_count,
  190. e2e_tests: e2eTestsOutput.test_count,
  191. all_tests_skipped: true,
  192. expected_to_fail: true,
  193. fixtures_created: uniqueFixtures.length,
  194. acceptance_criteria_covered: [
  195. ...apiTestsOutput.tests.flatMap((t) => t.acceptance_criteria_covered),
  196. ...e2eTestsOutput.tests.flatMap((t) => t.acceptance_criteria_covered),
  197. ],
  198. knowledge_fragments_used: [...apiTestsOutput.knowledge_fragments_used, ...e2eTestsOutput.knowledge_fragments_used],
  199. subagent_execution: subagentExecutionLabel,
  200. performance_gain: performanceGainLabel,
  201. };
  202. ```
  203. **Store summary for Step 5:**
  204. ```javascript
  205. fs.writeFileSync('/tmp/tea-atdd-summary-{{timestamp}}.json', JSON.stringify(summary, null, 2), 'utf8');
  206. ```
  207. ---
  208. ## OUTPUT SUMMARY
  209. Display to user:
  210. ```
  211. ✅ ATDD Test Generation Complete (TDD RED PHASE)
  212. 🔴 TDD Red Phase: Test Scaffolds Generated
  213. 📊 Summary:
  214. - Total Tests: {total_tests} (all with test.skip())
  215. - API Tests: {api_tests} (RED)
  216. - E2E Tests: {e2e_tests} (RED)
  217. - Fixtures Created: {fixtures_created}
  218. - Activated tests will FAIL until feature is implemented
  219. ✅ Acceptance Criteria Coverage:
  220. {list all covered criteria}
  221. 🚀 Performance: {performance_gain}
  222. 📂 Generated Files:
  223. - tests/api/[feature].spec.ts (with test.skip())
  224. - tests/e2e/[feature].spec.ts (with test.skip())
  225. - tests/fixtures/test-data.ts
  226. - {test_artifacts}/atdd-checklist-{story_key}.md
  227. 📝 Next Steps:
  228. 1. Link ATDD artifacts into the story file if available
  229. 2. Implement the feature
  230. 3. Remove test.skip() from the tests for the current task
  231. 4. Run activated tests → verify they FAIL before implementation, then PASS after implementation
  232. 5. Commit passing tests
  233. ✅ Ready for validation (Step 5 - verify red-phase scaffolds and handoff metadata)
  234. ```
  235. ---
  236. ## EXIT CONDITION
  237. Proceed to Step 5 when:
  238. - ✅ All test files written to disk (API + E2E)
  239. - ✅ All tests verified to have test.skip()
  240. - ✅ All fixtures created
  241. - ✅ ATDD checklist generated
  242. - ✅ Summary statistics calculated and saved
  243. - ✅ Output displayed to user
  244. ---
  245. ### 8. Save Progress
  246. **Save this step's accumulated work to `{outputFile}`.**
  247. - **If `{outputFile}` does not exist** (first save), create it with YAML frontmatter:
  248. ```yaml
  249. ---
  250. stepsCompleted: ['step-04c-aggregate']
  251. lastStep: 'step-04c-aggregate'
  252. lastSaved: '{date}'
  253. storyId: '{story_id}'
  254. storyKey: '{story_key}'
  255. storyFile: '{story_file}'
  256. atddChecklistPath: '{outputFile}'
  257. generatedTestFiles: []
  258. ---
  259. ```
  260. Then write this step's output below the frontmatter.
  261. - **If `{outputFile}` already exists**, update:
  262. - Add `'step-04c-aggregate'` to `stepsCompleted` array (only if not already present)
  263. - Set `lastStep: 'step-04c-aggregate'`
  264. - Set `lastSaved: '{date}'`
  265. - Set `storyId` to `{story_id}`
  266. - Set `storyKey` to `{story_key}`
  267. - Set `storyFile` to `{story_file}`
  268. - Set `atddChecklistPath` to `{outputFile}`
  269. - Set `generatedTestFiles` deterministically to the list of present test paths in this order: API, E2E, Component (omit blanks / N/A values)
  270. - Append this step's output to the appropriate section.
  271. Load next step: `{nextStepFile}`
  272. ---
  273. ## 🚨 SYSTEM SUCCESS/FAILURE METRICS:
  274. ### ✅ SUCCESS:
  275. - Both subagents succeeded
  276. - All tests have test.skip() (TDD red phase compliant)
  277. - All tests assert expected behavior (not placeholders)
  278. - All test files written to disk
  279. - ATDD checklist generated
  280. - Story metadata and handoff paths captured in checklist frontmatter
  281. ### ❌ SYSTEM FAILURE:
  282. - One or both subagents failed
  283. - Tests missing test.skip() (would break CI)
  284. - Tests have placeholder assertions
  285. - Test files not written to disk
  286. - ATDD checklist missing
  287. **Master Rule:** TDD RED PHASE requires ALL tests to use test.skip() and assert expected behavior.