Skip to content

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

style: apply rustfmt formatting across media and approval modules

Steven Enamakel6bd32f59ae4f
diff --git a/crates/openhuman-core/src/media/generation/artifact_tool.rs b/crates/openhuman-core/src/media/generation/artifact_tool.rs
index acc6c7843d..4cfcd5366e 100644
--- a/crates/openhuman-core/src/media/generation/artifact_tool.rs
+++ b/crates/openhuman-core/src/media/generation/artifact_tool.rs
@@ -295,7 +295,8 @@ impl<T: Tool> Tool for MediaArtifactTool<T> {
context,
label,
super::progress::HEARTBEAT_INTERVAL,
- self.inner.execute_with_context(args.clone(), options, context),
+ self.inner
+ .execute_with_context(args.clone(), options, context),
)
.await?;
if result.is_error {
diff --git a/crates/openhuman-core/src/media/generation/progress.rs b/crates/openhuman-core/src/media/generation/progress.rs
index b610d9ed68..37d099f337 100644
--- a/crates/openhuman-core/src/media/generation/progress.rs
+++ b/crates/openhuman-core/src/media/generation/progress.rs
@@ -40,7 +40,9 @@ pub(crate) fn video_status_observer() -> ProgressFn {
Arc::new(|status: &VideoJobStatus| {
let state = status.state.to_string();
let recorded = JOB_STATE.try_with(|slot| {
- *slot.lock().unwrap_or_else(std::sync::PoisonError::into_inner) = Some(state.clone());
+ *slot
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner) = Some(state.clone());
});
tracing::trace!(
job_state = %state,
diff --git a/crates/openhuman-core/src/media/generation/progress_tests.rs b/crates/openhuman-core/src/media/generation/progress_tests.rs
index a7564f20b7..62e07a51f1 100644
--- a/crates/openhuman-core/src/media/generation/progress_tests.rs
+++ b/crates/openhuman-core/src/media/generation/progress_tests.rs
@@ -30,7 +30,11 @@ fn status(state: JobState) -> VideoJobStatus {
#[test]
fn heartbeat_names_the_elapsed_time_and_job_state() {
assert_eq!(
- heartbeat_message("Generating video", Duration::from_secs(95), Some("in_progress")),
+ heartbeat_message(
+ "Generating video",
+ Duration::from_secs(95),
+ Some("in_progress")
+ ),
"Generating video — 1m 35s elapsed (job in_progress)"
);
assert_eq!(
@@ -50,9 +54,13 @@ async fn a_long_call_reports_progress_with_the_polled_job_state() {
tokio::time::sleep(Duration::from_secs(20)).await;
"clip.mp4"
};
- let output =
- with_progress_heartbeat(Some(&recorder), "Generating video", HEARTBEAT_INTERVAL, work)
- .await;
+ let output = with_progress_heartbeat(
+ Some(&recorder),
+ "Generating video",
+ HEARTBEAT_INTERVAL,
+ work,
+ )
+ .await;
assert_eq!(output, "clip.mp4");
let updates = recorder.updates.lock().unwrap().clone();
assert_eq!(
@@ -67,10 +75,15 @@ async fn a_long_call_reports_progress_with_the_polled_job_state() {
#[tokio::test(start_paused = true)]
async fn a_quick_call_reports_nothing() {
let recorder = Recorder::default();
- let output = with_progress_heartbeat(Some(&recorder), "Generating image", HEARTBEAT_INTERVAL, async {
- tokio::time::sleep(Duration::from_secs(3)).await;
- 1
- })
+ let output = with_progress_heartbeat(
+ Some(&recorder),
+ "Generating image",
+ HEARTBEAT_INTERVAL,
+ async {
+ tokio::time::sleep(Duration::from_secs(3)).await;
+ 1
+ },
+ )
.await;
assert_eq!(output, 1);
assert!(recorder.updates.lock().unwrap().is_empty());
diff --git a/crates/openhuman-core/src/security/approval/gate_intercept_decision.rs b/crates/openhuman-core/src/security/approval/gate_intercept_decision.rs
index 6eae5a8982..428b59462e 100644
--- a/crates/openhuman-core/src/security/approval/gate_intercept_decision.rs
+++ b/crates/openhuman-core/src/security/approval/gate_intercept_decision.rs
@@ -123,9 +123,7 @@ impl ApprovalGate {
let denied = store::decide(&self.config, request_id, ApprovalDecision::Deny);
let persisted = match &denied {
Ok(Some(_)) => Some(ApprovalDecision::Deny),
- Ok(None) => store::get_decision(&self.config, request_id)
- .ok()
- .flatten(),
+ Ok(None) => store::get_decision(&self.config, request_id).ok().flatten(),
Err(_) => None,
};
if matches!(persisted, Some(d) if d.is_approve()) {
@@ -165,7 +163,7 @@ impl ApprovalGate {
client_id: route.as_ref().and_then(|r| r.client_id.clone()),
tool_call_id: route.and_then(|r| r.tool_call_id),
resolution: Some("expired".to_string()),
- agent_id: row.agent_id.clone(),
+ agent_id: row.agent_id.clone(),
});
}
(
diff --git a/crates/openhuman-core/src/security/approval/gate_state.rs b/crates/openhuman-core/src/security/approval/gate_state.rs
index 3b73a4904e..7efd585369 100644
--- a/crates/openhuman-core/src/security/approval/gate_state.rs
+++ b/crates/openhuman-core/src/security/approval/gate_state.rs
@@ -40,12 +40,14 @@ impl ApprovalGate {
request_id: &str,
decision: ApprovalDecision,
) -> anyhow::Result<Option<PendingApproval>> {
- if !matches!(decision, ApprovalDecision::ApproveOnce | ApprovalDecision::Deny)
- && self
- .request_routes
- .lock()
- .get(request_id)
- .is_some_and(|route| route.forced)
+ if !matches!(
+ decision,
+ ApprovalDecision::ApproveOnce | ApprovalDecision::Deny
+ ) && self
+ .request_routes
+ .lock()
+ .get(request_id)
+ .is_some_and(|route| route.forced)
{
anyhow::bail!("this action requires a one-time approval or denial");
}
@@ -123,7 +125,8 @@ impl ApprovalGate {
let rows = store::list_pending_for_agent(&self.config, Some(agent))?;
let mut denied = 0;
for row in rows {
- let Some(decided) = store::decide(&self.config, &row.request_id, ApprovalDecision::Deny)?
+ let Some(decided) =
+ store::decide(&self.config, &row.request_id, ApprovalDecision::Deny)?
else {
continue;
};
@@ -288,7 +291,9 @@ impl ApprovalGate {
/// park time in `intercept_audited_inner`, alongside the `thread_to_request`
/// insert.
fn insert_request_route(&self, request_id: &str, route: RequestRoute) {
- self.request_routes.lock().insert(request_id.to_string(), route);
+ self.request_routes
+ .lock()
+ .insert(request_id.to_string(), route);
}
/// Remove and return the routing correlation for `request_id`, if any.
diff --git a/crates/openhuman-core/src/security/approval/gate_subagent_tests.rs b/crates/openhuman-core/src/security/approval/gate_subagent_tests.rs
index 025b2cca2c..425878505f 100644
--- a/crates/openhuman-core/src/security/approval/gate_subagent_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_subagent_tests.rs
@@ -26,11 +26,11 @@ async fn requested_event(
) -> crate::core::events::DomainEvent {
loop {
match rx.recv().await {
- Some(ref ev @ crate::core::events::DomainEvent::ApprovalRequested { ref tool_name, .. })
- if tool_name == tool =>
- {
- return ev.clone()
- }
+ Some(
+ ref ev @ crate::core::events::DomainEvent::ApprovalRequested {
+ ref tool_name, ..
+ },
+ ) if tool_name == tool => return ev.clone(),
Some(_) => continue,
None => panic!("the bus closed before the expected event arrived"),
}
@@ -97,10 +97,20 @@ async fn an_async_subagent_park_reaches_the_parent_thread_detached_with_a_short_
else {
unreachable!()
};
- assert_eq!(thread_id.as_deref(), Some("thread-parent"), "routed to the parent thread");
+ assert_eq!(
+ thread_id.as_deref(),
+ Some("thread-parent"),
+ "routed to the parent thread"
+ );
assert_eq!(client_id.as_deref(), Some("client-sub"));
- assert!(detached, "a park that can outlive its turn is marked detached");
- assert!(gate.request_is_detached(&request_id), "the replay path sees it too");
+ assert!(
+ detached,
+ "a park that can outlive its turn is marked detached"
+ );
+ assert!(
+ gate.request_is_detached(&request_id),
+ "the replay path sees it too"
+ );
let row = wait_parked(&gate).await;
assert!(
@@ -132,7 +142,8 @@ async fn an_inline_chat_park_is_not_detached_and_keeps_the_full_window() {
let handle = tokio::spawn(async move {
turn_origin::with_origin(
web_origin(),
- APPROVAL_CHAT_CONTEXT.scope(chat_ctx(), g.intercept(tool, "run", serde_json::json!({}))),
+ APPROVAL_CHAT_CONTEXT
+ .scope(chat_ctx(), g.intercept(tool, "run", serde_json::json!({}))),
)
.await
});
@@ -202,7 +213,11 @@ async fn an_expired_park_tells_the_model_nobody_answered() {
let handle = tokio::spawn(async move {
turn_origin::with_origin(
async_subagent_origin("thread-expiry"),
- g.intercept("media_generate_video", "generate a clip", serde_json::json!({})),
+ g.intercept(
+ "media_generate_video",
+ "generate a clip",
+ serde_json::json!({}),
+ ),
)
.await
});