Internals

The wire protocol, codec architecture, and transport patterns that AI Transport is built from. For senior engineers and codec implementers.

The internals section is for engineers who want to understand the system before they depend on it, and for anyone building a custom codec.

Three layers fit together, from the messages on the channel up to the transport your application calls:

  • Wire protocol: what AI Transport writes on the Ably channel. A codec's event type and fields go under extras.ai, the transport marks the messages of a stream and the message that ends one, and the headers of each send() or pipe() call go under extras.headers.
  • Codec architecture: how a codec encodes events to Ably messages and decodes them back. defineCodec builds a codec from a table of rows, and the decoder core reduces live appends, full-content updates and history reads to the text each delivery adds.
  • Transport patterns: the transport's internal parts. The pipe writer appends streams and repairs failed appends, the subscription delivers every message through the codec, the history replay buffers live messages, and the continuity watcher reports discontinuities.

Topics