Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cf0c498
chore(vendor): bump tinybox submodule
senamakel Oct 30, 2026
c5a3419
build(deps): add tinybox-openshell dependency
senamakel Oct 30, 2026
18cce72
test(config): cover openshell backend wire name
senamakel Oct 30, 2026
5f6a3b3
feat(config): register openshell runtime config module
senamakel Oct 30, 2026
c042cef
feat(config): add openshell runtime config and sandbox backend
senamakel Oct 30, 2026
5800c98
chore(config): re-export OpenShellRuntimeConfig
senamakel Oct 30, 2026
e8bdf57
feat(sandbox): add scripted driver fixture for openshell tests
senamakel Oct 30, 2026
113f340
test(sandbox): add registry tests for openshell sandbox
senamakel Oct 30, 2026
15dbeac
test(sandbox): add bus driver tests for openshell sandbox
senamakel Oct 30, 2026
c3b3ac4
test(sandbox): add tests for openshell sandbox module
senamakel Oct 30, 2026
4fad698
test(sandbox): cover openshell backend routing and serialization
senamakel Oct 30, 2026
7525b17
test(sandbox): cover openshell backend detection in doctor check
senamakel Oct 30, 2026
7cc6c52
feat(sandbox): expose openshell module
senamakel Oct 30, 2026
a769cf2
feat(sandbox): add per-tenant box registry with single-flight creation
senamakel Oct 30, 2026
6a9d623
refactor(sandbox): extract box checkout bookkeeping into a hold helper
senamakel Oct 30, 2026
6a13eea
feat(tinybox): add exec_within with caller-supplied deadline
senamakel Oct 30, 2026
ccce54c
feat(sandbox): add bus-backed box driver for openshell
senamakel Oct 30, 2026
eb1968b
feat(sandbox): add openshell backend with per-tenant box registry
senamakel Oct 30, 2026
4ab3c3e
feat(sandbox): add openshell backend support
senamakel Oct 30, 2026
7b51ad9
style: apply rustfmt formatting to openshell sandbox and config modules
senamakel Oct 30, 2026
9fb55cd
test(openshell): cover release and shutdown before any box exists
senamakel Oct 30, 2026
c40622a
chore(ci): register openshell box registry in process statics
senamakel Oct 30, 2026
5febc85
docs(sandbox): document the openshell sandbox backend
senamakel Oct 30, 2026
249d272
chore(ci): refresh saas ambient baseline for shifted lines
senamakel Oct 30, 2026
34f905a
chore(ci): update saas ambient baseline line numbers
senamakel Oct 30, 2026
bc46551
refactor(sandbox): use fully qualified std::sync::Arc paths
senamakel Oct 30, 2026
051dec5
test(openshell): cover closing a box reported gone before replacement
senamakel Oct 30, 2026
76b6489
fix(sandbox): close box on gateway after unknown resource error
senamakel Oct 30, 2026
59b57d9
fix(sandbox): reject unusable openshell box settings and clamp regist…
senamakel Oct 30, 2026
9cd6ca9
Merge branch 'main' of https://github.com/tinyhumansai/openhuman into…
senamakel Oct 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions crates/openhuman-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ pub use schema::{
LegacySearchInputs, LinqConfig, LocalAiConfig, LocalJailConfig, MatrixConfig, McpAuthConfig,
McpClientConfig, McpClientIdentityConfig, McpServerConfig, McpToolExposure, MemoryConfig,
MemoryLayoutMode, ModelRouteConfig, MultimodalConfig, MultimodalFileConfig,
ObservabilityConfig, OrchestratorModelConfig, PresentationMode, PrivacyConfig, PrivacyMode,
ProviderRoute, ProxyConfig, ProxyScope, ReliabilityConfig, ResourceLimitsConfig, RuntimeConfig,
SandboxBackend, SandboxConfig, SchedulerConfig, SchedulerGateConfig, SchedulerGateMode,
SearchConfig, SearchEngineCredentials, SearchHostCredential, SearchProviderSettings,
SearxngConfig, SecretsConfig, SecurityConfig, ShellConfig, SlackConfig, StreamMode, SttEngine,
TeamModelConfig, TelegramConfig, TokenjuiceConfig, UnknownKeyedSearchProvider, UpdateConfig,
UpdateRestartStrategy, VoiceServerConfig, WebSearchConfig, WebhookConfig, YuanbaoConfig,
MANAGED_SEARCH_PROVIDERS, SEARCH_ENGINE_BRAVE, SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA,
SEARCH_ENGINE_MANAGED, SEARCH_ENGINE_PARALLEL, SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY,
SEARCH_PROVIDERS, SEARCH_ROLES, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
ObservabilityConfig, OpenShellRuntimeConfig, OrchestratorModelConfig, PresentationMode,
PrivacyConfig, PrivacyMode, ProviderRoute, ProxyConfig, ProxyScope, ReliabilityConfig,
ResourceLimitsConfig, RuntimeConfig, SandboxBackend, SandboxConfig, SchedulerConfig,
SchedulerGateConfig, SchedulerGateMode, SearchConfig, SearchEngineCredentials,
SearchHostCredential, SearchProviderSettings, SearxngConfig, SecretsConfig, SecurityConfig,
ShellConfig, SlackConfig, StreamMode, SttEngine, TeamModelConfig, TelegramConfig,
TokenjuiceConfig, UnknownKeyedSearchProvider, UpdateConfig, UpdateRestartStrategy,
VoiceServerConfig, WebSearchConfig, WebhookConfig, YuanbaoConfig, MANAGED_SEARCH_PROVIDERS,
SEARCH_ENGINE_BRAVE, SEARCH_ENGINE_DISABLED, SEARCH_ENGINE_EXA, SEARCH_ENGINE_MANAGED,
SEARCH_ENGINE_PARALLEL, SEARCH_ENGINE_QUERIT, SEARCH_ENGINE_TAVILY, SEARCH_PROVIDERS,
SEARCH_ROLES, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS, SEARCH_ROLE_SEARCH,
};
// Kept as a separate re-export (issue #4117) so the large alphabetized group
// above stays byte-identical and rustfmt-stable.
Expand Down
70 changes: 45 additions & 25 deletions crates/openhuman-core/src/config/ops/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,7 @@ pub async fn get_sandbox_settings(ctx: &DispatchCtx) -> Result<Outcome<serde_jso
.await
.map_err(|_| "Docker status probe timed out".to_owned())??;

