zeph_session/error.rs
1// SPDX-FileCopyrightText: 2026 Andrei G <bug-ops>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Crate-wide error type for `zeph-session`.
5
6use thiserror::Error;
7
8/// Errors produced by the session persistence, replay, and fork engines.
9#[derive(Debug, Error)]
10pub enum SessionError {
11 /// Filesystem I/O failed while reading or appending to an event log.
12 #[error("session event log I/O error: {0}")]
13 Io(#[from] std::io::Error),
14
15 /// A `SessionEvent` line failed to (de)serialize.
16 #[error("session event (de)serialization error: {0}")]
17 Serde(#[from] serde_json::Error),
18
19 /// The `acp_sessions` metadata store returned a database error.
20 #[error("session store database error: {0}")]
21 Db(#[from] zeph_db::SqlxError),
22
23 /// A lookup by [`zeph_common::SessionId`] found no matching session.
24 #[error("session not found: {0}")]
25 NotFound(String),
26
27 /// A fork was requested at a `seq` beyond the source session's `last_seq`.
28 #[error("invalid fork point: {0}")]
29 InvalidForkPoint(String),
30
31 /// A condensation or compaction range overlapped a previously replaced range (INV-SP-4).
32 #[error("condensation range overlap: {0}")]
33 CondensationOverlap(String),
34
35 /// Condensation summarization failed (LLM call error or timeout).
36 #[error("condensation summarization failed: {0}")]
37 Llm(#[from] zeph_llm::LlmError),
38
39 /// [`crate::log::SessionEventLog::open_exclusive`] found another process already
40 /// holding the session's advisory write lock.
41 #[error("session event log at {0} is already locked by another process")]
42 AlreadyLocked(String),
43
44 /// A `UserMessage.image_refs` entry was not a bare hex string, so it was rejected before
45 /// being joined into a filesystem path (#5982 follow-up, path-traversal guard).
46 #[error("invalid blob hash (must be a non-empty hex string): {0:?}")]
47 InvalidBlobHash(String),
48}