Skip to main content

ic_backup/ports/ic_mutation/
mod.rs

1//! Single reserved IC update contract; no installed transport or dispatch implementation.
2
3use crate::model::ic_mutation::{IcMutationAcknowledgement, IcMutationRequest};
4use thiserror::Error;
5
6/// Integration-owned authenticated single-update submission for an original reservation.
7///
8/// Before invocation retain the exact original plan and IC bytes, persist the
9/// mutation reservation, qualify full prerequisite evidence and current exact
10/// network/caller/target/controller authority. Capture requires original consistency/
11/// fence/quiescence admission. Load additionally requires exact snapshot-origin
12/// permissions; target control/read visibility cannot substitute. Load/start require
13/// same-release source/upload identity,
14/// complete transfer and application-owned outside-snapshot restoration/restart safety.
15/// Retain obligations/source references and qualify exclusive dispatch/command and
16/// byte custody. The structural request itself proves none of these conditions.
17///
18/// Invoke only if qualified custody proves this reservation was never dispatched.
19/// Pending journal state after interruption is insufficient: reconcile the exact
20/// uncertain effect rather than invoke again. Send the exact management receiver,
21/// effective routing target, method and argument bytes as one host replicated update.
22/// No proxy/query substitution, hidden retries, observations, funding or extra calls
23/// occur within this invocation. Additional calls need their own prior approved
24/// durable accounting and independently qualified admission.
25///
26/// Return exact retained raw reply bytes and actual context/target association;
27/// integrations authenticate and qualify opaque evidence independently. A capture
28/// ID or canonical empty acknowledgement never produces an Applied/NotApplied
29/// receipt automatically. Failures/drop/death retain the consumed pending mutation,
30/// fences, source references and recovery evidence. No failure proves nonapplication
31/// or refunds allowance. Terminal replay invokes no provider. No default exists.
32pub trait IcMutationProvider {
33    /// Submit one exact originally reserved update without retry or follow-up observation.
34    /// # Errors
35    /// Every failure preserves pending original evidence; reconcile indeterminate replies.
36    fn submit_mutation(
37        &mut self,
38        request: &IcMutationRequest<'_>,
39    ) -> Result<IcMutationAcknowledgement, IcMutationProviderError>;
40}
41
42/// Redacted single-call failure; no variant grants retry, nonapplication or a refund.
43#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
44pub enum IcMutationProviderError {
45    /// No qualified provider; no dispatch.
46    #[error("IC mutation provider unavailable")]
47    Unavailable,
48    /// Provider cannot qualify this exact bounded host update contract.
49    #[error("IC mutation contract unsupported")]
50    Unsupported,
51    /// Submission/reply/authentication outcome is indeterminate; retain pending evidence.
52    #[error("IC mutation update indeterminate")]
53    Indeterminate,
54}