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
111
//! Read-time query embedder trait and identity types.
//!
//! Phase 12.5a defines the always-on scaffolding that Phase 12.5b (the
//! Candle + bge-small-en-v1.5 default implementation) plugs into behind the
//! `default-embedder` feature flag. The trait lives in `fathomdb-engine`
//! rather than `fathomdb-query` so that `fathomdb-query` stays a pure
//! AST-to-plan compiler with no dyn trait objects or runtime state.
//!
//! The coordinator owns an `Option<Arc<dyn QueryEmbedder>>`. When present,
//! `ExecutionCoordinator::fill_vector_branch` invokes `embed_query` on the
//! raw natural-language query, serializes the returned `Vec<f32>` via
//! `serde_json` into the JSON float-array literal that
//! `CompiledVectorSearch::query_text` already expects, and drops a fully
//! constructed `CompiledVectorSearch` into `plan.vector`. When absent, the
//! plan's vector slot stays `None` and the Phase 12 v1 dormancy invariant
//! on `search()` is preserved unchanged.
use Error;
pub use BuiltinBgeSmallEmbedder;
/// A read-time query embedder.
///
/// Implementations must be `Send + Sync` so the coordinator can share a
/// single `Arc<dyn QueryEmbedder>` across reader threads without cloning
/// per call. All methods are `&self` — embedders are expected to be
/// internally immutable or to manage their own interior mutability.
/// Identity metadata for a [`QueryEmbedder`].
/// Errors reported by a [`QueryEmbedder`].
///
/// Both variants are treated as capability misses by the coordinator:
/// `plan.was_degraded_at_plan_time` is set and the vector branch is
/// skipped, but the rest of the search pipeline proceeds normally.
/// A write-time batch embedder used by `regenerate_vector_embeddings_in_process`.
///
/// Unlike [`QueryEmbedder`] (which operates one query at a time for read-time
/// vector search), `BatchEmbedder` accepts a slice of texts and returns a
/// vector per input. This is more efficient for write-time regeneration
/// where all chunk texts can be processed together.