Skip to main content

codelens_engine/
embedding_store.rs

1//! Data types for vector embedding storage.
2//!
3//! The `EmbeddingStore` trait was removed in v1.12 — `SqliteVecStore` is the
4//! single implementation, used directly inside `embedding/mod.rs`. Only the
5//! plain data structs remain here so callers can still construct chunks and
6//! consume search results.
7
8use serde::Serialize;
9
10/// A single embedding chunk ready for storage.
11#[derive(Debug, Clone)]
12pub struct EmbeddingChunk {
13    pub file_path: String,
14    pub symbol_name: String,
15    pub kind: String,
16    pub line: usize,
17    pub signature: String,
18    pub name_path: String,
19    pub text: String,
20    /// Primary embedding: code signature + identifier split
21    pub embedding: Vec<f32>,
22    /// Optional secondary embedding: docstring/comment (for dual-vector search)
23    pub doc_embedding: Option<Vec<f32>>,
24}
25
26/// Result of a vector similarity search.
27#[derive(Debug, Clone, Serialize)]
28pub struct ScoredChunk {
29    pub file_path: String,
30    pub symbol_name: String,
31    pub kind: String,
32    pub line: usize,
33    pub signature: String,
34    pub name_path: String,
35    pub score: f64,
36}
37
38// ── Artifact memory embeddings ──────────────────────────────────────────
39
40/// A single artifact analysis summary ready for semantic storage.
41#[derive(Debug, Clone)]
42pub struct ArtifactEmbeddingChunk {
43    pub analysis_id: String,
44    pub tool_name: String,
45    pub surface: String,
46    pub project_scope: Option<String>,
47    pub summary: String,
48    pub top_findings: Vec<String>,
49    pub risk_level: String,
50    pub embedding: Vec<f32>,
51}
52
53/// Result of a semantic artifact search.
54#[derive(Debug, Clone, Serialize)]
55pub struct ScoredArtifactChunk {
56    pub analysis_id: String,
57    pub tool_name: String,
58    pub surface: String,
59    pub project_scope: Option<String>,
60    pub summary: String,
61    pub score: f64,
62}