{"record":{"id":"a16550bd2a0bd5eb","repo":"Yeachan-Heo/oh-my-codex","slug":"canonical-scale-down-config-missing","errorCode":null,"errorMessage":"canonical_scale_down_config_missing","messagePattern":"canonical_scale_down_config_missing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/scaling.ts","lineNumber":2067,"sourceCode":"                   );\n          }),\n        );\n        if (allDrained.every(Boolean)) break;\n        await new Promise(r => setTimeout(r, 2_000));\n      }\n    }\n\n    // Phase 3: acquire the membership barrier and task claim locks before any\n    // pane effect. The barrier and locks remain held through the canonical\n    // snapshot, exact pane teardown, and forward-recoverable commit.\n    let removableWorkers = targetWorkers;\n    let removableWorkerNames = new Set(removableWorkers.map((worker) => worker.name));\n    let teardownFailure: ScaleError | null = null;\n    try {\n      await withTaskMembershipBarrier(sanitized, leaderCwd, async () => {\n        await recoverTeamMembershipTaskTransaction(sanitized, leaderCwd);\n        const authoritativeConfig = await readTeamConfig(sanitized, leaderCwd);\n        if (!authoritativeConfig) throw new Error('canonical_scale_down_config_missing');\n        const authoritativeWorkers = removableWorkers.map((worker) => authoritativeConfig.workers.find((candidate) => candidate.name === worker.name));\n        if (authoritativeWorkers.some((worker): worker is undefined => !worker)) {\n          throw new Error('canonical_scale_down_membership_changed');\n        }\n        // Capture targets from the canonical generation while the membership\n        // authority is held; no caller-owned worker record authorizes a pane effect.\n        removableWorkers = authoritativeWorkers as WorkerInfo[];\n        removableWorkerNames = new Set(removableWorkers.map((worker) => worker.name));\n        teamStateRoot = authoritativeConfig.team_state_root ?? resolveCanonicalTeamStateRoot(leaderCwd);\n        Object.assign(config, authoritativeConfig);\n        const candidateTaskIds = (await listTasks(sanitized, leaderCwd))\n          .filter((task) => task.status !== 'completed' && task.status !== 'failed')\n          .map((task) => task.id);\n        await withTaskClaimLocks(sanitized, candidateTaskIds, leaderCwd, async () => {\n          const lockedTasks = await listTasks(sanitized, leaderCwd);\n          const configPath = join(teamStateRoot, 'team', sanitized, 'config.json');\n          const configSnapshot = await readFile(configPath);\n          const manifestPath = join(teamStateRoot, 'team', sanitized, 'manifest.v2.json');","sourceCodeStart":2049,"sourceCodeEnd":2085,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/scaling.ts#L2049-L2085","documentation":"During scale-down, after acquiring the membership barrier and recovering any pending transaction, the canonical team config could not be read (readTeamConfig returned null). Scale-down requires an authoritative config to identify removable workers.","triggerScenarios":"Calling scaleDown when the team config file does not exist or is unreadable/corrupt under the team state root.","commonSituations":"Team state directory deleted or moved; config deleted by another process mid-operation; wrong cwd/team name so a different (empty) state root is consulted; corrupt JSON.","solutions":["Verify the team exists and the config file is present under the team state root (run team status/list)","Ensure scaleDown is called with the same cwd/team name used at team creation","Restore or regenerate the team config if it was corrupted or deleted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const config = await readTeamConfig(team, cwd);\nif (!config) throw new Error(`team '${team}' has no config; create it before scaling down`);","typeGuard":null,"tryCatchPattern":"try {\n  await scaleDown(team, workers, opts);\n} catch (e) {\n  if ((e as Error).message === 'canonical_scale_down_config_missing') {\n    // team may already be gone; treat as no-op success or recreate\n    return refreshTeamState(team);\n  }\n  throw e;\n}","preventionTips":["Confirm team exists (status/list) before scale-down","Always run team ops from the same cwd used at creation"],"tags":["team","scale-down","config","missing-file"],"backgroundTag":"config-file-missing","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}