antecedent_core/query/
error.rs1use crate::ids::VariableId;
6
7#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
9#[non_exhaustive]
10pub enum QueryError {
11 #[error("treatment and outcome are the same variable {id}")]
13 TreatmentEqualsOutcome {
14 id: VariableId,
16 },
17 #[error("intervention targets {got}, expected treatment {expected}")]
19 InterventionVariableMismatch {
20 expected: VariableId,
22 got: VariableId,
24 },
25 #[error("intervention does not have a unique target variable")]
27 AmbiguousInterventionTarget,
28 #[error("effect modifier overlaps treatment or outcome")]
30 ModifierOverlapsTreatmentOrOutcome,
31 #[error("invalid temporal window [{from}, {until}]")]
33 InvalidTemporalWindow {
34 from: i32,
36 until: i32,
38 },
39 #[error("horizon_steps must be >= 1")]
41 NonPositiveHorizon,
42 #[error("invalid intervention: {0}")]
44 InvalidIntervention(String),
45 #[error("counterfactual query requires at least one outcome")]
47 EmptyCounterfactualOutcomes,
48 #[error("anomaly attribution requires targets")]
50 EmptyAnomalyTargets,
51 #[error("anomaly max_units must be >= 1")]
53 NonPositiveAnomalyLimit,
54 #[error("mediation query requires mediators")]
56 EmptyMediators,
57 #[error("mediator overlaps treatment or outcome")]
59 MediatorOverlapsTreatmentOrOutcome,
60 #[error("conditional effect requires non-empty effect modifiers")]
62 EmptyEffectModifiers,
63 #[error("population selector has no rows")]
65 EmptyPopulationRows,
66 #[error("predicate name must be non-empty")]
68 EmptyPredicateName,
69 #[error("TemporalPolicy::Dynamic has no single treatment offset")]
71 DynamicPolicyHasNoTreatmentOffset,
72 #[error("invalid population time range [{start}, {end})")]
74 InvalidPopulationTimeRange {
75 start: usize,
77 end: usize,
79 },
80 #[error("sequential allocation order is empty")]
82 EmptyAllocationOrder,
83 #[error("sequential allocation order contains duplicate components")]
85 DuplicateAllocationComponent,
86 #[error("Shapley max_exact_components must be >= 1")]
88 NonPositiveShapleyLimit,
89 #[error("Shapley sample / permutation count must be >= 1")]
91 NonPositiveShapleySamples,
92 #[error("max_components / max_targets must be >= 1")]
94 NonPositiveComponentLimit,
95 #[error("mechanism-change detection requires targets")]
97 EmptyMechanismChangeTargets,
98 #[error("significance level must be in (0, 1)")]
100 InvalidSignificanceLevel,
101 #[error("interventional distribution requires at least one outcome")]
103 EmptyDistributionOutcomes,
104 #[error("path max_paths / max_len must be >= 1")]
106 NonPositivePathLimit,
107 #[error("path node overlaps treatment or outcome")]
109 PathNodeOverlapsTreatmentOrOutcome,
110 #[error("distribution conditioning overlaps outcome or intervention")]
112 ConditioningOverlapsOutcomeOrIntervention,
113 #[error("named predicate / custom distribution requires a PopulationRegistry")]
115 PopulationRegistryRequired,
116 #[error("unknown predicate name `{name}`")]
118 UnknownPredicateName {
119 name: std::sync::Arc<str>,
121 },
122 #[error("unknown DistributionRef({id})")]
124 UnknownDistributionRef {
125 id: u32,
127 },
128 #[error("Treated/Untreated population requires a treatment column")]
130 PopulationNeedsTreatment,
131 #[error("Treated/Untreated population requires binary 0/1 treatment")]
133 PopulationNonBinaryTreatment,
134 #[error("population length mismatch: expected {expected}, got {actual}")]
136 PopulationLengthMismatch {
137 expected: usize,
139 actual: usize,
141 },
142 #[error("population row {row} out of range for n={n}")]
144 PopulationRowOutOfRange {
145 row: usize,
147 n: usize,
149 },
150 #[error("Environment target population is not resolved by PopulationRegistry")]
152 PopulationEnvironmentUnsupported,
153 #[error("custom distribution weights must be finite and non-negative")]
155 InvalidPopulationWeights,
156}