{"record":{"id":"ff937b405662da15","repo":"Hmbown/CodeWhale","slug":"automation-admission-belongs-to-a-different-task-store-it","errorCode":null,"errorMessage":"Automation admission belongs to a different task store; it cannot be replayed here","messagePattern":"Automation admission belongs to a different task store; it cannot be replayed here","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":2091,"sourceCode":"        execution_scope: automation.execution_scope.clone(),\n        request: automation_task_request(automation),\n        task_data_dir: task_data_dir\n            .canonicalize()\n            .context(\"resolve task store before automation admission\")?,\n        accepted: false,\n        delivery_mode: automation.delivery_mode(),\n        suppress_report: false,\n        schedule: scheduled.then(|| AdmittedSchedule {\n            updated_at: automation.updated_at,\n            rrule: automation.rrule.clone(),\n        }),\n    });\n    Ok(())\n}\n\nfn check_dispatch_store(dispatch: &AutomationDispatch, tasks: &SharedTaskManager) -> Result<()> {\n    if tasks.data_dir().canonicalize()? != dispatch.task_data_dir.canonicalize()? {\n        bail!(\"Automation admission belongs to a different task store; it cannot be replayed here\");\n    }\n    Ok(())\n}\n\nasync fn dispatch_bound_task(\n    dispatch: &mut AutomationDispatch,\n    task_id: &str,\n    tasks: &SharedTaskManager,\n) -> Result<crate::task_manager::TaskRecord> {\n    check_dispatch_store(dispatch, tasks)?;\n    if dispatch.execution_scope.as_deref() != Some(tasks.execution_scope()) {\n        bail!(\n            \"Automation admission execution ownership is unverified or belongs to another Runtime\"\n        );\n    }\n    let task = if dispatch.accepted {\n        tasks\n            .read_bound_task(task_id)?","sourceCodeStart":2073,"sourceCodeEnd":2109,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/tui/src/automation_manager.rs#L2073-L2109","documentation":"Before replaying an admitted automation dispatch, the library verifies that the dispatch's recorded task_data_dir matches the current SharedTaskManager's data directory (compared via canonicalize). If they differ, the admission was created against a different task store and cannot be replayed here; executing it would bind the task into the wrong store. The error makes store mismatch an explicit failure instead of silently running an automation in the wrong context.","triggerScenarios":"Calling dispatch_bound_task (which calls check_dispatch_store) with a dispatch whose task_data_dir canonicalizes to a different path than tasks.data_dir() — e.g. dispatching a trigger or run record persisted under another profile/data root.","commonSituations":"Copying automation state files between machines or between dev and production data directories; changing CODEX_HOME/data dir between runs; running two profiles concurrently and replaying a record from the other profile; restoring backups into a different location.","solutions":["Replay the dispatch against the task manager whose data_dir matches dispatch.task_data_dir","Re-admit the automation in the current store (create a fresh dispatch) instead of replaying the foreign one","Point the task manager at the original data directory (restore the expected path) if the record is the one you want","If migrating stores deliberately, rewrite dispatch.task_data_dir to the new canonical path via a migration, not at dispatch time"],"exampleFix":"// before\ndispatch_bound_task(&mut dispatch, &task_id, &wrong_store_tasks).await?;\n// after\nif tasks.data_dir().canonicalize()? == dispatch.task_data_dir.canonicalize()? {\n    dispatch_bound_task(&mut dispatch, &task_id, &tasks).await?;\n} else {\n    // re-admit in this store or route to the owning store\n}","handlingStrategy":"validation","validationCode":"if tasks.data_dir().canonicalize()? != dispatch.task_data_dir.canonicalize()? {\n    return Err(anyhow!(\"dispatch belongs to a different task store\"));\n}","typeGuard":null,"tryCatchPattern":"match dispatch_bound_task(&mut dispatch, &task_id, &tasks).await {\n    Err(e) if e.to_string().contains(\"different task store\") => {\n        // route to owning store or re-admit locally\n    },\n    other => other?,\n}","preventionTips":["Keep one canonical data directory per environment; don't copy automation state between stores","When migrating stores, re-admit automations instead of copying dispatch records","Record the owning store alongside any exported dispatch data","Canonicalize paths before comparing them yourself"],"tags":["rust","automation","paths","task-store"],"backgroundTag":"incompatible-source-type","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}