{"record":{"id":"c55a72eca5228651","repo":"Yeachan-Heo/oh-my-codex","slug":"autoresearch-resume-terminal-run","errorCode":"autoresearch_resume_terminal_run","errorMessage":"autoresearch_resume_terminal_run:${runId}","messagePattern":"autoresearch_resume_terminal_run:(.+?)","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/autoresearch/runtime.ts","lineNumber":971,"sourceCode":"    runDir,\n    instructionsFile,\n    manifestFile,\n    ledgerFile,\n    latestEvaluatorFile,\n    resultsFile,\n    stateFile,\n    candidateFile,\n    repoRoot: projectRoot,\n    worktreePath,\n    taskDescription,\n  };\n}\n\nexport async function resumeAutoresearchRuntime(projectRoot: string, runId: string): Promise<PreparedAutoresearchRuntime> {\n  await assertAutoresearchLockAvailable(projectRoot);\n  const manifest = await loadAutoresearchRunManifest(projectRoot, runId);\n  if (manifest.status !== 'running') {\n    throw new Error(`autoresearch_resume_terminal_run:${runId}`);\n  }\n  if (!existsSync(manifest.worktree_path)) {\n    throw new Error(`autoresearch_resume_missing_worktree:${manifest.worktree_path}`);\n  }\n  await ensureRuntimeExcludes(manifest.worktree_path);\n  await ensureAutoresearchWorktreeDependencies(projectRoot, manifest.worktree_path);\n  assertResetSafeWorktree(manifest.worktree_path);\n  await startMode('autoresearch', `autoresearch resume ${runId}`, 1, projectRoot);\n  await activateAutoresearchRun(manifest);\n  await updateModeState('autoresearch', {\n    current_phase: 'running',\n    run_id: manifest.run_id,\n    run_tag: manifest.run_tag,\n    mission_dir: manifest.mission_dir,\n    mission_file: manifest.mission_file,\n    sandbox_file: manifest.sandbox_file,\n    mission_slug: manifest.mission_slug,\n    repo_root: manifest.repo_root,","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/autoresearch/runtime.ts#L953-L989","documentation":"resumeAutoresearchRuntime throws (code autoresearch_resume_terminal_run) when the loaded manifest's status is anything other than 'running'. Runs that already completed, failed, or were discarded are terminal and cannot be resumed.","triggerScenarios":"Calling resumeAutoresearchRuntime(repoRoot, runId) for a run whose manifest.json has status 'complete', 'failed', 'aborted', etc. — commonly re-running a resume command after the run already finished successfully.","commonSituations":"CI retrying a job step after the run completed, double-executing a resume script, or manually flipping status in the manifest earlier.","solutions":["Read the manifest at .omx/logs/autoresearch/<runId>/manifest.json and confirm its status; if not 'running', do not resume","If you need another cycle, start a new autoresearch run instead of resuming the terminal one","Make CI resume steps conditional on the manifest status being 'running'","If the status looks wrong (run actually still mid-flight), investigate why it was finalized before overriding anything"],"exampleFix":"// before\nawait resumeAutoresearchRuntime(repoRoot, runId); // throws for completed run\n// after\nconst m = JSON.parse(await readFile(join(repoRoot, '.omx/logs/autoresearch', runId, 'manifest.json'), 'utf8'));\nif (m.status === 'running') await resumeAutoresearchRuntime(repoRoot, runId);\nelse await prepareAutoresearchRuntime(repoRoot, newTask); // start a new run","handlingStrategy":"validation","validationCode":"import { readFile } from 'node:fs/promises';\nconst manifest = JSON.parse(await readFile(join(repoRoot, '.omx', 'logs', 'autoresearch', runId, 'manifest.json'), 'utf-8'));\nif (manifest.status !== 'running') {\n  throw new Error(`Run ${runId} is terminal (${manifest.status}); start a new run instead.`);\n}","typeGuard":"function isRunningManifest(v: unknown): v is { status: 'running'; worktree_path: string } {\n  return typeof v === 'object' && v !== null && (v as any).status === 'running';\n}","tryCatchPattern":"try { await resumeAutoresearchRuntime(repoRoot, runId); }\ncatch (e) { if (e instanceof Error && e.message.startsWith('autoresearch_resume_terminal_run')) { /* start a new run instead of resuming */ } throw e; }","preventionTips":["Check manifest.status before attempting resume","Make CI resume steps conditional on status === 'running'","Treat completed/failed runs as immutable; start new runs for further work"],"tags":["autoresearch","terminal-state","resume","workflow-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}