{"record":{"id":"2e677e50f07f2598","repo":"coleam00/Archon","slug":"cannot-supersede-run-superseded-id-it-is-sti","errorCode":null,"errorMessage":"Cannot supersede run '${superseded.id}': it is still ${superseded.status}.","messagePattern":"Cannot supersede run '(.+?)': it is still (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":742,"sourceCode":"      `Error: ${error.message}\\n` +\n      'Hint: Check your database connection before using --resume.'\n  );\n}\n\n/**\n * Validate a `--supersedes` declaration (#2747): the run must exist and be terminal.\n * Supersede inherits nothing, so existence and terminality are the whole contract.\n *\n * One owner for the refusals because two callers need them: the `--detach` pre-flight,\n * which refuses before forking (#2872), and the run path that records the provenance.\n */\nasync function resolveSupersededRun(runId: string): Promise<WorkflowRun> {\n  const superseded = await workflowDb.getWorkflowRun(runId);\n  if (!superseded) {\n    throw new Error(`Cannot supersede: no workflow run '${runId}' exists.`);\n  }\n  if (!TERMINAL_WORKFLOW_STATUSES.includes(superseded.status)) {\n    throw new Error(`Cannot supersede run '${superseded.id}': it is still ${superseded.status}.`);\n  }\n  return superseded;\n}\n\n/**\n * The acting CLI user's Archon id, or undefined when `ARCHON_USER_ID`/`$USER` is unset\n * or the identity cannot be resolved. Attribution is best-effort by design — a run must\n * not fail because the user table could not be reached.\n */\nasync function resolveCliUserRecordId(): Promise<string | undefined> {\n  const cliId = resolveCliUserId();\n  if (!cliId) return undefined;\n  try {\n    const cliUser = await userDb.findOrCreateUserByPlatformIdentity('cli', cliId, cliId);\n    return cliUser.id;\n  } catch (error) {\n    getLog().warn({ err: error as Error, cliId }, 'cli.user_identity_resolve_failed');\n    return undefined;","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L724-L760","documentation":"resolveSupersededRun() only permits superseding runs already in a terminal status (TERMINAL_WORKFLOW_STATUSES). If the referenced run exists but is still running/pending/approving, the CLI throws this refusal naming the run id and its current status, preventing a new run from superseding live work.","triggerScenarios":"Passing --supersede <runId> for a run whose status is not terminal — e.g. it is still 'running', 'waiting' (durable wait), or blocked at a human approval gate.","commonSituations":"Re-running a workflow while the previous invocation is still executing; superseding a run paused at an approval gate; a stale/crashed run that still shows a non-terminal status and should instead be cancelled or resumed.","solutions":["Cancel the active run first (`archon workflow cancel <runId>`) or wait for it to reach a terminal status.","Resume the stuck run (`archon workflow resume <runId>`) if it is in a durable wait rather than superseding.","Approve/reject any pending gate so the run finishes, then re-run with --supersede.","If the run is genuinely orphaned with a non-terminal status, follow the operator flow for ambiguous ownership rather than superseding."],"exampleFix":"// before\n$ archon workflow run foo --supersede wf_123\nError: Cannot supersede run 'wf_123': it is still running.\n// after\n$ archon workflow cancel wf_123\n$ archon workflow run foo --supersede wf_123","handlingStrategy":"validation","validationCode":"// only supersede runs already in a terminal status\nimport { workflowDb, TERMINAL_WORKFLOW_STATUSES } from '@archon/core';\nconst run = await workflowDb.getWorkflowRun(runId);\nif (run && !TERMINAL_WORKFLOW_STATUSES.includes(run.status)) {\n  throw new Error(`Run ${runId} is still ${run.status}; cancel or wait first.`);\n}","typeGuard":"function isTerminal(status: string, terminal: readonly string[]): boolean {\n  return terminal.includes(status);\n}","tryCatchPattern":"try {\n  await runWorkflow(name, { supersede: runId });\n} catch (e) {\n  const msg = String((e as Error).message);\n  if (msg.includes('it is still')) {\n    console.error('Target run is active: cancel it (`archon workflow cancel`) or wait for it to finish.');\n  }\n}","preventionTips":["Check run status before planning a supersede.","Cancel or resume active runs instead of attempting to supersede them.","Handle runs stuck at approval gates by approving/rejecting first."],"tags":["cli","workflow-run","lifecycle","state-conflict"],"backgroundTag":"run-still-active","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}