Skip to content

Commit 041f9de

Browse files
committed
refactor(compute): remove MXC policy side channel
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 3e96466 commit 041f9de

21 files changed

Lines changed: 329 additions & 194 deletions

File tree

‎architecture/README.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,12 @@ bridge networks, port mappings, NAT traversal, or bespoke tunnels. The common
141141
runtime requirement is narrower: the supervisor must be able to reach the
142142
gateway.
143143

144-
The Windows MXC driver is an explicit exception. It launches and monitors a
145-
one-shot workload in the driver, self-reports readiness, and does not expose a
146-
supervisor session, interactive connect, live policy delivery, or governed egress.
144+
The compute-driver capability contract identifies whether the supervisor or the
145+
driver owns runtime control. Supervisor-controlled drivers use the session model
146+
above. A driver-controlled runtime receives the canonical policy in its validate
147+
and create requests, applies it before launch, and self-reports readiness without
148+
a supervisor session. The Windows MXC driver uses this mode and does not expose
149+
interactive connect, live policy delivery, or governed egress.
147150

148151
The gateway delivers desired state; the sandbox applies it locally. Policy,
149152
settings, credentials, and inference routes flow from the gateway to the

‎architecture/compute-runtimes.md‎

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
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. Supervisor-controlled runtimes start a workload that runs the
5+
`openshell-sandbox` supervisor, which enforces the sandbox contract locally.
6+
Driver-controlled runtimes apply the canonical sandbox policy while
7+
provisioning and report workload readiness directly.
78

89
## Driver Contract
910

10-
Each runtime receives a sandbox spec from the gateway and is responsible for:
11+
Each runtime receives a sandbox spec and canonical policy from the gateway and
12+
is responsible for:
1113

1214
- Selecting the sandbox image.
13-
- Injecting sandbox identity and gateway callback configuration.
14-
- Supplying TLS or secret material for supervisor callbacks.
15-
- Providing the supervisor binary or image in the workload.
15+
- For supervisor-controlled runtimes, injecting sandbox identity and gateway
16+
callback configuration, supplying callback credentials, and providing the
17+
supervisor binary or image.
18+
- For driver-controlled runtimes, validating and applying the canonical policy
19+
before launching the workload.
1620
- Forwarding the exact canonical main-process argv and TTY mode without shell
1721
reconstruction. The sandbox-level environment and policy workspace apply to
1822
the main process.
1923
- Reporting lifecycle and platform events back to the gateway.
2024
- Cleaning up runtime-owned resources.
2125

22-
Drivers report **backend state only**. A driver snapshot with `Ready=True` means
23-
the underlying compute resource (container, pod, VM) is healthy and running —
24-
nothing more. Drivers must not gate on supervisor session state or hold
25-
references to gateway-internal types. The gateway owns the public
26-
`SandboxPhase::Ready` decision. This applies equally to extension drivers
27-
implementing `ComputeDriver` out of tree.
26+
Drivers report **runtime-observed state only** and must not hold references to
27+
gateway-internal types. For supervisor-controlled runtimes, `Ready=True` means
28+
only that the compute resource is healthy; the gateway also requires a
29+
supervisor session before publishing `SandboxPhase::Ready`. For
30+
driver-controlled runtimes, `Ready=True` is authoritative because the driver
31+
launches and monitors the policy-constrained workload itself.
2832

2933
`compute_driver.proto` is the supported gateway/driver extension boundary.
3034
At initialization the gateway snapshots the driver's identity, version,
31-
default image, and gateway-lifecycle preference from `GetCapabilities`.
35+
default image, gateway-lifecycle preference, and `sandbox_runtime_control` from
36+
`GetCapabilities`. An omitted or unknown runtime-control value is treated as
37+
`SUPERVISOR` for compatibility. The gateway includes the canonical
38+
`SandboxPolicy` in both `ValidateSandboxCreate` and `CreateSandbox`; drivers
39+
that advertise `DRIVER` must validate and apply it before launch.
3240
Process-identity omissions are preserved across this boundary so every driver
3341
can apply its native image or runtime defaults. Driver-requested listeners are
3442
structurally validated and remain restricted to sandbox callback RPCs.
@@ -45,28 +53,29 @@ reason strings.
4553

