Skip to main content

synapse_application/
execution_error.rs

1use soma_ops::OperationName;
2
3use crate::CompatibilityError;
4
5/// Failure while executing one canonical Synapse operation.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum ExecutionError {
9    /// Canonical contract validation failed.
10    #[error(transparent)]
11    Compatibility(#[from] CompatibilityError),
12    /// Fleet topology or transport failed.
13    #[error(transparent)]
14    Fleet(#[from] soma_fleet::FleetError),
15    /// Infrastructure driver failed.
16    #[error(transparent)]
17    Infra(#[from] soma_infra::InfraError),
18    /// Operation plan construction or fingerprint validation failed.
19    #[error(transparent)]
20    Plan(#[from] soma_ops::PlanError),
21    /// Product authorization evidence did not match the mutation request.
22    #[error(transparent)]
23    Authorization(#[from] soma_ops::AuthorizationError),
24    /// Canonical operation result construction failed.
25    #[error(transparent)]
26    Result(#[from] soma_ops::ResultError),
27    /// Canonical target construction failed.
28    #[error(transparent)]
29    Target(#[from] soma_ops::TargetRefError),
30    /// Infrastructure mutation failed before a terminal result could be built.
31    #[error(transparent)]
32    Mutation(#[from] soma_infra::MutationFailure),
33    /// The operation exists but is not handled by this runtime.
34    #[error("canonical runtime cannot execute {0}")]
35    UnsupportedOperation(OperationName),
36    /// Supplied plan does not match the exact operation, context, target, or topology.
37    #[error("mutation plan mismatch: {0}")]
38    PlanMismatch(String),
39    /// An idempotent mutation omitted its required idempotency key.
40    #[error("idempotent mutation requires an idempotency key")]
41    MissingIdempotencyKey,
42    /// Synapse policy requires explicit confirmation for disruptive mutations.
43    #[error("disruptive mutation requires a confirmation reference")]
44    ConfirmationRequired,
45    /// A required product mutation port was not configured.
46    #[error("{domain} mutation port is unavailable for host {host}")]
47    MutationPortUnavailable {
48        /// Mutation domain.
49        domain: &'static str,
50        /// Host identity.
51        host: String,
52    },
53    /// The mutation deadline passed before admission.
54    #[error("mutation deadline has passed")]
55    DeadlineExceeded,
56    /// No host was supplied and no unambiguous default could be selected.
57    #[error("operation requires an explicit host because the topology has multiple candidates")]
58    HostRequired,
59    /// Requested host was absent from the current topology snapshot.
60    #[error("host is not present in the current topology: {0}")]
61    HostNotFound(String),
62    /// A canonical parameter had an unexpected runtime representation.
63    #[error("invalid canonical parameter {field}: {message}")]
64    InvalidParameter {
65        /// Invalid field.
66        field: String,
67        /// Corrective detail.
68        message: String,
69    },
70    /// Compose project discovery could not resolve a usable config file.
71    #[error("Compose project {project} was not found on host {host}")]
72    ProjectNotFound {
73        /// Host identity.
74        host: String,
75        /// Project name.
76        project: String,
77    },
78    /// Typed infrastructure output could not be serialized.
79    #[error("canonical result serialization failed: {0}")]
80    Serialization(String),
81}
82
83#[cfg(test)]
84#[path = "execution_error_tests.rs"]
85mod tests;