Skip to main content

nodedb_vector/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Vector engine error types.
4
5use nodedb_mem::MemError;
6
7/// Errors from vector index operations.
8#[derive(Debug, thiserror::Error)]
9#[non_exhaustive]
10pub enum VectorError {
11    #[error("memory budget exhausted: {0}")]
12    BudgetExhausted(#[from] MemError),
13    #[error("vector dimension mismatch: expected {expected}, got {got}")]
14    DimensionMismatch { expected: usize, got: usize },
15    #[error("unsupported HNSW checkpoint version {found}; expected {expected}")]
16    UnsupportedVersion { found: u8, expected: u8 },
17    #[error("invalid PQ codec magic bytes")]
18    InvalidMagic,
19    #[error("PQ codec deserialization failed: {0}")]
20    DeserializationFailed(String),
21    /// Checkpoint file is encrypted (starts with `SEGV`) but no KEK was supplied.
22    #[error(
23        "vector checkpoint is encrypted but no encryption key was provided; \
24         cannot load plaintext from an encrypted checkpoint"
25    )]
26    CheckpointEncryptedNoKey,
27    /// Checkpoint file is plaintext but a KEK was configured (policy violation).
28    #[error(
29        "vector checkpoint is plaintext but an encryption key is configured; \
30         refusing to load an unencrypted checkpoint when encryption is required"
31    )]
32    CheckpointPlaintextKeyRequired,
33    /// AES-256-GCM encryption/decryption or envelope framing of a checkpoint failed.
34    #[error("vector checkpoint encryption error: {detail}")]
35    CheckpointEncryptionError { detail: String },
36    /// I/O error from segment file operations (open, mmap, metadata).
37    #[error("vector segment I/O error: {0}")]
38    SegmentIo(#[from] std::io::Error),
39}