Skip to main content

wasm_capability_contract/component/entity/
component_manifest.rs

1//! [`ComponentManifest`] — identity, route, limits, and declared capabilities of one component.
2
3use serde::{Deserialize, Serialize};
4
5use crate::{ArtifactProvenance, ResourceLimits};
6
7/// Declares what a Wasm component is, what route it wants, what it
8/// declares it needs, and where it came from.
9///
10/// Checked by a real `ComponentValidator` implementor before the
11/// component's route is ever registered — a component whose manifest
12/// fails validation must never reach the host's dispatch engine.
13///
14/// The one `entity` in this crate: `component_id` is a stable identity
15/// that outlives changes to route, contract version, or anything else
16/// here, so equality is by `component_id` alone (see [`PartialEq`] below),
17/// not full structural equality the way a `vo`/`dto` compares.
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct ComponentManifest {
20    /// Stable identifier for this component, independent of route or version.
21    pub component_id: String,
22    /// The route this component wants to serve (e.g. `"/echo"`).
23    pub route_id: String,
24    /// The byte-ABI contract version this component was compiled against.
25    pub contract_version: String,
26    /// Name of the component's exported handler function.
27    pub handler_export: String,
28    /// Resource bounds the host must enforce for this component.
29    pub resource_limits: ResourceLimits,
30    /// Capability names this component declares it needs (e.g.
31    /// `"http-egress"`). Anything not also present in the route's granted
32    /// `Vec<CapabilityGrant>` is denied — ADR-001's deny-by-default posture.
33    pub capabilities: Vec<String>,
34    /// Where this artifact came from and how to verify it.
35    pub artifact_provenance: ArtifactProvenance,
36}
37
38/// Identity-based, not structural: two manifests with the same
39/// `component_id` are the same component even if every other field
40/// differs (e.g. a redeploy that changes `route_id` or bumps
41/// `contract_version`) -- the entity persists across such changes.
42impl PartialEq for ComponentManifest {
43    fn eq(&self, other: &Self) -> bool {
44        self.component_id == other.component_id
45    }
46}
47
48impl Eq for ComponentManifest {}