Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Schema language

A schema is the contract between sender and receiver. Both ends must use the same schema; the encoder’s schema hash is part of generated state and custom predictor declarations are folded into the fingerprint. The compiler parses a small YAML subset and rejects anything outside it.

namespace: robot        # optional; qualifies the message name
name: pose              # required identifier
id: 12                  # optional 0..=255 override of the derived message ID
sync:                   # optional defaults for every predictor field
  refresh: 10           # K: send a true value every 10 committed frames
  reset: 50             # K_R: reset receiver state every 50 committed frames
  max_resets_per_frame: 1
enums:                  # optional, scoped to this message
  - name: Status
    variants: [Idle, Moving, Fault]
fields:                 # ordered sequence; wire order follows declaration order
  - name: x
    type: f32
    quantise: 0.01
    range: [-100.0, 100.0]
    predictor: { type: linear, window: 5 }
    tolerance: { abs: 0.01, rel: 0.01, mode: all }
  - name: flags
    type: u8            # no predictor: always included in the payload
  - name: mode
    type: Status
    predictor: { type: hold_last }
  - name: waypoint_ids
    type: [u16]  # one-element sequence; max_len is mandatory for strings and lists
    max_len: 32
  - name: label
    type: string
    max_len: 64
    predictor: { type: hold_last }

Identifiers and message IDs

name, field names, enum names and enum variant names match [A-Za-z_][A-Za-z0-9_]*. The qualified name is namespace.name when a namespace is present, otherwise name. The message ID is a folded FNV-1a 32-bit hash of the qualified name; an explicit id overrides it. Use predsync schema_check to detect ID collisions within a set and inconsistent IDs across receiver sets.

Field types

TypeWire representation
bool1 bit
u8, u16, u32, u64little-endian two’s complement, native width
i8, i16, i32, i64little-endian two’s complement, native width
f32, f64raw IEEE bits unless quantised
A message enummax(1, ceil_log2(n_variants)) bits holding the variant index
string16-bit byte length, then UTF-8 bytes
[T]16-bit element count, then bit-packed elements of scalar or enum type T

A list type is written as a one-element YAML sequence, for example type: [u16].

Nested lists, lists of strings and maps are not supported in v1. Every string or list field must declare max_len in 1..=65535; the decoder validates wire lengths against it before allocating or copying.

Predictors and tolerance

The predictor discriminator is type, as in predictor: { type: linear, window: 5 }.

Numeric fields may use linear, quadratic, cubic, ewma or hold_last, and must declare a tolerance. window is required for polynomial predictors and must be at least the number of samples the fit needs: 2 for linear, 3 for quadratic, 4 for cubic. The maximum window is 64. ewma instead requires alpha in (0, 1] and must not declare window; alpha is only valid for ewma. The smoothing factor is folded into the schema fingerprint, so two ends with different alpha values cannot silently agree.

bool, enum, string and list fields may use only hold_last and must not declare a tolerance: equality is exact on the final value. quantise and range are allowed on numeric scalars and lists of numeric scalars.

Tolerance supports abs, rel and mode. With both bounds present, mode: all requires both to pass and mode: any requires either. The auto key is recognised but rejected with Unsupported("auto tolerance") in v1.

refresh (K) and reset (K_R) may be set per field or in the message sync: block. K_R must be a multiple of K, and K must be at least the predictor window when the predictor has one (ewma and hold_last do not). A predictor field with no recovery period anywhere is valid but produces a warning: after a link gap it can only recover if a startup Reset happens to arrive.

Custom predictors

Custom predictor names are declared at the API boundary (Builder in Rust, Registry in Python/C) rather than in the YAML grammar. A custom declaration has a name, a window, optional ordered numeric params and an optional integer version. Unregistered names fail at generation or construction time. The name, window, parameters and version are folded into the schema fingerprint so the two ends cannot silently run different models. Callback models written in C or Python are outside the cross-platform bit-exactness guarantee.

Validation is deterministic

Fields are stored and validated in declaration order; maps never influence output. Every rejected schema produces a specific SchemaError variant rather than a generic parse failure. See the API guides for the error types exposed by each language.