{"record":{"id":"6b86d5ee64890992","repo":"eyaltoledano/claude-task-master","slug":"test-results-required-for-green-phase-transition","errorCode":null,"errorMessage":"Test results required for GREEN phase transition","messagePattern":"Test results required for GREEN phase transition","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/workflow/orchestrators/workflow-orchestrator.ts","lineNumber":224,"sourceCode":"\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Normal RED phase: has failing tests, proceed to GREEN\n\t\t\t\tthis.emit('tdd:red:completed');\n\t\t\t\tthis.context.currentTDDPhase = 'GREEN';\n\t\t\t\tthis.emit('tdd:green:started');\n\t\t\t\tbreak;\n\n\t\t\tcase 'GREEN_PHASE_COMPLETE':\n\t\t\t\tif (currentTDD !== 'GREEN') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Invalid transition: GREEN_PHASE_COMPLETE from non-GREEN phase'\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Validate test results are provided\n\t\t\t\tif (!event.testResults) {\n\t\t\t\t\tthrow new Error('Test results required for GREEN phase transition');\n\t\t\t\t}\n\n\t\t\t\t// Validate GREEN phase has no failures\n\t\t\t\tif (event.testResults.failed !== 0) {\n\t\t\t\t\tthrow new Error('GREEN phase must have zero failures');\n\t\t\t\t}\n\n\t\t\t\t// Store test results in context\n\t\t\t\tthis.context.lastTestResults = event.testResults;\n\n\t\t\t\tthis.emit('tdd:green:completed');\n\t\t\t\tthis.context.currentTDDPhase = 'COMMIT';\n\t\t\t\tthis.emit('tdd:commit:started');\n\t\t\t\tbreak;\n\n\t\t\tcase 'COMMIT_COMPLETE':\n\t\t\t\tif (currentTDD !== 'COMMIT') {\n\t\t\t\t\tthrow new Error(","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/workflow/orchestrators/workflow-orchestrator.ts#L206-L242","documentation":"When completing the GREEN (implementation) phase of the TDD cycle, the orchestrator requires the event to carry test results proving the implementation works. This error is thrown by handleTDDPhaseTransition when a GREEN_PHASE_COMPLETE event is dispatched with event.testResults undefined. The results are stored in context.lastTestResults and are validated to have zero failures before the workflow may advance to COMMIT.","triggerScenarios":"Calling orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE' }) without a testResults field; constructing the event object dynamically and omitting testResults when the test run produced no summary; a test runner integration that fails to attach its summary object to the event.","commonSituations":"Custom automation that fires phase events manually; a test runner wrapper returning undefined on runner crash so the summary never gets attached; refactoring event shapes after a version change where testResults became mandatory on GREEN_PHASE_COMPLETE.","solutions":["Attach a test results summary to the event: transition({ type: 'GREEN_PHASE_COMPLETE', testResults: { total, passed, failed } }).","Run the test suite and capture its summary before dispatching the GREEN_PHASE_COMPLETE event.","If the test runner crashed and produced no summary, treat it as a failed GREEN phase rather than completing it; fix the runner or tests first.","Guard the call site: only dispatch when a non-null testResults object exists."],"exampleFix":"// before\nawait orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE' });\n\n// after\nconst testResults = await runTests(); // { total, passed, failed }\nawait orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE', testResults });","handlingStrategy":"validation","validationCode":"function hasTestResults(e: { type: string; testResults?: { total: number; passed: number; failed: number } }): boolean {\n  return e.type === 'GREEN_PHASE_COMPLETE' && !!e.testResults && typeof e.testResults.failed === 'number';\n}\n// call: if (!hasTestResults(event)) throw new Error('Attach test results before GREEN_PHASE_COMPLETE');","typeGuard":"function hasTestResults(e: unknown): e is { type: 'GREEN_PHASE_COMPLETE'; testResults: { total: number; passed: number; failed: number } } {\n  const ev = e as { type?: string; testResults?: { failed?: unknown } };\n  return ev.type === 'GREEN_PHASE_COMPLETE' && !!ev.testResults && typeof ev.testResults.failed === 'number';\n}","tryCatchPattern":"try {\n  await orchestrator.transition(event);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Test results required for GREEN')) {\n    const results = await runTests();\n    await orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE', testResults: results });\n  } else {\n    throw e;\n  }\n}","preventionTips":["Never dispatch GREEN_PHASE_COMPLETE by hand — derive it from a completed test run whose summary is attached.","Wrap test-runner integration so a crashed run cannot produce an event with missing results.","Type the event object so testResults is required for GREEN_PHASE_COMPLETE (discriminated union)."],"tags":["validation","workflow","tdd","missing-argument"],"backgroundTag":"missing-required-field","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}