Skip to content

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

refactor(triage): drop unused retry state params from clear_outage

Steven Enamakel305d0f8f3699
diff --git a/crates/openhuman-core/src/triage/decision_tests.rs b/crates/openhuman-core/src/triage/decision_tests.rs
index ce190a32d7..399a2d97ce 100644
--- a/crates/openhuman-core/src/triage/decision_tests.rs
+++ b/crates/openhuman-core/src/triage/decision_tests.rs
@@ -80,9 +80,9 @@ fn prefers_last_fenced_block() {
}
#[test]
-fn corrected_unfenced_object_after_fence_is_selected() {
- let reply = "```json\n{\"action\":\"drop\",\"reason\":\"old\"}\n```\nCorrection: {\"action\":\"acknowledge\",\"reason\":\"corrected\"}";
+fn owner_relaxed_json_recovery_preserves_action_normalization() {
+ let reply = "{action: \"DROP\", reason: \"recovered\",}";
let decision = parse_triage_decision(reply).unwrap();
- assert_eq!(decision.action, TriageAction::Acknowledge);
- assert_eq!(decision.reason, "corrected");
+ assert_eq!(decision.action, TriageAction::Drop);
+ assert_eq!(decision.reason, "recovered");
}
diff --git a/crates/openhuman-core/src/triage/evaluator/chain.rs b/crates/openhuman-core/src/triage/evaluator/chain.rs
index b5d49bea0b..8a175a4216 100644
--- a/crates/openhuman-core/src/triage/evaluator/chain.rs
+++ b/crates/openhuman-core/src/triage/evaluator/chain.rs
@@ -163,11 +163,11 @@ where
// ── Cloud arm ──────────────────────────────────────────────────
match try_arm(&cloud, envelope, TriageResolutionPath::Cloud).await {
Ok(run) => {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
return Ok(TriageOutcome::Decision(run));
}
Err(ArmError::Fatal(err)) => {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
return Err(err);
}
Err(ArmError::BudgetExhausted(err)) => {
@@ -231,11 +231,11 @@ where
match try_arm(&cloud, envelope, TriageResolutionPath::CloudAfterRetry).await {
Ok(run) => {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
return Ok(TriageOutcome::Decision(run));
}
Err(ArmError::Fatal(err)) => {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
return Err(err);
}
Err(ArmError::BudgetExhausted(err)) => {
@@ -308,7 +308,7 @@ where
"cloud retry exhausted; local arm unavailable".to_string()
};
if cloud_budget_exhausted.is_some() || cloud_safety_flagged.is_some() {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
return Ok(TriageOutcome::Terminal { reason });
}
@@ -332,7 +332,7 @@ where
match try_arm(&local, envelope, TriageResolutionPath::LocalFallback).await {
Ok(run) => {
- clear_outage(retry_state, &retry_key, outage_attempt.as_mut());
+ clear_outage(outage_attempt.as_mut());
Ok(TriageOutcome::Decision(run))
}
Err(ArmError::Fatal(err))
@@ -381,11 +381,7 @@ fn now_ms() -> i64 {
chrono::Utc::now().timestamp_millis()
}
-fn clear_outage(
- _state: Option<&RetryState>,
- _key: &str,
- attempt: Option<&mut PersistentFailoverAttempt<String>>,
-) {
+fn clear_outage(attempt: Option<&mut PersistentFailoverAttempt<String>>) {
if let Some(attempt) = attempt {
attempt.record_success();
}
diff --git a/crates/openhuman-core/src/triage/evaluator/chain_tests.rs b/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
index 79569ae7ee..290ba23644 100644
--- a/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
+++ b/crates/openhuman-core/src/triage/evaluator/chain_tests.rs
@@ -22,7 +22,7 @@ fn unguarded_success_does_not_clear_another_in_flight_attempt() {
let state = new_retry_state();
let mut attempt = begin_outage_attempt(Some(&state), "stub-cloud").expect("attempt");
- clear_outage(Some(&state), "stub-cloud", None);
+ clear_outage(None);
assert!(begin_outage_attempt(Some(&state), "stub-cloud").is_none());
attempt.record_success();
@@ -33,7 +33,7 @@ fn stale_failure_after_concurrent_recovery_remains_deferred() {
let state = new_retry_state();
let mut attempt = begin_outage_attempt(Some(&state), "stub-cloud").expect("attempt");
- clear_outage(Some(&state), "stub-cloud", Some(&mut attempt));
+ clear_outage(Some(&mut attempt));
assert!(matches!(
record_outage(Some(&mut attempt)),
diff --git a/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs b/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
index 47bcea5b1e..610ff2eb8a 100644
--- a/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
+++ b/crates/openhuman-core/src/triage/evaluator_deferral_tests.rs
@@ -39,9 +39,28 @@ fn outage_failure_maps_to_deferred_then_terminal_host_outcomes() {
.expect("attempt");
let outcome = record_outage(Some(&mut attempt)).expect("host outcome");
if failure < 8 {
- assert!(matches!(outcome, TriageOutcome::Deferred { .. }));
+ match outcome {
+ TriageOutcome::Deferred {
+ defer_until_ms,
+ reason,
+ } => {
+ assert_eq!(reason, "managed backend outage; retry 0ms backoff");
+ assert!(defer_until_ms >= now_ms() - 50);
+ assert!(defer_until_ms <= now_ms() + 50);
+ }
+ TriageOutcome::Decision(_) | TriageOutcome::Terminal { .. } => {
+ panic!("failure {failure} should remain deferred")
+ }
+ }
} else {
- assert!(matches!(outcome, TriageOutcome::Terminal { .. }));
+ match outcome {
+ TriageOutcome::Terminal { reason } => {
+ assert!(reason.contains("retry limit (8)"));
+ }
+ TriageOutcome::Decision(_) | TriageOutcome::Deferred { .. } => {
+ panic!("failure 8 should reach the terminal limit")
+ }
+ }
}
}
}