ic_backup/ports/ic_observation/mod.rs
1//! Single reserved IC status/list observation contract; no installed provider.
2
3use crate::model::attempt_journal::AttemptJournalRecord;
4use crate::model::ic_observation::{IcObservationRequest, IcObservationResponse};
5use thiserror::Error;
6
7/// Integration-owned authenticated observation of an original pending mutation.
8///
9/// Retain original plan/mutation/observation bytes and durably reserve this exact
10/// observation before invocation. Qualify actual context, method-specific current
11/// read permission, original recovery chronology and exclusive command/dispatch
12/// custody proving this observation reservation was never dispatched. A reconstructed
13/// pending request proves none of these; a lost observation cannot be repeated.
14///
15/// Submit exactly one host replicated update using the original management receiver,
16/// effective target, method and Candid bytes. Status/list are semantic observations,
17/// still potentially paid. No query/proxy substitution, hidden retry, extra observations,
18/// funding or mutation is permitted. Additional calls need independent prior accounting.
19///
20/// Return exact retained raw reply and actual original authority/attempt/payload/context/
21/// target association. Integrations independently authenticate and qualify evidence,
22/// timing and exclusive attribution. Wire projections and inventory cardinality never
23/// automatically produce Applied/NotApplied/Uncertain receipts or fresh control/read
24/// authority. Failure/drop/death retain pending spent observation and mutation,
25/// obligations and source references; an absent reply is not settled uncertainty.
26/// Terminal replay invokes no provider. A configured Agent adapter requires exact signed-ingress retention before
27/// submission; no default provider or recovery qualification is installed.
28/// Await one observation while retaining the current original journal guard.
29/// Providers recheck the supplied record before submission; cancellation preserves
30/// both pending attempts and grants no reissue. No runtime or `Send` bound follows.
31pub trait IcObservationProvider {
32 /// Observe once under the exact already reserved original observation.
33 /// # Errors
34 /// All failures retain pending original accounting; no implicit reissue or outcome.
35 fn observe(
36 &mut self,
37 request: &IcObservationRequest<'_>,
38 journal: &AttemptJournalRecord,
39 ) -> impl Future<Output = Result<IcObservationResponse, IcObservationProviderError>>;
40}
41
42/// Redacted observation failure; no automatic receipt, refund or permission follows.
43#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
44pub enum IcObservationProviderError {
45 /// No qualified provider; no dispatch.
46 #[error("IC observation provider unavailable")]
47 Unavailable,
48 /// This exact bounded original observation contract cannot be qualified.
49 #[error("IC observation contract unsupported")]
50 Unsupported,
51 /// Observation dispatch/reply/authentication is indeterminate, not settled Uncertain.
52 #[error("IC observation response indeterminate")]
53 Indeterminate,
54}