Hmbown/CodeWhale · error

Automation execution ownership is unverified

Error message

Automation execution ownership is unverified

What it means

This error is thrown when preparing an automation run record for an automation whose execution_scope field is None. The library requires every admitted automation to carry an execution scope that verifies which Runtime/task store owns its execution; a record without one cannot be proven to belong here, so admission is refused rather than guessed. It is a guard against executing automations with unverified ownership.

Solutions

  1. Set automation.execution_scope to the owning scope before admission (it is normally assigned when the automation is admitted/saved)
  2. Re-admit or re-save the automation through the normal API so execution_scope is populated and persisted
  3. If the record came from an old file, migrate it by assigning the current task store's execution scope and rewriting the file
  4. In tests/fixtures, always populate execution_scope

Example fix

// before
let mut automation: AutomationRecord = serde_json::from_str(&raw)?;
// admission bails: execution_scope is None
// after
let mut automation: AutomationRecord = serde_json::from_str(&raw)?;
automation.execution_scope = Some(tasks.execution_scope().to_string());
manager.save_automation(&automation)?;
Defensive patterns

Strategy: validation

Validate before calling

if automation.execution_scope.is_none() {
    automation.execution_scope = Some(tasks.execution_scope().to_string());
}

Type guard

fn has_execution_scope(a: &AutomationRecord) -> bool {
    a.execution_scope.as_deref().map(|s| !s.is_empty()).unwrap_or(false)
}

Prevention

When it happens

Trigger: Calling the run-preparation function with an AutomationRecord loaded from storage (or constructed in code) where automation.execution_scope is None.

Common situations: Hand-written or migrated automation JSON files that predate the execution_scope field; records copied between task stores with the scope stripped; tests constructing AutomationRecord fixtures without setting execution_scope; older schema files loaded by a newer build that now requires the field.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/6890007254c599be. Report an issue: GitHub.

Appendix: source

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

        model_provider: automation.model_provider.clone(),
        model_provider_id: automation.model_provider_id.clone(),
        workspace: automation.cwds.first().cloned(),
        mode: Some(automation.task_mode()),
        allow_shell: Some(automation.task_allow_shell()),
        trust_mode: Some(automation.task_trust_mode()),
        auto_approve: Some(automation.task_auto_approve()),
        owner_session_id: None,
    }
}

fn bind_run_dispatch(
    run: &mut AutomationRunRecord,
    automation: &AutomationRecord,
    task_data_dir: &Path,
    scheduled: bool,
) -> Result<()> {
    if automation.execution_scope.is_none() {
        bail!("Automation execution ownership is unverified");
    }
    run.schema_version = CURRENT_RUN_SCHEMA_VERSION;
    run.task_id = Some(crate::task_manager::TaskManager::new_task_id());
    run.dispatch = Some(AutomationDispatch {
        execution_scope: automation.execution_scope.clone(),
        request: automation_task_request(automation),
        task_data_dir: task_data_dir
            .canonicalize()
            .context("resolve task store before automation admission")?,
        accepted: false,
        delivery_mode: automation.delivery_mode(),
        suppress_report: false,
        schedule: scheduled.then(|| AdmittedSchedule {
            updated_at: automation.updated_at,
            rrule: automation.rrule.clone(),
        }),
    });
    Ok(())

View on GitHub (pinned to 433685b202)