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(e2e): backfill coverage for the git config guard, the retained workspace denylist, and the null-classed driver refusal\n\nThree of the four gaps found auditing #5672, #5807, #5825 and #5847. Each test drives\nthe surface an agent actually calls, and each was checked by reverting its fix and\nconfirming the test fails naming its own assertion.\n\n- #5672 — a repository config naming a command does not get to run it, asserted through\n `GitOperationsTool::execute` rather than the private helper the unit suite uses. The\n assertion is a marker file the planted `core.fsmonitor` hook would create: an error\n alone would not distinguish "refused" from "refused after spawning git". Revert the\n guard and the hook runs *and* the tool returns a clean status payload, so the agent is\n told everything is fine while attacker-controlled code executes.\n A second test pins the other direction — an ordinary `git init` + identity still works\n — so a future tightening of `ALLOWED_REPO_CONFIG` that breaks real repositories fails\n here rather than in the field.\n\n- #5847 — the one behaviour deliberately retained when TinyPlace was deleted. Agent file\n tools cannot read or write `tinyplace/` inside the workspace at full autonomy, and the\n file is byte-identical afterwards, so a refusal that only prints an error would not\n pass. `redirect_links` and `codegraph` are asserted alongside it: all three are\n retained-after-removal entries with the same rationale, and a test naming only\n `tinyplace` would miss a regression that took all three. A control read of an ordinary\n workspace file keeps the test from passing because everything is blocked.\n\n- #5807 — importing into a driver deliberately given `class = "null"` names that driver\n and its class, and does not blame a build with no memory module. Driven through\n `migration_helpers::rpc::migrate_openclaw`, the function the `config.openclaw` RPC\n handler calls, with an explicit `Config` so the assertion does not depend on\n process-global state shared with the rest of the merged test binary.\n\n#5825 is deliberately not covered, and the reason is recorded rather than papered over:\nno provider reachable from an integration target exposes `as_scoring()`, so the only\ntest that could be written there asserts the fail-open fallback — which is the\npre-change behaviour and therefore passes with the fix reverted. A vacuous test that\nsatisfies the string-match gate would be worse than the gap.\n\nOne bug found while writing these: #5672's refusal message never reaches the agent. Every\noperation is preceded by a `rev-parse --is-inside-work-tree` probe that runs through the\nsame guarded function, so a refused probe collapses to "Not in a git repository" for a\ndirectory that plainly is one. The security property is unaffected; the diagnostic is\nlost. The test asserts the property that holds and carries a comment saying why it does\nnot assert the message.\n
M3gA-Mind7cd885b65e17
diff --git a/tests/raw_coverage/tools_agent_credentials_state_raw_coverage_e2e.rs b/tests/raw_coverage/tools_agent_credentials_state_raw_coverage_e2e.rsindex 54467a7ae2..e2ca99b416 100644--- a/tests/raw_coverage/tools_agent_credentials_state_raw_coverage_e2e.rs+++ b/tests/raw_coverage/tools_agent_credentials_state_raw_coverage_e2e.rs@@ -957,3 +957,167 @@ async fn round16_app_state_config_and_session_snapshot_edges() {assert!(cleared.encryption_key.is_none());assert!(cleared.onboarding_tasks.is_none());}++/// #5847 — the one behaviour deliberately kept when TinyPlace was deleted.+///+/// The removal took ~49,600 lines but retained a single entry on the+/// workspace-internal denylist, because an upgraded profile can still hold+/// `tinyplace/` state written by an older version — encrypted identity and+/// session material. Nothing in any e2e lane asserted it, which makes the entry+/// look like a leftover reference to a deleted domain rather than the guard it+/// is: exactly the line a future cleanup deletes as dead.+///+/// Driven through the agent file tools rather than `is_workspace_internal_path`+/// directly, because the question is not whether the predicate is right — the+/// unit suite covers that — but whether the tools an agent actually calls sit+/// behind it, at the most permissive autonomy tier there is.+///+/// `redirect_links` and `codegraph` are asserted alongside it: all three are+/// retained-after-removal entries with the same rationale, so one regression+/// would take all three and a test naming only `tinyplace` would miss it.+#[tokio::test]+async fn file_tools_cannot_reach_retained_legacy_state_in_the_workspace() {+ use openhuman_core::openhuman::config::AutonomyConfig;+ use openhuman_core::openhuman::security::AutonomyLevel;+ use openhuman_core::openhuman::tools::{FileReadTool, FileWriteTool};++ let tmp = tempdir();+ let workspace = tmp.path().to_path_buf();+ std::fs::create_dir_all(&workspace).expect("workspace");++ // Full autonomy, and the workspace is also the action dir — the most+ // permissive shape a real install can take. If the guard holds here it+ // holds everywhere.+ let security = Arc::new(SecurityPolicy::from_config(+ &AutonomyConfig {+ level: AutonomyLevel::Full,+ max_actions_per_hour: 10_000,+ ..Default::default()+ },+ &workspace,+ &workspace,+ ));+ let read = FileReadTool::new(security.clone());+ let write = FileWriteTool::new(security.clone());++ // Paths are workspace-relative on purpose: `workspace_only` is on by+ // default and rejects every absolute path outright+ // (`security/policy/path_checks.rs:88`), so an absolute path would be+ // refused for a reason that has nothing to do with the denylist under test.+ // Relative is also what an agent actually sends — file tools resolve them+ // from `action_dir`.+ //+ // A control: an ordinary workspace file must stay reachable, so a passing+ // test cannot be explained by everything being blocked.+ std::fs::write(workspace.join("notes.md"), "reachable\n").expect("write control file");+ let control = read+ .execute(json!({"path": "notes.md"}))+ .await+ .expect("control read");+ assert!(+ !control.is_error && control.output().contains("reachable"),+ "an ordinary workspace file must remain readable: {}",+ control.output()+ );++ for legacy in ["tinyplace", "redirect_links", "codegraph"] {+ let dir = workspace.join(legacy);+ std::fs::create_dir_all(&dir).expect("legacy dir");+ let secret = dir.join("session.json");+ let original = format!("{{\"legacy\":\"{legacy}\",\"token\":\"do-not-read\"}}");+ std::fs::write(&secret, &original).expect("seed legacy state");++ let relative = format!("{legacy}/session.json");+ let attempted_read = read+ .execute(json!({"path": relative}))+ .await+ .expect("read returns a ToolResult");+ assert!(+ attempted_read.is_error,+ "{legacy}: agent read of retained legacy state succeeded: {}",+ attempted_read.output()+ );+ assert!(+ !attempted_read.output().contains("do-not-read"),+ "{legacy}: the secret leaked into the tool output: {}",+ attempted_read.output()+ );++ let attempted_write = write+ .execute(json!({"path": format!("{legacy}/session.json"), "content": "clobbered"}))+ .await+ .expect("write returns a ToolResult");+ assert!(+ attempted_write.is_error,+ "{legacy}: agent write into retained legacy state succeeded: {}",+ attempted_write.output()+ );+ // The refusal has to be a refusal, not a message printed after the fact.+ assert_eq!(+ std::fs::read_to_string(&secret).expect("legacy file still present"),+ original,+ "{legacy}: the file was modified despite the tool reporting an error"+ );+ }+}++/// #5807 — a driver deliberately given `class = "null"` is named as such, not+/// blamed on a build that has no memory module.+///+/// `admit` accepts a non-built-in driver id carrying `class = "null"` verbatim+/// (the `built_in_class` consistency check is skipped for ids that are not+/// built in), so the binding reports `class = Null` with a `driver_id` that is+/// not `"null"`. Keying the refusal reason on that id put this config in the+/// modules-off arm and told a user with a working modules build to go and+/// investigate their build flags.+///+/// Driven through `migration_helpers::rpc::migrate_openclaw` — the function the+/// `config.openclaw` RPC handler calls — rather than the private wrapper the+/// unit test uses, and with an explicit `Config` so the assertion does not+/// depend on process-global config state shared with the rest of this binary.+///+/// This runs in every feature configuration on purpose: the misdirection it+/// guards against is one a *modules-enabled* build hits.+#[tokio::test]+async fn openclaw_import_names_a_null_classed_driver_rather_than_the_build() {+ use openhuman_core::openhuman::config::migration_helpers::rpc as migration_rpc;+ use openhuman_core::openhuman::config::schema::{MemoryDriverConfig, MemorySubsystemConfig};++ let tmp = tempdir();+ let mut config = Config::default();+ config.workspace_dir = tmp.path().join("workspace");+ config.config_path = tmp.path().join("config.toml");+ std::fs::create_dir_all(&config.workspace_dir).expect("workspace");++ let mut drivers = std::collections::BTreeMap::new();+ drivers.insert(+ "mynull".to_string(),+ MemoryDriverConfig {+ class: Some("null".to_string()),+ ..Default::default()+ },+ );+ config.subsystems.memory = MemorySubsystemConfig {+ driver: "mynull".to_string(),+ drivers,+ ..Default::default()+ };++ let source = tmp.path().join("openclaw-src");+ std::fs::create_dir_all(&source).expect("source workspace");+ std::fs::write(source.join("MEMORY.md"), "# Note\nkeep me").expect("seed source");++ let err = migration_rpc::migrate_openclaw(&config, Some(source), false)+ .await+ .expect_err("importing into a null-classed driver must refuse");++ assert!(+ err.contains("mynull") && err.contains("class"),+ "the refusal must name the configured driver and its class; got: {err}"+ );+ assert!(+ !err.contains("no memory module compiled in"),+ "a deliberately null-classed driver must not be reported as a modules-off \+ build — that is the misdirection #5807 fixed; got: {err}"+ );+}diff --git a/tests/raw_coverage/tools_network_channels_raw_coverage_e2e.rs b/tests/raw_coverage/tools_network_channels_raw_coverage_e2e.rsindex fd5b3f352b..98decc4a1e 100644--- a/tests/raw_coverage/tools_network_channels_raw_coverage_e2e.rs+++ b/tests/raw_coverage/tools_network_channels_raw_coverage_e2e.rs@@ -412,3 +412,118 @@ fn run_git(repo: &std::path::Path, args: &[&str]) {String::from_utf8_lossy(&output.stderr));}++/// #5494 / #5672 — a repository config that names a command does not get to run it,+/// asserted through the live agent tool surface rather than the private helper.+///+/// The tool's own workspace is agent-writable, and several git config keys name a+/// program git then executes — `core.fsmonitor` is run by `git status`, which every+/// operation this tool exposes reaches through `run_git_command_in`. So an agent that+/// can write a file can choose what the next `status` executes.+///+/// The unit suite in `git_operations_tests.rs` already pins the predicate. What it+/// cannot show is that the *tool surface an agent actually calls* is the one sitting+/// behind the guard: a new operation, or a refactor that reaches git another way,+/// would restore the exploit with every unit test still green. That is what this+/// drives — `GitOperationsTool::execute`, the same entry the agent tool loop uses.+///+/// The marker assertion is the security one. An error message alone would not prove+/// the hook did not run: the guard could refuse *after* spawning git. The hook is+/// proven to work before it is planted, so a missing marker afterwards means it was+/// refused, not that the hook was silently broken.+#[cfg(unix)]+#[tokio::test]+async fn git_tool_refuses_a_workspace_repo_config_that_names_a_command() {+ use std::os::unix::fs::PermissionsExt;++ let tmp = tempdir().expect("repo tempdir");+ let repo = tmp.path();+ run_git(repo, &["init"]);+ run_git(repo, &["config", "user.email", "[email protected]"]);+ run_git(repo, &["config", "user.name", "Guard"]);++ // A hook that records the fact it ran. Proven to run on its own first, so a+ // later absent marker is evidence of refusal rather than of a broken fixture.+ let hook = repo.join("hook.sh");+ let marker = repo.join("COMMAND_RAN");+ std::fs::write(+ &hook,+ format!("#!/bin/sh\ntouch {:?}\nexit 1\n", marker.to_string_lossy()),+ )+ .expect("write hook");+ std::fs::set_permissions(&hook, std::fs::Permissions::from_mode(0o755)).expect("chmod hook");+ std::process::Command::new(&hook)+ .status()+ .expect("hook runs");+ assert!(marker.exists(), "the planted hook does not run at all");+ std::fs::remove_file(&marker).expect("clear marker");++ let hook_path = hook.to_string_lossy().into_owned();+ run_git(repo, &["config", "core.fsmonitor", &hook_path]);++ let tool = GitOperationsTool::new(full_security(repo), repo.to_path_buf());+ let refused = tool.execute(json!({"operation": "status"})).await;+ let message = match &refused {+ Ok(result) => result.output(),+ Err(err) => err.to_string(),+ };++ // Checked BEFORE anything about the result, deliberately: whether the call+ // reported an error is secondary, and asserting that first would abort the+ // test before it reached the question that matters. Remove the guard and+ // `status` succeeds, so an is-error assertion fires first and reports a+ // missing error rather than an executed command.+ //+ // THE assertion. An error alone would not prove anything — the guard could+ // refuse after spawning git, or git could fail for an unrelated reason. The+ // marker is the only evidence that the command named by the workspace's own+ // config never ran.+ assert!(+ !marker.exists(),+ "git executed the command named by the workspace's own repository config \+ (`core.fsmonitor`); the tool returned: {message}"+ );++ // Secondary: the call must not report success either.+ if let Ok(result) = &refused {+ assert!(+ result.is_error,+ "status under a hostile repository config reported success: {message}"+ );+ }++ // The refusal must also be legible. This was briefly not true: the+ // repository probe used to run through the guarded `run_git_command_in`,+ // so a refused probe was flattened by `is_ok_and` into the generic "Not in+ // a git repository" — false, and un-actionable, for a directory that+ // plainly is one. `25ea41efe` fixed that by probing with `hardened_git`+ // and asking the guard before concluding anything. Asserting the key here+ // keeps the diagnostic from regressing back to the generic message.+ assert_contains(&message, "core.fsmonitor");+}++/// The other half of #5672, and the reason the allowlist is not simply "refuse any+/// local config": an ordinary repository still works.+///+/// `git init` plus an identity is what every real workspace looks like, so a guard+/// that refused it would make the tool useless and would be reverted rather than+/// fixed. Pinning it here means a future tightening of `ALLOWED_REPO_CONFIG` that+/// breaks ordinary repositories fails in the e2e lane rather than in the field.+#[tokio::test]+async fn git_tool_still_runs_under_an_ordinary_repository_config() {+ let tmp = tempdir().expect("repo tempdir");+ let repo = tmp.path();+ run_git(repo, &["init"]);+ run_git(repo, &["config", "user.email", "[email protected]"]);+ run_git(repo, &["config", "user.name", "Ordinary"]);+ std::fs::write(repo.join("visible.txt"), "hello\n").expect("write file");++ let tool = GitOperationsTool::new(full_security(repo), repo.to_path_buf());+ let status = tool+ .execute(json!({"operation": "status"}))+ .await+ .expect("status on an ordinary repo must not error");++ assert!(!status.is_error, "ordinary repo refused: {}", text(&status));+ assert_contains(&text(&status), "visible.txt");+}