Skip to content

Commit db42b60

Browse files
committed
feat(sandbox): add control and boundary supervisor modes
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent efba1d8 commit db42b60

32 files changed

Lines changed: 6423 additions & 1432 deletions

File tree

‎Cargo.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎architecture/compute-runtimes.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Compute Runtimes
22

33
Compute runtimes create, stop, start, delete, and watch sandbox workloads for the
4-
gateway. They do not replace sandbox policy enforcement. Every runtime starts a
5-
workload that runs the `openshell-sandbox` supervisor, and the supervisor
6-
enforces the sandbox contract locally.
4+
gateway. They do not replace sandbox policy enforcement. A runtime either starts
5+
the co-located `openshell-sandbox` supervisor or provisions its RFC 0012
6+
`--mode=control` and `--mode=boundary` placements.
77

88
## Driver Contract
99

@@ -13,6 +13,11 @@ Each runtime receives a sandbox spec from the gateway and is responsible for:
1313
- Injecting sandbox identity and gateway callback configuration.
1414
- Supplying TLS or secret material for supervisor callbacks.
1515
- Providing the supervisor binary or image in the workload.
16+
- Provisioning protected control and boundary configs plus a private Unix socket,
17+
authenticated TCP, or vsock transport when the supervisor is separated. Runtime-specific code
18+
supplies immutable resource claims and transport coordinates; the shared
19+
boundary protocol supplies lifecycle, exec, signaling, forwarding, and binary
20+
identity semantics.
1621
- Forwarding the exact canonical main-process argv and TTY mode without shell
1722
reconstruction. The sandbox-level environment and policy workspace apply to
1823
the main process.

‎architecture/sandbox.md‎

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Sandbox
22

3-
A sandbox is the runtime boundary where agent code executes. It is created by a
4-
compute runtime and managed inside the workload by `openshell-sandbox`, the
5-
sandbox supervisor.
3+
A sandbox is the runtime boundary where agent code executes. A compute runtime
4+
creates it, and `openshell-sandbox` operates it as one logical supervisor.
65

76
## Runtime Model
87

@@ -21,18 +20,38 @@ container-granted capabilities. This is fail-closed: the supervisor retains
2120
aborts unless the bounding set ends up empty. A `setpcap` `EPERM` is tolerated
2221
only when the set is already empty; any other outcome fails the spawn.
2322

23+
Separated runtimes split the same logical supervisor into two placements:
24+
25+
| Mode | Placement and authority |
26+
|---|---|
27+
| `openshell-sandbox --mode=control` | Runs outside the workload boundary. Owns gateway credentials, the admitted policy, RFC 0012 lifecycle, network-policy decisions, SSH, and gateway relays. |
28+
| `openshell-sandbox --mode=boundary --boundary-config <path>` | Runs inside or adjacent to the workload. Owns process launch and observation, exec signaling, PTY control, loopback forwarding, egress capture, and binary identity. It has no gateway credentials or independent policy authority. |
29+
30+
The compute driver provisions the two protected configurations and their private
31+
Unix-socket, authenticated TCP, or vsock transport. All configurations carry the
32+
same boundary ID, bootstrap credential, protocol version, and immutable driver resource claims.
33+
The shared remote backend authenticates each request and rejects a resource-claim
34+
mismatch. Driver crates do not appear in generic supervisor lifecycle, network,
35+
SSH, or session code.
36+
37+
For cross-UID Unix-socket placements, the driver-owned parent directory limits
38+
socket reachability and the bootstrap credential authenticates every request.
39+
Boundary mode can re-own a bind-mounted config as root-only before starting the
40+
workload when its host ownership could otherwise coincide with the workload UID.
41+
2442
## Startup Flow
2543

2644
1. The compute runtime starts the workload with sandbox identity, callback
2745
endpoint, TLS or secret material, image metadata, and initial command.
28-
2. The supervisor loads policy and runtime settings from local files or the
46+
2. Control mode loads policy and runtime settings from local files or the
2947
gateway, depending on mode.
30-
3. It prepares filesystem access, process restrictions, network namespace
31-
routing, trust stores, provider credential resolution, and inference routes.
32-
4. It launches the persisted canonical main-process argv and retains its PTY
33-
or pipes in the main-session multiplexer.
34-
5. It starts the policy proxy and local SSH server.
35-
6. It opens a supervisor session back to the gateway for connect, exec, file
48+
3. The isolation backend attaches and confirms standing enforcement. Boundary
49+
mode prepares boundary-local filesystem, process, and egress controls.
50+
4. Control mode starts the admitted main process through the backend. Boundary
51+
mode applies launch-time controls before its first untrusted instruction.
52+
5. Control mode starts the policy proxy and local SSH server. Exec and loopback
53+
streams cross the shared boundary protocol when the modes are separated.
54+
6. Control mode opens a supervisor session back to the gateway for connect, exec, file
3655
sync, config polling, and log push.
3756

3857
## Isolation Layers

‎crates/openshell-core/src/sandbox_env.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ pub const TELEMETRY_ENABLED: &str = "OPENSHELL_TELEMETRY_ENABLED";
122122
/// `"sidecar"`; the default combined supervisor path omits it.
123123
pub const SUPERVISOR_TOPOLOGY: &str = "OPENSHELL_SUPERVISOR_TOPOLOGY";
124124

125+
/// The isolation backend admitted by the deployment configuration (RFC 0012).
126+
///
127+
/// Delivered on a channel separate from the topology descriptor so descriptor
128+
/// verification against the admitted backend is not self-referential. Required
129+
/// whenever a topology descriptor is supplied.
130+
pub const ADMITTED_ISOLATION_BACKEND: &str = "OPENSHELL_ADMITTED_ISOLATION_BACKEND";
131+
125132
/// Network enforcement backend selected by the compute driver.
126133
pub const NETWORK_ENFORCEMENT_MODE: &str = "OPENSHELL_NETWORK_ENFORCEMENT_MODE";
127134

‎crates/openshell-isolation-interface/Cargo.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ repository.workspace = true
1313
[dependencies]
1414
openshell-core = { path = "../openshell-core", default-features = false }
1515
async-trait = "0.1"
16+
serde = { workspace = true }
17+
serde_json = { workspace = true }
18+
thiserror = { workspace = true }
1619
tokio = { workspace = true }
1720

21+
[target.'cfg(unix)'.dependencies]
22+
libc = "0.2"
23+
1824
[dev-dependencies]
1925
tokio = { workspace = true }
2026

0 commit comments

Comments
 (0)