wasm-capability-contract 0.3.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
//! [`ComponentValidator`] — checks a component before its route is ever registered.

use crate::{CapabilityError, ValidateComponentRequest};

/// Checks a Wasm component's manifest and real bytes before its route is
/// registered. A real implementor enforces two gates, per ADR-001:
///
/// 1. **Manifest-level grant check** — every capability
///    `req.manifest.capabilities` declares must appear in
///    `req.granted_capabilities` (deny-by-default), and each grant's
///    `CapabilityScope` must be non-trivially empty for its kind.
/// 2. **Structural import check** — `req.component_bytes`' actual
///    component-level imports must each be backed by either a granted
///    capability with a real host implementation, or an unconditional
///    base-ABI runtime-support import.
///
/// Zero implementation here — this port only declares the contract.
pub trait ComponentValidator: Send + Sync {
    /// Validate `req`, per the two-gate contract above.
    ///
    /// # Errors
    ///
    /// Returns [`CapabilityError`] naming which gate failed and why.
    fn validate(&self, req: ValidateComponentRequest) -> Result<(), CapabilityError>;
}