eyaltoledano/claude-task-master · error
GREEN phase must have zero failures
Error message
GREEN phase must have zero failures
What it means
GREEN in this TDD state machine means 'implement until all tests pass', so the orchestrator refuses to leave GREEN while any test is failing. This error is thrown when a GREEN_PHASE_COMPLETE event carries testResults whose failed count is not 0. Unlike RED (where failing tests are expected and drive the flow), only a fully green suite may advance the workflow to COMMIT.
Source
Thrown at packages/tm-core/src/modules/workflow/orchestrators/workflow-orchestrator.ts:229
this.context.currentTDDPhase = 'GREEN';
this.emit('tdd:green:started');
break;
case 'GREEN_PHASE_COMPLETE':
if (currentTDD !== 'GREEN') {
throw new Error(
'Invalid transition: GREEN_PHASE_COMPLETE from non-GREEN phase'
);
}
// Validate test results are provided
if (!event.testResults) {
throw new Error('Test results required for GREEN phase transition');
}
// Validate GREEN phase has no failures
if (event.testResults.failed !== 0) {
throw new Error('GREEN phase must have zero failures');
}
// Store test results in context
this.context.lastTestResults = event.testResults;
this.emit('tdd:green:completed');
this.context.currentTDDPhase = 'COMMIT';
this.emit('tdd:commit:started');
break;
case 'COMMIT_COMPLETE':
if (currentTDD !== 'COMMIT') {
throw new Error(
'Invalid transition: COMMIT_COMPLETE from non-COMMIT phase'
);
}
this.emit('tdd:commit:completed');
// Mark current subtask as completedView on GitHub (pinned to c0c98d367c)
Solutions
- Fix the failing tests or the implementation, re-run the suite until failed === 0, then dispatch GREEN_PHASE_COMPLETE with the fresh passing results.
- Re-run the full test suite immediately before the transition so the attached summary reflects current code.
- Investigate flaky tests (isolate, mock external dependencies, add retries) if failures are intermittent.
- If the subtask cannot be made to pass, abort or restructure the workflow instead of forcing the GREEN transition.
Example fix
// before
await orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE', testResults: currentRun });
// after
if (currentRun.failed !== 0) {
throw new Error(`Cannot complete GREEN: ${currentRun.failed} test(s) still failing`);
}
await orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE', testResults: currentRun }); Defensive patterns
Strategy: validation
Validate before calling
if (testResults.failed !== 0) {
throw new Error(`Refusing GREEN_PHASE_COMPLETE: ${testResults.failed} test(s) failing`);
} Type guard
function isGreenPassing(r: { total: number; passed: number; failed: number }): boolean {
return r.failed === 0 && r.passed + r.failed === r.total;
} Try / catch
try {
await orchestrator.transition({ type: 'GREEN_PHASE_COMPLETE', testResults });
} catch (e) {
if (e instanceof Error && e.message.includes('zero failures')) {
// stay in GREEN: fix code/tests and re-run before retrying
} else {
throw e;
}
} Prevention
- Gate the transition in CI code on a green suite: only dispatch when failed === 0.
- Re-run the full suite right before the transition; never reuse stale summaries.
- Treat intermittent failures as blockers — stabilize or quarantine flaky tests before completing GREEN.
When it happens
Trigger: Calling transition({ type: 'GREEN_PHASE_COMPLETE', testResults }) where testResults.failed > 0; dispatching the event before the full suite has been re-run after implementation; reporting results from a partial/filtered test run that excludes still-failing tests from its counts incorrectly.
Common situations: Developer/agent declares the subtask done while some tests still fail; flaky tests fail intermittently when the GREEN suite runs; a test-runner integration counts errors/skipped tests as failures; stale results from a previous run are attached to the event.
Related errors
- Test results required for RED phase transition
- Test results required for GREEN phase transition
- Invalid transition: RED_PHASE_COMPLETE from non-RED phase
- Invalid transition: GREEN_PHASE_COMPLETE from non-GREEN phas
- Invalid transition: COMMIT_COMPLETE from non-COMMIT phase
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/1d6c467a44dffed0.
Report an issue: GitHub.