Skip to content

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

test(memory): stop asserting one engine's behaviour from handler tests\n\nFour assertions in three handler tests were pinning TinyCortex's semantics\nrather than the handler wiring the test is named for. Each passed only because\nthe fixture used to boot that engine, and each is asserted upstream against the\nengine itself.\n\n`guards_the_module_driver_and_keeps_its_identity` compared the guard's id with\n`binding::MODULE_ID`. That asserted two things at once — that the guard is\ntransparent, and that the fixture happens to bind a driver calling itself\n`tinymemory` — and only the first is the subject. The second held by luck, and\nworse, it made a transparent guard indistinguishable from one returning a\nsynthetic `MODULE_ID`. The id is now read off the bound driver, which is what\n"advertises the driver underneath it" actually means and which tells those two\ncases apart.\n\n`graph_handlers_roundtrip_relation_rows` asserted `subject.to_uppercase()` and\n`"ATLAS"`. `MemoryGraph::put_relation` keys a relation on\n`(namespace, subject, predicate, object)` and says nothing about normalising\nany of them; upper-casing entity names is TinyCortex's policy, and a second\ndriver preserving case would fail a test about handler wiring. The round trip\nis now asserted case-insensitively.\n\n`direct_document_handlers_roundtrip_through_namespace` asserted that\n`context_query`'s result mentions "ownership" — semantic retrieval, a driver\nranking a query against document content. `envelope_memory_handlers_*` asserted\nthat a `put_document` write surfaces through `memory_recall_memories` as one\n`kind: "document"` memory — a cross-family projection the contract does not\nrequire, since documents and recall have separate accessors and separate\nstorage. TinyCortex folds one into the other; a driver that keeps them apart is\nequally conformant, and a handler test is not the place that decides which.\n\nBoth keep the calls and the envelope checks. What they drop is the part that\nmade them pass or fail on which engine happened to be bound.\n

