Skip to content

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

fix(modules): scope the site forget epoch per workspace and gate desktop.pending tests

Steven Enamakel4acaa904f36f
diff --git a/crates/openhuman-core/src/desktop/control/schemas_tests.rs b/crates/openhuman-core/src/desktop/control/schemas_tests.rs
index be1e1fa4c2..992c0de83b 100644
--- a/crates/openhuman-core/src/desktop/control/schemas_tests.rs
+++ b/crates/openhuman-core/src/desktop/control/schemas_tests.rs
@@ -26,7 +26,10 @@ fn scoped_context(computer: bool) -> (tempfile::TempDir, std::sync::Arc<CoreCont
let mut config = crate::config::Config::default();
config.workspace_dir = dir.path().to_path_buf();
config.components.computer = computer;
- (dir, CoreContext::for_test_with_config(DomainSet::full(), config))
+ (
+ dir,
+ CoreContext::for_test_with_config(DomainSet::full(), config),
+ )
}
#[tokio::test]
@@ -44,7 +47,9 @@ async fn every_desktop_controller_answers_component_disabled_when_computer_is_of
let (_dir, context) = scoped_context(false);
CoreContext::scope(context, async {
for function in ["status", "probe", "pending"] {
- let error = (controller(function).handler)(Map::new()).await.unwrap_err();
+ let error = (controller(function).handler)(Map::new())
+ .await
+ .unwrap_err();
assert!(
error.contains("COMPONENT_DISABLED:computer"),
"{function}: {error}"
@@ -52,7 +57,9 @@ async fn every_desktop_controller_answers_component_disabled_when_computer_is_of
}
let mut params = Map::new();
params.insert("enabled".to_owned(), Value::Bool(true));
- let error = (controller("set_enabled").handler)(params).await.unwrap_err();
+ let error = (controller("set_enabled").handler)(params)
+ .await
+ .unwrap_err();
assert!(error.contains("COMPONENT_DISABLED:computer"), "{error}");
let mut params = Map::new();
params.insert("confirmation_id".to_owned(), Value::String("id".to_owned()));
diff --git a/crates/openhuman-core/src/modules/site_memory_host.rs b/crates/openhuman-core/src/modules/site_memory_host.rs
index f99020385c..8e8497ea5c 100644
--- a/crates/openhuman-core/src/modules/site_memory_host.rs
+++ b/crates/openhuman-core/src/modules/site_memory_host.rs
@@ -241,10 +241,7 @@ fn site_named(host: &str) -> Option<String> {
/// # Errors
///
/// Returns an I/O error when a site's file exists and cannot be removed.
-pub async fn forget(
- config: &crate::config::Config,
- site: Option<&str>,
-) -> std::io::Result<usize> {
+pub async fn forget(config: &crate::config::Config, site: Option<&str>) -> std::io::Result<usize> {
let site = match site {
Some(named) => match site_of(named).or_else(|| site_named(named)) {
Some(site) => Some(site),
diff --git a/crates/openhuman-core/src/modules/site_memory_host_tests.rs b/crates/openhuman-core/src/modules/site_memory_host_tests.rs
index d2851fb68a..bdb53a749d 100644
--- a/crates/openhuman-core/src/modules/site_memory_host_tests.rs
+++ b/crates/openhuman-core/src/modules/site_memory_host_tests.rs
@@ -131,7 +131,12 @@ async fn a_site_forgotten_after_it_was_loaded_is_not_written_back() {
let loaded = load(&config, "gone.example").await;
assert!(save(&config, "gone.example", loaded.epoch).await);
- assert_eq!(forget(&config, Some("https://www.Gone.example/x")).await.unwrap(), 1);
+ assert_eq!(
+ forget(&config, Some("https://www.Gone.example/x"))
+ .await
+ .unwrap(),
+ 1
+ );
// The task that loaded before the forget still holds the old epoch.
assert!(!save(&config, "gone.example", loaded.epoch).await);
assert!(load(&config, "gone.example").await.memory.is_empty());
@@ -149,7 +154,10 @@ async fn forgetting_every_site_counts_them_and_an_address_that_names_no_site_for
let epoch = load(&config, site).await.epoch;
assert!(save(&config, site, epoch).await);
}
- assert_eq!(forget(&config, Some("file:///etc/passwd")).await.unwrap(), 0);
+ assert_eq!(
+ forget(&config, Some("file:///etc/passwd")).await.unwrap(),
+ 0
+ );
assert_eq!(forget(&config, None).await.unwrap(), 2);
}
@@ -192,9 +200,20 @@ async fn a_load_sweeps_site_files_nothing_changed_for_thirty_days() {
#[test]
fn a_site_is_its_host_without_www() {
- assert_eq!(site_of("https://www.Amazon.in/s?k=x").as_deref(), Some("amazon.in"));
- assert_eq!(site_of(" http://shop.test:8080/cart ").as_deref(), Some("shop.test"));
- for none in ["ftp://x.test/", "file:///etc/passwd", "not a url", "http://[::1]/"] {
+ assert_eq!(
+ site_of("https://www.Amazon.in/s?k=x").as_deref(),
+ Some("amazon.in")
+ );
+ assert_eq!(
+ site_of(" http://shop.test:8080/cart ").as_deref(),
+ Some("shop.test")
+ );
+ for none in [
+ "ftp://x.test/",
+ "file:///etc/passwd",
+ "not a url",
+ "http://[::1]/",
+ ] {
assert_eq!(site_of(none), None, "{none}");
}
}
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
index 2538857614..d31700396f 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
@@ -554,14 +554,21 @@ fn v1_memory_capabilities_are_not_advertised() {
#[test]
fn computer_capabilities_disclose_the_components_ceiling() {
- for id in ["settings.desktop_control", "workflows.computer_browser_automation"] {
+ for id in [
+ "settings.desktop_control",
+ "workflows.computer_browser_automation",
+ ] {
let capability = lookup(id).unwrap_or_else(|| panic!("{id} is in the catalog"));
assert!(
- capability.description.contains("[components] computer = false"),
+ capability
+ .description
+ .contains("[components] computer = false"),
"{id} must name the ceiling that switches it off"
);
assert!(
- capability.description.contains("COMPONENT_DISABLED:computer"),
+ capability
+ .description
+ .contains("COMPONENT_DISABLED:computer"),
"{id} must name the typed error a switched-off computer answers"
);
}