Vein Wire Format
Vein is LODE’s compact binary encoding. Every compiled LODE object is a Vein payload.
Binary Layout
Header
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 1 | Magic[0] | 0x4C ('L') |
| 1 | 1 | Magic[1] | 0x44 ('D') |
| 2 | 1 | Version | Schema version (matches schema.version) |
| 3 | 1 | Count | Number of encoded fields |
The magic bytes LD identify the payload as a Vein binary. Any file or buffer starting with 0x4C44 is a candidate Vein payload.
Field Entry
Each field is encoded as:
| Offset | Size | Field | Description |
|---|---|---|---|
| 0 | 1 | Field ID | Numeric field identifier (1–255) |
| 1 | 1 | Type Tag | Wire type (see Type System) |
| 2 | 2 | Length | Data length in bytes (big-endian uint16) |
| 4 | N | Data | Type-specific encoded value |
The maximum data length per field is 65,535 bytes (2^16 - 1).
Content Type
Vein binaries are served with the MIME type:
Content-Type: application/x-veinByte Order
All multi-byte integers in Vein are big-endian (network byte order). This includes:
- Field data length (2 bytes)
- String array item count (2 bytes)
- String array item lengths (2 bytes each)
- Map entry count (2 bytes)
- Map key/value lengths (2 bytes each)
Size Characteristics
For a typical model layer with 5 fields:
| Format | Size |
|---|---|
| JSON (pretty) | ~350 bytes |
| JSON (compact) | ~220 bytes |
| Vein | ~90 bytes |
The Vein encoding is roughly 60% smaller than compact JSON for structured data with string fields.
Last updated on