Skip to content

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

chore: files changed crates/openhuman-core/src/flows/ops_resume_race_tests.rs,vendor/tinyflows

Steven Enamakel30d7b247e883
diff --git a/crates/openhuman-core/src/flows/ops_resume_race_tests.rs b/crates/openhuman-core/src/flows/ops_resume_race_tests.rs
index 4863675665..fd5ebc9317 100644
--- a/crates/openhuman-core/src/flows/ops_resume_race_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_resume_race_tests.rs
@@ -16,6 +16,85 @@ fn insert_parked_run(config: &Config, flow_id: &str, run_id: &str) {
.unwrap());
}
+#[tokio::test]
+async fn duplicate_resume_preserves_the_registered_run_and_parked_checkpoint() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ let created = flows_create(
+ &config,
+ "duplicate-resume".to_string(),
+ approval_gated_graph(),
+ false,
+ )
+ .await
+ .unwrap();
+ let parked = flows_run(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &created.value.id,
+ json!({ "x": 1 }),
+ serde_json::Map::new(),
+ FlowRunTrigger::Rpc,
+ )
+ .await
+ .unwrap();
+ let run_id = parked.value["thread_id"].as_str().unwrap().to_string();
+ let pending: Vec<String> =
+ serde_json::from_value(parked.value["pending_approvals"].clone()).unwrap();
+ assert!(!pending.is_empty());
+
+ // Resume A has registered its cancellation token but has not yet flipped
+ // the durable row from pending_approval to running. Resume B must refuse
+ // to replace that token or claim the checkpoint out from under A.
+ let (active_token, active_guard) = run_registry::register(&run_id);
+ let duplicate = flows_resume(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &created.value.id,
+ &run_id,
+ pending.clone(),
+ vec![],
+ )
+ .await
+ .expect_err("a second resume must refuse an already registered run");
+ assert!(duplicate.contains("in flight"), "{duplicate}");
+ assert!(!active_token.is_cancelled());
+ assert!(run_registry::is_in_flight(&run_id));
+
+ let row = store::get_flow_run(&config, &run_id).unwrap().unwrap();
+ assert_eq!(row.status, "pending_approval");
+ assert_eq!(row.pending_approvals, pending);
+ let checkpointer = crate::flows::tinyflows::open_flow_checkpointer(&config).unwrap();
+ let checkpoints = crate::storage::block_on_anyhow(async move {
+ Ok(checkpointer.get_thread(&run_id).await?.len())
+ })
+ .unwrap();
+ assert!(
+ checkpoints > 0,
+ "the active resume's checkpoint must remain stored"
+ );
+
+ drop(active_guard);
+ let resumed = flows_resume(
+ &crate::core::runtime::DispatchCtx::ambient(),
+ &config,
+ &created.value.id,
+ &run_id,
+ pending,
+ vec![],
+ )
+ .await
+ .expect("the preserved checkpoint must still resume after the active owner exits");
+ assert_eq!(resumed.value["pending_approvals"], json!([]));
+ assert_eq!(
+ store::get_flow_run(&config, &run_id)
+ .unwrap()
+ .unwrap()
+ .status,
+ "completed"
+ );
+}
+
#[tokio::test]
async fn compatibility_refusal_does_not_label_a_resume_claimed_run_failed() {
let tmp = TempDir::new().unwrap();
diff --git a/vendor/tinyflows b/vendor/tinyflows
index 17796d7da0..57086af899 160000
--- a/vendor/tinyflows
+++ b/vendor/tinyflows
@@ -1 +1 @@
-Subproject commit 17796d7da0a4bcdee4f1d227c77a654c163443eb
+Subproject commit 57086af8999979ab86afaf029c1a03f74577e1b9