Skip to content

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

refactor(tinybox): use named bus constants for method catalogue

Steven Enamakel2b30bcd30296
diff --git a/crates/openhuman-core/src/modules/tinybox.rs b/crates/openhuman-core/src/modules/tinybox.rs
index a560f15ecd..0398ebefb3 100644
--- a/crates/openhuman-core/src/modules/tinybox.rs
+++ b/crates/openhuman-core/src/modules/tinybox.rs
@@ -18,40 +18,39 @@ pub const MODULE_ID: &str = "tinybox";
const MODULE_CALL_TIMEOUT: Duration = Duration::from_secs(300);
-// `tinybox_bus::METHODS` is the canonical method catalogue. Its original
-// members retain their positions and additions are append-only; indexing here
-// avoids maintaining a second set of wire strings in the host.
-const DESCRIBE: &str = contract::METHODS[0];
-const CREATE: &str = contract::METHODS[1];
-const EXEC: &str = contract::METHODS[2];
-const INSPECT: &str = contract::METHODS[3];
-const CLOSE: &str = contract::METHODS[4];
-const SPAWN: &str = contract::METHODS[5];
-const IS_RUNNING: &str = contract::METHODS[6];
-const CANCEL: &str = contract::METHODS[7];
-const ANALYZE_SHELL: &str = contract::METHODS[8];
-const RESERVE: &str = contract::METHODS[9];
-const CAPABILITIES: &str = contract::METHODS[10];
-const SHUTDOWN: &str = contract::METHODS[11];
-const FORWARD: &str = contract::METHODS[12];
-const CLOSE_FORWARD: &str = contract::METHODS[13];
-const JAIL_STATUS: &str = contract::METHODS[14];
-const ANALYZE_COMMAND: &str = contract::METHODS[15];
-const BEGIN_FILE_READ: &str = contract::METHODS[16];
-const READ_FILE_CHUNK: &str = contract::METHODS[17];
-const FINISH_FILE_READ: &str = contract::METHODS[18];
-const BEGIN_FILE_WRITE: &str = contract::METHODS[19];
-const WRITE_FILE_CHUNK: &str = contract::METHODS[20];
-const FINISH_FILE_WRITE: &str = contract::METHODS[21];
-const ABORT_FILE_WRITE: &str = contract::METHODS[22];
-const START_EXEC: &str = contract::METHODS[23];
-const READ_OUTPUT: &str = contract::METHODS[24];
-const RELEASE_OUTPUT: &str = contract::METHODS[25];
-const START_JAILED_EXEC: &str = contract::METHODS[26];
-const RUN_DOCKER: &str = contract::METHODS[27];
-const DOCKER_STATUS: &str = contract::METHODS[28];
-const CLEANUP_DOCKER: &str = contract::METHODS[29];
-const RUN_DOCKER_WITHOUT_WORKSPACE: &str = contract::METHODS[30];
+// `tinybox_bus::names` carries one named constant per bus member; the host
+// never indexes `METHODS` positionally nor keeps a second set of wire strings.
+const DESCRIBE: &str = contract::names::DESCRIBE;
+const CREATE: &str = contract::names::CREATE;
+const EXEC: &str = contract::names::EXEC;
+const INSPECT: &str = contract::names::INSPECT;
+const CLOSE: &str = contract::names::CLOSE;
+const SPAWN: &str = contract::names::SPAWN;
+const IS_RUNNING: &str = contract::names::IS_RUNNING;
+const CANCEL: &str = contract::names::CANCEL;
+const ANALYZE_SHELL: &str = contract::names::ANALYZE_SHELL;
+const RESERVE: &str = contract::names::RESERVE;
+const CAPABILITIES: &str = contract::names::CAPABILITIES;
+const SHUTDOWN: &str = contract::names::SHUTDOWN;
+const FORWARD: &str = contract::names::FORWARD;
+const CLOSE_FORWARD: &str = contract::names::CLOSE_FORWARD;
+const JAIL_STATUS: &str = contract::names::JAIL_STATUS;
+const ANALYZE_COMMAND: &str = contract::names::ANALYZE_COMMAND;
+const BEGIN_FILE_READ: &str = contract::names::BEGIN_FILE_READ;
+const READ_FILE_CHUNK: &str = contract::names::READ_FILE_CHUNK;
+const FINISH_FILE_READ: &str = contract::names::FINISH_FILE_READ;
+const BEGIN_FILE_WRITE: &str = contract::names::BEGIN_FILE_WRITE;
+const WRITE_FILE_CHUNK: &str = contract::names::WRITE_FILE_CHUNK;
+const FINISH_FILE_WRITE: &str = contract::names::FINISH_FILE_WRITE;
+const ABORT_FILE_WRITE: &str = contract::names::ABORT_FILE_WRITE;
+const START_EXEC: &str = contract::names::START_EXEC;
+const READ_OUTPUT: &str = contract::names::READ_OUTPUT;
+const RELEASE_OUTPUT: &str = contract::names::RELEASE_OUTPUT;
+const START_JAILED_EXEC: &str = contract::names::START_JAILED_EXEC;
+const RUN_DOCKER: &str = contract::names::RUN_DOCKER;
+const DOCKER_STATUS: &str = contract::names::DOCKER_STATUS;
+const CLEANUP_DOCKER: &str = contract::names::CLEANUP_DOCKER;
+const RUN_DOCKER_WITHOUT_WORKSPACE: &str = contract::names::RUN_DOCKER_WITHOUT_WORKSPACE;
const SELECT_SHELL: &str = contract::names::SELECT_SHELL;
const RESOLVE_LOCAL_GRANTS: &str = contract::names::RESOLVE_LOCAL_GRANTS;
const START_SHELL_EXEC: &str = contract::names::START_SHELL_EXEC;
diff --git a/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs b/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs
index 3f9eae679f..0b0b24cdb9 100644
--- a/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_allowlist_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use tinybox_bus::CommandClass;
// -- AutonomyLevel ------------------------------------------------
diff --git a/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs b/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
index 8f6fd89c72..340128e2e0 100644
--- a/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_disabled_tests.rs
@@ -6,6 +6,7 @@
//! likely to break, so it is asserted here beside the first.
use super::*;
+use tinybox_bus::CommandClass;
use std::path::PathBuf;
fn disabled_policy() -> SecurityPolicy {
diff --git a/crates/openhuman-core/src/security/policy/policy_injection_tests.rs b/crates/openhuman-core/src/security/policy/policy_injection_tests.rs
index 7b77683be8..622dec99b9 100644
--- a/crates/openhuman-core/src/security/policy/policy_injection_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_injection_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use tinybox_bus::CommandClass;
#[test]
fn command_injection_background_chain_blocked() {
diff --git a/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs b/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs
index df733ff5fa..cae73a281e 100644
--- a/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs
+++ b/crates/openhuman-core/src/security/policy/policy_paths_and_risk_tests.rs
@@ -1,4 +1,5 @@
use super::*;
+use tinybox_bus::CommandClass;
#[test]
fn always_forbidden_blocks_core_os_dirs_cross_platform() {
@@ -73,7 +74,7 @@ fn parse_declared_class_maps_known_and_rejects_unknown() {
#[test]
fn tinybox_command_facts_drive_policy_and_keep_the_path_floor_when_disabled() {
use crate::modules::tinybox::contract::{
- CommandAnalysis, CommandClass as ModuleClass, CommandSegment,
+ CommandAnalysis, CommandSegment,
};
let write_segment = CommandSegment {
@@ -82,7 +83,7 @@ fn tinybox_command_facts_drive_policy_and_keep_the_path_floor_when_disabled() {
basename: "ls".into(),
normalized_name: "ls".into(),
arguments: vec!["-la".into()],
- class: ModuleClass::Write,
+ class: CommandClass::Write,
leading_env_assignment: false,
dangerous_env_prefix: false,
executor: false,
@@ -156,7 +157,7 @@ fn tinybox_command_facts_drive_policy_and_keep_the_path_floor_when_disabled() {
#[test]
fn tinybox_fact_allowlist_treats_heredoc_as_data_and_unknown_commands_as_writes() {
use crate::modules::tinybox::contract::{
- CommandAnalysis, CommandClass as ModuleClass, CommandSegment,
+ CommandAnalysis, CommandSegment,
};
let policy = SecurityPolicy {
@@ -174,7 +175,7 @@ fn tinybox_fact_allowlist_treats_heredoc_as_data_and_unknown_commands_as_writes(
basename: "cat".into(),
normalized_name: "cat".into(),
arguments: vec!["notes.txt".into()],
- class: ModuleClass::Write,
+ class: CommandClass::Write,
leading_env_assignment: false,
dangerous_env_prefix: false,
executor: false,
@@ -197,7 +198,7 @@ fn tinybox_fact_allowlist_treats_heredoc_as_data_and_unknown_commands_as_writes(
basename: "unrecognized-tool".into(),
normalized_name: "unrecognized-tool".into(),
arguments: vec!["--flag".into()],
- class: ModuleClass::Write,
+ class: CommandClass::Write,
leading_env_assignment: false,
dangerous_env_prefix: false,
executor: false,