Skip to content

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

refactor(flows): replace FlowWriteResult with direct use of PutWorkflowResult

Steven Enamakel910adf8a0e95
diff --git a/crates/openhuman-core/src/flows/ops/updates.rs b/crates/openhuman-core/src/flows/ops/updates.rs
index a1953860e3..74f3387c16 100644
--- a/crates/openhuman-core/src/flows/ops/updates.rs
+++ b/crates/openhuman-core/src/flows/ops/updates.rs
@@ -179,7 +179,7 @@ async fn flows_update_inner(
// happened store-side against a fresh read, so this is purely for the
// info log / result message wording below and can't desync from what
// was actually persisted.
- let store::FlowWriteResult {
+ let tinyflows_bus::catalog::PutWorkflowResult {
workflow: updated,
born_disabled: should_disarm,
approval_forced,
diff --git a/crates/openhuman-core/src/flows/store.rs b/crates/openhuman-core/src/flows/store.rs
index 5fa03d4e02..38c577ada1 100644
--- a/crates/openhuman-core/src/flows/store.rs
+++ b/crates/openhuman-core/src/flows/store.rs
@@ -7,7 +7,6 @@
use anyhow::{anyhow, Result};
use serde::{de::DeserializeOwned, Serialize};
-use std::ops::Deref;
use tinyflows_bus::catalog::{
self, DeleteWorkflowResult, FlowUpdateError as BusUpdateError, GetRevisionRequest,
ListRevisionsRequest, ListWorkflowsResult, PutWorkflowRequest, PutWorkflowResponse,
@@ -18,23 +17,6 @@ use tinyflows_bus::catalog::{FlowSuggestion, SuggestionStatus};
use crate::config::Config;
use crate::modules::tinyflows as module;
-/// Host projection of a Catalog write, retaining owner policy flags while
-/// dereferencing to the persisted workflow for existing internal callers.
-#[derive(Clone, Debug)]
-pub(crate) struct FlowWriteResult {
- pub(crate) workflow: Flow,
- pub(crate) born_disabled: bool,
- pub(crate) approval_forced: bool,
-}
-
-impl Deref for FlowWriteResult {
- type Target = Flow;
-
- fn deref(&self) -> &Self::Target {
- &self.workflow
- }
-}
-
pub(crate) fn call_catalog<T, A>(config: &Config, member: &'static str, args: A) -> Result<T>
where
T: DeserializeOwned + Send + 'static,
@@ -60,13 +42,9 @@ where
serde_json::from_value(serde_json::to_value(value)?).map_err(Into::into)
}
-fn put_result(response: PutWorkflowResponse) -> Result<FlowWriteResult> {
+fn put_result(response: PutWorkflowResponse) -> Result<PutWorkflowResult> {
match response {
- PutWorkflowResponse::Ok(result) => Ok(FlowWriteResult {
- workflow: result.workflow,
- born_disabled: result.born_disabled,
- approval_forced: result.approval_forced,
- }),
+ PutWorkflowResponse::Ok(result) => Ok(result),
PutWorkflowResponse::Error(error) => Err(anyhow!(match error {
BusUpdateError::NotFound { message }
| BusUpdateError::VersionConflict { message, .. }
@@ -95,7 +73,7 @@ pub fn create_flow(
graph: Value,
require_approval: bool,
enabled: bool,
-) -> Result<FlowWriteResult> {
+) -> Result<PutWorkflowResult> {
let storage = super::catalog_storage::register_blocking(config)?;
let request = PutWorkflowRequest::Create {
storage,
@@ -189,7 +167,7 @@ pub fn update_flow_graph(
_enabled_override: Option<bool>,
force_disarm_if_automatic: bool,
expected_updated_at: Option<&str>,
-) -> std::result::Result<FlowWriteResult, BusUpdateError> {
+) -> std::result::Result<PutWorkflowResult, BusUpdateError> {
let storage = super::catalog_storage::register_blocking(config).map_err(|error| {
BusUpdateError::Store {
message: error.to_string(),
@@ -211,11 +189,7 @@ pub fn update_flow_graph(
}
})?;
match response {
- PutWorkflowResponse::Ok(result) => Ok(FlowWriteResult {
- workflow: result.workflow,
- born_disabled: result.born_disabled,
- approval_forced: result.approval_forced,
- }),
+ PutWorkflowResponse::Ok(result) => Ok(result),
PutWorkflowResponse::Error(error) => Err(error),
}
}