{"record":{"id":"908f281ae0724632","repo":"coleam00/Archon","slug":"cannot-resume-workflow-workflowname-failed-t","errorCode":null,"errorMessage":"Cannot resume workflow '${workflowName}': failed to load prior run state — ${err.message}","messagePattern":"Cannot resume workflow '(.+?)': failed to load prior run state — (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":2968,"sourceCode":"    );\n  }\n\n  // When --resume, hand the already-found run (and its completed-node outputs)\n  // to executeWorkflow. Otherwise this is a fresh run and prepared stays null.\n  // The lookup-by-(workflowName, cwd) was already done above for worktree-path\n  // resolution; reuse that result rather than querying twice.\n  const deps = createWorkflowDeps();\n  let prepared: Awaited<ReturnType<typeof hydrateResumableRun>> = null;\n  if (options.resume && resumable) {\n    try {\n      prepared = await hydrateResumableRun(deps, resumable);\n    } catch (error) {\n      const err = error as Error;\n      getLog().error(\n        { err, workflowName, runId: resumable.id },\n        'cli.workflow_hydrate_resume_failed'\n      );\n      throw new Error(\n        `Cannot resume workflow '${workflowName}': failed to load prior run state — ${err.message}`\n      );\n    }\n    if (!prepared) {\n      throw new Error(\n        `Cannot resume: the prior run for '${workflowName}' has no completed nodes and no interactive-loop state.`\n      );\n    }\n  }\n\n  // Execute workflow with workingCwd (may be worktree path). `undefined` until\n  // assigned so the finally-block teardown can tell \"threw before a result\" from\n  // a real terminal/paused result.\n  let result: Awaited<ReturnType<typeof executeWorkflow>> | undefined;\n  // A genuine container-teardown failure captured in the finally, rethrown AFTER\n  // the finally when the run itself succeeded — so a leaked privileged container\n  // fails the CLI instead of reporting success + exit 0.\n  let containerTeardownError: Error | undefined;","sourceCodeStart":2950,"sourceCodeEnd":2986,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L2950-L2986","documentation":"When resuming, the CLI hydrates prior run state so execution can continue from completed nodes; if loading that state throws, the error is re-thrown with the workflow name and original message, telling the user the prior run's state could not be loaded (logged as 'cli.workflow_hydrate_resume_failed').","triggerScenarios":"`archon workflow <name> --resume` where hydrating the resumable run throws — corrupted or truncated run-state JSON, DB read failure, or schema drift between the version that wrote the state and the current binary.","commonSituations":"Database restored or moved leaving inconsistent run rows; upgrading archon across a schema change; disk-full during the original run left partial state; manual DB edits.","solutions":["Re-run the resume; transient DB read failures may clear.","Check logs for 'cli.workflow_hydrate_resume_failed' — the underlying error is included in the thrown message.","If state is corrupted or schema-incompatible, start a fresh run instead of resuming.","Align binary and database schema versions (update archon or follow database docs)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check the run has hydratable state before attempting resume\nconst prior = await store.getWorkflowRun(resumable.id);\nif (!prior || (!prior.completedNodes?.length && !prior.interactiveLoopState)) {\n  throw new Error('Run has no resumable state; start a fresh run instead');\n}","typeGuard":"function isResumableState(s: unknown): s is { completedNodes: unknown[]; interactiveLoopState?: unknown } {\n  return typeof s === 'object' && s !== null && Array.isArray((s as { completedNodes?: unknown }).completedNodes);\n}","tryCatchPattern":"try {\n  prepared = await hydrateResume(resumable.id);\n} catch (error) {\n  const err = error as Error;\n  getLog().error({ err, runId: resumable.id }, 'cli.workflow_hydrate_resume_failed');\n  throw new Error(`Cannot resume workflow '${workflowName}': failed to load prior run state — ${err.message}`);\n}","preventionTips":["Upgrade archon and its schema together; avoid cross-version state sharing.","Do not hand-edit the run-state database.","Ensure adequate disk space so state writes are not truncated.","Verify the target run has completed nodes (`workflow list --verbose`) before resuming."],"tags":["resume","state","persistence"],"backgroundTag":"resume-state-load-failed","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}