Skip to content

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

style: apply rustfmt formatting across sandbox, hooks, and shell tests

Steven Enamakelbda324ab4070
diff --git a/crates/openhuman-core/src/agent/host_runtime_tests.rs b/crates/openhuman-core/src/agent/host_runtime_tests.rs
index 9f47eda721..9044e4231a 100644
--- a/crates/openhuman-core/src/agent/host_runtime_tests.rs
+++ b/crates/openhuman-core/src/agent/host_runtime_tests.rs
@@ -121,7 +121,10 @@ fn hide_window_reaches_the_native_runtime_only() {
true,
)
.unwrap();
- assert!(!docker.hide_window(), "docker runs in a container, not a console");
+ assert!(
+ !docker.hide_window(),
+ "docker runs in a container, not a console"
+ );
}
/// The shell flavor told to the model is the one TinyBox's `SelectShell`
diff --git a/crates/openhuman-core/src/hooks/mod.rs b/crates/openhuman-core/src/hooks/mod.rs
index a4195c6cec..9b27b7e6da 100644
--- a/crates/openhuman-core/src/hooks/mod.rs
+++ b/crates/openhuman-core/src/hooks/mod.rs
@@ -28,9 +28,9 @@
pub mod bridge;
pub mod host;
pub mod ops;
-mod shell;
pub mod prompt_eval;
pub mod schemas;
+mod shell;
pub use ops::{init, PromptVerdict};
pub use schemas::{
diff --git a/crates/openhuman-core/src/hooks/shell_tests.rs b/crates/openhuman-core/src/hooks/shell_tests.rs
index 6ec9debe20..283211864d 100644
--- a/crates/openhuman-core/src/hooks/shell_tests.rs
+++ b/crates/openhuman-core/src/hooks/shell_tests.rs
@@ -46,7 +46,12 @@ fn the_hook_command_replaces_the_placeholder_in_the_selected_arguments() {
#[test]
fn a_command_that_contains_the_placeholder_text_is_not_rewritten_twice() {
let process = from_selection(&posix(), PLACEHOLDER);
- let last = process.get_args().last().unwrap().to_string_lossy().into_owned();
+ let last = process
+ .get_args()
+ .last()
+ .unwrap()
+ .to_string_lossy()
+ .into_owned();
assert_eq!(last, format!("set -o pipefail\n{PLACEHOLDER}"));
}
diff --git a/crates/openhuman-core/src/sandbox/docker_tests.rs b/crates/openhuman-core/src/sandbox/docker_tests.rs
index f5c7e6cae6..7c3018f1d0 100644
--- a/crates/openhuman-core/src/sandbox/docker_tests.rs
+++ b/crates/openhuman-core/src/sandbox/docker_tests.rs
@@ -46,7 +46,10 @@ async fn validation_never_reports_safe_when_tinybox_is_unavailable() {
let mut config = crate::config::Config::default();
config.modules.enabled = false;
let verdict = validate_docker_policy(&config, &test_policy()).await;
- assert!(verdict.is_err(), "no module means no verdict, not a clean one");
+ assert!(
+ verdict.is_err(),
+ "no module means no verdict, not a clean one"
+ );
}
#[cfg(feature = "modules")]
diff --git a/crates/openhuman-core/src/sandbox/mod.rs b/crates/openhuman-core/src/sandbox/mod.rs
index a9eb79eb3d..a7f5ab7e14 100644
--- a/crates/openhuman-core/src/sandbox/mod.rs
+++ b/crates/openhuman-core/src/sandbox/mod.rs
@@ -13,9 +13,9 @@
pub mod docker;
pub(crate) mod local_grants;
pub(crate) mod native_jail;
-pub(crate) mod shell_exec;
pub mod ops;
pub mod schemas;
+pub(crate) mod shell_exec;
pub mod types;
pub use ops::{
diff --git a/crates/openhuman-core/src/sandbox/native_jail.rs b/crates/openhuman-core/src/sandbox/native_jail.rs
index 41cc08780e..c50dae568e 100644
--- a/crates/openhuman-core/src/sandbox/native_jail.rs
+++ b/crates/openhuman-core/src/sandbox/native_jail.rs
@@ -111,12 +111,8 @@ async fn execute_owned(
anyhow::bail!("requested Landlock sandbox is unavailable");
}
- let mut run = super::shell_exec::NativeShellRun::new(
- command,
- working_dir,
- &policy.state_dir,
- timeout,
- );
+ let mut run =
+ super::shell_exec::NativeShellRun::new(command, working_dir, &policy.state_dir, timeout);
run.workspace = policy.workspace_root.clone();
run.env = approved_environment(extra_env)?;
run.isolate_network = true;
diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rs
index 6c11601318..96d8ab054b 100644
--- a/crates/openhuman-core/src/sandbox/ops_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs
@@ -240,7 +240,10 @@ async fn execute_unsandboxed_refuses_non_utf8_environment_instead_of_altering_it
.await;
assert!(result.is_err());
- assert!(!marker.exists(), "a refused environment must not run the command");
+ assert!(
+ !marker.exists(),
+ "a refused environment must not run the command"
+ );
}
/// Caller-approved overrides reach the command on top of the safe snapshot.
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rs
index 46f610763d..e62ce83023 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs
@@ -708,7 +708,9 @@ fn exec_result(
effective: Duration,
) -> ToolResult {
match result {
- Ok(result) if result.timed_out => ToolResult::error(tool_timeout_message(effective.as_secs())),
+ Ok(result) if result.timed_out => {
+ ToolResult::error(tool_timeout_message(effective.as_secs()))
+ }
Ok(result) if result.success() => {
if result.stderr.is_empty() {
ToolResult::success(result.stdout)
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
index d93b046df0..dda93cc070 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_platform_tests.rs
@@ -51,18 +51,12 @@ fn the_tool_describes_the_shell_this_host_actually_spawns() {
test_runtime(),
test_audit(),
);
- assert_eq!(
- tool.description(),
- shell_description(host_shell_flavor())
- );
+ assert_eq!(tool.description(), shell_description(host_shell_flavor()));
let command_desc = tool.parameters_schema()["properties"]["command"]["description"]
.as_str()
.unwrap()
.to_string();
- assert_eq!(
- command_desc,
- command_param_description(host_shell_flavor())
- );
+ assert_eq!(command_desc, command_param_description(host_shell_flavor()));
assert!(command_param_description(ShellFlavor::Cmd).contains("cmd.exe"));
}
@@ -103,7 +97,10 @@ async fn the_container_environment_forwards_only_the_allowlist_plus_python_defau
("OPENAI_API_KEY".to_owned(), "sk-secret".to_owned()),
("AWS_SECRET_ACCESS_KEY".to_owned(), "secret".to_owned()),
]);
- let env = scoped.scope(async { container_environment() }).await.unwrap();
+ let env = scoped
+ .scope(async { container_environment() })
+ .await
+ .unwrap();
assert_eq!(env.get("PATH").map(String::as_str), Some("/bin"));
assert_eq!(env.get("PYTHONUTF8").map(String::as_str), Some("1"));
assert!(!env.contains_key("OPENAI_API_KEY"));
diff --git a/crates/openhuman-core/src/tools/timeout/mod_tests.rs b/crates/openhuman-core/src/tools/timeout/mod_tests.rs
index e1db825cab..7af21c0527 100644
--- a/crates/openhuman-core/src/tools/timeout/mod_tests.rs
+++ b/crates/openhuman-core/src/tools/timeout/mod_tests.rs
@@ -196,7 +196,6 @@ fn test_shell(command: &str) -> tokio::process::Command {
cmd
}
-
/// The deadline must take the command's whole process group with it. A shell
/// pipeline is grandchildren of the tool's child, and a `grep -rl … /` the tool
/// had reported as killed ran on for half an hour at a full core.
@@ -208,10 +207,7 @@ async fn a_timed_out_command_takes_its_whole_process_group_with_it() {
let pidfile = dir.join("grandchild.pid");
// `sleep 30 &` is a grandchild in the shell's own process group; `wait`
// keeps the shell alive past the deadline.
- let mut cmd = test_shell(&format!(
- "sleep 30 & echo $! > {}; wait",
- pidfile.display()
- ));
+ let mut cmd = test_shell(&format!("sleep 30 & echo $! > {}; wait", pidfile.display()));
let result = output_or_kill(&mut cmd, Duration::from_millis(700)).await;
assert!(result.is_err(), "the deadline must fire on a 30s sleep");
@@ -254,10 +250,7 @@ async fn a_shell_family_child_dies_with_a_dropped_future() {
let dir = std::env::temp_dir().join(format!("oh-dropkill-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let pidfile = dir.join("child.pid");
- let mut cmd = test_shell(&format!(
- "echo $$ > {}; sleep 30",
- pidfile.display()
- ));
+ let mut cmd = test_shell(&format!("echo $$ > {}; sleep 30", pidfile.display()));
// `timeout` takes the future by value and drops it when the deadline
// passes -- exactly the abandoned-future path a cancelled tool call takes.
let _ = tokio::time::timeout(Duration::from_millis(300), cmd.output()).await;
diff --git a/crates/openhuman-embed/tests/process_cancellation.rs b/crates/openhuman-embed/tests/process_cancellation.rs
index eb6a843a24..e0590b6558 100644
--- a/crates/openhuman-embed/tests/process_cancellation.rs
+++ b/crates/openhuman-embed/tests/process_cancellation.rs
@@ -96,9 +96,7 @@ async fn dropped_command(bounded: bool) {
#[tokio::test]
async fn captured_commands_preserve_output_and_exit_status() {
for bounded in [true, false] {
- let mut cmd = shell_child(
- "printf stdout; printf stderr >&2; exit 7",
- );
+ let mut cmd = shell_child("printf stdout; printf stderr >&2; exit 7");
let output = if bounded {
output_or_kill(&mut cmd, Duration::from_secs(5))
.await