canic-core 0.101.34

Canic — a canister orchestration and management toolkit for the Internet Computer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
//! Module: dto::component_provisioning
//!
//! Responsibility: carry one canonical Fleet Component provisioning plan across boundaries.
//! Does not own: plan derivation, validation, persistence, root effects, or receipts.
//! Boundary: the Coordinator retains the complete plan and sends each root only its exact batch.

use crate::{
    config::{ComponentDeploymentLabel, ComponentDeploymentLimits, ComponentDeploymentPurpose},
    dto::fleet_registry::FleetRegistryVersion,
    ids::{
        ComponentBinding, ComponentDeploymentConfigurationDigest, ComponentGroupDeploymentId,
        ComponentGroupMemberPath, ComponentGroupPlacementId, ComponentGroupSpecId, ComponentSpecId,
        FleetBinding, FleetSubnetRootBinding, FleetSubnetRootReleaseSet,
    },
};
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};

/// Complete canonical provisioning authority retained before any root effect.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningPlan {
    pub fleet: FleetBinding,
    pub fleet_registry: FleetRegistryVersion,
    pub configuration_digest: ComponentDeploymentConfigurationDigest,
    pub operation: FleetComponentProvisioningOperation,
    pub directory_confirmation_roots: Vec<Principal>,
    pub batches: Vec<FleetSubnetRootProvisioningBatch>,
}

/// Controller-authenticated command that durably freezes one complete plan.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningPrepareRequest {
    pub operation_id: [u8; 32],
    pub plan: FleetComponentProvisioningPlan,
}

/// Controller-authenticated command advancing one exact Coordinator provisioning step.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningAdvanceRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub expected_phase: FleetComponentProvisioningPhase,
    pub expected_accepted_root_count: u32,
    pub expected_provisioned_root_count: u32,
    pub expected_current_root: Option<FleetComponentProvisioningRootProgress>,
    pub expected_directory_confirmed_root_count: u32,
    pub expected_current_publication: Option<FleetComponentPublicationRootProgress>,
    pub expected_runtime_activated_root_count: u32,
    pub expected_current_activation: Option<FleetComponentActivationRootProgress>,
}

/// Exact root-local cursor copied from passive Coordinator status before one advance.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningRootProgress {
    pub fleet_subnet_root: Principal,
    pub component_count: u32,
    pub reserved_component_count: u32,
    pub claimed_component_count: u32,
    pub installed_component_count: u32,
    pub registry_committed_component_count: u32,
}

/// Exact root-local Directory cursor copied from passive Coordinator status.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentPublicationRootProgress {
    pub fleet_subnet_root: Principal,
    pub component_count: u32,
    pub published_component_count: u32,
}

/// Exact root-local runtime-activation cursor copied from passive Coordinator status.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentActivationRootProgress {
    pub fleet_subnet_root: Principal,
    pub component_count: u32,
    pub activated_component_count: u32,
    pub root_runtime_active: bool,
}

/// Exact passive lookup key for one Coordinator-owned provisioning operation.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningStatusRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
}

/// Durable Coordinator progress exposed without returning the complete plan.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum FleetComponentProvisioningPhase {
    Planned,
    AcceptingRoots,
    RootsAccepted,
    ProvisioningRoots,
    ComponentsProvisioned,
    ServiceTopologyPublished,
    ConfirmingDirectories,
    DirectoriesConfirmed,
    ActivatingRuntimes,
    RuntimesActivated,
}

