fix(core): remove all unwraps, fix unpolled futures, and fix search index memory leak on restart

This commit is contained in:
Riz Ashraf committed 2026-09-21 18:54:19 +01:00
1 parent ae0ea9ab22
commit 7dc0c329ad
9 files changed
+45 -59

No files matched your search

+5 -7
View File
@@ -41,10 +41,9 @@ impl McpTool for LogDecisionHandler {
adrs.push(a);
});
if let Some(adr) = new_adr
&& let Ok(idx) = state.search_index.read()
{
drop(idx.index_adr(&adr));
if let Some(adr) = new_adr {
let idx = state.search_index.read().unwrap_or_else(|e| e.into_inner()).clone();
let _ = idx.index_adr(&adr).await;
}
Ok(format!("Decision logged as {}", adr_id).to_string())
@@ -346,11 +345,10 @@ impl McpTool for OmniSearchHandler {
async fn execute(&self, args: Value, state: Arc<MemoryState>) -> Result<String, String> {
let req: OmniSearchTool = serde_json::from_value(args).map_err(|e| e.to_string())?;
let matches = if let Ok(idx) = state.search_index.read() {
let matches = {
let idx = state.search_index.read().unwrap_or_else(|e| e.into_inner());
idx.search(&req.query, req.namespace.as_deref())
.unwrap_or_default()
} else {
vec![]
};
let kg_json = state.read_graph(|full| {