canic_host/deployment_truth/model/promotion/source/
mod.rs1use super::super::VerifiedPostconditionV1;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
8pub enum ArtifactTransportV1 {
9 LocalCli,
10 WasmStore,
11 DirectAgent,
12}
13
14impl ArtifactTransportV1 {
15 #[must_use]
16 pub const fn label(self) -> &'static str {
17 match self {
18 Self::LocalCli => "LocalCli",
19 Self::WasmStore => "WasmStore",
20 Self::DirectAgent => "DirectAgent",
21 }
22 }
23}
24
25#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
29pub struct StagingReceiptV1 {
30 pub schema_version: u32,
31 pub role: String,
32 pub artifact_identity: String,
33 pub transport: ArtifactTransportV1,
34 pub wasm_store_locator: Option<String>,
35 pub prepared_chunk_hashes: Vec<String>,
36 pub published_chunk_count: usize,
37 pub verified_postcondition: VerifiedPostconditionV1,
38}
39
40#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
44pub struct RoleArtifactSourceV1 {
45 pub role: String,
46 pub kind: RoleArtifactSourceKindV1,
47 pub locator: Option<String>,
48 pub previous_receipt_kind: Option<PreviousArtifactReceiptKindV1>,
49 pub previous_receipt_lineage_digest: Option<String>,
50 pub expected_wasm_sha256: Option<String>,
51 pub expected_wasm_gz_sha256: Option<String>,
52 pub expected_candid_sha256: Option<String>,
53 pub expected_canonical_embedded_config_sha256: Option<String>,
54}
55
56#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
60pub struct RolePromotionInputV1 {
61 pub role: String,
62 pub promotion_level: PromotionArtifactLevelV1,
63 pub source: RoleArtifactSourceV1,
64 pub require_byte_identical_wasm: bool,
65 pub require_target_embedded_config: bool,
66 pub target_store_has_artifact: Option<bool>,
67}
68
69#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
73pub enum PromotionArtifactLevelV1 {
74 SealedWasm,
75 SourceBuild,
76}
77
78impl PromotionArtifactLevelV1 {
79 #[must_use]
80 pub const fn label(self) -> &'static str {
81 match self {
82 Self::SealedWasm => "SealedWasm",
83 Self::SourceBuild => "SourceBuild",
84 }
85 }
86}
87
88#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
92pub enum PromotionReadinessStatusV1 {
93 Ready,
94 Blocked,
95}
96
97impl PromotionReadinessStatusV1 {
98 #[must_use]
99 pub const fn label(self) -> &'static str {
100 match self {
101 Self::Ready => "ready",
102 Self::Blocked => "blocked",
103 }
104 }
105}
106
107#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
111pub enum RoleArtifactSourceKindV1 {
112 WorkspacePackage,
113 PublishedPackage,
114 LocalWasm,
115 LocalWasmGz,
116 PreviousReceiptArtifact,
117 CanonicalWasmStoreDefault,
118}
119
120impl RoleArtifactSourceKindV1 {
121 #[must_use]
122 pub const fn label(self) -> &'static str {
123 match self {
124 Self::WorkspacePackage => "WorkspacePackage",
125 Self::PublishedPackage => "PublishedPackage",
126 Self::LocalWasm => "LocalWasm",
127 Self::LocalWasmGz => "LocalWasmGz",
128 Self::PreviousReceiptArtifact => "PreviousReceiptArtifact",
129 Self::CanonicalWasmStoreDefault => "CanonicalWasmStoreDefault",
130 }
131 }
132}
133
134#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
138pub enum PreviousArtifactReceiptKindV1 {
139 DeploymentReceipt,
140 StagingReceipt,
141}
142
143impl PreviousArtifactReceiptKindV1 {
144 #[must_use]
145 pub const fn label(self) -> &'static str {
146 match self {
147 Self::DeploymentReceipt => "DeploymentReceipt",
148 Self::StagingReceipt => "StagingReceipt",
149 }
150 }
151}
152
153#[cfg(test)]
154mod tests {
155 use super::*;
156
157 #[test]
158 fn artifact_transport_owns_text_labels() {
159 assert_eq!(ArtifactTransportV1::LocalCli.label(), "LocalCli");
160 assert_eq!(ArtifactTransportV1::WasmStore.label(), "WasmStore");
161 assert_eq!(ArtifactTransportV1::DirectAgent.label(), "DirectAgent");
162 }
163
164 #[test]
165 fn promotion_artifact_level_owns_text_labels() {
166 assert_eq!(PromotionArtifactLevelV1::SealedWasm.label(), "SealedWasm");
167 assert_eq!(PromotionArtifactLevelV1::SourceBuild.label(), "SourceBuild");
168 }
169
170 #[test]
171 fn promotion_readiness_status_owns_text_labels() {
172 assert_eq!(PromotionReadinessStatusV1::Ready.label(), "ready");
173 assert_eq!(PromotionReadinessStatusV1::Blocked.label(), "blocked");
174 }
175
176 #[test]
177 fn role_artifact_source_kind_owns_text_labels() {
178 assert_eq!(
179 RoleArtifactSourceKindV1::WorkspacePackage.label(),
180 "WorkspacePackage"
181 );
182 assert_eq!(
183 RoleArtifactSourceKindV1::PublishedPackage.label(),
184 "PublishedPackage"
185 );
186 assert_eq!(RoleArtifactSourceKindV1::LocalWasm.label(), "LocalWasm");
187 assert_eq!(RoleArtifactSourceKindV1::LocalWasmGz.label(), "LocalWasmGz");
188 assert_eq!(
189 RoleArtifactSourceKindV1::PreviousReceiptArtifact.label(),
190 "PreviousReceiptArtifact"
191 );
192 assert_eq!(
193 RoleArtifactSourceKindV1::CanonicalWasmStoreDefault.label(),
194 "CanonicalWasmStoreDefault"
195 );
196 }
197
198 #[test]
199 fn previous_artifact_receipt_kind_owns_text_labels() {
200 assert_eq!(
201 PreviousArtifactReceiptKindV1::DeploymentReceipt.label(),
202 "DeploymentReceipt"
203 );
204 assert_eq!(
205 PreviousArtifactReceiptKindV1::StagingReceipt.label(),
206 "StagingReceipt"
207 );
208 }
209}