Repository navigation
v0.1.0 release
automerge-cpp v0.1.0 — Initial Release
This release marks the debut of automerge-cpp, a from-scratch C++23 reimplementation of the Automerge CRDT. This version provides a robust, high-performance foundation for building collaborative applications with a modern, type-safe API.
Unlike a simple wrapper, this library embraces idiomatic C++23 features—such as ranges, algebraic types, and strong typing—to ensure that illegal states are unrepresentable at compile time.
Core Features
Data Model & Containers
Support for the primary Automerge data types, allowing for complex nested structures:
- Maps & Tables: Key-value storage with deterministic conflict resolution.
- Lists: Ordered sequences of values.
- Text: Specialized RGA-based sequences for character-level collaborative editing.
- Counters: CRDT counters that merge by accumulating increments/decrements.
Rich Text Marks
Comprehensive support for rich text annotations (bold, italic, links, etc.):
- Identity-Anchored: Marks are anchored to element
OpIds rather than indices, ensuring they survive concurrent insertions or deletions. - Dynamic Resolution: Indices are resolved at read-time, automatically adjusting as the document changes.
Time Travel & Historical Reads
The document state is stored as a directed acyclic graph (DAG) of changes:
- Heads Tracking: Retrieve the "heads" (leaf hashes) of the document.
- Historical Queries: Read any part of the document at any specific point in history using
get_at(),text_at(),keys_at(), andlength_at().
Stable Cursors
- Cursors provide a way to track a specific position in a list or text object that remains stable across merges and edits, unlike traditional integer indices.
Fork, Merge, & Sync
- Fork/Merge: Deeply copy a document into an independent instance and merge it back later.
- Efficient Sync: A Bloom filter-based synchronization protocol for minimal-bandwidth peer-to-peer updates.
- Change Tracking: Atomic
transact()blocks produce discreteChangeobjects with causal dependency tracking.
Binary Persistence
- Efficient Storage: Full
save()andload()support using LEB128 variable-length encoding for compact binary representation. - Verification: Robust loading that reconstructs document state by replaying change history.
Performance
Optimized for high-throughput environments. Benchmarks performed on Apple M3 Max (Release build):
- Map Operations: ~3.3 Million puts/sec | ~29.3 Million gets/sec.
- Cursor Resolution: ~6.1 Million resolves/sec.
- Time Travel: ~1.3 Million historical reads/sec.
Developer Experience
Modern C++23 Architecture
Built on the principles of "Easy to use, Hard to misuse":
- No Raw Loops: Traversal is handled via
std::rangespipelines and algorithms. - Strong IDs:
ActorId,ObjId, andOpIdare distinct types to prevent accidental mix-ups. - Algebraic Values: Values are modeled as
std::variant, ensuring safe access to scalars and objects. - No Exceptions: Uses
std::optionalandstd::expected(planned) for predictable error handling.
Multi-Platform Support
Continuous Integration (CI) ensures compatibility across:
- Linux (GCC 14+, Clang 18+)
- macOS (Apple Clang)
- Windows (MSVC 19.38+)
- FreeBSD
Project Resources
- Documentation: Comprehensive style guides and API references are available in the
docs/folder. - Examples: Four sample programs (
basic_usage,collaborative_todo,text_editor,sync_demo) are included to help you get started.