name: ‘step-04c-aggregate’ description: ‘Aggregate subagent outputs and complete ATDD test infrastructure’ outputFile: ‘{test_artifacts}/atdd-checklist-{story_key}.md’
Read outputs from parallel subagents (API + E2E red-phase test generation), aggregate results, verify TDD red phase compliance, and create supporting infrastructure.
{communication_language}CRITICAL: Follow this sequence exactly. Do not skip, reorder, or improvise.
Read API test subagent output:
const apiTestsPath = '/tmp/tea-atdd-api-tests-{{timestamp}}.json';
const apiTestsOutput = JSON.parse(fs.readFileSync(apiTestsPath, 'utf8'));
Read E2E test subagent output:
const e2eTestsPath = '/tmp/tea-atdd-e2e-tests-{{timestamp}}.json';
const e2eTestsOutput = JSON.parse(fs.readFileSync(e2eTestsPath, 'utf8'));
Verify both subagents succeeded:
apiTestsOutput.success === truee2eTestsOutput.success === trueCRITICAL TDD Validation:
Check API tests:
apiTestsOutput.tests.forEach((test) => {
// Verify test.skip() is present
if (!test.content.includes('test.skip(')) {
throw new Error(`ATDD ERROR: ${test.file} missing test.skip() - tests MUST be skipped in red phase!`);
}
// Verify not placeholder assertions
if (test.content.includes('expect(true).toBe(true)')) {
throw new Error(`ATDD ERROR: ${test.file} has placeholder assertions - must assert EXPECTED behavior!`);
}
// Verify expected_to_fail flag
if (!test.expected_to_fail) {
throw new Error(`ATDD ERROR: ${test.file} not marked as expected_to_fail!`);
}
});
Check E2E tests:
e2eTestsOutput.tests.forEach((test) => {
// Same validation as API tests
if (!test.content.includes('test.skip(')) {
throw new Error(`ATDD ERROR: ${test.file} missing test.skip() - tests MUST be skipped in red phase!`);
}
if (test.content.includes('expect(true).toBe(true)')) {
throw new Error(`ATDD ERROR: ${test.file} has placeholder assertions!`);
}
if (!test.expected_to_fail) {
throw new Error(`ATDD ERROR: ${test.file} not marked as expected_to_fail!`);
}
});
If validation passes:
✅ TDD Red Phase Validation: PASS
- All tests use test.skip()
- All tests assert expected behavior (not placeholders)
- All tests marked as expected_to_fail
Write API test files:
apiTestsOutput.tests.forEach((test) => {
fs.writeFileSync(test.file, test.content, 'utf8');
console.log(`✅ Created (RED): ${test.file}`);
});
Write E2E test files:
e2eTestsOutput.tests.forEach((test) => {
fs.writeFileSync(test.file, test.content, 'utf8');
console.log(`✅ Created (RED): ${test.file}`);
});
Collect all fixture needs from both subagents:
const allFixtureNeeds = [...apiTestsOutput.fixture_needs, ...e2eTestsOutput.fixture_needs];
// Remove duplicates
const uniqueFixtures = [...new Set(allFixtureNeeds)];
Create fixtures needed by ATDD tests: (Similar to automate workflow, but may be simpler for ATDD since feature not implemented)
Minimal fixtures for TDD red phase:
// tests/fixtures/test-data.ts
export const testUserData = {
email: 'test@example.com',
password: 'SecurePass123!',
};
Note: More complete fixtures will be needed when moving to green phase.
Create ATDD checklist document:
# ATDD Checklist: [Story Name]
## TDD Red Phase (Current)
✅ Red-phase test scaffolds generated
- API Tests: {api_test_count} tests (all skipped)
- E2E Tests: {e2e_test_count} tests (all skipped)
## Acceptance Criteria Coverage
{list all acceptance criteria with test coverage}
## Next Steps (Task-by-Task Activation)
During implementation of each task:
1. Remove `test.skip()` from the current test file or scenario
2. Run tests: `npm test`
3. Verify the activated test fails first, then passes after implementation (green phase)
4. If any activated tests still fail unexpectedly:
- Either fix implementation (feature bug)
- Or fix test (test bug)
5. Commit passing tests
## Implementation Guidance
Feature endpoints to implement:
{list endpoints from API tests}
UI components to implement:
{list UI flows from E2E tests}
Save checklist:
fs.writeFileSync(`{test_artifacts}/atdd-checklist-{story_key}.md`, checklistContent, 'utf8');
If {story_file} exists and is writable, attempt to link artifacts back into the story:
### ATDD Artifacts subsection under ## Dev NotesChecklist: {test_artifacts}/atdd-checklist-{story_key}.mdAPI tests: {api_test_file_path} when presentE2E tests: {e2e_test_file_path} when presentComponent tests: {component_test_file_path} when presentAggregate test counts:
const resolvedMode = subagentContext?.execution?.resolvedMode; // Provided by Step 4's orchestration context
const subagentExecutionLabel =
resolvedMode === 'sequential'
? 'SEQUENTIAL (API → E2E)'
: resolvedMode === 'agent-team'
? 'AGENT-TEAM (API + E2E)'
: resolvedMode === 'subagent'
? 'SUBAGENT (API + E2E)'
: 'PARALLEL (API + E2E)';
const performanceGainLabel =
resolvedMode === 'sequential'
? 'baseline (no parallel speedup)'
: resolvedMode === 'agent-team' || resolvedMode === 'subagent'
? '~50% faster than sequential'
: 'mode-dependent';
const summary = {
tdd_phase: 'RED',
total_tests: apiTestsOutput.test_count + e2eTestsOutput.test_count,
api_tests: apiTestsOutput.test_count,
e2e_tests: e2eTestsOutput.test_count,
all_tests_skipped: true,
expected_to_fail: true,
fixtures_created: uniqueFixtures.length,
acceptance_criteria_covered: [
...apiTestsOutput.tests.flatMap((t) => t.acceptance_criteria_covered),
...e2eTestsOutput.tests.flatMap((t) => t.acceptance_criteria_covered),
],
knowledge_fragments_used: [...apiTestsOutput.knowledge_fragments_used, ...e2eTestsOutput.knowledge_fragments_used],
subagent_execution: subagentExecutionLabel,
performance_gain: performanceGainLabel,
};
Store summary for Step 5:
fs.writeFileSync('/tmp/tea-atdd-summary-{{timestamp}}.json', JSON.stringify(summary, null, 2), 'utf8');
Display to user:
✅ ATDD Test Generation Complete (TDD RED PHASE)
🔴 TDD Red Phase: Test Scaffolds Generated
📊 Summary:
- Total Tests: {total_tests} (all with test.skip())
- API Tests: {api_tests} (RED)
- E2E Tests: {e2e_tests} (RED)
- Fixtures Created: {fixtures_created}
- Activated tests will FAIL until feature is implemented
✅ Acceptance Criteria Coverage:
{list all covered criteria}
🚀 Performance: {performance_gain}
📂 Generated Files:
- tests/api/[feature].spec.ts (with test.skip())
- tests/e2e/[feature].spec.ts (with test.skip())
- tests/fixtures/test-data.ts
- {test_artifacts}/atdd-checklist-{story_key}.md
📝 Next Steps:
1. Link ATDD artifacts into the story file if available
2. Implement the feature
3. Remove test.skip() from the tests for the current task
4. Run activated tests → verify they FAIL before implementation, then PASS after implementation
5. Commit passing tests
✅ Ready for validation (Step 5 - verify red-phase scaffolds and handoff metadata)
Proceed to Step 5 when:
Save this step’s accumulated work to {outputFile}.
{outputFile} does not exist (first save), create it with YAML frontmatter: ---
stepsCompleted: ['step-04c-aggregate']
lastStep: 'step-04c-aggregate'
lastSaved: '{date}'
storyId: '{story_id}'
storyKey: '{story_key}'
storyFile: '{story_file}'
atddChecklistPath: '{outputFile}'
generatedTestFiles: []
---
Then write this step’s output below the frontmatter.
{outputFile} already exists, update:
'step-04c-aggregate' to stepsCompleted array (only if not already present)lastStep: 'step-04c-aggregate'lastSaved: '{date}'storyId to {story_id}storyKey to {story_key}storyFile to {story_file}atddChecklistPath to {outputFile}generatedTestFiles deterministically to the list of present test paths in this order: API, E2E, Component (omit blanks / N/A values)Load next step: {nextStepFile}
Master Rule: TDD RED PHASE requires ALL tests to use test.skip() and assert expected behavior.