Skip to content

The native protocol and the row format, version 1 (DRAFT)

Status: design, 2026-12-02, reviewed (decisions in section 10). Nothing of it is implemented yet.

The network API (oliviadb-api.openapi.json, HTTP and JSON) answers a read with JSON text. Every node carries its full path, its type, its key as an object, its layout id and its fields as text. A dossier (a customer, 2 accounts with 100 transactions each, a card: 204 nodes) is 65,915 bytes that way. The server has to parse every key, decode every field and write it out. The native protocol is the data path for applications and SDKs. It carries the same requests over one long-lived connection, and it answers reads with rows:

  • the structure goes in a type descriptor, sent once per connection;
  • the data goes as the node's stored bytes: its key component and its value as the layout wrote it. The server copies them, and the client decodes them.

This is the model of PostgreSQL's RowDescription and DataRow, Cassandra's result metadata and rows, and MySQL's column definitions and rows. HTTP and JSON stay for administration, curl, browsers and simple integrations. Both front ends call one handler layer, and every request of the native protocol has an HTTP twin with the same meaning.

Borrowed, by source:

  • Framing with a stream id per request, many requests in flight on one connection, and server-pushed frames on a stream: CQL binary protocol v4, sections 2.3 "stream" and 4.2.6 "EVENT".
  • Optional lz4 compression of frame bodies, with the uncompressed length first: CQL v4, section 5.
  • Structure separate from data, and metadata once per statement: CQL v4, sections 4.2.5.2 "Rows" (the No_metadata flag) and 4.2.5.4 "Prepared"; CQL v5, sections 4.1.6 and 4.2.5.2 (result_metadata_id, the Metadata_changed flag).
  • A type byte, then a length, then the body; integers in network byte order: PostgreSQL 19 documentation, chapter 54 "Frontend/Backend Protocol", sections 54.1.1 "Messaging Overview" and 54.1.3 "Formats and Format Codes".
  • RowDescription before DataRow: PostgreSQL section 54.2.2 "Simple Query".
  • Pipelining: PostgreSQL section 54.2.4 "Pipelining". Here pipelining comes from stream ids, and there is no Sync. Every request is independent, and a transaction is one request.
  • Asynchronous messages at any time: PostgreSQL section 54.2.7 "Asynchronous Operations".

URLs: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec, .../native_protocol_v5.spec, https://www.postgresql.org/docs/current/protocol-overview.html, https://www.postgresql.org/docs/current/protocol-flow.html.

