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
test(flows): add resource tests for catalog storage
Steven Enamakel88b5cb174a88
diff --git a/crates/openhuman-core/src/flows/catalog_storage.rs b/crates/openhuman-core/src/flows/catalog_storage.rsindex 1290614450..51a8d1fdcb 100644--- a/crates/openhuman-core/src/flows/catalog_storage.rs+++ b/crates/openhuman-core/src/flows/catalog_storage.rs@@ -484,3 +484,7 @@ impl CatalogStoragePort {#[cfg(test)]#[path = "catalog_storage_tests.rs"]mod tests;++#[cfg(all(test, unix))]+#[path = "catalog_storage_resource_tests.rs"]+mod resource_tests;diff --git a/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs b/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rsnew file mode 100644index 0000000000..4d31a9f18a--- /dev/null+++ b/crates/openhuman-core/src/flows/catalog_storage_resource_tests.rs@@ -0,0 +1,80 @@+use super::*;++use crate::core::runtime::{ContextOverlay, CoreContext, DomainSet};+use crate::tools::toolpacks::ToolGroups;++const WORKSPACE_COUNT: usize = 8;+const FD_TOLERANCE: usize = 4;++fn context(config: &Config, profile: &str) -> DispatchCtx {+ let root = CoreContext::for_test_with_config(DomainSet::full(), config.clone());+ DispatchCtx::new(+ root.derive_with(+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::default())+ .profile(profile),+ ),+ )+}++fn open_fd_count() -> usize {+ std::fs::read_dir("/dev/fd")+ .expect("Unix exposes the current process descriptor directory")+ .count()+}++#[tokio::test]+async fn workspace_fd_lifetime_is_separate_from_catalog_callback_lifetime() {+ // Warm the process-wide bus before measuring. Serving additional callback+ // objects should only add entries to that shared bus, not open a backend.+ crate::modules::runtime::runtime()+ .await+ .expect("process module runtime starts");+ let before = open_fd_count();++ let mut workspaces = Vec::with_capacity(WORKSPACE_COUNT);+ let mut registrations = Vec::with_capacity(WORKSPACE_COUNT);+ for index in 0..WORKSPACE_COUNT {+ let workspace = tempfile::tempdir().expect("isolated workspace");+ let config = Config {+ workspace_dir: workspace.path().to_path_buf(),+ ..Config::default()+ };+ let context = context(&config, &format!("fd-probe-{index}"));+ registrations.push(+ register(&context, &config)+ .await+ .expect("scope callback registers without opening a workspace backend"),+ );+ workspaces.push(workspace);+ }+ let after_registrations = open_fd_count();+ assert!(+ after_registrations <= before + FD_TOLERANCE,+ "idle callback registration opened OS descriptors: before={before}, after={after_registrations}"+ );++ // The existing default storage cache intentionally keeps a backend per+ // workspace. Exercise that separate owner, then use its existing release+ // API and retain TempDirs until every cached backend has been dropped.+ for workspace in &workspaces {+ let backend = crate::storage::local::backend_for(workspace.path())+ .expect("open the temporary workspace default backend");+ assert_eq!(backend.driver(), "sqlite");+ drop(backend);+ }+ let after_backend_opens = open_fd_count();+ assert!(+ after_backend_opens >= after_registrations + WORKSPACE_COUNT,+ "opening one SQLite database per workspace should retain file descriptors: registrations={after_registrations}, backends={after_backend_opens}"+ );++ for workspace in &workspaces {+ crate::storage::local::forget(workspace.path());+ }+ drop(registrations);+ let after_release = open_fd_count();+ assert!(+ after_release <= after_registrations + FD_TOLERANCE,+ "forgetting cached workspace backends should return to the callback-only descriptor count: registrations={after_registrations}, released={after_release}"+ );+}