Skip to content

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

test(core): add coverage for tool writes, approval gate, and import state

Steven Enamakelcc6b4417434a
diff --git a/crates/openhuman-core/src/memory/tool_writes_tests.rs b/crates/openhuman-core/src/memory/tool_writes_tests.rs
index 2d27a687fc..8a749d1cdc 100644
--- a/crates/openhuman-core/src/memory/tool_writes_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_writes_tests.rs
@@ -185,6 +185,10 @@ impl tinymemory_api::MemoryEngine for HeldEngine {
}
}
+/// A guard against a hang, not a latency budget: on a loaded machine the held
+/// write still acknowledges promptly, so a generous bound never slows a pass.
+const TIMEOUT: Duration = Duration::from_secs(30);
+
#[tokio::test]
async fn held_engine_writes_do_not_delay_acknowledgements_or_hold_the_producer_lock() {
use tinytools::Tool;
@@ -199,18 +203,18 @@ async fn held_engine_writes_do_not_delay_acknowledgements_or_hold_the_producer_l
crate::memory::engine::install_test_engine(&config.workspace_dir, engine.clone());
let tool = crate::memory::MemoryTool::new(Arc::new(config.clone()));
let first = tokio::time::timeout(
- Duration::from_secs(2),
+ TIMEOUT,
tool.execute(json!({"action":"learn","text":"First fact"})),
)
.await
.unwrap()
.unwrap();
assert!(!first.is_error);
- tokio::time::timeout(Duration::from_secs(2), engine.entered.notified())
+ tokio::time::timeout(TIMEOUT, engine.entered.notified())
.await
.unwrap();
let second = tokio::time::timeout(
- Duration::from_secs(2),
+ TIMEOUT,
tool.execute(json!({"action":"learn","text":"Second fact"})),
)
.await
diff --git a/crates/openhuman-core/src/security/approval/gate_core_flow_tests.rs b/crates/openhuman-core/src/security/approval/gate_core_flow_tests.rs
index 7847d7cf62..7b419326a1 100644
--- a/crates/openhuman-core/src/security/approval/gate_core_flow_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_core_flow_tests.rs
@@ -474,7 +474,8 @@ async fn timeout_returns_deny() {
let mut tries = 0;
while gate.list_pending().unwrap().is_empty() {
tries += 1;
- assert!(tries < 50, "audit row never appeared for timeout test");
+ // A hang guard (10 s), not a latency budget: a loaded machine can delay the park.
+ assert!(tries < 1000, "audit row never appeared for timeout test");
tokio::time::sleep(Duration::from_millis(10)).await;
}
drop(env);
diff --git a/crates/openhuman-core/src/storage/import_state_tests.rs b/crates/openhuman-core/src/storage/import_state_tests.rs
index b96bf5bc52..39c0f77433 100644
--- a/crates/openhuman-core/src/storage/import_state_tests.rs
+++ b/crates/openhuman-core/src/storage/import_state_tests.rs
@@ -232,14 +232,16 @@ fn a_waiting_process_runs_once_the_holder_releases() {
fn a_long_import_keeps_its_claim_alive() {
let repo = repo();
let now = chrono::Utc::now().timestamp_millis();
- // 90ms lease, body runs 400ms: without renewal a rival would take over.
+ // 600ms lease, body runs 1.6s: without renewal a rival would take over. The
+ // lease is long enough that a loaded machine starving the renewal thread for
+ // a few hundred ms does not read as a lapse.
let rival_repo = repo.clone();
- let rival_ran = with_claim_at(&repo, OWNER, "m", now, 90, || {
+ let rival_ran = with_claim_at(&repo, OWNER, "m", now, 600, || {
let mut took_over = false;
for _ in 0..8 {
- std::thread::sleep(std::time::Duration::from_millis(50));
+ std::thread::sleep(std::time::Duration::from_millis(200));
let at = chrono::Utc::now().timestamp_millis();
- took_over |= with_claim_at(&rival_repo, OWNER, "m", at, 90, || Ok(()))
+ took_over |= with_claim_at(&rival_repo, OWNER, "m", at, 600, || Ok(()))
.unwrap()
.is_some();
}