4654
## Sandbox Readiness Composition
4755

48-
The gateway composes driver backend state with supervisor session presence to
49-
produce the public `SandboxPhase`. This composition is gateway-owned and applied
50-
uniformly across all drivers:
56+
The gateway composes driver state with the advertised runtime-control mode to
57+
produce the public `SandboxPhase`:
5158

5259
```
5360
backend_phase = derive_phase(driver_status)
5461
5562
public_phase =
5663
if backend_phase in {Error, Deleting}: → pass through (terminal precedence)
64+
if runtime_control == Driver && backend_phase == Ready: → Ready
5765
if backend_phase == Ready && session connected: → Ready
5866
if backend_phase == Ready && no session: → Provisioning
5967
if backend_phase in {Provisioning, Unknown} && session: → Ready
6068
if backend_phase in {Provisioning, Unknown} && no session: → Provisioning
6169
```
6270

63-
When `public_phase == Ready` the sandbox is usable through the gateway — both the
71+
For a supervisor-controlled runtime, `public_phase == Ready` means both the
6472
backend resource is healthy and a supervisor session is registered. A sandbox whose
6573
backend reports ready but has no supervisor session yet holds `Provisioning` with a
6674
`Ready=False`, `SupervisorNotConnected` condition and the message
6775
`Backend ready; waiting for supervisor session`. This distinguishes it from a sandbox
6876
whose compute resource is still provisioning without exposing contradictory public
69-
readiness signals.
77+
readiness signals. For a driver-controlled runtime, the driver's ready condition
78+
is published without waiting for a supervisor session.
7079

7180
**Session precedence over lagging driver snapshots:** A supervisor session can only be
7281
established by a running workload. When `set_supervisor_session_state` promotes the
@@ -85,10 +94,12 @@ session-owning replica. That work is deferred to GitHub issue #1868. Until then,
8594
deployments that require reliable readiness composition must run a single gateway
8695
replica.
8796

88-
**Extension point:** The readiness decision is a safety invariant, not an
89-
operator-configurable hook. The driver contract is the correct extension point for
90-
custom backend readiness semantics. RFC-0010 lifecycle hooks may observe readiness
91-
transitions via `post_commit`; they do not override the composition rule.
97+
**Extension point:** Runtime control is a driver capability, not an
98+
operator-configurable hook. A driver may advertise `DRIVER` only when it applies
99+
the canonical create-time policy and owns workload readiness. Driver-controlled
100+
runtimes do not support live policy mutation; recreate the sandbox to apply a
101+
new policy. RFC-0010 lifecycle hooks may observe readiness transitions via
102+
`post_commit`; they do not override the composition rule.
92103

93104
The capability RPC reports driver identity, version, and the default sandbox
94105
image used by the gateway. GPU availability stays driver-local and is validated

‎architecture/windows-msvc-build.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ driver. It does not make Windows a Docker, Kubernetes, Podman, or VM runtime hos
1010
- Keep the Linux and macOS build paths unchanged.
1111
- Preserve gateway configuration parsing for all existing compute driver names.
1212
- Build and test the in-process MXC driver on supported Windows hosts.
13+
- Use the ordinary in-process compute-driver composition path; MXC receives the
14+
canonical sandbox policy through validate/create RPC messages and advertises
15+
driver-owned runtime control for readiness.
1316
- Return clear unsupported errors when a Windows gateway is configured to use Docker, Kubernetes, Podman, or VM.
1417
- Keep dedicated `windows:*` validation tasks while allowing the repository-wide
1518
`pre-commit` task to delegate compiler-bearing Rust checks to the native

‎crates/openshell-driver-docker/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,8 @@ impl DockerComputeDriver {
667667
default_image: self.config.default_image.clone(),
668668
gateway_manages_lifecycle: true,
669669
supports_sandbox_authentication: false,
670+
sandbox_runtime_control:
671+
openshell_core::proto::compute::v1::SandboxRuntimeControl::Supervisor.into(),
670672
}
671673
}
672674

