1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Encoder abstraction for the ripvec static-table engine.
//!
//! [`VectorEncoder`] exposes the surviving ripvec engine behind one interface,
//! so downstream search code (CLI dispatch,
//! [`HybridIndex`](crate::hybrid::HybridIndex), cache layer) does not branch
//! on encoder internals.
//!
//! ## Implementation
//!
//! - [`StaticEncoder`](crate::encoder::ripvec::dense::StaticEncoder) —
//! static embedding-table lookup via the in-process Model2Vec engine.
//! Used for `--model ripvec`. CPU-only; no batching or ring buffer
//! (table-lookup encoder is memory-bound, not compute-bound).
//!
//! ## Design rationale
//!
//! `VectorEncoder` abstracts at the repo→(chunks, embeddings) boundary,
//! where the concrete pipeline shape does not leak through. Callers receive
//! a `(Vec<CodeChunk>, Vec<Vec<f32>>)` pair regardless of how the encoder
//! implements walk, chunk, and embed internally.
//!
//! @Parnas (1972) — the module hides which engine is active; the trait is
//! the stable interface boundary. @Postel (1980) — callers use the same
//! `VectorEncoder` surface; no change at the call site after the transformer
//! path was removed.
//!
//! See `docs/PLAN.md` cluster B6 for the surgery context.
use Path;
use crateCodeChunk;
use crateSearchConfig;
use crateProfiler;
/// Trait that abstracts text/chunks → embedding vectors.
///
/// The implementation owns its full pipeline (walk, chunk, encode).
///
/// # Object safety
///
/// `dyn VectorEncoder` is constructible. Methods take `&self` and use only
/// concrete return types — no associated types or generic methods.
///
/// # Thread safety
///
/// `Send + Sync` is required because the encoder is shared across the
/// indexing pipeline's rayon and channel-based workers.