Skip to main content

weavatrix_semantic/linker/
mod.rs

1mod edge;
2mod execute;
3pub(crate) mod math;
4mod report;
5
6use crate::LinkConfig;
7use weavatrix_graph::{Edge, EdgeKind};
8
9/// Custom graph edge kind emitted by this crate.
10pub const SEMANTIC_EDGE_KIND: &str = "semantic_similarity";
11
12/// Stable provenance extractor identity used for idempotent relinking.
13pub const SEMANTIC_EXTRACTOR: &str = "weavatrix-semantic";
14
15/// Strategy used to generate candidate neighborhoods before semantic policy.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum CandidateBackend {
18    /// Exhaustive all-pairs cosine comparisons.
19    Exact,
20    /// First-party `weavatrix-search-vector` HNSW candidates.
21    WeavatrixVector,
22}
23
24#[derive(Debug, Clone, Copy, PartialEq)]
25pub(crate) struct Candidate {
26    pub(crate) target: usize,
27    pub(crate) score: f64,
28}
29
30/// Summary of one semantic-linking run.
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct SemanticLinkReport {
33    vector_count: usize,
34    dimension: usize,
35    comparisons: u64,
36    pair_count: usize,
37    candidate_backend: CandidateBackend,
38    policy_id: String,
39    edges: Vec<Edge>,
40}
41
42/// Exact cosine top-K semantic linker for existing graph nodes.
43#[derive(Debug, Clone)]
44pub struct SemanticLinker {
45    config: LinkConfig,
46    edge_kind: EdgeKind,
47}