Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(guard): correct fallback engine to use bypass allowlist

Steven Enamakeld786af376baf
diff --git a/crates/openhuman-core/src/memory/bypass_allowlist_tests.rs b/crates/openhuman-core/src/memory/bypass_allowlist_tests.rs
index a69263c943..d12289ddb0 100644
--- a/crates/openhuman-core/src/memory/bypass_allowlist_tests.rs
+++ b/crates/openhuman-core/src/memory/bypass_allowlist_tests.rs
@@ -185,6 +185,11 @@ const ALLOWED: &[(&str, &str, &str)] = &[
"NullMemoryProvider::new(",
"this is the construction path the lint protects (fail-closed fallback)",
),
+ (
+ "crates/openhuman-core/src/memory/binding_build.rs",
+ "NullMemoryProvider::new(",
+ "the fail-closed fallback construction, moved out of binding.rs unchanged",
+ ),
(
"vendor/tinymemory/crates/tinymemory-core/src/global.rs",
"MemoryClient::from_workspace_dir(",
diff --git a/crates/openhuman-core/src/memory/guard/provider.rs b/crates/openhuman-core/src/memory/guard/provider.rs
index a329b31bd7..4451919faf 100644
--- a/crates/openhuman-core/src/memory/guard/provider.rs
+++ b/crates/openhuman-core/src/memory/guard/provider.rs
@@ -70,6 +70,11 @@ pub struct MemoryGuard {
}
impl MemoryGuard {
+ /// How the guarded driver was bound (a host fact, from the policy).
+ pub(crate) fn class(&self) -> crate::core::subsystem::DriverClass {
+ self.policy.class()
+ }
+
/// Wrap `inner` in `policy`.
///
/// Builds all fourteen decorators up front. That is not an optimisation: the
diff --git a/crates/openhuman-core/src/memory/ops/engine.rs b/crates/openhuman-core/src/memory/ops/engine.rs
index b3be71cc0d..6828a258a9 100644
--- a/crates/openhuman-core/src/memory/ops/engine.rs
+++ b/crates/openhuman-core/src/memory/ops/engine.rs
@@ -247,7 +247,8 @@ fn validate_endpoint(endpoint: &str) -> Result<(), String> {
}
if !parsed.username().is_empty() || parsed.password().is_some() {
return Err(
- "endpoint must not contain credentials (user:pass@); use the API key field".to_string(),
+ "endpoint must not embed credentials before the host; use the API key field"
+ .to_string(),
);
}
let link_local = match parsed.host() {
diff --git a/crates/openhuman-core/src/memory/ops/fallback.rs b/crates/openhuman-core/src/memory/ops/fallback.rs
index 173f620054..6895c6c7a2 100644
--- a/crates/openhuman-core/src/memory/ops/fallback.rs
+++ b/crates/openhuman-core/src/memory/ops/fallback.rs
@@ -64,9 +64,9 @@ pub(crate) fn classify_for_engine(external: bool, message: String) -> String {
/// come from a remote engine.
pub(crate) fn classify_rpc_error(message: String) -> String {
let external = crate::core::runtime::context::CoreContext::current()
- .and_then(|ctx| ctx.memory_binding().ok())
- .map_or(true, |binding| {
- binding.class() == crate::core::subsystem::DriverClass::External
+ .and_then(|ctx| ctx.memory().ok())
+ .map_or(true, |guard| {
+ guard.class() == crate::core::subsystem::DriverClass::External
});
classify_for_engine(external, message)
}
diff --git a/crates/openhuman-core/src/memory/ops/fallback_tests.rs b/crates/openhuman-core/src/memory/ops/fallback_tests.rs
index 1ac0fd5e5e..489576b5e9 100644
--- a/crates/openhuman-core/src/memory/ops/fallback_tests.rs
+++ b/crates/openhuman-core/src/memory/ops/fallback_tests.rs
@@ -60,11 +60,16 @@ async fn recall_hits_use_mandatory_recall_scoped_to_the_namespace() {
}
#[tokio::test]
-async fn recent_hits_list_the_namespace_newest_first_within_the_limit() {
- let guard = seeded().await;
- let hits = recent_hits(&guard, "notes", 10).await.unwrap();
- assert_eq!(hits.len(), 2);
- let one = recent_hits(&guard, "notes", 1).await.unwrap();
+async fn recent_hits_return_the_namespace_newest_first_within_the_limit() {
+ use crate::memory::guard::in_memory::guard_over;
+ use crate::memory::ops::engine_fakes_tests::ScriptedProvider;
+ let provider = ScriptedProvider::spread(10, 2);
+ let guard = guard_over(provider as std::sync::Arc<dyn MemoryProvider>);
+ let hits = recent_hits(&guard, "ns0", 10).await.unwrap();
+ assert_eq!(hits.len(), 5);
+ assert!(hits.iter().all(|h| h.namespace == "ns0"));
+ assert!(hits.windows(2).all(|w| w[0].updated_at >= w[1].updated_at));
+ let one = recent_hits(&guard, "ns0", 1).await.unwrap();
assert_eq!(one.len(), 1);
assert!(recent_hits(&guard, "missing", 5).await.unwrap().is_empty());
}