Skip to content

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

refactor(flows): thread dispatch context through rollback and draft promote

Steven Enamakel10ae305c3b7b
diff --git a/crates/openhuman-core/src/flows/ops/updates.rs b/crates/openhuman-core/src/flows/ops/updates.rs
index 07f48ae0b9..396f9a4764 100644
--- a/crates/openhuman-core/src/flows/ops/updates.rs
+++ b/crates/openhuman-core/src/flows/ops/updates.rs
@@ -279,13 +279,31 @@ pub async fn flows_rollback(
id: &str,
revision_id: &str,
expected_version: Option<String>,
+) -> Result<Outcome<Flow>, String> {
+ flows_rollback_with_context(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ config,
+ id,
+ revision_id,
+ expected_version,
+ )
+ .await
+}
+
+pub(crate) async fn flows_rollback_with_context(
+ ctx: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+ id: &str,
+ revision_id: &str,
+ expected_version: Option<String>,
) -> Result<Outcome<Flow>, String> {
let rev = store::revision_by_id(config, id, revision_id)
.map_err(|e| e.to_string())?
.ok_or_else(|| format!("revision '{revision_id}' not found for flow '{id}'"))?;
tracing::debug!(target: "flows", flow_id = %id, %revision_id, "[flows] flows_rollback: restoring prior revision");
- flows_update(
+ flows_update_with_context(
+ ctx,
config,
id,
Some(rev.name),
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
index bfe741c2a3..6b55a72c2f 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
@@ -193,7 +193,14 @@ pub(in crate::flows::schemas) fn handle_rollback(
.filter(|s| !s.is_empty())
.map(str::to_string);
to_json(
- ops::flows_rollback(&config, id.trim(), revision_id.trim(), expected_version).await?,
+ ops::flows_rollback_with_context(
+ &ctx,
+ &config,
+ id.trim(),
+ revision_id.trim(),
+ expected_version,
+ )
+ .await?,
)
})
}
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
index 731d3db43f..892c3c1739 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
@@ -92,7 +92,10 @@ pub(in crate::flows::schemas) fn handle_draft_promote(
let config = ctx.load_config().await?;
let id = read_required::<String>(&params, "id")?;
let require_approval = params.get("require_approval").and_then(Value::as_bool);
- to_json(ops::flows_draft_promote(&config, id.trim(), require_approval).await?)
+ to_json(
+ ops::flows_draft_promote_with_context(&ctx, &config, id.trim(), require_approval)
+ .await?,
+ )
})
}