{"record":{"id":"c7daf19bc020cce0","repo":"Yeachan-Heo/oh-my-codex","slug":"delegation-only-violation","errorCode":null,"errorMessage":"delegation_only_violation","messagePattern":"delegation_only_violation","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime.ts","lineNumber":4694,"sourceCode":"export 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`);\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(',')}`);","sourceCodeStart":4676,"sourceCodeEnd":4712,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime.ts#L4676-L4712","documentation":"Thrown when the team manifest's governance policy has delegation_only enabled and the assignment targets the reserved worker name 'leader-fixed'. Delegation-only mode forbids the leader from executing tasks directly.","triggerScenarios":"Calling task assignment with workerName === 'leader-fixed' while the manifest governance resolves delegation_only to true (explicitly set or via defaults from resolveGovernancePolicy).","commonSituations":"Legacy scripts that hardcoded 'leader-fixed' as the worker; enabling delegation_only on an existing team without updating dispatch callers; default governance flipping delegation_only on after a version upgrade.","solutions":["Dispatch to a real worker name from config.workers instead of 'leader-fixed'","If the leader must execute, disable delegation_only in the team manifest governance","List valid worker names from the team config before choosing the assignee"],"exampleFix":"// before\nawait assignTask(team, taskId, 'leader-fixed', cwd);\n\n// after\nconst config = await readTeamConfig(team, cwd);\nconst worker = config?.workers.find(w => w.name !== 'leader-fixed');\nif (!worker) throw new Error('no delegatable worker configured');\nawait assignTask(team, taskId, worker.name, cwd);","handlingStrategy":"validation","validationCode":"const config = await readTeamConfig(teamName, cwd);\nconst governance = resolveGovernancePolicy((await readTeamManifestV2(teamName, cwd))?.governance);\nif (governance.delegation_only && workerName === 'leader-fixed') throw new Error('pick a real worker');","typeGuard":null,"tryCatchPattern":"try { await assignTask(t, id, w, cwd); } catch (e) { if ((e as Error).message === 'delegation_only_violation') w = pickDelegatableWorker(t); else throw e; }","preventionTips":["Never hardcode 'leader-fixed' as an assignee","Read worker names from config.workers at runtime","Document governance flags when enabling delegation_only"],"tags":["governance","delegation","worker"],"backgroundTag":"policy-violation","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}