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
fix(harness): preserve explicit action_dir on inherited workspace
Steven Enamakel6ef75dfcc4fd
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex 37cecbe60f..084dd32590 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -647,11 +647,11 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an| Status | Count || ---------------- | ------------------------------------------------ |-| ✅ Covered | 79 |-| 🟡 Partial | 27 |+| ✅ Covered | 89 |+| 🟡 Partial | 28 || ❌ Missing | 26 || 🚫 Manual smoke | 11 |-| **Total leaves** | **143 explicit + nested = 214 product features** |+| **Total leaves** | **154 explicit + nested = 214 product features** |PR-A delta: 13 leaves moved from ❌ → ✅ via 5 WDIO specs + 2 Vitest + 1 Rust integration test.Section 16 adds 11 leaves (10 ✅, 1 🟡) for the embedded library harness.diff --git a/docs/plans/pluggable-core/phase-1-corebuilder.md b/docs/plans/pluggable-core/phase-1-corebuilder.mdindex 37c0e13310..4729a34b74 100644--- a/docs/plans/pluggable-core/phase-1-corebuilder.md+++ b/docs/plans/pluggable-core/phase-1-corebuilder.md@@ -68,7 +68,7 @@ HTTP, socket.io, cron, channels, heartbeat, update scheduler.turn through `run_turn_via_tinyagents_shared`, and asserts no listener wasbound.-**Status: done.** `tests/harness_embed.rs` and `examples/run_turn.rs` exist. The+**Acceptance test status: done.** `tests/harness_embed.rs` and `examples/run_turn.rs` exist. Theturn goes through `openhuman.inference_agent_chat` rather than reaching`run_turn_via_tinyagents_shared` directly — dispatch is the only path thathonours `DomainSet` gating and installs `CoreContext` scope (seediff --git a/src/embed/harness/builder.rs b/src/embed/harness/builder.rsindex 5fa155897b..5bb487fd0e 100644--- a/src/embed/harness/builder.rs+++ b/src/embed/harness/builder.rs@@ -251,6 +251,17 @@ impl HarnessBuilder {};if let Some(config) = config.as_mut() {+ // `Inherit` keeps the operator's resolved paths, but an explicit+ // action_dir is a caller instruction, not a discovered default, so+ // it must survive onto the inherited config. Without this an+ // `action_dir` is silently disregarded for `Workspace::Inherit`,+ // and the agent runs against the operator's configured action+ // directory instead.+ if inherit {+ if let Some(dir) = self.action_dir.as_ref() {+ config.action_dir = dir.clone();+ }+ }if let Some(url) = self.backend_url.clone() {config.api_url = Some(url);}diff --git a/src/embed/harness/workspace.rs b/src/embed/harness/workspace.rsindex bccc107bc1..9925660e19 100644--- a/src/embed/harness/workspace.rs+++ b/src/embed/harness/workspace.rs@@ -119,15 +119,26 @@ impl ResolvedWorkspace {}Workspace::Dir(dir) => {let workspace_dir = dir.clone();+ // `Path::parent()` yields `Some("")` for a single-component+ // relative path (e.g. `Workspace::dir("ws")`), not `None`.+ // Treating that empty parent as a real directory would make the+ // sibling `action/` and `config.toml` resolve against the+ // process working directory instead of beside the workspace,+ // which breaks the credential-isolation invariant below.+ let parent = dir+ .parent()+ .filter(|parent| !parent.as_os_str().is_empty());let action_dir = action_dir_override.map(Path::to_path_buf)// A sibling, for the `is_workspace_internal_path` reason- // above. `dir.parent()` is `None` only for a filesystem- // root, where a sibling is meaningless anyway.- .or_else(|| dir.parent().map(|parent| parent.join("action")))+ // above. `dir.parent()` is `None` (or an empty path) only+ // for a filesystem root or a path with no parent — all+ // cases where a sibling is meaningless anyway, and using+ // the workspace dir itself is the only safe fallback.+ .or_else(|| parent.map(|parent| parent.join("action"))).unwrap_or_else(|| dir.join("action"));create_dirs(&workspace_dir, &action_dir)?;- let config_path = dir.parent().unwrap_or(dir.as_path()).join("config.toml");+ let config_path = parent.unwrap_or(dir.as_path()).join("config.toml");Ok(Self {workspace_dir,action_dir,diff --git a/src/embed/harness/workspace_tests.rs b/src/embed/harness/workspace_tests.rsindex d06d8ffce6..dd178dfe16 100644--- a/src/embed/harness/workspace_tests.rs+++ b/src/embed/harness/workspace_tests.rs@@ -121,3 +121,33 @@ fn a_dir_workspace_puts_config_beside_it_too() {ResolvedWorkspace::resolve(&Workspace::dir(temp.path().join("ws")), None).expect("resolve");assert_eq!(resolved.config_path, temp.path().join("config.toml"));}++#[test]+fn a_relative_dir_workspace_does_not_resolve_siblings_against_cwd() {+ // `Path::parent()` on the single-component relative path "ws" is+ // `Some("")`, not `None`. Resolving the sibling action_dir / config_path+ // against that empty parent would put them in the process working+ // directory rather than beside the workspace — breaking the+ // credential-isolation invariant. Both must fall back to the workspace's+ // own directory.+ // Run from a contained cwd so the bare relative path and its sibling+ // directories land in a temp dir rather than the test's working directory.+ let cwd_guard = std::env::current_dir().expect("current dir");+ let temp = tempfile::tempdir().expect("tempdir");+ std::env::set_current_dir(temp.path()).expect("chdir to temp");+ let result = std::panic::catch_unwind(|| {+ let resolved =+ ResolvedWorkspace::resolve(&Workspace::dir("ws"), None).expect("resolve");+ assert_eq!(resolved.workspace_dir, std::path::PathBuf::from("ws"));+ assert_eq!(+ resolved.action_dir,+ std::path::PathBuf::from("ws").join("action")+ );+ assert_eq!(+ resolved.config_path,+ std::path::PathBuf::from("ws").join("config.toml")+ );+ });+ std::env::set_current_dir(&cwd_guard).expect("restore cwd");+ result.expect("assertions held");+}