{"record":{"id":"41c81c1e9ed55137","repo":"zeroclaw-labs/zeroclaw","slug":"active-run-not-found","errorCode":null,"errorMessage":"Active run not found: {}","messagePattern":"Active run not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-runtime/src/sop/engine.rs","lineNumber":4323,"sourceCode":"        let sop_name = match self.active_runs.get(&state.run_id) {\n            Some(run) if run.status == SopRunStatus::PausedCheckpoint => run.sop_name.clone(),\n            Some(run) => {\n                bail!(\n                    \"Run {} is not paused at checkpoint (status: {})\",\n                    state.run_id,\n                    run.status\n                );\n            }\n            None => {\n                let run_id = state.run_id.clone();\n                ::zeroclaw_log::record!(\n                    WARN,\n                    ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Reject)\n                        .with_outcome(::zeroclaw_log::EventOutcome::Failure)\n                        .with_attrs(::serde_json::json!({\"run_id\": run_id})),\n                    \"SOP engine: active run not found\"\n                );\n                bail!(\"Active run not found: {}\", state.run_id);\n            }\n        };\n\n        // Refuse to resume while the checkpoint's parked snapshot has not yet\n        // been durably persisted (see `is_park_persist_pending`'s doc): the kept\n        // claim predates this attempt, and reacquiring on top of it would give a\n        // later rollback or a maintenance retry no way to distinguish \"freshly\n        // reacquired\" from \"pre-existing, must survive.\"\n        if self.is_park_persist_pending(&state.run_id) {\n            bail!(\n                \"Run {} cannot resume: its parked checkpoint snapshot is not yet durably persisted (retrying)\",\n                state.run_id\n            );\n        }\n\n        let sop = self\n            .sops\n            .iter()","sourceCodeStart":4305,"sourceCodeEnd":4341,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-runtime/src/sop/engine.rs#L4305-L4341","documentation":"The resume path could not find the run id in the engine's active_runs map, so there is nothing to resume. The engine logs a WARN Reject event with the run_id before bailing. Active runs are the in-memory execution surface (the durable store is the concurrency source of truth), so the id is unknown, expired, or was lost when the engine restarted.","triggerScenarios":"Calling resume with a run id that was never active in this process, was evicted after completion, or belonged to a previous engine instance before a restart; truncated or mistyped run ids from configuration or messages.","commonSituations":"Engine restart between checkpoint pause and resume; long-lived cron or channel handlers holding stale run ids; copy-pasting an id from old logs.","solutions":["List or query current runs to find the live run id before resuming.","After an engine restart, re-admit/resume parked runs through the store-backed recovery path rather than replaying stale ids.","Take the run id from the checkpoint notification itself, not from a stored or hand-typed copy."],"exampleFix":"// before: resume with an id captured before an engine restart\nengine.resume_checkpoint(state).await?; // state.run_id no longer active\n\n// after: re-resolve the live run id first\nlet run_id = engine\n    .list_runs()\n    .into_iter()\n    .find(|r| r.sop_name == state.sop_name && r.status == SopRunStatus::PausedCheckpoint)\n    .map(|r| r.run_id)\n    .ok_or_else(|| anyhow::anyhow!(\"no parked run for SOP {}\", state.sop_name))?;\nengine.resume_checkpoint(state.with_run_id(run_id)).await?;","handlingStrategy":"validation","validationCode":"let Some(run) = engine.get_run(&state.run_id) else {\n    // stale id (e.g. after engine restart): re-resolve the parked run from the live list\n    anyhow::bail!(\"active run {} not found; re-resolve from list_runs\", state.run_id);\n};\nengine.resume_checkpoint(state).await?;","typeGuard":null,"tryCatchPattern":"match engine.resume_checkpoint(state).await {\n    Err(e) if e.to_string().contains(\"Active run not found\") => {\n        // refresh the run id from the engine's live runs and retry once\n    }\n    other => other?,\n}","preventionTips":["Always source run ids from the checkpoint notification or a live listing, never from stored copies.","After engine restarts, run store-backed recovery before replaying resume requests.","Validate id format/length before calling to catch truncation."],"tags":["sop","run","not-found","resume"],"backgroundTag":"entity-not-found","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}