{"record":{"id":"6cc33d56f78768e7","repo":"Hmbown/CodeWhale","slug":"automation-belongs-to-another-runtime-execution-scope","errorCode":null,"errorMessage":"Automation belongs to another Runtime execution scope","messagePattern":"Automation belongs to another Runtime execution scope","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":1128,"sourceCode":"    }\n\n    pub(crate) fn execution_scope(&self) -> Option<&str> {\n        self.execution_scope.as_deref()\n    }\n\n    fn eligible_scope(&self, scope: Option<&str>) -> bool {\n        scope.is_some() && scope == self.execution_scope()\n    }\n\n    /// Explicit control may bind an unbound definition; saved admissions never\n    /// read this field back from the definition during recovery.\n    fn adopt_for_run(&self, automation: &mut AutomationRecord) -> Result<()> {\n        let scope = self\n            .execution_scope()\n            .context(\"Automation execution ownership is unverified\")?;\n        if let Some(bound) = &automation.execution_scope {\n            if bound != scope {\n                bail!(\"Automation belongs to another Runtime execution scope\");\n            }\n        } else {\n            automation.execution_scope = Some(scope.to_string());\n            automation.schema_version = CURRENT_AUTOMATION_SCHEMA_VERSION;\n            automation.updated_at = Utc::now();\n            if automation.status == AutomationStatus::Active {\n                let schedule = AutomationSchedule::parse_rrule(&automation.rrule)?;\n                automation.next_run_at =\n                    match schedule.next_after_with_anchor(Utc::now(), automation.created_at) {\n                        Ok(next) => Some(next),\n                        Err(_) if matches!(schedule, AutomationSchedule::Once { .. }) => {\n                            automation.status = AutomationStatus::Paused;\n                            None\n                        }\n                        Err(error) => return Err(error),\n                    };\n            }\n            self.save_automation_unlocked(automation)?;","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/automation_manager.rs#L1110-L1146","documentation":"adopt_for_run requires the manager to have a verified execution ownership scope before adopting an unbound automation for a run; the bail fires when execution_scope is None, meaning runtime ownership of the definition could not be proven, so the run is refused rather than executed under unknown ownership.","triggerScenarios":"Thrown at crates/tui/src/automation_manager.rs:1128 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure adopt_for_run is only reached when the manager's execution_scope was set (not None) at bind time.","Re-open the AutomationManager under the Runtime that owns the automation so the scope is present before adoption."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T06:17:15.046Z"}