Skip to content

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

refactor(flows): update storage trait bounds for serialization

Steven Enamakel2d4bcd904a4c
diff --git a/crates/openhuman-core/src/flows/catalog_storage.rs b/crates/openhuman-core/src/flows/catalog_storage.rs
index 92a719f6d5..14c7350f17 100644
--- a/crates/openhuman-core/src/flows/catalog_storage.rs
+++ b/crates/openhuman-core/src/flows/catalog_storage.rs
@@ -169,7 +169,7 @@ pub(crate) fn call_test_storage<T, A>(
) -> anyhow::Result<T>
where
T: serde::de::DeserializeOwned + Send + 'static,
- A: Serialize + Send + 'static,
+ A: Serialize + Send + Sync + 'static,
{
let storage = register_blocking(config)?;
crate::storage::block_on_anyhow(async move {
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 1d2c506c10..4b55c11512 100644
--- a/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_resume_checkpoint_tests.rs
@@ -47,6 +47,50 @@ pub(super) fn update_parked_run_document_for_test(
assert!(matches!(reply, CatalogStorageReply::Value { .. }));
}
+/// Corrupt a stored flow graph through the host's owner-scoped document port.
+/// The malformed record is used to verify that one broken definition does not
+/// block reconciliation of its valid siblings.
+pub(super) fn corrupt_saved_flow_graph_for_test(config: &Config, flow_id: &str, graph: &str) {
+ use tinyflows_bus::catalog::{
+ self as catalog, CatalogDocumentPrecondition, CatalogStorageReply,
+ CatalogVersionedDocument, DocGetRequest, DocPutRequest,
+ };
+
+ let reply = crate::flows::catalog_storage::call_test_storage::<CatalogStorageReply, _>(
+ config,
+ catalog::storage::GET,
+ (DocGetRequest {
+ collection: "flows.definitions".into(),
+ id: flow_id.to_owned(),
+ },),
+ )
+ .expect("read the module-created flow document");
+ let value = match reply {
+ CatalogStorageReply::Value { value } => value,
+ CatalogStorageReply::Error { error } => panic!("flow fixture read failed: {error:?}"),
+ };
+ let stored: Option<CatalogVersionedDocument> =
+ serde_json::from_value(value).expect("decode the module-created flow document");
+ let mut stored = stored.expect("the flow document must exist");
+ stored.doc["graph"] = Value::String(graph.to_owned());
+
+ let reply = crate::flows::catalog_storage::call_test_storage::<CatalogStorageReply, _>(
+ config,
+ catalog::storage::PUT,
+ (DocPutRequest {
+ collection: "flows.definitions".into(),
+ id: flow_id.to_owned(),
+ doc: stored.doc,
+ precondition: CatalogDocumentPrecondition::Version(stored.version),
+ schema: stored.meta.schema,
+ expires_ms: stored.meta.expires_ms,
+ created_ms: Some(stored.meta.created_ms),
+ },),
+ )
+ .expect("write the corrupt flow fixture through its owner-scoped port");
+ assert!(matches!(reply, CatalogStorageReply::Value { .. }));
+}
+
/// The success-path mirror of the refusal test above: when nothing rewrites
/// the flow between park and resume, the recomputed hash matches the pinned
/// one and the resume proceeds exactly as it did before this guard existed.
diff --git a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
index 647e671046..91d232a141 100644
--- a/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_triggers_and_resume_tests.rs
@@ -140,7 +140,11 @@ async fn reconcile_schedule_triggers_on_boot_survives_a_corrupt_row() {
flows_set_enabled(&config, &bad.value.id, true)
.await
.unwrap();
- store::force_corrupt_graph_json_for_test(&config, &bad.value.id, "{ not valid json").unwrap();
+ super::resume_checkpoint_tests::corrupt_saved_flow_graph_for_test(
+ &config,
+ &bad.value.id,
+ "{ not valid json",
+ );
// Remove the cron job `flows_set_enabled` already bound for the good flow
// above, so the post-reconcile assertion proves