cupel 1.2.0

Context window management pipeline for LLM applications
//! Error types for pipeline construction and execution.
//!
//! All errors are represented by the single [`CupelError`] enum. Variants cover
//! validation failures during model construction (e.g. empty content, invalid
//! budgets), scorer/slicer configuration issues, and runtime pipeline errors
//! (e.g. overflow, pinned items exceeding the budget).

/// Errors that can occur during Cupel pipeline construction and execution.
#[non_exhaustive]
#[derive(Debug, Clone, thiserror::Error)]
pub enum CupelError {
    #[error("content must be non-empty")]
    EmptyContent,

    #[error("kind must be a non-empty, non-whitespace-only string")]
    EmptyKind,

    #[error("source must be a non-empty, non-whitespace-only string")]
    EmptySource,

    #[error("invalid budget: {0}")]
    InvalidBudget(String),

    #[error("pinned tokens ({pinned_tokens}) exceed available budget ({available})")]
    PinnedExceedsBudget { pinned_tokens: i64, available: i64 },

    #[error("merged tokens ({merged_tokens}) exceed target tokens ({target_tokens})")]
    Overflow {
        merged_tokens: i64,
        target_tokens: i64,
    },

    #[error("invalid pipeline configuration: {0}")]
    PipelineConfig(String),

    #[error("invalid scorer configuration: {0}")]
    ScorerConfig(String),

    #[error("invalid slicer configuration: {0}")]
    SlicerConfig(String),

    /// Never emitted. Structural cycles are impossible with owned `Box<dyn Scorer>` children.
    /// Reserved for future use.
    #[error("cycle detected: scorer appears in its own dependency graph")]
    CycleDetected,

    #[error(
        "KnapsackSlice DP table exceeds the 50,000,000-cell limit: candidates={candidates}, capacity={capacity}, cells={cells}"
    )]
    TableTooLarge {
        candidates: usize,
        capacity: usize,
        cells: u64,
    },
}