Skip to main content

agentstategraph_taint/
error.rs

1//! Error enum for the taint substrate. Surfaced through the
2//! Repository methods (`taint` / `untaint` / `quarantine` / ...) and
3//! the pre-commit hook.
4
5use thiserror::Error;
6
7#[derive(Debug, Error, PartialEq)]
8pub enum TaintError {
9    /// Pre-commit hook rejected a write because the path carries a
10    /// `Block`-effect taint.
11    #[error("path {path} is blocked by taint {taint}: {reason}")]
12    Blocked {
13        path: String,
14        taint: String,
15        reason: String,
16    },
17
18    /// Pre-commit hook rejected a write because the path is
19    /// quarantined and the acting agent is not in the quarantine's
20    /// `authorized_agents` list.
21    #[error("path {path} is quarantined; agent {agent_id} is not authorized")]
22    NotAuthorized { path: String, agent_id: String },
23
24    /// Pre-commit hook rejected a write because the path carries a
25    /// `Review`-effect taint and the commit's `confidence` is below
26    /// the required threshold (default 0.9).
27    #[error("review taint {taint} on {path} requires confidence >= {required}; got {got}")]
28    InsufficientConfidence {
29        path: String,
30        taint: String,
31        required: f64,
32        got: f64,
33    },
34
35    /// A `taint` / `untaint` / `resolve_taint` call referred to an
36    /// id that does not exist.
37    #[error("taint {0} not found")]
38    NotFound(String),
39
40    /// Attempted to resolve a taint that is already resolved.
41    #[error("taint {0} is already resolved")]
42    AlreadyResolved(String),
43
44    /// Storage-backend error; the message is opaque to the taint
45    /// crate (the repository wrapper surfaces the real error).
46    #[error("storage: {0}")]
47    Storage(String),
48
49    /// A proposed taint failed basic validation (empty path, empty
50    /// name, unknown effect for the chosen kind, etc.).
51    #[error("invalid taint: {0}")]
52    InvalidTaint(String),
53}