refactor: address 5-pass audit findings for antipatterns, bottlenecks, memory efficiency, and LLM handlers

This commit is contained in:
Riz Ashraf committed 2026-10-05 21:44:10 +01:00
1 parent 626403900f
commit 924b6d09fa
30 files changed
+1120 -503

No files matched your search

+8 -3
View File
@@ -23,14 +23,14 @@ impl McpTool for LogDecisionHandler {
let idx = state.get_search_index();
let mut final_id = String::new();
let mut adrs_to_index = Vec::new();
state.code.adrs.modify(|adrs| {
if let Some(superseded_id) = &req.supersedes {
for old_adr in adrs.iter_mut() {
if old_adr.id == *superseded_id {
old_adr.status = "superseded".to_string();
// Re-index the modified old ADR
drop(idx.index_adr(old_adr));
adrs_to_index.push(old_adr.clone());
break;
}
}
@@ -48,10 +48,15 @@ impl McpTool for LogDecisionHandler {
timestamp: crate::handlers::utils::now_secs(),
};
drop(idx.index_adr(&a));
adrs_to_index.push(a.clone());
adrs.push(a);
});
// Index in Tantivy outside the store write lock
for adr in &adrs_to_index {
drop(idx.index_adr(adr));
}
state.record_activity("decision", &format!("Logged {}: {}", final_id, req.title), Some(&req.decision));
Ok(format!("Logged decision {}: {}", final_id, req.title))
}