Skip to content

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

feat(flows): add trail-off and validation ops

Steven Enamakel06f6231e214f
diff --git a/crates/openhuman-core/src/flows/ops.rs b/crates/openhuman-core/src/flows/ops.rs
index 64697ff6e9..086632eb51 100644
--- a/crates/openhuman-core/src/flows/ops.rs
+++ b/crates/openhuman-core/src/flows/ops.rs
@@ -38,7 +38,9 @@ use std::sync::{Arc, LazyLock};
use chrono::Utc;
use serde_json::{json, Value};
+use tinyflows::authoring::validate_and_migrate_graph;
use tinyflows::model::{NodeKind, TriggerKind, WorkflowGraph};
+use tinyflows::triggers::graph_trigger_warnings;
// The save/run safety predicates are `tinyflows-catalog`'s: whether a graph
// fires unattended, whether it can act on the world, whether it has anything to
// do at all are properties of the graph, not of this host. Re-exported at
diff --git a/crates/openhuman-core/src/flows/ops/trail_off.rs b/crates/openhuman-core/src/flows/ops/trail_off.rs
index be72f71b62..2ad3ea6d70 100644
--- a/crates/openhuman-core/src/flows/ops/trail_off.rs
+++ b/crates/openhuman-core/src/flows/ops/trail_off.rs
@@ -6,7 +6,7 @@ use tinyflows_copilot::fallback::{self, ToolResult};
// trail-off fallback construction live in `tinyflows-copilot`; what stays here
// is the host adapter that correlates the harness `TranscriptEntry` history
// into the module's `ToolResult` shape.
-pub(super) use tinyflows_copilot::combine_trail_off_fallback;
+pub(super) use tinyflows_copilot::fallback::combine_trail_off_fallback;
pub(super) use tinyflows_copilot::text_looks_like_question;
/// Correlates each `ToolResults` entry's `tool_call_id` back to the
diff --git a/crates/openhuman-core/src/flows/ops/validation.rs b/crates/openhuman-core/src/flows/ops/validation.rs
index f95523650c..9df2fec733 100644
--- a/crates/openhuman-core/src/flows/ops/validation.rs
+++ b/crates/openhuman-core/src/flows/ops/validation.rs
@@ -1,56 +1,10 @@
use super::*;
-/// Runs a raw graph JSON value through `tinyflows::migrate::migrate` (upgrade
-/// an older-schema definition to current), deserializes it, and rejects a
-/// structurally invalid graph via `tinyflows::validate::validate` — so a bad
-/// graph is caught at the door, before it's ever persisted.
-///
-/// `pub(crate)` (not private) so `flows::tools::ProposeWorkflowTool` (issue
-/// B4 — agent-first workflow authoring) can run a candidate graph through the
-/// exact same validate/migrate path `flows_create` uses below, without
-/// duplicating it. The tool only calls this — never `flows_create` itself —
-/// which is what keeps the "the agent can never create a flow" invariant
-/// intact: this function validates and returns, it has no persistence effect.
-pub(crate) fn validate_and_migrate_graph(graph_json: Value) -> Result<WorkflowGraph, String> {
- let graph = migrate_and_deserialize_graph(graph_json)?;
- tinyflows::validate::validate(&graph).map_err(|e| e.to_string())?;
- tinyflows::compat::ensure_compatible(&graph)?;
- Ok(graph)
-}
-
-/// Every engine-incompatible topology in `graph`, mapped onto this domain's
-/// validation-error shape.
-///
-/// The classification is [`tinyflows::compat`]'s, and belongs there: which
-/// fan-in shapes the engine's barrier relief can execute is a fact about the
-/// engine, not about OpenHuman. This host used to carry the whole walk.
-pub(crate) fn engine_compatibility_errors(
- graph: &WorkflowGraph,
-) -> Vec<tinyflows_catalog::FlowValidationError> {
- tinyflows::compat::errors(graph)
- .into_iter()
- .map(to_compat_validation_error)
- .collect()
-}
-
// The refusal code is `tinyflows::compat`'s, re-exported at `ops::` scope
-// because this module's tests assert on it by name — which is the point of a
-// stable code, and what keeps a rename upstream a compile error here rather
-// than a silently-passing `contains`.
+// because this module's tests assert on it by name.
#[cfg(test)]
pub(crate) use tinyflows::compat::UNSUPPORTED_NESTED_CONDITIONAL_FAN_IN;
-fn to_compat_validation_error(
- error: tinyflows::compat::CompatibilityError,
-) -> tinyflows_catalog::FlowValidationError {
- tinyflows_catalog::FlowValidationError {
- code: error.code.to_string(),
- message: error.message,
- node_id: error.node_id,
- field: None,
- }
-}
-
/// Host-aware compatibility check, including saved descendants that graph-only
/// validation cannot inspect. Authoring boundaries use it before persistence;
/// execution boundaries use it before compiling a root run/resume or returning
@@ -75,21 +29,6 @@ pub(super) fn ensure_config_aware_engine_compatible(
/// call sites (and the authoring tools' error text) unchanged.
pub(crate) use tinyflows::migrate::deserialize_graph as migrate_and_deserialize_graph;
-/// Maps a portable `tinyflows` [`ValidationError`](tinyflows::error::ValidationError)
-/// into the host's structured [`FlowValidationError`], carrying its stable
-/// `code`, anchoring `node_id`, and human `message`. One place so the mapping
-/// stays consistent across `flows_validate` and the builder gate stack.
-pub(crate) fn to_flow_validation_error(
- err: &tinyflows::error::ValidationError,
-) -> tinyflows_catalog::FlowValidationError {
- tinyflows_catalog::FlowValidationError {
- code: err.code().to_string(),
- message: err.to_string(),
- node_id: err.node_id().map(str::to_string),
- field: None,
- }
-}
-
/// Checks literal `workflow_id` children reachable from an authoring candidate.
///
/// Pure graph validation can recurse through inline children, but resolving a