HeadlinesBriefing favicon HeadlinesBriefing.com

Loro's Mergeable Containers Solve Concurrent Child Creation Data Loss

Hacker News •
×

Two users working offline on the same empty note both add content, then sync. One user's edits appear to vanish without error, creating the illusion of data loss. This long-standing issue affects JSON-like CRDTs across Loro, Yjs, and Automerge implementations. The root cause lies in how child container identities are assigned during concurrent creation.

Loro's new Mergeable Containers feature addresses this by deriving child container identity from logical position rather than the creating operation's ID. This means multiple users creating children at the same key reference the same underlying object. Alexis Williams from Synapdeck contributed significantly to the implementation. The API change is minimal - developers simply opt into mergeable children for specific use cases.

The technical approach combines deterministic container IDs with map slot markers. Mergeable CIDs are synthetic root containers under an internal namespace, while activation markers in parent maps control visibility. This separation allows type switching without destroying state - deleting a key removes only the marker, preserving the mergeable child's history.

Mergeable Containers solve practical problems where eager initialization isn't feasible. They're ideal for date-keyed child lists, schema migrations adding new containers lazily, and dynamic per-user subdocuments. The feature maintains compatibility while adding modest metadata overhead for deeper paths.