Initial offline value of a shared document

GitHub - yjs/yjs: Shared data types for building collaborative software
Document Updates
Changes on the shared document are encoded into document updates. Document updates are commutative and idempotent. This means that they can be applied in any order and multiple times.

That is not my understanding.

IF the local client applies the template as an update to the document, then yes - a random userID will be generated on each page refresh/load. Seperate client IDs will cause the data to “duplicate”.

IF, tho, you encode a document update into a base64 string, and then hardcode (or fetch) that string (with a “reliable” already encoded user ID) and apply it as the first update every time the ydoc is initiated into memory, then the Idempotent nature of updates should prevent data duplication.