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
// Copyright (c) 2026 Kirky.X. All rights reserved.
// SPDX-License-Identifier: MIT
//! Optional vector embedding subsystem (Strategy pattern).
//!
//! Gated behind the `embed` feature (ADR-004). Provides two embedding backends:
//!
//! - **Remote HTTP** ([`OpenAIEmbedClient`]): calls an OpenAI-compatible
//! embedding API via `reqwest`. API keys are read from environment variables
//! and never persisted (TRD §6.1).
//! - **Local ONNX** ([`LocalEmbedClient`], H10/D7): runs `arctic-embed-xs`
//! inference locally via `ort` (ONNX Runtime). Works fully offline — no API
//! key, no network access required. The model file must be present on disk.
//!
//! Backend selection is driven by [`EmbeddingConfig::endpoint`]:
//! `Some(url)` → remote HTTP, `None` → local ONNX. The default is local
//! (offline), so `--embed` works out of the box without any API key.
//!
//! # Architecture
//!
//! - [`client`]: [`EmbedClient`] trait + [`OpenAIEmbedClient`] (reqwest HTTP)
//! + [`LocalEmbedClient`] (ort ONNX) + [`MockEmbedClient`] (test).
//! - [`storage`]: [`EmbeddingStorage`] stores/retrieves `FLOAT[384]` vectors in
//! the LadybugDB `Embedding` table (DDD §5.9).
//! - [`search`]: [`SearchStrategy`] trait with [`Bm25Strategy`],
//! [`SemanticStrategy`], and [`HybridStrategy`] (RRF fusion, AC-SEARCH-002).
//!
//! # Degradation
//!
//! On Windows the LadybugDB VECTOR extension is unavailable (R-003/TR-005);
//! [`search::is_vector_supported`] returns `false` and the search strategy
//! degrades to BM25-only. If the embedding service is unreachable (remote
//! mode) or the model file is missing (local mode), indexing continues
//! without embeddings (SubTask 16.4).
//!
//! # trait-kit integration (Task 2.12)
//!
//! When the `embed` feature is enabled, [`client::EmbedClient`] is the
//! capability trait stored in [`Kit`](crate::kit::Kit) under
//! [`EmbedKey`](crate::kit::EmbedKey). The concrete impl
//! ([`module::EmbedCapability`]) lazily loads the local model or creates a
//! fresh HTTP client per call, depending on [`EmbeddingConfig::endpoint`].
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Expected embedding dimension (DDD §5.9: `FLOAT[384]`).
pub const EMBEDDING_DIM: usize = 384;
/// Test-only lock to serialize environment-variable manipulation across
/// `client::tests` and `config::tests` (prevents `std::env::set_var` races).
pub static ENV_TEST_LOCK: Mutex = new;