11# Compute Runtimes
22
33Compute 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.
3034At 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.
3240Process-identity omissions are preserved across this boundary so every driver
3341can apply its native image or runtime defaults. Driver-requested listeners are
3442structurally 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```
5360backend_phase = derive_phase(driver_status)
5461
5562public_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
6472backend resource is healthy and a supervisor session is registered. A sandbox whose
6573backend 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
6876whose 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
7281established 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,
8594deployments that require reliable readiness composition must run a single gateway
8695replica.
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
93104The capability RPC reports driver identity, version, and the default sandbox
94105image used by the gateway. GPU availability stays driver-local and is validated
0 commit comments