Skip to content

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

refactor(security): replace vendored shell-parsing with tinybox_core::shell

Steven Enamakelda6870b20a6d
diff --git a/crates/openhuman-core/src/security/policy/README.md b/crates/openhuman-core/src/security/policy/README.md
index 43dfafde12..90bce6b993 100644
--- a/crates/openhuman-core/src/security/policy/README.md
+++ b/crates/openhuman-core/src/security/policy/README.md
@@ -45,7 +45,7 @@ impl in `types.rs`.
| `path_checks.rs` | `is_workspace_internal_path`, `is_always_forbidden`, `check_cross_profile`, `is_within_trusted_root`, `is_resolved_path_allowed[_for]`, `check_resolved_against_forbidden` |
| `command_checks.rs` | `classify_command`, `gate_decision`, `check_gated_command`, `is_command_allowed`, `command_risk_level`, `parse_declared_class`, `is_command_executor`, `split_unquoted_segments` |
| `enforcement.rs` | `can_act`, `enforce_write_tier`, `enforce_tool_operation`, `record_action`/`is_rate_limited`, `from_config`, `with_privacy_mode`, `openhuman_scratch_dir`/`ensure_openhuman_scratch_dir`, `validate_path_within_root` |
-| `policy_command/` (`quoting.rs`, `env_guard.rs`, `command_name.rs`, `classification.rs`) | Shell-parsing helpers behind the command checks: `split_unquoted_segments`, `skip_env_assignments`, `normalized_command_name`, `is_command_executor`, `classify_segment`, `has_hidden_execution`, `contains_unquoted_char` |
+| `tinybox_core::shell::{scan,classify,executor,env_guard}` (vendored) | Shell-parsing helpers behind the command checks: `split_unquoted_segments`, `skip_env_assignments`, `normalized_command_name`, `is_command_executor`, `classify_segment`, `has_hidden_execution`, `has_dangerous_env_prefix`, `contains_unquoted_char`, and the `CommandClass` enum (re-exported from `types.rs`) |
## Public surface
diff --git a/crates/openhuman-core/src/security/policy/command_checks.rs b/crates/openhuman-core/src/security/policy/command_checks.rs
index 5347b2f012..49091d6ff3 100644
--- a/crates/openhuman-core/src/security/policy/command_checks.rs
+++ b/crates/openhuman-core/src/security/policy/command_checks.rs
@@ -1,12 +1,12 @@
use crate::util::floor_char_boundary;
-use super::policy_command::{
- classify_segment, has_dangerous_env_prefix, has_hidden_execution, is_command_executor,
-};
use super::types::{
AutonomyLevel, CommandClass, CommandRiskLevel, GateDecision, SecurityPolicy,
POLICY_BLOCKED_MARKER,
};
+use tinybox_core::shell::classify::{classify_segment, has_hidden_execution};
+use tinybox_core::shell::env_guard::has_dangerous_env_prefix;
+use tinybox_core::shell::executor::is_command_executor;
use tinybox_core::shell::scan::{
command_basename, contains_unquoted_char, contains_unquoted_single_ampersand,
has_leading_env_assignment, normalized_command_name, skip_env_assignments,
diff --git a/crates/openhuman-core/src/security/policy/mod.rs b/crates/openhuman-core/src/security/policy/mod.rs
index 0055d844c1..727c075c7e 100644
--- a/crates/openhuman-core/src/security/policy/mod.rs
+++ b/crates/openhuman-core/src/security/policy/mod.rs
@@ -6,8 +6,6 @@ mod command_checks;
mod enforcement;
mod path_checks;
-mod policy_command;
-
mod types;
pub use enforcement::validate_path_within_root;
diff --git a/crates/openhuman-core/src/security/policy/policy_command/classification.rs b/crates/openhuman-core/src/security/policy/policy_command/classification.rs
deleted file mode 100644
index ac11ba5d1f..0000000000
--- a/crates/openhuman-core/src/security/policy/policy_command/classification.rs
+++ /dev/null
@@ -1,380 +0,0 @@
-//! Base-command classification: the read/write/network/install/destructive
-//! bucket lists, verb-sensitive VCS / package-manager handling, and the
-//! structural "hidden execution" guard for the harness-gated command flow.
-
-use crate::security::policy::policy_command::command_name::is_command_executor;
-use crate::security::policy::types::CommandClass;
-use tinybox_core::shell::scan::{
- contains_unquoted_background_ampersand, strip_quoted_heredoc_bodies,
-};
-
-/// Provably read-only command bases (cross-platform union). A base **not** in
-/// this set — and not a recognized network/destructive/executor command, nor a
-/// read-only verb of git/npm/cargo — falls through to [`CommandClass::Write`]
-/// (the classifier is fail-closed). Conservative on purpose: anything that can
-/// write a file under a common flag is intentionally omitted (`sort -o`, `tee`).
-const READ_ONLY_BASES: &[&str] = &[
- // POSIX inspection / read-only coreutils
- "ls",
- "cat",
- "pwd",
- "echo",
- "wc",
- "head",
- "tail",
- "date",
- "grep",
- "egrep",
- "fgrep",
- "rg",
- "which",
- "whoami",
- "id",
- "hostname",
- "uname",
- "printenv",
- "stat",
- "file",
- "du",
- "df",
- "tree",
- "realpath",
- "readlink",
- "dirname",
- "basename",
- "cmp",
- "true",
- "false",
- "sleep",
- "seq",
- "tty",
- "groups",
- "locale",
- "ps",
- "top",
- "free",
- "uptime",
- "lsblk",
- "lscpu",
- "cut",
- // NOTE: OS-native launchers (`open`, `xdg-open`, `start`) are deliberately
- // NOT in the read-only set. `classify_command` only sees the base command,
- // not its args, and these launchers can open arbitrary `https://` URLs and
- // custom URI handlers — i.e. trigger outbound network / system actions — so
- // treating them as `Read` (no approval) is too broad. App launching now
- // goes through the dedicated `launch_app` tool, which is scoped to named
- // applications only and carries no shell-arg ambiguity.
- // Windows cmd / PowerShell read verbs + common aliases
- "dir",
- "type",
- "where",
- "whereis",
- "get-childitem",
- "gci",
- "get-content",
- "gc",
- "get-location",
- "gl",
- "select-string",
- "sls",
- "measure-object",
- "get-item",
- "gi",
- "test-path",
- "resolve-path",
- "get-command",
- "gcm",
- "get-process",
-];
-
-/// Commands that reach the network. Always-ask in every acting tier.
-const NETWORK_BASES: &[&str] = &[
- "curl",
- "wget",
- "ssh",
- "scp",
- "sftp",
- "rsync",
- "nc",
- "ncat",
- "netcat",
- "telnet",
- "ftp",
- "tftp",
- "socat",
- // Windows / PowerShell
- "invoke-webrequest",
- "iwr",
- "invoke-restmethod",
- "irm",
- "start-bitstransfer",
- "bitsadmin",
-];
-
-/// Catastrophic / irreversible / privilege / system-control bases. Always-ask
-/// in every acting tier (Full included). Coarse on the broad Windows verbs
-/// (`reg`/`net`/`sc`) — over-prompting there is the safe default.
-const DESTRUCTIVE_BASES: &[&str] = &[
- // POSIX privilege / disk / system-control
- "sudo",
- "su",
- "doas",
- "dd",
- "mkfs",
- "fdisk",
- "sfdisk",
- "parted",
- "wipefs",
- "shred",
- "shutdown",
- "reboot",
- "halt",
- "poweroff",
- "init",
- "telinit",
- "mount",
- "umount",
- "swapoff",
- "iptables",
- "ip6tables",
- "nft",
- "ufw",
- "firewall-cmd",
- "useradd",
- "userdel",
- "usermod",
- "groupadd",
- "groupdel",
- "passwd",
- "chpasswd",
- "visudo",
- "modprobe",
- "insmod",
- "rmmod",
- // Windows / PowerShell
- "format",
- "diskpart",
- "bcdedit",
- "takeown",
- "cipher",
- "vssadmin",
- "reg",
- "regedit",
- "runas",
- "sc",
- "net",
- "set-executionpolicy",
- "stop-computer",
- "restart-computer",
- "clear-disk",
- "format-volume",
- "remove-partition",
- "disable-computerrestore",
-];
-
-/// Git subcommands that only read repository state. Anything else — including
-/// `commit`/`push`/`branch`/`config`/unknown/bare `git` — is fail-closed to
-/// `Write`.
-const GIT_READ_VERBS: &[&str] = &[
- "status",
- "log",
- "diff",
- "show",
- "remote",
- "describe",
- "blame",
- "ls-files",
- "ls-tree",
- "rev-parse",
- "cat-file",
- "shortlog",
- "reflog",
- "rev-list",
- "name-rev",
- "var",
- "check-ignore",
- "check-attr",
- "verify-commit",
- "count-objects",
- "fsck",
- "whatchanged",
- "grep",
- "version",
- "help",
-];
-
-/// npm/pnpm/yarn read-only subcommands. `install`/`run`/`test`/`exec` (which
-/// run arbitrary scripts) and unknown verbs are fail-closed to `Write`.
-const NODE_PKG_READ_VERBS: &[&str] = &[
- "ls", "list", "view", "info", "outdated", "ping", "whoami", "help", "why", "audit", "doctor",
-];
-
-/// cargo read-only subcommands. `build`/`run`/`test`/`check` compile and may
-/// run build scripts, so they are fail-closed to `Write`.
-const CARGO_READ_VERBS: &[&str] = &["tree", "metadata", "search", "info", "version", "help"];
-
-/// Detect a pacman *install/upgrade* from its bundled operation flag.
-///
-/// pacman packs its operation and modifiers into a single flag (`-Syu`, `-Ss`),
-/// and `args` reach us already lowercased — so the `-S` (sync) operation is
-/// indistinguishable from a literal `-s` by case alone. We therefore key off
-/// the *modifier* letters instead of a blanket `starts_with("-s")`, which would
-/// over-match every read-only `-S` query: a `-S`-family flag mutates the host
-/// only when it carries none of pacman's read-only query modifiers — search
-/// (`s`), info (`i`), list (`l`), groups (`g`) or print (`p`). So `-S pkg`,
-/// `-Sy`, `-Syu` are installs while `-Ss`/`-Si`/`-Sl`/`-Sg`/`-Sp` are reads.
-fn is_pacman_install(args: &[String]) -> bool {
- args.iter().any(|a| {
- a.strip_prefix("-s")
- .is_some_and(|modifiers| !modifiers.contains(['s', 'i', 'l', 'g', 'p']))
- })
-}
-
-/// Detect a package-manager *install* invocation. These mutate the host /
-/// global environment, so they are the always-ask `Install` bucket (even in
-/// Full) — the same gate the dedicated `install_tool` enforces, applied to the
-/// shell escape hatch. Project-local installs (`npm install` without `-g`,
-/// `cargo add`) are ordinary `Write`s and are deliberately NOT matched here.
-/// `args` are already lowercased by the caller.
-fn is_install_command(base: &str, args: &[String]) -> bool {
- let has = |needle: &str| args.iter().any(|a| a == needle);
- let first_is = |verb: &str| args.first().map(String::as_str) == Some(verb);
- match base {
- // System package managers.
- "apt" | "apt-get" | "dnf" | "yum" | "zypper" => has("install"),
- "pacman" => is_pacman_install(args),
- "apk" => has("add"),
- "brew" | "snap" | "flatpak" | "winget" | "choco" | "scoop" => has("install"),
- // Language package managers — host/global-modifying installs only.
- "pip" | "pip3" | "pipx" | "gem" | "go" | "cargo" => first_is("install"),
- "npm" | "pnpm" => {
- (has("install") || has("i") || has("add")) && (has("-g") || has("--global"))
- }
- "yarn" => has("global"),
- _ => false,
- }
-}
-
-/// Classify a single already-split shell segment. `base` is the normalized
-/// (lowercased, `.exe`-stripped, basename-only) program name; `args` are the
-/// lowercased remaining words; `joined` is the lowercased segment used for
-/// pattern matching. Fail-closed: an unrecognized base resolves to `Write`.
-pub(in crate::security::policy) fn classify_segment(
- base: &str,
- args: &[String],
- joined: &str,
-) -> CommandClass {
- // Catastrophic patterns first — they win regardless of the base command.
- if joined.contains("rm -rf /") || joined.contains("rm -fr /") || joined.contains(":(){:|:&};:")
- {
- return CommandClass::Destructive;
- }
- if DESTRUCTIVE_BASES.contains(&base) {
- return CommandClass::Destructive;
- }
- if NETWORK_BASES.contains(&base) {
- return CommandClass::Network;
- }
- // Package installs mutate the host → always-ask Install bucket (closes the
- // shell escape hatch around `install_tool`).
- if is_install_command(base, args) {
- return CommandClass::Install;
- }
- // Interpreters / code executors run arbitrary code. Fail-closed to Write
- // (not Destructive) so Full can still run code while Supervised prompts.
- if is_command_executor(base) {
- return CommandClass::Write;
- }
- // `find` is read-only unless it executes commands, deletes, or writes
- // files. -fprintf / -fprint / -fprint0 / -fls write their output to a
- // named file rather than stdout — an arbitrary-path write that side-steps
- // the gated file-write tools (and their workspace confinement), so they
- // must be classified Write (approval-gated) alongside -delete.
- //
- // `args` is built with `split_whitespace()`, which keeps shell quotes that
- // the shell itself strips before `find` runs — `find . '-fprint' out`
- // arrives as the literal `'-fprint'`. Trim surrounding single/double quotes
- // before matching so a quoted predicate cannot slip the write past the gate.
- if base == "find" {
- if args.iter().any(|a| {
- matches!(
- a.trim_matches(|c| c == '\'' || c == '"'),
- "-exec"
- | "-execdir"
- | "-ok"
- | "-okdir"
- | "-delete"
- | "-fprintf"
- | "-fprint"
- | "-fprint0"
- | "-fls"
- )
- }) {
- return CommandClass::Write;
- }
- return CommandClass::Read;
- }
- // Verb-sensitive VCS / package tools.
- if base == "git" {
- return verb_class(args, GIT_READ_VERBS);
- }
- if matches!(base, "npm" | "pnpm" | "yarn") {
- return verb_class(args, NODE_PKG_READ_VERBS);
- }
- if base == "cargo" {
- return verb_class(args, CARGO_READ_VERBS);
- }
- if READ_ONLY_BASES.contains(&base) {
- return CommandClass::Read;
- }
- // Fail closed: unknown or known-mutating base → Write.
- CommandClass::Write
-}
-
-/// `Read` when the first subcommand word is in `read_verbs`, else fail-closed
-/// `Write`. Mirrors the `args.first()` verb check used by `command_risk_level`.
-fn verb_class(args: &[String], read_verbs: &[&str]) -> CommandClass {
- match args.first().map(String::as_str) {
- Some(verb) if read_verbs.contains(&verb) => CommandClass::Read,
- _ => CommandClass::Write,
- }
-}
-
-/// Structural-safety guard for the harness-gated command flow (Option 2). Even
-/// after a human approves a command, a hidden subshell / command substitution /
-/// output redirect / `tee` / background `&` could smuggle a *different* command
-/// past the approval summary, so these are refused outside Full (which is
-/// trusted to use redirects and pipes). Mirrors the structural checks in
-/// [`SecurityPolicy::is_command_allowed`].
-/// Detect shell structure that can **hide execution** from `classify_command`,
-/// which only inspects the base command of each `;`/`&&`/`|` segment. Command
-/// and process substitution and backticks run an *inner* command classification
-/// can't see (`echo $(rm -rf ~)` classifies as `echo` = Read and would run
-/// unprompted), and a trailing `&` detaches a process past the gate — so these
-/// stay hard-blocked outside Full.
-///
-/// Deliberately NOT flagged here: plain redirects (`>`, `2>&1`, `2>/dev/null`),
-/// `tee`, and `${VAR}` expansion. `classify_command` already lifts a redirect /
-/// `tee` to `Write`, so the gate prompts and — once the human approves — the
-/// command MUST actually run. Re-blocking an approved `… 2>&1` here was the bug
-/// that made Supervised mode unusable: every command the agent wrote carried a
-/// `2>&1`, got approved, then silently failed this in-tool guard and never ran.
-pub(in crate::security::policy) fn has_hidden_execution(command: &str) -> bool {
- // A quoted heredoc body (`<< 'EOF' … EOF`) is data, not shell: the shell
- // performs no expansion inside it, so an `&`, a backtick or a `$(` there
- // cannot run anything. Scanning it as live text refused ordinary documents
- // — the life-scenario `meal-plan` write was blocked because four recipe
- // titles read "Chicken & Spinach". An *unquoted* delimiter is left in place
- // by the helper, because expansion IS live in that body.
- let command = &strip_quoted_heredoc_bodies(command);
- // The backtick check is deliberately NOT quote-aware: any backtick in the
- // command string is blocked, even inside a double-quoted literal. Over-
- // blocking is the safe direction here. (By contrast the `&` case below is
- // quote-aware via `contains_unquoted_background_ampersand`, because that one
- // must still allow benign fd-dup redirects like `2>&1`.)
- command.contains('`')
- || command.contains("$(")
- || command.contains("<(")
- || command.contains(">(")
- || contains_unquoted_background_ampersand(command)
-}
diff --git a/crates/openhuman-core/src/security/policy/policy_command/command_name.rs b/crates/openhuman-core/src/security/policy/policy_command/command_name.rs
deleted file mode 100644
index 6969d24475..0000000000
--- a/crates/openhuman-core/src/security/policy/policy_command/command_name.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-//! Detecting bases that execute arbitrary code (interpreters,
-//! shells, `xargs`, Windows LOLBins, …). Basename normalisation itself is
-//! `tinybox_core::shell::scan`.
-
-use tinybox_core::shell::scan::normalized_command_name;
-
-fn is_python_command(command: &str) -> bool {
- let command = normalized_command_name(command);
- command == "python"
- || command == "pythonw"
- || command
- .strip_prefix("pythonw")
- .and_then(|suffix| suffix.chars().next())
- .is_some_and(|ch| ch.is_ascii_digit())
- || command
- .strip_prefix("python")
- .and_then(|suffix| suffix.chars().next())
- .is_some_and(|ch| ch.is_ascii_digit())
-}
-
-pub(in crate::security::policy) fn is_command_executor(command: &str) -> bool {
- let command = normalized_command_name(command);
- is_python_command(command.as_str())
- || matches!(
- command.as_str(),
- "xargs"
- | "awk"
- | "gawk"
- | "mawk"
- | "nawk"
- | "perl"
- | "ruby"
- | "bash"
- | "sh"
- | "dash"
- | "zsh"
- | "ksh"
- | "fish"
- | "env"
- // JS/TS runtimes (the `node_exec`/`npm_exec` shell equivalents)
- | "node"
- | "nodejs"
- | "deno"
- | "bun"
- // Windows / PowerShell arbitrary-code launchers + LOLBins
- | "iex"
- | "invoke-expression"
- | "cmd"
- | "pwsh"
- | "powershell"
- | "wscript"
- | "cscript"
- | "mshta"
- | "rundll32"
- | "start-process"
- )
-}
diff --git a/crates/openhuman-core/src/security/policy/policy_command/env_guard.rs b/crates/openhuman-core/src/security/policy/policy_command/env_guard.rs
deleted file mode 100644
index 7da351ff7b..0000000000
--- a/crates/openhuman-core/src/security/policy/policy_command/env_guard.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-//! The "dangerous" subset of inline environment-variable assignments that can redirect execution of an
-//! otherwise-allowed command (pagers, editors, loader overrides, …).
-
-/// Environment variable names that can trigger arbitrary command execution
-/// when supplied as a leading inline assignment on an otherwise-allowed
-/// command. Each name here is either a hook variable that a downstream tool
-/// will spawn as a subprocess (`GIT_PAGER`, `GIT_SSH_COMMAND`, `EDITOR`,
-/// `LESS`/`LESSOPEN`, `MANPAGER`, `BROWSER`, `BAT_PAGER`), a runtime
-/// configuration knob that affects how Python or the shell evaluate user
-/// input (`PYTHONSTARTUP`, `BASH_ENV`, `ENV`, `PROMPT_COMMAND`), or a loader
-/// override that lets an attacker inject a library into the next process
-/// (`LD_PRELOAD`, `LD_LIBRARY_PATH`, `LD_AUDIT`, `DYLD_INSERT_LIBRARIES`,
-/// `DYLD_LIBRARY_PATH`, `DYLD_FORCE_FLAT_NAMESPACE`).
-///
-/// `PATH` and `SHELL` are listed so an inline override cannot redirect
-/// resolution of any allowed binary to an attacker-controlled path. `IFS`
-/// is listed because the shell uses it for word splitting and a malicious
-/// value can hide command boundaries from later parsers.
-const DANGEROUS_ENV_PREFIXES: &[&str] = &[
- "BASH_ENV",
- "BAT_PAGER",
- "BROWSER",
- "DYLD_FORCE_FLAT_NAMESPACE",
- "DYLD_INSERT_LIBRARIES",
- "DYLD_LIBRARY_PATH",
- "EDITOR",
- "ENV",
- "GIT_EDITOR",
- "GIT_EXTERNAL_DIFF",
- "GIT_EXTERNAL_FILTER",
- "GIT_PAGER",
- "GIT_SSH",
- "GIT_SSH_COMMAND",
- "IFS",
- "LD_AUDIT",
- "LD_LIBRARY_PATH",
- "LD_PRELOAD",
- "LESS",
- "LESSCLOSE",
- "LESSOPEN",
- "MANOPT",
- "MANPAGER",
- "PAGER",
- "PATH",
- "PROMPT_COMMAND",
- "PS1",
- "PS2",
- "PS3",
- "PS4",
- "PYTHONPATH",
- "PYTHONSTARTUP",
- "SHELL",
- "VISUAL",
-];
-
-/// Returns true if `s` starts with one or more inline env assignments and any
-/// of the assigned names are in [`DANGEROUS_ENV_PREFIXES`].
-///
-/// Now superseded by `has_leading_env_assignment` for the
-/// allowlist check (which rejects ANY leading env assignment), but kept
-/// for callers that specifically want the dangerous-only signal —
-/// notably tests that pin the old DANGEROUS_ENV_PREFIXES rejection
-/// shape.
-///
-/// The allowlist validation in [`SecurityPolicy::is_command_allowed`] uses
-/// [`skip_env_assignments`] to look past the env prefix before matching the
-/// command name. That leaves a class of attacks where the bare command (e.g.
-/// `git log`) is allowlisted but the env prefix mutates how it executes (e.g.
-/// `GIT_PAGER=<cmd> git log` — `git` spawns `<cmd>` as its pager). Because
-/// the prefix is stripped before allowlisting and the shell evaluates the
-/// prefix at execution time, the bypass lands without ever touching a
-/// blocked command name.
-///
-/// Treating any dangerous prefix as a denial keeps the allowlist
-/// semantically meaningful without having to enumerate every shape of every
-/// downstream tool's hook surface.
-pub(in crate::security::policy) fn has_dangerous_env_prefix(s: &str) -> bool {
- let mut rest = s.trim_start();
- loop {
- let Some(word) = rest.split_whitespace().next() else {
- return false;
- };
- if !word.contains('=') {
- return false;
- }
- if !word
- .chars()
- .next()
- .is_some_and(|c| c.is_ascii_alphabetic() || c == '_')
- {
- return false;
- }
- let (name, _) = word.split_once('=').unwrap_or((word, ""));
- let upper = name.to_ascii_uppercase();
- if DANGEROUS_ENV_PREFIXES.contains(&upper.as_str()) {
- return true;
- }
- rest = rest[word.len()..].trim_start();
- }
-}
diff --git a/crates/openhuman-core/src/security/policy/policy_command/mod.rs b/crates/openhuman-core/src/security/policy/policy_command/mod.rs
deleted file mode 100644
index 8c822d021d..0000000000
--- a/crates/openhuman-core/src/security/policy/policy_command/mod.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-//! Shell-command classification internals used by [`super::SecurityPolicy`]'s
-//! command-risk and allowlist gates.
-//!
-//! Split by responsibility:
-//! - [`env_guard`]: the dangerous inline env-assignment names.
-//! - [`command_name`]: the "executes arbitrary code" bases.
-//!
-//! The lexical scanning (quote-aware segment splitting, unquoted-character
-//! detection, quoted-heredoc blanking, basename and env-assignment parsing) is
-//! `tinybox_core::shell::scan`.
-//! - [`classification`]: read/write/network/install/destructive bucket lists
-//! and the hidden-execution structural guard.
-
-mod classification;
-mod command_name;
-mod env_guard;
-
-pub(super) use classification::{classify_segment, has_hidden_execution};
-pub(super) use command_name::is_command_executor;
-pub(super) use env_guard::has_dangerous_env_prefix;
diff --git a/crates/openhuman-core/src/security/policy/types.rs b/crates/openhuman-core/src/security/policy/types.rs
index ed99a16dd9..480ff42d77 100644
--- a/crates/openhuman-core/src/security/policy/types.rs
+++ b/crates/openhuman-core/src/security/policy/types.rs
@@ -71,31 +71,10 @@ pub enum CommandRiskLevel {
High,
}
-/// Coarse permission bucket the harness approval gate keys on.
-///
-/// Classification is **fail-closed**: a command that is not provably read-only
-/// (and not a recognized network/destructive command) is treated as at least
-/// [`CommandClass::Write`]. Across multiple shell segments the **highest** class
-/// wins (so `ls | curl …` is `Network`). Variants are ordered low→high so
-/// [`Ord`] / [`Iterator::max`] compose them directly.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub enum CommandClass {
- /// Provably read-only / observational (curated safe-read allowlist).
- Read,
- /// State-changing but not inherently catastrophic — the fail-closed default
- /// for anything not recognized as read/network/destructive.
- Write,
- /// Reaches the network (curl/wget/ssh/scp/…). Always prompts, every tier.
- Network,
- /// Installs an OS / language package (system package manager, or a *global*
- /// npm/pnpm/yarn/cargo/pip install). Always-ask in every acting tier,
- /// including Full — mirrors the dedicated `install_tool` gate so shell
- /// installs can't slip past it. Project-local installs are ordinary `Write`.
- Install,
- /// Catastrophic / irreversible / privilege-escalating / system-control.
- /// Always prompts, even in Full.
- Destructive,
-}
+/// Coarse permission bucket the harness approval gate keys on. Defined with the
+/// classifier in `tinybox_core::shell::classify`; re-exported here so host
+/// callers keep their path.
+pub use tinybox_core::shell::classify::CommandClass;
/// What the harness should do with an acting tool call of a given
/// [`CommandClass`] under the session's [`AutonomyLevel`]. Computed by