Skip to content

feat(drivers): launch contract for gateway-managed compute drivers #5901

Duplicate

Description

@drew

User Story

The gateway needs to launch the Docker, Podman, and VM compute drivers as separate processes through one contract so the desktop drivers can move to ai-openshell/desktop (#5200) without the gateway linking driver crates or translating driver config tables into CLI flags.

Description

Replace VM's flag-based subprocess launch and Docker/Podman's in-process loading with a single launch contract split by owner:

  • Bootstrap (argv, gateway-owned): fixed CLI interface for all managed drivers:
    • openshell-driver-<name> serve --bind-socket <path> --expected-peer-pid <pid> --log-level <level>
    • openshell-driver-<name> preflight
  • Driver table (stdin, driver-owned): raw [openshell.drivers.<name>] TOML forwarded unparsed by the gateway (after stripping gateway-owned keys like driver_dir). Empty stdin uses driver defaults. Both serve and preflight validate the table through one side-effect-free settings_from_table function that rejects unknown keys.
  • Gateway metadata (DriverLaunch gRPC service, gateway-owned): openshell.driver.launch.v1.DriverLaunch with GetLaunchInfo (driver name/version, supported protocol versions, features) and Configure (max 1 MiB, succeeds at most once, retryable on failure). Configure carries protocol version, required features, GatewayContext (gateway_port, tls_ca_path, gateway_name), staged NetworkTrust (path, digest, cert count), ImageOverrides, and Telemetry (OTLP exports, collector TLS, secret trace headers). All other services (including Docker's ComputeDriverConfigurationUpdates) return UNAVAILABLE until Configure succeeds, and serve creates no persistent state before Configure.

Detection, preflight, and security

  • Detection: the gateway launches each candidate's serve in priority order with its stdin table. Before binding the socket, the driver validates the table and checks its backend (honoring settings like socket_path). Before exiting on failure, serve and preflight write one JSON reason line to stderr and exit with EX_UNAVAILABLE (69) for an unavailable backend, EX_CONFIG (78) for an invalid table, or another non-zero code on error. Auto-detection falls through on 69 (and warns + falls through on 78); explicit driver selection fails startup on any non-zero exit.
  • Preflight: openshell-gateway config preflight runs each candidate's preflight subcommand without contacting the backend.
  • Telemetry: serve starts with stderr tracing at --log-level and an empty reloadable OTLP layer, then attaches OTLP export during Configure.
  • Security: resolve binaries from driver_dir or packaged libexec (owned by root or gateway user, not group/world-writable), bind sockets under a 0700 directory, and keep secrets off argv and env.

Scope

Related: #5200, #5384, #5385, #5838 (based on @elezar's draft proposal).

Definition of Done

  • Support deferred OTLP export in openshell-otel (stderr tracing at startup, OTLP layer enabled on Configure).
  • Add openshell.driver.launch.v1.DriverLaunch (GetLaunchInfo, Configure) and a core-free openshell-driver-launch crate with the Configure state machine, generic UNAVAILABLE wrapper, and 1 MiB request limit.
  • Add driver SDK launch helpers: stdin table reader, exit-code + stderr JSON startup result, network-trust loader, Telemetry-to-OTLP conversion, and parent-death guard.
  • Split driver config into DriverSettings (operator keys) and shared GatewayContext, migrating VM to settings_from_table, serve, preflight, and the generic gateway launcher.
  • Migrate Podman and Docker to the launch contract, stop linking them in-process (covering ComputeDriverConfigurationUpdates on Docker), and route detection and config preflight through serve/preflight.
  • Add real-binary integration tests per driver (GetLaunchInfo, pre-Configure UNAVAILABLE, Configure version checks/retry, startup exit codes, side-effect-free preflight) and fake-binary gateway tests (trust checks, exit-code mapping, detection fallback, unexpected exit).
  • Ship driver binaries in Debian, RPM, and snap packages with a CI packaging check, and update gateway config and driver extensibility docs.

Open Questions

  • Keep gateway_port, grpc_endpoint, and guest_tls_ca as optional operator overrides in driver tables? (Default: yes.)
  • Keep allow_driver_config and resource_admission in the driver table enforced by the driver? (Default: yes.)
  • Keep startup availability as exit codes + one stderr JSON line, or report over the socket instead?
  • Move gateway-owned keys like driver_dir to [openshell.compute.<name>] and deprecate the old location?

Activity

  1. added
    area:drivers
    topic:api
    topic:architecture
    topic:extensions
    on Nov 23, 2026
  2. drew commented on Nov 23, 2026

    @drew
    ContributorAuthor

    Gateway-derived keys (gateway_port, grpc_endpoint, guest_tls_ca): should they stay valid in driver tables as optional operator overrides, or be removed?

    Drop guest_tls_ca and gateway_port from DriverSettings; the gateway supplies both through Configure's GatewayContext. (main already rejects guest_tls_ca in [openshell.drivers.*] and overwrites gateway_port.) Keep grpc_endpoint as an optional override in DriverSettings for custom network/NAT setups, defaulting from GatewayContext when unset. preflight checks URL syntax and scheme; Configure checks that https:// has a CA path. Standalone operator-run drivers keep their existing CLI flags.

    Admission policy (allow_driver_config, resource_admission): should the gateway or the driver enforce it?

    The gateway should own and enforce admission policy. Remove allow_driver_config and resource_admission from DriverSettings so [openshell.drivers.<name>] stays opaque to the gateway. The gateway enforces allow_driver_config directly at the API boundary; moving backend-native label evaluation for resource_admission fully into the gateway requires extending ComputeDriver to report resolved resource metadata/labels (track as a follow-up if #5901 keeps ComputeDriver unchanged, passing the gateway's policy in Configure in the meantime).

    Start-up result format: are exit codes plus one JSON line on stderr the right protocol, or should availability be reported over the socket instead?

    Keep EX_UNAVAILABLE (69) and EX_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 both serve and preflight without spinning up a socket for unavailable drivers.

    Gateway-owned table: should keys like driver_dir move to a gateway-owned table such as [openshell.compute.<name>], with the old location deprecated?

    Put driver_dir under [openshell.gateway] instead of adding [openshell.compute.<name>]. The gateway owns driver_dir (and gateway-owned admission settings); any legacy driver-table location such as [openshell.drivers.vm].driver_dir is deprecated and stripped with a warning during transition.

  3. drew commented on Nov 23, 2026

    @drew
    ContributorAuthor

    Duplicate of #5384 — moved the launch contract plan and Q&A responses there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:driverstopic:apitopic:architecturetopic:extensions

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions