Repository navigation
Description
Part of #5200.
User Story
As an OpenShell Maintainer I want the desktop drivers to exist in their own repository so that their ownership and maintenance can be considered separately to core OpenShell. That requires the gateway to run them as separate processes it launches.
Problem Statement
The gateway compiles Docker and Podman in-process behind the default in-tree-compute-drivers feature and registers them through in-process factories. The VM driver is already a gateway-launched subprocess, but through VM-specific code in crates/openshell-gateway/src/vm.rs. There is no generic way to launch and configure an external driver, and operator-managed external drivers cannot use features such as additional CA trust.
Impact / Why This Matters
Core cannot build or release without the Docker and Podman crates, and the desktop drivers cannot move. See #5200.
Proposed Design
The gateway discovers a driver binary, writes a versioned startup document, launches the process with --config <path>, and talks to it over the existing ComputeDriver gRPC contract on a Unix socket. Driver names, auto-detect order, and driver_config tables are unchanged. The driver validates its own config.
Sub-issues:
- feat: pass launched drivers a versioned startup document #5385 Startup document
- feat: launch external compute drivers from a generic launcher #5386 Launcher
- feat: add probe, preflight, capability fields, and driver selection for launched drivers #5387
probe,preflight, capability fields, and driver selection - refactor: launch the VM driver through the generic launcher #5388 Migrate the VM driver to the launcher
Acceptance Criteria
- The VM driver passes its existing e2e, including
vm-additional-ca-e2e, with no VM-specific gateway code. - All sub-issues are complete.
Alternatives Considered
- A gateway binary built by
desktopthat links core's server crates and registers drivers in-process. Avoids a launcher, but makes the Rust factory trait a public API and produces two gateway binaries. - Keep drivers linked and delegate ownership with CODEOWNERS. Least work, but everyone still shares one repository and release machinery.
Agent Investigation
- The gateway can reach a driver three ways today: linked in-process (Docker, Podman, Kubernetes), a gateway-managed subprocess (VM,
ManagedDriverProcess), and an operator-managed external driver.
Activity
[-]feat: run compute drivers as launched external processes[/-][+]feat: run compute drivers as launched child processes[/+]elezar commentedon Nov 20, 2026
Recording consequences of moving Podman to the launcher (work on #5385).
The gateway no longer links
openshell-driver-podman. Auto-detection runsopenshell-driver-podman probeinstead of the in-processis_available, and the Podman driver runs only as a launched process. The gateway still has thecompute-driver-podmanfeature, which now gates the launcher path and not the driver crate. Because Podman is no longer in the gateway process, I also dropped its in-process tracing registration (with_in_process_tracing), as VM already does. The launched driver sets up its own tracing from the telemetry settings in the startup document.probetakes no startup document. It reports{"available": bool, "reason"?: string}and reads only the process environment, which is allis_availableread. This differs from the #5387 design, which hasprobetake the document. We can add the document later if a driver needs config to decide availability.Consequences until
preflightexists (adding Podman to the VM note on #5387):validate_configis removed from the Podman factory, andsupports_config_preflightreturnsfalse, soopenshell-gateway config preflightrejects a configuration that selects Podman. Packaged installs run it asExecStartPre.openshell-driver-podmanbinary beside the gateway or in a libexec path. Packaging does not ship it yet.crates/openshell-gateway/tests/config_preflight.rsare ignored untilpreflightreturns that check.drew commentedon Nov 23, 2026
Answers on the open questions from the launch contract proposal:
Drop
guest_tls_caandgateway_portfromDriverSettings; the gateway supplies both throughConfigure'sGatewayContext. (mainalready rejectsguest_tls_cain[openshell.drivers.*]and overwritesgateway_port.) Keepgrpc_endpointas an optional override inDriverSettingsfor custom network/NAT setups, defaulting fromGatewayContextwhen unset.preflightchecks URL syntax and scheme;Configurechecks thathttps://has a CA path. Standalone operator-run drivers keep their existing CLI flags.The gateway should own and enforce admission policy. Remove
allow_driver_configandresource_admissionfromDriverSettingsso[openshell.drivers.<name>]stays opaque to the gateway. The gateway enforcesallow_driver_configdirectly at the API boundary; moving backend-native label evaluation forresource_admissionfully into the gateway requires extendingComputeDriverto report resolved resource metadata/labels (track as a follow-up if#5384keepsComputeDriverunchanged, passing the gateway's policy inConfigurein the meantime).Keep
EX_UNAVAILABLE(69) andEX_CONFIG(78) exit codes, and write the single JSON reason line to stdout instead of stderr. Keep stderr for tracing, panics, and native library output so logs never collide with the startup result parser. This works the same way for bothserveandpreflightwithout spinning up a socket for unavailable drivers.Put
driver_dirunder[openshell.gateway]instead of adding[openshell.compute.<name>]. The gateway ownsdriver_dir(and gateway-owned admission settings); any legacy driver-table location such as[openshell.drivers.vm].driver_diris deprecated and stripped with a warning during transition.Original draft proposal (@elezar)
Summary
The gateway launches the Docker, Podman and VM compute drivers as separate processes, all through one contract. That contract has three parts, separated by owner:
[openshell.drivers.<name>]table, written to the process's stdin when it starts.ConfigureRPC once the driver reports it is available.servevalidates its table and checks its backend before binding its socket, so starting it is also how the gateway detects whether a driver is usable. Apreflightcommand runs the same table check without contacting the backend.The outcome is a gateway that can launch drivers it doesn't link, built and released from another repository, without changing the
ComputeDriverAPI, driver names, the detection order or operator config files.Motivation
The desktop drivers are moving to
ai-openshell/desktopso they can be developed and released independently of core (#5200). The gateway still has to launch and talk to them the same way. Onmainthe three drivers run in two different ways:vm.rsbuilds about 30 of them, plus the OTLP flags fromappend_otlp_args.is_available()in priority order. It ignores the operator's table, so a configuredsocket_pathdoesn't count.config preflightvalidates the Podman and Docker tables inside the gateway, because the gateway links those drivers.None of this works once the drivers live in another repo:
Driver-owned and gateway-owned settings are also mixed today. Driver config structs carry
#[serde(skip)]runtime fields and keys the gateway fills in, which blurs who owns which schema.Why implement the launcher before migrating
The launcher is the interface between the two repos. The bootstrap, the stdin table, the start-up result,
Configureandpreflightare what core and the desktop repo agree on. Settling them while both sides are in one repo means each change is one PR series, tested together.Changing it after the split is expensive. A contract change would then take:
Until all three are done, the gateway must support both behaviours, which needs version negotiation.
Podman and Docker have to stop running in-process anyway. Doing that in core first means the migration only moves code, CI and packaging, with no behaviour change at the same time.
It's off the critical path. What blocks the move is the drivers' remaining Rust dependencies on core (#5405, #5488). The launcher can be built in parallel with that work and land first.
Non-goals
ComputeDrivergRPC API or driver names.settings_from_tableand accept gateway metadata throughConfigureinstead of flags, but they first needConfiguresupport.Design questions
1. How does the gateway detect which driver to use?
By starting the driver. The gateway launches each candidate's
servein priority order, with that candidate's table on stdin. Before binding its socket, the driver:socket_path.EX_UNAVAILABLE(69)EX_CONFIG(78)The first available candidate is the one that serves, so detection never starts a process that it then has to stop. If no candidate is available, the startup error lists every candidate's reason.
Why not a separate detection command? The alternative is a short-lived command the gateway runs only to ask whether a driver's backend is usable:
serve, adding its own result format and its own copy of the backend check.2. How is the driver configured at launch?
By splitting the inputs by owner instead of using flags or one combined document:
argv, frozen per protocol version[openshell.drivers.<name>]stdin, raw TOML forwarded unparsed by the gatewayConfigureRPC (protobuf)The operator still writes one gateway config file. The gateway removes any gateway-owned keys from the driver table (see Config split) and forwards the rest without parsing it.
Why this split:
Configure, which carries a protocol version and a feature list, so it can evolve across repos.argvand out of the environment. For example, OTLP trace headers travel only inConfigure, over the private socket.3. How is driver config validated?
The driver validates its own table, with one function used by every entry point. Each driver implements:
The function rejects unknown keys, runs every check that needs neither the backend nor the gateway context, and has no side effects.
preflight(stdin)settings_from_table-> exit 0 orEX_CONFIGserve(stdin)settings_from_table-> backend check -> bind ->ConfigureWhat this means in practice:
config preflightruns each candidate driver'spreflightand rejects any invalid table, as onmain.preflightnever contacts the backend.Proposal
Launch sequence
sequenceDiagram participant G as Gateway participant FS as Gateway state dir participant D as Driver process participant B as Backend (Docker/Podman/libkrun) Note over G,D: config preflight (no backend contact) G->>D: spawn `preflight`, driver table on stdin D->>D: settings_from_table D-->>G: exit 0, or EX_CONFIG + reason Note over G,D: Detection and launch (candidates in priority order) G->>G: resolve binary, check trust G->>D: spawn `serve --bind-socket --expected-peer-pid --log-level`, driver table on stdin D->>D: settings_from_table, install stderr tracing D->>B: check backend with the table (e.g. socket_path) alt backend unavailable D-->>G: EX_UNAVAILABLE + reason G->>G: next candidate (fail if named explicitly) else invalid table D-->>G: EX_CONFIG + reason G->>G: warn, next candidate (fail if named explicitly) else other error D-->>G: non-zero + reason G->>G: fail startup end D->>D: bind socket, serve DriverLaunch + ComputeDriver (UNAVAILABLE) G->>D: GetLaunchInfo D-->>G: driver name, protocol versions, features G->>FS: stage network trust artifact G->>D: Configure(gateway ctx, telemetry, trust path/digest/count, image overrides) D->>D: check version + features, enable OTLP export D->>FS: verify trust artifact D->>B: build driver D-->>G: Configure OK G->>D: ComputeDriver RPCs D-->>G: exits unexpectedly G->>G: log, exit nonzeroCommands
serveandpreflightwrite exactly one JSON line to stderr, for example{"result":"unavailable","reason":"..."}, which the gateway logs. The exit code decides what the gateway does next; the line explains why.Configure.servecreates no persistent state, such as networks, volumes or state directories, untilConfiguresucceeds.DriverLaunchserviceRules:
protocol_versionor an unknown required feature withFAILED_PRECONDITION.Configuresucceeds at most once. A call that fails leaves the driver running, and the gateway may retry.ConfigureRequestcan be at most 1 MiB.Configure: every other service the driver serves returnsUNAVAILABLEuntilConfiguresucceeds. One generic wrapper does this for all of them, including Docker'sComputeDriverConfigurationUpdates.Configurecarries only the path, digest and certificate count. Drivers verify the file before each sandbox create or start, and the container drivers bind-mount it.Config split
Each driver separates the settings the operator writes from the context the gateway provides:
DriverSettingsholds only operator keys and rejects unknown ones. The#[serde(skip)]runtime fields (supervisor_otlp,supervisor_gateway_name) move toGatewayContext.GatewayContextis one struct shared by all drivers, built fromConfigure.gateway_port,grpc_endpointandguest_tls_cadefault from the gateway context. See open question 1 for whether operators can still override them in the table.ImageOverrides, which comes from the gateway's environment, takes precedence, asprefer_environmentdoes today.driver_dir.Telemetry
--log-level, plus an empty, reloadable OTLP export layer.Configure: the driver fills that layer fromTelemetryandGatewayContext.gateway_name, before it builds the driver. A retriedConfiguredoesn't install a second exporter.In-process and operator-run drivers
--config <file>and their existing flags. The gateway keeps connecting to them through a socket endpoint. This proposal doesn't change them; aligning them with the launch contract is a follow-up (see Non-goals).Security
driver_diror the packagedlibexecdirectory. It refuses a file that isn't owned by root or the gateway user, or that is writable by group or others.0700. VM also checks that the peer is the expected PID; the other drivers check that the caller runs as the same user until shared PID enforcement lands.argvor into the environment. The driver table goes on stdin and gateway secrets go inConfigure.Implementation plan
All of this lands in core before the drivers move. Each step builds and passes tests on its own.
openshell-otel: install stderr tracing first and enable OTLP export later.DriverLaunchprotocol and theopenshell-driver-launchcrate: the proto, aConfigurestate machine, theUNAVAILABLEwrapper and the size limit. The crate has no core dependencies.Telemetryinto OTLP settings;settings_from_table,serveandpreflight. Then the gateway's generic launcher replaces VM's flag building.serve, and the gateway stops linking the Podman crate.ComputeDriverConfigurationUpdates.ai-openshell/desktoponce refactor(driver-sdk): carve out the driver SDK and container-runtime crate #5405 and refactor(driver-contract): move the driver contract types into a contract crate #5488 remove their core dependencies. Core packaging then takes the driver binaries from desktop releases.Validation: each driver gets integration tests against its real binary:
GetLaunchInfoanswers beforeConfigure;UNAVAILABLEbeforeConfigure;Configurerejects unsupported versions and can be retried;preflightaccepts valid tables, rejects invalid ones and creates no state.Gateway tests use fake driver binaries to cover:
Risks
socket_pathcan select a different driver thanmainwould. An invalid table on an earlier candidate now logs a warning where it was silently ignored before. Mitigation:config preflightstill rejects invalid tables, and the startup log names the selected driver and why the others were skipped.Configure, onlyDriverLaunchanswers. A bug in the wrapper could expose a half-built driver. Mitigation: one shared wrapper with tests, not per-driver code.Configure, including the backend check, reach stderr but not OTLP.Configureuntil shared PID enforcement. For Podman and Docker, any process running as the gateway's user could callConfigurefirst. Mitigation: the socket is private (mode0700), and shared PID enforcement is a planned follow-up.Alternatives
Command-line flags for every setting (extend VM's current approach)
This needs no new protocol. But each driver key needs a matching flag, the gateway has to turn each table back into flags, secrets end up on
argv, and every new setting changes the command line. It doesn't scale to three drivers maintained in another repo.Startup document (#5838)
The gateway writes a versioned TOML document holding both the gateway metadata and the driver table, and passes its path to the driver. The driver starts fully configured, so it has no unconfigured window and doesn't need deferred tracing. The costs:
probe), which ignores the table.Configurecarrying the driver table, with a separate detection commandThe gateway sends everything, including the driver table as an opaque field, in
Configure. A separateprobecommand does detection without config. This has the clean versioned contract, but:Keep Podman and Docker in-process
This needs no packaging or launcher work now, but it can't survive the migration: the gateway in core can't link crates from a repo that depends on core. Keeping both in-process and launched modes would also double testing, and keep two ways of building driver config.
Prior art
SetConfigRPC.GetLaunchInfoandConfigurefollow the same pattern.sysexits.h.EX_UNAVAILABLE(69) andEX_CONFIG(78) are the conventional exit codes for "service unavailable" and "configuration error".main. It already runs as a subprocess with a private socket and checks the peer PID. This proposal generalises that model and replaces its command-line flags.Open questions
gateway_port,grpc_endpoint,guest_tls_ca): should they stay valid in driver tables as optional operator overrides, or be removed? Proposed answer: keep them as overrides, so existing files keep working.allow_driver_config,resource_admission): should the gateway or the driver enforce it? Proposed answer: no change. It stays in the driver table, the driver enforces it, and the server keeps reading it.driver_dirmove to a gateway-owned table such as[openshell.compute.<name>], with the old location deprecated?