{"record":{"id":"856c1401e0954f49","repo":"Yeachan-Heo/oh-my-codex","slug":"canonical-scale-up-rollback-task-verification-fail","errorCode":null,"errorMessage":"canonical_scale_up_rollback_task_verification_failed:${taskId}","messagePattern":"canonical_scale_up_rollback_task_verification_failed:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/scaling.ts","lineNumber":986,"sourceCode":"      const cleanupWorkerNames = new Set([\n        ...rollbackWorkers\n          .filter((worker) => typeof worker.pane_id !== 'string' || resolvedPaneIds.has(worker.pane_id))\n          .map((worker) => worker.name),\n        ...(context.workerName && !unresolvedWorkerNames.has(context.workerName) ? [context.workerName] : []),\n      ]);\n      try {\n        for (const taskId of createdTaskIds) {\n          const task = await readTask(sanitized, taskId, leaderCwd);\n          if (task && unresolvedWorkerNames.has(task.owner ?? '')) continue;\n          await rm(join(teamStateRoot, 'team', sanitized, 'tasks', `task-${taskId}.json`), { force: true });\n        }\n        await Promise.all([...cleanupWorkerNames].map(async (workerName) => {\n          await rm(join(teamStateRoot, 'team', sanitized, 'workers', workerName), { recursive: true, force: true });\n        }));\n        for (const taskId of createdTaskIds) {\n          const task = await readTask(sanitized, taskId, leaderCwd);\n          if (task && unresolvedWorkerNames.has(task.owner ?? '')) continue;\n          if (task) throw new Error(`canonical_scale_up_rollback_task_verification_failed:${taskId}`);\n        }\n        for (const workerName of cleanupWorkerNames) {\n          if (existsSync(join(teamStateRoot, 'team', sanitized, 'workers', workerName))) {\n            throw new Error(`canonical_scale_up_rollback_worker_verification_failed:${workerName}`);\n          }\n        }\n      } catch (rollbackError) {\n        cleanupDebt.push(`canonical_cleanup_failed:${String(rollbackError)}`);\n      }\n\n      try {\n        const contextWorkerName = context.worker?.name ?? context.workerName;\n        const contextWorktreePath = context.worker?.worktree_path ?? context.worktreePath;\n        if (contextWorkerName && contextWorktreePath && !unresolvedWorkerNames.has(contextWorkerName)) {\n          await removeWorkerWorktreeRootAgentsFile(sanitized, contextWorkerName, teamStateRoot, contextWorktreePath);\n        }\n        const unresolvedWorktreePaths = new Set(rollbackWorkers\n          .filter((worker) => unresolvedWorkerNames.has(worker.name) && typeof worker.worktree_path === 'string')","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/scaling.ts#L968-L1004","documentation":"During scale-up rollback, a task created during the failed scale-up attempt still exists on disk and is not owned by an unresolved worker, meaning cleanup did not remove or reassign it. The message embeds the offending taskId.","triggerScenarios":"scaleUp failure path iterates createdTaskIds; readTask returns a task whose owner is not in unresolvedWorkerNames, so rollback left a stray task.","commonSituations":"Task files written concurrently by workers during rollback; interrupted cleanup (process killed mid-rollback); transaction journal desync.","solutions":["Inspect the reported task ID under the team task store and delete or reassign it manually","Re-run scaleUp (idempotent recovery reconciles leftover tasks) after ensuring no concurrent workers are writing","Check/clear the membership task transaction journal if it is stuck"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) {\n  const m = /canonical_scale_up_rollback_task_verification_failed:(.+)$/.exec(String((e as Error).message));\n  if (m) { await deleteTaskManually(team, m[1]); return retryScaleUp(); }\n  throw e;\n}","preventionTips":["Quiesce worker task writes before scaling","Treat createdTaskIds cleanup as idempotent and re-run scaleUp to reconcile"],"tags":["team","scaling","rollback","tasks","cleanup"],"backgroundTag":"orphaned-resource-after-rollback","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}