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
feat(memory): read a rank-only engine's hits as unscored
Shanubbd112e65172
diff --git a/crates/openhuman-core/src/memory/auto_recall/auto_recall_tests.rs b/crates/openhuman-core/src/memory/auto_recall/auto_recall_tests.rsindex 143cbf2833..ffa502b4b0 100644--- a/crates/openhuman-core/src/memory/auto_recall/auto_recall_tests.rs+++ b/crates/openhuman-core/src/memory/auto_recall/auto_recall_tests.rs@@ -511,6 +511,27 @@ async fn from_guard_asks_the_notes_namespace_through_the_retrieval_family() {);}+/// Hosted CortexDB's retrieval family ranks its notes and reports no signal:+/// they are kept in the engine's order, as an unscored engine's are, rather+/// than all dropped by the similarity floor.+#[tokio::test]+async fn from_guard_keeps_a_rank_only_drivers_notes_in_its_order() {+ let ranked = |key: &str, content: &str, rank: f64| {+ let mut hit = namespace_hit("global", key, content, 0.0);+ hit.score = rank;+ hit.score_breakdown.final_score = rank;+ hit+ };+ let provider = RecordingProvider::new().with_namespace_hits(vec![+ ranked("favourite_tea_oolong", TEA_NOTE, 1.0),+ ranked("rent", "Rent is due on the 5th.", 0.9),+ ]);+ let (_provider, guard) = guarded_with(provider, embedded_policy());+ let lane = AutoRecall::from_guard(Arc::new(guard));+ let block = lane.block_for(TEA_QUESTION).await.expect("a block");+ assert!(block.contains(TEA_NOTE), "{block}");+}+#[tokio::test]async fn from_guard_honours_the_hooks_switch() {let hooks = crate::config::schema::MemoryHooksConfig {diff --git a/crates/openhuman-core/src/memory/auto_recall/source.rs b/crates/openhuman-core/src/memory/auto_recall/source.rsindex 3782cfd97d..1b318a908a 100644--- a/crates/openhuman-core/src/memory/auto_recall/source.rs+++ b/crates/openhuman-core/src/memory/auto_recall/source.rs@@ -50,9 +50,10 @@ pub struct ScoredNotes {/// The hits, most relevant first.pub hits: Vec<NamespaceMemoryHit>,/// Whether each hit's `vector_similarity` is the engine's own score.- /// `false` for an engine whose recall is ranked but carries no score- /// (hosted CortexDB): its hits read 0.0, and flooring on that would drop- /// every one of them however well the engine ranked it.+ /// `false` for an engine whose recall is ranked but carries no similarity+ /// (hosted CortexDB, with or without its retrieval family): its hits read+ /// 0.0, and flooring on that would drop every one of them however well+ /// the engine ranked it.pub scored: bool,}@@ -129,9 +130,18 @@ impl AutoRecallSource for GuardSource {// No session to exclude: the notes namespace is never auto-saved per// session, and the lane runs before this turn is archived, so there is// no self-echo for the engine's exclusion to catch.- retrieval+ let hits = retrieval.recall_namespace_scored(namespace, query, limit, None)- .await- .map(ScoredNotes::scored)+ .await?;+ // A retrieval family can rank without measuring similarity (hosted+ // CortexDB scores by rank): its hits are unscored notes, not misses.+ let scored = !crate::memory::ops::fallback::rank_only(&hits);+ if !scored {+ log::debug!(+ "[auto_recall] retrieval ranks without similarity; notes kept in rank order hits={}",+ hits.len()+ );+ }+ Ok(ScoredNotes { hits, scored })}}diff --git a/crates/openhuman-core/src/memory/ops/fallback.rs b/crates/openhuman-core/src/memory/ops/fallback.rsindex 3f21767e5b..5d7b148df2 100644--- a/crates/openhuman-core/src/memory/ops/fallback.rs+++ b/crates/openhuman-core/src/memory/ops/fallback.rs@@ -128,6 +128,29 @@ pub(crate) async fn namespace_names(guard: &MemoryGuard) -> Result<Vec<String>,Ok(summaries.into_iter().map(|s| s.namespace).collect())}+/// Whether `hits` were ranked without anything measured: each has a positive+/// final score and no signal at all — no similarity, keyword, graph, episodic+/// or freshness.+///+/// That is the mark a driver ranking without scoring leaves (hosted CortexDB's+/// retrieval family scores a hit by its rank and reports no signal), and a+/// weighted sum of signals cannot produce it, so an engine that scores is+/// never read as one. A similarity floor cannot tell such hits apart, so a+/// caller treats them as it treats [`ranked_recall`]'s unscored ones. An empty+/// list is not rank-only: there is nothing to keep either way.+pub(crate) fn rank_only(hits: &[NamespaceMemoryHit]) -> bool {+ !hits.is_empty()+ && hits.iter().all(|hit| {+ let signals = &hit.score_breakdown;+ signals.final_score > 0.0+ && signals.vector_similarity == 0.0+ && signals.keyword_relevance == 0.0+ && signals.graph_relevance == 0.0+ && signals.episodic_relevance == 0.0+ && signals.freshness == 0.0+ })+}+/// What [`ranked_recall`] answered: the hits, and whether the engine scored/// them.pub(crate) struct RankedRecall {diff --git a/crates/openhuman-core/src/memory/ops/fallback_tests.rs b/crates/openhuman-core/src/memory/ops/fallback_tests.rsindex 489576b5e9..333275b21c 100644--- a/crates/openhuman-core/src/memory/ops/fallback_tests.rs+++ b/crates/openhuman-core/src/memory/ops/fallback_tests.rs@@ -218,3 +218,27 @@ fn error_envelopes_carry_the_classified_message() {let message = outcome.value.error.expect("error").message;assert!(message.starts_with("INSUFFICIENT_CREDITS:"), "{message}");}++/// A hit as a driver ranking without scoring sends it: a rank, no signal.+fn ranked_hit(key: &str, rank_score: f64) -> NamespaceMemoryHit {+ let mut hit = crate::memory::guard::test_support::namespace_hit("global", key, key, 0.0);+ hit.score = rank_score;+ hit.score_breakdown.final_score = rank_score;+ hit+}++#[test]+fn a_ranking_with_no_signal_is_rank_only_and_a_scored_one_is_not() {+ let ranked = vec![ranked_hit("a", 1.0), ranked_hit("b", 0.9)];+ assert!(rank_only(&ranked));+ assert!(!rank_only(&[]), "nothing is not a ranking");+ let mut keyword = ranked.clone();+ keyword[1].score_breakdown.keyword_relevance = 0.4;+ assert!(!rank_only(&keyword), "one measured signal makes it scored");+ let mut recent = ranked.clone();+ recent[0].score_breakdown.freshness = 0.7;+ assert!(!rank_only(&recent), "recency is a signal");+ let mut unranked = ranked;+ unranked[0].score_breakdown.final_score = 0.0;+ assert!(!rank_only(&unranked), "a zero final score is not a rank");+}diff --git a/crates/openhuman-core/src/memory/preferences/mod.rs b/crates/openhuman-core/src/memory/preferences/mod.rsindex ef1f4365c6..be290cb626 100644--- a/crates/openhuman-core/src/memory/preferences/mod.rs+++ b/crates/openhuman-core/src/memory/preferences/mod.rs@@ -92,9 +92,21 @@ pub(crate) async fn recall_by_vector_over(let started = std::time::Instant::now();let hits = match provider.as_retrieval() {Some(retrieval) => {- retrieval+ let hits = retrieval.recall_namespace_scored(namespace, query, limit, None)- .await?+ .await?;+ if crate::memory::ops::fallback::rank_only(&hits) {+ // A retrieval family that ranks without measuring similarity+ // (hosted CortexDB) is the unscored engine below under another+ // name, and gets the same answer for the same reason.+ log::debug!(+ "[pref_recall] namespace={namespace} retrieval ranks without similarity; \+ nothing clears a similarity floor elapsed_ms={}",+ started.elapsed().as_millis()+ );+ return Ok(Vec::new());+ }+ hits}// No retrieval family (a remote engine): the mandatory ranked recall// answers, so Lane B still works instead of injecting nothing.diff --git a/crates/openhuman-core/src/memory/preferences/preferences_tests.rs b/crates/openhuman-core/src/memory/preferences/preferences_tests.rsindex f886a18040..d886f828e2 100644--- a/crates/openhuman-core/src/memory/preferences/preferences_tests.rs+++ b/crates/openhuman-core/src/memory/preferences/preferences_tests.rs@@ -330,6 +330,25 @@ async fn situational_recall_filters_on_the_vector_component_not_the_final_score(assert_eq!(out, vec!["Prefers vim.".to_string()]);}+/// A retrieval family that ranks without measuring any signal (hosted+/// CortexDB) is the unscored engine under another name: no floor can tell a+/// preference that fits from one that does not, so neither lane injects one.+#[tokio::test]+async fn a_driver_ranking_without_signals_yields_no_preferences() {+ let guard = scripted(vec![+ ("editor", "Prefers vim.", 0.0),+ ("tone", "Be terse.", 0.0),+ ]);+ assert!(recall_situational_preferences(&guard, "which editor?")+ .await+ .is_empty());+ assert!(+ recall_related_preferences(&guard, "Be brief.", "verbosity", 4)+ .await+ .is_empty()+ );+}+#[tokio::test]async fn an_empty_query_recalls_nothing_without_asking_the_driver() {let guard = scripted(vec![("editor", "Prefers vim.", 0.99)]);diff --git a/crates/openhuman-core/src/memory/tools/search/hybrid_search.rs b/crates/openhuman-core/src/memory/tools/search/hybrid_search.rsindex 4c5667ef10..ef18a8b5bb 100644--- a/crates/openhuman-core/src/memory/tools/search/hybrid_search.rs+++ b/crates/openhuman-core/src/memory/tools/search/hybrid_search.rs@@ -287,11 +287,23 @@ impl Tool for MemoryHybridSearchTool {return Ok(ToolResult::success("No results found."));}+ // A driver that ranks without measuring any signal (hosted CortexDB)+ // leaves nothing to re-weight: its order is the ranking, and a weighted+ // sum of zeros would report no results at all.+ let ranked = crate::memory::ops::fallback::rank_only(&hits);+ if ranked {+ log::debug!(+ "[tool][memory_hybrid_search] driver ranks without signals; keeping its order"+ );+ }// Re-score using the selected weight profilelet mut rescored: Vec<(usize, f64)> = hits.iter().enumerate().map(|(i, hit)| {+ if ranked {+ return (i, hit.score);+ }let bd = &hit.score_breakdown;let score = hybrid_final_score(&profile,@@ -314,8 +326,14 @@ impl Tool for MemoryHybridSearchTool {parsed.mode,);- for (hit_idx, score) in &rescored {+ for (position, (hit_idx, score)) in rescored.iter().enumerate() {let hit = &hits[*hit_idx];+ // A rank is not a relevance, so it is not shown as a percentage.+ let mark = if ranked {+ format!("#{}", position + 1)+ } else {+ format!("{:.0}%", score * 100.0)+ };let preview: String = hit.content.chars().take(200).collect();let truncated = if hit.content.chars().count() > 200 {"..."@@ -324,8 +342,8 @@ impl Tool for MemoryHybridSearchTool {};let _ = writeln!(output,- "- [{:.0}%] [{}] {}: {}{}",- score * 100.0,+ "- [{}] [{}] {}: {}{}",+ mark,kind_label(&hit.kind),hit.key,preview,