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
fix(storage): pass collection name by value to declaration helpers
Steven Enamakel0c5e600287d5
diff --git a/crates/openhuman-core/src/storage/documents.rs b/crates/openhuman-core/src/storage/documents.rsindex 9b0f1b7390..1a0d3653d7 100644--- a/crates/openhuman-core/src/storage/documents.rs+++ b/crates/openhuman-core/src/storage/documents.rs@@ -132,7 +132,7 @@ impl Repo {.into_iter().filter(|spec| {origin.as_ref().is_none_or(|origin| {- !is_declared(&origin.backend, &origin.scope, spec.name())+ !is_declared(&origin.backend, &origin.scope, spec.name)})}).collect();@@ -142,7 +142,7 @@ impl Repo {for spec in &specs {docs.ensure_collection(spec).await?;if let Some(origin) = &origin {- mark_declared(&origin.backend, &origin.scope, spec.name());+ mark_declared(&origin.backend, &origin.scope, spec.name);}}future.awaitdiff --git a/crates/openhuman-core/src/storage/documents_tests.rs b/crates/openhuman-core/src/storage/documents_tests.rsindex 25e8c2b401..6c11373fb1 100644--- a/crates/openhuman-core/src/storage/documents_tests.rs+++ b/crates/openhuman-core/src/storage/documents_tests.rs@@ -127,3 +127,36 @@ fn scopes_do_not_see_each_other() {.unwrap();assert!(seen.is_none());}++fn backend() -> Arc<dyn StorageBackend> {+ Arc::new(MemoryStorage::new())+}++#[test]+fn a_collection_is_declared_once_per_backend_scope_and_name() {+ let backend = backend();+ assert!(!is_declared(&backend, "local", THINGS));+ mark_declared(&backend, "local", THINGS);+ assert!(is_declared(&backend, "local", THINGS));+ assert!(!is_declared(&backend, "agent-b", THINGS), "another scope");+ assert!(!is_declared(&backend, "local", "other"), "another collection");+ assert!(!is_declared(&self::backend(), "local", THINGS), "another backend");+}++#[test]+fn a_repo_with_an_origin_declares_a_collection_only_on_its_first_run() {+ let backend = backend();+ let scoped = backend.for_scope(&Scope::new("cached").unwrap()).unwrap();+ let mut repo = Repo::over(&scoped, "test", specs);+ repo.origin = Some(Origin {+ backend: Arc::clone(&backend),+ scope: "cached".to_string(),+ });+ assert!(!is_declared(&backend, "cached", THINGS));+ repo.run(|docs| async move { docs.get(THINGS, "a").await })+ .unwrap();+ assert!(is_declared(&backend, "cached", THINGS));+ // Second run still works with the declaration skipped.+ repo.run(|docs| async move { docs.get(THINGS, "a").await })+ .unwrap();+}