Recovery and validity
Sequence and ticks
Each frame carries an 8-bit sequence number and a 16-bit wire tick count. A
decoder expects the next sequence number for each message type. A late frame is
rejected as StaleFrame; a gap marks all predictor fields for that message as
untrusted until a Reset is delivered.
dt == 0 is rejected as Malformed before any state mutation. A silence of
exactly 65,536 wire ticks therefore aliases to zero and loses one harmlessly
framed update; the next frame shows the sequence gap.
The 8-bit sequence number has a documented blind spot: losing exactly a
multiple of 256 consecutive frames is not detected by sequence alone. The next
Reset bounds the damage. This is the sole exception to “no silent staleness”.
Field validity
Every decoded field has one of four validity values:
| Validity | Meaning |
|---|---|
Valid | The true value was received or explicitly checked this frame. |
Predicted | The receiver’s predictor supplied the value. |
Unknown | No trustworthy value is available after startup or a gap. |
ReSync | A Refresh disagreed with the receiver’s prediction. |
Decoded::missed reports the sequence gap and Decoded::resynced reports the
ReSync transition. Unknown scalar fields carry Slot(0) as a placeholder;
callers must read validity before using the value.
No prediction from untrusted state
The receiver keeps a trust flag per predictor field. Startup and sequence gaps
clear it. Only a Reset sets it again. An Included value updates the predictor
but does not make later predictions trustworthy: on a one-way link the sender
does not know that the receiver missed a frame.
Refresh compares the received true value with the receiver’s prediction on
final values. A mismatch produces ReSync and the included value becomes
Valid. A match keeps the field trustworthy.
Containment
The decoder parses and validates the CRC, message ID, presence bits, payload
lengths, UTF-8 and enum ranges before mutating persistent state. If any check
fails, predictor state and trust flags are unchanged. Only the diagnostic
crc_fail_streak, stale run and last stale sequence counters may change.
Fuzz targets assert this invariant around every feed call.
State hashes
state_hashes(message_index) exposes FNV-1a 64-bit hashes of each predictor’s
state. Polynomial predictors hash their window in oldest-first order. For
ewma, the hash covers the sample count, alpha bits, last sample tick and
smoothed level bits, in that order as little-endian bytes. These hashes are a
deterministic observability tool: both ends should agree after a delivered
Reset, and they must not change when a frame is rejected. For opaque
hold_last predictors the hash covers a presence flag and the stored slots or
bytes.
Cost of the conservative rule
Marking every predictor field Unknown after a gap is conservative but not
free. docs/guarantee-report.md measures the counterfactual cost if the sender
knew about untrusted fields and had to send true values: about 6 bytes per
committed frame on lossy profiles. The current one-way design cannot know, so
wire bytes do not change when loss occurs. See Guarantees.