Skip to content

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

chore(tinyflows): add memory adapter tests

Steven Enamakelea079198b143
diff --git a/crates/openhuman-core/src/flows/tinyflows/memory_adapter_tests.rs b/crates/openhuman-core/src/flows/tinyflows/memory_adapter_tests.rs
index 3e23d05950..9948af1faf 100644
--- a/crates/openhuman-core/src/flows/tinyflows/memory_adapter_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/memory_adapter_tests.rs
@@ -321,3 +321,35 @@ fn plain_agent_learnings_are_trusted_and_everything_else_is_not() {
None
)));
}
+
+fn workflow_origin(flow_id: &str, require_approval: bool) -> AgentTurnOrigin {
+ AgentTurnOrigin::TrustedAutomation {
+ job_id: flow_id.to_string(),
+ source: TrustedAutomationSource::Workflow { require_approval },
+ }
+}
+
+// ── the run's origin comes from its context, not the task's scope ────
+
+#[tokio::test]
+async fn flow_id_comes_from_the_runs_context_not_the_calling_tasks_scope() {
+ let (_tmp, mut adapter) = adapter(AutonomyLevel::Full);
+ let own = workflow_origin("flow-own", false);
+ let other = workflow_origin("flow-other", false);
+ adapter.ctx = crate::core::runtime::DispatchCtx::unbound().with_turn_origin(own);
+
+ // A different flow's origin scoped on the task must not win.
+ let id = crate::agent::turn_origin::with_origin(other, async { adapter.trusted_flow_id() })
+ .await
+ .unwrap();
+ assert_eq!(id, "flow-own");
+}
+
+#[tokio::test]
+async fn a_context_without_a_workflow_origin_refuses_flow_scope_even_inside_a_workflow_scope() {
+ let (_tmp, adapter) = adapter(AutonomyLevel::Full);
+ let other = workflow_origin("flow-other", false);
+ let result =
+ crate::agent::turn_origin::with_origin(other, async { adapter.trusted_flow_id() }).await;
+ assert!(result.is_err());
+}