‎crates/openshell-driver-docker/src/tests.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,10 @@ async fn tracing_in_process_service_preserves_the_driver_rpc_server_boundary() {
222222
);
223223
ComputeDriver::validate_sandbox_create(
224224
&service,
225-
Request::new(ValidateSandboxCreateRequest { sandbox: None }),
225+
Request::new(ValidateSandboxCreateRequest {
226+
sandbox: None,
227+
policy: None,
228+
}),
226229
)
227230
.instrument(gateway_span)
228231
.await
@@ -306,7 +309,10 @@ async fn tracing_lifecycle_rpc_failures_export_docker_operation_spans() {
306309
async {
307310
ComputeDriver::create_sandbox(
308311
&driver,
309-
Request::new(CreateSandboxRequest { sandbox: None }),
312+
Request::new(CreateSandboxRequest {
313+
sandbox: None,
314+
policy: None,
315+
}),
310316
)
311317
.await
312318
.expect_err("missing sandbox should fail");

‎crates/openshell-driver-kubernetes/src/driver.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ impl KubernetesComputeDriver {
575575
default_image: self.config.default_image.clone(),
576576
gateway_manages_lifecycle: false,
577577
supports_sandbox_authentication: true,
578+
sandbox_runtime_control:
579+
openshell_core::proto::compute::v1::SandboxRuntimeControl::Supervisor.into(),
578580
})
579581
}
580582

‎crates/openshell-driver-kubernetes/src/grpc.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,10 @@ mod tests {
438438

439439
ComputeDriver::validate_sandbox_create(
440440
&service,
441-
Request::new(ValidateSandboxCreateRequest { sandbox: None }),
441+
Request::new(ValidateSandboxCreateRequest {
442+
sandbox: None,
443+
policy: None,
444+
}),
442445
)
443446
.await
444447
}

‎crates/openshell-driver-mxc/README.md‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ OpenShell compute driver backed by **Microsoft MXC** (`wxc-exec`) on Windows.
44

55
## Design
66

7-
This driver implements the gateway's `ComputeDriver` contract as an in-process
8-
library linked into `openshell-gateway`. `process_container` launches a one-shot
7+
This driver implements the gateway's ordinary in-process `ComputeDriver`
8+
contract and is linked into `openshell-gateway`. It advertises driver-owned
9+
runtime control, so the gateway passes the canonical `SandboxPolicy` in both
10+
`ValidateSandboxCreate` and `CreateSandbox` and accepts driver-reported
11+
readiness without a supervisor session. `process_container` launches a one-shot
912
AppContainer and is the default. The opt-in `isolation_session` backend uses the
1013
state-aware `provision` → `start` → `exec` → `stop` → `deprovision` lifecycle.
1114
The driver launches and monitors the configured workload itself and self-reports
@@ -64,7 +67,11 @@ no isolation session needed), set `OPENSHELL_MXC_MOCK_WXC=1`.
6467

6568
## Policy mapping
6669

67-
The production driver maps the typed `SandboxPolicy` to MXC configuration before it inserts a registry entry or invokes `wxc-exec`. Mapping failure therefore returns from `CreateSandbox` without leaving a partial sandbox.
70+
The production driver maps the typed `SandboxPolicy` carried by the standard
71+
driver request to MXC configuration before it inserts a registry entry or
72+
invokes `wxc-exec`. Mapping failure therefore returns from `CreateSandbox`
73+
without leaving a partial sandbox. There is no in-process policy side channel
74+
or MXC-specific gateway composition variant.
6875

6976
`EmbeddedPolicyMapper` calls the embedded [`policy_map`](src/policy_map/) module directly and normalizes filesystem paths to Windows form. It does not add gateway-configured host paths. The policy supplied for the sandbox is the only source of filesystem grants.
7077

0 commit comments

Comments
 (0)