Skip to content

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

fix(hooks): warn when built without modules and serialize shell tests

Steven Enamakeled3137a9477b
diff --git a/crates/openhuman-core/src/hooks/shell.rs b/crates/openhuman-core/src/hooks/shell.rs
index ca4bdabb71..cc8bf7390f 100644
--- a/crates/openhuman-core/src/hooks/shell.rs
+++ b/crates/openhuman-core/src/hooks/shell.rs
@@ -48,6 +48,8 @@ pub(super) async fn resolve() {
Err(error) => log::warn!("[hooks] TinyBox shell selection failed: {error}"),
}
}
+ #[cfg(not(feature = "modules"))]
+ log::warn!("[hooks] built without `modules`; hook commands cannot select a shell");
}
fn install(selection: ShellInvocation) {
diff --git a/crates/openhuman-core/src/hooks/shell_tests.rs b/crates/openhuman-core/src/hooks/shell_tests.rs
index 283211864d..8798ae2b57 100644
--- a/crates/openhuman-core/src/hooks/shell_tests.rs
+++ b/crates/openhuman-core/src/hooks/shell_tests.rs
@@ -67,11 +67,26 @@ fn a_selection_must_embed_the_command_exactly_once() {
assert!(!embeds_placeholder_once(&twice));
}
+/// The selection is process-global, so tests that install or clear it share this.
+static SELECTION: std::sync::Mutex<()> = std::sync::Mutex::new(());
+
#[test]
fn an_unresolved_selection_fails_the_spawn_instead_of_picking_a_shell() {
- // A fresh slot is process-global state; this test only reads the factory's
- // behavior when nothing was installed or after clearing it.
+ let _serial = SELECTION
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
*slot().write().unwrap() = None;
let process = command("echo hi");
assert_eq!(process.as_std().get_program(), UNAVAILABLE);
}
+
+#[test]
+fn an_installed_selection_builds_the_hook_process() {
+ let _serial = SELECTION
+ .lock()
+ .unwrap_or_else(std::sync::PoisonError::into_inner);
+ install(posix());
+ let process = command("echo hi");
+ assert_eq!(process.as_std().get_program(), "/bin/bash");
+ *slot().write().unwrap() = None;
+}
diff --git a/crates/openhuman-core/src/modules/tinybox_tests.rs b/crates/openhuman-core/src/modules/tinybox_tests.rs
index 8ef5738c49..6e54c09735 100644
--- a/crates/openhuman-core/src/modules/tinybox_tests.rs
+++ b/crates/openhuman-core/src/modules/tinybox_tests.rs
@@ -356,7 +356,7 @@ async fn pinned_loader_serves_resolve_local_grants_from_tinybox_v0124() {
let record = crate::modules::registry::find(MODULE_ID).expect("TinyBox registry record");
assert_eq!(record.version, "0.1.28");
- assert_eq!(contract::CONTRACT_VERSION, (1, 17));
+ assert_eq!(contract::CONTRACT_VERSION, (1, 18));
let asset = tinybus::module::platform::host_candidates()
.iter()
.find_map(|host_key| record.asset_for(host_key))
diff --git a/crates/openhuman-core/src/sandbox/README.md b/crates/openhuman-core/src/sandbox/README.md
index 2a7627c24c..9163a4f081 100644
--- a/crates/openhuman-core/src/sandbox/README.md
+++ b/crates/openhuman-core/src/sandbox/README.md
@@ -38,8 +38,10 @@ backend, execute.
+--------------+------------------+
v v v
None Local Docker
- host shell TinyBox StartJailedExec TinyBox RunDocker
- (env cleared) with explicit jail action_dir mounted at /workspace
+ TinyBox TinyBox TinyBox RunDocker
+ StartNative- StartNativeShellExec action_dir mounted at /workspace
+ ShellExec with explicit jail
+ (no jail)
```
### Resolving a policy
@@ -80,13 +82,13 @@ the `modules` feature the run is refused.
`native_jail.rs` asks the pinned TinyBox module for `JailStatus`, creates a
module-owned `passthrough` resource rooted at `policy.workspace_root`, and
-starts the shell through `StartJailedExec`. The request carries only the
+starts the shell through `StartNativeShellExec` with a jail. The request carries only the
resolved read-only/read-write grants, network policy, and a required enforced
isolation floor. TinyBox owns the jail provider, child process, pipe capture,
and kill/reap acknowledgement; OpenHuman reads bounded output batches and
-closes the resource after terminal cleanup. A per-call scratch directory under
-the core state dir is granted read-write and used for `TMPDIR`, `TEMP`, and
-`TMP` unless the caller supplied one. No host-local jail or unconfined fallback
+closes the resource after terminal cleanup. TinyBox owns the per-call scratch
+directory under the core state dir: it grants it read-write and points `TMPDIR`,
+`TEMP`, and `TMP` at it unless the caller supplied one. No host-local jail or unconfined fallback
runs if the module, artifact, or requested enforcement is unavailable.
A real jail (Landlock, Seatbelt) denies everything it is not told about, so