Skip to content

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

chore: files changed crates/openhuman-core/src/skills/ops_discovery_tests.rs,crates/openhuman-core/s

Steven Enamakelc612e2da11b6
diff --git a/crates/openhuman-core/src/skills/bundled/flow_authoring_tests.rs b/crates/openhuman-core/src/skills/bundled/flow_authoring_tests.rs
new file mode 100644
index 0000000000..15235ad135
--- /dev/null
+++ b/crates/openhuman-core/src/skills/bundled/flow_authoring_tests.rs
@@ -0,0 +1,82 @@
+use super::*;
+
+fn gate_for(workspace: &Path) -> DiscoveryGate {
+ let mut config = Config::default();
+ config.workspace_dir = workspace.to_path_buf();
+ DiscoveryGate::from_config(
+ &DispatchCtx::host_default(),
+ &config,
+ Some(DomainSet::full()),
+ )
+}
+
+fn resources(reference: &str) -> Vec<ResourceFile> {
+ vec![
+ ResourceFile {
+ path: tinyskills::WORKFLOW_MD.to_string(),
+ contents: "---\nname: Flow authoring\ndescription: module manual\n---\n\nRead references when needed.\n"
+ .to_string(),
+ },
+ ResourceFile {
+ path: "references/guide.md".to_string(),
+ contents: reference.to_string(),
+ },
+ ]
+}
+
+#[tokio::test]
+async fn optional_warmup_returns_while_the_loader_is_blocked_and_deduplicates() {
+ let workspace = tempfile::tempdir().expect("workspace");
+ let key = snapshot_key(workspace.path(), &gate_for(workspace.path()));
+ let (started_tx, started_rx) = tokio::sync::oneshot::channel();
+ let (release_tx, release_rx) = tokio::sync::oneshot::channel::<()>();
+ let (finished_tx, finished_rx) = tokio::sync::oneshot::channel();
+
+ assert!(spawn_background(key.clone(), async move {
+ let _ = started_tx.send(());
+ let _ = release_rx.await;
+ let _ = finished_tx.send(());
+ }));
+ // The scheduled operation is now blocked on `release_rx`. Reaching this
+ // point proves the caller that scheduled it did not wait for the loader.
+ started_rx.await.expect("background task started");
+ assert!(
+ !spawn_background(key, async {}),
+ "a second warmup for the same explicit scope is coalesced"
+ );
+ release_tx.send(()).expect("release background task");
+ finished_rx.await.expect("background task finished");
+}
+
+#[test]
+fn resource_snapshot_revisions_follow_changed_bus_bytes() {
+ let workspace = tempfile::tempdir().expect("workspace");
+ let gate = gate_for(workspace.path());
+ let first = publish_snapshot(workspace.path(), &gate, resources("first version"))
+ .expect("materialize first resource set");
+ let unchanged = publish_snapshot(workspace.path(), &gate, resources("first version"))
+ .expect("retain identical resource set");
+ assert_eq!(unchanged, first, "unchanged bus files keep their revision");
+
+ let updated = publish_snapshot(workspace.path(), &gate, resources("second version"))
+ .expect("materialize updated resource set");
+ assert!(updated > first, "changed bus bytes advance the snapshot revision");
+ let current = snapshot_for(&snapshot_key(workspace.path(), &gate), updated).expect("snapshot");
+ assert!(materialization_matches(workspace.path(), &gate, &current));
+ assert_eq!(current.files[1].contents, "second version");
+}
+
+#[test]
+fn tiny_skills_rejects_unsafe_resource_paths_without_writing_outside_scope() {
+ let workspace = tempfile::tempdir().expect("workspace");
+ let gate = gate_for(workspace.path());
+ let mut files = resources("safe reference");
+ files.push(ResourceFile {
+ path: "../outside.txt".to_string(),
+ contents: "must stay outside".to_string(),
+ });
+
+ assert!(publish_snapshot(workspace.path(), &gate, files).is_err());
+ assert!(!workspace.path().join(".openhuman/outside.txt").exists());
+ assert!(snapshot_for(&snapshot_key(workspace.path(), &gate), 1).is_none());
+}
diff --git a/crates/openhuman-core/src/skills/ops_discovery_tests.rs b/crates/openhuman-core/src/skills/ops_discovery_tests.rs
index ac03964760..1c56c6438f 100644
--- a/crates/openhuman-core/src/skills/ops_discovery_tests.rs
+++ b/crates/openhuman-core/src/skills/ops_discovery_tests.rs
@@ -375,6 +375,91 @@ async fn flow_authoring_is_hidden_when_tinyflows_component_is_disabled() {
);
}
+#[cfg(feature = "flows")]
+#[tokio::test]
+async fn module_builtin_gate_only_narrows_context_and_explicit_config() {
+ use crate::core::runtime::{ComponentSet, ContextOverlay, CoreContext, DomainSet};
+ use crate::tools::toolpacks::ToolGroups;
+
+ let workspace = tempfile::tempdir().unwrap();
+ let mut enabled_config = crate::config::Config::default();
+ enabled_config.workspace_dir = workspace.path().to_path_buf();
+ let all = ComponentSet::all();
+ let base = CoreContext::for_test_with_components(all);
+ let enabled_context = base.derive_with(
+ ContextOverlay::new(enabled_config.clone(), DomainSet::full(), ToolGroups::none())
+ .profile("shared"),
+ );
+
+ let enabled = CoreContext::scope(enabled_context, async {
+ let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ crate::skills::bundled::flow_authoring::prewarm(
+ &dispatch,
+ &enabled_config,
+ None,
+ )
+ .await;
+ crate::skills::load_workflow_metadata_for(&dispatch, &enabled_config)
+ })
+ .await;
+ assert!(enabled.iter().any(|skill| skill.id() == "flow-authoring"));
+
+ let mut context_components = all;
+ context_components.tinyflows = false;
+ let context_component_context = CoreContext::for_test_with_components(context_components)
+ .derive_with(
+ ContextOverlay::new(enabled_config.clone(), DomainSet::full(), ToolGroups::none())
+ .profile("shared"),
+ );
+ let context_component_hidden = CoreContext::scope(context_component_context, async {
+ let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ crate::skills::load_workflow_metadata_for(&dispatch, &enabled_config)
+ })
+ .await;
+ assert!(
+ !context_component_hidden
+ .iter()
+ .any(|skill| skill.id() == "flow-authoring"),
+ "an all-enabled Config cannot widen a context with TinyFlows disabled"
+ );
+
+ let mut narrowed_domains = DomainSet::full();
+ narrowed_domains.flows = false;
+ let context_domain_context = CoreContext::for_test_with_components(all).derive_with(
+ ContextOverlay::new(enabled_config.clone(), narrowed_domains, ToolGroups::none())
+ .profile("shared"),
+ );
+ let context_domain_hidden = CoreContext::scope(context_domain_context, async {
+ let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ crate::skills::load_workflow_metadata_for(&dispatch, &enabled_config)
+ })
+ .await;
+ assert!(
+ !context_domain_hidden
+ .iter()
+ .any(|skill| skill.id() == "flow-authoring"),
+ "an all-enabled Config cannot widen a context without the Flows domain"
+ );
+
+ let mut disabled_config = enabled_config.clone();
+ disabled_config.components.tinyflows = false;
+ let config_hidden = CoreContext::scope(
+ CoreContext::for_test_with_components(all).derive_with(
+ ContextOverlay::new(enabled_config.clone(), DomainSet::full(), ToolGroups::none())
+ .profile("shared"),
+ ),
+ async {
+ let dispatch = crate::core::runtime::DispatchCtx::ambient();
+ crate::skills::load_workflow_metadata_for(&dispatch, &disabled_config)
+ },
+ )
+ .await;
+ assert!(
+ !config_hidden.iter().any(|skill| skill.id() == "flow-authoring"),
+ "a narrower supplied Config hides resources from an enabled parent context"
+ );
+}
+
#[test]
fn skills_component_enabled_without_context_is_on() {
assert!(crate::skills::skills_component_enabled());