Home / Market / rust yrs shared map identity

rust yrs shared map identity

Use when Rust Yrs replicas converge but lose offline edits after creating nested shared maps independently, or when designing shared map initialization.

skill★ 508990 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: rust-yrs-shared-map-identity description: "Use when Rust Yrs replicas converge but lose offline edits after creating nested shared maps independently, or when designing shared map initialization." category: development risk: critical source: self source_type: self date_added: "2026-12-02" author: ShianMike tags: [rust, yrs, yjs, crdt, offline-sync, shared-map]

---

Rust Yrs Shared Map Identity

When to Use

Prerequisites

1. Find the object each peer actually edits

  1. Trace the parent key and child object separately. Two peers can assign different shared map objects to the same parent key. Both assignments compete, even when their child edits use different keys.
  2. Check whether edits go through the integrated map already stored under the key. Creating another MapPrelim and assigning it replaces the parent entry.
  3. Capture snapshots before either peer receives the other's changes. Compare the visible result after both updates arrive and confirm the expected fields on both replicas.
Replica A   creates project.notes, then inserts alpha
Replica B   creates another project.notes, then inserts beta
After sync  replicas agree on one visible notes map

2. Arrange for the peers to edit one shared object

  1. For stable document-wide collections, consider a named root map via Doc::get_or_insert_map. The root name and shared kind form part of the application schema. Both peers use the same root and insert their own entries into it.
  2. For a collection nested under a parent record, integrate the child once and distribute that document update before peers edit it offline. Have existing clients retrieve and mutate the integrated child.
  3. Handle a missing child explicitly during sync or recovery. An empty local view can mean that the document is insufficiently initialized. For truly concurrent nested creation, define an application-level merge or choose a root layout that supports independently created entries.

3. Verify offline semantics and replay

  1. Assert both visible content and convergence. Include a case with distinct entry keys and another for writes to the same key if the product relies on it.
  2. Exchange updates captured before either receives the other. Test replay and, when relevant, out-of-order or duplicate delivery with the real update encoding.
  3. For existing documents, test saved updates and schema migration in disposable replicas. Preserve the original serialized state until visible entries and references are verified.

Example

Run the two-replica fixture. It checks independent nested creation, edits to a named root, and edits to a nested map initialized once and shared.

Limitations

Safety and Side Effects

Related Skills and Documentation