Skip to content

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

chore(flows): reformat module declarations and call sites

Steven Enamakel1bbd1670c5d8
diff --git a/crates/openhuman-core/src/flows/catalog_storage.rs b/crates/openhuman-core/src/flows/catalog_storage.rs
index d1cf424145..db6b931db0 100644
--- a/crates/openhuman-core/src/flows/catalog_storage.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage.rs
@@ -76,8 +76,9 @@ impl CatalogStorageRegistration {
}
}
-static REGISTRATIONS: LazyLock<tokio::sync::Mutex<HashMap<RegistrationKey, Arc<CatalogStorageRegistration>>>> =
- LazyLock::new(|| tokio::sync::Mutex::new(HashMap::new()));
+static REGISTRATIONS: LazyLock<
+ tokio::sync::Mutex<HashMap<RegistrationKey, Arc<CatalogStorageRegistration>>>,
+> = LazyLock::new(|| tokio::sync::Mutex::new(HashMap::new()));
#[cfg(test)]
struct RegistrationGate {
@@ -126,11 +127,9 @@ pub(crate) async fn register(
return Ok(Arc::clone(registration));
}
- let served = module::serve_registered(
- path.clone(),
- CatalogStoragePort { scope: documents },
- )
- .await?;
+ let served =
+ module::serve_registered(path.clone(), CatalogStoragePort { scope: documents })
+ .await?;
#[cfg(test)]
record_served(&path);
#[cfg(test)]
@@ -220,17 +219,8 @@ const COLLECTIONS: [&str; 16] = [
"tsd.migrations",
];
-const SHARED_COLLECTIONS: [&str; 4] = [
- "tsd.kv",
- "tsd.leases",
- "tsd.counters",
- "tsd.migrations",
-];
-const GRAPH_COLLECTIONS: [&str; 3] = [
- "graph.checkpoints",
- "graph.threads",
- "graph.writes",
-];
+const SHARED_COLLECTIONS: [&str; 4] = ["tsd.kv", "tsd.leases", "tsd.counters", "tsd.migrations"];
+const GRAPH_COLLECTIONS: [&str; 3] = ["graph.checkpoints", "graph.threads", "graph.writes"];
const FLOW_KEY_PREFIX: &str = "flows/";
const FLOW_MIGRATION_IDS: [&str; 6] = [
"flows/flows.definitions/definitions_v2",
@@ -288,13 +278,15 @@ fn flow_namespace_filter(collection: &str, filter: Filter) -> Filter {
}
fn encoded<T: Serialize>(value: T) -> Result<Value, StorageError> {
- serde_json::to_value(value)
- .map_err(|error| StorageError::invalid_input(format!("catalog value encoding failed: {error}")))
+ serde_json::to_value(value).map_err(|error| {
+ StorageError::invalid_input(format!("catalog value encoding failed: {error}"))
+ })
}
fn decoded<T: serde::de::DeserializeOwned>(value: Value) -> Result<T, StorageError> {
- serde_json::from_value(value)
- .map_err(|error| StorageError::invalid_input(format!("catalog value decoding failed: {error}")))
+ serde_json::from_value(value).map_err(|error| {
+ StorageError::invalid_input(format!("catalog value decoding failed: {error}"))
+ })
}
fn catalog_error(error: StorageError) -> CatalogStorageReply {
@@ -320,13 +312,14 @@ struct CatalogStoragePort {
#[tinybus::interface(name = "ai.tinyhumans.tinyflows.CatalogStorage")]
impl CatalogStoragePort {
async fn doc_capabilities(&self) -> BusResult<CatalogStorageReply> {
- let result = self.scope.documents().map(|documents| {
- catalog::CatalogStorageCapabilities {
+ let result = self
+ .scope
+ .documents()
+ .map(|documents| catalog::CatalogStorageCapabilities {
record_metadata: documents
.capabilities()
.contains(Capability::RecordMetadata),
- }
- });
+ });
Ok(catalog_reply(result))
}
diff --git a/crates/openhuman-core/src/flows/catalog_storage_tests.rs b/crates/openhuman-core/src/flows/catalog_storage_tests.rs
index d331145a0c..6d014f89e9 100644
--- a/crates/openhuman-core/src/flows/catalog_storage_tests.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage_tests.rs
@@ -6,15 +6,15 @@ fn context(config: &Config, profile: &str) -> DispatchCtx {
use crate::tools::toolpacks::ToolGroups;
let root = CoreContext::for_test_with_config(DomainSet::full(), config.clone());
- DispatchCtx::new(root.derive_with(
- ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::default())
- .profile(profile),
- ))
+ DispatchCtx::new(
+ root.derive_with(
+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::default())
+ .profile(profile),
+ ),
+ )
}
-async fn callback_proxy(
- registration: &CatalogStorageRegistration,
-) -> tinybus::Proxy {
+async fn callback_proxy(registration: &CatalogStorageRegistration) -> tinybus::Proxy {
let runtime = crate::modules::runtime::runtime()
.await
.expect("module runtime is available");
@@ -56,8 +56,14 @@ fn document_records_cannot_address_other_shared_or_graph_keys() {
"graph.threads",
"graph.writes",
] {
- assert!(allowed_record(collection, "other-owner/key").is_err(), "{collection}");
- assert!(allowed_record(collection, "flows/thread/checkpoint").is_ok(), "{collection}");
+ assert!(
+ allowed_record(collection, "other-owner/key").is_err(),
+ "{collection}"
+ );
+ assert!(
+ allowed_record(collection, "flows/thread/checkpoint").is_ok(),
+ "{collection}"
+ );
}
for (collection, id) in [
("tsd.migrations", "other/definitions_v2"),
@@ -74,17 +80,11 @@ fn graph_query_and_delete_filters_are_confined_to_the_flows_namespace() {
assert!(all.matches("flows/thread/1", &json!({"ns":"flows"})));
assert!(!all.matches("other/thread/1", &json!({"ns":"other"})));
- let conflicting = flow_namespace_filter(
- "graph.writes",
- Filter::eq("ns", "other"),
- );
+ let conflicting = flow_namespace_filter("graph.writes", Filter::eq("ns", "other"));
assert!(!conflicting.matches("flows/thread/1", &json!({"ns":"flows"})));
assert!(!conflicting.matches("other/thread/1", &json!({"ns":"other"})));
- let widened = flow_namespace_filter(
- "graph.threads",
- Filter::one_of("ns", ["flows", "other"]),
- );
+ let widened = flow_namespace_filter("graph.threads", Filter::one_of("ns", ["flows", "other"]));
assert!(widened.matches("flows/thread", &json!({"ns":"flows"})));
assert!(!widened.matches("other/thread", &json!({"ns":"other"})));
}
@@ -146,11 +146,7 @@ async fn cancelling_the_caller_after_serve_keeps_one_cached_registration() {
.expect("module runtime remains available");
let proxy = runtime
.connection()
- .proxy(
- module::HOST_BUS_NAME,
- &path,
- catalog::STORAGE_INTERFACE,
- )
+ .proxy(module::HOST_BUS_NAME, &path, catalog::STORAGE_INTERFACE)
.expect("storage callback address is valid");
let reply: CatalogStorageReply = proxy
.call(catalog::storage::CAPABILITIES, &())
@@ -260,15 +256,11 @@ async fn catalog_module_uses_captured_profile_and_storage_preserves_cas_metadata
CatalogStorageReply::Error { ref error } if error.kind == "conflict"
));
- let foreign: CatalogStorageReply = bob_bus
- .call(catalog::storage::GET, &(get,))
- .await
- .unwrap();
+ let foreign: CatalogStorageReply = bob_bus.call(catalog::storage::GET, &(get,)).await.unwrap();
assert!(matches!(
foreign,
CatalogStorageReply::Value { value } if value.is_null()
));
-
}
#[tokio::test]
@@ -373,7 +365,10 @@ async fn catalog_storage_resolves_the_current_backend_and_confines_graph_namespa
.get("graph.threads", "other/bob-thread")
.await
.unwrap();
- assert!(foreign.is_some(), "flow deletion leaves the other namespace intact");
+ assert!(
+ foreign.is_some(),
+ "flow deletion leaves the other namespace intact"
+ );
let forbidden_get: CatalogStorageReply = proxy
.call(
@@ -421,5 +416,8 @@ async fn catalog_storage_resolves_the_current_backend_and_confines_graph_namespa
rebound,
CatalogStorageReply::Value { ref value } if value.is_null()
));
- assert_eq!(registration.address.object_path, registration.storage().callback.object_path);
+ assert_eq!(
+ registration.address.object_path,
+ registration.storage().callback.object_path
+ );
}
diff --git a/crates/openhuman-core/src/flows/draft_store.rs b/crates/openhuman-core/src/flows/draft_store.rs
index 7301a0f240..a0625ef0bc 100644
--- a/crates/openhuman-core/src/flows/draft_store.rs
+++ b/crates/openhuman-core/src/flows/draft_store.rs
@@ -40,11 +40,8 @@ pub fn get_draft(config: &Config, id: &str) -> Result<Option<FlowDraft>> {
storage,
id: id.to_owned(),
};
- let draft: Option<WireDraft> = store::call_catalog(
- config,
- catalog::members::GET_DRAFT,
- (request,),
- )?;
+ let draft: Option<WireDraft> =
+ store::call_catalog(config, catalog::members::GET_DRAFT, (request,))?;
draft.map(store::roundtrip).transpose()
}
diff --git a/crates/openhuman-core/src/flows/mod.rs b/crates/openhuman-core/src/flows/mod.rs
index 01bd1db74e..802bd8d763 100644
--- a/crates/openhuman-core/src/flows/mod.rs
+++ b/crates/openhuman-core/src/flows/mod.rs
@@ -29,6 +29,8 @@ pub mod builder_host;
pub(crate) mod builder_tools;
mod builder_tools_connection_reads;
pub mod bus;
+pub(crate) mod caps_host;
+pub(crate) mod catalog_storage;
pub mod catalogue;
mod copilot_bus;
mod draft_store;
diff --git a/crates/openhuman-core/src/flows/store.rs b/crates/openhuman-core/src/flows/store.rs
index 8ea7f900f6..bcc532a5d3 100644
--- a/crates/openhuman-core/src/flows/store.rs
+++ b/crates/openhuman-core/src/flows/store.rs
@@ -15,8 +15,7 @@ use tinyflows_bus::catalog::{
SetEnabledRequest, Workflow, WorkflowRevision,
};
use tinyflows_catalog::{
- Flow, FlowRevision, FlowSuggestion, SuggestionStatus,
- store::FlowUpdateError,
+ Flow, FlowRevision, FlowSuggestion, SuggestionStatus, store::FlowUpdateError,
};
use crate::config::Config;
@@ -59,7 +58,6 @@ fn flow_from_wire(workflow: Workflow) -> Result<Flow> {
})
}
-
pub(crate) fn roundtrip<T, U>(value: T) -> Result<U>
where
T: Serialize,
@@ -99,11 +97,8 @@ pub fn upsert_flow(config: &Config, flow: &Flow) -> Result<()> {
#[cfg(test)]
fn test_seed_flow(config: &Config, flow: &Flow) -> Result<()> {
let storage = super::catalog_storage::register_blocking(config)?;
- let _: ListWorkflowsResult = call_catalog(
- config,
- catalog::members::LIST_WORKFLOWS,
- (storage.clone(),),
- )?;
+ let _: ListWorkflowsResult =
+ call_catalog(config, catalog::members::LIST_WORKFLOWS, (storage.clone(),))?;
let created_ms = chrono::DateTime::parse_from_rfc3339(&flow.created_at)
.map(|date| date.timestamp_millis())
.unwrap_or(0);
@@ -137,11 +132,7 @@ fn test_seed_flow(config: &Config, flow: &Flow) -> Result<()> {
expires_ms: None,
created_ms: Some(created_ms),
};
- let _: catalog::CatalogStorageReply = call_catalog(
- config,
- catalog::storage::PUT,
- (request,),
- )?;
+ let _: catalog::CatalogStorageReply = call_catalog(config, catalog::storage::PUT, (request,))?;
Ok(())
}
@@ -153,7 +144,8 @@ pub fn insert_duplicate_flow(config: &Config, source: &Flow, new_name: String) -
id: source.id.clone(),
name: new_name,
};
- let response: PutWorkflowResponse = call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
+ let response: PutWorkflowResponse =
+ call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
put_result(response)
}
@@ -172,7 +164,8 @@ pub fn create_flow(
graph: serde_json::to_value(graph)?,
require_approval,
};
- let response: PutWorkflowResponse = call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
+ let response: PutWorkflowResponse =
+ call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))?;
let flow = put_result(response)?;
if !enabled && flow.enabled {
set_enabled(config, &flow.id, false)
@@ -195,11 +188,8 @@ pub fn get_flow(config: &Config, id: &str) -> Result<Option<Flow>> {
/// List workflows and their full graphs through the module's catalog client.
pub fn list_flows(config: &Config) -> Result<(Vec<Flow>, usize)> {
let storage = super::catalog_storage::register_blocking(config)?;
- let listed: ListWorkflowsResult = call_catalog(
- config,
- catalog::members::LIST_WORKFLOWS,
- (storage.clone(),),
- )?;
+ let listed: ListWorkflowsResult =
+ call_catalog(config, catalog::members::LIST_WORKFLOWS, (storage.clone(),))?;
let mut flows = Vec::with_capacity(listed.workflows.len());
let mut skipped = listed.skipped_rows;
for summary in listed.workflows {
@@ -223,7 +213,10 @@ pub fn list_flows(config: &Config) -> Result<(Vec<Flow>, usize)> {
/// List enabled workflows through the same module-owned catalog surface.
pub fn list_enabled_flows(config: &Config) -> Result<(Vec<Flow>, usize)> {
let (flows, skipped) = list_flows(config)?;
- Ok((flows.into_iter().filter(|flow| flow.enabled).collect(), skipped))
+ Ok((
+ flows.into_iter().filter(|flow| flow.enabled).collect(),
+ skipped,
+ ))
}
/// Remove a workflow through the module's Catalog contract.
@@ -273,8 +266,9 @@ pub fn update_flow_graph(
expected_version: expected_updated_at.map(str::to_owned),
force_disarm_automatic: force_disarm_if_automatic,
};
- let response: PutWorkflowResponse = call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))
- .map_err(FlowUpdateError::Store)?;
+ let response: PutWorkflowResponse =
+ call_catalog(config, catalog::members::PUT_WORKFLOW, (request,))
+ .map_err(FlowUpdateError::Store)?;
match response {
PutWorkflowResponse::Ok(result) => {
flow_from_wire(result.workflow).map_err(FlowUpdateError::Store)
@@ -291,15 +285,9 @@ pub fn list_revisions(config: &Config, flow_id: &str, limit: usize) -> Result<Ve
flow_id: flow_id.to_owned(),
limit,
};
- let revisions: Vec<WorkflowRevision> = call_catalog(
- config,
- catalog::members::LIST_REVISIONS,
- (request,),
- )?;
- revisions
- .into_iter()
- .map(roundtrip)
- .collect()
+ let revisions: Vec<WorkflowRevision> =
+ call_catalog(config, catalog::members::LIST_REVISIONS, (request,))?;
+ revisions.into_iter().map(roundtrip).collect()
}
/// Read one workflow revision by id.
@@ -314,14 +302,9 @@ pub fn revision_by_id(
flow_id: flow_id.to_owned(),
revision_id: revision_id.to_owned(),
};
- let revision: Option<WorkflowRevision> = call_catalog(
- config,
- catalog::members::GET_REVISION,
- (request,),
- )?;
- revision
- .map(roundtrip)
- .transpose()
+ let revision: Option<WorkflowRevision> =
+ call_catalog(config, catalog::members::GET_REVISION, (request,))?;
+ revision.map(roundtrip).transpose()
}
/// Upsert module-owned discovery suggestions.
@@ -346,9 +329,7 @@ pub fn list_suggestions(
limit: usize,
) -> Result<Vec<FlowSuggestion>> {
let storage = super::catalog_storage::register_blocking(config)?;
- let status: Option<catalog::SuggestionStatus> = status
- .map(roundtrip)
- .transpose()?;
+ let status: Option<catalog::SuggestionStatus> = status.map(roundtrip).transpose()?;
let request = catalog::ListSuggestionsRequest {
storage,
status,
@@ -356,18 +337,11 @@ pub fn list_suggestions(
};
let suggestions: Vec<catalog::FlowSuggestion> =
call_catalog(config, catalog::members::LIST_SUGGESTIONS, (request,))?;
- suggestions
- .into_iter()
- .map(roundtrip)
- .collect()
+ suggestions.into_iter().map(roundtrip).collect()
}
/// Set a suggestion's module-owned lifecycle status.
-pub fn set_suggestion_status(
- config: &Config,
- id: &str,
- status: SuggestionStatus,
-) -> Result<bool> {
+pub fn set_suggestion_status(config: &Config, id: &str, status: SuggestionStatus) -> Result<bool> {
let storage = super::catalog_storage::register_blocking(config)?;
let status: catalog::SuggestionStatus = roundtrip(status)?;
let request = catalog::SetSuggestionStatusRequest {
diff --git a/crates/openhuman-core/src/flows/store_tests.rs b/crates/openhuman-core/src/flows/store_tests.rs
index dd9ca660dc..1bc4d00db8 100644
--- a/crates/openhuman-core/src/flows/store_tests.rs
+++ b/crates/openhuman-core/src/flows/store_tests.rs
@@ -74,7 +74,10 @@ fn catalog_clients_preserve_definition_revisions_and_suggestion_semantics() {
created_at: flow.created_at,
source_run_id: None,
};
- assert_eq!(upsert_suggestions(&config, &[suggestion.clone()]).unwrap(), 1);
+ assert_eq!(
+ upsert_suggestions(&config, &[suggestion.clone()]).unwrap(),
+ 1
+ );
assert_eq!(
list_suggestions(&config, Some(SuggestionStatus::New), 10)
.unwrap()