refactor: resolve critical concurrency, data loss, schema, and search audit passes

This commit is contained in:
Riz Ashraf committed 2026-10-07 07:09:28 +01:00
1 parent e4a0fe72df
commit d80915635f
7 files changed
+846 -450

No files matched your search

+10 -7
View File
@@ -513,12 +513,12 @@ impl SearchService {
let mut uncached_meta = Vec::new();
self.state.code.snippets.read_with(|snips| {
for snippet in snips.iter().take(50) {
for snippet in snips.iter() {
let title = snippet.name.clone();
let desc = snippet.description.clone();
if let Some(ref emb) = snippet.embedding {
cached_items.push((title, "snippet".to_string(), desc, emb.clone()));
} else {
} else if uncached_texts.len() < 50 {
uncached_texts.push(format!(
"{} {} {}",
snippet.name, snippet.description, snippet.code
@@ -529,7 +529,10 @@ impl SearchService {
});
self.state.code.sticky.read_with(|sticky| {
for note in sticky.iter().take(50) {
for note in sticky.iter() {
if uncached_texts.len() >= 50 {
break;
}
let content_preview = note.content.chars().take(200).collect::<String>();
uncached_texts.push(note.content.clone());
uncached_meta.push((
@@ -540,7 +543,7 @@ impl SearchService {
}
});
self.state.read_graph(|graph| {
for entity in graph.entities.values().take(50) {
for entity in graph.entities.values() {
if let Some(ns) = filter_namespace {
if entity.namespace != ns {
continue;
@@ -551,7 +554,7 @@ impl SearchService {
let desc = format!("{}: {}", entity.entity_type, obs);
if let Some(ref emb) = entity.embedding {
cached_items.push((title, "entity".to_string(), desc, emb.clone()));
} else {
} else if uncached_texts.len() < 50 {
uncached_texts.push(format!("{} {} {}", entity.name, entity.entity_type, obs));
uncached_meta.push((title, "entity".to_string(), desc));
}
@@ -559,12 +562,12 @@ impl SearchService {
});
self.state.code.error_fixes.read_with(|fixes| {
for fix in fixes.iter().take(50) {
for fix in fixes.iter() {
let title = fix.signature.clone();
let desc = fix.solution.clone();
if let Some(ref emb) = fix.embedding {
cached_items.push((title, "error_fix".to_string(), desc, emb.clone()));
} else {
} else if uncached_texts.len() < 50 {
uncached_texts.push(format!("{} {}", fix.signature, fix.solution));
uncached_meta.push((title, "error_fix".to_string(), desc));
}