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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
pub(crate) enum Entity {
Shade(shade::ShadeError),
}
pub(crate) mod shade {
use clock::ShadeClockError;
use walker::Walker;
#[derive(Debug)]
pub(crate) enum ShadeError {
Ingestion(ingestion::Ingestion),
ClockError(ShadeClockError),
WalkerError(Walker),
}
mod walker {
use alloc::string::String;
use alloc::vec::Vec;
use crate::PathBuf;
#[derive(Debug)]
pub(crate) enum Walker {
ClockError(walkerclock::WalkerClockError),
// WalkerError Read Source File failure, uses fs::read_to_string
FileRead(FileRead),
DirRead(DirRead),
DirEntry(DirEntry),
// WalkerError Unsupported input language, tree-sitter thrown flag
UnsupportedLanguage(UnsupportedLanguage),
// WalkerError Parser thrown error, likely from SymbolTree dep or TreeSitter, indicates language set failure.
ParseErrorLangSet(ParseErrorLangSet),
ParseErrorFile(ParseErrorFile),
Cancelled(Cancelled),
EnumerationCancelled(EnumerationCancelled),
TaskPanic(TaskPanic),
Extraction(Extraction),
SpawnError(SpawnError),
EnumerationFailed(EnumerationFailed),
MemoryAccessError(MemoryAccessError),
ParseError(ParseError),
EntropyTermination(EntropyTermination),
}
#[derive(Debug)]
struct FileRead {
filename: Vec<PathBuf>,
error_context: String,
}
#[derive(Debug)]
struct DirRead {
filename: Vec<PathBuf>,
error_context: String,
}
#[derive(Debug)]
struct DirEntry {
filename: Vec<PathBuf>,
error_context: String,
}
#[derive(Debug)]
struct UnsupportedLanguage {
language: String,
filename: Vec<PathBuf>,
}
#[derive(Debug)]
struct ParseErrorLangSet {
error_context: String,
}
#[derive(Debug)]
struct ParseErrorFile {
filename: String,
}
#[derive(Debug)]
struct Cancelled {
walker_id: u64,
file_id: Option<PathBuf>,
}
#[derive(Debug)]
struct EnumerationCancelled {
walker_id: u64,
comment: String,
}
#[derive(Debug)]
struct TaskPanic {
walker_id: u64,
file_id: Vec<PathBuf>,
panic_message: String,
}
#[derive(Debug)]
struct Extraction {
file: Vec<PathBuf>,
error: String,
}
#[derive(Debug)]
struct SpawnError {
error: String,
}
#[derive(Debug)]
struct EnumerationFailed {
comment: String,
}
#[derive(Debug)]
struct MemoryAccessError {
pid: u32,
error_context: String,
}
#[derive(Debug)]
struct ParseError {
filename: Vec<PathBuf>,
error_context: String,
}
#[derive(Debug)]
struct EntropyTermination {
path: PathBuf,
comment: String,
}
mod walkerclock {
use alloc::string::String;
#[derive(Debug)]
pub(crate) enum WalkerClockError {
/// Clock overflow (approaching u64::MAX)
WalkerClockOverflow {
current: u64,
attempted: u64,
comment: Option<String>,
},
WalkerClockApproachingOverflow {
current: u64,
comment: Option<String>,
},
/// Invalid duration (end < start)
WalkerClockInvalidDuration {
start: u64,
end: u64,
},
WalkerClockClockError {
context: String,
},
WalkerClockClockErrorExt {
context: String,
extension: String,
},
WalkerClockClockUpdateFailure {
context: String,
comment: String,
},
}
}
}
mod clock {
use alloc::string::String;
#[derive(Debug)]
pub enum ShadeClockError {
/// Clock overflow (approaching u64::MAX)
ShadeClockOverflow(ShadeClockOverflow),
ShadeClockApproachingOverflow(ShadeClockApproachingOverflow),
/// Invalid duration (end < start)
ShadeClockInvalidDuration(ShadeClockInvalidDuration),
ShadeClockClockError(ShadeClockClockError),
ShadeClockClockErrorExt(ShadeClockErrorExt),
ShadeClockClockUpdateFailure(ShadeClockClockUpdateFailure),
}
#[derive(Debug)]
struct ShadeClockClockUpdateFailure {
context: String,
comment: String,
}
#[derive(Debug)]
struct ShadeClockErrorExt {
context: String,
extension: String,
}
#[derive(Debug)]
struct ShadeClockOverflow {
current: u64,
attempted: u64,
comment: Option<String>,
}
#[derive(Debug)]
struct ShadeClockApproachingOverflow {
current: u64,
comment: Option<String>,
}
#[derive(Debug)]
struct ShadeClockInvalidDuration {
start: u64,
end: u64,
}
#[derive(Debug)]
struct ShadeClockClockError {
context: String,
}
}
mod ingestion {
use alloc::string::String;
/// im aware this seems like overkill for a single failure mode but
/// this enum will grow as the ingestion logic deepens.
// use crate::{
// DaemonicError,
// ErrorContext,
// Position,
// Timestamp,
// EmissionGuarantee,
// daemonic::{
// daemonic_contract::{
// daemonic_result::{
// diagnostic::Diagnostic,
// subdiagnostic::Subdiagnostic,
// }
// }
// },
// };
#[derive(Debug)]
pub(crate) enum Ingestion {
IngestionFailure(IngestionFailure),
}
#[derive(Debug)]
struct IngestionFailure {
error_context: String,
comment: String,
}
// fn ctx(&self) -> ErrorContext {
// match self {
// Self::Configuration { context, comment } => {
// ctx!("Shade", "Configuration",
// format!("Daemonic Error: SHADE Configuration Error. Context: {context:#?} \
// Comment: {comment:#?}")
// )
// }
// Self::IngestionFailure { error_context, comment } => {
// ctx!("Shade", "Ingestion",
// format!("Daemonic Error: SHADE Ingestion Error. Context: {error_context:#?} \
// Comment: {comment:#?}")
// )
// }
// }
// }
}
// impl DaemonicError<'_> for NoShade {
// fn ctx(&self) -> ErrorContext {
// match self {
// Self::FileSystem { path, error_context } =>
// ctx!("Shade", "FileRead",
// format!("Daemonic Error::FileError {path:#?} Context FileRead() Failure Context: {error_context:#?} — GLASS SHATTERED")),
// Self::RecursivePoolWalker { error_context } =>
// ctx!("Shade", "RecursivePoolWalker",
// format!("Daemonic Error::RecursivePoolWalker {error_context:#?} Context RecursivePoolWalker")
// ),
// Self::RequestSerializationError { context } =>
// ctx!("Shade", "RequestSerialization",
// format!("Daemonic Error::RequestSerializationError {context:#?}")
// ),
// Self::CoordinatorReadError { context } =>
// ctx!("Shade", "CoordinatorRead",
// format!("Daemonic Error::CoordinatorReadError {context:#?}")
// ),
// Self::CoordinatorWriteError { context } =>
// ctx!("Shade", "CoordinatorWrite",
// format!("Daemonic Error::CoordinatorWriteError {context:#?}")
// ),
// Self::CoordinatorStdninFlushError { context } =>
// ctx!("Shade", "CoordinatorStdninFlush",
// format!("Daemonic Error::CoordinatorStdninFlushError {context:#?}")
// ),
// Self::CoordinatorResponseError { context } =>
// ctx!("Shade", "CoordinatorResponse",
// format!("Daemonic Error::CoordinatorResponseError(generic) {context:#?}")
// ),
// Self::DaemonDeath { broken_sword, declaration } =>
// ctx!("Shade", "DaemonDeath",
// format!("Daemonic Error::DaemonDeath Daemon Declared their own death context: {broken_sword:#?}. Declaration: {declaration:#?}")
// ),
// Self::CoordinatorResponseMalformed { context, } =>
// ctx!("Shade", "CoordinatorResponseMalformed",
// format!("Daemonic Error:: Invalid or Malformed Coordinator response. Context: {context:#?}")
// ),
// Self::CoordinatorBinaryError { context, error_context } =>
// ctx!("Shade", "CoordinatorBinary",
// format!("Daemonic Error: {error_context:#?}. Error passed up from bin: {context:#?}")
// ),
// Self::ClockError(context) =>
// ctx!("Shade", "ClockError",
// format!("Daemonic Error: Clock Error {context:#?} <UNK> GLASS SHATTERED, TEMPORAL STACK UNWIND INITIATING (in dev, todo)")
// ),
// Self::Configuration { context, comment } => {
// ctx!("Shade", "Configuration",
// format!("Daemonic Error: SHADE Configuration Error. Context: {context:#?} \
// Comment: {comment:#?}")
// )
// }
// Self::IngestionFailure { error_context, comment } => {
// ctx!("Shade", "Ingestion",
// format!("Daemonic Error: SHADE Ingestion Error. Context: {error_context:#?} \
// Comment: {comment:#?}")
// )
// }
// }
// }
// }
#[derive(Debug)]
struct NoShade;
}