Skip to content

Wire Tags

Twilic v2 uses a compact tag-table wire model. The first byte is always a tag family or fixed literal tag — there is no top-level message-kind envelope byte.

First-Byte Compact Families

These ranges encode common values without an additional tag byte.

RangeMeaningNotes
0x00..0x7Fpositive fixint (0..127)Direct integer value
0x80..0x9Ffixstr (len=0..31)Low 5 bits = length
0xA0..0xAFfixarray (count=0..15)Low 4 bits = count
0xB0..0xBFfixmap (count=0..15)Low 4 bits = count
0xE0..0xFFnegative fixint (-32..-1)Two's complement

Extended Tags (0xC0..0xDF)

TagNameDescription
0xC0nullNull / absence
0xC1falseBoolean false
0xC2trueBoolean true
0xC3float6464-bit float, little-endian
0xC4uint88-bit unsigned integer
0xC5uint1616-bit unsigned integer
0xC6uint3232-bit unsigned integer
0xC7uint6464-bit unsigned integer
0xC8int88-bit signed integer
0xC9int1616-bit signed integer
0xCAint3232-bit signed integer
0xCBint6464-bit signed integer
0xCCbin8Binary, 8-bit length prefix
0xCDbin16Binary, 16-bit length prefix
0xCEbin32Binary, 32-bit length prefix
0xCFstr8String, 8-bit length prefix
0xD0str16String, 16-bit length prefix
0xD1str32String, 32-bit length prefix
0xD2array16Array, 16-bit count prefix
0xD3array32Array, 32-bit count prefix
0xD4map16Map, 16-bit count prefix
0xD5map32Map, 32-bit count prefix
0xD6shape_defDefine a key sequence for shape interning
0xD7shape_refReference a prior shape; encode values only
0xD8key_refReference a previously seen map key
0xD9str_refReference a previously seen string value
0xDAtyped_vecTyped homogeneous vector with codec
0xDBrow_batchRow-wise batch of same-shape records
0xDCcol_batchColumnar batch with per-column codecs
0xDDstate_patchDelta against a previous message or base
0xDEtemplate_batchMicro-batch reuse for repeated patterns
0xDFextExtension point

Interning Tags

shape_def (0xD6)

Defines an ordered key sequence and registers a shape_id for the current message.

text
0xD6 [shape_id] [key_count] [key_0] ... [key_n]

shape_ref (0xD7)

References a prior shape_def in the same message. Only values are encoded — keys are omitted.

text
0xD7 [shape_id] [value_0] ... [value_n]

Unknown shape_ref id is a hard decode error.

key_ref (0xD8)

References a map key literal already emitted in the current message.

text
0xD8 [varuint key_id]

str_ref (0xD9)

References a string value literal already emitted in the current message.

text
0xD9 [varuint str_id]

All intern tables (key_id, str_id, shape_id) reset at each top-level message boundary.

Batch Tags

typed_vec (0xDA)

Typed homogeneous vector. Codec is selected per vector.

text
0xDA [element_type] [count] [codec] [payload]

Available codecs: DIRECT_BITPACK, DELTA_BITPACK, FOR_BITPACK, DELTA_FOR_BITPACK, DELTA_DELTA_BITPACK, RLE, PATCHED_FOR, SIMPLE8B, XOR_FLOAT.

row_batch (0xDB)

Row-wise batch of same-shape records.

text
0xDB [shape_id] [row_count] [row_0_values] ... [row_n_values]

col_batch (0xDC)

Columnar batch. Each column is encoded independently with its own codec.

text
0xDC [shape_id] [row_count] [col_0_codec + payload] ... [col_n_codec + payload]

Stateful Tags

These tags require session state and ordered, reliable delivery.

state_patch (0xDD)

Delta payload against the previous message or an explicit base snapshot.

text
0xDD [base_ref?] [patch_ops...]

template_batch (0xDE)

Micro-batch reuse for repeated schema or shape bursts.

text
0xDE [template_id] [count] [record_0] ... [record_n]

Released under the CC-BY-4.0 License.