← LeaderboardThe Skill Leaderboard

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.

Published by sickn33 ↗sickn33/agentic-awesome-skills

Try your first task

A source-grounded starter task has not been verified for this skill yet.

SKILL.md

name: rust-yrs-shared-map-identitydescription: "Use when Rust Yrs replicas converge but lose offline edits after creating nested shared maps independently, or when designing shared map initialization."category: developmentrisk: criticalsource: selfsource_type: selfdate_added: "2026-12-02"author: ShianMiketags: [rust, yrs, yjs, crdt, offline-sync, shared-map]

Rust Yrs Shared Map Identity

When to Use

  • Two replicas add different fields offline and one entry disappears after synchronization.
  • Each client initializes a nested MapPrelim when a parent key is missing.
  • A shared document schema needs a top-level namespace or an initialization step for nested shared types.

Prerequisites

  • Record the Yrs version, the update encoding used by all peers, and the names and types of shared roots.
  • Identify which transaction integrates each nested shared object and when another peer can first see it.
  • Use distinct client IDs for active replicas. Fixed IDs are useful in synthetic tests that need deterministic outcomes.

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

  • The fixture uses in-memory Rust peers and V1 full-state updates. It does not test JavaScript interoperability, a transport, incremental sync recovery, or persistence.
  • Sharing one map retains concurrent edits at separate keys. Concurrent assignments to the same key still follow map conflict rules.

Safety and Side Effects

  • The fixture mutates synthetic in-memory documents. Cargo writes a scratch lockfile and build artifacts.
  • Changing a shared root or nested layout affects persisted updates. Verify migration and recovery before changing production documents.

Related Skills and Documentation

rust-yrs-shared-map-identity by sickn33 · The Skill Leaderboard