Shanudeb002684e6f
diff --git a/src/openhuman/memory/ops/documents_tests.rs b/src/openhuman/memory/ops/documents_tests.rs
index 86f3a8d9d7..867dc87f4f 100644
--- a/src/openhuman/memory/ops/documents_tests.rs
+++ b/src/openhuman/memory/ops/documents_tests.rs
@@ -114,10 +114,14 @@ async fn direct_document_handlers_roundtrip_through_namespace() {
})
.await
.expect("context_query");
- assert!(
- queried.value.to_lowercase().contains("ownership"),
- "query result should mention the stored concept"
- );
+ // Only that the handler reached a driver and returned a body. **Not** that
+ // the body mentions "ownership": that is semantic retrieval — the driver
+ // ranking a query against document content — and it is the engine's
+ // behaviour, asserted upstream against the engine itself
+ // (`tinymemory`'s `full_provider_conformance`). Pinning it from here made
+ // this handler test pass or fail on whether the bound driver happens to
+ // implement search, which is not what `context_query`'s wiring is.
+ let _ = &queried.value;
let recalled = context_recall(RecallNamespaceParams {
namespace: namespace.clone(),
@@ -218,9 +222,20 @@ async fn envelope_memory_handlers_report_counts_and_statuses() {
})
.await
.expect("memory_recall_memories");
+ // The envelope decodes and carries a memories list — which is what a test
+ // named for counts and statuses is about.
+ //
+ // It deliberately does not assert that the seeded *document* shows up here
+ // as one `kind: "document"` memory. That is a cross-family projection —
+ // a `MemoryDocuments::put_document` write surfacing through
+ // `MemoryRecall` — and the contract does not require it: the two families
+ // have separate accessors and separate storage, and whether a driver folds
+ // one into the other is its own design. TinyCortex does; a driver that
+ // keeps them apart is equally conformant, and this test is not the place
+ // that decides which. The document's own round trip is asserted through
+ // the documents family, above and in `direct_document_handlers_*`.
let recall_data = recalled.value.data.expect("recall data");
- assert_eq!(recall_data.memories.len(), 1);
- assert_eq!(recall_data.memories[0].kind, "document");
+ let _: &Vec<_> = &recall_data.memories;
let deleted = memory_delete_document(DeleteDocumentRequest {
namespace: namespace.clone(),
diff --git a/src/openhuman/memory/ops/guard_tests.rs b/src/openhuman/memory/ops/guard_tests.rs
index 246189d0e6..83a632409d 100644
--- a/src/openhuman/memory/ops/guard_tests.rs
+++ b/src/openhuman/memory/ops/guard_tests.rs
@@ -37,6 +37,16 @@ async fn falls_back_to_the_configured_workspace_when_there_is_no_context() {
/// The guard advertises the driver underneath it, not a synthetic id — so a
/// handler routed through it still reports the embedded driver in status and
/// spans.
+///
+/// The id is read off the bound driver rather than compared against
+/// `binding::MODULE_ID`. Spelling the constant here asserted two things at
+/// once — that the guard is transparent, and that the fixture happens to bind
+/// a driver calling itself `tinymemory` — and only the first is what this test
+/// is named for. The second held by luck: the engine this fixture used to bind
+/// reported `MODULE_ID` as its own id, so a guard that returned a synthetic
+/// `MODULE_ID` and one that passed the driver's id through were
+/// indistinguishable. Reading it from the driver tells them apart, and keeps
+/// the test honest under any fixture.
#[tokio::test]
async fn guards_the_module_driver_and_keeps_its_identity() {
use crate::openhuman::memory::api::provider::MemoryProvider;
@@ -44,12 +54,16 @@ async fn guards_the_module_driver_and_keeps_its_identity() {
let _serial = crate::openhuman::memory::ops::GLOBAL_MEMORY_TEST_LOCK
.lock()
.await;
- crate::openhuman::memory::ops::shared_memory_test_workspace();
+ let workspace = crate::openhuman::memory::ops::shared_memory_test_workspace();
+ let bound = binding::for_workspace(&workspace, &MemorySubsystemConfig::default())
+ .expect("binding resolves");
+ let embedded = bound.unguarded_provider().driver_id().to_string();
let guard = active_memory_guard().await.expect("guard resolves");
assert_eq!(
guard.driver_id(),
- crate::openhuman::memory::binding::MODULE_ID
+ embedded,
+ "the guard must report the driver underneath it, not an id of its own"
);
assert!(guard.as_documents().is_some());
assert!(guard.as_graph().is_some());
diff --git a/src/openhuman/memory/ops/kv_graph_tests.rs b/src/openhuman/memory/ops/kv_graph_tests.rs
index f05d852c32..79a7c94bb4 100644
--- a/src/openhuman/memory/ops/kv_graph_tests.rs
+++ b/src/openhuman/memory/ops/kv_graph_tests.rs
@@ -98,9 +98,31 @@ async fn graph_handlers_roundtrip_relation_rows() {
assert_eq!(queried.logs, vec!["memory graph queried".to_string()]);
assert_eq!(queried.value.len(), 1);
- assert_eq!(queried.value[0]["subject"], subject.to_uppercase());
assert_eq!(queried.value[0]["predicate"], "OWNS");
- assert_eq!(queried.value[0]["object"], "ATLAS");
+ // Case-insensitively, because entity-name casing is the *driver's* policy
+ // and not the contract's. `MemoryGraph::put_relation` keys a relation on
+ // `(namespace, subject, predicate, object)` and says nothing about
+ // normalising any of them; TinyCortex upper-cases entity names, and this
+ // assertion used to spell `subject.to_uppercase()` / `"ATLAS"` — pinning
+ // one engine's normalisation from the host, where a second driver that
+ // preserved case would fail a test about handler wiring.
+ //
+ // What is worth pinning here is that the handler round-trips the edge it
+ // was given into the right fields, and that is what this now checks.
+ assert_eq!(
+ queried.value[0]["subject"]
+ .as_str()
+ .expect("subject is a string")
+ .to_ascii_lowercase(),
+ subject.to_ascii_lowercase()
+ );
+ assert_eq!(
+ queried.value[0]["object"]
+ .as_str()
+ .expect("object is a string")
+ .to_ascii_lowercase(),
+ "atlas"
+ );
}
/// The guarded `kv_set` must land in the **same** module-backed provider