Skip to content

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

refactor(memory): use provider retrieval entity kind\n\nImport `EntityKind` from the provider retrieval API and clarify that recall uses the host task-local scope to enforce memory source restrictions. Explain why an absent scope must remain unrestricted rather than becoming an empty deny-all scope.\n\nAuto-committed-on: macbook\n

Steven Enamakelac3279d4ab94
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index 5e92a9dc61..6a73415586 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -400,13 +400,21 @@ pub async fn recall_rpc(
limit
);
- // Explicit scope: `query_source` (unscoped) reads the *engine's* own
- // task-local, which nothing on the host side ever sets — the host's
- // per-turn allowlist lives in `memory::source_scope` instead (see its
- // module docs). Calling the unscoped form here would always see `None`
- // and recall would run unrestricted regardless of the active profile's
- // `memory_sources` allowlist. Mirrors `query_source_rpc` in
- // `tree/retrieval/rpc.rs`.
+ // Through the bound driver's `MemoryRetrieval` rather than the engine
+ // (#5560), and with an explicit scope.
+ //
+ // `binding.provider()` is the UNGUARDED driver: nothing between here and
+ // the store re-applies the active profile's `memory_sources` allowlist, so
+ // the scope this call passes is the gate. The engine's `*_scoped` entry
+ // points existed for the same reason — their ambient twins read the
+ // ENGINE's task-local, which a separately compiled module cannot see, and
+ // an absent scope means unrestricted, i.e. the gate failing open.
+ //
+ // `as_bus_scope()` renders this host's own task-local in the contract's
+ // vocabulary. `None` from it means genuinely unrestricted and must stay
+ // `None` — an *empty* `SourceScope` denies every source-attributed row, so
+ // mapping "no restriction" onto one would invert the policy. Mirrors
+ // `query_source_rpc` in `tree/retrieval/rpc.rs`.
let scope = crate::openhuman::memory::source_scope::as_bus_scope();
let binding = crate::openhuman::memory::binding::for_config(config)?;
let resp = match binding.provider().as_retrieval() {
diff --git a/src/openhuman/memory/tree/retrieval/rpc.rs b/src/openhuman/memory/tree/retrieval/rpc.rs
index 3b312e1b20..6cc374fb6e 100644
--- a/src/openhuman/memory/tree/retrieval/rpc.rs
+++ b/src/openhuman/memory/tree/retrieval/rpc.rs
@@ -63,7 +63,7 @@ use crate::openhuman::memory::api::provider::retrieval::{
CoverWindowQuery, EntityMatch, RetrievalHit, RetrievalResponse, SourceRetrievalQuery,
};
use crate::openhuman::memory::source_scope::as_bus_scope;
-use crate::openhuman::memory::tree::score::extract::EntityKind;
+use crate::openhuman::memory::api::provider::retrieval::EntityKind;
use crate::rpc::RpcOutcome;
use tinymemory_api::chunks::SourceKind;