Repository navigation
v0.4.1 release
automerge-cpp v0.4.1
This maintenance release focuses on storage reliability, encoding correctness, and exhaustive validation of the Run-Length Encoding (RLE) engine. It resolves critical bugs in the binary format that previously led to document corruption and incomplete data persistence.
This release achieves test suite parity with the upstream library's test suite.
RLE Engine & Columnar Fixes
A comprehensive overhaul of the RLE (Run-Length Encoding) and columnar storage layers ensures full data integrity across complex concurrent editing scenarios.
Bug Fixes
- RLE Null Coalescing: Fixed a logic error where
append_null()triggered a premature flush of pending runs. This caused consecutive null values to be encoded individually (taking 2 bytes each) rather than as a compact run (2 bytes total), and occasionally led to misaligned buffers. - Column Header Ambiguity: Resolved a critical parsing bug where RLE literal control bytes (specifically
0x7F) were misidentified as ascending column specifications. This caused the parser to consume data as headers, shifting all subsequent data and breakingDocument::load(). - Explicit Column Count: Introduced an explicit column count prefix to the raw column format to replace the previous ascending-order heuristic, making the parser immune to data-payload overlap.
Improved Serializer Support
- Complete Actor Table:
ensure_actor_table()now recursively extracts actor IDs fromobj,insert_after, andpredfields. This ensures that documents containingincrementoperations on nested objects or complex causal histories remain loadable. - Object Type Round-Trips: Fixed a limitation where
insert_objectoperations into lists lost theirObjTypeidentity during serialization. These are now correctly encoded using action codes 0 (map) or 2 (list) to preserve their identity during load.
Testing & Validation
This release represents a major leap in test coverage, achieving closer parity with the upstream Rust implementation.
-
Expanded RLE Test Suite: 59 new tests (increasing the count from 10 to 69) cover exhaustive edge cases, including:
-
Null positioning and interleaving (nulls at start/middle/end).
-
Signed integer transition patterns (run literal null).
-
Compactness verification and stress tests for unique value runs.
-
New Integration Tests: Added 23 new integration tests to
document_test.cppfocusing on: -
List Conflicts: Conflict resolution and deterministic insertion ordering across multiple actors.
-
Counter Edge Cases: Verification that independent counters do not combine incorrectly and survive nested map operations.
-
Large Data Stress: Validated O(n) scan performance with 500-element lists and 100+ put/delete cycles.
Performance & Parallelism Refinements
The threading model introduced in v0.4.0 has been tightened for production stability.
-
Thread Pool API Integration: The
parallel_perf_demohas been rewritten to use the built-inparallelize_loopAPI. It now demonstrates lock-free parallel reads by leveragingset_read_locking(false)to eliminateshared_mutexcontention. -
API Enhancements:
-
Added
Document::get_thread_pool()to allow sharing pools between documents. -
Added
Document::read_locking()to query the current synchronization state. -
Platform Compatibility: Replaced
std::jthreadwithstd::threadand explicit join loops to improve compatibility with older toolchains and the FreeBSD environment. -
CMake Infrastructure: Added
Threadsas a public dependency, ensuring proper linking ofpthreadacross all consumer targets.
Statistics & Environment
- Version: 0.4.1
- Total Tests: 347 passing tests.
- Dependencies: CMake 3.28+, zlib, and C++23.