1. Transport

  • TCP, on its own port (server configuration native_listen), by default 7655. The port lies in the IANA user-port range (1024-49151, RFC 6335 section 6) inside the unassigned block 7649-7662 of the Service Name and Transport Protocol Port Number Registry (https://www.iana.org/assignments/service-names-port-numbers/, read 2026-12-02). No well-known product claims it, and it is not an alternative port of HTTP or of another database. A registration with IANA follows the RFC 6335 procedure when the protocol is stable. With TLS configured, the connection is TLS from its first byte, with ALPN oliviadb/1. The certificate is the one the HTTP listener uses. There is no plaintext upgrade, because that is the cause of PostgreSQL's buffer-stuffing issue (section 54.2.10, CVE-2021-23222). Without TLS the server accepts connections only on loopback. Plaintext from other addresses needs the explicit switch native_plaintext_remote: true, and the server then logs a warning at start-up naming the listener. A client connecting with TLS offers ALPN oliviadb/1 (RFC 7301) and refuses the connection when the server selects another protocol or none. It verifies the server's certificate chain against its trust anchors (by default the platform's roots; a client may take a CA file instead) and the server's name against the certificate (RFC 6125 section 6; a client may take the name to verify when it differs from the host it connects to). A handshake that fails either check ends the connection before any frame is sent.
  • Unix socket (native_socket): no TLS, the same frames.
  • Local shared memory: on the server's node, a client can carry the same frames through a shared-memory slot of oliviadb_shm, which is the transport of the DL/I local call path (docs/integration.md in the core, "C ABI version 10"). The Unix socket is the guard, and the slot carries the frames. The encoder is the same and only the byte sink differs (section 9).

2. Frames

Byte order. Every fixed-width integer, in frame headers and in bodies (u16, u32, u64), is big-endian (network byte order, as PostgreSQL section 54.1.3 and CQL v4 section 1). varint is unsigned LEB128, which is little-endian by groups of 7 bits by its definition. The layout bytes inside a value keep the byte order the layout gives each field (schema.md 4.1: binary-be big-endian, float-ieee big-endian, packed decimals as packed). lp is a varint length followed by that many bytes. str is an lp that holds UTF-8.

frame  = length:u32  opcode:u8  flags:u8  stream:u32  body
length = the number of bytes after the length field (10 + body length, minus 4)
flags  : bit 0 compressed body (lz4 block, the body starts with the uncompressed length u32)
         bit 1 more: the response continues in the next frame of this stream
         other bits 0 (a receiver refuses a frame with an unknown bit)
stream : chosen by the client, not 0, unique among its requests in flight; the server
         answers on the same stream; frames of different streams interleave

The largest frame is 1 MiB by default (max_frame, given in READY). A result that is larger is sent as several frames with the more bit, so the server streams a large tree without buffering it. Frames are atomic: a frame is written whole or not at all, and the nodes of a result never straddle two frames.

more and CANCEL. The server checks for a CANCEL of a stream between frames of its result. When one arrives, it finishes the frame it is writing, sends no further frame of the result and ends the stream with END. The client discards a result that ended without a frame whose more bit is clear. A CANCEL for a stream that has already finished is ignored. CQL v4 caps a frame at 256 MB (section 2.5) and v5 caps a payload at 128 KiB (section 2.1). Compression is negotiated in HELLO. A sender may still leave any frame uncompressed (CQL v4, section 5).

There is no checksum: TCP and TLS cover integrity, and shared memory needs none. CQL v5 added CRCs because its framing layer is separate from TLS (section 2.1). That reason does not apply here.

3. Opcodes

opcode direction body
0x01 HELLO client → server, stream 1, first frame versions: u16 count, u16*; options: varint count, (str, str)* (compression = lz4 or none, client = name and version)
0x02 READY server → client version: u16; server: str; max_frame: u32; options as in HELLO, the chosen ones
0x03 AUTH client → server scheme: str (token or bearer); credential: lp
0x04 AUTH_OK server → client tenant: str; principal: str
0x10 REQUEST client → server route: u8; path: str; params: varint count, (str, str)*; body: lp (section 4)
0x11 DESCRIBE server → client a type descriptor (section 5), sent on the stream of the first result that uses it, before that result
0x12 ROWS server → client nodes (section 6)
0x13 JSON server → client status: u16; body: lp, the HTTP route's JSON answer (routes without a row form)
0x14 ERROR server → client status: u16; problem: lp, the HTTP route's application/problem+json body
0x15 CHANGE server → client one change record on the stream of a CHANGES request (section 4)
0x16 END server → client the stream ends: the last frame of a CHANGES stream after CANCEL, or of an empty result
0x17 UNDESCRIBE server → client id: varint: the descriptor is dropped (section 5); a later use of the type comes with a new DESCRIBE and a new id
0x20 CANCEL client → server stream: u32: stops a request in flight or a change stream; answered with END on that stream
0x21 PING / 0x22 PONG both data: lp, echoed

Start-up runs HELLO → READY (or ERROR 400 for no common version), then AUTH → AUTH_OK (or ERROR 401). The client then sends REQUEST frames. A REQUEST before AUTH_OK gets ERROR 401. A client may send HELLO and AUTH together without waiting. The flow is CQL v4's (section 4.1.1 STARTUP, 4.2.2 READY, 4.2.3 AUTHENTICATE, 4.2.8 AUTH_SUCCESS) with the credential in the first message, because the server knows one kind of credential.

Authentication takes exactly what the HTTP Authorization header takes: token/bearer followed by an API key, or bearer followed by a JWT. They give the same principals, profiles and tenant. There is no new kind of secret. One connection is one caller.

Cancelling happens on the same connection. PostgreSQL needs a second connection and a key for this (section 54.2.8). Here the stream id names the request.

Limits against slow and hostile clients (all in the server configuration):

  • handshake_timeout (default 10 s): HELLO through AUTH_OK must finish within it; otherwise ERROR (protocol error P11) and the connection closes.
  • idle_timeout (default 300 s): a connection with no frame in either direction for that long is closed. Clients send PING to keep a quiet connection open.
  • max_connections (default 1024 per listener): a connection beyond it gets ERROR 503 right after READY and is closed.
  • Authentication failures: after a failed AUTH the server waits before it answers, 100 ms doubling per further failure from the same address up to 5 s (the count drops after 10 minutes without a failure), and closes the connection after the third failure on it. The HTTP listener has no such back-off today. It gets the same one in the same change, so the two front ends do not differ in what a guesser can try.
  • A frame header that announces a length above max_frame is answered with ERROR 413 and the connection closes without reading the body.

Flow control: the server limits the requests in flight per connection (max_streams, default 1024, sent in READY). One more is answered with ERROR 429. A slow reader stops the server's writes through TCP back-pressure, so a stream that is not read holds only its socket buffer.

4. Requests: the HTTP routes, one to one

A REQUEST names a route of the network API. path and params are the route's path (after its prefix) and query parameters, and body is its request body. The answer is what the HTTP route answers, as ROWS for reads with a row form and as JSON otherwise. One handler serves both front ends. The test suite runs every case through both, and it compares the rows, decoded by the Rust SDK into the JSON form, with the HTTP answer byte for byte.

route HTTP twin answer
0x01 GET GET /v1/aggregates/{path} (a node; tree=true, each=N, as_of; a listing: limit, after, prefix, to) ROWS
0x02 LOOKUP GET /v1/lookup/{index} (key, limit) ROWS (section 6.1)
0x03 SEARCH POST /v1/search/{aggregate} ROWS (section 6.1)
0x04 TXN POST /v1/txn JSON (the commit's version and results)
0x05 WRITE POST/PATCH/DELETE /v1/aggregates/{path} (params method) JSON
0x07 DLI GET /v1/dli/{path} (DL/I databases, read only: a segment; tree=true; a listing: limit, after; section 6.4) ROWS
0x06 CHANGES GET /v1/changes (path: the paths, separated by spaces, which paths never contain unencoded; from; limit), as with text/event-stream CHANGE frames until CANCEL, then END; each CHANGE body is one record in binary form (section 6.2), its descriptors sent on the stream before it

Every read answers in binary form: GET, LOOKUP and SEARCH as ROWS, and the change stream as CHANGE frames. Only the answers to writes (TXN, WRITE), which are versions and small results, are the HTTP JSON. Write bodies are the HTTP JSON bodies too. A later version may send field values as layout bytes, encoded by the client from the descriptor of the type's current layout (open point 2).

5. Type descriptors

A descriptor tells the client how to read nodes of one type that were written with one layout and are shown under one grant. The server numbers descriptors per connection, sends each once, before the first ROWS frame that uses it, and refers to it by number afterwards. A connection holds at most max_descriptors of them (default 4096), except while a single result needs more types than that: such a result holds all of its descriptors until it ends, and the excess goes when the next descriptor is needed or used. When a new one is needed beyond that, the server evicts the least recently used descriptor that no result in flight refers to, and sends UNDESCRIBE for it before any later frame. Ids are not reused on a connection, so a client never confuses an old descriptor with a new one. A client that receives a node whose descriptor id it does not hold has a broken stream (protocol error P10). It closes the connection. This is the per-statement metadata of CQL (v4 section 4.2.5.4, v5 result_metadata_id) moved to per type, because a tree mixes types.

descriptor = id:varint
             layout:32 bytes      ; the SHA-256 of the writer layout (schema.md 4.2, 4.3)
             aggregate:str  type_path:str  type_code:u16
             bucket:u8  ordinal:u8         ; bytes of the bucket before the key parts; 1: an ordinal
                                           ; (twins, path-keys.md) follows them
             key: varint count, keypart*
             fixed_len:varint
             fields: varint count, field*
             variants: varint count, variant*
             defaults: varint count, (field, value:lp)*           ; fields of the type's current
                                                                  ; layout that the writer's lacks
                                                                  ; (their place in the current
                                                                  ; layout), and their default
             children: varint count, (type_code:u16, name:str)*   ; the child types, by code
keypart    = name:str  type:str  descending:u8  collation:str     ; path-keys.md format 2
field      = number:varint  name:str  type:str  place:u8  offset:varint  length:varint  scale:u8
             shown:u8                                             ; 0 hidden, 1 shown, 2 masked
place      : 0 fixed area (offset and length in it), 1 tail (offset: the index in the tail)
variant    = discriminator:varint  values: varint count, str*  fields: varint count, field*

type is the logical type as in schema.md 4.1 (string(20), decimal(18,2), timestamp, ...). The encodings are those of the layout table (decimal packed, timestamp microseconds big-endian, ...). The grant enters the descriptor only through shown. A different grant on the same type and layout gives another descriptor, which happens with field grants and masks.

A default's value depends on the field's shown. A shown field's default is its type's default (schema.md 4.5) as layout bytes of the type: a fixed field's bytes, or for text and ref the empty tail entry (one zero byte). A masked field's default is the masked text in UTF-8, the text JSON shows. A hidden field's default is empty. A reader shows these values for every node the descriptor describes, as the JSON answer does.

Size: about 60 bytes plus 25 per field. The bench schema's three types are under 400 bytes, sent once per connection.

6. Rows

rows    = flags:u8  [version:u64]  [next:str]  [base:str]  node*        ; every ROWS frame of a result
flags   : bit 0 version present (reads: the snapshot's version)
          bit 1 next present (a full listing page: the HTTP answer's `next`, the last node's
          level as a path segment, which the next request passes as `after`; a `str`)
          both only in the result's last frame (the one without the more bit): a listing knows
          its next page when it ends, and frames before it are sent as they fill
          bit 2 base present, in the result's first frame only: the canonical path text of the
          depth-0 nodes' parent (empty for roots), as JSON's `path` writes it
node    = desc:varint  depth:varint  key:lp  value:lp  nflags:u8  [lists]  [masks]
nflags  : bit 0 lists present, bit 1 masks present, bit 2 parent present, bit 3 score present,
          bit 4 hit present
lists   = varint count, type_code:u16*                     ; granted child listings of this node
masks   = varint count, (field_number:varint, text:str)*
parent  = str        ; this depth-0 node's parent path (instead of base; "" for a root)
score   = u32        ; the bits of an IEEE 754 binary32, big-endian (SEARCH; the HTTP answer's
                     ; score has that precision)
hit     = str        ; LOOKUP: the path of the indexed node, when it is not this node
  • depth is 0 for the request's node, or for each node of a listing, and the parent's depth plus 1 below it. Nodes come in key order, which is pre-order (path-keys.md, "Order"), so a node's parent is the nearest earlier node with depth one less. Paths are not repeated. The client builds them from the components when it needs them.
  • key is the node's own path component as stored: type code, bucket, key parts in path-keys.md format 2 (or format 1), and the ordinal. The client decodes the parts with the descriptor's key. Every node, at depth 0 too, carries only its own component; the path of a depth-0 node is the result's base, its type's name and its component's text (the canonical path, as the HTTP answer's path, even where the request named the node by a position).
  • value is the node's data as its writer's layout encoded it: the stored value without its version header (schema.md 4.3), with its string(n) fields trimmed (section 6.3). A sealed node (an aggregate under a data subject's key) is opened by the server first, and an erased one is left out, as in JSON.
  • lists: for a node whose type has child types, in a tree read, the listings the profile grants. JSON shows a granted listing without children as [], and these bytes carry that information.

What the server does per node in the fast path is one copy of the key from the block and of the value with its padding left out (section 6.3). There is no path parse, no field decode and no text. Estimated size for the dossier above: 204 nodes × (a component of about 16 bytes, 65 bytes of data, 5 of framing) ≈ 17.5 KB, against 65.9 KB of JSON and 28.5 to 29.3 KB of PostgreSQL DataRow text.

6.1 Lookups and searches

LOOKUP answers ROWS with one entry per record, in the HTTP answer's order. An entry is the record's root node, at depth 0 with base "", carrying hit when the indexed node is a descendant of the root. When the caller's profile does not show the root, the HTTP answer has the paths only, and so does the entry:

entry   = node | 0x00 record:str hit:str        ; descriptor id 0: no node, the record's
                                                 ; path and the indexed node's

The last frame's flags may also have bit 3, async, set: the index is asynchronous, and applied_through:u64 pending:u8 follow base. These are the HTTP answer's applied_through and pending.

SEARCH answers ROWS: the ranked nodes in the HTTP answer's order, each at depth 0 with its parent and its score. The last frame's flags have bit 4, tokens, set, and tokens:u64, the tokens the answer used, follows the other fields of the last frame. The ranking and the token budget are those of the HTTP route: the budget counts the tokens of each node's JSON form, so both front ends return the same nodes.

6.2 Change records

The native protocol streams the changes of native aggregates. A CHANGES request with any other path is refused with the HTTP route's status for mixed streams (422), and those changes are read over HTTP. A CHANGE body is one record of the change stream:

change  = cflags:u8  position:str  version:u64  op:u8  id:16 bytes  parent:str  [before]  [after]
cflags  : bit 0 before present, bit 1 after present, bit 2 erased (the data subject's key is
          destroyed; then neither is present)
op      : 1 insert, 2 replace, 3 delete
before, after = node      ; at depth 0, its own component, the fields as written: the
                          ; descriptor's defaults do not apply to change records

id is the record's key of the HTTP stream (its 16 bytes, which the HTTP record shows in hexadecimal). parent is the canonical path of the node's parent. The collection, type, key and layout come from the descriptor and the component. The descriptors are sent on the CHANGES stream before the first CHANGE frame that uses them. A record whose before and after show the same fields to the caller is not sent, as over HTTP.

6.3 Fixed strings travel without their padding

A string(n) field is stored as n bytes, its UTF-8 text followed by spaces (schema.md, "Layouts of the schema language"). Trailing pad blanks are not significant, as in SQL CHAR (the JSON answer shows the text without them), so the protocol does not carry them. This holds for every node value the protocol sends: ROWS nodes and the before and after of CHANGE records.

Let S be the fields of the node's descriptor (fields, not variant cases) with place 0 (fixed area) and type string(n), in increasing offset. On the wire, the value is the layout value with each field of S replaced by its trimmed form; every other byte (other fixed fields, the variant areas, the tail) is sent as it is, in the same order:

trimmed  = len:varint  bytes          ; the field's first len bytes
len      : shown 1: n minus the number of trailing 0x20 bytes of the field
           shown 0 or 2 (hidden, masked): 0

A decoder restores the layout value exactly. It walks S in offset order, copies the bytes before each field as they are, reads len and the bytes, and fills the rest of the n bytes with 0x20 for a shown field, or with zero bytes for a hidden or masked one (section 7's copy holds zeros there, and so does the restored value). The value length prefix counts the bytes on the wire. A len above n, or a value that ends inside a field of S or before the fixed area ends, is a protocol error (P13, client side). Nothing else changes: the descriptor's defaults carry layout bytes as before, and decoded fields, JSON and the never- leak rule are those of the restored value.

Only spaces (0x20) are left out. Other trailing bytes, a zero byte included, are text and are sent.

6.4 DL/I segments

GET /v1/dli/{path} (route 0x07 DLI) reads the DL/I databases a server serves, read only (the network API document, "DL/I databases"). The server holds the stores of those databases open exclusively while it runs (storage-format.md, "Store lock"): a DL/I program in another process cannot open them then, and a server cannot start on a store a program holds.

Paths. path is DBD/SEG/key/SEG/key/...: the database, then per level a segment type and the segment's text. The text of a segment is the text of its sequence field: the field's value as its type shows it (below; C without its trailing blanks), or x: and the field's bytes in upper-case hexadecimal when they are not a value of the type or do not read back as the same bytes. A segment type whose sequence field is not unique adds ~ and its ordinal; one without a sequence field has ~ and its ordinal only. The ordinal is the twin's number among the twins of the same text under the same parent, from 1, in bijective base-255 digits 0x01 to 0xFF (1 is 01, 255 is ff, 256 is 0101) in lower-case hexadecimal. A request may also give [n] for a segment of a type without a sequence field: the n-th twin under its parent. Path segments are percent-encoded as in aggregate paths. A path that ends with a segment names that segment: with tree=true the answer is the segment and every segment under it, in hierarchic sequence. A path that ends with a segment type is a listing of that type under its parent (limit, at most 1000, default 100; after: the text of the segment to start after), in hierarchic sequence.

JSON. The answers have the form of aggregate answers: a segment is {"path", "type", "key", "fields", "layout", "version"}, under tree=true with "children": {SEG: [...]} for every child type the caller is sensitive to (an empty array when there are none); a listing is {"nodes", "next", "version"}. key holds the sequence field's text under the field's name, and "~" the ordinal's hexadecimal digits where the segment has one. fields are the segment's fields that the caller sees, valued as the schema language's layout table shows its types (decimal as a string, bytes as lower-case hexadecimal).

The rows are those of section 6, with these differences.

  • Descriptors: aggregate is the DBD name and type_path the segment type's path from the root segment type (PART/STOCK); type_code is the segment type's number in the DBD (its SEGM statements counted from 1); bucket is 0; ordinal is 1 for a type whose segments carry an ordinal. key is one part when the type has a sequence field, named after it, of type string(2n+2) for a field of n bytes: the segment's text, as JSON's key shows it. The type's fields are the segment's FIELD statements in DBD order, numbered from 1, without the system-defined names that begin with /, every one of them whatever the caller sees, laid out by the schema language's layout table (schema.md 4.1); the descriptor's layout is that layout's SHA-256. Field types follow TYPE=, whose values are X, P, C, F and H (IMS 15 System Utilities, SC27-6798-00, chapter 2, FIELD statement, TYPE=, PDF p. 131): C is string(n), P is decimal(2n-1,0), H of 2 bytes is int16, F of 4 bytes is int32, and X, any other type and H or F of another length are bytes(n).
  • value: the server re-encodes the segment's fields into that layout (characters from the database's character set to UTF-8, packed decimal with sign C or D, binary in the database's byte order to binary-be), so a client decodes DL/I rows as it decodes aggregate rows. Bytes outside every field are not sent.
  • Sensitivity: the caller's view (a PSB with SENSEG, SENFLD and OliviaDB's ROWS and MASK statements, one per principal) decides as a profile does in section 7. A segment type the PSB is not sensitive to is not sent, nor its subtree, and a path through it is not found (404), as is a database no PCB names. A field outside the PSB's field-level sensitivity (SENFLD; with PROCOPT=K only the key) is hidden, a masked field (MASK) is masked. A segment that fails the ROWS predicates of its database (over the fields of the segment and its parents) is not sent, nor its subtree. The never-leak test of section 7 covers DL/I rows.
  • Values that are not of their type: a field whose bytes are not a value of its type (a packed field with a bad digit or sign, characters that do not convert, text longer than n bytes of UTF-8) is sent as JSON shows it, x: and the bytes in upper-case hexadecimal: the node's descriptor gives the field shown 2 and the node carries that text in masks (such a node has a descriptor of its own). A field the caller does not see stays hidden, and one that is masked shows its mask of that text.
  • base: the depth-0 nodes' parent path; for root segments it is the DBD name.
  • version: the OliviaDB version the read was made at; all rows of a result are of that one committed version.

7. Profiles: grants, masks, rows

  • Fast path: the profile neither masks nor filters the type's fields, and has no row rule on the type. The bytes are copied as stored.
  • Field grants (fields(...), except): the descriptor marks those fields hidden. In the server's copy of the value, a hidden fixed field's bytes are zeros and a hidden tail field has length 0. A hidden field's stored bytes never leave the server.
  • Masks (mask ... redact | token | partial(n), pii masked): the masked text is a string that may not fit the field's type or width, so it travels in the node's masks. The field's bytes in the copy are zeros, as for a hidden field, and the descriptor marks it masked. The text is the one JSON shows.
  • Row rules hide whole nodes. The server reads the rule's field from the bytes, and a hidden node and its subtree are not sent, as in JSON.

The test for "never leak" checks every masked or hidden field of every node of a randomized store under every profile: the field's stored bytes, when not all zeros or spaces, must not occur in the response (the bytes on the wire, with fixed strings trimmed, section 6.3). The rows decoded to JSON must equal the HTTP answer, and each restored value must equal section 7's copy of the stored value byte for byte.

8. Errors

ERROR carries the HTTP status and the HTTP problem body (kind, detail, retryable, version) unchanged, so both front ends report errors with the same codes and words.

Errors of the protocol itself have the kind protocol-error and a code:

code status meaning after it
P01 400 malformed frame or body connection closed
P02 400 unknown opcode connection closed
P03 400 a flag bit that is not defined connection closed
P04 400 unknown route the stream ends, connection stays
P05 400 no common protocol version (HELLO) connection closed
P06 400 stream id 0, or a stream id already in flight connection closed
P07 400 a frame the state does not allow (HELLO twice, AUTH before HELLO, REQUEST before AUTH_OK is P12) connection closed
P08 413 frame longer than max_frame connection closed
P09 429 more streams in flight than max_streams the stream ends, connection stays
P10 none (client side) a node refers to a descriptor id the client does not hold the client closes
P11 408 handshake not finished within handshake_timeout connection closed
P12 401 a request before AUTH_OK, or a failed AUTH the stream ends (closed at the third failure)
P13 none (client side) a node value that does not restore (section 6.3: a trimmed length above n, a value that ends inside a fixed string or the fixed area) the client closes

When the server closes the connection after an error, it sends that ERROR on the stream of the offending frame (0 when it has none) first. An error on one stream leaves the others running.

9. Server and clients

  • Server: the same async runtime as HTTP (tokio). A connection is a task with a reader and a writer. Reads that finish in microseconds (one node, a full-key lookup of a unique index: native::small_read in the core) run on that task. Trees, listings and searches go to the blocking pool and stream their frames back through a bounded channel. The row encoder writes into a byte sink: a socket buffer, a frame being built, or a shared-memory slot.
  • The DL/I path: a DL/I call already returns binary data, namely the segment's bytes in the I/O area as the segment's layout has them (schema.md 4.6, the IMS layouts). It shares with the rows the principle that the data is the stored bytes. It also shares the code of section 7's copy (hidden and masked fields zeroed in a copy of the value) and the shared-memory transport. It does not share the framing: a DL/I call returns one segment together with its PCB feedback, not a stream of nodes.
  • Rust SDK first (oliviadb-rust, crate oliviadb): an async connection with multiplexed streams. A result's frames are kept as received, and each node is a view that borrows from them (&[u8] key and value). Accessors are resolved once per descriptor (desc.field("amount") gives an offset and a type), and a string is a &str into the frame with the padding trimmed. A decimal is read from its packed bytes without allocating. The generated clients (oliviadb schema client --lang rust) use typed accessors that check the descriptor's layout id. The Java, Python and JS SDKs follow with the same decoder.
  • The bench measures OliviaDB through the native protocol, as PostgreSQL is measured through its own. The JSON over HTTP numbers stay as a second row.

10. Tests

  • Both front ends run one suite. The rows, decoded to JSON by the Rust SDK, equal the HTTP answers byte for byte.
  • Never leak (section 7).
  • Fuzzing of the frame and handshake parser: a cargo fuzz target (native_frames) for long local runs, and a property test with a seed corpus of valid and broken frames (truncated, oversized, unknown opcodes and flags, reused streams, out-of-order handshakes) that the cheap CI job runs for a short time on the stable toolchain. The parser must never panic, allocate beyond max_frame or accept a frame the state does not allow.
  • Limits: handshake and idle timeouts, max_connections, max_streams, max_descriptors eviction with UNDESCRIBE, and the auth back-off, each driven by a test client and observed through the frames and the closed socket, never by fixed sleeps.

11. Decisions (review of 2026-12-02)

  1. path-keys.md format 2 is made final. Clients decode key components with the descriptor's key parts. Its open list is settled in path-keys.md before any code.
  2. Version 1 keeps JSON write bodies. Writes with field values as layout bytes are version 2, after the read numbers.
  3. Default port 7655 (section 1). Plaintext beyond loopback only with an explicit switch and a start-up warning.
  4. A per-connection descriptor cap with least-recently-used eviction and UNDESCRIBE (default 4096; section 5).
  5. No HTTP/2 for the JSON API: applications that care about speed use this protocol.