Skip to content

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

fix(config): keep sealed storage url when decryption fails

Steven Enamakel0e6b54db4e60
diff --git a/crates/openhuman-core/src/config/schema/load/secrets.rs b/crates/openhuman-core/src/config/schema/load/secrets.rs
index 12672f7f58..ae97f88ff2 100644
--- a/crates/openhuman-core/src/config/schema/load/secrets.rs
+++ b/crates/openhuman-core/src/config/schema/load/secrets.rs
@@ -102,7 +102,14 @@ pub(super) fn decrypt_config_secrets(config: &mut Config, openhuman_dir: &Path)
decrypt_optional_secret(&store, &mut config.api_key, "api_key")?;
// A MongoDB URL carries the database password.
+ // Fail closed: if the sealed URL cannot be opened, keep the ciphertext so
+ // the storage backend fails to open at boot instead of the field being
+ // cleared into the "no URL" sentinel (the classic on-disk layout).
+ let sealed_storage_url = config.storage.url.clone();
decrypt_optional_secret(&store, &mut config.storage.url, "storage.url")?;
+ if config.storage.url.is_none() && sealed_storage_url.is_some() {
+ config.storage.url = sealed_storage_url;
+ }
decrypt_optional_secret(&store, &mut config.seltz.api_key, "seltz.api_key")?;
decrypt_optional_secret(
diff --git a/crates/openhuman-rpc/src/session_store/mod.rs b/crates/openhuman-rpc/src/session_store/mod.rs
index 5fe0fa0e45..2f9d161f44 100644
--- a/crates/openhuman-rpc/src/session_store/mod.rs
+++ b/crates/openhuman-rpc/src/session_store/mod.rs
@@ -161,16 +161,18 @@ pub fn install() {
pub async fn install_for_host() -> anyhow::Result<()> {
let url = match std::env::var(openhuman_core::storage::STORAGE_URL_VAR) {
Ok(url) if !url.trim().is_empty() => Some(url.trim().to_string()),
- // A config that cannot be loaded may be hiding a `[storage] url`:
- // fail the boot rather than quietly choosing the classic layout.
- _ => {
- let config = openhuman_core::config::rpc::load_config_with_timeout()
- .await
- .map_err(|error| {
- anyhow::anyhow!("loading the config to read [storage]: {error}")
- })?;
- openhuman_core::storage::configured_url(&config)
- }
+ _ => match openhuman_core::config::rpc::load_config_with_timeout().await {
+ Ok(config) => openhuman_core::storage::configured_url(&config),
+ // An unreadable config keeps the desktop booting on the classic
+ // layout, as it always has. Remote deployments pin the backend
+ // with `OPENHUMAN_STORAGE_URL`, which never reads the config.
+ Err(error) => {
+ tracing::warn!(
+ "[session_store] config unavailable ({error}); keeping the on-disk layout"
+ );
+ None
+ }
+ },
};
install_for_url(url).await
}
diff --git a/crates/openhuman-rpc/src/session_store/mod_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rs
index 12379cef3f..8bee6a2d84 100644
--- a/crates/openhuman-rpc/src/session_store/mod_tests.rs
+++ b/crates/openhuman-rpc/src/session_store/mod_tests.rs
@@ -52,12 +52,25 @@ fn recovery_interrupts_turns_left_in_flight() {
/// The provider and storage slots are process-wide; these tests take turns.
static SLOTS: Mutex<()> = Mutex::new(());
+/// Puts the process-global storage backend back as a test found it.
+fn restore_backend(previous: Option<Arc<dyn tinystoragedrivers::StorageBackend>>) {
+ match previous {
+ Some(backend) => {
+ openhuman_core::storage::install(backend);
+ }
+ None => {
+ openhuman_core::storage::clear();
+ }
+ }
+}
+
#[tokio::test]
async fn a_storage_url_installs_the_driver_backed_store() {
let _turn = SLOTS
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let previous = openhuman_core::agent::session_store::installed();
+ let previous_backend = openhuman_core::storage::installed();
install_for_url(Some("memory".into())).await.unwrap();
let provider = openhuman_core::agent::session_store::installed().unwrap();
@@ -85,7 +98,7 @@ async fn a_storage_url_installs_the_driver_backed_store() {
.unwrap()
.is_none());
- openhuman_core::storage::clear();
+ restore_backend(previous_backend);
openhuman_core::agent::session_store::restore(previous);
}
@@ -95,6 +108,7 @@ async fn no_url_keeps_the_classic_layout() {
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let previous = openhuman_core::agent::session_store::installed();
+ let previous_backend = openhuman_core::storage::installed();
install_for_url(None).await.unwrap();
let provider = openhuman_core::agent::session_store::installed().unwrap();
assert!(
@@ -102,6 +116,7 @@ async fn no_url_keeps_the_classic_layout() {
"the file layout is installed"
);
assert!(openhuman_core::storage::installed().is_none());
+ restore_backend(previous_backend);
openhuman_core::agent::session_store::restore(previous);
}
@@ -124,9 +139,40 @@ async fn restoring_the_classic_layout_clears_a_previous_backend() {
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
let previous = openhuman_core::agent::session_store::installed();
+ let previous_backend = openhuman_core::storage::installed();
install_for_url(Some("memory".into())).await.unwrap();
assert!(openhuman_core::storage::installed().is_some());
install_for_url(None).await.unwrap();
assert!(openhuman_core::storage::installed().is_none());
+ restore_backend(previous_backend);
+ openhuman_core::agent::session_store::restore(previous);
+}
+
+#[tokio::test]
+async fn the_host_reads_the_storage_url_from_the_environment() {
+ let _turn = SLOTS
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ let previous = openhuman_core::agent::session_store::installed();
+ let previous_backend = openhuman_core::storage::installed();
+ let var = openhuman_core::storage::STORAGE_URL_VAR;
+ let old = std::env::var_os(var);
+
+ std::env::set_var(var, " memory ");
+ let booted = install_for_host().await;
+ let driver = openhuman_core::storage::installed().map(|b| b.driver());
+
+ std::env::set_var(var, "ftp://nowhere");
+ let refused = install_for_host().await;
+
+ match old {
+ Some(value) => std::env::set_var(var, value),
+ None => std::env::remove_var(var),
+ }
+ restore_backend(previous_backend);
openhuman_core::agent::session_store::restore(previous);
+
+ booted.unwrap();
+ assert_eq!(driver, Some("memory"));
+ assert!(refused.is_err(), "an unusable env URL fails the boot");
}
diff --git a/scripts/ci/check-dep-sim-calibration.sh b/scripts/ci/check-dep-sim-calibration.sh
index b0170ba208..60a5011c5a 100755
--- a/scripts/ci/check-dep-sim-calibration.sh
+++ b/scripts/ci/check-dep-sim-calibration.sh
@@ -99,8 +99,10 @@ cd "$(dirname "$0")/../.."
# five names from the Linux flows graph; native builds remain at three.
# 311 -> 320 on 2026-10-07: tinyskills v0.2.8 (#7054) brings cap-std and its
# dependencies into the flows graph.
-# This matches the current `flows:342:320:3` entry in
+# 320 -> 313 on 2026-10-09: the tinyagents and tinyflows mains shed seven
+# names from the flows graph.
+# This matches the current `flows:335:313:2` entry in
# scripts/kernel-floor.limits; its preceding entries are historical.
-EXPECTED_NAMES=320
+EXPECTED_NAMES=313
exec python3 scripts/dep-sim.py --cut-nothing --expect-names "${EXPECTED_NAMES}"