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
// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
// SPDX-License-Identifier: MIT OR Apache-2.0
/// Top-level error type for all `zeph-memory` operations.
///
/// Wraps database, vector-store, LLM, and serialization errors into a single type
/// consumed by callers in `zeph-core`.
///
/// # Examples
///
/// ```rust
/// use zeph_memory::MemoryError;
///
/// fn demo(e: MemoryError) -> String {
/// e.to_string()
/// }
/// ```
#[derive(Debug, thiserror::Error)]
pub enum MemoryError {
#[error("database error: {0}")]
Sqlx(#[from] zeph_db::SqlxError),
#[error("database error: {0}")]
Db(#[from] zeph_db::DbError),
#[error("Qdrant error: {0}")]
Qdrant(#[from] Box<qdrant_client::QdrantError>),
#[error("vector store error: {0}")]
VectorStore(#[from] crate::vector_store::VectorStoreError),
#[error("LLM error: {0}")]
Llm(#[from] zeph_llm::LlmError),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("integer conversion: {0}")]
IntConversion(#[from] std::num::TryFromIntError),
#[error("snapshot error: {0}")]
Snapshot(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("graph store error: {0}")]
GraphStore(String),
#[error("invalid input: {0}")]
InvalidInput(String),
/// A mutex or `RwLock` was poisoned by a panicking thread.
///
/// This indicates a programming error (a thread panicked while holding the lock).
/// The inner string describes which lock was poisoned.
#[error("lock poisoned: {0}")]
LockPoisoned(String),
/// Catch-all for errors that do not yet have a specific typed variant.
///
/// # Deprecation
///
/// Prefer adding a typed variant over using `Other`. This variant exists for
/// backward compatibility and will be removed once all callsites are migrated.
#[error("{0}")]
Other(String),
#[error("operation timed out: {0}")]
Timeout(String),
/// Returned when inserting a supersede pointer would form a cycle in the chain.
#[error("supersede cycle detected at edge id={0}")]
SupersedeCycle(i64),
/// Returned when the supersede chain depth would exceed [`crate::graph::conflict::SUPERSEDE_DEPTH_CAP`].
#[error("supersede chain depth cap exceeded at edge id={0}")]
SupersedeDepthExceeded(i64),
/// A promotion-scan or promote error (Feature A, #3305).
///
/// Wraps errors from clustering, skill generation, evaluator calls, or disk writes.
#[error("promotion scan failed: {0}")]
Promotion(String),
}