Switch dumps to use `CBOR` instead of `postcard`

Merged
SA
2mo ago
+795-254

Switch dumps to use cbor via minicbor so we can use serde default features and reorder fields without needing to bump the dump version and invalidate old dumps.

See this claude artifact for discussion.


Summary by cubic

Switches session dumps from postcard to CBOR via minicbor-serde, so derived structs serialize as maps keyed by field name and enums by variant name. Adding, removing, or reordering fields or variants no longer breaks loading of existing dumps, and byte arrays are written as CBOR byte strings (via serde_bytes) instead of one integer per byte. DUMP_VERSION now only bumps when the meaning of stored data changes (e.g. opcodes). postcard is dropped, and #[serde(default)] fallbacks that only served pre-13 dumps are removed since those dumps are rejected on load. Keys without a heap identity hash by stable name instead of enum discriminant (module functions by module-qualified name), since dict and set entries persist their hash in dumps; the fingerprint tests read serde variant names back from the encoding, and a fixture test pins dump compatibility.

Breaking Changes

  • DUMP_VERSION goes from 12 to 13, so dumps written before this PR are rejected; MIN_SUPPORTED_DUMP_VERSION now equals 13.
  • DumpError::Payload and dump()'s error wrap the codec's errors in new DumpDecodeError / DumpEncodeError types so the public API does not name the codec.

Migration

  • A checked-in fixture (dump_v13.bin) and crates/monty/tests/dump_compat.rs pin compatibility: a layout change at version 13 needs a #[serde(alias)] or #[serde(default)], or a bump plus UPDATE_DUMP_FIXTURE=1 to regenerate the fixture.