wasm-capability-contract 0.4.0

Generic, domain-agnostic capability pattern: CapabilityEngine/CapabilityRegistry/CapabilityDispatcher trait shapes + component/capability types. Trait definitions only -- see wasm-capability-core for this pattern's own default implementation, extracted from agent-runtime's ADR-001 (agent-runtime#31, ADR-011).
Documentation
//! [`CapabilityDispatcher`] — executes one granted capability call.

/// Executes one capability call: decode `payload`, call the real
/// implementor injected behind this dispatcher, encode the result back to
/// bytes. A leaf operation (ADR-001) — never triggers a second capability
/// call on the guest's behalf.
///
/// `target` names what to call within this dispatcher's own bound scope
/// (a `"pkg.Service/Method"` for `grpc-egress`, a query name for
/// `database`, a secret name for `secrets`, ...) — never an open-ended
/// address the dispatcher itself resolves.
///
/// Returns a plain `String` error, not a typed one: every dispatcher
/// wraps a different real implementor's own error type, and this port has
/// no reason to unify them into one enum. Zero implementation here.
pub trait CapabilityDispatcher: Send + Sync {
    /// Dispatch one call to `target` with `payload`, returning the raw
    /// response bytes.
    ///
    /// `tokio_handle` lets an implementor whose real call is async re-enter
    /// a tokio runtime from a context (e.g. a component's own dedicated OS
    /// thread) that has none of its own ambiently.
    ///
    /// # Errors
    ///
    /// Returns a human-readable message naming what failed.
    fn dispatch(
        &self,
        tokio_handle: &tokio::runtime::Handle,
        target: &str,
        payload: Vec<u8>,
    ) -> Result<Vec<u8>, String>;
}