{"record":{"id":"9aa007b5da9b8dea","repo":"Hmbown/CodeWhale","slug":"operate-keepalive-belongs-to-another-runtime-execution-scope","errorCode":null,"errorMessage":"Operate keepalive belongs to another Runtime execution scope","messagePattern":"Operate keepalive belongs to another Runtime execution scope","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/operate.rs","lineNumber":727,"sourceCode":"    let credentials = crate::config::has_api_key_for(&route.config, route.identity.provider);\n    Ok((route.identity, route.model, credentials))\n}\n\n/// Inspect the same saved route used by the scheduler. Credential presence is\n/// a local readiness observation, not proof of provider execution.\npub(crate) fn keepalive_readiness(\n    manager: &AutomationManager,\n    config: &crate::config::Config,\n    selection: Option<(&crate::config::ProviderIdentity, &str)>,\n) -> Result<(String, bool)> {\n    let mut readiness = (String::new(), false);\n    manager.edit_automation(OPERATE_KEEPALIVE_ID, |current| {\n        if current\n            .as_ref()\n            .and_then(|record| record.execution_scope.as_deref())\n            .is_some_and(|scope| Some(scope) != manager.execution_scope())\n        {\n            bail!(\"Operate keepalive belongs to another Runtime execution scope\");\n        }\n        let (_, model, credentials) = keepalive_route(config, current.as_ref(), selection)?;\n        readiness = (model, credentials);\n        Ok(None)\n    })?;\n    Ok(readiness)\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub struct AutoMergeRequest<'a> {\n    pub pr: &'a str,\n    pub role: &'a str,\n    pub repo: &'a str,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub enum AutoMergeDecision {\n    Allow,","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/operate.rs#L709-L745","documentation":"keepalive_readiness checks the persisted Operate keepalive automation record's execution_scope against the current manager scope. If the keepalive record was created under a different Runtime execution scope (workspace/session), the library refuses to read or reuse it rather than acting on automation owned elsewhere.","triggerScenarios":"Reading keepalive readiness when the stored OPERATE_KEEPALIVE_ID record has an execution_scope that no longer matches manager.execution_scope() — typically after switching workspaces, restoring a different session, or moving the config between scopes.","commonSituations":"Resuming the TUI in a different workspace or profile where an old keepalive record survives in shared automation state; copying automation state between machines/containers; scope identity changed after a Runtime upgrade.","solutions":["Clear or re-create the operate keepalive automation record in the current scope","Run the operate mode from the execution scope that created the keepalive","Remove the stale execution_scope value (or the whole record) so it is re-bound to the current scope on next use"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let scope_ok = manager.lookup(OPERATE_KEEPALIVE_ID).and_then(|r| r.execution_scope).map(|s| Some(&s) == manager.execution_scope().as_deref().map(|x| x).as_ref()).unwrap_or(true);","typeGuard":"fn scope_matches(record: Option<&AutomationRecord>, scope: Option<&str>) -> bool { record.and_then(|r| r.execution_scope.as_deref()).map_or(true, |s| Some(s) == scope) }","tryCatchPattern":"match keepalive_readiness(...) { Err(e) if e.to_string().contains(\"another Runtime execution scope\") => { manager.remove_automation(OPERATE_KEEPALIVE_ID); rebind_keepalive(); } other => other?, }","preventionTips":["Clear keepalive records when switching workspace/scope","Store automation state per scope, not in shared paths","Log scope identity at record creation to ease diagnosis"],"tags":["state","scope-mismatch","automation"],"backgroundTag":"invalid-state-transition","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}