Skip to main content

weavatrix_semantic/error/
mod.rs

1mod display;
2use weavatrix_graph::GraphError;
3
4/// Result type returned by semantic-linking operations.
5pub type Result<T> = std::result::Result<T, SemanticError>;
6
7/// Validation and graph-integration failures.
8#[derive(Debug)]
9#[non_exhaustive]
10pub enum SemanticError {
11    /// The model identifier is empty.
12    EmptyModel,
13    /// The model identifier has leading or trailing whitespace.
14    ModelHasSurroundingWhitespace,
15    /// The cosine threshold is non-finite or outside `[0, 1]`.
16    InvalidSimilarityThreshold,
17    /// Top-K must be positive.
18    ZeroTopK,
19    /// The configured vector limit must be positive.
20    ZeroMaxVectors,
21    /// A vector has no dimensions.
22    EmptyVector { node: String },
23    /// A vector contains NaN or infinity.
24    NonFiniteVectorValue { node: String, index: usize },
25    /// A vector has no direction and cannot be compared with cosine similarity.
26    ZeroVector { node: String },
27    /// More vectors were supplied than the caller-configured safety bound.
28    TooManyVectors { count: usize, maximum: usize },
29    /// Two vectors target the same graph node.
30    DuplicateNode { node: String },
31    /// A vector targets a node absent from the input graph.
32    MissingGraphNode { node: String },
33    /// Vectors from the same model have inconsistent dimensions.
34    DimensionMismatch {
35        node: String,
36        expected: usize,
37        actual: usize,
38    },
39    /// A platform-sized counter could not be represented in graph metadata.
40    NumericOverflow,
41    /// Semantic candidate or report storage could not be reserved.
42    AllocationFailed,
43    /// The vector candidate-pool multiplier must be positive.
44    ZeroCandidatePoolMultiplier,
45    /// A candidate engine returned a key outside the current semantic input.
46    CandidateKeyOutOfRange { key: u64, vector_count: usize },
47    /// An SEO site identifier is empty.
48    EmptySeoSite { node: String },
49    /// An SEO site identifier has leading or trailing whitespace.
50    SeoSiteHasSurroundingWhitespace { node: String },
51    /// An SEO canonical identifier is empty.
52    EmptySeoCanonical { node: String },
53    /// An SEO canonical identifier has leading or trailing whitespace.
54    SeoCanonicalHasSurroundingWhitespace { node: String },
55    /// An SEO language identifier is empty.
56    EmptySeoLanguage { node: String },
57    /// An SEO language identifier has leading or trailing whitespace.
58    SeoLanguageHasSurroundingWhitespace { node: String },
59    /// More than one SEO profile targets the same graph node.
60    DuplicateSeoProfile { node: String },
61    /// A semantic vector has no corresponding SEO profile.
62    MissingSeoProfile { node: String },
63    /// An SEO profile targets a node absent from the graph.
64    SeoProfileMissingGraphNode { node: String },
65    /// The anchor matcher model identifier is empty.
66    EmptyAnchorModel,
67    /// The anchor matcher model identifier has surrounding whitespace.
68    AnchorModelHasSurroundingWhitespace,
69    /// The anchor similarity threshold is non-finite or outside `[0, 1]`.
70    InvalidAnchorSimilarityThreshold,
71    /// At least one anchor suggestion per link must be requested.
72    ZeroAnchorSuggestions,
73    /// A candidate anchor locator is empty.
74    EmptyAnchorLocator { source: String },
75    /// Candidate anchor text is empty.
76    EmptyAnchorText { source: String, locator: String },
77    /// Candidate anchor context is empty.
78    EmptyAnchorContext { source: String, locator: String },
79    /// Candidate anchor text is not present in its supplied source context.
80    AnchorTextOutsideContext { source: String, locator: String },
81    /// Candidate anchor text metadata has surrounding whitespace.
82    AnchorTextHasSurroundingWhitespace {
83        source: String,
84        locator: String,
85        field: &'static str,
86    },
87    /// More than one candidate uses the same source and locator.
88    DuplicateAnchorCandidate { source: String, locator: String },
89    /// A semantic link target has no page vector for anchor matching.
90    MissingAnchorTargetVector { target: String },
91    /// A candidate anchor vector does not match the target-vector dimension.
92    AnchorDimensionMismatch {
93        source: String,
94        locator: String,
95        expected: usize,
96        actual: usize,
97    },
98    /// A semantic edge was produced by another embedding model.
99    AnchorModelMismatch { expected: String, actual: String },
100    /// A semantic edge is missing an attribute required for anchor matching.
101    MissingSemanticEdgeAttribute { attribute: &'static str },
102    /// The first-party vector candidate engine rejected a build or query.
103    #[cfg(feature = "vector-search")]
104    VectorSearch(weavatrix_search_vector::SearchError),
105    /// The underlying graph rejected a kind, identifier, provenance, or edge.
106    Graph(GraphError),
107}