use async_trait::async_trait;
use picloud_shared::{Script, ScriptId};

/// How the orchestrator looks up a script before dispatching to the
/// executor. In MVP this is backed by a direct Postgres read inside the
/// manager-core repository, exposed through this trait so orchestrator-core
/// stays DB-agnostic.
#[async_trait]
pub trait ScriptResolver: Send + Sync {
    async fn resolve(&self, id: ScriptId) -> Result<Option<Script>, ResolverError>;
}

#[derive(Debug, thiserror::Error)]
pub enum ResolverError {
    #[error("backend error: {0}")]
    Backend(String),
}
