NOVA vs Cap’n Proto, CBOR and MessagePack

CBOR and MessagePack are self-describing, but one value can be encoded in several ways, so equal data can hash differently. Cap’n Proto is fast but needs its schema. NOVA binary is self-describing and has exactly one canonical encoding per value.

CBOR {a: 1, b: 2} written twice
a2 61 61 01 61 62 02
a2 61 62 02 61 61 01
a first
b first: other bytes
NOVA, canonical the same two records
0d 02 02 61 03 02 02 62 03 04
0d 02 02 61 03 02 02 62 03 04
sha256:a200d6e9…
the same bytes

Record fields are sorted by key in the canonical encoding, so field order never changes the bytes or the revision. CBOR has an optional deterministic mode that does the same for CBOR. Canonical encoding, spec §5.2

What changes

TopicBinary formatsNOVASpec
Canonical formMessagePack: none. CBOR: an optional deterministic profileExactly one, the basis of equality§5.2
HashingAgree on an encoding firstA sha256: revision of every value, used by patches§2.13
TypesExtension types and tags, agreed out of bandDecimals, rationals, timestamps, durations, sets, tuples and variants built in§5.1
Duplicate keysOften accepted by decodersRejected by every decoder§5.1
Repeated keysWritten each timeBack-references and record lists write a key once§5.3
FramingNone built inFrames with a magic number, optional schema reference and CRC-32§5.4

Migrating

The reference tools read and write CBOR, including its deterministic encoding. MessagePack and Cap’n Proto have no adapter.

nvf convert events.cbor --to nova
nvf convert events.nova --to binary-canonical -o events.nvb
nvf convert events.nova --to cbor-deterministic -o events.cbor
nvf hash events.nova

Timestamps, big integers, decimals, rationals and sets map to registered CBOR tags. Durations, tuples and variants have none and are reported as lossy. CBOR mapping, spec §11.2

When to stay with them

  • You need zero-copy reads or an RPC system. Cap’n Proto is built for that; NOVA decodes into values.
  • You exchange MessagePack with existing services. NOVA has no MessagePack adapter yet; it is listed as future work.
  • You need a format that is stable today. NOVA is a 0.1 draft.

Questions

Can NOVA read and write CBOR?

Yes, as specified in RFC 8949, with a deterministic mode. NOVA kinds without a registered CBOR tag are written with a loss warning.

Is NOVA binary smaller than CBOR?

It depends on the data. Run nvf stats FILE to see the bytes and an estimate of tokens for every representation of your own file.

Does a reformatted file get a new revision?

No. A revision covers the value only. Comments, formatting and field order do not change it, so reformatting never invalidates a pending patch.