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(config): cover document-backed secret reload and forced source nesting
Steven Enamakel0f2e9046ca1b
diff --git a/crates/openhuman-core/src/config/schema/load/branches.rs b/crates/openhuman-core/src/config/schema/load/branches.rsindex 07098b111c..03c8a0087d 100644--- a/crates/openhuman-core/src/config/schema/load/branches.rs+++ b/crates/openhuman-core/src/config/schema/load/branches.rs@@ -7,9 +7,7 @@use super::super::Config;use super::dirs::{default_action_dir, resolve_action_dir, ConfigResolutionSource};use super::env::EnvLookup;-use super::impl_load::{- migration_source, parse_config_boxed,-};+use super::impl_load::{migration_source, parse_config_boxed};use super::migrate::{migrate_cloud_provider_slugs, migrate_legacy_inference_url, migrate_legacy_memory_backend,migrate_legacy_memory_sources, migrate_search_settings,diff --git a/crates/openhuman-core/src/config/schema/load/source/mod.rs b/crates/openhuman-core/src/config/schema/load/source/mod.rsindex 9aa583522f..58de088611 100644--- a/crates/openhuman-core/src/config/schema/load/source/mod.rs+++ b/crates/openhuman-core/src/config/schema/load/source/mod.rs@@ -147,7 +147,9 @@ pub(crate) fn apply_bootstrap(stored: &str, bootstrap_text: Option<&str>) -> Res// A bootstrap file that does not parse is an error, not an empty file:// treating it as empty would silently drop the storage table.let bootstrap: toml::Table = match bootstrap_text {- Some(text) => toml::from_str(text).context("the bootstrap config file is not valid TOML")?,+ Some(text) => {+ toml::from_str(text).context("the bootstrap config file is not valid TOML")?+ }None => toml::Table::default(),};for name in BOOTSTRAP_TABLES {diff --git a/crates/openhuman-core/src/config/schema/load/source/mod_tests.rs b/crates/openhuman-core/src/config/schema/load/source/mod_tests.rsindex df787a51b7..2a619f35b8 100644--- a/crates/openhuman-core/src/config/schema/load/source/mod_tests.rs+++ b/crates/openhuman-core/src/config/schema/load/source/mod_tests.rs@@ -140,8 +140,7 @@ async fn a_document_does_not_decrypt_under_another_scope_or_master_key() {alice.write("default_model = \"m\"\n").await.unwrap();// Another master key fails closed.- let wrong_key =- document_source_keyed(&storage, "alice", &tmp.path().join("a.toml"), keys(2));+ let wrong_key = document_source_keyed(&storage, "alice", &tmp.path().join("a.toml"), keys(2));assert!(wrong_key.read().await.is_err());// Another scope's data key cannot open alice's ciphertext even when the@@ -150,7 +149,12 @@ async fn a_document_does_not_decrypt_under_another_scope_or_master_key() {let sealed = docs.get("config", "alice").await.unwrap().unwrap().doc;let bob_docs = Arc::clone(scoped(&storage, "bob").documents());bob_docs- .put("config", "bob", sealed, tinystoragedrivers::Precondition::None)+ .put(+ "config",+ "bob",+ sealed,+ tinystoragedrivers::Precondition::None,+ ).await.unwrap();let bob = document_source(&storage, "bob", &tmp.path().join("b.toml"));@@ -228,7 +232,10 @@ async fn two_scopes_keep_their_config_apart() {.await.unwrap();assert!(alice.exists().await.unwrap());- assert!(!bob.exists().await.unwrap(), "bob sees nothing of alice's config");+ assert!(+ !bob.exists().await.unwrap(),+ "bob sees nothing of alice's config"+ );bob.write("default_model = \"bob-model\"\n").await.unwrap();assert!(alice.read().await.unwrap().contents.contains("alice-model"));@@ -278,3 +285,58 @@ async fn without_a_shared_backend_config_stays_on_the_file() {assert!(config.config_path.exists());assert_eq!(for_config(&config.config_path).unwrap().label(), "file");}++#[tokio::test]+async fn a_document_backed_config_keeps_secrets_readable_on_reload() {+ let tmp = tempfile::tempdir().unwrap();+ let storage = MemoryStorage::new();+ let _forced = ForcedDocumentSource::new(+ scoped(&storage, "tenant-a"),+ Scope::new("tenant-a").unwrap(),+ keys(3),+ );+ let mut config = config_at(tmp.path(), "m");+ config.api_key = Some("sk-portable".to_string());+ config.save().await.unwrap();++ // Sealed as a whole under the scope key, not field-by-field under the+ // process-local key: the stored text has no per-field ciphertext, and a+ // reload hands back the usable value.+ let reloaded = Config::load_from_config_path(&config.config_path, &config.workspace_dir)+ .await+ .unwrap();+ assert_eq!(reloaded.api_key.as_deref(), Some("sk-portable"));+}++#[test]+fn forced_sources_nest_and_restore() {+ let storage = MemoryStorage::new();+ let outer = ForcedDocumentSource::new(+ scoped(&storage, "outer"),+ Scope::new("outer").unwrap(),+ keys(1),+ );+ {+ let _inner = ForcedDocumentSource::new(+ scoped(&storage, "inner"),+ Scope::new("inner").unwrap(),+ keys(1),+ );+ assert_eq!(+ tests_support::forced_document_scope()+ .unwrap()+ .scope+ .as_str(),+ "inner"+ );+ }+ assert_eq!(+ tests_support::forced_document_scope()+ .unwrap()+ .scope+ .as_str(),+ "outer"+ );+ drop(outer);+ assert!(tests_support::forced_document_scope().is_none());+}