Skip to content

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

test: align upstream guards with shared policy

Steven Enamakel7c65b1ac6f28
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
index d609ca3406..882e980da4 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
@@ -230,6 +230,20 @@ fn shell_family_tools_route_to_sandbox_when_sandboxed_mode_active() {
const SHELL_SRC: &str = include_str!("shell.rs");
const NODE_EXEC_SRC: &str = include_str!("node_exec.rs");
const NPM_EXEC_SRC: &str = include_str!("npm_exec.rs");
+ const SANDBOX_OPS_SRC: &str = include_str!("../../../sandbox/ops.rs");
+
+ // The sandbox-mode decision is shared by the shell-family tools so the
+ // SaaS and explicit backend rules stay consistent. Keep the mode guard
+ // checked in its owning helper rather than requiring every tool to repeat
+ // the same `current_sandbox_mode()` match inline.
+ assert!(
+ SANDBOX_OPS_SRC.contains("current_sandbox_mode()"),
+ "command_requires_sandbox must read the active sandbox mode"
+ );
+ assert!(
+ SANDBOX_OPS_SRC.contains("SandboxMode::Sandboxed"),
+ "command_requires_sandbox must sandbox SandboxMode::Sandboxed sessions"
+ );
for (name, src) in [
("shell.rs", SHELL_SRC),
@@ -237,14 +251,8 @@ fn shell_family_tools_route_to_sandbox_when_sandboxed_mode_active() {
("npm_exec.rs", NPM_EXEC_SRC),
] {
assert!(
- src.contains("current_sandbox_mode()"),
- "{name} must check `current_sandbox_mode()` to detect SandboxMode::Sandboxed \
- sessions and route through the sandbox backend (see #3235)"
- );
- assert!(
- src.contains("SandboxMode::Sandboxed"),
- "{name} must compare against `SandboxMode::Sandboxed` to opt in to the \
- sandbox routing path (see #3235)"
+ src.contains("command_requires_sandbox().await"),
+ "{name} must consult the shared sandbox-mode decision before execution"
);
// Use the call-site pattern `.run_sandboxed(` so the assertion
// doesn't trivially pass on the helper definition itself
diff --git a/tests/x402_twit_sh_live.rs b/tests/x402_twit_sh_live.rs
index 049fd133ff..22136328f8 100644
--- a/tests/x402_twit_sh_live.rs
+++ b/tests/x402_twit_sh_live.rs
@@ -5,6 +5,7 @@
use openhuman_core::web3::x402;
use serde_json::json;
+use std::sync::Arc;
use tinytools::Tool;
#[tokio::test]
@@ -15,7 +16,10 @@ async fn x402_pay_twit_sh_for_hal_finney_tweet() {
let tmp = tempfile::tempdir().unwrap();
x402::init_ledger(tmp.path(), "test-session");
- let tool = x402::request_tool();
+ let tool = x402::request_tool(
+ Arc::new(openhuman_core::security::SecurityPolicy::default()),
+ vec!["twit.sh".into()],
+ );
let result = tool
.execute(json!({
"url": "https://x402.twit.sh/tweets/by/id?id=1110302988",