The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor: make index priming contract explicit
Steven Enamakeladb58c9194c6
diff --git a/src/openhuman/memory/conversations/store/store_index.rs b/src/openhuman/memory/conversations/store/store_index.rsindex 698bedcc92..6d8cb72f24 100644--- a/src/openhuman/memory/conversations/store/store_index.rs+++ b/src/openhuman/memory/conversations/store/store_index.rs@@ -113,10 +113,12 @@ impl ConversationStore {unreachable!("bounded prime loop returns on every path")}- /// Acquire the cached inverted index for this workspace and run `f` against- /// it. `search_cross_thread_messages` warms it first while holding the- /// root's lifecycle read guard, so purge cannot remove it between the two.- pub(super) fn with_index<R>(+ /// Acquire an index that the caller has already warmed with+ /// [`Self::prime_index_if_cold`] and run `f` against it. The only+ /// production caller, `search_cross_thread_messages`, holds the root's+ /// lifecycle read guard across both calls, so purge cannot remove the+ /// entry between priming and access.+ pub(super) fn with_primed_index<R>(&self,f: impl FnOnce(&mut InvertedIndex) -> R,) -> Result<R, String> {@@ -124,7 +126,7 @@ impl ConversationStore {let mut cache = CONVERSATION_INDEX_CACHE.lock();let idx = cache.get_mut(&key)- .ok_or_else(|| "conversation index missing after prime".to_string())?;+ .ok_or_else(|| "conversation index missing after required prime".to_string())?;Ok(f(idx))}diff --git a/src/openhuman/memory/conversations/store/store_ops.rs b/src/openhuman/memory/conversations/store/store_ops.rsindex 680d1806ab..2961381b28 100644--- a/src/openhuman/memory/conversations/store/store_ops.rs+++ b/src/openhuman/memory/conversations/store/store_ops.rs@@ -113,7 +113,7 @@ impl ConversationStore {// rebuild.let _lifecycle = self.locks.lifecycle.read();self.prime_index_if_cold()?;- self.with_index(|idx| idx.search(query, limit, exclude_thread_id))+ self.with_primed_index(|idx| idx.search(query, limit, exclude_thread_id))}/// Append a message to the thread's JSONL file. Errors if the thread is missing.diff --git a/src/openhuman/memory/conversations/store/store_tests_late.rs b/src/openhuman/memory/conversations/store/store_tests_late.rsindex e84c10abe2..c89e291bca 100644--- a/src/openhuman/memory/conversations/store/store_tests_late.rs+++ b/src/openhuman/memory/conversations/store/store_tests_late.rs@@ -320,7 +320,7 @@ fn search_cold_rebuild_does_not_block_concurrent_append() {scanned_tx.send(()).unwrap();release_rx.recv().unwrap();})?;- store_search.with_index(|idx| idx.search("seed message", 5, None))+ store_search.with_primed_index(|idx| idx.search("seed message", 5, None))});scanned_rx