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
//! [`CapabilityError`] — every actionable failure mode for
//! `ComponentValidator::validate` and `CapabilityEngine::load`/`invoke`.

/// Everything `ComponentValidator::validate` or a real `CapabilityEngine`
/// can fail with, named so the message alone tells the caller what to fix.
///
/// Split into two phases, matching the port's own split: validation/load-time
/// (`UnsupportedContractVersion`, `InvalidManifest`, `CapabilityUnavailable`
/// — rejected before a route is ever registered) and invocation-time
/// (`Trap`, `InvalidOutput`, `ResourceExhausted`, `Cancelled`, `Timeout` —
/// surfaced from a live `CapabilityEngine::invoke` call). `#1` scoped this
/// enum down to only the first phase since no `CapabilityEngine` existed yet;
/// `#3` (ADR-001's component engine wiring) adds the second phase back.
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
pub enum CapabilityError {
    /// The manifest's `contract_version` is not one this host understands.
    #[error("unsupported contract version: {0}")]
    UnsupportedContractVersion(String),
    /// The manifest or component bytes are structurally invalid.
    #[error("invalid manifest: {0}")]
    InvalidManifest(String),
    /// A declared capability has no matching grant, or its scope is
    /// empty/wildcarded in a way its kind never permits, or (at engine
    /// time) a granted capability has no matching real dispatcher wired.
    #[error("capability unavailable: {0}")]
    CapabilityUnavailable(String),
    /// The component trapped (panicked/aborted) during execution.
    #[error("component trap: {0}")]
    Trap(String),
    /// The component produced output that does not match its declared
    /// export shape.
    #[error("invalid output: {0}")]
    InvalidOutput(String),
    /// A configured memory, CPU, concurrency, or queue limit was exceeded.
    #[error("resource exhausted: {0}")]
    ResourceExhausted(String),
    /// The invocation was cancelled before it completed.
    #[error("invocation cancelled")]
    Cancelled,
    /// The invocation exceeded its configured deadline.
    #[error("invocation timed out")]
    Timeout,
}