moon/SPEC_NOTES.md
This file records implementation-critical notes for the MoonBit codec under moon/,
as requested by moon/specs/01-context-checklist.md.
It is intentionally not a full spec: the source of truth is docs/encoding.md
and the Rust implementation referenced below.
u16) is big-endian (bytes [20..22] in the document header).xxHash32) is stored as u32 little-endian in bytes [16..20],
and the checksum covers bytes [20..] (mode + body), not just body.peer(u64 BE) + counter(i32 BE).F64 is big-endian IEEE754.I64/DeltaInt use SLEB128 (two’s complement sign extension), not zigzag.keys arena,
and the custom value encoding.ContainerType::to_bytes mapping):
Map=0, List=1, Text=2, Tree=3, MovableList=4, Counter=5.Option<ContainerID> in wrapper.parent):
Text=0, Map=1, List=2, MovableList=3, Tree=4, Counter=5.See Rust: crates/loro-internal/src/state/container_store/container_wrapper.rs.
count_utf8_codepoints(...) when converting between
string lengths and the on-wire representation.BigInt as the internal accumulator for i128-like behavior
(see moon/loro_codec/serde_columnar_delta_rle.mbt).lz4_flex::frame).lz4_decompress_frame)lz4_compress_frame) using block-independence and BD=64KBCompressionType::NoneValue::Future(tag, data)),
enabling conservative round-tripping at the value layer.UnknownOp (forward-compat op content) for non-Counter containers🦜:cid:root-...) because binary container values
reconstruct IDs from op_id + container_type and cannot represent roots.crates/loro-internal/src/encoding.rs, .../encoding/fast_snapshot.rscrates/kv-store/src/sstable.rs, crates/kv-store/src/block.rs, crates/kv-store/src/compress.rscrates/loro-internal/src/oplog/change_store/block_encode.rs,
crates/loro-internal/src/oplog/change_store/block_meta_encode.rs,
crates/loro-internal/src/encoding/outdated_encode_reordered.rscrates/loro-internal/src/encoding/value.rscrates/loro-common/src/lib.rs