The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(profiles): add layout tests for profile directory resolution
Steven Enamakel612e816ffbb6
diff --git a/crates/openhuman-core/src/profiles/layout_tests.rs b/crates/openhuman-core/src/profiles/layout_tests.rsindex ecfeb6bab6..2b01ff5ac7 100644--- a/crates/openhuman-core/src/profiles/layout_tests.rs+++ b/crates/openhuman-core/src/profiles/layout_tests.rs@@ -1,13 +1,15 @@use super::*;+use crate::profiles::ProfileIdMode;fn id() -> ProfileId {- ProfileId::for_user("layout-user", crate::profiles::ProfileIdMode::Raw).unwrap()+ ProfileId::for_user("layout-user", ProfileIdMode::Raw).unwrap()}#[test]-fn every_path_sits_under_the_agent_directory() {- let layout = ProfileLayout::new(Path::new("/srv/oh"), &id());- assert_eq!(layout.dir, Path::new("/srv/oh/agents").join(id().as_str()));+fn every_path_sits_under_the_profile_directory() {+ let layout = profile_layout(Path::new("/srv/oh"), &id());+ assert_eq!(layout.dir, Path::new("/srv/oh/users").join(id().as_str()));+ assert_eq!(layout.meta_path, layout.dir.join("profile.toml"));for path in [&layout.meta_path,&layout.config_path,@@ -19,8 +21,19 @@ fn every_path_sits_under_the_agent_directory() {}#[test]-fn the_config_is_rooted_in_the_agent_and_bound_to_its_memory() {- let layout = ProfileLayout::new(Path::new("/srv/oh"), &id());+fn the_saas_layout_is_the_desktop_user_layout() {+ let root = Path::new("/srv/oh");+ let layout = profile_layout(root, &id());+ assert_eq!(+ layout.dir,+ crate::config::schema::user_openhuman_dir(root, id().as_str())+ );+ assert_eq!(layout.dir.parent(), Some(users_dir(root).as_path()));+}++#[test]+fn the_config_is_rooted_in_the_profile_and_bound_to_its_memory() {+ let layout = profile_layout(Path::new("/srv/oh"), &id());let config = profile_config(&layout, &id());assert_eq!(config.config_path, layout.config_path);assert_eq!(config.workspace_dir, layout.workspace_dir);@@ -34,10 +47,40 @@ fn the_memory_root_is_a_valid_layout_root() {crate::memory::scope::validate_root(&memory_root(&id())).unwrap();}+/// Under `users/<id>`, `memory::scope::user_root` reads an account id out of+/// the config path. A raw profile id that looks like a TinyHumans account+/// (24 hex) would give `org:<id>`; layout v3 would bind the engine there and+/// ignore `user:<id>`. The pin keeps a profile on the root it is forced to.+#[test]+fn a_profile_binds_its_user_root_never_an_org_root() {+ use crate::memory::scope::{self, MemoryIdentity};+ let id = ProfileId::for_user("65f1c0ffee0123456789abcd", ProfileIdMode::Raw).unwrap();+ assert_eq!(id.as_str(), "65f1c0ffee0123456789abcd");+ let layout = profile_layout(Path::new("/srv/oh"), &id);+ let config = profile_config(&layout, &id);++ // The hazard the pin closes.+ assert_eq!(+ scope::user_root(&config).as_deref(),+ Some("org:65f1c0ffee0123456789abcd")+ );+ // The pin: legacy layout, so `memory::engine::resolve` binds no org root+ // and every operation is confined to `user:<id>`.+ assert_eq!(config.memory.layout, MemoryLayoutMode::Legacy);+ assert!(!scope::layout_is_v3(&config));+ let bound = MemoryIdentity::root().resolve(&config);+ assert_eq!(bound.root().to_string(), "user:65f1c0ffee0123456789abcd");+ assert_eq!(bound.agent_id, id.as_str());+ let confined = crate::memory::user_scope::confinement_in(true, &config)+ .unwrap()+ .unwrap();+ assert_eq!(confined.to_string(), "user:65f1c0ffee0123456789abcd");+}+#[test]fn the_memory_binding_wins_over_pins_and_teams() {use crate::memory::scope::MemoryIdentity;- let layout = ProfileLayout::new(Path::new("/srv/oh"), &id());+ let layout = profile_layout(Path::new("/srv/oh"), &id());let mut config = profile_config(&layout, &id());config.memory.agents.insert("planner".into(),@@ -50,7 +93,7 @@ fn the_memory_binding_wins_over_pins_and_teams() {#[test]fn the_policy_is_on_and_closed() {- let layout = ProfileLayout::new(Path::new("/srv/oh"), &id());+ let layout = profile_layout(Path::new("/srv/oh"), &id());let autonomy = profile_config(&layout, &id()).autonomy;assert!(autonomy.enabled);assert_eq!(autonomy.level, AutonomyLevel::Supervised);@@ -61,9 +104,9 @@ fn the_policy_is_on_and_closed() {}#[test]-fn artifacts_land_in_the_agents_sandbox() {- let id = ProfileId::for_user("alice", crate::profiles::ProfileIdMode::Raw).unwrap();- let layout = ProfileLayout::new(std::path::Path::new("/srv/oh"), &id);+fn artifacts_land_in_the_profiles_sandbox() {+ let id = ProfileId::for_user("alice", ProfileIdMode::Raw).unwrap();+ let layout = profile_layout(Path::new("/srv/oh"), &id);let config = profile_config(&layout, &id);assert!(config.files_dir().starts_with(&layout.sandbox_dir));}