Skip to content

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

test(flows): cover builder tool validation and creation

Steven Enamakel5ccca02db2cb
diff --git a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
index 81f2c4825f..7bc217a3b8 100644
--- a/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_validate_and_create_tests.rs
@@ -365,12 +365,11 @@ async fn edit_workflow_edits_a_draft_and_writes_back() {
assert_eq!(reloaded.graph["nodes"].as_array().unwrap().len(), 3);
}
-// T-m6: when the draft write-back itself fails (here: a genuine write lock on
-// the catalog database held by another connection, not a mock), the response
-// must surface the failure instead of claiming "Edits live on draft {id}" —
-// the exact wording that used to ship regardless of whether the write
-// actually landed. Reads still work under the lock (WAL), so the draft loads
-// and only the write-back fails, after the database's busy timeout.
+// T-m6: when the draft write-back itself fails (here: a genuine constraint of
+// the database that refuses updates to draft documents, not a mock), the
+// response must surface the failure instead of claiming "Edits live on draft
+// {id}" — the exact wording that used to ship regardless of whether the write
+// actually landed.
#[tokio::test]
async fn edit_workflow_surfaces_draft_write_back_failure() {
use tinyflows_catalog::DraftOrigin;
@@ -388,9 +387,23 @@ async fn edit_workflow_surfaces_draft_write_back_failure() {
.unwrap()
.value;
- let lock =
+ // Updating a draft document aborts; creating, reading and listing do not,
+ // so the draft loads and only the write-back fails.
+ let conn =
crate::storage::rusqlite::Connection::open(crate::flows::store::db_path(&config)).unwrap();
- lock.execute_batch("BEGIN IMMEDIATE").unwrap();
+ let docs_table: String = conn
+ .query_row(
+ "SELECT name FROM sqlite_master WHERE type = 'table' AND name LIKE '%\\_tsd\\_docs' ESCAPE '\\'",
+ [],
+ |row| row.get(0),
+ )
+ .unwrap();
+ conn.execute_batch(&format!(
+ "CREATE TRIGGER refuse_draft_updates BEFORE UPDATE ON {docs_table}
+ WHEN NEW.coll = 'flows_drafts'
+ BEGIN SELECT RAISE(ABORT, 'drafts are read-only'); END;"
+ ))
+ .unwrap();
let tool = EditWorkflowTool::new(config.clone());
let result = tool
@@ -401,7 +414,6 @@ async fn edit_workflow_surfaces_draft_write_back_failure() {
.await
.unwrap();
- lock.execute_batch("ROLLBACK").unwrap();
assert!(result.is_error, "{}", result.output());
assert!(