Skip to content
Python

test: align native validation and guest policy fixtures

Rohit P1199b9aba5d6
diff --git a/harness/runtime/tests/native_tools.rs b/harness/runtime/tests/native_tools.rs
index b8e7a710..e30de47c 100644
--- a/harness/runtime/tests/native_tools.rs
+++ b/harness/runtime/tests/native_tools.rs
@@ -163,7 +163,7 @@ fn native_cannot_claim_sandbox_placement() {
assert!(error.to_string().contains("host placement"), "{error:#}");
}
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "macos"))]
mod execution {
use super::*;
use openworker_runtime::{execution::Backend, model::Model, runtime::Runtime};
@@ -292,7 +292,17 @@ mod execution {
let invalid = f
.start(&rt, "bypass", json!({"behavior":"not-in-schema"}))
.await;
- assert_eq!(finish(&rt, &invalid).await["turn"]["status"], "failed");
+ // Invalid arguments are returned to the model as an unexecuted tool
+ // error so it can correct them or finish, rather than failing the turn.
+ let finished = finish(&rt, &invalid).await;
+ assert_eq!(finished["turn"]["status"], "completed");
+ assert_eq!(finished["turn"]["budget"]["validation_errors"], 1);
+ let events = rt.store.lock().unwrap().events(&invalid, 0).unwrap();
+ assert!(!events.iter().any(|e| e.kind == "tool_started"));
+ let rejected = events.iter().find(|e| e.kind == "tool_finished").unwrap();
+ assert_eq!(rejected.data["result"]["code"], "invalid_tool_arguments");
+ assert_eq!(rejected.data["result"]["executed"], false);
+ assert!(events.iter().any(|e| e.kind == "tool_validation_failed"));
assert_eq!(f.calls.load(Ordering::SeqCst), 0);
rt.shutdown().await.unwrap();
}
diff --git a/harness/runtime/tests/resources.rs b/harness/runtime/tests/resources.rs
index 2c3975e8..9bf30fe8 100644
--- a/harness/runtime/tests/resources.rs
+++ b/harness/runtime/tests/resources.rs
@@ -313,15 +313,9 @@ fn replacing_a_granted_root_invalidates_its_resolved_identity() {
async fn protocol_preview_pins_creation_and_blocks_changed_credentials() {
let f = Fixture::new();
let runner = f.root.join("runner");
- fs::write(
- &runner,
- if cfg!(target_os = "macos") {
- b"\xcf\xfa\xed\xfe-test-no-execution".as_slice()
- } else {
- b"\x7fELF-test-no-execution".as_slice()
- },
- )
- .unwrap();
+ // OpenShell runs a Linux guest even when the host is macOS. This policy
+ // preview never executes the fixture, but it must match that guest format.
+ fs::write(&runner, b"\x7fELF-test-no-execution").unwrap();
let rt = Runtime::open_with_policies(
&f.root.join("state"),
&f.bundle.root,