canic_backup/manifest/types.rs
1//! Module: manifest::types
2//!
3//! Responsibility: define serialized backup manifest data contracts.
4//! Does not own: validation, discovery, snapshot capture, or restore actions.
5//! Boundary: stable JSON shapes shared by backup creation and restore flows.
6
7use serde::{Deserialize, Serialize};
8
9///
10/// DeploymentBackupManifest
11///
12/// Top-level deployment backup manifest persisted with a backup bundle.
13/// Owned by backup manifest contracts and consumed by restore planning.
14///
15
16#[derive(Clone, Debug, Deserialize, Serialize)]
17pub struct DeploymentBackupManifest {
18 pub manifest_version: u16,
19 pub backup_id: String,
20 pub created_at: String,
21 pub tool: ToolMetadata,
22 pub source: SourceMetadata,
23 pub consistency: ConsistencySection,
24 pub deployment: DeploymentSection,
25 pub verification: VerificationPlan,
26}
27
28///
29/// ToolMetadata
30///
31/// Tool identity recorded with one generated backup manifest.
32/// Owned by backup manifest contracts and written during backup creation.
33///
34
35#[derive(Clone, Debug, Deserialize, Serialize)]
36pub struct ToolMetadata {
37 pub name: String,
38 pub version: String,
39}
40
41///
42/// SourceMetadata
43///
44/// Source environment identity recorded for a backup bundle.
45/// Owned by backup manifest contracts and used by restore validation.
46///
47
48#[derive(Clone, Debug, Deserialize, Serialize)]
49pub struct SourceMetadata {
50 pub environment: String,
51 pub root_canister: String,
52}
53
54///
55/// ConsistencySection
56///
57/// Backup unit grouping used to validate deployment consistency.
58/// Owned by backup manifest contracts and checked before restore planning.
59///
60
61#[derive(Clone, Debug, Deserialize, Serialize)]
62pub struct ConsistencySection {
63 pub backup_units: Vec<BackupUnit>,
64}
65
66///
67/// BackupUnit
68///
69/// Role grouping that must be captured and restored as one consistency unit.
70/// Owned by backup manifest contracts and validated against deployment roles.
71///
72
73#[derive(Clone, Debug, Deserialize, Serialize)]
74pub struct BackupUnit {
75 pub unit_id: String,
76 pub kind: BackupUnitKind,
77 pub roles: Vec<String>,
78}
79
80///
81/// BackupUnitKind
82///
83/// Consistency grouping mode for a backup unit.
84/// Owned by backup manifest contracts and interpreted by validators.
85///
86
87#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
88#[serde(rename_all = "kebab-case")]
89pub enum BackupUnitKind {
90 Single,
91 Subtree,
92}
93
94///
95/// DeploymentSection
96///
97/// Captured deployment topology and member list for one backup.
98/// Owned by backup manifest contracts and consumed by restore planning.
99///
100
101#[derive(Clone, Debug, Deserialize, Serialize)]
102pub struct DeploymentSection {
103 pub topology_hash_algorithm: String,
104 pub topology_hash_input: String,
105 pub discovery_topology_hash: String,
106 pub pre_snapshot_topology_hash: String,
107 pub topology_hash: String,
108 pub members: Vec<DeploymentMember>,
109}
110
111///
112/// DeploymentMember
113///
114/// One canister member captured in a deployment backup manifest.
115/// Owned by backup manifest contracts and mapped into restore plan members.
116///
117
118#[derive(Clone, Debug, Deserialize, Serialize)]
119pub struct DeploymentMember {
120 pub role: String,
121 pub canister_id: String,
122 pub parent_canister_id: Option<String>,
123 pub subnet_canister_id: Option<String>,
124 pub controller_hint: Option<String>,
125 pub identity_mode: IdentityMode,
126 pub verification_checks: Vec<VerificationCheck>,
127 pub source_snapshot: SourceSnapshot,
128}
129
130///
131/// IdentityMode
132///
133/// Restore identity policy for one deployment member.
134/// Owned by backup manifest contracts and enforced during restore planning.
135///
136
137#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
138#[serde(rename_all = "kebab-case")]
139pub enum IdentityMode {
140 Fixed,
141 Relocatable,
142}
143
144///
145/// SourceSnapshot
146///
147/// Snapshot artifact metadata for one deployment member.
148/// Owned by backup manifest contracts and validated before restore execution.
149///
150
151#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
152pub struct SourceSnapshot {
153 pub snapshot_id: String,
154 pub module_hash: Option<String>,
155 pub code_version: Option<String>,
156 pub artifact_path: String,
157 pub checksum_algorithm: String,
158 #[serde(default)]
159 pub checksum: Option<String>,
160}
161
162///
163/// VerificationPlan
164///
165/// Deployment and member verification checks required for a backup bundle.
166/// Owned by backup manifest contracts and consumed by restore validation.
167///
168
169#[derive(Clone, Debug, Default, Deserialize, Serialize)]
170pub struct VerificationPlan {
171 pub deployment_checks: Vec<VerificationCheck>,
172 pub member_checks: Vec<MemberVerificationChecks>,
173}
174
175///
176/// MemberVerificationChecks
177///
178/// Verification checks scoped to one deployment role.
179/// Owned by backup manifest contracts and validated against deployment members.
180///
181
182#[derive(Clone, Debug, Deserialize, Serialize)]
183pub struct MemberVerificationChecks {
184 pub role: String,
185 pub checks: Vec<VerificationCheck>,
186}
187
188///
189/// VerificationCheck
190///
191/// Named verification check and the deployment roles it covers.
192/// Owned by backup manifest contracts and interpreted by validators.
193///
194
195#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
196pub struct VerificationCheck {
197 pub kind: String,
198 pub roles: Vec<String>,
199}