1use super::AgentState;
2
3pub type HostResult<T> = Result<T, HostError>;
4
5#[derive(Debug, thiserror::Error, PartialEq, Eq)]
7pub enum HostError {
8 #[error("invalid host input: {0}")]
9 InvalidInput(&'static str),
10 #[error("invalid Agent transition {from:?} -> {to:?}")]
11 InvalidTransition { from: AgentState, to: AgentState },
12 #[error("mini Agent cannot be restored after losing its memory state")]
13 MiniStateLost,
14 #[error("resident Agent limit {limit} reached")]
15 AtCapacity { limit: usize },
16 #[error("Agent already owns a resident slot")]
17 AlreadyResident,
18 #[error("host capacity state is poisoned")]
19 Poisoned,
20}
21
22pub type CatalogResult<T> = Result<T, CatalogError>;
23
24#[derive(Debug, thiserror::Error)]
25pub enum CatalogError {
26 #[error(transparent)]
27 Policy(#[from] HostError),
28 #[error("host registry is already owned by another instance")]
29 AlreadyRunning,
30 #[error("host registry path must be private, owned by this user, and not a symlink")]
31 UnsafePath,
32 #[error("host catalog is not supported on this platform yet")]
33 UnsupportedPlatform,
34 #[error("unsupported host registry schema version {0}")]
35 UnsupportedVersion(i64),
36 #[error("invalid stored host record: {0}")]
37 InvalidRecord(&'static str),
38 #[error("Agent is already registered")]
39 AlreadyRegistered,
40 #[error("Session reference is already registered to another Agent")]
41 SessionAlreadyRegistered,
42 #[error("unknown Agent")]
43 UnknownAgent,
44 #[error("Agent revision changed (expected {expected}, actual {actual})")]
45 RevisionConflict { expected: u64, actual: u64 },
46 #[error("Host epoch changed")]
47 EpochConflict,
48 #[error("lifecycle request identity conflicts with the stored request or result")]
49 LifecycleConflict,
50 #[error("lifecycle journal capacity exhausted; no intent was accepted")]
51 LifecycleCapacity,
52 #[error("another lifecycle intent conflicts with this action; no new intent was accepted")]
53 LifecycleBusy,
54 #[error("unknown lifecycle request")]
55 UnknownLifecycle,
56 #[error("lifecycle journal synchronization is uncertain; inspect before retrying")]
57 LifecycleUncertain,
58 #[error("host catalog worker stopped; inspect state before retrying an uncertain mutation")]
59 WorkerStopped,
60 #[error("host registry I/O failed")]
61 Io(#[from] std::io::Error),
62 #[error("host registry database operation failed")]
63 Database(#[from] rusqlite::Error),
64 #[error("host registry encoding is invalid")]
65 Encoding(#[from] serde_json::Error),
66}