/// Compact exact status for one Coordinator-owned provisioning operation.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetComponentProvisioningStatusResponse {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub fleet_registry: FleetRegistryVersion,
    pub configuration_digest: ComponentDeploymentConfigurationDigest,
    pub operation: FleetComponentProvisioningOperation,
    pub phase: FleetComponentProvisioningPhase,
    pub directory_confirmation_root_count: u32,
    pub root_batch_count: u32,
    pub accepted_root_count: u32,
    pub acceptance_in_flight_root: Option<Principal>,
    pub provisioned_root_count: u32,
    pub current_root: Option<FleetComponentProvisioningRootProgress>,
    pub provisioning_in_flight_root: Option<Principal>,
    pub directory_confirmed_root_count: u32,
    pub current_publication: Option<FleetComponentPublicationRootProgress>,
    pub publication_in_flight_root: Option<Principal>,
    pub runtime_activated_root_count: u32,
    pub current_activation: Option<FleetComponentActivationRootProgress>,
    pub activation_in_flight_root: Option<Principal>,
    pub group_placement_count: u32,
    pub component_count: u32,
    pub planned_at_ns: u64,
    pub roots_accepted_at_ns: Option<u64>,
    pub components_provisioned_at_ns: Option<u64>,
    pub published_fleet_registry: Option<FleetRegistryVersion>,
    pub service_topology_published_at_ns: Option<u64>,
    pub directories_confirmed_at_ns: Option<u64>,
    pub runtimes_activated_at_ns: Option<u64>,
}

/// Fresh-install or monotonic scale-out scope covered by one plan.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub enum FleetComponentProvisioningOperation {
    FreshInstall,
    ScaleOut {
        deployment: ComponentGroupDeploymentId,
        previous_placements: u32,
        requested_placements: u32,
    },
}

/// One selected root's complete canonical provisioning batch.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct FleetSubnetRootProvisioningBatch {
    pub root: FleetSubnetRootBinding,
    pub active_release_set: FleetSubnetRootReleaseSet,
    pub placements: Vec<ComponentGroupPlacementPlan>,
}

/// One materialized copy of a completely flattened Component Group.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupPlacementPlan {
    pub group_placement: ComponentGroupPlacementId,
    pub component_group: ComponentGroupSpecId,
    pub entries: Vec<ComponentGroupPlanEntry>,
}

/// One exact top-level Component occurrence within a group placement.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupPlanEntry {
    pub member_path: ComponentGroupMemberPath,
    pub component_spec: ComponentSpecId,
    pub spec_hash: [u8; 32],
    pub purpose: ComponentDeploymentPurpose,
    pub labels: Vec<ComponentDeploymentLabel>,
    pub limits: ComponentDeploymentLimits,
}

/// Coordinator-authenticated command asking one root to retain its exact plan batch.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentProvisioningAcceptanceRequest {
    pub fleet_registry: FleetRegistryVersion,
    pub configuration_digest: ComponentDeploymentConfigurationDigest,
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub batch: FleetSubnetRootProvisioningBatch,
}

/// Read-only lookup key for one exact root provisioning operation.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentProvisioningStatusRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
}

/// Coordinator-authenticated command advancing one exact bounded provisioning step.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentProvisioningAdvanceRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub expected_reserved_component_count: u32,
    pub expected_claimed_component_count: u32,
    pub expected_installed_component_count: u32,
    pub expected_registry_committed_component_count: u32,
}

/// One exact member of a root-derived Component Group Directory.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupDirectoryMember {
    pub member_path: ComponentGroupMemberPath,
    pub component_spec: ComponentSpecId,
    pub purpose: ComponentDeploymentPurpose,
    pub labels: Vec<ComponentDeploymentLabel>,
    pub binding: ComponentBinding,
}

/// Protected origin of one root-derived Component Group Directory.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupDirectoryProvenance {
    pub authority: crate::ids::FleetRegistryAuthority,
    pub fleet_subnet_root: Principal,
    pub group_placement: ComponentGroupPlacementId,
    pub component_group: ComponentGroupSpecId,
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub placement_receipt_content_hash: [u8; 32],
}

/// Complete bounded sibling projection for one materialized Component Group placement.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupDirectory {
    pub provenance: ComponentGroupDirectoryProvenance,
    pub members: Vec<ComponentGroupDirectoryMember>,
}

/// Compact proof of one exact Component Directory delivered during publication.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentDirectoryPublicationEvidence {
    pub component: crate::ids::ComponentInstanceId,
    pub content_hash: [u8; 32],
}

/// Compact proof of one exact Component Group Directory delivered during publication.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ComponentGroupDirectoryPublicationEvidence {
    pub group_placement: ComponentGroupPlacementId,
    pub content_hash: [u8; 32],
}

