Decision records
ADR-0004: Two-level runtime contract (Handler / RuntimeAdapter)
- Status: Accepted (2026-10-05)
Context
Handoff §5: core routing must not care whether the destination is PHP, Python, Node, a container, a Unix socket or a TCP service. Language specifics must not leak into the core.
Decision
scalws_core::Handler— request-path trait, object safe, returns a boxed future. The router storesArc<dyn Handler>only.scalws_runtime::RuntimeAdapter— lifecycle factory per runtime kind: validates a spec, prepares aRuntimeInstance.scalws_runtime::RuntimeInstance— owns any processes/sockets, exposesLifecycleState,start,drain, and aHandler.- Managed runtimes talk to the server over Unix sockets (preferred) or loopback TCP. Their handler is a FastCGI (PHP) or HTTP proxy (Node, Python ASGI/WSGI servers) handler.
Consequences
- PHP/Node/Python adapters are separate crates; the server registers them in a registry.
- M1 handlers (static, proxy, respond) need no lifecycle and implement
Handlerdirectly; M2 wraps them as adapters so every runtime type goes through one registry.