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
refactor(security): extract command analysis into its own module
Steven Enamakel4e348699ba10
diff --git a/crates/openhuman-core/src/security/policy/command_analysis.rs b/crates/openhuman-core/src/security/policy/command_analysis.rsnew file mode 100644index 0000000000..a6c6169d65--- /dev/null+++ b/crates/openhuman-core/src/security/policy/command_analysis.rs@@ -0,0 +1,202 @@+use crate::security::policy::CommandClass;++/// Host-owned interpretation of TinyBox's structural shell facts.+///+/// TinyBox reports live command segments and redirection only. OpenHuman adds+/// the policy fields below locally so command permission and autonomy remain+/// host decisions instead of bus-contract vocabulary.+#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]+pub(crate) struct CommandAnalysis {+ pub segments: Vec<CommandSegment>,+ pub hidden_execution: bool,+ pub redirection: bool,+ pub expansion: bool,+ pub tee: bool,+ pub background: bool,+ pub literal_words: Vec<String>,+}++#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]+pub(crate) struct CommandSegment {+ pub source: String,+ pub command: String,+ pub basename: String,+ pub normalized_name: String,+ pub arguments: Vec<String>,+ pub class: CommandClass,+ pub leading_env_assignment: bool,+ pub dangerous_env_prefix: bool,+ pub executor: bool,+}++impl CommandAnalysis {+ pub(crate) fn from_shell_analysis(facts: tinybox_bus::ShellAnalysis) -> Self {+ let mut analysis = Self {+ segments: Vec::new(),+ hidden_execution: false,+ redirection: facts.redirection,+ expansion: false,+ tee: false,+ background: false,+ literal_words: Vec::new(),+ };++ for source in facts.segments {+ let words = source.split_whitespace().collect::<Vec<_>>();+ let Some(raw_command) = words.first().copied() else {+ continue;+ };+ let command = raw_command.trim_matches(|c: char| matches!(c, '\'' | '"'));+ let basename = command.rsplit(['/', '\\']).next().unwrap_or(command);+ let normalized_name = basename.to_ascii_lowercase();+ let arguments = words+ .iter()+ .skip(1)+ .map(|word| {+ word.trim_matches(|c: char| matches!(c, '\'' | '"'))+ .to_owned()+ })+ .collect::<Vec<_>>();+ let lower = source.to_ascii_lowercase();+ let leading_env_assignment = command.contains('=')+ && command.split_once('=').is_some_and(|(name, _)| {+ !name.is_empty() && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')+ });+ let dangerous_env_prefix =+ words+ .iter()+ .take_while(|word| word.contains('='))+ .any(|word| {+ let name = word+ .split('=')+ .next()+ .unwrap_or_default()+ .to_ascii_uppercase();+ matches!(+ name.as_str(),+ "LD_PRELOAD"+ | "LD_LIBRARY_PATH"+ | "DYLD_INSERT_LIBRARIES"+ | "DYLD_LIBRARY_PATH"+ | "PATH"+ )+ });+ let executor = matches!(+ normalized_name.as_str(),+ "sh" | "bash"+ | "zsh"+ | "fish"+ | "python"+ | "python2"+ | "python3"+ | "node"+ | "ruby"+ | "perl"+ | "php"+ | "lua"+ | "awk"+ | "xargs"+ );+ let class = classify_host_command(&normalized_name, &arguments, &lower);+ analysis.hidden_execution |= lower.contains("$(")+ || lower.contains("<(")+ || lower.contains(">(")+ || source.contains('`')+ || has_background_operator(&source);+ analysis.expansion |= source.contains('$') || source.contains('`');+ analysis.background |= has_background_operator(&source);+ analysis.tee |= words+ .iter()+ .any(|word| word == &"tee" || word.ends_with("/tee"));+ analysis.literal_words.extend(+ words+ .iter()+ .map(|word| {+ word.trim_matches(|c: char| matches!(c, '\'' | '"' | '<' | '>' | '&' | '|'))+ .to_owned()+ })+ .filter(|word| !word.is_empty()),+ );+ analysis.segments.push(CommandSegment {+ source: source.clone(),+ command: source.clone(),+ basename: basename.to_owned(),+ normalized_name,+ arguments,+ class,+ leading_env_assignment,+ dangerous_env_prefix,+ executor,+ });+ }+ analysis+ }+}++fn has_background_operator(source: &str) -> bool {+ let bytes = source.as_bytes();+ bytes.iter().enumerate().any(|(index, byte)| {+ *byte == b'&'+ && bytes.get(index + 1) != Some(&b'&')+ && (index == 0 || bytes[index - 1] != b'&')+ && (index == 0 || bytes[index - 1] != b'>')+ })+}++pub(super) fn classify_host_command(base: &str, args: &[String], source: &str) -> CommandClass {+ if matches!(+ base,+ "sudo"+ | "su"+ | "mkfs"+ | "dd"+ | "shutdown"+ | "reboot"+ | "halt"+ | "poweroff"+ | "useradd"+ | "userdel"+ | "usermod"+ | "passwd"+ ) || source.contains("rm -rf /")+ || source.contains("rm -fr /")+ || source.contains(":(){:|:&};:")+ {+ return CommandClass::Destructive;+ }+ if matches!(+ base,+ "curl" | "wget" | "ssh" | "scp" | "sftp" | "ftp" | "telnet" | "nc" | "ncat" | "netcat"+ ) {+ return CommandClass::Network;+ }+ let first = args.first().map(String::as_str).unwrap_or_default();+ if matches!(base, "npm" | "pnpm" | "yarn" | "pip" | "pip3")+ && matches!(first, "install" | "add" | "remove" | "uninstall" | "update")+ || base == "cargo" && matches!(first, "add" | "remove" | "install" | "update")+ {+ return CommandClass::Install;+ }+ if matches!(+ base,+ "ls" | "pwd"+ | "cat"+ | "head"+ | "tail"+ | "grep"+ | "rg"+ | "find"+ | "stat"+ | "wc"+ | "sort"+ | "echo"+ | "printf"+ | "whoami"+ | "date"+ ) || base == "git" && matches!(first, "status" | "diff" | "log" | "show" | "branch")+ || base == "cargo" && matches!(first, "check" | "test" | "tree" | "metadata")+ {+ return CommandClass::Read;+ }+ CommandClass::Write+}diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rsindex 40ffb8291e..47ae089a74 100644--- a/crates/openhuman-core/src/security/policy/command_checks.rs+++ b/crates/openhuman-core/src/security/policy/command_checks.rs@@ -4,6 +4,9 @@use std::path::{Path, PathBuf};+use super::CommandAnalysis;+use super::command_analysis::classify_host_command;+#[cfg(test)]use super::types::CommandRiskLevel;use super::types::{AutonomyLevel, GateDecision, SecurityPolicy};@@ -23,8 +26,7 @@ fn command_basename(command: &str) -> &str {#[cfg(test)]fn normalized_command_name(command: &str) -> String {- command_basename(command.trim_matches(|c: char| matches!(c, '\'' | '"')))- .to_ascii_lowercase()+ command_basename(command.trim_matches(|c: char| matches!(c, '\'' | '"'))).to_ascii_lowercase()}#[cfg(test)]@@ -52,19 +54,28 @@ fn has_leading_env_assignment(command: &str) -> bool {#[cfg(test)]fn has_dangerous_env_prefix(command: &str) -> bool {- command.split_whitespace().take_while(|word| word.contains('=')).any(|word| {- matches!(- word.split('=').next().unwrap_or_default().to_ascii_uppercase().as_str(),- "LD_PRELOAD" | "LD_LIBRARY_PATH" | "DYLD_INSERT_LIBRARIES" | "DYLD_LIBRARY_PATH" | "PATH"- )- })+ command+ .split_whitespace()+ .take_while(|word| word.contains('='))+ .any(|word| {+ matches!(+ word.split('=')+ .next()+ .unwrap_or_default()+ .to_ascii_uppercase()+ .as_str(),+ "LD_PRELOAD"+ | "LD_LIBRARY_PATH"+ | "DYLD_INSERT_LIBRARIES"+ | "DYLD_LIBRARY_PATH"+ | "PATH"+ )+ })}#[cfg(test)]fn contains_unquoted_single_ampersand(command: &str) -> bool {- contains_unquoted_char(command, '&')- && !command.contains("&&")- && !command.contains(">&")+ contains_unquoted_char(command, '&') && !command.contains("&&") && !command.contains(">&")}#[cfg(test)]@@ -80,8 +91,19 @@ fn has_hidden_execution(command: &str) -> bool {fn is_command_executor(command: &str) -> bool {matches!(command,- "sh" | "bash" | "zsh" | "fish" | "python" | "python2" | "python3" | "node"- | "ruby" | "perl" | "php" | "lua" | "awk" | "xargs"+ "sh" | "bash"+ | "zsh"+ | "fish"+ | "python"+ | "python2"+ | "python3"+ | "node"+ | "ruby"+ | "perl"+ | "php"+ | "lua"+ | "awk"+ | "xargs")}@@ -90,207 +112,6 @@ fn classify_segment(base: &str, args: &[String], joined: &str) -> CommandClass {classify_host_command(base, args, joined)}-/// Host-owned interpretation of TinyBox's structural shell facts.-///-/// TinyBox reports live command segments and redirection only. OpenHuman adds-/// the policy fields below locally so command permission and autonomy remain-/// host decisions instead of bus-contract vocabulary.-#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]-pub(crate) struct CommandAnalysis {- pub segments: Vec<CommandSegment>,- pub hidden_execution: bool,- pub redirection: bool,- pub expansion: bool,- pub tee: bool,- pub background: bool,- pub literal_words: Vec<String>,-}--#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]-pub(crate) struct CommandSegment {- pub source: String,- pub command: String,- pub basename: String,- pub normalized_name: String,- pub arguments: Vec<String>,- pub class: CommandClass,- pub leading_env_assignment: bool,- pub dangerous_env_prefix: bool,- pub executor: bool,-}--impl CommandAnalysis {- pub(crate) fn from_shell_analysis(facts: tinybox_bus::ShellAnalysis) -> Self {- let mut analysis = Self {- segments: Vec::new(),- hidden_execution: false,- redirection: facts.redirection,- expansion: false,- tee: false,- background: false,- literal_words: Vec::new(),- };-- for source in facts.segments {- let words = source.split_whitespace().collect::<Vec<_>>();- let Some(raw_command) = words.first().copied() else {- continue;- };- let command = raw_command.trim_matches(|c: char| matches!(c, '\'' | '"'));- let basename = command.rsplit(['/', '\\']).next().unwrap_or(command);- let normalized_name = basename.to_ascii_lowercase();- let arguments = words- .iter()- .skip(1)- .map(|word| {- word.trim_matches(|c: char| matches!(c, '\'' | '"'))- .to_owned()- })- .collect::<Vec<_>>();- let lower = source.to_ascii_lowercase();- let leading_env_assignment = command.contains('=')- && command.split_once('=').is_some_and(|(name, _)| {- !name.is_empty() && name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_')- });- let dangerous_env_prefix =- words- .iter()- .take_while(|word| word.contains('='))- .any(|word| {- let name = word- .split('=')- .next()- .unwrap_or_default()- .to_ascii_uppercase();- matches!(- name.as_str(),- "LD_PRELOAD"- | "LD_LIBRARY_PATH"- | "DYLD_INSERT_LIBRARIES"- | "DYLD_LIBRARY_PATH"- | "PATH"- )- });- let executor = matches!(- normalized_name.as_str(),- "sh" | "bash"- | "zsh"- | "fish"- | "python"- | "python2"- | "python3"- | "node"- | "ruby"- | "perl"- | "php"- | "lua"- | "awk"- | "xargs"- );- let class = classify_host_command(&normalized_name, &arguments, &lower);- analysis.hidden_execution |= lower.contains("$(")- || lower.contains("<(")- || lower.contains(">(")- || source.contains('`')- || has_background_operator(&source);- analysis.expansion |= source.contains('$') || source.contains('`');- analysis.background |= has_background_operator(&source);- analysis.tee |= words- .iter()- .any(|word| word == &"tee" || word.ends_with("/tee"));- analysis.literal_words.extend(- words- .iter()- .map(|word| {- word.trim_matches(|c: char| matches!(c, '\'' | '"' | '<' | '>' | '&' | '|'))- .to_owned()- })- .filter(|word| !word.is_empty()),- );- analysis.segments.push(CommandSegment {- source: source.clone(),- command: source.clone(),- basename: basename.to_owned(),- normalized_name,- arguments,- class,- leading_env_assignment,- dangerous_env_prefix,- executor,- });- }- analysis- }-}--fn has_background_operator(source: &str) -> bool {- let bytes = source.as_bytes();- bytes.iter().enumerate().any(|(index, byte)| {- *byte == b'&'- && bytes.get(index + 1) != Some(&b'&')- && (index == 0 || bytes[index - 1] != b'&')- && (index == 0 || bytes[index - 1] != b'>')- })-}--fn classify_host_command(base: &str, args: &[String], source: &str) -> CommandClass {- if matches!(- base,- "sudo"- | "su"- | "mkfs"- | "dd"- | "shutdown"- | "reboot"- | "halt"- | "poweroff"- | "useradd"- | "userdel"- | "usermod"- | "passwd"- ) || source.contains("rm -rf /")- || source.contains("rm -fr /")- || source.contains(":(){:|:&};:")- {- return CommandClass::Destructive;- }- if matches!(- base,- "curl" | "wget" | "ssh" | "scp" | "sftp" | "ftp" | "telnet" | "nc" | "ncat" | "netcat"- ) {- return CommandClass::Network;- }- let first = args.first().map(String::as_str).unwrap_or_default();- if matches!(base, "npm" | "pnpm" | "yarn" | "pip" | "pip3")- && matches!(first, "install" | "add" | "remove" | "uninstall" | "update")- || base == "cargo" && matches!(first, "add" | "remove" | "install" | "update")- {- return CommandClass::Install;- }- if matches!(- base,- "ls" | "pwd"- | "cat"- | "head"- | "tail"- | "grep"- | "rg"- | "find"- | "stat"- | "wc"- | "sort"- | "echo"- | "printf"- | "whoami"- | "date"- ) || base == "git" && matches!(first, "status" | "diff" | "log" | "show" | "branch")- || base == "cargo" && matches!(first, "check" | "test" | "tree" | "metadata")- {- return CommandClass::Read;- }- CommandClass::Write-}-impl SecurityPolicy {/// Apply the supervised allowlist to parser facts returned by TinyBox./// The module owns shell structure; this host owns the permission policy.diff --git a/crates/openhuman-core/src/security/policy/mod.rs b/crates/openhuman-core/src/security/policy/mod.rsindex c17558fe69..aefad182d4 100644--- a/crates/openhuman-core/src/security/policy/mod.rs+++ b/crates/openhuman-core/src/security/policy/mod.rs@@ -2,15 +2,16 @@//! for the invariants this module enforces (workspace-internal path//! protection, fail-closed command classification, always-forbidden paths).+mod command_analysis;mod command_checks;mod enforcement;mod path_checks;mod types;-pub(crate) use command_checks::CommandAnalysis;+pub(crate) use command_analysis::CommandAnalysis;#[cfg(test)]-pub(crate) use command_checks::CommandSegment;+pub(crate) use command_analysis::CommandSegment;pub use enforcement::validate_path_within_root;pub use enforcement::{ensure_openhuman_scratch_dir, openhuman_scratch_dir};@@ -21,8 +22,8 @@ pub(crate) use path_checks::{ALWAYS_FORBIDDEN_PREFIXES, SENSITIVE_COMPONENTS, SENSITIVE_FILES, SENSITIVE_PAIRS,};pub use types::{- tool_result_artifacts_dir, ActionTracker, AutonomyLevel, CommandClass, CommandRiskLevel,- GateDecision, SecurityPolicy, ToolOperation, TrustedAccess, TrustedRoot,+ ActionTracker, AutonomyLevel, CommandClass, CommandRiskLevel, GateDecision, SecurityPolicy,+ ToolOperation, TrustedAccess, TrustedRoot, tool_result_artifacts_dir,};#[cfg(test)]diff --git a/crates/openhuman-core/src/security/policy/path_checks.rs b/crates/openhuman-core/src/security/policy/path_checks.rsindex 6b48350b97..a8bc9e7d9f 100644--- a/crates/openhuman-core/src/security/policy/path_checks.rs+++ b/crates/openhuman-core/src/security/policy/path_checks.rs@@ -1,10 +1,10 @@use std::path::{Path, PathBuf};-use super::types::{SecurityPolicy, TrustedAccess};use super::types::{- ACCOUNT_CONFIG_FILE, ARTIFACTS_DIR, ARTIFACT_TOOL_RESULTS_DIR, WORKSPACE_INTERNAL_DIRS,+ ACCOUNT_CONFIG_FILE, ARTIFACT_TOOL_RESULTS_DIR, ARTIFACTS_DIR, WORKSPACE_INTERNAL_DIRS,WORKSPACE_INTERNAL_FILES,};+use super::types::{SecurityPolicy, TrustedAccess};use tinytools::status::POLICY_BLOCKED_MARKER;/// Credential-store path segments, matched case-insensitively at any depth.@@ -224,11 +224,11 @@ impl SecurityPolicy {.unwrap_or(forbidden_expanded);if canonical.starts_with(&forbidden_canonical) {log::trace!(- "[security:policy] path blocked: symlink resolves to forbidden tree (requested={}, resolved={}, forbidden={})",- path,- canonical.display(),- forbidden_canonical.display()- );+ "[security:policy] path blocked: symlink resolves to forbidden tree (requested={}, resolved={}, forbidden={})",+ path,+ canonical.display(),+ forbidden_canonical.display()+ );return false;}}diff --git a/crates/openhuman-core/src/security/policy/policy_action_dir_tests.rs b/crates/openhuman-core/src/security/policy/policy_action_dir_tests.rsindex 1c8b2f2c47..7f2f528e67 100644--- a/crates/openhuman-core/src/security/policy/policy_action_dir_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_action_dir_tests.rs@@ -109,10 +109,12 @@ async fn tool_result_artifacts_are_readable_by_absolute_path_under_workspace_onllet grant = super::tool_result_artifacts_dir(&workspace).to_string_lossy().to_string();- assert!(policy- .trusted_roots- .iter()- .any(|r| r.path == grant && r.access == TrustedAccess::Read));+ assert!(+ policy+ .trusted_roots+ .iter()+ .any(|r| r.path == grant && r.access == TrustedAccess::Read)+ );let result = artifacts.join("call.txt");policy@@ -120,8 +122,10 @@ async fn tool_result_artifacts_are_readable_by_absolute_path_under_workspace_onl.await.expect("a tool-result artifact must be readable by absolute path");// The grant is that directory only: internal artifact records stay closed.- assert!(policy- .validate_path(&record.join("meta.json").to_string_lossy())- .await- .is_err());+ assert!(+ policy+ .validate_path(&record.join("meta.json").to_string_lossy())+ .await+ .is_err()+ );}diff --git a/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs b/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rsindex 84cd1c3b5c..399307c611 100644--- a/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs@@ -36,9 +36,10 @@ fn can_act_full_true() {#[test]fn enforce_tool_operation_read_allowed_in_readonly_mode() {let p = readonly_policy();- assert!(p- .enforce_tool_operation(ToolOperation::Read, "memory_recall")- .is_ok());+ assert!(+ p.enforce_tool_operation(ToolOperation::Read, "memory_recall")+ .is_ok()+ );}#[test]diff --git a/crates/openhuman-core/src/security/policy/policy_media_artifact_tests.rs b/crates/openhuman-core/src/security/policy/policy_media_artifact_tests.rsindex 9fc01a02c7..51fb563adf 100644--- a/crates/openhuman-core/src/security/policy/policy_media_artifact_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_media_artifact_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::artifacts::{create_artifact, finalize_artifact, ArtifactKind, FileRoots};+use crate::artifacts::{ArtifactKind, FileRoots, create_artifact, finalize_artifact};use std::sync::Arc;use tempfile::TempDir;@@ -64,18 +64,24 @@ async fn ready_media_artifacts_are_readable_but_other_files_are_not() {..SecurityPolicy::default()};- assert!(policy- .validate_path(&image_path.to_string_lossy())- .await- .is_ok());- assert!(policy- .validate_path(&document_path.to_string_lossy())- .await- .is_err());- assert!(policy- .validate_path(&pending_path.to_string_lossy())- .await- .is_err());+ assert!(+ policy+ .validate_path(&image_path.to_string_lossy())+ .await+ .is_ok()+ );+ assert!(+ policy+ .validate_path(&document_path.to_string_lossy())+ .await+ .is_err()+ );+ assert!(+ policy+ .validate_path(&pending_path.to_string_lossy())+ .await+ .is_err()+ );crate::artifacts::store::delete_artifact(&workspace, FileRoots::new(files), &image.id).awaitdiff --git a/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs b/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rsindex e7a790a2c8..04eef3b529 100644--- a/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs@@ -370,14 +370,16 @@ fn relative_personalities_path_resolves_under_action_dir() {};assert!(policy.is_path_string_allowed("personalities/alice.md"));- assert!(!policy.is_path_string_allowed(- workspace- .join("personalities")- .join("alice")- .join("SOUL.md")- .to_string_lossy()- .as_ref()- ));+ assert!(+ !policy.is_path_string_allowed(+ workspace+ .join("personalities")+ .join("alice")+ .join("SOUL.md")+ .to_string_lossy()+ .as_ref()+ )+ );}#[test]diff --git a/crates/openhuman-core/src/security/policy/policy_trusted_roots_tests.rs b/crates/openhuman-core/src/security/policy/policy_trusted_roots_tests.rsindex c0df8164bf..b16dfd415d 100644--- a/crates/openhuman-core/src/security/policy/policy_trusted_roots_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_trusted_roots_tests.rs@@ -177,10 +177,12 @@ async fn validate_parent_path_blocks_symlinked_parent_dir() {forbidden_paths: vec![],..SecurityPolicy::default()};- assert!(policy- .validate_parent_path("subdir/newfile.txt")- .await- .is_err());+ assert!(+ policy+ .validate_parent_path("subdir/newfile.txt")+ .await+ .is_err()+ );}#[cfg(unix)]@@ -224,10 +226,12 @@ async fn validate_parent_path_blocks_forbidden_path() {..SecurityPolicy::default()};// Writing a new file directly into the forbidden dir must be blocked.- assert!(policy- .validate_parent_path("secrets/output.csv")- .await- .is_err());+ assert!(+ policy+ .validate_parent_path("secrets/output.csv")+ .await+ .is_err()+ );}// ── tilde expansion in validate_path / validate_parent_path ──────────────────@@ -458,9 +462,10 @@ fn supervised_runs_approved_redirects_but_blocks_hidden_execution() {.is_ok(),"stderr-dup redirect 2>&1 must run after approval");- assert!(p- .check_gated_command("pip show yfinance 2>/dev/null")- .is_ok());+ assert!(+ p.check_gated_command("pip show yfinance 2>/dev/null")+ .is_ok()+ );assert!(p.check_gated_command("ls -la | grep foo").is_ok());assert!(p.check_gated_command("echo done > out.txt").is_ok());diff --git a/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs b/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rsindex e767432dbe..261653d814 100644--- a/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs+++ b/crates/openhuman-core/src/security/policy/policy_workspace_internal_tests.rs@@ -20,10 +20,12 @@ fn is_workspace_internal_path_blocks_state_dirs() {assert!(policy.is_workspace_internal_path(&ws.join("memory").join("namespaces")));assert!(policy.is_workspace_internal_path(&ws.join("memory-alice").join("memory.db")));assert!(policy.is_workspace_internal_path(&ws.join("memory_tree-alice").join("tree")));- assert!(policy.is_workspace_internal_path(- &ws.join("session_raw-alice")- .join("1700000000_orchestrator.jsonl")- ));+ assert!(+ policy.is_workspace_internal_path(+ &ws.join("session_raw-alice")+ .join("1700000000_orchestrator.jsonl")+ )+ );assert!(policy.is_workspace_internal_path(&ws.join("sessions")));assert!(policy.is_workspace_internal_path(&ws.join("state")));assert!(policy.is_workspace_internal_path(&ws.join("cron")));@@ -31,13 +33,15 @@ fn is_workspace_internal_path_blocks_state_dirs() {assert!(policy.is_workspace_internal_path(&ws.join("personalities").join("alice").join("SOUL.md")));- assert!(policy.is_workspace_internal_path(- &ws.join("personalities")- .join("alice")- .join("skills")- .join("private-skill")- .join("SKILL.md")- ));+ assert!(+ policy.is_workspace_internal_path(+ &ws.join("personalities")+ .join("alice")+ .join("skills")+ .join("private-skill")+ .join("SKILL.md")+ )+ );assert!(policy.is_workspace_internal_path(&ws.join("approval")));assert!(policy.is_workspace_internal_path(&ws.join("mcp_clients")));assert!(policy.is_workspace_internal_path(&ws.join("codegraph")));@@ -120,17 +124,21 @@ async fn artifact_metadata_is_internal_but_tool_results_are_not() {let meta = record.join("meta.json");assert!(!policy.is_path_string_allowed(&meta.to_string_lossy()));assert!(policy.validate_path(&meta.to_string_lossy()).await.is_err());- assert!(policy- .validate_parent_path(&record.join("args.json").to_string_lossy())- .await- .is_err());+ assert!(+ policy+ .validate_parent_path(&record.join("args.json").to_string_lossy())+ .await+ .is_err()+ );let result = results.join("call-1.txt");assert!(policy.is_path_string_allowed(&result.to_string_lossy()));- assert!(policy- .validate_path(&result.to_string_lossy())- .await- .is_ok());+ assert!(+ policy+ .validate_path(&result.to_string_lossy())+ .await+ .is_ok()+ );}#[tokio::test]@@ -154,14 +162,16 @@ async fn trusted_root_cannot_expose_workspace_internal_state() {assert!(!policy.is_path_string_allowed(&soul.to_string_lossy()));assert!(policy.validate_path(&soul.to_string_lossy()).await.is_err());- assert!(policy- .validate_parent_path(- &ws.join("session_raw-alice")- .join("new.jsonl")- .to_string_lossy()- )- .await- .is_err());+ assert!(+ policy+ .validate_parent_path(+ &ws.join("session_raw-alice")+ .join("new.jsonl")+ .to_string_lossy()+ )+ .await+ .is_err()+ );}#[test]@@ -212,13 +222,17 @@ async fn the_account_config_beside_the_workspace_is_internal() {};assert!(!policy.is_path_string_allowed(&config.to_string_lossy()));- assert!(policy- .validate_path(&config.to_string_lossy())- .await- .is_err());- assert!(policy- .validate_parent_path(&config.to_string_lossy())- .await- .is_err());+ assert!(+ policy+ .validate_path(&config.to_string_lossy())+ .await+ .is_err()+ );+ assert!(+ policy+ .validate_parent_path(&config.to_string_lossy())+ .await+ .is_err()+ );assert!(policy.validate_path(¬es.to_string_lossy()).await.is_ok());}