let backend_str = match sandbox.backend {
crate::config::SandboxBackend::Auto => "auto",
crate::config::SandboxBackend::Landlock => "landlock",
crate::config::SandboxBackend::Firejail => "firejail",
crate::config::SandboxBackend::Bubblewrap => "bubblewrap",
crate::config::SandboxBackend::Docker => "docker",
crate::config::SandboxBackend::None => "none",
};
let backend_str = backend_name(&sandbox.backend);

let detected_backend = crate::sandbox::native_jail::status(&config)
.await
Expand All @@ -62,6 +55,45 @@ pub async fn get_sandbox_settings(ctx: &DispatchCtx) -> Result<Outcome<serde_jso
Ok(Outcome::single_log(value, "sandbox settings read"))
}

/// The settings name of a backend, as `[security.sandbox] backend` spells it.
fn backend_name(backend: &crate::config::SandboxBackend) -> &'static str {
use crate::config::SandboxBackend;
match backend {
SandboxBackend::Auto => "auto",
SandboxBackend::Landlock => "landlock",
SandboxBackend::Firejail => "firejail",
SandboxBackend::Bubblewrap => "bubblewrap",
SandboxBackend::Docker => "docker",
SandboxBackend::OpenShell => "openshell",
SandboxBackend::None => "none",
}
}

/// The backend a settings name selects. `firejail` and `bubblewrap` stay
/// readable in saved settings but cannot be chosen: TinyBox does the native
/// sandboxing in this build.
fn parse_backend(name: &str) -> Result<crate::config::SandboxBackend, String> {
use crate::config::SandboxBackend;
Ok(match name {
"auto" => SandboxBackend::Auto,
"landlock" => SandboxBackend::Landlock,
"firejail" | "bubblewrap" => {
return Err(format!(
"unsupported sandbox backend '{name}': this build uses TinyBox for native sandboxing; valid: auto, landlock, docker, openshell, none"
));
}
"docker" => SandboxBackend::Docker,
"openshell" => SandboxBackend::OpenShell,
"none" => SandboxBackend::None,
other => {
log::warn!("[config][sandbox] rejected unknown backend: {other}");
return Err(format!(
"unknown sandbox backend '{other}'; valid: auto, landlock, docker, openshell, none"
));
}
})
}

