Protocol Spec
Ontology Conventions
Look Conventions
kanonak.org
wire-form@1.0.0
wire-form
Body Schema
The class whose generated (kanonak-codec) shape the JSON tail parses against. REQUIRED when encodedAs is JsonBody; forbidden otherwise.
Byte Length
Exact byte count. REQUIRED when encodedAs is FixedBytes; forbidden otherwise.
Constant
One named constant. Embedded within its group's wire.constants list.
Constant Group
A named registry of wire constants (channel ids, frame kinds, op codes) — generated as typed constants in every language, so cross-boundary numbers are never…
Constant Name
The constant's logical name (lowerCamelCase; rendered per language idiom).
Constant Value
The constant's numeric value. Must fit the group's membersEncodedAs range.
ConstantGroupShape
Constants
The group's members. constantNames MUST be unique within the group.
ConstantShape
Declaration
Marker superclass for the wire artifacts a package author declares — Structs, Unions, and ConstantGroups. Generators detect a package's wire surface as its…
EmptyStructsAreVariantsOnly
A Variant MAY declare zero fields (a tag-only message). A standalone Struct declaration MUST declare at least one field.
Encoded As
The field's wire form: a Primitive member, or a declared Struct/Union (composition — the referenced declaration's layout is encoded in place).
Field
One field of a Struct (or Variant). Embedded within its owner's wire.fields list; never a standalone declaration.
Field Name
The generated accessor's logical name (lowerCamelCase). Each language port renders it per idiom — the name, like everything else here, is authored once.
FieldOrderIsByteOrder
The wire.fields list order IS the byte layout. Implementations MUST encode and decode fields in list order with no padding, alignment, or reordering.
Fields
The Struct's fields, IN BYTE ORDER — the list order is the wire layout. At most one tail-typed field (Rest, JsonBody), and only in final position.
FieldShape
Fixed Bytes
Exactly byteLength raw bytes (the Field MUST carry wire.byteLength). Decoded as a zero-copy view where the language has one.
FixedBytesRequiresLength
A field typed FixedBytes MUST carry wire.byteLength; any other field type MUST NOT.
GenerateDontInterpret
Wire declarations MUST be realized as generated static codecs; implementations MUST NOT interpret declarations on the per-frame data path.
JSON Body
All remaining bytes decoded as strict UTF-8 and parsed as JSON against the Field's wire.bodySchema class. A tail type: legal only as the FINAL field. Never…
JsonBodyRequiresSchema
A field typed JsonBody MUST carry wire.bodySchema; any other field type MUST NOT.
KernelSemantics
Primitive semantics are defined by the kanonak-wire runtime kernel at wireFormatVersion "1" (big-endian, strict UTF-8, lowercase UUID canonical form, fail-loud…
LayoutVersioning
Wire messages carry no in-band version. Any change to a Declaration's layout (fields, order, types, tags, constants) MUST ship as a new package version, never…
Length-Prefixed UTF-8
A u16be byte length, then exactly that many bytes decoded as strict UTF-8. Unlike the tail types this may appear at any position. Added for a real consumer: a…
Members Encoded As
The wire type of every member. Version 1 permits U8, U16BE, or U32BE.
Primitive
The closed set of primitive field types. Byte semantics are defined by the kanonak-wire runtime kernel, wireFormatVersion "1" — big-endian integers,…
Rest
All remaining bytes (possibly zero), as a zero-copy view. A tail type: legal only as the FINAL field of its Struct or Variant.
Struct
An ordered sequence of Fields encoded back-to-back with no padding, no alignment, and no in-band version byte (layout changes require a new package version).…
StructShape
Tag Value
The discriminator value selecting this variant. Unique within the Union.
Tagged By
The discriminator primitive read before the variant body. Version 1 permits U8 only (widen only with a real consumer).
TagValuesUniqueAndInRange
Within a Union, every Variant's tagValue MUST be unique and MUST fit the taggedBy primitive's value range. Decoders MUST fail loudly (UnknownTag) on an…
TailTypesLast
A field typed Rest or JsonBody MUST be the final field of its Struct or Variant, and at most one such field may appear.
U16BE
Two bytes, big-endian, unsigned, 0..65535.
U32BE
Four bytes, big-endian, unsigned, 0..2^32-1. Languages without a fitting unsigned type widen (e.g. Java long) — exactness above 2^31 is normative.
U8
One byte, unsigned, 0..255.
Union
A discriminated union: the tag (taggedBy's primitive) is read first, then exactly the matching Variant's fields. An unrecognized tag is a loud UnknownTag error…
UnionShape
UUID
Exactly 16 bytes. String form is lowercase hyphenated 8-4-4-4-12; any 16 bytes are legal (no version/variant validation).
Variant
One arm of a Union: a Struct (ordered fields) plus the tagValue that selects it. Embedded within its Union's wire.variants list; never a standalone declaration.
Variant Name
The generated variant's logical name (lowerCamelCase).
Variants
The union's arms. tagValue decides dispatch; list order carries no wire meaning. tagValues MUST be unique within the Union and fit taggedBy's range.
VariantShape
Wire Form
Anything a Field may be encoded as: a Primitive member, or a declared Struct or Union. Abstract — never instantiated directly.