Skip to content

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

refactor(flows): delegate resume compatibility checks to ResumeRun

Steven Enamakelce942f754935
diff --git a/crates/openhuman-core/src/flows/ops/resume.rs b/crates/openhuman-core/src/flows/ops/resume.rs
index e19839716b..7313d6c49a 100644
--- a/crates/openhuman-core/src/flows/ops/resume.rs
+++ b/crates/openhuman-core/src/flows/ops/resume.rs
@@ -15,22 +15,6 @@ pub async fn flows_resume(
rejections: Vec<String>,
) -> Result<Outcome<Value>, String> {
let workflow = current_workflow_for_resume(ctx, config, flow_id).await?;
-
- // This is an OpenHuman-specific configuration check. The generic saved
- // snapshot/graph compatibility checks are enforced by ResumeRun itself.
- // If current host configuration cannot support the run, leave its parked
- // state intact so it can be retried after configuration is repaired.
- if let Err(error) = ensure_config_aware_engine_compatible(ctx, config, &workflow.graph).await {
- tracing::warn!(
- target: "flows",
- flow_id,
- %thread_id,
- %error,
- "[flows] flows_resume: rejected by host configuration compatibility"
- );
- return Err(error);
- }
-
let bindings = crate::flows::runs_adapter::register_resume_bindings(
ctx,
config,
@@ -70,13 +54,14 @@ pub async fn flows_resume(
}
struct ResumeWorkflow {
- graph: tinyflows::model::WorkflowGraph,
require_approval: bool,
}
/// Read the workflow through the same owner-scoped catalog callback that the
/// run adapter will use. This prevents a caller-supplied run or flow id from
/// resolving another account's approval policy for the fresh CapsHost.
+/// Compatibility of the saved execution graph and its children is checked by
+/// the owner-scoped Runs.ResumeRun operation.
async fn current_workflow_for_resume(
ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
@@ -93,16 +78,7 @@ async fn current_workflow_for_resume(
.await
.map_err(|error| error.wire_message())?;
let workflow = workflow.ok_or_else(|| format!("flow '{flow_id}' not found"))?;
- let graph = crate::flows::ops::validation::migrate_over_bus(ctx, config, workflow.graph)
- .await
- .and_then(|graph| serde_json::from_value(graph).map_err(|error| error.to_string()))
- .map_err(|error| format!("decode workflow graph for resume: {error}"))?;
Ok(ResumeWorkflow {
- graph,
require_approval: workflow.require_approval,
})
}
-
-// The graph hash is a persisted format owned by tinyflows-catalog. ResumeRun
-// performs the hash comparison against its saved execution snapshot.
-pub(super) use tinyflows_catalog::graph_hash::compute_graph_hash;
diff --git a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs
index e6c11c9e23..c28e534a92 100644
--- a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs
@@ -345,9 +345,9 @@ async fn flows_resume_marks_an_incompatible_legacy_checkpoint_failed() {
let pending: Vec<String> =
serde_json::from_value(run.value["pending_approvals"].clone()).unwrap();
- // Simulate a graph persisted before the host compatibility gate existed.
- // The store layer intentionally trusts its typed caller; authoring paths
- // own validation.
+ // Model a legacy parked checkpoint whose current saved graph is unsafe.
+ // The module owns compatibility refusal and should settle this run as
+ // failed when ResumeRun is attempted.
let legacy_graph = structurally_valid_graph(nested_conditional_fan_in_graph());
store::update_flow_graph(
&config,
@@ -360,6 +360,14 @@ async fn flows_resume_marks_an_incompatible_legacy_checkpoint_failed() {
None,
)
.unwrap();
+ // Keep the compatibility refusal under test distinct from the stale-pin
+ // refusal: a pre-pin parked row has no graph hash to compare.
+ update_parked_run_document_for_test(&config, &thread_id, |document| {
+ document
+ .as_object_mut()
+ .expect("run document is an object")
+ .remove("graph_hash");
+ });
let error = flows_resume(
&crate::core::runtime::DispatchCtx::ambient(),
&config,
@@ -429,6 +437,14 @@ async fn flows_resume_marks_a_checkpoint_with_an_incompatible_saved_child_failed
None,
)
.unwrap();
+ // Keep the compatibility refusal under test distinct from the stale-pin
+ // refusal: a pre-pin parked row has no graph hash to compare.
+ update_parked_run_document_for_test(&config, &thread_id, |document| {
+ document
+ .as_object_mut()
+ .expect("run document is an object")
+ .remove("graph_hash");
+ });
let error = flows_resume(
&crate::core::runtime::DispatchCtx::ambient(),
&config,