pub async fn apply_sandbox_settings(
config: &mut Config,
update: SandboxSettingsPatch,
Expand All @@ -73,23 +105,7 @@ pub async fn apply_sandbox_settings(
);
}
if let Some(ref backend) = update.backend {
config.sandbox.backend = match backend.as_str() {
"auto" => crate::config::SandboxBackend::Auto,
"landlock" => crate::config::SandboxBackend::Landlock,
"firejail" | "bubblewrap" => {
return Err(format!(
"unsupported sandbox backend '{backend}': this build uses TinyBox for native sandboxing; valid: auto, landlock, docker, none"
));
}
"docker" => crate::config::SandboxBackend::Docker,
"none" => crate::config::SandboxBackend::None,
other => {
log::warn!("[config][sandbox] rejected unknown backend: {other}");
return Err(format!(
"unknown sandbox backend '{other}'; valid: auto, landlock, docker, none"
));
}
};
config.sandbox.backend = parse_backend(backend)?;
}
if let Some(enabled) = update.enabled {
config.sandbox.enabled = Some(enabled);
Expand Down Expand Up @@ -133,3 +149,7 @@ pub async fn load_and_apply_sandbox_settings(
let mut config = ctx.load_config().await?;
apply_sandbox_settings(&mut config, update).await
}

#[cfg(test)]
#[path = "sandbox_tests.rs"]
mod tests;
35 changes: 35 additions & 0 deletions crates/openhuman-core/src/config/ops/sandbox_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use super::*;
use crate::config::SandboxBackend;

#[test]
fn every_backend_name_parses_back_to_itself() {
for backend in [
SandboxBackend::Auto,
SandboxBackend::Landlock,
SandboxBackend::Docker,
SandboxBackend::OpenShell,
SandboxBackend::None,
] {
let name = backend_name(&backend);
assert_eq!(
serde_json::to_value(&backend).unwrap(),
serde_json::json!(name)
);
assert_eq!(backend_name(&parse_backend(name).unwrap()), name);
}
}

#[test]
fn an_unknown_backend_names_the_valid_ones() {
let refused = parse_backend("vm").unwrap_err();
assert!(refused.contains("unknown sandbox backend 'vm'"));
assert!(refused.contains("openshell"));
}

#[test]
fn the_legacy_jail_names_are_refused_as_unsupported() {
for name in ["firejail", "bubblewrap"] {
let refused = parse_backend(name).unwrap_err();
assert!(refused.contains("unsupported sandbox backend"), "{refused}");
}
}
1 change: 1 addition & 0 deletions crates/openhuman-core/src/config/schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ is mounted as a submodule of [`load/dirs.rs`](./load/dirs.rs) via `#[path]`.
| `[[model_routes]]`, `[[embedding_routes]]` | [`routes.rs`](./routes.rs) | `ModelRouteConfig`, `EmbeddingRouteConfig` |
| `[runtime]` (+ `[runtime.docker]`), `[shell]`, `[reliability]`, `[scheduler]` | [`runtime.rs`](./runtime.rs) | `RuntimeConfig`, `DockerRuntimeConfig`, `ShellConfig`, `ReliabilityConfig`, `SchedulerConfig` |
| `[runtime.local_jail]` | [`runtime_local_jail.rs`](./runtime_local_jail.rs) | `LocalJailConfig`: filesystem grants for the local OS jail |
| `[runtime.openshell]` | [`runtime_openshell.rs`](./runtime_openshell.rs) | `OpenShellRuntimeConfig`: image, CPU, memory (whole MiB), idle TTL and `max_live` for the OpenShell sandbox backend |
| `[scheduler_gate]` | [`scheduler_gate.rs`](./scheduler_gate.rs) | `SchedulerGateConfig`, `SchedulerGateMode` |
| `[memory]` (engine, `engines.<id>`, `conversations`, `context`, `sources`, embedding settings) | [`memory.rs`](./memory.rs) | `MemoryConfig`, `MemoryEngineSettings`, `MemoryConversationsConfig`, `MemoryContextConfig`, `MemorySourceConfig` (see [`docs/specs/memory-v2.md`](../../../../../docs/specs/memory-v2.md)) |
| `[task_sources]` | [`task_sources.rs`](./task_sources.rs) | `TaskSourcesConfig` |
Expand Down
2 changes: 2 additions & 0 deletions crates/openhuman-core/src/config/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ mod proxy;
mod routes;
mod runtime;
mod runtime_local_jail;
mod runtime_openshell;
mod scheduler_gate;
mod task_sources;
mod tokenjuice;
Expand Down Expand Up @@ -149,6 +150,7 @@ pub use runtime::{
DockerRuntimeConfig, ReliabilityConfig, RuntimeConfig, SchedulerConfig, ShellConfig,
};
pub use runtime_local_jail::LocalJailConfig;
pub use runtime_openshell::{OpenShellRuntimeConfig, DEFAULT_OPENSHELL_IMAGE};
pub use scheduler_gate::{PauseReason, Policy, SchedulerGateConfig, SchedulerGateMode};
pub use security::{
AuditConfig, ResourceLimitsConfig, SandboxBackend, SandboxConfig, SecurityConfig,
Expand Down
4 changes: 4 additions & 0 deletions crates/openhuman-core/src/config/schema/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ pub struct RuntimeConfig {
/// Filesystem grants for the local OS jail (`[runtime.local_jail]`).
#[serde(default)]
pub local_jail: super::LocalJailConfig,
/// Boxes for the OpenShell sandbox backend (`[runtime.openshell]`).
#[serde(default)]
pub openshell: super::OpenShellRuntimeConfig,
#[serde(default)]
pub reasoning_enabled: Option<bool>,
/// Reasoning ("thinking") effort for agent turns: `none`, `minimal`,
Expand Down Expand Up @@ -107,6 +110,7 @@ impl Default for RuntimeConfig {
kind: default_runtime_kind(),
docker: DockerRuntimeConfig::default(),
local_jail: super::LocalJailConfig::default(),
openshell: super::OpenShellRuntimeConfig::default(),
reasoning_enabled: None,
reasoning_effort: None,
reasoning_effort_by_model: BTreeMap::new(),
Expand Down
63 changes: 63 additions & 0 deletions crates/openhuman-core/src/config/schema/runtime_openshell.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//! `[runtime.openshell]` — the boxes the OpenShell sandbox backend creates.
//!
//! With `[security.sandbox] backend = "openshell"`, every sandboxed shell
//! command runs in a box the TinyBox module creates on an NVIDIA OpenShell
//! gateway. Each tenant (profile and agent) gets one box, created on its first
//! command, reused after that, and closed once it has been idle for
//! `idle_ttl_secs`. `max_live` caps the boxes alive at once across the
//! process. The idle TTL and the cap are read when the first box is needed, so
//! changing them takes effect on the next core start; the image and limits
//! apply to every box created after a change.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

/// The image a box starts from when none is configured: the OpenShell
/// community base sandbox, which carries the `/sandbox` workspace, `sh` and
/// `timeout` the backend relies on.
pub const DEFAULT_OPENSHELL_IMAGE: &str =
"ghcr.io/nvidia/openshell-community/sandboxes/base:latest";

const MEBIBYTE: u64 = 1024 * 1024;

/// `[runtime.openshell]`: what each OpenShell box is created with, and how
/// many may live at once.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct OpenShellRuntimeConfig {
/// OCI image reference every new box starts from.
pub image: String,
/// CPU allowance per box, in thousandths of a core.
pub cpu_millis: u32,
/// Memory per box, in mebibytes. OpenShell only accepts whole mebibytes,
/// which is why the setting is not in bytes.
pub memory_mb: u64,
/// Seconds a box may sit idle before it is closed.
pub idle_ttl_secs: u64,
/// The most boxes alive at once in this process.
pub max_live: usize,
}

impl OpenShellRuntimeConfig {
/// [`Self::memory_mb`] in bytes, always a whole number of mebibytes, or
/// `None` when that many bytes does not fit in a `u64`.
pub fn memory_bytes(&self) -> Option<u64> {
self.memory_mb.checked_mul(MEBIBYTE)
}
}

impl Default for OpenShellRuntimeConfig {
fn default() -> Self {
Self {
image: DEFAULT_OPENSHELL_IMAGE.to_owned(),
cpu_millis: 1_000,
memory_mb: 256,
idle_ttl_secs: 900,
max_live: 50,
}
}
}

#[cfg(test)]
#[path = "runtime_openshell_tests.rs"]
mod tests;
76 changes: 76 additions & 0 deletions crates/openhuman-core/src/config/schema/runtime_openshell_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
use super::*;

#[test]
fn defaults_give_one_core_256_mib_and_a_fifteen_minute_idle_ttl() {
let config = OpenShellRuntimeConfig::default();
assert_eq!(config.image, DEFAULT_OPENSHELL_IMAGE);
assert_eq!(config.cpu_millis, 1_000);
assert_eq!(config.memory_mb, 256);
assert_eq!(config.idle_ttl_secs, 900);
assert_eq!(config.max_live, 50);
}

#[test]
fn an_empty_table_keeps_every_default() {
let config: OpenShellRuntimeConfig = toml::from_str("").unwrap();
assert_eq!(config, OpenShellRuntimeConfig::default());
}

#[test]
fn the_serde_form_pins_its_field_names() {
let config = OpenShellRuntimeConfig {
image: "registry.example/agent:1".into(),
cpu_millis: 500,
memory_mb: 128,
idle_ttl_secs: 60,
max_live: 3,
};
let value = serde_json::to_value(&config).unwrap();
assert_eq!(
value,
serde_json::json!({
"image": "registry.example/agent:1",
"cpu_millis": 500,
"memory_mb": 128,
"idle_ttl_secs": 60,
"max_live": 3,
})
);
let back: OpenShellRuntimeConfig = serde_json::from_value(value).unwrap();
assert_eq!(back, config);
}

#[test]
fn memory_converts_to_whole_mebibytes() {
let config = OpenShellRuntimeConfig::default();
assert_eq!(config.memory_bytes(), Some(256 * 1024 * 1024));
assert_eq!(config.memory_bytes().unwrap() % (1024 * 1024), 0);
}

#[test]
fn memory_that_overflows_bytes_has_no_byte_count() {
let config = OpenShellRuntimeConfig {
memory_mb: u64::MAX,
..OpenShellRuntimeConfig::default()
};
assert_eq!(config.memory_bytes(), None);
}

#[test]
fn the_runtime_table_reads_its_openshell_section() {
let runtime: super::super::RuntimeConfig = toml::from_str(
r#"
[openshell]
image = "registry.example/agent:2"
max_live = 7
"#,
)
.unwrap();
assert_eq!(runtime.openshell.image, "registry.example/agent:2");
assert_eq!(runtime.openshell.max_live, 7);
assert_eq!(runtime.openshell.idle_ttl_secs, 900);
assert_eq!(
super::super::RuntimeConfig::default().openshell,
OpenShellRuntimeConfig::default()
);
}
4 changes: 4 additions & 0 deletions crates/openhuman-core/src/config/schema/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub enum SandboxBackend {
Firejail,
Bubblewrap,
Docker,
/// One long-lived box per tenant on an NVIDIA OpenShell gateway, through
/// the TinyBox module (`[runtime.openshell]`).
#[serde(rename = "openshell")]
OpenShell,
None,
}

Expand Down
10 changes: 10 additions & 0 deletions crates/openhuman-core/src/config/schema/security_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ fn security_config_defaults() {
assert_eq!(sec.audit.max_size_mb, 100);
}

#[test]
fn the_openshell_backend_is_named_openshell_on_the_wire() {
assert_eq!(
serde_json::to_value(SandboxBackend::OpenShell).unwrap(),
serde_json::json!("openshell")
);
let config: SandboxConfig = toml::from_str("backend = \"openshell\"").unwrap();
assert!(matches!(config.backend, SandboxBackend::OpenShell));
}

#[test]
fn sandbox_config_default() {
let sb = SandboxConfig::default();
Expand Down
5 changes: 5 additions & 0 deletions crates/openhuman-core/src/doctor/checks/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ impl SandboxBackendCheck {
"Review the sandbox runtime and rerun doctor.",
),
},
SandboxBackend::OpenShell => Finding::skipped(
"sandbox/backend",
"The OpenShell backend is configured; its gateway is reached when a tenant's first box is created.",
"Run a sandboxed command to confirm the OpenShell gateway accepts new boxes.",
),
SandboxBackend::Firejail | SandboxBackend::Bubblewrap => Finding::error(
"sandbox/backend",
"The configured sandbox backend is not supported by this build.",
Expand Down
Loading
Loading