Skip to content

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

test(triage): cover monotonic clock and use wall clock in deferral tests

Steven Enamakelf0202e1d22c3
diff --git a/crates/openhuman-core/src/triage/evaluator/chain_tests.rs b/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
index b31cab24b1..0cfcce9003 100644
--- a/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
+++ b/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
@@ -8,6 +8,13 @@ fn dropped_attempt_releases_in_flight_state() {
assert!(begin_outage_attempt(Some(&state), "stub-cloud").is_some());
}
+#[test]
+fn monotonic_clock_does_not_move_backwards() {
+ let before = monotonic_ms();
+ let after = monotonic_ms();
+ assert!(after >= before);
+}
+
#[test]
fn only_one_initial_outage_attempt_can_be_in_flight() {
let state = new_retry_state();
diff --git a/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs b/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
index cadeaa035d..0f0d73cfb3 100644
--- a/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
+++ b/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
@@ -1,4 +1,10 @@
+use super::super::chain::record_outage;
use super::*;
+use tinyagents_harness::retry::{PersistentFailoverBreaker, PersistentFailoverBreakerConfig};
+
+fn wall_clock_ms() -> i64 {
+ chrono::Utc::now().timestamp_millis()
+}
#[test]
fn outage_backoff_is_exponential_and_has_terminal_limit() {
@@ -34,12 +40,10 @@ fn outage_failure_maps_to_deferred_then_terminal_host_outcomes() {
});
for failure in 1..=8 {
- let mut attempt = state
- .try_acquire("stub-cloud".to_string(), monotonic_ms())
- .expect("attempt");
- let before = now_ms();
+ let mut attempt = begin_outage_attempt(Some(&state), "stub-cloud").expect("attempt");
+ let before = wall_clock_ms();
let outcome = record_outage(Some(&mut attempt)).expect("host outcome");
- let after = now_ms();
+ let after = wall_clock_ms();
if failure < 8 {
match outcome {
TriageOutcome::Deferred {
@@ -269,15 +273,14 @@ async fn double_cloud_parse_failure_without_local_returns_terminal_not_err() {
#[tokio::test]
async fn in_flight_breaker_defers_before_dispatch_for_one_second() {
let state = new_retry_state();
- let attempt = state
- .try_acquire("stub-cloud:stub-cloud-model".to_string(), monotonic_ms())
- .expect("held attempt");
- let before = now_ms();
+ let attempt =
+ begin_outage_attempt(Some(&state), "stub-cloud:stub-cloud-model").expect("held attempt");
+ let before = wall_clock_ms();
let outcome = run_triage_with_arms_for_test_with_state(cloud_arm(), None, &envelope(), &state)
.await
.expect("deferred outcome");
- let after = now_ms();
+ let after = wall_clock_ms();
match outcome {
TriageOutcome::Deferred { defer_until_ms, .. } => {
diff --git a/scripts/ci/process-statics.json b/scripts/ci/process-statics.json
index 2c3937c90c..aa1eb0250d 100644
--- a/scripts/ci/process-statics.json
+++ b/scripts/ci/process-statics.json
@@ -219,6 +219,16 @@
"reason": "The in-memory provider is a workspace-keyed fallback routing handle; its AgentStores are selected with the caller's tenant session key, and an unusable workspace cannot read another workspace's provider.",
"verification": "storage/sessions/workspace_tests.rs: an_unusable_workspace_degrades_to_an_in_memory_store; storage/sessions/mod_tests.rs: two_profiles_default_agents_keep_separate_session_keys_and_stores; threads/ops/edit_tests.rs: a_profile_prefixed_key_round_trips_through_edit_and_regenerate"
},
+ {
+ "file": "crates/openhuman-core/src/triage/evaluator/chain.rs",
+ "scope": "",
+ "name": "TRIAGE_MONOTONIC_START",
+ "type": "OnceLock<Instant>",
+ "count": 1,
+ "category": "A",
+ "reason": "Provides one monotonic millisecond epoch for provider/model outage-breaker timestamps across all calls in the process; it stores no tenant or trigger data.",
+ "verification": "triage/evaluator/chain_tests.rs: monotonic_clock_does_not_move_backwards; triage/evaluator/chain_tests.rs: only_one_initial_outage_attempt_can_be_in_flight"
+ },
{
"file": "crates/openhuman-core/src/triage/evaluator/chain.rs",
"scope": "",