{"record":{"id":"79919b642061540f","repo":"Yeachan-Heo/oh-my-codex","slug":"teamcontinuationrequireddiagnostic-phasestate","errorCode":null,"errorMessage":"teamContinuationRequiredDiagnostic(phaseState)","messagePattern":"teamContinuationRequiredDiagnostic\\(phaseState\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime.ts","lineNumber":4686,"sourceCode":"      updated_at: updatedAt,\n    },\n  };\n}\n\n/**\n * Assign a task to a worker by writing inbox and sending trigger.\n */\nexport async function assignTask(\n  teamName: string,\n  workerName: string,\n  taskId: string,\n  cwd: string,\n): Promise<void> {\n  const sanitized = sanitizeTeamName(teamName);\n  return await withTeamTaskMembershipBarrier(sanitized, cwd, async () => {\n    const phaseState = await readTeamPhaseState(sanitized, cwd);\n    if (phaseState?.terminal_epoch || (phaseState && isTerminalPhase(phaseState.current_phase))) {\n      throw new Error(teamContinuationRequiredDiagnostic(phaseState));\n    }\n    const task = await readTask(sanitized, taskId, cwd);\n    if (!task) throw new Error(`Task ${taskId} not found`);\n  const manifest = await readTeamManifestV2(sanitized, cwd);\n  const governance = resolveGovernancePolicy(manifest?.governance);\n\n  if (governance.delegation_only && workerName === 'leader-fixed') {\n    throw new Error('delegation_only_violation');\n  }\n\n  if (governance.plan_approval_required && task.requires_code_change === true) {\n    const approved = await isTaskApprovedForExecution(sanitized, taskId, cwd);\n    if (!approved) {\n      throw new Error('plan_approval_required');\n    }\n  }\n  const config = await readTeamConfig(sanitized, cwd);\n  if (!config) throw new Error(`Team ${sanitized} not found`);","sourceCodeStart":4668,"sourceCodeEnd":4704,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime.ts#L4668-L4704","documentation":"Thrown when a team task operation is attempted on a team whose phase state is terminal (a terminal_epoch is recorded or the current_phase is a terminal phase). The runtime refuses to continue normal task workflows after the team has finished/shut down, and instead emits a diagnostic describing the terminal state.","triggerScenarios":"Calling the task-assignment entry point (the function around src/team/runtime.ts:4686) after the team reached a terminal phase — e.g. after shutdown completed or a terminal_epoch was written to team phase state. The check fires before the task is even read.","commonSituations":"A queued job/CI pipeline retries task dispatch after a team was shut down mid-run; stale scripts referencing a team that already completed its lifecycle; phase-state file left in a terminal state after a crash during shutdown.","solutions":["Check the team phase state (readTeamPhaseState) or team status before dispatching tasks; if terminal, restart or recreate the team","If the team should still be alive, inspect the phase-state file for a prematurely written terminal_epoch or terminal phase and reconcile it","Wrap dispatch calls in try-catch and surface the diagnostic message to the operator instead of retrying blindly"],"exampleFix":"// before\nawait assignTask(teamName, taskId, workerName, cwd);\n\n// after\nconst phase = await readTeamPhaseState(teamName, cwd);\nif (phase?.terminal_epoch || isTerminalPhase(phase?.current_phase ?? '')) {\n  throw new Error('team already terminal; recreate it before assigning tasks');\n}\nawait assignTask(teamName, taskId, workerName, cwd);","handlingStrategy":"validation","validationCode":"const phase = await readTeamPhaseState(teamName, cwd);\nif (phase?.terminal_epoch || isTerminalPhase(phase?.current_phase ?? '')) {\n  throw new Error('team is terminal; recreate it before assigning tasks');\n}","typeGuard":"function isTeamContinuable(phase: TeamPhaseState | null | undefined): boolean {\n  return !!phase && !phase.terminal_epoch && !isTerminalPhase(phase.current_phase);\n}","tryCatchPattern":"try { await assignTask(t, id, w, cwd); } catch (e) { if (String((e as Error).message).includes('terminal')) await recreateTeam(t); else throw e; }","preventionTips":["Check team phase state before every dispatch","Alert when a team enters a terminal phase so pipelines stop queuing work","Do not hard-retry assignment errors on terminal teams"],"tags":["team","lifecycle","phase-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}