Skip to main content

canic_core/dto/
component_provisioning.rs

1//! Module: dto::component_provisioning
2//!
3//! Responsibility: carry one canonical Fleet Component provisioning plan across boundaries.
4//! Does not own: plan derivation, validation, persistence, root effects, or receipts.
5//! Boundary: the Coordinator retains the complete plan and sends each root only its exact batch.
6
7use crate::{
8    config::{ComponentDeploymentLabel, ComponentDeploymentLimits, ComponentDeploymentPurpose},
9    dto::fleet_registry::FleetRegistryVersion,
10    ids::{
11        ComponentDeploymentConfigurationDigest, ComponentGroupDeploymentId,
12        ComponentGroupMemberPath, ComponentGroupPlacementId, ComponentGroupSpecId, ComponentSpecId,
13        FleetBinding, FleetSubnetRootBinding, FleetSubnetRootReleaseSet,
14    },
15};
16use candid::{CandidType, Principal};
17use serde::{Deserialize, Serialize};
18
19/// Complete canonical provisioning authority retained before any root effect.
20#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
21#[serde(deny_unknown_fields)]
22pub struct FleetComponentProvisioningPlan {
23    pub fleet: FleetBinding,
24    pub fleet_registry: FleetRegistryVersion,
25    pub configuration_digest: ComponentDeploymentConfigurationDigest,
26    pub operation: FleetComponentProvisioningOperation,
27    pub directory_confirmation_roots: Vec<Principal>,
28    pub batches: Vec<FleetSubnetRootProvisioningBatch>,
29}
30
31/// Fresh-install or monotonic scale-out scope covered by one plan.
32#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
33#[serde(deny_unknown_fields)]
34pub enum FleetComponentProvisioningOperation {
35    FreshInstall,
36    ScaleOut {
37        deployment: ComponentGroupDeploymentId,
38        previous_placements: u32,
39        requested_placements: u32,
40    },
41}
42
43/// One selected root's complete canonical provisioning batch.
44#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
45#[serde(deny_unknown_fields)]
46pub struct FleetSubnetRootProvisioningBatch {
47    pub root: FleetSubnetRootBinding,
48    pub active_release_set: FleetSubnetRootReleaseSet,
49    pub placements: Vec<ComponentGroupPlacementPlan>,
50}
51
52/// One materialized copy of a completely flattened Component Group.
53#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
54#[serde(deny_unknown_fields)]
55pub struct ComponentGroupPlacementPlan {
56    pub group_placement: ComponentGroupPlacementId,
57    pub component_group: ComponentGroupSpecId,
58    pub entries: Vec<ComponentGroupPlanEntry>,
59}
60
61/// One exact top-level Component occurrence within a group placement.
62#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
63#[serde(deny_unknown_fields)]
64pub struct ComponentGroupPlanEntry {
65    pub member_path: ComponentGroupMemberPath,
66    pub component_spec: ComponentSpecId,
67    pub spec_hash: [u8; 32],
68    pub purpose: ComponentDeploymentPurpose,
69    pub labels: Vec<ComponentDeploymentLabel>,
70    pub limits: ComponentDeploymentLimits,
71}