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:
Taylor Eernisse
2026-02-05 00:04:32 -05:00
parent 976ad92ef0
commit 65583ed5d6
57 changed files with 143 additions and 1693 deletions

View File

@@ -1,7 +1,3 @@
//! Database connection and migration management.
//!
//! Uses rusqlite with WAL mode for crash safety.
use rusqlite::Connection;
use sqlite_vec::sqlite3_vec_init;
use std::fs;
@@ -10,11 +6,8 @@ use tracing::{debug, info};
use super::error::{LoreError, Result};
/// Latest schema version, derived from the embedded migrations count.
/// Used by the health check to verify databases are up-to-date.
pub const LATEST_SCHEMA_VERSION: i32 = MIGRATIONS.len() as i32;
/// Embedded migrations - compiled into the binary.
const MIGRATIONS: &[(&str, &str)] = &[
("001", include_str!("../../migrations/001_initial.sql")),
("002", include_str!("../../migrations/002_issues.sql")),
@@ -53,9 +46,7 @@ const MIGRATIONS: &[(&str, &str)] = &[
),
];
/// Create a database connection with production-grade pragmas.
pub fn create_connection(db_path: &Path) -> Result<Connection> {
// Register sqlite-vec extension globally (safe to call multiple times)
#[allow(clippy::missing_transmute_annotations)]
unsafe {
rusqlite::ffi::sqlite3_auto_extension(Some(std::mem::transmute(
@@ -63,30 +54,26 @@ pub fn create_connection(db_path: &Path) -> Result<Connection> {
)));
}
// Ensure parent directory exists
if let Some(parent) = db_path.parent() {
fs::create_dir_all(parent)?;
}
let conn = Connection::open(db_path)?;
// Production-grade pragmas for single-user CLI
conn.pragma_update(None, "journal_mode", "WAL")?;
conn.pragma_update(None, "synchronous", "NORMAL")?; // Safe for WAL on local disk
conn.pragma_update(None, "synchronous", "NORMAL")?;
conn.pragma_update(None, "foreign_keys", "ON")?;
conn.pragma_update(None, "busy_timeout", 5000)?; // 5s wait on lock contention
conn.pragma_update(None, "temp_store", "MEMORY")?; // Small speed win
conn.pragma_update(None, "cache_size", -64000)?; // 64MB cache (negative = KB)
conn.pragma_update(None, "mmap_size", 268_435_456)?; // 256MB memory-mapped I/O
conn.pragma_update(None, "busy_timeout", 5000)?;
conn.pragma_update(None, "temp_store", "MEMORY")?;
conn.pragma_update(None, "cache_size", -64000)?;
conn.pragma_update(None, "mmap_size", 268_435_456)?;
debug!(db_path = %db_path.display(), "Database connection created");
Ok(conn)
}
/// Run all pending migrations using embedded SQL.
pub fn run_migrations(conn: &Connection) -> Result<()> {
// Get current schema version
let has_version_table: bool = conn
.query_row(
"SELECT COUNT(*) > 0 FROM sqlite_master WHERE type='table' AND name='schema_version'",
@@ -114,9 +101,6 @@ pub fn run_migrations(conn: &Connection) -> Result<()> {
continue;
}
// Wrap each migration in a transaction to prevent partial application.
// If the migration SQL already contains BEGIN/COMMIT, execute_batch handles
// it, but wrapping in a savepoint ensures atomicity for those that don't.
let savepoint_name = format!("migration_{}", version);
conn.execute_batch(&format!("SAVEPOINT {}", savepoint_name))
.map_err(|e| LoreError::MigrationFailed {
@@ -150,7 +134,6 @@ pub fn run_migrations(conn: &Connection) -> Result<()> {
Ok(())
}
/// Run migrations from filesystem (for testing or custom migrations).
#[allow(dead_code)]
pub fn run_migrations_from_dir(conn: &Connection, migrations_dir: &Path) -> Result<()> {
let has_version_table: bool = conn
@@ -194,8 +177,6 @@ pub fn run_migrations_from_dir(conn: &Connection, migrations_dir: &Path) -> Resu
let sql = fs::read_to_string(entry.path())?;
// Wrap each migration in a savepoint to prevent partial application,
// matching the safety guarantees of run_migrations().
let savepoint_name = format!("migration_{}", version);
conn.execute_batch(&format!("SAVEPOINT {}", savepoint_name))
.map_err(|e| LoreError::MigrationFailed {
@@ -229,8 +210,6 @@ pub fn run_migrations_from_dir(conn: &Connection, migrations_dir: &Path) -> Resu
Ok(())
}
/// Verify database pragmas are set correctly.
/// Used by lore doctor command.
pub fn verify_pragmas(conn: &Connection) -> (bool, Vec<String>) {
let mut issues = Vec::new();
@@ -258,7 +237,6 @@ pub fn verify_pragmas(conn: &Connection) -> (bool, Vec<String>) {
let synchronous: i32 = conn
.pragma_query_value(None, "synchronous", |row| row.get(0))
.unwrap_or(0);
// NORMAL = 1
if synchronous != 1 {
issues.push(format!("synchronous is {synchronous}, expected 1 (NORMAL)"));
}
@@ -266,7 +244,6 @@ pub fn verify_pragmas(conn: &Connection) -> (bool, Vec<String>) {
(issues.is_empty(), issues)
}
/// Get current schema version.
pub fn get_schema_version(conn: &Connection) -> i32 {
let has_version_table: bool = conn
.query_row(