dci-tool 0.1.0

Direct Corpus Interaction: a sandboxed, ripgrep-backed corpus-search toolset and agent for cyber-focused LLM agents, built on rig.
Documentation
//! Error types for the Direct Corpus Interaction (DCI) toolset.

use std::path::PathBuf;

/// Errors produced by corpus-interaction operations.
///
/// These are surfaced to the agent as tool-call errors, so their `Display`
/// text is written to be intelligible to a language model deciding what to do
/// next (e.g. "path escapes the corpus root" tells it to pick a path inside the
/// corpus).
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum DciError {
    /// The corpus root could not be established (missing, not a directory, or
    /// not canonicalizable).
    #[error("invalid corpus root {path:?}: {reason}")]
    InvalidRoot {
        /// The offending path.
        path: PathBuf,
        /// Human-readable reason.
        reason: String,
    },

    /// A requested path resolved outside the corpus root (path traversal or a
    /// symlink escaping the jail).
    #[error("path {requested:?} escapes the corpus root and was denied")]
    PathEscape {
        /// The path the caller asked for.
        requested: String,
    },

    /// A requested path does not exist inside the corpus.
    #[error("path {requested:?} was not found in the corpus")]
    NotFound {
        /// The path the caller asked for.
        requested: String,
    },

    /// The caller supplied an invalid regular expression.
    #[error("invalid search pattern: {0}")]
    InvalidPattern(String),

    /// The caller supplied an invalid glob.
    #[error("invalid glob {glob:?}: {reason}")]
    InvalidGlob {
        /// The offending glob.
        glob: String,
        /// Why it failed to compile.
        reason: String,
    },

    /// An operation exceeded its time budget.
    #[error("operation timed out after {millis} ms")]
    Timeout {
        /// The configured budget in milliseconds.
        millis: u64,
    },

    /// An underlying I/O failure.
    #[error("i/o error on {path:?}: {source}")]
    Io {
        /// The path being operated on, if known.
        path: PathBuf,
        /// The underlying error.
        #[source]
        source: std::io::Error,
    },

    /// A background worker task failed to complete (runtime/cancellation).
    #[error("corpus worker task failed: {0}")]
    Worker(String),
}

/// Convenience alias for results in this crate.
pub type Result<T> = std::result::Result<T, DciError>;