Refactor: Fix clippy warnings and introduce AppError

This commit is contained in:
Riz Ashraf committed 2026-09-30 20:43:28 +01:00
1 parent 3add6c3d31
commit 4e1a633dbd
13 files changed
+129 -103

No files matched your search

+10 -7
View File
@@ -1,6 +1,7 @@
use crate::models::*;
use crate::search::MemoryIndex;
use crate::store::Store;
use crate::vector_db::VectorDB;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::{Arc, RwLock};
@@ -17,6 +18,7 @@ pub struct MemoryState {
pub clipboard_watch_mode: tokio::sync::RwLock<bool>,
pub graph: Store<KnowledgeGraph>,
pub search_index: RwLock<MemoryIndex>,
pub vector_db: tokio::sync::RwLock<Option<VectorDB>>,
pub ledger: Store<Vec<CodeChange>>,
pub sticky: Store<Vec<StickyNote>>,
pub tasks: Store<Vec<Task>>,
@@ -63,6 +65,7 @@ impl MemoryState {
std::process::exit(1);
}
}),
vector_db: tokio::sync::RwLock::new(None),
ledger: Store::new("audit_ledger", db.clone()),
sticky: Store::new("sticky_notes", db.clone()),
tasks: Store::new("tasks", db.clone()),
@@ -144,7 +147,7 @@ impl MemoryState {
let snippets = self.snippets.read_with(|s| s.clone());
let adrs = self.adrs.read_with(|a| a.clone());
println!(
tracing::info!(
"rebuild_index: found {} entities, {} tasks",
entities.len(),
tasks.len()
@@ -152,7 +155,7 @@ impl MemoryState {
let idx_clone = idx.clone();
tokio::task::spawn_blocking(move || {
println!("spawn_blocking started in rebuild_index");
// tracing::info!("spawn_blocking started in rebuild_index");
for e in entities {
idx_clone.add_entity_sync(&e);
}
@@ -222,13 +225,13 @@ mod tests {
let idx = arc_state.search_index.read().unwrap();
// Force reload reader to ensure it sees the commit made by rebuild_index
idx.reader.reload().unwrap();
println!(
"Index reader doc count: {}",
idx.reader.searcher().num_docs()
);
// tracing::info!(
// "Index reader doc count: {}",
// idx.reader.searcher().num_docs()
// );
let all_docs = idx.search("Test", None).expect("Search failed");
println!("All docs for 'Test': {:?}", all_docs);
// tracing::info!("All docs for 'Test': {:?}", all_docs);
// Verify the task added synchronously is actually searchable
let results = idx.search("Test", None).expect("Search failed");