Skip to content

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

feat(workflow-builder): add flow discovery prompt and user scope tests

Steven Enamakele9ba1f59f440
diff --git a/crates/openhuman-core/src/flows/agents/flow_discovery/prompt.rs b/crates/openhuman-core/src/flows/agents/flow_discovery/prompt.rs
index e33f265ee8..dc4661e12f 100644
--- a/crates/openhuman-core/src/flows/agents/flow_discovery/prompt.rs
+++ b/crates/openhuman-core/src/flows/agents/flow_discovery/prompt.rs
@@ -2,10 +2,7 @@
//! Scout").
//!
//! Assembles the discovery archetype (from the sibling `prompt.md`) plus the
-//! shared runtime sections (user files, the agent's tool list, and the
-//! workspace footer). PROFILE.md / MEMORY.md are injected by the harness per the
-//! agent's `omit_profile = false` / `omit_memory_md = false` TOML flags — the
-//! scout grounds its suggestions in who the user is, so it reads them directly.
+//! shared runtime sections (the agent's tool list and the workspace footer).
//! No `## Safety` block: `omit_safety_preamble = true` because every tool in
//! scope is read-only except the `suggest_workflows` emit sink (which has no
//! external effect); the "read, then suggest — never act" invariant lives in
diff --git a/crates/openhuman-core/src/flows/agents/workflow_builder/mod.rs b/crates/openhuman-core/src/flows/agents/workflow_builder/mod.rs
index c53fa84bbf..7a2a9aea7a 100644
--- a/crates/openhuman-core/src/flows/agents/workflow_builder/mod.rs
+++ b/crates/openhuman-core/src/flows/agents/workflow_builder/mod.rs
@@ -5,7 +5,7 @@
//! the propose-only contract, and the turn brief that opens an authoring turn —
//! lives in `tinyflows-copilot` and names no harness. What is here is the
//! wiring: [`prompt`] assembles that archetype with this host's runtime
-//! sections (user files, the agent's tool list, the workspace footer), and
+//! sections (the agent's tool list, the workspace footer), and
//! `agent.toml` registers the agent with this host's registry.
//!
//! [`builder_prompt`] is the historical path the brief was reached by; it is a
diff --git a/crates/openhuman-core/src/flows/agents/workflow_builder/prompt.rs b/crates/openhuman-core/src/flows/agents/workflow_builder/prompt.rs
index 28c2808eb5..d06a410747 100644
--- a/crates/openhuman-core/src/flows/agents/workflow_builder/prompt.rs
+++ b/crates/openhuman-core/src/flows/agents/workflow_builder/prompt.rs
@@ -1,7 +1,7 @@
//! System prompt builder for the `workflow_builder` built-in agent (Phase 5a).
//!
//! Assembles the workflow-authoring archetype (`tinyflows_copilot::prompts::WORKFLOW_BUILDER`
-//! — it belongs to the engine, not to this host) plus the shared runtime sections (user files, the agent's tool list, and the
+//! — it belongs to the engine, not to this host) plus the shared runtime sections (the agent's tool list and the
//! workspace footer). No `## Safety` block — the agent has `omit_safety_preamble
//! = true` in its TOML because every tool in scope is propose-or-read and has no
//! real external effect (the "propose, never persist" invariant lives in the
diff --git a/crates/openhuman-core/src/integrations/composio/ops/user_scopes_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/user_scopes_tests.rs
index 2fe7071615..ba9dfe0c6c 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/user_scopes_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/user_scopes_tests.rs
@@ -1,46 +1,23 @@
-//! Pins the host copy of the scope-pref storage shape.
-//!
-//! These constants were copied out of `tinymemory-core` when the two RPC
-//! handlers stopped reaching the in-process engine (openhuman#5560). The engine
-//! still reads the same rows to gate tool calls by scope, and it now runs
-//! inside the loaded module — so drift between the two spellings does not
-//! fail. It reads as "no preference stored" and hands the agent the permissive
-//! default while the user's saved choice sits one key away: a permission bug
-//! that looks like a working app. Hence a test rather than a comment.
-//!
-//! **What this can and cannot check, stated rather than implied.**
-//! `tinymemory-core`'s own `user_scopes::KV_NAMESPACE` no longer exists —
-//! tinymemory v1.13.4 deleted the whole in-process Composio pipeline, this
-//! constant included — so there is nothing left in that crate to assert
-//! against. What *is* still public and load-bearing is `tinycortex`'s own
-//! `memory::sync::state::STATE_NAMESPACE` (`"composio-sync-state"`), which is
-//! the literal `memory_cleanup.rs` reads and writes under, and the two must
-//! differ so prefs and Composio sync cursors never collide — that is the half
-//! asserted here, and the literal is asserted against itself.
-//!
-//! `tinycortex` resolves because it is an ordinary dependency of this crate
-//! (`Cargo.toml`); production code in `user_scopes.rs` names neither it nor
-//! any engine item.
-
use super::*;
-/// `kv_key` trims and ASCII-lowercases, exactly as the engine's does — the RPC
-/// takes free text from a settings toggle, so `"GitHub"`, `" github "` and
-/// `"github"` have to reach one row.
+fn config_in(dir: &tempfile::TempDir) -> Config {
+ Config {
+ workspace_dir: dir.path().to_path_buf(),
+ ..Config::default()
+ }
+}
+
+/// The RPC takes free text from a settings toggle, so `"GitHub"`,
+/// `" github "` and `"github"` have to reach one row.
#[test]
-fn kv_key_normalises_the_toolkit_the_same_way_the_engine_does() {
+fn kv_key_normalises_the_toolkit() {
assert_eq!(kv_key(" GitHub "), "github");
assert_eq!(kv_key("SLACK"), "slack");
assert_eq!(kv_key("gmail"), "gmail");
assert_eq!(kv_key(" "), "", "an all-whitespace toolkit has no row");
}
-/// The stored JSON is the engine's `UserScopePref`, field for field.
-///
-/// A host-side twin with the same three booleans would serialise identically
-/// today and drift on the first field either side adds, so the production code
-/// re-exports the engine's type instead of declaring one. This asserts the
-/// bytes that actually land in the row.
+/// The stored JSON is the three boolean fields.
#[test]
fn stored_value_is_the_three_boolean_fields() {
let value = serde_json::to_value(UserScopePref {
@@ -64,3 +41,45 @@ fn default_pref_is_read_write_without_admin() {
assert!(pref.write);
assert!(!pref.admin, "admin must stay opt-in");
}
+
+#[tokio::test]
+async fn save_then_load_round_trips_per_toolkit() {
+ let dir = tempfile::tempdir().unwrap();
+ let config = config_in(&dir);
+ let pref = UserScopePref {
+ read: true,
+ write: false,
+ admin: true,
+ };
+ save(&config, "GitHub", pref).await.unwrap();
+
+ let loaded = load_or_default(&config, " github ").await;
+ assert_eq!(
+ serde_json::to_value(loaded).unwrap(),
+ serde_json::to_value(pref).unwrap()
+ );
+ let other = load_or_default(&config, "slack").await;
+ assert!(other.read && other.write && !other.admin);
+}
+
+#[tokio::test]
+async fn save_rejects_an_empty_toolkit() {
+ let dir = tempfile::tempdir().unwrap();
+ let config = config_in(&dir);
+ assert!(save(&config, " ", UserScopePref::default()).await.is_err());
+}
+
+#[tokio::test]
+async fn unreadable_store_fails_open_to_the_default() {
+ let dir = tempfile::tempdir().unwrap();
+ let config = config_in(&dir);
+ let path = file_store::path(&config, USER_SCOPES_FILE);
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(&path, b"not json").unwrap();
+
+ let pref = load_or_default(&config, "github").await;
+ assert!(pref.read && pref.write && !pref.admin);
+ assert!(save(&config, "github", UserScopePref::default())
+ .await
+ .is_err());
+}