/// Complete root-local evidence for one published provisioning batch.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentPublicationEvidence {
    pub fleet_registry: FleetRegistryVersion,
    pub fleet_directory_content_hash: [u8; 32],
    pub component_directories: Vec<ComponentDirectoryPublicationEvidence>,
    pub component_group_directories: Vec<ComponentGroupDirectoryPublicationEvidence>,
}

/// Coordinator-authenticated command advancing one bounded root publication step.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentPublicationRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub published_fleet_registry: FleetRegistryVersion,
    pub expected_published_component_count: u32,
}

///
/// RootComponentDirectorySynchronizationRequest
///
/// Coordinator-authenticated command advancing one affected-root scale-out Directory step.
///

#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentDirectorySynchronizationRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub source_fleet_registry: FleetRegistryVersion,
    pub published_fleet_registry: FleetRegistryVersion,
    pub expected_synchronized_component_count: u32,
}

///
/// RootComponentDirectorySynchronizationResponse
///
/// Compact exact progress for one root's affected existing service members.
///

#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentDirectorySynchronizationResponse {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub source_fleet_registry: FleetRegistryVersion,
    pub published_fleet_registry: FleetRegistryVersion,
    pub fleet_subnet_root: Principal,
    pub affected_component_count: u32,
    pub synchronized_component_count: u32,
    pub fleet_directory_content_hash: [u8; 32],
    pub complete: bool,
    pub synchronized_at_ns: Option<u64>,
    pub receipt_content_hash: [u8; 32],
}

/// Coordinator-authenticated command advancing one bounded root activation step.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentActivationRequest {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub expected_activated_component_count: u32,
    pub expected_root_runtime_active: bool,
}

/// Compact terminal evidence binding Component inventory and root runtime activation.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentActivationEvidence {
    pub fleet_activation_operation_id: [u8; 32],
    pub initial_inventory_hash: [u8; 32],
    pub component_count: u32,
    pub root_activated_at_ns: u64,
}

/// One exact provisioned Component occurrence and its committed Registry identity.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootProvisionedGroupMember {
    pub member_path: ComponentGroupMemberPath,
    pub component_spec: ComponentSpecId,
    pub purpose: ComponentDeploymentPurpose,
    pub limits: ComponentDeploymentLimits,
    pub binding: ComponentBinding,
    pub component_registry_revision: u64,
    pub component_registry_content_hash: [u8; 32],
}

/// Complete provisioned result for one exact group placement on this root.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootProvisionedGroupPlacement {
    pub group_placement: ComponentGroupPlacementId,
    pub component_group: ComponentGroupSpecId,
    pub members: Vec<RootProvisionedGroupMember>,
}

/// Complete group-partitioned result of one root provisioning operation.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentProvisioningResult {
    pub placements: Vec<RootProvisionedGroupPlacement>,
}

/// Durable aggregate progress of one root provisioning batch.
#[derive(CandidType, Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum RootComponentProvisioningPhase {
    Accepted,
    Provisioned,
    Published,
    RuntimesActive,
}

/// Durable progress or complete terminal result for one exact root provisioning operation.
#[derive(CandidType, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RootComponentProvisioningStatusResponse {
    pub operation_id: [u8; 32],
    pub plan_hash: [u8; 32],
    pub fleet_registry: FleetRegistryVersion,
    pub configuration_digest: ComponentDeploymentConfigurationDigest,
    pub fleet_subnet_root: Principal,
    pub phase: RootComponentProvisioningPhase,
    pub placement_count: u32,
    pub component_count: u32,
    pub reserved_component_count: u32,
    pub claimed_component_count: u32,
    pub installed_component_count: u32,
    pub registry_committed_component_count: u32,
    pub published_component_count: u32,
    pub activated_component_count: u32,
    pub root_runtime_active: bool,
    pub result: Option<RootComponentProvisioningResult>,
    pub publication: Option<RootComponentPublicationEvidence>,
    pub activation: Option<RootComponentActivationEvidence>,
    pub accepted_at_ns: u64,
    pub provisioned_at_ns: Option<u64>,
    pub published_at_ns: Option<u64>,
    pub activation_started_at_ns: Option<u64>,
    pub runtimes_activated_at_ns: Option<u64>,
    pub receipt_content_hash: [u8; 32],
}