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
style(flows): apply rustfmt formatting to flow run modules
Steven Enamakel736002f934d9
diff --git a/crates/openhuman-core/src/flows/bus_subscriber_tests.rs b/crates/openhuman-core/src/flows/bus_subscriber_tests.rsindex c2ad08b8b4..82c34de170 100644--- a/crates/openhuman-core/src/flows/bus_subscriber_tests.rs+++ b/crates/openhuman-core/src/flows/bus_subscriber_tests.rs@@ -406,4 +406,3 @@ fn render_run_digest_is_bounded_and_includes_key_fields() {assert!(digest.contains("n1"));assert!(digest.chars().count() <= DIGEST_MAX_CHARS);}-diff --git a/crates/openhuman-core/src/flows/ops.rs b/crates/openhuman-core/src/flows/ops.rsindex 1a6589e56d..89de8252d9 100644--- a/crates/openhuman-core/src/flows/ops.rs+++ b/crates/openhuman-core/src/flows/ops.rs@@ -42,18 +42,16 @@ use tinyflows::triggers::graph_trigger_warnings;// do at all are properties of the graph, not of this host. Re-exported at// `ops::` scope because the agent tools and this module's tests already name// them there.-pub(crate) use tinyflows_catalog::graph_policy::{- enforce_side_effect_approval, graph_has_actionable_nodes, trigger_is_automatic,-};use crate::config::Config;use crate::core::Outcome;use crate::flows::bus;use crate::flows::draft_store;use crate::flows::store;use tinyflows_catalog::build_registry;-use tinyflows_catalog::types::{- FlowConnection, FlowRunTrigger, FlowSuggestion, SuggestionStatus,+pub(crate) use tinyflows_catalog::graph_policy::{+ enforce_side_effect_approval, graph_has_actionable_nodes, trigger_is_automatic,};+use tinyflows_catalog::types::{FlowConnection, FlowRunTrigger, FlowSuggestion, SuggestionStatus};use {tinyflows_catalog::Flow, tinyflows_catalog::FlowRun};/// Overall safety bound on a single `flows_run` / `flows_resume`. Individual@@ -149,11 +147,11 @@ pub use connections::*;pub use definitions::*;pub use discovery::*;pub use drafts::*;+pub(crate) use execution::{export_run_to_langfuse, notify_pending_approval};pub(crate) use inference_readiness::*;pub use resume::*;pub use run::*;pub use run_management::*;-pub(crate) use execution::{export_run_to_langfuse, notify_pending_approval};pub use streaming::*;use trail_off::*;pub use triggers::*;diff --git a/crates/openhuman-core/src/flows/ops/execution.rs b/crates/openhuman-core/src/flows/ops/execution.rsindex 7cf7a983d1..5e8d1a5212 100644--- a/crates/openhuman-core/src/flows/ops/execution.rs+++ b/crates/openhuman-core/src/flows/ops/execution.rs@@ -57,7 +57,11 @@ pub(crate) fn notify_pending_approval(flow: &Flow, run_id: &str, pending_approva"\"{}\" is waiting on {} approval{} before it can continue.",flow.name,pending_approvals.len(),- if pending_approvals.len() == 1 { "" } else { "s" }+ if pending_approvals.len() == 1 {+ ""+ } else {+ "s"+ }),deep_link: None,timestamp_ms: now_ms(),diff --git a/crates/openhuman-core/src/flows/ops/resume.rs b/crates/openhuman-core/src/flows/ops/resume.rsindex 3435e3b020..f263d2b9f7 100644--- a/crates/openhuman-core/src/flows/ops/resume.rs+++ b/crates/openhuman-core/src/flows/ops/resume.rs@@ -48,13 +48,8 @@ pub async fn flows_resume(rejections,timeout_ms: FLOW_RUN_TIMEOUT_SECS.saturating_mul(1_000),};- let resumed = crate::flows::runs_adapter::resume_and_wait(- ctx,- config,- request,- bindings,- )- .await?;+ let resumed =+ crate::flows::runs_adapter::resume_and_wait(ctx, config, request, bindings).await?;tracing::info!(target: "flows",diff --git a/crates/openhuman-core/src/flows/ops/run.rs b/crates/openhuman-core/src/flows/ops/run.rsindex ede536989a..e53545045d 100644--- a/crates/openhuman-core/src/flows/ops/run.rs+++ b/crates/openhuman-core/src/flows/ops/run.rs@@ -23,12 +23,8 @@ pub async fn flows_run(trigger,).await?;- let result = crate::flows::runs_adapter::wait_for_outcome(- &mut events,- &prepared.run_id,- 0,- )- .await?;+ let result =+ crate::flows::runs_adapter::wait_for_outcome(&mut events, &prepared.run_id, 0).await?;drop(session);Ok(run_outcome(result, prepared.no_actionable_nodes))}@@ -128,10 +124,9 @@ pub(super) async fn prepare_flow_run().await.map_err(|error| error.wire_message())?;- let flow: Flow = store::roundtrip(- workflow.ok_or_else(|| format!("flow '{flow_id}' not found"))?,- )- .map_err(|error| format!("decode workflow for run: {error}"))?;+ let flow: Flow =+ store::roundtrip(workflow.ok_or_else(|| format!("flow '{flow_id}' not found"))?)+ .map_err(|error| format!("decode workflow for run: {error}"))?;let no_actionable_nodes = !graph_has_actionable_nodes(&flow.graph);if no_actionable_nodes {tracing::warn!(diff --git a/crates/openhuman-core/src/flows/ops/run_management.rs b/crates/openhuman-core/src/flows/ops/run_management.rsindex a336b5bd98..575332d641 100644--- a/crates/openhuman-core/src/flows/ops/run_management.rs+++ b/crates/openhuman-core/src/flows/ops/run_management.rs@@ -1,7 +1,7 @@use super::*;-use tinyflows_catalog::run_management as rm;use tinyflows_bus::catalog::{self as wire, FlowRun as WireFlowRun};+use tinyflows_catalog::run_management as rm;/// Cancel a workflow run through its owner-scoped Runs.CancelRun operation.pub async fn flows_cancel_run(config: &Config, run_id: &str) -> Result<Outcome<Value>, String> {@@ -153,11 +153,7 @@ async fn get_run_with_storage(.map_err(|error| error.to_string())}-async fn catalog_call<T, A>(- config: &Config,- member: &'static str,- args: A,-) -> Result<T, String>+async fn catalog_call<T, A>(config: &Config, member: &'static str, args: A) -> Result<T, String>whereT: serde::de::DeserializeOwned + Send + 'static,A: serde::Serialize + Send + 'static,diff --git a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rsindex 94a8e6ceb1..40561cdea2 100644--- a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs+++ b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs@@ -52,7 +52,9 @@ async fn flows_resume_succeeds_when_the_graph_is_unchanged() {.collect();assert_eq!(response_keys,- ["output", "pending_approvals", "thread_id"].into_iter().collect(),+ ["output", "pending_approvals", "thread_id"]+ .into_iter()+ .collect(),"ResumeRun's internal admission acknowledgement must not change the public RPC shape");assert_eq!(resumed.value["pending_approvals"], json!([]));diff --git a/crates/openhuman-core/src/flows/runs_adapter.rs b/crates/openhuman-core/src/flows/runs_adapter.rsindex f2a3091215..f4b71913f4 100644--- a/crates/openhuman-core/src/flows/runs_adapter.rs+++ b/crates/openhuman-core/src/flows/runs_adapter.rs@@ -10,14 +10,14 @@ mod session;use std::sync::Arc;-use serde_json::{Value, json};+use serde_json::{json, Value};use tinyflows_bus::runs::{self, ResumeRun, StartRun};-use tinyflows_catalog::{Flow, types::FlowRunTrigger};+use tinyflows_catalog::{types::FlowRunTrigger, Flow};use crate::config::Config;use crate::core::runtime::DispatchCtx;-use crate::flows::catalog_storage::{self, CatalogStorageRegistration};use crate::flows::caps_host::{self, CapsHostRegistration};+use crate::flows::catalog_storage::{self, CatalogStorageRegistration};use crate::modules::tinyflows as module;const RUN_TIMEOUT_MS: u64 = 600_000;@@ -117,7 +117,13 @@ pub(crate) async fn start_run(input: Value,inputs: serde_json::Map<String, Value>,trigger: FlowRunTrigger,-) -> Result<(Arc<RunSession>, tokio::sync::mpsc::UnboundedReceiver<runs::RunEvent>), String> {+) -> Result<+ (+ Arc<RunSession>,+ tokio::sync::mpsc::UnboundedReceiver<runs::RunEvent>,+ ),+ String,+> {let bindings = register_bindings(ctx, config, flow, run_id).await?;let session = RunSession::new(Arc::clone(&bindings),@@ -152,19 +158,17 @@ pub(crate) async fn start_run(inputs,timeout_ms: RUN_TIMEOUT_MS,};- let started: runs::StartRunResponse = match proxy- .call(runs::methods::START_RUN, (request,))- .await- {- Ok(started) => started,- Err(error) => {- match run_exists(config, bindings.storage(), run_id).await {- Ok(true) | Err(_) => session.start_polling(proxy),- Ok(false) => session::remove(&session),+ let started: runs::StartRunResponse =+ match proxy.call(runs::methods::START_RUN, (request,)).await {+ Ok(started) => started,+ Err(error) => {+ match run_exists(config, bindings.storage(), run_id).await {+ Ok(true) | Err(_) => session.start_polling(proxy),+ Ok(false) => session::remove(&session),+ }+ return Err(error.wire_message());}- return Err(error.wire_message());- }- };+ };if started.run_id != run_id {session::remove(&session);return Err("TinyFlows admitted a different run id".to_string());@@ -197,9 +201,9 @@ pub(crate) async fn wait_for_outcome(.map_err(|error| format!("decode parked run outcome: {error}"))?;return Ok(RunOutcome {run_id: run_id.to_owned(),- output: parked.output.ok_or_else(|| {- "TinyFlows omitted the parked engine outcome".to_string()- })?,+ output: parked+ .output+ .ok_or_else(|| "TinyFlows omitted the parked engine outcome".to_string())?,pending_approvals: parked.pending_approvals,status: "pending_approval".into(),});@@ -240,7 +244,9 @@ pub(crate) async fn register_resume_bindings(.map_err(|error| error.wire_message())?;let run = run.ok_or_else(|| format!("flow run '{run_id}' not found"))?;if run.flow_id != flow_id {- return Err(format!("flow run '{run_id}' does not belong to flow '{flow_id}'"));+ return Err(format!(+ "flow run '{run_id}' does not belong to flow '{flow_id}'"+ ));}if run.status != "pending_approval" {return Err(format!("flow run '{run_id}' is not waiting for approval"));@@ -263,7 +269,9 @@ pub(crate) async fn register_resume_bindings(if let Some(session) = session::get(&catalog.storage(), run_id) {if session.flow_id() != flow_id {- return Err(format!("flow run '{run_id}' is bound to a different workflow"));+ return Err(format!(+ "flow run '{run_id}' is bound to a different workflow"+ ));}}register_with_catalog(ctx, config, &flow, run_id, catalog).await@@ -333,7 +341,7 @@ pub(crate) async fn resume_and_wait(session.replace_flow(candidate.flow.clone()).await;session.set_trigger(FlowRunTrigger::Resume);session.mark_resumed();- session.replace_bindings(candidate);+ session.replace_bindings(candidate);session.start_polling(proxy);wait_for_outcome(&mut receiver, &request.run_id, baseline).await}@@ -471,10 +479,7 @@ pub(crate) async fn after_recovery(Ok(())}-fn finished_outcome(- finished: runs::RunFinished,- run_id: &str,-) -> Result<RunOutcome, String> {+fn finished_outcome(finished: runs::RunFinished, run_id: &str) -> Result<RunOutcome, String> {if finished.timed_out {return Err(finished.error@@ -489,10 +494,12 @@ fn finished_outcome(});}let output = finished.output.ok_or_else(|| {- finished- .error- .clone()- .unwrap_or_else(|| format!("flow run ended as {} without an engine outcome", finished.status))+ finished.error.clone().unwrap_or_else(|| {+ format!(+ "flow run ended as {} without an engine outcome",+ finished.status+ )+ })})?;Ok(RunOutcome {run_id: run_id.to_owned(),diff --git a/crates/openhuman-core/src/flows/runs_adapter/projection.rs b/crates/openhuman-core/src/flows/runs_adapter/projection.rsindex f330ca932d..d84974e6dc 100644--- a/crates/openhuman-core/src/flows/runs_adapter/projection.rs+++ b/crates/openhuman-core/src/flows/runs_adapter/projection.rs@@ -43,16 +43,16 @@ pub(super) async fn project(session: &RunSession, event: &RunEvent) {publish_step(session, node_id, status);}}- "graph_observation" => match serde_json::from_value::<tinyagents_graph::GraphObservation>(- event.data.clone(),- ) {- Ok(observation) => session.add_observation(observation),- Err(_) => tracing::warn!(- target: "flows",- run_id = %session.run_id,- "[flows] PollRun graph observation could not be decoded for Langfuse"- ),- },+ "graph_observation" => {+ match serde_json::from_value::<tinyagents_graph::GraphObservation>(event.data.clone()) {+ Ok(observation) => session.add_observation(observation),+ Err(_) => tracing::warn!(+ target: "flows",+ run_id = %session.run_id,+ "[flows] PollRun graph observation could not be decoded for Langfuse"+ ),+ }+ }"agent_progress" => {// Detailed agent events remain on the module stream. The OpenHuman// workflow overlay consumes the node-level progress events above.diff --git a/crates/openhuman-core/src/flows/runs_adapter/session.rs b/crates/openhuman-core/src/flows/runs_adapter/session.rsindex 630d78f2dc..0278031801 100644--- a/crates/openhuman-core/src/flows/runs_adapter/session.rs+++ b/crates/openhuman-core/src/flows/runs_adapter/session.rs@@ -5,12 +5,12 @@ use std::sync::{Arc, LazyLock, Mutex};use std::time::Duration;use tinyflows_bus::runs::{self, RunEvent};-use tinyflows_catalog::{Flow, types::FlowRunTrigger};+use tinyflows_catalog::{types::FlowRunTrigger, Flow};use crate::config::Config;use crate::modules::tinyflows as module;-use super::{RunBindings, projection};+use super::{projection, RunBindings};#[derive(Clone, Debug, Eq, Hash, PartialEq)]pub(crate) struct RunKey {@@ -158,25 +158,29 @@ impl RunSession {}pub(super) fn mark_started(&self) -> bool {- self.live_actor.store(true, std::sync::atomic::Ordering::Release);+ self.live_actor+ .store(true, std::sync::atomic::Ordering::Release);!self.started_event.swap(true, std::sync::atomic::Ordering::AcqRel)}pub(super) fn mark_finished(&self) -> bool {- self.live_actor.store(false, std::sync::atomic::Ordering::Release);+ self.live_actor+ .store(false, std::sync::atomic::Ordering::Release);!self.finished_event.swap(true, std::sync::atomic::Ordering::AcqRel)}pub(super) fn mark_parked(&self) {- self.live_actor.store(false, std::sync::atomic::Ordering::Release);+ self.live_actor+ .store(false, std::sync::atomic::Ordering::Release);}pub(super) fn mark_resumed(&self) {- self.live_actor.store(true, std::sync::atomic::Ordering::Release);+ self.live_actor+ .store(true, std::sync::atomic::Ordering::Release);}pub(super) fn is_live_actor(&self) -> bool {@@ -226,7 +230,11 @@ impl RunSession {/// and the background projector from reading and publishing one sequence/// twice. `project=false` is used only to prime a process-restarted parked/// run before admitting its resume.- pub(super) async fn drain(&self, proxy: &tinybus::Proxy, project: bool) -> Result<bool, String> {+ pub(super) async fn drain(+ &self,+ proxy: &tinybus::Proxy,+ project: bool,+ ) -> Result<bool, String> {let _poll = self.poll_lock.lock().await;loop {let cursor = self.cursor();@@ -278,13 +286,19 @@ pub(crate) fn insert(session: Arc<RunSession>) -> Result<(), String> {.lock().unwrap_or_else(std::sync::PoisonError::into_inner);if sessions.contains_key(&key) {- return Err(format!("flow run '{}' already has a host session", session.run_id));+ return Err(format!(+ "flow run '{}' already has a host session",+ session.run_id+ ));}sessions.insert(key, session);Ok(())}-pub(crate) fn get(storage: &tinyflows_bus::catalog::CatalogStorage, run_id: &str) -> Option<Arc<RunSession>> {+pub(crate) fn get(+ storage: &tinyflows_bus::catalog::CatalogStorage,+ run_id: &str,+) -> Option<Arc<RunSession>> {SESSIONS.lock().unwrap_or_else(std::sync::PoisonError::into_inner)@@ -308,4 +322,3 @@ pub(crate) fn remove(session: &Arc<RunSession>) {sessions.remove(&key);}}-diff --git a/crates/openhuman-core/src/flows/runs_adapter_tests.rs b/crates/openhuman-core/src/flows/runs_adapter_tests.rsindex 82d0874fe8..50f531be9c 100644--- a/crates/openhuman-core/src/flows/runs_adapter_tests.rs+++ b/crates/openhuman-core/src/flows/runs_adapter_tests.rs@@ -20,7 +20,10 @@ fn failed_graph_with_engine_output_keeps_the_legacy_success_payload() {.expect("an engine RunOutcome remains the legacy RPC payload, even for failed status");assert_eq!(outcome.run_id, "flow:example:run");- assert_eq!(outcome.output, json!({"partial": [1, 2], "nodes": {"node": "result"}}));+ assert_eq!(+ outcome.output,+ json!({"partial": [1, 2], "nodes": {"node": "result"}})+ );assert!(outcome.pending_approvals.is_empty());assert_eq!(outcome.status, "failed");}