{"record":{"id":"31efd9967337637c","repo":"eyaltoledano/claude-task-master","slug":"cannot-complete-commit-phase-with-test-results-us","errorCode":null,"errorMessage":"Cannot complete COMMIT phase with test results. Use commit() instead.","messagePattern":"Cannot complete COMMIT phase with test results\\. Use commit\\(\\) instead\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/workflow/services/workflow.service.ts","lineNumber":443,"sourceCode":"\t\t\tthrow new Error('Not in active TDD phase');\n\t\t}\n\n\t\t// Transition based on current phase\n\t\tswitch (tddPhase) {\n\t\t\tcase 'RED':\n\t\t\t\tawait this.orchestrator.transition({\n\t\t\t\t\ttype: 'RED_PHASE_COMPLETE',\n\t\t\t\t\ttestResults\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'GREEN':\n\t\t\t\tawait this.orchestrator.transition({\n\t\t\t\t\ttype: 'GREEN_PHASE_COMPLETE',\n\t\t\t\t\ttestResults\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'COMMIT':\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Cannot complete COMMIT phase with test results. Use commit() instead.'\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unknown TDD phase: ${tddPhase}`);\n\t\t}\n\n\t\treturn this.getStatus();\n\t}\n\n\t/**\n\t * Commit current changes and advance workflow\n\t */\n\tasync commit(): Promise<WorkflowStatus> {\n\t\tif (!this.orchestrator) {\n\t\t\tthrow new Error('No active workflow. Start or resume a workflow first.');\n\t\t}\n\n\t\tconst tddPhase = this.orchestrator.getCurrentTDDPhase();","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/workflow/services/workflow.service.ts#L425-L461","documentation":"completePhase(testResults) handles RED and GREEN transitions only. When the current TDD phase is COMMIT, test results are meaningless because the RED-GREEN cycle already finished; the workflow expects a commit via commit(). The library throws this explicit redirect so agents do not try to 'complete' the COMMIT phase with results.","triggerScenarios":"Calling completePhase() while orchestrator.getCurrentTDDPhase() === 'COMMIT' — e.g. after GREEN already completed and the machine advanced to COMMIT; an automation loop that keeps posting test results each cycle without checking the phase.","commonSituations":"An AI agent running autopilot_complete_phase in a loop and overshooting into COMMIT; test-runner webhooks re-delivering results after the phase advanced; scripted pipelines that always call completePhase after tests regardless of phase.","solutions":["Check the phase first and call commit() when tddPhase === 'COMMIT' instead of completePhase()","Use getNextAction(); when it returns action 'commit_changes', invoke commit()","Stop resubmitting test results after a successful GREEN completion; the same results transitioned you already","Catch the error and route to commit() in agent loops"],"exampleFix":"// before\nawait workflowService.completePhase(results); // throws in COMMIT\n// after\nconst tdd = workflowService.getStatus().tddPhase;\nif (tdd === 'COMMIT') {\n  await workflowService.commit();\n} else {\n  await workflowService.completePhase(results);\n}","handlingStrategy":"validation","validationCode":"const tdd = workflowService.getStatus().tddPhase;\nif (tdd === 'COMMIT') {\n  await workflowService.commit();\n} else {\n  await workflowService.completePhase(results);\n}","typeGuard":"function isCommitPhase(e: unknown): e is Error {\n  return e instanceof Error && e.message.includes('Cannot complete COMMIT phase');\n}","tryCatchPattern":"try {\n  await workflowService.completePhase(results);\n} catch (e) {\n  if (isCommitPhase(e)) {\n    await workflowService.commit();\n  } else throw e;\n}","preventionTips":["Route on phase: RED/GREEN -> completePhase(results), COMMIT -> commit()","Stop resubmitting test results once GREEN completed; track the last transition in your loop","Use getNextAction().action ('commit_changes' vs 'generate_test'/'implement_code') to pick the call","Guard test-runner webhooks against re-delivery of old results"],"tags":["workflow","tdd","api-misuse"],"backgroundTag":"invalid-workflow-phase","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}