liminal-server 0.25.4

Standalone server for the liminal messaging bus
Documentation
//! How a committed agent receipt reaches the runtime's own projections.

use super::DraftError;
use lys_pass::drafts::ApprovedDraft;

/// Repairs runtime projections from a committed receipt without another mutation.
pub trait AgentProjection: Send + Sync {
    /// Applies the native roster and state projection after durable execution.
    ///
    /// # Errors
    /// A failed native projection; the receipt remains available to replay.
    fn apply(&self, draft: &ApprovedDraft) -> Result<(), DraftError>;
}
impl AgentProjection for crate::agents::runtime::Agents {
    fn apply(&self, draft: &ApprovedDraft) -> Result<(), DraftError> {
        if draft.target.action == "create_agent" {
            self.created(&draft.target.id)
                .map_err(|_| DraftError::Store)?;
        }
        Ok(())
    }
}
impl AgentProjection for crate::server::connection::services::LiminalConnectionServices {
    fn apply(&self, draft: &ApprovedDraft) -> Result<(), DraftError> {
        self.execute_agent_draft(draft)
            .map_err(|_| DraftError::Store)?;
        Ok(())
    }
}