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
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Core library client for brainwires-rag
//!
//! This module provides the main client interface for using brainwires-rag
//! as a library in your own Rust applications.
//!
//! # Structure
//!
//! The implementation is split across focused submodules:
//!
//! - [`constructor`] — constructors, basic utilities, path helpers
//! - [`locking`] — two-layer index locking (filesystem + in-process broadcast)
//! - [`search`] — indexing dispatch, semantic search, filtered search, statistics, clear, git history
//! - [`ensemble`] — multi-strategy ensemble query with Reciprocal Rank Fusion
//! - [`reranking`] — pluggable diversity/relevance reranking (`spectral-select` feature)
//! - `code_analysis` — find definition, find references, call graph (`code-analysis` feature)
use crateHybridRelationsProvider;
use crateHashCache;
use crateConfig;
use crateFastEmbedManager;
use crateGitCache;
use crateCodeChunker;
use VectorDatabase;
use HashMap;
use PathBuf;
use Arc;
use RwLock;
// Filesystem locking for cross-process coordination
pub use FsLockGuard;
// Index locking mechanism (uses fs_lock for cross-process, broadcast for in-process)
pub use ;
// ── impl blocks, split by concern ────────────────────────────────────────────
/// Constructor methods and utility helpers.
/// Two-layer index locking.
/// Indexing dispatch, search, statistics, clear, and git-history search.
/// Multi-strategy ensemble query with RRF fusion.
/// Pluggable diversity/relevance reranking (requires `spectral-select`).
/// Code-navigation: find definition, find references, call graph (requires `code-analysis`).
// ── existing public submodules ────────────────────────────────────────────────
/// Indexing operations (public for MCP server binary).
// Git indexing operations module
pub
// ── Re-exports (keeps all existing call sites working) ────────────────────────
// All public types from `types` are already glob-imported above via `use crate::rag::types::*`.
// The public API surface of RagClient itself is fully re-exported through the struct below.
/// Main client for interacting with the RAG system
///
/// This client provides a high-level API for indexing codebases and performing
/// semantic searches. It contains all the core functionality and can be used
/// directly as a library or wrapped by the MCP server.
///
/// # Example
///
/// ```ignore
/// use crate::rag::{RagClient, IndexRequest, QueryRequest};
///
/// #[tokio::main]
/// async fn main() -> anyhow::Result<()> {
/// // Create client with default configuration
/// let client = RagClient::new().await?;
///
/// // Index a codebase
/// let index_req = IndexRequest {
/// path: "/path/to/code".to_string(),
/// project: Some("my-project".to_string()),
/// include_patterns: vec!["**/*.rs".to_string()],
/// exclude_patterns: vec!["**/target/**".to_string()],
/// max_file_size: 1_048_576,
/// };
/// let response = client.index_codebase(index_req).await?;
/// println!("Indexed {} files", response.files_indexed);
///
/// Ok(())
/// }
/// ```