{"record":{"id":"39ca864be4e2657e","repo":"Yeachan-Heo/oh-my-codex","slug":"plan-approval-required","errorCode":null,"errorMessage":"plan_approval_required","messagePattern":"plan_approval_required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime.ts","lineNumber":4700,"sourceCode":"  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`);\n  const workerInfo = config.workers.find(w => w.name === workerName);\n  if (!workerInfo) throw new Error(`Worker ${workerName} not found in team`);\n  const dispatchPolicy = resolveDispatchPolicy(manifest?.policy, config.worker_launch_mode);\n\n  const claim = await claimTask(sanitized, taskId, workerName, task.version ?? 1, cwd);\n  if (!claim.ok) {\n    if (claim.error === 'blocked_dependency') {\n      throw new Error(`blocked_dependency:${(claim.dependencies ?? []).join(',')}`);\n    }\n    throw new Error(claim.error);\n  }\n\n  try {\n    // Retry dispatch up to 2 times to handle trust prompts during assignment (fixes #393).","sourceCodeStart":4682,"sourceCodeEnd":4718,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime.ts#L4682-L4718","documentation":"Thrown when governance requires plan approval and the task is marked requires_code_change === true, but isTaskApprovedForExecution reports the task has not been approved. The gate prevents unreviewed code-changing work from being dispatched.","triggerScenarios":"Assigning a requires_code_change task under a manifest whose governance sets plan_approval_required, when no approval record exists for the task (isTaskApprovedForExecution returns false).","commonSituations":"Automated pipelines dispatching tasks straight after creation without the approval step; approvals stored per-team that were lost when state was reset; governance defaults changing between versions so previously-fine dispatch now requires approval.","solutions":["Approve the task plan first via the team's approval flow, then re-dispatch","If approval genuinely is not needed for this task, clear requires_code_change on the task definition","If governance is too strict, adjust plan_approval_required in the manifest governance policy"],"exampleFix":"// before\nawait assignTask(team, taskId, worker, cwd);\n\n// after\nif (task.requires_code_change) {\n  await approveTaskForExecution(team, taskId, cwd); // or CLI approval command\n}\nawait assignTask(team, taskId, worker, cwd);","handlingStrategy":"validation","validationCode":"if (task.requires_code_change && governance.plan_approval_required) {\n  const ok = await isTaskApprovedForExecution(teamName, taskId, cwd);\n  if (!ok) throw new Error('approve the plan before dispatch');\n}","typeGuard":null,"tryCatchPattern":"try { await assignTask(t, id, w, cwd); } catch (e) { if ((e as Error).message === 'plan_approval_required') { await approveTask(t, id); await assignTask(t, id, w, cwd); } else throw e; }","preventionTips":["Make approval part of the CI pipeline for code-changing tasks","Keep task.requires_code_change accurate","Audit governance flags after upgrades"],"tags":["governance","approval","plan-review"],"backgroundTag":"authorization-required","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}