Skip to main content

canic_host/component_operation/model/
mod.rs

1//! Durable authority and progress for one host-owned Component invocation.
2//! Root storage remains the authoritative allocation and activation owner.
3
4use candid::Principal;
5use canic_core::ids::{
6    CanisterRole, ComponentBinding, ComponentInstanceId, ComponentSpecId, FleetSubnetRootBinding,
7    FleetSubnetRootReleaseSet,
8};
9use serde::{Deserialize, Serialize};
10
11/// Exact reviewed local, installation and placement authority.
12#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
13#[serde(deny_unknown_fields)]
14pub struct ComponentAuthorityRecord {
15    pub environment: String,
16    pub fleet: String,
17    pub root_name: String,
18    /// Historical review provenance; live authority can survive an unchanged-Fleet replan.
19    pub source_plan_sha256: String,
20    pub binding: FleetSubnetRootBinding,
21    pub release_set: FleetSubnetRootReleaseSet,
22    pub root_module_sha256: String,
23    pub root_candid_sha256: [u8; 32],
24    pub root_controllers: Vec<String>,
25    pub registry_sha256: [u8; 32],
26    pub operator: Principal,
27    pub component_spec: ComponentSpecId,
28    pub spec_hash: [u8; 32],
29    pub role: CanisterRole,
30}
31
32/// Immutable review for one local name and one Root operation identity.
33#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
34#[serde(deny_unknown_fields)]
35pub struct ComponentPlanRecord {
36    pub schema_version: u16,
37    pub name: String,
38    pub operation_id: [u8; 32],
39    pub authority: ComponentAuthorityRecord,
40    pub review_sha256: String,
41}
42
43/// Host projection of the maintained Root allocation phases.
44#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
45#[serde(rename_all = "snake_case")]
46pub enum ComponentPhase {
47    Reserved,
48    CreationIntent,
49    Created,
50    InstallIntent,
51    Installed,
52    Verified,
53    Committed,
54    Removed,
55}
56
57/// Root-observed identity and terminal activation evidence retained by the host.
58#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
59#[serde(deny_unknown_fields)]
60pub struct ComponentProgressRecord {
61    pub allocation_sequence: u64,
62    pub component: ComponentInstanceId,
63    pub phase: ComponentPhase,
64    pub binding: Option<ComponentBinding>,
65    pub complete: bool,
66}
67
68/// One atomically published local operation record; intent precedes submission.
69#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
70#[serde(deny_unknown_fields)]
71pub struct ComponentOperationRecord {
72    pub document_sha256: String,
73    pub plan: ComponentPlanRecord,
74    pub submission_attempts: u64,
75    pub progress: Option<ComponentProgressRecord>,
76}