1pub mod graph;
8
9pub mod pipeline;
11
12pub mod executor;
14
15pub mod idempotency;
17
18pub mod error {
20 use thiserror::Error;
21
22 #[derive(Debug, Error)]
36 pub enum StygianError {
37 #[error("Graph error: {0}")]
39 Graph(#[from] GraphError),
40
41 #[error("Service error: {0}")]
43 Service(#[from] ServiceError),
44
45 #[error("Provider error: {0}")]
47 Provider(#[from] ProviderError),
48
49 #[error("Config error: {0}")]
51 Config(#[from] ConfigError),
52
53 #[error("Rate limit error: {0}")]
55 RateLimit(#[from] RateLimitError),
56
57 #[error("Cache error: {0}")]
59 Cache(#[from] CacheError),
60 }
61
62 #[derive(Debug, Error)]
64 pub enum GraphError {
65 #[error("Graph contains cycle, cannot execute")]
67 CycleDetected,
68
69 #[error("Node not found: {0}")]
71 NodeNotFound(String),
72
73 #[error("Invalid edge: {0}")]
75 InvalidEdge(String),
76
77 #[error("Invalid pipeline: {0}")]
79 InvalidPipeline(String),
80
81 #[error("Execution failed: {0}")]
83 ExecutionFailed(String),
84 }
85
86 #[derive(Debug, Error)]
88 pub enum ServiceError {
89 #[error("Service unavailable: {0}")]
91 Unavailable(String),
92
93 #[error("Service timeout after {0}ms")]
95 Timeout(u64),
96
97 #[error("Invalid response: {0}")]
99 InvalidResponse(String),
100
101 #[error("Authentication failed: {0}")]
103 AuthenticationFailed(String),
104
105 #[error("Rate limited, retry after {retry_after_ms}ms")]
107 RateLimited {
108 retry_after_ms: u64,
110 },
111 }
112
113 #[derive(Debug, Error)]
115 pub enum ProviderError {
116 #[error("API error: {0}")]
118 ApiError(String),
119
120 #[error("Invalid credentials")]
122 InvalidCredentials,
123
124 #[error("Token limit exceeded: {0}")]
126 TokenLimitExceeded(String),
127
128 #[error("Model not available: {0}")]
130 ModelUnavailable(String),
131
132 #[error("Content policy violation: {0}")]
134 ContentPolicyViolation(String),
135 }
136
137 #[derive(Debug, Error)]
139 pub enum ConfigError {
140 #[error("Missing required config: {0}")]
142 MissingConfig(String),
143
144 #[error("Invalid config value for '{key}': {reason}")]
146 InvalidValue {
147 key: String,
149 reason: String,
151 },
152
153 #[error("Config file error: {0}")]
155 FileError(String),
156
157 #[error("TOML parse error: {0}")]
159 ParseError(String),
160 }
161
162 #[derive(Debug, Error)]
164 pub enum RateLimitError {
165 #[error("Rate limit exceeded: {0} requests per {1} seconds")]
167 Exceeded(u32, u32),
168
169 #[error("Quota exhausted: {0}")]
171 QuotaExhausted(String),
172
173 #[error("Retry after {0} seconds")]
175 RetryAfter(u64),
176 }
177
178 #[derive(Debug, Error)]
180 pub enum CacheError {
181 #[error("Cache miss: {0}")]
183 Miss(String),
184
185 #[error("Cache write failed: {0}")]
187 WriteFailed(String),
188
189 #[error("Cache read failed: {0}")]
191 ReadFailed(String),
192
193 #[error("Cache eviction failed: {0}")]
195 EvictionFailed(String),
196
197 #[error("Cache corrupted: {0}")]
199 Corrupted(String),
200 }
201
202 pub type Result<T> = std::result::Result<T, StygianError>;
204
205 #[derive(Debug, Error)]
207 pub enum DomainError {
208 #[error("Graph contains cycle, cannot execute")]
210 CycleDetected,
211
212 #[error("Invalid pipeline: {0}")]
214 InvalidPipeline(String),
215
216 #[error("Execution failed: {0}")]
218 ExecutionFailed(String),
219
220 #[error("Service error: {0}")]
222 ServiceError(String),
223 }
224
225 pub type DomainResult<T> = std::result::Result<T, DomainError>;
227}