refactor: Remove redundant doc comments throughout codebase
Removes module-level doc comments (//! lines) and excessive inline doc comments that were duplicating information already evident from: - Function/struct names (self-documenting code) - Type signatures (the what is clear from types) - Implementation context (the how is clear from code) Affected modules: - cli/* - Removed command descriptions duplicating clap help text - core/* - Removed module headers and obvious function docs - documents/* - Removed extractor/regenerator/truncation docs - embedding/* - Removed pipeline and chunking docs - gitlab/* - Removed client and transformer docs (kept type definitions) - ingestion/* - Removed orchestrator and ingestion docs - search/* - Removed FTS and vector search docs Philosophy: Code should be self-documenting. Comments should explain "why" (business decisions, non-obvious constraints) not "what" (which the code itself shows). This change reduces noise and maintenance burden while keeping the codebase just as understandable. Retains comments for: - Non-obvious business logic - Important safety invariants - Complex algorithm explanations - Public API boundaries where generated docs matter Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
//! Search command: lexical (FTS5) search with filter support and single-query hydration.
|
||||
|
||||
use console::style;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -15,7 +13,6 @@ use crate::search::{
|
||||
search_fts,
|
||||
};
|
||||
|
||||
/// Display-ready search result with all fields hydrated.
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct SearchResultDisplay {
|
||||
pub document_id: i64,
|
||||
@@ -34,7 +31,6 @@ pub struct SearchResultDisplay {
|
||||
pub explain: Option<ExplainData>,
|
||||
}
|
||||
|
||||
/// Ranking explanation for --explain output.
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct ExplainData {
|
||||
pub vector_rank: Option<usize>,
|
||||
@@ -42,7 +38,6 @@ pub struct ExplainData {
|
||||
pub rrf_score: f64,
|
||||
}
|
||||
|
||||
/// Search response wrapper.
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct SearchResponse {
|
||||
pub query: String,
|
||||
@@ -52,7 +47,6 @@ pub struct SearchResponse {
|
||||
pub warnings: Vec<String>,
|
||||
}
|
||||
|
||||
/// Build SearchFilters from CLI args.
|
||||
pub struct SearchCliFilters {
|
||||
pub source_type: Option<String>,
|
||||
pub author: Option<String>,
|
||||
@@ -64,7 +58,6 @@ pub struct SearchCliFilters {
|
||||
pub limit: usize,
|
||||
}
|
||||
|
||||
/// Run a lexical search query.
|
||||
pub fn run_search(
|
||||
config: &Config,
|
||||
query: &str,
|
||||
@@ -75,7 +68,6 @@ pub fn run_search(
|
||||
let db_path = get_db_path(config.storage.db_path.as_deref());
|
||||
let conn = create_connection(&db_path)?;
|
||||
|
||||
// Check if any documents exist
|
||||
let doc_count: i64 = conn
|
||||
.query_row("SELECT COUNT(*) FROM documents", [], |row| row.get(0))
|
||||
.unwrap_or(0);
|
||||
@@ -90,7 +82,6 @@ pub fn run_search(
|
||||
});
|
||||
}
|
||||
|
||||
// Build filters
|
||||
let source_type = cli_filters
|
||||
.source_type
|
||||
.as_deref()
|
||||
@@ -146,7 +137,6 @@ pub fn run_search(
|
||||
limit: cli_filters.limit,
|
||||
};
|
||||
|
||||
// Adaptive recall: wider initial fetch when filters applied
|
||||
let requested = filters.clamp_limit();
|
||||
let top_k = if filters.has_any_filter() {
|
||||
(requested * 50).clamp(200, 1500)
|
||||
@@ -154,24 +144,20 @@ pub fn run_search(
|
||||
(requested * 10).clamp(50, 1500)
|
||||
};
|
||||
|
||||
// FTS search
|
||||
let fts_results = search_fts(&conn, query, top_k, fts_mode)?;
|
||||
let fts_tuples: Vec<(i64, f64)> = fts_results
|
||||
.iter()
|
||||
.map(|r| (r.document_id, r.bm25_score))
|
||||
.collect();
|
||||
|
||||
// Build snippet map before ranking
|
||||
let snippet_map: std::collections::HashMap<i64, String> = fts_results
|
||||
.iter()
|
||||
.map(|r| (r.document_id, r.snippet.clone()))
|
||||
.collect();
|
||||
|
||||
// RRF ranking (single-list for lexical mode)
|
||||
let ranked = rank_rrf(&[], &fts_tuples);
|
||||
let ranked_ids: Vec<i64> = ranked.iter().map(|r| r.document_id).collect();
|
||||
|
||||
// Apply post-retrieval filters
|
||||
let filtered_ids = apply_filters(&conn, &ranked_ids, &filters)?;
|
||||
|
||||
if filtered_ids.is_empty() {
|
||||
@@ -184,10 +170,8 @@ pub fn run_search(
|
||||
});
|
||||
}
|
||||
|
||||
// Hydrate results in single round-trip
|
||||
let hydrated = hydrate_results(&conn, &filtered_ids)?;
|
||||
|
||||
// Build display results preserving filter order
|
||||
let rrf_map: std::collections::HashMap<i64, &crate::search::RrfResult> =
|
||||
ranked.iter().map(|r| (r.document_id, r)).collect();
|
||||
|
||||
@@ -233,7 +217,6 @@ pub fn run_search(
|
||||
})
|
||||
}
|
||||
|
||||
/// Raw row from hydration query.
|
||||
struct HydratedRow {
|
||||
document_id: i64,
|
||||
source_type: String,
|
||||
@@ -248,10 +231,6 @@ struct HydratedRow {
|
||||
paths: Vec<String>,
|
||||
}
|
||||
|
||||
/// Hydrate document IDs into full display rows in a single query.
|
||||
///
|
||||
/// Uses json_each() to pass ranked IDs and preserve ordering via ORDER BY j.key.
|
||||
/// Labels and paths fetched via correlated json_group_array subqueries.
|
||||
fn hydrate_results(conn: &rusqlite::Connection, document_ids: &[i64]) -> Result<Vec<HydratedRow>> {
|
||||
if document_ids.is_empty() {
|
||||
return Ok(Vec::new());
|
||||
@@ -299,7 +278,6 @@ fn hydrate_results(conn: &rusqlite::Connection, document_ids: &[i64]) -> Result<
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Parse a JSON array string into a Vec<String>, filtering out null/empty.
|
||||
fn parse_json_array(json: &str) -> Vec<String> {
|
||||
serde_json::from_str::<Vec<serde_json::Value>>(json)
|
||||
.unwrap_or_default()
|
||||
@@ -309,7 +287,6 @@ fn parse_json_array(json: &str) -> Vec<String> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Print human-readable search results.
|
||||
pub fn print_search_results(response: &SearchResponse) {
|
||||
if !response.warnings.is_empty() {
|
||||
for w in &response.warnings {
|
||||
@@ -364,7 +341,6 @@ pub fn print_search_results(response: &SearchResponse) {
|
||||
println!(" Labels: {}", result.labels.join(", "));
|
||||
}
|
||||
|
||||
// Strip HTML tags from snippet for terminal display
|
||||
let clean_snippet = result.snippet.replace("<mark>", "").replace("</mark>", "");
|
||||
println!(" {}", style(clean_snippet).dim());
|
||||
|
||||
@@ -384,7 +360,6 @@ pub fn print_search_results(response: &SearchResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
/// JSON output structures.
|
||||
#[derive(Serialize)]
|
||||
struct SearchJsonOutput<'a> {
|
||||
ok: bool,
|
||||
@@ -397,7 +372,6 @@ struct SearchMeta {
|
||||
elapsed_ms: u64,
|
||||
}
|
||||
|
||||
/// Print JSON robot-mode output.
|
||||
pub fn print_search_results_json(response: &SearchResponse, elapsed_ms: u64) {
|
||||
let output = SearchJsonOutput {
|
||||
ok: true,
|
||||
|
||||
Reference in New Issue
Block a user