{"record":{"id":"463078d4058444ca","repo":"coleam00/Archon","slug":"workflow-run-not-found-after-fan-out-recovery-id","errorCode":null,"errorMessage":"Workflow run not found after fan-out recovery (id: ${id})","messagePattern":"Workflow run not found after fan-out recovery \\(id: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/db/workflows.ts","lineNumber":1082,"sourceCode":"           AND ${cancelledReason} IN ($2, $3, $4)`,\n        [id, ...FAN_OUT_CANCEL_REASONS]\n      );\n      if ((result.rowCount ?? 0) === 0) {\n        throw new Error(`Workflow run is not an engine-cancelled fan-out child (id: ${id})`);\n      }\n      await query(\n        `DELETE FROM remote_agent_workflow_events\n         WHERE workflow_run_id = $1\n           AND event_type = 'workflow_cancelled'\n           AND ${eventReason} IN ($2, $3, $4)`,\n        [id, ...FAN_OUT_CANCEL_REASONS]\n      );\n      const recovered = await query<WorkflowRun>(\n        'SELECT * FROM remote_agent_workflow_runs WHERE id = $1',\n        [id]\n      );\n      const row = recovered.rows[0];\n      if (!row) throw new Error(`Workflow run not found after fan-out recovery (id: ${id})`);\n      return normalizeWorkflowRun(row);\n    });\n  } catch (error) {\n    if (error instanceof Error && error.message.startsWith('Workflow run ')) throw error;\n    const err = error as Error;\n    getLog().error({ err, workflowRunId: id }, 'db.workflow_run_fan_out_recover_failed');\n    throw new Error(`Failed to recover cancelled fan-out run: ${err.message}`);\n  }\n}\n\n/**\n * Find the most recent workflow run for a worker platform conversation ID.\n * Joins with conversations table to resolve platform_conversation_id → DB id.\n */\nexport async function getWorkflowRunByWorkerPlatformId(\n  platformConversationId: string\n): Promise<WorkflowRun | null> {\n  try {","sourceCodeStart":1064,"sourceCodeEnd":1100,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/db/workflows.ts#L1064-L1100","documentation":"Error \"Workflow run not found after fan-out recovery (id: ${id})\" thrown in coleam00/Archon.","triggerScenarios":"Thrown at packages/core/src/db/workflows.ts:1082 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}