Skip to main content

Crate alkcall

Crate alkcall 

Source
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, feature gateway): the transport-neutral dispatch spine and services/schema disclosure 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 as alk/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

RoleCall protocolChannels protocol
ProducerRegisters ops on an OperationRegistry, runs a DispatcherRuns a ChannelsAdapter, registers openable ALPNs via ChannelCore::register_openable
ConsumerUses CallConnection to call ops, uses from_call to discover/import remote opsUses ChannelClient to open channels via call_open_op + open_channel
HubBoth: runs a Dispatcher for ops it produces, holds CallConnections to spokes for ops it consumesBoth: runs a ChannelsAdapter for inbound connections, holds ChannelClients to spokes
Spoke / WorkerBoth: produces ops (its own services), consumes hub opsBoth: 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:

  1. Producer half — a register_*() function that takes an &mut OperationRegistry and registers ops with their handlers. For channels-based protocols, an OpenHandler factory registered via channels::operations::ChannelCore::register_openable.
  2. Consumer half — a typed client wrapper around protocol::connection::CallConnection (or channels::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_type concept).
client
Client adapters: turn external operation sources (JSON Schema, OpenAPI, MCP, remote from_call peers) into HandlerRegistration bundles.
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.