Skip to main content

logit_loom_diffusion/
error.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Diffusion contract and callback failures.
4
5use logit_loom_core::CoreError;
6use thiserror::Error;
7
8/// Result returned by backend-neutral diffusion mechanics.
9pub type Result<T> = std::result::Result<T, Error>;
10
11/// Failure before native state can be committed.
12#[derive(Debug, Error)]
13#[non_exhaustive]
14pub enum Error {
15    /// A serializable contract was invalid.
16    #[error(transparent)]
17    Contract(#[from] CoreError),
18    /// The supplied state does not match the declared tensor contract.
19    #[error("diffusion state is incompatible: {0}")]
20    Incompatible(String),
21    /// An ordered intervention stage returned an error.
22    #[error("diffusion intervention stage {stage} failed: {message}")]
23    Intervention {
24        /// Zero-based stage index.
25        stage: usize,
26        /// Bounded callback detail.
27        message: String,
28    },
29    /// A post-step observer returned an error.
30    #[error("diffusion observer {observer} failed: {message}")]
31    Observer {
32        /// Zero-based observer index.
33        observer: usize,
34        /// Bounded callback detail.
35        message: String,
36    },
37}