Skip to content

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

fix(config): resolve OPENHUMAN_WORKSPACE inside .openhuman instead of discarding config\n\nresolve_config_dir_for_workspace derived the config dir as parent()/.openhuman\nand, for any path ending in 'workspace', returned it without checking it exists.\nSo OPENHUMAN_WORKSPACE=~/.openhuman/workspace resolved to ~/.openhuman/.openhuman\n(doubled, non-existent); the real ~/.openhuman/config.toml was never read and\nevery setting silently reverted to schema defaults, with no warning.\n\nRecognize the modern layout (workspace basename 'workspace' whose parent is the\n.openhuman config dir) by pure path structure so it resolves to the parent and\nloads the real config; guard the legacy sibling arm on .exists(); and warn when\nthe resolved config dir has no config.toml. Tighten the vacuous existing test\nand add regression coverage for modern/legacy/fall-through layouts.\n\nFixes #6079\n

shanu51adb16507dc
diff --git a/src/openhuman/config/schema/load/dirs.rs b/src/openhuman/config/schema/load/dirs.rs
index b9e0fc331d..101438a6de 100644
--- a/src/openhuman/config/schema/load/dirs.rs
+++ b/src/openhuman/config/schema/load/dirs.rs
@@ -265,18 +265,42 @@ pub(crate) fn resolve_config_dir_for_workspace(workspace_dir: &Path) -> (PathBuf
);
}
- let legacy_config_dir = workspace_dir
- .parent()
- .map(|parent| parent.join(".openhuman"));
+ let has_workspace_basename = workspace_dir
+ .file_name()
+ .is_some_and(|name| name == std::ffi::OsStr::new("workspace"));
+ let parent = workspace_dir.parent();
+
+ // Modern default layout: the workspace lives *inside* the `.openhuman`
+ // config dir (`~/.openhuman/workspace`), so the parent IS the config dir.
+ // `default_config_and_workspace_dirs` produces exactly this shape. This is
+ // a pure path-structure decision — no `.exists()` probe — so pointing
+ // `OPENHUMAN_WORKSPACE` at `~/.openhuman/workspace` resolves to
+ // `~/.openhuman` and loads the real `~/.openhuman/config.toml` instead of
+ // the doubled, non-existent `~/.openhuman/.openhuman` (#6079).
+ if has_workspace_basename {
+ if let Some(parent) = parent {
+ if parent
+ .file_name()
+ .is_some_and(|name| name == std::ffi::OsStr::new(default_root_dir_name()))
+ {
+ return (parent.to_path_buf(), workspace_config_dir);
+ }
+ }
+ }
+
+ let legacy_config_dir = parent.map(|parent| parent.join(".openhuman"));
if let Some(legacy_dir) = legacy_config_dir {
+ // Legacy sibling layout: `<something>/workspace` with config living in a
+ // sibling `<something>/.openhuman`.
if legacy_dir.join("config.toml").exists() {
return (legacy_dir, workspace_config_dir);
}
- if workspace_dir
- .file_name()
- .is_some_and(|name| name == std::ffi::OsStr::new("workspace"))
- {
+ // Same layout without a config.toml yet, but only when the sibling
+ // `.openhuman` actually exists — never return a non-existent doubled
+ // path (the original #6079 bug: this arm fired for any `workspace`
+ // basename, so `~/.openhuman/workspace` produced `~/.openhuman/.openhuman`).
+ if has_workspace_basename && legacy_dir.exists() {
return (legacy_dir, workspace_config_dir);
}
}
@@ -387,6 +411,27 @@ pub(crate) async fn resolve_runtime_config_dirs_with(
if !custom_workspace.is_empty() {
let (openhuman_dir, workspace_dir) =
resolve_config_dir_for_workspace(&PathBuf::from(custom_workspace));
+ // A misresolved config dir (e.g. `OPENHUMAN_WORKSPACE` pointing
+ // inside `.openhuman`, #6079) silently reverts every setting to
+ // schema defaults, and the resolved workspace_dir stays correct so
+ // the mistake is otherwise invisible. Name the chosen config dir and
+ // whether it holds a `config.toml`: warn when it does not (the
+ // fall-to-defaults case), debug on the happy path.
+ let config_found = openhuman_dir.join("config.toml").exists();
+ if config_found {
+ tracing::debug!(
+ config_dir = %openhuman_dir.display(),
+ workspace_dir = %workspace_dir.display(),
+ "OPENHUMAN_WORKSPACE resolved config dir; config.toml present"
+ );
+ } else {
+ tracing::warn!(
+ config_dir = %openhuman_dir.display(),
+ workspace_dir = %workspace_dir.display(),
+ "OPENHUMAN_WORKSPACE resolved to a config dir with no config.toml; \
+ settings will fall back to schema defaults (see #6079)"
+ );
+ }
return Ok((
openhuman_dir,
workspace_dir,
diff --git a/src/openhuman/config/schema/load_tests_part_01_tests.rs b/src/openhuman/config/schema/load_tests_part_01_tests.rs
index 049bf64abf..c61cf60afb 100644
--- a/src/openhuman/config/schema/load_tests_part_01_tests.rs
+++ b/src/openhuman/config/schema/load_tests_part_01_tests.rs
@@ -554,13 +554,74 @@ async fn missing_env_workspace_uses_pre_login_default() {
#[test]
fn resolve_config_dir_for_workspace_returns_parent_and_workspace() {
+ // `default_root_dir_name()` reads `OPENHUMAN_APP_ENV`; hold the shared env
+ // lock so a concurrent staging-flip test can't turn the root into
+ // `.openhuman-staging` mid-assertion.
+ let _g = env_lock();
let ws = PathBuf::from("/home/test/.openhuman/workspace");
let (config_dir, workspace_dir) = resolve_config_dir_for_workspace(&ws);
- // Config dir is the parent of workspace.
- assert!(
- config_dir.ends_with(".openhuman") || config_dir == PathBuf::from("/home/test/.openhuman")
+ // Modern default layout: the config dir IS the `.openhuman` parent, resolved
+ // by pure path structure (no filesystem probe), so the fake path resolves
+ // even though it doesn't exist. The old, buggy code returned the doubled
+ // `/home/test/.openhuman/.openhuman` here — which `Path::ends_with` still
+ // matched against `".openhuman"` (whole-component match), making the old
+ // assertion vacuous. `assert_eq!` against the exact parent catches that.
+ assert_eq!(config_dir, PathBuf::from("/home/test/.openhuman"));
+ assert_eq!(workspace_dir, ws);
+}
+
+#[test]
+fn resolve_config_dir_for_workspace_modern_layout_does_not_double_openhuman() {
+ // The #6079 repro: `OPENHUMAN_WORKSPACE=~/.openhuman/workspace` must resolve
+ // to `~/.openhuman` (where `config.toml` lives), NOT the doubled
+ // `~/.openhuman/.openhuman`, which never exists and silently reverts every
+ // setting to schema defaults. This is a pure path-structure decision, so it
+ // holds for a non-existent path.
+ let _g = env_lock();
+ let ws = PathBuf::from("/home/test/.openhuman/workspace");
+ let (config_dir, workspace_dir) = resolve_config_dir_for_workspace(&ws);
+ assert_eq!(config_dir, PathBuf::from("/home/test/.openhuman"));
+ assert_ne!(
+ config_dir,
+ PathBuf::from("/home/test/.openhuman/.openhuman"),
+ "must never return the doubled .openhuman/.openhuman path"
+ );
+ assert_eq!(workspace_dir, ws);
+}
+
+#[test]
+fn resolve_config_dir_for_workspace_legacy_sibling_layout_is_preserved() {
+ // Legacy layout: `<tmp>/project/workspace` with a real sibling
+ // `<tmp>/project/.openhuman/config.toml` still resolves to the sibling
+ // `.openhuman`. This arm probes the filesystem, so use a real temp dir.
+ let tmp = tempfile::tempdir().unwrap();
+ let project = tmp.path().join("project");
+ let legacy = project.join(".openhuman");
+ let ws = project.join("workspace");
+ std::fs::create_dir_all(&legacy).unwrap();
+ std::fs::create_dir_all(&ws).unwrap();
+ std::fs::write(legacy.join("config.toml"), "").unwrap();
+
+ let (config_dir, workspace_dir) = resolve_config_dir_for_workspace(&ws);
+ assert_eq!(config_dir, legacy);
+ assert_eq!(workspace_dir, ws);
+}
+
+#[test]
+fn resolve_config_dir_for_workspace_workspace_basename_without_config_falls_through() {
+ // Basename is `workspace`, but the parent is neither `.openhuman` nor has a
+ // real sibling `.openhuman/config.toml`, and nothing exists on disk. It must
+ // fall through to `(ws, ws/workspace)` — never a doubled `.openhuman/.openhuman`.
+ let _g = env_lock();
+ let ws = PathBuf::from("/home/test/some-project/workspace");
+ let (config_dir, workspace_dir) = resolve_config_dir_for_workspace(&ws);
+ assert_eq!(config_dir, ws);
+ assert_eq!(workspace_dir, ws.join("workspace"));
+ assert_ne!(
+ config_dir,
+ PathBuf::from("/home/test/some-project/.openhuman"),
+ "a non-existent sibling .openhuman must not be returned"
);
- assert!(workspace_dir.ends_with("workspace"));
}
#[test]
diff --git a/src/openhuman/inference/embeddings/cloud_adapter_tests.rs b/src/openhuman/inference/embeddings/cloud_adapter_tests.rs
index 7cc885802a..ba87e49476 100644
--- a/src/openhuman/inference/embeddings/cloud_adapter_tests.rs
+++ b/src/openhuman/inference/embeddings/cloud_adapter_tests.rs
@@ -74,15 +74,21 @@ fn default_scope_falls_back_to_the_pre_login_user_dir() {
/// reintroduce "No backend session" for that deployment.
#[test]
fn env_workspace_scope_is_the_config_dir_not_the_raw_workspace() {
- // A path that does not exist on disk, so the resolver's `config.toml`
- // probes both miss and the `"workspace"` basename rule decides.
- let workspace = std::path::Path::new("/nonexistent-openhuman-test-root/workspace");
+ // Legacy sibling layout: `<X>/workspace` with credentials in `<X>/.openhuman`.
+ // The resolver only maps a `workspace`-basename override to a sibling
+ // `.openhuman` when that sibling actually exists (#6079 guard — it must never
+ // fabricate a non-existent doubled path), so create it on a real temp dir.
+ let root = tempfile::tempdir().unwrap();
+ let base = root.path();
+ let workspace = base.join("workspace");
+ let sibling_config = base.join(".openhuman");
+ std::fs::create_dir_all(&workspace).unwrap();
+ std::fs::create_dir_all(&sibling_config).unwrap();
- let resolved = env_workspace_state_dir(workspace);
+ let resolved = env_workspace_state_dir(&workspace);
assert_eq!(
- resolved,
- std::path::Path::new("/nonexistent-openhuman-test-root/.openhuman"),
+ resolved, sibling_config,
"a `.../workspace` override must resolve to its sibling .openhuman config dir"
);
assert_ne!(