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
//! Error types for khive-fold
use thiserror::Error;
use uuid::Uuid;
/// Result type for fold operations
pub type FoldResult<T> = std::result::Result<T, FoldError>;
/// Errors that can occur in fold operations
#[derive(Error, Debug)]
pub enum FoldError {
/// Entry not found
#[error("Entry {0} not found")]
EntryNotFound(Uuid),
/// Invalid entry type for this fold
#[error("Invalid entry type: expected {expected}, got {actual}")]
InvalidEntryType {
/// The expected entry type name
expected: String,
/// The actual entry type that was provided
actual: String,
},
/// Fold context error
#[error("Context error: {0}")]
Context(String),
/// Serialization error
#[error("Serialization error: {0}")]
Serialization(#[from] serde_json::Error),
/// Storage error
#[error("Storage error: {0}")]
Storage(String),
/// Internal lock poisoned (concurrent panic)
#[error("Internal lock poisoned: {0}")]
LockPoisoned(String),
/// Invalid input to a cognitive primitive (Anchor, Selector).
#[error("invalid input: {0}")]
InvalidInput(String),
/// Budget exhausted during selection.
#[error("budget exhausted: needed {needed}, have {budget}")]
BudgetExhausted {
/// Budget needed.
needed: usize,
/// Budget available.
budget: usize,
},
/// Anchor not found during graph traversal.
#[error("anchor not found: {0}")]
AnchorNotFound(String),
/// Required component not configured.
#[error("required component not configured: {0}")]
ComponentMissing(String),
/// Checkpoint integrity check failed: stored hash does not match recomputed hash.
#[error("checkpoint integrity mismatch for '{id}': stored {stored}, computed {computed}")]
IntegrityMismatch {
/// Checkpoint id that failed verification.
id: String,
/// The hash stored in the checkpoint.
stored: String,
/// The hash recomputed from the loaded state.
computed: String,
},
/// A checkpoint with the given id was not found.
#[error("checkpoint not found: {0}")]
CheckpointNotFound(String),
}
#[cfg(test)]
#[path = "error_tests.rs"]
mod tests;