Hmbown/CodeWhale · error · anyhow::Error

Automation service belongs to another Runtime scope

Error message

Automation service belongs to another Runtime scope

What it means

bind_task_manager refuses to attach the automation service to a TaskManager whose execution scope differs from the scope the service was opened with; the bail fires when execution_scope is set and mismatches, preventing automations from running tasks under another Runtime's isolation boundary.

Solutions

  1. Do not share one AutomationManager across Runtime scopes; open a separate manager per scope.
  2. Rebind the TaskManager whose execution_scope matches the manager's stored execution_scope.
  3. If the manager was created via open_for_test, use a TaskManager bound to the same 'test' scope.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/automation_manager.rs:1106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/b0c7e56dbfeb0056. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/automation_manager.rs:1106

    }

    #[cfg(test)]
    pub(crate) fn open_for_test(root: PathBuf) -> Result<Self> {
        let mut manager = Self::open(root)?;
        manager.execution_scope = Some(crate::task_manager::test_execution_scope("test"));
        Ok(manager)
    }

    pub(crate) fn bind_task_manager(
        &mut self,
        tasks: &crate::task_manager::TaskManager,
    ) -> Result<()> {
        if self
            .execution_scope
            .as_deref()
            .is_some_and(|scope| scope != tasks.execution_scope())
        {
            bail!("Automation service belongs to another Runtime scope");
        }
        self.execution_scope = Some(tasks.execution_scope().to_string());
        Ok(())
    }

    pub(crate) fn execution_scope(&self) -> Option<&str> {
        self.execution_scope.as_deref()
    }

    fn eligible_scope(&self, scope: Option<&str>) -> bool {
        scope.is_some() && scope == self.execution_scope()
    }

    /// Explicit control may bind an unbound definition; saved admissions never
    /// read this field back from the definition during recovery.
    fn adopt_for_run(&self, automation: &mut AutomationRecord) -> Result<()> {
        let scope = self
            .execution_scope()

View on GitHub (pinned to 73e0f67d83)