Repository navigation
v0.5.0 release
automerge-cpp v0.5.0 — Modern API & JSON Interoperability
The 0.5.0 release introduces a significant evolution of the automerge-cpp API, focusing on developer ergonomics and seamless integration with the modern C++ ecosystem. This version bridges the gap between CRDT complexity and the intuitive patterns popularized by libraries like nlohmann/json.
Modern C++ API (Phase 12A)
This release significantly reduces boilerplate by introducing type-aware overloads and template-driven accessors.
Ergonomic Transactions
The transact and transact_with_patches methods are now templated, allowing lambdas to return values directly to the caller. This eliminates the need for capturing external variables just to retrieve a new ObjId.
auto list_id = doc.transact([](am::Transaction& tx) {
tx.put(am::root, "title", "Shopping List");
return tx.put_object(am::root, "items", am::ObjType::list);
});
Initializer Lists & STL Containers
Mutations now support bare initializer lists and standard STL containers. The API automatically disambiguates between list and map structures based on the input type.
- List Creation:
tx.put(root, "items", {"Milk", "Eggs", "Bread"}) - Map Creation:
tx.put(root, "config", {{"port", 8080}, {"host", "localhost"}}) - STL Support: Directly pass
std::vector,std::set, orstd::maptoputandinsert.
Simplified Data Access
New accessors make navigating the document tree as simple as working with a standard JSON object.
- Typed
get<T>: Retrieve values directly as C++ types:doc.get<std::string>(root, "name"). - Variadic
get_path: Navigate nested structures in a single call:doc.get_path("config", "database", "port"). - Bracket Operator: Quick access to the root map:
doc["title"].
nlohmann/json Interoperability
Automerge documents can now be easily initialized from or exported to nlohmann/json structures.
- Recursive Import/Export: Utilities to convert between
nlohmann::jsonand AutomergeDocumentinstances. - ADL Serialization: Provides
to_jsonandfrom_jsonoverloads for all core Automerge types (ActorId,ChangeHash,OpId,Change, etc.). - Submodule Integration: The library now includes
nlohmann/jsonas an upstream reference.
Critical Fixes & Improvements
Serializer & Encoder Stability
- Fixed Actor Table Incompleteness: The actor table now recursively scans
obj,insert_after, andpredfields, ensuring that documents with complex causal histories (like nested increments) remain loadable. - Object Type Preservation: Fixed a bug where
insert_objectoperations into lists lost their type identity during serialization. - Parsing Ambiguity: Resolved a critical bug where RLE literal control bytes could be misidentified as column headers.
RLE Engine Refinement
- Null Coalescing: Fixed a logic error in
append_null()that caused consecutive null values to be encoded inefficiently. - Exhaustive Testing: Added 59 new RLE-specific tests, covering edge cases for null interleaving, transition patterns, and large run compression.
Release Statistics & CI
- Total Tests: 485 passing tests (up from 347 in v0.4.1).
- CI Configuration: Optimized GitHub Actions to trigger on
pushonly to streamline the development cycle. - Doxygen: Added GitHub Pages workflow to automatically deploy API documentation generated from Doxygen-annotated headers.
Would you like me to generate a code sample showing how to use the new get_path variadic template to safely access deeply nested data?