Skip to main content

DaemonDispatch

Trait DaemonDispatch 

Source
pub trait DaemonDispatch:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn dispatch<'life0, 'async_trait>(
        &'life0 self,
        ops: String,
        presentation: Option<String>,
        presentation_per_op: Option<Vec<Option<String>>>,
        format: Option<String>,
        format_per_op: Option<Vec<Option<String>>>,
        from_wire: bool,
        identity: Option<RequestIdentity>,
    ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn warm_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn namespace(&self) -> &str;
    fn config_id(&self) -> &str;

    // Provided methods
    fn pool_for_checkpoint(&self) -> Option<Arc<ConnectionPool>> { ... }
    fn event_store_for_checkpoint(&self) -> Option<Arc<dyn EventStore>> { ... }
}
Expand description

Transport-agnostic dispatch interface for the daemon server.

The MCP crate implements this by dispatching through the shared request body while honoring DaemonRequestFrame::from_wire (so subhandler visibility is gated by request origin, not by transport); any future transport can do the same.

Required Methods§

Source

fn dispatch<'life0, 'async_trait>( &'life0 self, ops: String, presentation: Option<String>, presentation_per_op: Option<Vec<Option<String>>>, format: Option<String>, format_per_op: Option<Vec<Option<String>>>, from_wire: bool, identity: Option<RequestIdentity>, ) -> Pin<Box<dyn Future<Output = Result<String, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dispatch a verb-DSL request string and return the rendered result.

from_wire carries the origin discriminator from DaemonRequestFrame::from_wire: when true, the implementor enforces verb visibility (rejects Visibility::Subhandler verbs); when false, the request is from a trusted operator surface and subhandlers pass.

identity is the per-request identity context threaded from the frame (ADR-096): Some(..) when serving a request forwarded over the daemon socket (built from frame.namespace / frame.actor_id / frame.visible_namespaces by the connection handler), None for any other dispatch path. Implementors should mint the storage/gate token from identity when present and fall back to their own construction-baked identity when absent, so pure local (non-daemon) dispatch is unchanged.

Source

fn warm_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Warm every pack’s in-memory state (ANN indexes, etc.).

Source

fn namespace(&self) -> &str

The namespace this dispatcher was configured for.

Source

fn config_id(&self) -> &str

Fingerprint of this dispatcher’s resolved runtime config (packs, db target, embedders). Used to reject forwarded requests from clients whose config differs, so a restricted client cannot dispatch through a broader daemon.

Provided Methods§

Source

fn pool_for_checkpoint(&self) -> Option<Arc<ConnectionPool>>

Return the pool to use for background WAL checkpointing, if available.

Implementors backed by a file-based SQLite database should return Some(pool_arc). In-memory or test dispatchers that have no pool return None and the checkpoint task is not spawned.

The default implementation returns None.

Source

fn event_store_for_checkpoint(&self) -> Option<Arc<dyn EventStore>>

Return the audit EventStore the checkpoint task should append ADR-094 lifecycle events (CheckpointOutcomeRecorded) to, if any.

Mirrors Self::pool_for_checkpoint’s default-None shape: an implementor with no configured event store (or no pool at all) simply gets a checkpoint task that never appends events — the checkpoint task itself remains fully functional either way.

The default implementation returns None.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§