Expand description
alkcall: Call + channels RPC — operations, streaming, service discovery, and N-channel multiplexing over one transport stream.
This crate is the unification of the call protocol (structured JSON RPC:
operations, streaming subscriptions, service discovery) and the channels
protocol (multiplexing proxy: N logical channels over one transport
stream, channel 0 pre-negotiated as alk/call). Both halves share
the vendored core types and the call protocol’s OperationRegistry —
channel lifecycle is orchestrated by call operations on channel 0
(ADR-047: openable ALPNs are operations).
§Architecture
- Vendored core types (
core):Connection,ProtocolHandler,BiStream,BidiStreamSource,AuthContext,IdentityProvider,Capabilities,OwnershipProvider— the home for these types going forward. - Registry (
registry): operation specs, context, dispatch, and the operation registry — the call half’s dispatch core. - Gateway (module
gateway, featuregateway): the transport-neutral dispatch spine andservices/schemadisclosure guard — the deadline-bounded, re-rooted-context invoke surface for HTTP gateways, hub relays, and other transport front-ends (ADR-048). - Protocol (
protocol): wire format, streams, adapter, dispatch loop, pending requests, abort cascade — the call half’s wire layer. - Client (
client):CallClient,from_call,OperationAdapter— the call half’s outbound surface. - Channels (
channels): the channels protocol — 8-byte chunk wire format, demux/mux,ChannelManager,ChannelsAdapter,ChannelBidiStreamSource,ChannelOperations,ChannelLifecyclePolicy,ChannelClient,pump_bidi(the two-pump helper, ADR-050). Channel 0 is pre-negotiated asalk/call; channels 1..N are opened via per-ALPN open ops (channels/<alpn>/sub,channels/<alpn>/pub) on channel 0 (ADR-047).
§Downstream composition
alkcall is a pure protocol crate — no networking, no transport
dependencies. Downstream crates compose on top of it in a layered
dependency chain. See docs/architecture/README.md §“Roles and
Composition” for the full layering diagram and role definitions.
§The four roles
| Role | Call protocol | Channels protocol |
|---|---|---|
| Producer | Registers ops on an OperationRegistry, runs a Dispatcher | Runs a ChannelsAdapter, registers openable ALPNs via ChannelCore::register_openable |
| Consumer | Uses CallConnection to call ops, uses from_call to discover/import remote ops | Uses ChannelClient to open channels via call_open_op + open_channel |
| Hub | Both: runs a Dispatcher for ops it produces, holds CallConnections to spokes for ops it consumes | Both: runs a ChannelsAdapter for inbound connections, holds ChannelClients to spokes |
| Spoke / Worker | Both: produces ops (its own services), consumes hub ops | Both: produces channels (TTY, tunnel), may consume hub channels |
A single process can be a producer of some ops, a consumer of others,
a channel opener for TTY, and a channel acceptor for tunnels — all on
the same alk/channels connection.
§Pattern for protocol crates
A protocol crate (e.g. alktty, alktunnels) depends only on alkcall and provides two halves:
- Producer half — a
register_*()function that takes an&mut OperationRegistryand registers ops with their handlers. For channels-based protocols, anOpenHandlerfactory registered viachannels::operations::ChannelCore::register_openable. - Consumer half — a typed client wrapper around
protocol::connection::CallConnection(orchannels::client::ChannelClient) that exposes the crate’s ops as async methods.
The protocol crate doesn’t know whether it’s running on a hub, a spoke, or a standalone process. The networking + composition layer (alk/alknode) wires protocol crates’ producers into registries and consumers into clients.
Re-exports§
pub use registry::registration::OperationRegistryBuilder;
Modules§
- channels
- Channels protocol: N logical channels over one transport stream
(ADR-034, amended by ADR-035 — no
stream_typeconcept). - client
- Client adapters: turn external operation sources (JSON Schema, OpenAPI,
MCP, remote
from_callpeers) intoHandlerRegistrationbundles. - core
- Vendored core types:
ProtocolHandler,Connection,BiStream,BidiStreamSource,AuthContext,IdentityProvider,Identity,AuthToken,Capabilities,OwnershipProvider,HandlerError,StreamError. - protocol
- Call protocol: wire format, streams, and the call adapter.
- registry
- Operation registry: specs, handlers, access control, service discovery.