Skip to content

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

chore: files changed crates/openhuman-core/src/config/ops/sandbox.rs,crates/openhuman-core/src/sandb

Steven Enamakelc6360b5ca89c
diff --git a/crates/openhuman-core/src/config/ops/sandbox.rs b/crates/openhuman-core/src/config/ops/sandbox.rs
index b0e7de1074..234f39e3cb 100644
--- a/crates/openhuman-core/src/config/ops/sandbox.rs
+++ b/crates/openhuman-core/src/config/ops/sandbox.rs
@@ -51,7 +51,9 @@ pub async fn get_sandbox_settings() -> Result<Outcome<serde_json::Value>, String
"detected_backend": detected_backend,
"env_passthrough": crate::sandbox::ops::SANDBOX_ENV_PASSTHROUGH,
});
- log::debug!("[config][sandbox] get_sandbox_settings: backend={backend_str}, docker_available={docker_available}");
+ log::debug!(
+ "[config][sandbox] get_sandbox_settings: backend={backend_str}, docker_available={docker_available}"
+ );
Ok(Outcome::single_log(value, "sandbox settings read"))
}
diff --git a/crates/openhuman-core/src/sandbox/README.md b/crates/openhuman-core/src/sandbox/README.md
index 84d1bff141..fdda5b246a 100644
--- a/crates/openhuman-core/src/sandbox/README.md
+++ b/crates/openhuman-core/src/sandbox/README.md
@@ -145,7 +145,7 @@ Local derives its status from which jail backend was picked
| [`types.rs`](./types.rs) | `SandboxBackendKind`, `SandboxPolicy`, `DockerOverrides`, exec request and result, handle and status, `ElevatedOp`, `ELEVATED_TOOLS`. |
| [`ops.rs`](./ops.rs) | Policy resolution, backend creation, routed execution (None and Local paths), the env allowlist, the host off switch, elevated ops. |
| [`grants.rs`](./grants.rs) | The Local jail's filesystem grant set and its credential floor. |
-| [`docker.rs`](./docker.rs) | Policy-to-`OneShot` mapping, availability probe, orphan cleanup, Docker policy validation. |
+| [`docker.rs`](./docker.rs) | Policy-to-`RunDocker` mapping, module status/cleanup calls, Docker policy validation. |
| [`schemas.rs`](./schemas.rs) | The `sandbox.*` controllers. |
## Key types and entry points
@@ -187,9 +187,10 @@ The settings surface (`get_sandbox_settings`, `[security.sandbox]` and
## Boundaries
- The OS jail (Landlock, Seatbelt, AppContainer, noop) is `tinybox-jail` in
- `vendor/tinybox/crates/tinybox-jail`. The one-shot container command line
- is `tinybox-docker`. Both belong to the `tinybox` repo; this folder keeps
- only the policy of when and how to confine.
+ `vendor/tinybox/crates/tinybox-jail`. Docker execution, daemon status, and
+ label-scoped cleanup run through TinyBox's loadable module. Both providers
+ belong to the `tinybox` repo; this folder keeps the policy of when and how to
+ confine.
- Permission to run a command at all, the approval gate and the path checks
are `security/`. The autonomy policy is off by default there, so for a
default install the sandbox and the `is_always_forbidden` floor are what
diff --git a/crates/openhuman-core/src/sandbox/docker.rs b/crates/openhuman-core/src/sandbox/docker.rs
index 9fc2e47ea5..5ecfaa1b65 100644
--- a/crates/openhuman-core/src/sandbox/docker.rs
+++ b/crates/openhuman-core/src/sandbox/docker.rs
@@ -25,16 +25,25 @@ use crate::modules::tinybox::{self, contract};
/// Label applied to all sandbox containers for orphan cleanup.
const CONTAINER_LABEL: &str = "openhuman.sandbox=true";
+#[cfg(feature = "modules")]
+fn status_request() -> contract::DockerStatusRequest {
+ contract::DockerStatusRequest {
+ timeout_ms: contract::DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
+ }
+}
+
+#[cfg(feature = "modules")]
+fn cleanup_request() -> contract::CleanupDockerRequest {
+ contract::CleanupDockerRequest {
+ label: CONTAINER_LABEL.to_owned(),
+ timeout_ms: contract::DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
+ }
+}
+
/// Check whether Docker is available and responsive.
#[cfg(feature = "modules")]
pub async fn is_docker_available(config: &Config) -> Result<bool, String> {
- let status = tinybox::docker_status(
- config,
- contract::DockerStatusRequest {
- timeout_ms: contract::DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
- },
- )
- .await?;
+ let status = tinybox::docker_status(config, status_request()).await?;
Ok(status.available)
}
@@ -174,15 +183,9 @@ fn path_string(path: &std::path::Path, kind: &str) -> anyhow::Result<String> {
/// OpenHuman label.
#[cfg(feature = "modules")]
pub async fn cleanup_orphaned_containers(config: &Config) -> anyhow::Result<u32> {
- let output = tinybox::cleanup_docker(
- config,
- contract::CleanupDockerRequest {
- label: CONTAINER_LABEL.to_owned(),
- timeout_ms: contract::DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
- },
- )
- .await
- .map_err(|error| anyhow::anyhow!("{error}"))?;
+ let output = tinybox::cleanup_docker(config, cleanup_request())
+ .await
+ .map_err(|error| anyhow::anyhow!("{error}"))?;
let count = output.containers_stopped;
tracing::debug!(count = count, "[sandbox:docker] orphan cleanup finished");
Ok(count)
diff --git a/crates/openhuman-core/src/sandbox/docker_exec_tests.rs b/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
index 8d6c471bb8..f3598d2155 100644
--- a/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
+++ b/crates/openhuman-core/src/sandbox/docker_exec_tests.rs
@@ -112,9 +112,11 @@ fn module_request_rounds_small_timeouts_up_and_rejects_unbounded_timeouts() {
exec_request.timeout = Duration::from_millis(MAX_DOCKER_RUN_TIMEOUT_MS + 1);
let error = build_docker_request(&policy(temp.path()), &exec_request)
.expect_err("unbounded request must not bypass the contract limit");
- assert!(error
- .to_string()
- .contains("timeout exceeds the supported limit"));
+ assert!(
+ error
+ .to_string()
+ .contains("timeout exceeds the supported limit")
+ );
}
#[cfg(all(feature = "modules", unix))]
diff --git a/crates/openhuman-core/src/sandbox/docker_tests.rs b/crates/openhuman-core/src/sandbox/docker_tests.rs
index d8789ee10f..e7f6a7407b 100644
--- a/crates/openhuman-core/src/sandbox/docker_tests.rs
+++ b/crates/openhuman-core/src/sandbox/docker_tests.rs
@@ -61,6 +61,26 @@ fn validate_docker_policy_multiple_issues() {
assert!(issues.len() >= 3);
}
+#[cfg(feature = "modules")]
+#[test]
+fn daemon_status_and_orphan_cleanup_use_bounded_tinybox_requests() {
+ use crate::modules::tinybox::contract::DEFAULT_DOCKER_CONTROL_TIMEOUT_MS;
+
+ assert_eq!(
+ status_request(),
+ crate::modules::tinybox::contract::DockerStatusRequest {
+ timeout_ms: DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
+ }
+ );
+ assert_eq!(
+ cleanup_request(),
+ crate::modules::tinybox::contract::CleanupDockerRequest {
+ label: "openhuman.sandbox=true".to_owned(),
+ timeout_ms: DEFAULT_DOCKER_CONTROL_TIMEOUT_MS,
+ }
+ );
+}
+
#[test]
fn docker_backend_handle_maps_module_status_truthfully() {
let available = docker_handle_for_status(true);
diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rs
index ea89bd05a2..f6ec4b148a 100644
--- a/crates/openhuman-core/src/sandbox/ops.rs
+++ b/crates/openhuman-core/src/sandbox/ops.rs
@@ -2,10 +2,10 @@
//! routed execution.
use super::docker;
-use super::grants::{resolve_local_jail_grants, JailGrants};
+use super::grants::{JailGrants, resolve_local_jail_grants};
use super::types::{
- ElevatedOp, SandboxBackendHandle, SandboxBackendKind, SandboxExecRequest, SandboxExecResult,
- SandboxPolicy, SandboxStatus, ELEVATED_TOOLS,
+ ELEVATED_TOOLS, ElevatedOp, SandboxBackendHandle, SandboxBackendKind, SandboxExecRequest,
+ SandboxExecResult, SandboxPolicy, SandboxStatus,
};
use crate::agent::harness::definition::SandboxMode;
use crate::agent::platform_shell;
@@ -426,10 +426,14 @@ pub(crate) fn apply_requested_backend(
Ok(true)
}
SandboxBackend::Firejail => {
- anyhow::bail!("Firejail sandbox was explicitly requested but this build has no Firejail execution backend")
+ anyhow::bail!(
+ "Firejail sandbox was explicitly requested but this build has no Firejail execution backend"
+ )
}
SandboxBackend::Bubblewrap => {
- anyhow::bail!("Bubblewrap sandbox was explicitly requested but this build has no Bubblewrap execution backend")
+ anyhow::bail!(
+ "Bubblewrap sandbox was explicitly requested but this build has no Bubblewrap execution backend"
+ )
}
}
}
diff --git a/crates/openhuman-core/src/sandbox/ops_host_grants_tests.rs b/crates/openhuman-core/src/sandbox/ops_host_grants_tests.rs
index 3484e09daa..fda29b9751 100644
--- a/crates/openhuman-core/src/sandbox/ops_host_grants_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_host_grants_tests.rs
@@ -7,10 +7,12 @@ fn saas_local_grants_never_consult_the_operator_home() {
panic!("a tenant must not read the operator's home")
});
assert!(grants.read_write.is_empty());
- assert!(grants
- .read_only
- .iter()
- .all(|path| path.starts_with("/usr/local") || path.starts_with("/opt")));
+ assert!(
+ grants
+ .read_only
+ .iter()
+ .all(|path| path.starts_with("/usr/local") || path.starts_with("/opt"))
+ );
}
#[test]
@@ -19,7 +21,9 @@ fn single_user_local_grants_keep_the_configured_toolchain_home() {
std::fs::create_dir(home.path().join(".rustup")).unwrap();
let runtime = RuntimeConfig::default();
let grants = local_jail_grants_with_home(&runtime, false, || Some(home.path().to_path_buf()));
- assert!(grants
- .read_only
- .contains(&home.path().join(".rustup").canonicalize().unwrap()));
+ assert!(
+ grants
+ .read_only
+ .contains(&home.path().join(".rustup").canonicalize().unwrap())
+ );
}
diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rs
index 082e8dd546..b35f0bc721 100644
--- a/crates/openhuman-core/src/sandbox/ops_tests.rs
+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs
@@ -289,9 +289,11 @@ async fn execute_in_sandbox_none_backend_runs_on_every_os() {
fn env_passthrough_includes_safe_vars() {
assert!(SANDBOX_ENV_PASSTHROUGH.contains(&"PATH"));
assert!(SANDBOX_ENV_PASSTHROUGH.contains(&"HOME"));
- assert!(!SANDBOX_ENV_PASSTHROUGH
- .iter()
- .any(|v| v.contains("KEY") || v.contains("SECRET")));
+ assert!(
+ !SANDBOX_ENV_PASSTHROUGH
+ .iter()
+ .any(|v| v.contains("KEY") || v.contains("SECRET"))
+ );
}
// ── the security-relevant decision, tested independently of the host ─────────
diff --git a/crates/openhuman-core/src/sandbox/schemas.rs b/crates/openhuman-core/src/sandbox/schemas.rs
index 7569211fbd..97beceac49 100644
--- a/crates/openhuman-core/src/sandbox/schemas.rs
+++ b/crates/openhuman-core/src/sandbox/schemas.rs
@@ -3,8 +3,8 @@
use serde_json::{Map, Value};
use crate::config::rpc as config_rpc;
-use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::Outcome;
+use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
pub fn all_controller_schemas() -> Vec<ControllerSchema> {
diff --git a/crates/openhuman-core/src/sandbox/schemas_tests.rs b/crates/openhuman-core/src/sandbox/schemas_tests.rs
index a9476afba8..76021a5995 100644
--- a/crates/openhuman-core/src/sandbox/schemas_tests.rs
+++ b/crates/openhuman-core/src/sandbox/schemas_tests.rs
@@ -1,6 +1,6 @@
use super::*;
-use crate::core::runtime::context::CoreContext;
use crate::core::runtime::DomainSet;
+use crate::core::runtime::context::CoreContext;
/// Scope a `Config` onto the embedder-config seam that `load_config_with_timeout()`
/// prefers, so a handler reads it instead of doing live disk I/O against