The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(e2e): backfill coverage for the embeddings dimension probe and the flows authoring gates
M3gA-Mindd3c55cbf9991
diff --git a/tests/embeddings_rpc_e2e.rs b/tests/embeddings_rpc_e2e.rsindex eb79318c84..81cc652d3f 100644--- a/tests/embeddings_rpc_e2e.rs+++ b/tests/embeddings_rpc_e2e.rs@@ -882,3 +882,79 @@ async fn legacy_alias_inference_embed_resolves() {"legacy alias should resolve to embeddings_embed and return vector data: {inner}");}++/// #4056 / #5859: a Custom endpoint whose NATIVE vector width differs from the+/// width the user guessed must still verify, and the width that gets persisted+/// must be the endpoint's, not the guess.+///+/// This is the half of the change no existing test could observe.+/// `embeddings_embed_with_custom_openai_endpoint_round_trips_vectors_and_api_key`+/// configures `dimensions: 3` against a mock that returns 3-wide vectors, so+/// "honoured the guess" and "discovered the native width" produce the same+/// number and its `dimensions == 3` assertion cannot tell them apart. Here the+/// two are deliberately different: the guess is the product default (1024) and+/// the endpoint returns 3.+///+/// Before the probe was made dimension-agnostic, the save-time verification+/// enforced the guessed width, so every reachable, valid endpoint whose native+/// size was not the guess failed verification — the whole of #4056. After it,+/// `final_probe_dims` adopts the returned length for any model outside the+/// `text-embedding-3-*` family (`mock-embedding-model` is one), which is also+/// what keeps the live embed path's length guard from rejecting later embeds.+#[tokio::test(flavor = "multi_thread")]+async fn embeddings_update_settings_adopts_custom_endpoint_native_dimension() {+ let _lock = embeddings_e2e_env_lock();+ let (rpc_base, _tmp, _guards, _join) = setup_embeddings_test().await;+ let (mock_base, _mock_state, mock_join) = serve_mock_embeddings().await;++ let update = post_json_rpc(+ &rpc_base,+ 90,+ "openhuman.embeddings_update_settings",+ json!({+ "provider": "custom",+ "custom_endpoint": mock_base,+ "model": "mock-embedding-model",+ // The guess. The mock returns 3-wide vectors, so this is wrong on+ // purpose — it is the product default a user would never edit.+ "dimensions": 1024,+ "confirm_wipe": true+ }),+ )+ .await;+ let update_result = assert_no_rpc_error(&update, "embeddings_update_settings native dims");+ let update_inner = update_result.get("result").unwrap_or(update_result);++ // 1. The save is NOT rejected. A mismatched guess used to fail verification.+ assert_eq!(+ update_inner.get("error").and_then(Value::as_str),+ None,+ "a reachable endpoint whose native width differs from the guess must \+ still verify, not be refused: {update_inner}"+ );+ let expected_provider = format!("custom:{mock_base}");+ assert_eq!(+ update_inner.get("provider").and_then(Value::as_str),+ Some(expected_provider.as_str()),+ "the custom provider must be persisted: {update_inner}"+ );++ // 2. The width that survives is the endpoint's 3, not the guessed 1024.+ let after = post_json_rpc(+ &rpc_base,+ 91,+ "openhuman.embeddings_get_settings",+ json!({}),+ )+ .await;+ let after_result = assert_no_rpc_error(&after, "get_settings after native-dim save");+ let after_inner = after_result.get("result").unwrap_or(after_result);+ assert_eq!(+ after_inner.get("dimensions").and_then(Value::as_u64),+ Some(3),+ "the probe must adopt the endpoint's native vector width (3), not the \+ guessed 1024: {after_inner}"+ );++ mock_join.abort();+}diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rsindex d987dc4266..a9b8ece8b0 100644--- a/tests/json_rpc_e2e.rs+++ b/tests/json_rpc_e2e.rs@@ -14394,3 +14394,244 @@ async fn voice_test_provider_honours_validate_only_for_the_stt_workload() {mock_join.abort();rpc_join.abort();}++// ─────────────────────────────────────────────────────────────────────────────+// #5846 — the two authoring-gate behaviour changes, driven end-to-end through+// the real strict-mode create path.+//+// `flows_create` with `strict: true` runs `ops::strict_gate`+// (`flows/schemas_handlers.rs:18`) -> `run_builder_gates`+// (`flows/ops_part_01.rs:509`) -> `validate_binding_resolvability`+// (`flows/ops_part_02.rs:433`) -> `tinyflows::gates::failures`, the stack+// #5846 evicted upstream.+//+// `ops_tests_part_06_tests.rs` already pins the gate FUNCTION at unit level.+// What no test covered is that the evicted gate is still WIRED into the strict+// RPC path — the eviction moved the implementation out of this repository, so+// the wiring is exactly the thing that can now rot without a local test failing.+//+// A NOTE ON #5846's SUMMARY. The PR body reads "a workflow whose `tool_call`+// arg binds to a schema-less agent is now refused". Taken literally that is not+// what the gate does, deliberately: an agent with NO `output_parser.schema` is+// skipped because "the field may exist, so it is unverifiable rather than+// guaranteed invalid" (`gates/mod.rs:234-239`). Only a field absent from a+// schema that EXISTS is refused. These tests pin the implemented contract, and+// the carve-out gets its own case precisely because the PR wording invites+// someone to "fix" it away.+// ─────────────────────────────────────────────────────────────────────────────++/// A `tool_call` arg reading a field the target agent's declared schema omits.+#[cfg(feature = "flows")]+fn graph_binding_to_undeclared_agent_field() -> Value {+ json!({+ "name": "undeclared-field",+ "nodes": [+ { "id": "t", "kind": "trigger", "name": "Manual" },+ { "id": "summarize", "kind": "agent", "name": "Summarize",+ "config": { "prompt": "summarize",+ "output_parser": { "schema": { "type": "object",+ "properties": { "summary": { "type": "string" } } } } } },+ { "id": "post", "kind": "tool_call", "name": "Post",+ "config": { "slug": "SLACK_SEND_MESSAGE",+ "args": { "channel": "=nodes.summarize.item.json.channel" } } }+ ],+ "edges": [+ { "from_node": "t", "to_node": "summarize" },+ { "from_node": "summarize", "to_node": "post" }+ ]+ })+}++/// The same shape with NO declared schema — the deliberate carve-out.+#[cfg(feature = "flows")]+fn graph_binding_to_schemaless_agent() -> Value {+ json!({+ "name": "schemaless-agent",+ "nodes": [+ { "id": "t", "kind": "trigger", "name": "Manual" },+ { "id": "summarize", "kind": "agent", "name": "Summarize",+ "config": { "prompt": "summarize" } },+ { "id": "post", "kind": "tool_call", "name": "Post",+ "config": { "slug": "SLACK_SEND_MESSAGE",+ "args": { "channel": "=nodes.summarize.item.json.channel" } } }+ ],+ "edges": [+ { "from_node": "t", "to_node": "summarize" },+ { "from_node": "summarize", "to_node": "post" }+ ]+ })+}++/// An instruction written as a `=`-expression beside a real `messages` array.+#[cfg(feature = "flows")]+fn graph_prose_prompt_beside_real_messages() -> Value {+ json!({+ "name": "prose-prompt-with-messages",+ "nodes": [+ { "id": "t", "kind": "trigger", "name": "Manual" },+ { "id": "writer", "kind": "agent", "name": "Writer",+ "config": {+ "prompt": "=Write a short friendly summary of the article above",+ "messages": [{ "role": "user", "content": "summarise the article" }] } }+ ],+ "edges": [{ "from_node": "t", "to_node": "writer" }]+ })+}++/// The same prompt with no `messages` to fall through to — still refused.+#[cfg(feature = "flows")]+fn graph_prose_prompt_without_messages() -> Value {+ json!({+ "name": "prose-prompt-alone",+ "nodes": [+ { "id": "t", "kind": "trigger", "name": "Manual" },+ { "id": "writer", "kind": "agent", "name": "Writer",+ "config": { "prompt": "=Write a short friendly summary of the article above" } }+ ],+ "edges": [{ "from_node": "t", "to_node": "writer" }]+ })+}++/// The refusal message from a strict `flows_create`, or `None` when it saved.+#[cfg(feature = "flows")]+fn strict_create_refusal(response: &Value) -> Option<String> {+ response+ .get("error")+ .and_then(|e| e.get("message"))+ .and_then(Value::as_str)+ .map(ToOwned::to_owned)+}++#[cfg(feature = "flows")]+#[tokio::test]+async fn json_rpc_flows_strict_create_refuses_binding_to_undeclared_agent_field() {+ let _env_lock = json_rpc_e2e_env_lock();+ let (rpc_base, _tmp, api_join, rpc_join, _guards) = boot_flows_rpc_env().await;++ let create = post_json_rpc(+ &rpc_base,+ 9801,+ "openhuman.flows_create",+ json!({+ "name": "undeclared-field",+ "graph": graph_binding_to_undeclared_agent_field(),+ "strict": true+ }),+ )+ .await;++ let refusal = strict_create_refusal(&create)+ .unwrap_or_else(|| panic!("strict create must be refused, got: {create}"));+ assert!(+ refusal.contains("output_parser.schema"),+ "the refusal must come from the undeclared-field gate, got: {refusal}"+ );+ assert!(+ refusal.contains("channel"),+ "the refusal must name the offending field, got: {refusal}"+ );++ rpc_join.abort();+ api_join.abort();+}++/// The carve-out: an agent with no declared schema is unverifiable, not+/// invalid, so this binding must NOT be refused by the schema gate.+///+/// Asserted as "no refusal naming this gate" rather than "the save succeeded",+/// because a strict create must clear every later gate too and this test is+/// about one of them. It is still non-vacuous: revert the carve-out and the+/// refusal names `output_parser.schema`, which is exactly what this forbids.+#[cfg(feature = "flows")]+#[tokio::test]+async fn json_rpc_flows_strict_create_accepts_binding_to_schemaless_agent() {+ let _env_lock = json_rpc_e2e_env_lock();+ let (rpc_base, _tmp, api_join, rpc_join, _guards) = boot_flows_rpc_env().await;++ let create = post_json_rpc(+ &rpc_base,+ 9803,+ "openhuman.flows_create",+ json!({+ "name": "schemaless-agent",+ "graph": graph_binding_to_schemaless_agent(),+ "strict": true+ }),+ )+ .await;++ if let Some(refusal) = strict_create_refusal(&create) {+ assert!(+ !refusal.contains("output_parser.schema"),+ "a schema-less agent must be treated as unverifiable, not refused: {refusal}"+ );+ }++ rpc_join.abort();+ api_join.abort();+}++/// #5846's second behaviour change: a vestigial `=`-prose `prompt` beside real+/// `messages` no longer blocks the save — the node never runs on `prompt` once+/// `messages` supply the turn, so refusing it was a refusal with no failure+/// behind it.+#[cfg(feature = "flows")]+#[tokio::test]+async fn json_rpc_flows_strict_create_accepts_prose_prompt_beside_real_messages() {+ let _env_lock = json_rpc_e2e_env_lock();+ let (rpc_base, _tmp, api_join, rpc_join, _guards) = boot_flows_rpc_env().await;++ let create = post_json_rpc(+ &rpc_base,+ 9804,+ "openhuman.flows_create",+ json!({+ "name": "prose-prompt-with-messages",+ "graph": graph_prose_prompt_beside_real_messages(),+ "strict": true+ }),+ )+ .await;++ if let Some(refusal) = strict_create_refusal(&create) {+ assert!(+ !refusal.contains("reads as an instruction written as a"),+ "a `=`-prose prompt beside real messages must not block the save: {refusal}"+ );+ }++ rpc_join.abort();+ api_join.abort();+}++/// The other side of the same rule: with no `messages` to fall through to, the+/// `=`-prose prompt is still a hard refusal. #5846 narrowed this rule; it did+/// not remove it, and pinning that stops the narrowing being widened.+#[cfg(feature = "flows")]+#[tokio::test]+async fn json_rpc_flows_strict_create_still_refuses_prose_prompt_without_messages() {+ let _env_lock = json_rpc_e2e_env_lock();+ let (rpc_base, _tmp, api_join, rpc_join, _guards) = boot_flows_rpc_env().await;++ let create = post_json_rpc(+ &rpc_base,+ 9805,+ "openhuman.flows_create",+ json!({+ "name": "prose-prompt-alone",+ "graph": graph_prose_prompt_without_messages(),+ "strict": true+ }),+ )+ .await;++ let refusal = strict_create_refusal(&create)+ .unwrap_or_else(|| panic!("strict create must be refused, got: {create}"));+ assert!(+ refusal.contains("reads as an instruction written as a"),+ "the refusal must come from the `=`-prose prompt gate, got: {refusal}"+ );++ rpc_join.abort();+ api_join.abort();+}