1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//! Facade errors.
//!
//! SPDX-License-Identifier: MIT OR Apache-2.0
use antecedent_attribution::AttributionError;
use antecedent_core::SchemaError;
use antecedent_counterfactual::CounterfactualError;
use antecedent_data::DataError;
use antecedent_design::DesignError;
use antecedent_discovery::DiscoveryError;
use antecedent_estimate::EstimationError;
use antecedent_graph::GraphError;
use antecedent_identify::IdentificationError;
use antecedent_io::IoError;
use antecedent_model::ModelError;
use antecedent_state::StateError;
use antecedent_validate::ValidationError;
use thiserror::Error;
/// Pipeline and facade failures — structured sum over domain errors.
#[derive(Clone, Debug, Error, Eq, PartialEq)]
pub enum CausalError {
/// Identification failed.
#[error(transparent)]
Identify(#[from] IdentificationError),
/// Estimation failed.
#[error(transparent)]
Estimate(#[from] EstimationError),
/// Validation / refutation failed.
#[error(transparent)]
Validate(#[from] ValidationError),
/// Discovery failed.
#[error(transparent)]
Discovery(#[from] DiscoveryError),
/// Structural / probabilistic model failure.
#[error(transparent)]
Model(#[from] ModelError),
/// Counterfactual evaluation failed.
#[error(transparent)]
Counterfactual(#[from] CounterfactualError),
/// Attribution failed.
#[error(transparent)]
Attribution(#[from] AttributionError),
/// Artifact serialization / deserialization.
#[error(transparent)]
Serialization(#[from] IoError),
/// Tabular / time-series data construction or lookup.
#[error(transparent)]
Data(#[from] DataError),
/// Graph construction or validation.
#[error(transparent)]
Graph(#[from] GraphError),
/// Experiment / measurement design evaluation.
#[error(transparent)]
Design(#[from] DesignError),
/// Incremental antecedent-state update.
#[error(transparent)]
State(#[from] StateError),
/// Schema construction or name lookup at an API boundary.
#[error(transparent)]
Schema(#[from] SchemaError),
/// Logical / physical plan compilation failed.
#[error("{message}")]
Compile {
/// Message.
message: String,
},
/// Memory or other resource refusal.
#[error("{message}")]
Resource {
/// Message.
message: String,
},
/// Graph review incomplete (structured for facade UX).
#[error("{message}")]
ReviewRequired {
/// Review kind: `temporal_pag`, `temporal_cpdag`, `static_pag`, `static_cpdag`, `temporal_dag`, `generic`.
kind: String,
/// Discovery / supply algorithm id when known.
algorithm: Option<String>,
/// Count of pending / ambiguous marks blocking estimation.
pending_edge_count: usize,
/// Human-readable message.
message: String,
/// Next-step hint for callers.
hint: String,
},
/// Query / feature unsupported.
#[error("{message}")]
Unsupported {
/// Message.
message: &'static str,
},
/// Missing required builder input.
#[error("missing required field: {field}")]
Missing {
/// Field name.
field: &'static str,
},
/// Cooperative cancellation before a usable point estimate was available.
#[error("cancelled during {stage}")]
Cancelled {
/// Pipeline stage where cancellation was observed.
stage: &'static str,
},
}
impl CausalError {
/// Build a structured review-required error.
#[must_use]
pub fn review_required(
kind: impl Into<String>,
algorithm: Option<impl Into<String>>,
pending_edge_count: usize,
message: impl Into<String>,
hint: impl Into<String>,
) -> Self {
Self::ReviewRequired {
kind: kind.into(),
algorithm: algorithm.map(Into::into),
pending_edge_count,
message: message.into(),
hint: hint.into(),
}
}
/// Convenience when only a message is available (generic review).
#[must_use]
pub fn review_required_msg(message: impl Into<String>) -> Self {
let message = message.into();
Self::review_required(
"generic",
None::<String>,
0,
message,
"complete graph review (finish_*_review) or supply a fully oriented graph",
)
}
}
/// Deprecated alias for [`CausalError`].
#[deprecated(note = "renamed to CausalError")]
pub type AnalysisError = CausalError;