{"record":{"id":"5eb19ce2b0a74876","repo":"Yeachan-Heo/oh-my-codex","slug":"claim-error","errorCode":null,"errorMessage":"claim.error","messagePattern":"claim\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/runtime.ts","lineNumber":4714,"sourceCode":"\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).\n    const approvedExecutionState = await resolvePersistedApprovedTeamExecutionContinuityState(\n      sanitized,\n      config.leader_cwd ?? cwd,\n      config.team_state_root ?? resolveCanonicalTeamStateRoot(config.leader_cwd ?? cwd),\n    );\n    const persistedUltragoalContext = await readPersistedTeamUltragoalContext(\n      sanitized,\n      config.leader_cwd ?? cwd,\n      config.team_state_root ?? resolveCanonicalTeamStateRoot(config.leader_cwd ?? cwd),\n    );\n    const approvedContextSection = joinContextSections(\n      approvedExecutionState.status === 'valid'\n        ? buildApprovedTeamHandoffSection(approvedExecutionState.approvedHint)\n        : undefined,","sourceCodeStart":4696,"sourceCodeEnd":4732,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime.ts#L4696-L4732","documentation":"Generic passthrough of a failed task claim: claimTask returned ok:false with an error other than 'blocked_dependency', and that raw error string is rethrown verbatim. Typical values include version conflicts (task.version mismatch) or already-claimed states.","triggerScenarios":"Concurrent assignment where another worker claimed the task first (claim token/version mismatch), or the supplied task.version ?? 1 is stale relative to the stored task record.","commonSituations":"Two dispatchers racing on the same task; retrying assignment with a cached stale task object (old version); task mutated between read and claim.","solutions":["Re-read the task to get its current version and check its status before re-claiming","Serialize assignment of a given task (only one dispatcher) to avoid claim races","Inspect the specific claim.error string to identify the exact claim failure mode"],"exampleFix":"// before\nawait assignTask(team, taskId, worker, cwd); // uses task.version ?? 1\n\n// after\nconst fresh = await readTask(team, taskId, cwd);\nif (!fresh || fresh.status !== 'pending') throw new Error('task no longer claimable');\nawait claimTask(team, taskId, worker, fresh.version ?? 1, cwd);","handlingStrategy":"retry","validationCode":"const fresh = await readTask(teamName, taskId, cwd);\nif (fresh?.status !== 'pending') throw new Error('not claimable');","typeGuard":null,"tryCatchPattern":"try { await assignTask(t, id, w, cwd); } catch (e) { if (/version|claimed/.test((e as Error).message)) { await sleep(500); await assignTask(t, id, w, cwd); } else throw e; }","preventionTips":["Re-read task version immediately before claiming","Single dispatcher per task to avoid races","Treat raw claim.error strings as authoritative failure modes"],"tags":["claim","concurrency","task"],"backgroundTag":"concurrent-modification-conflict","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}