Skip to main content

ic_backup/model/inventory_settlement/
mod.rs

1//! Passive independently qualified original snapshot-creation claims.
2
3use crate::model::artifacts::ArtifactChecksumRecord;
4use std::fmt;
5
6/// Independent original capture or allocation attribution; candidate cardinality supplies no claim.
7#[derive(Clone)]
8pub enum IcInventoryAttribution {
9    /// Exclusive attribution to the exact original capture or allocation, retained through observation.
10    Applied {
11        /// Exact new raw ID, distinct from every retained baseline ID.
12        snapshot_id: Vec<u8>,
13        /// Qualified evidence excluding independent creation by other writers.
14        attribution: ArtifactChecksumRecord,
15    },
16    /// The original capture or allocation never applied, including no transient creation then deletion.
17    NotApplied {
18        /// Qualified exclusion; an empty inventory delta is insufficient.
19        exclusion: ArtifactChecksumRecord,
20    },
21    /// An actually settled authenticated list cannot resolve the original capture or allocation.
22    Unresolved {
23        /// Settled uncertainty; lost, unavailable or malformed replies stay pending.
24        uncertainty: ArtifactChecksumRecord,
25    },
26}
27
28impl fmt::Debug for IcInventoryAttribution {
29    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
30        match self {
31            Self::Applied {
32                snapshot_id,
33                attribution,
34            } => formatter
35                .debug_struct("Applied")
36                .field("snapshot_id_bytes", &snapshot_id.len())
37                .field("attribution", attribution)
38                .finish(),
39            Self::NotApplied { exclusion } => formatter
40                .debug_struct("NotApplied")
41                .field("exclusion", exclusion)
42                .finish(),
43            Self::Unresolved { uncertainty } => formatter
44                .debug_struct("Unresolved")
45                .field("uncertainty", uncertainty)
46                .finish(),
47        }
48    }
49}
50
51/// Passive claims bound to original reservations and independently retained inventories.
52///
53/// Integrations retain the full original baseline before mutation and authenticate
54/// actual context/target, chronology, freshness, permissions, custody and attribution.
55/// `evidence` binds all fields and their qualification. No persisted proof flag,
56/// spending owner or receipt is introduced.
57#[derive(Clone, Debug)]
58pub struct IcInventorySettlement {
59    /// Original reservation and independently retained qualification evidence.
60    pub context: crate::model::settlement::SettlementContext,
61    /// Existing exact original list request/raw baseline digest.
62    pub baseline: ArtifactChecksumRecord,
63    /// Existing exact current list request/raw inventory digest.
64    pub inventory: ArtifactChecksumRecord,
65    /// Independently qualified outcome, never inferred from candidate count.
66    pub attribution: IcInventoryAttribution,
67}