Skip to content

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

refactor(flows): tidy schema handler imports and visibility

Steven Enamakelc43cce437ca7
diff --git a/crates/openhuman-core/src/flows/schemas.rs b/crates/openhuman-core/src/flows/schemas.rs
index d5150920e1..5134569ff5 100644
--- a/crates/openhuman-core/src/flows/schemas.rs
+++ b/crates/openhuman-core/src/flows/schemas.rs
@@ -8,8 +8,8 @@
use serde::de::DeserializeOwned;
use serde_json::{Map, Value};
-use crate::core::runtime::DispatchCtx;
use crate::core::all::{ControllerFuture, RegisteredController};
+use crate::core::runtime::DispatchCtx;
use crate::core::Outcome;
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
use crate::flows::ops;
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
index 2902ce180f..9b53abf030 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/builder.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
-use super::{read_required, to_json};
use super::super::*;
+use super::{read_required, to_json};
+use crate::core::runtime::DispatchCtx;
pub(super) fn handle_build(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
index e23005507d..cbf0498d36 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
-use super::{read_required, to_json};
use super::super::*;
+use super::{read_required, to_json};
+use crate::core::runtime::DispatchCtx;
pub(super) fn handle_create(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
index b679b4f47f..d0e379a58c 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/draft.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
-use super::{read_required, to_json};
use super::super::*;
+use super::{read_required, to_json};
+use crate::core::runtime::DispatchCtx;
pub(super) fn handle_draft_create(
ctx: DispatchCtx,
@@ -90,6 +90,19 @@ pub(super) fn handle_draft_promote(
})
}
+/// Parses `draft_update`'s `flow_id` param (R-m7). The outer `Option`
+/// mirrors `ops::flows_draft_update`'s "present vs absent" contract — absent
+/// leaves the draft's existing link untouched; the inner `Option` is the new
+/// link (`None` unlinks).
+///
+/// A present-but-non-string `flow_id` (a number, or an object from a buggy
+/// client) is REJECTED rather than silently coerced into `Some(None)` via
+/// `Value::as_str()` returning `None` on a type mismatch — that shape used
+/// to be indistinguishable from an explicit `flow_id: null` unlink, and
+/// `update_draft` treats `Some(None)` as exactly that: unlinking the draft
+/// from its flow. A later `draft_promote` then creates a brand-new flow
+/// instead of updating the one the caller actually meant.
+
pub(super) fn parse_draft_update_flow_id(
params: &Map<String, Value>,
) -> Result<Option<Option<String>>, String> {
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs b/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
index 51a3e0b2fd..aeb04640f6 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/mod.rs
@@ -23,20 +23,6 @@ pub(super) fn read_required<T: DeserializeOwned>(
serde_json::from_value(value).map_err(|e| format!("invalid '{key}': {e}"))
}
-fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
+pub(super) fn to_json<T: serde::Serialize>(outcome: Outcome<T>) -> Result<Value, String> {
outcome.into_cli_compatible_json()
}
-
-/// Parses `draft_update`'s `flow_id` param (R-m7). The outer `Option`
-/// mirrors `ops::flows_draft_update`'s "present vs absent" contract — absent
-/// leaves the draft's existing link untouched; the inner `Option` is the new
-/// link (`None` unlinks).
-///
-/// A present-but-non-string `flow_id` (a number, or an object from a buggy
-/// client) is REJECTED rather than silently coerced into `Some(None)` via
-/// `Value::as_str()` returning `None` on a type mismatch — that shape used
-/// to be indistinguishable from an explicit `flow_id: null` unlink, and
-/// `update_draft` treats `Some(None)` as exactly that: unlinking the draft
-/// from its flow. A later `draft_promote` then creates a brand-new flow
-/// instead of updating the one the caller actually meant.
-
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/run.rs b/crates/openhuman-core/src/flows/schemas/handlers/run.rs
index 9ac070e9bc..3d0b138253 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/run.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/run.rs
@@ -1,6 +1,6 @@
-use crate::core::runtime::DispatchCtx;
-use super::{read_required, to_json};
use super::super::*;
+use super::{read_required, to_json};
+use crate::core::runtime::DispatchCtx;
pub(super) fn handle_run(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {