The state_sync receive path in handleDataMessage (src/core/mesh-store.ts) merges add-only: if (!this.agents.has(id)) (same shape for rooms, messages, dms). Since the dial-window broadcast fix (#25), patches are reliable while peers are connected, so this gap only bites when a peer is disconnected outright while an entity changes — a rename, status change, or room edit. The returning peer keeps its stale copy until some later patch about that entity happens to arrive, and any peer that syncs from it inherits the stale copy.
Reproducer shape: three TLS peers; C shuts down; A renames its agent and edits a room; C returns and reconnects. C still sees the old name and old room state, with no further patch coming to correct it.
Fix direction settled during the #23 investigation: per-entity monotonic versions. Every mutating store bumps the entity's version and embeds it in the entity record carried by patches and SerialisedState; state_sync and patch application take the higher version (ties keep the existing union semantics for room members and subscribedRooms, which also keeps concurrent joins race-safe). Owner-authority merging was considered and rejected: a rejoining peer can carry an old copy of a third peer's entity and would clobber it.
Also heals room-leave divergence, which the current member-union cannot (union only ever adds).
Found while verifying the persistent-identity work (#24) and the broadcast queue (#25).
The
state_syncreceive path inhandleDataMessage(src/core/mesh-store.ts) merges add-only:if (!this.agents.has(id))(same shape for rooms, messages, dms). Since the dial-window broadcast fix (#25), patches are reliable while peers are connected, so this gap only bites when a peer is disconnected outright while an entity changes — a rename, status change, or room edit. The returning peer keeps its stale copy until some later patch about that entity happens to arrive, and any peer that syncs from it inherits the stale copy.Reproducer shape: three TLS peers; C shuts down; A renames its agent and edits a room; C returns and reconnects. C still sees the old name and old room state, with no further patch coming to correct it.
Fix direction settled during the #23 investigation: per-entity monotonic versions. Every mutating store bumps the entity's version and embeds it in the entity record carried by patches and
SerialisedState; state_sync and patch application take the higher version (ties keep the existing union semantics for room members and subscribedRooms, which also keeps concurrent joins race-safe). Owner-authority merging was considered and rejected: a rejoining peer can carry an old copy of a third peer's entity and would clobber it.Also heals room-leave divergence, which the current member-union cannot (union only ever adds).
Found while verifying the persistent-identity work (#24) and the broadcast queue (#25).