Added
HubRecord, StoredTombstone and ElementWrite types.
tombstoneRetentionMs on createSyncServer (default 7 days) for the default
MemoryHubBackend; passing it together with backend throws. MemoryHubBackend takes the same
option. Non-positive or non-finite values throw a RangeError.
Changed (breaking)
HubBackend replaces get and apply with getRecord(room, id) (element, tombstone or
undefined) and applyElement(room, write, expected), an atomic compare-and-set on the stored
record’s { version, editor } that returns { ok: true } or { ok: false, current }.
snapshot(room) returns { elements, tombstones }.
- Connections that send
capabilities with protocolVersion below 2 are closed with 4406.
Frames sent before capabilities are validated as protocol 2. Authority connections are
unaffected.
- Element ops are now written, then published, then delivered (previously published, then
applied). A conflicting concurrent write restarts the op from the read, up to 3 attempts, so a
server plugin’s
process may run up to 3 times for one op; keep side effects in broadcast and
corrections. If publishing fails after the write, the op is still delivered locally and
handleMessage rejects.
- Stale ops, and versions more than 1,000,000 above the stored one, get a correction sent to the
sender only.
- Removes and clears leave tombstones that keep the element’s owner, audience and remover on the
server. When
authorize is configured, only the owner or the remover may re-create a tombstoned
id (so the remover can undo); without authorize, ownership is not enforced.
clear tombstones every element at its version + 1; each recipient gets only the tombstones it
may read. Snapshots carry the tombstones the viewer may read.
- Client element ops claiming
editor: 'hub', and clears sent as from: 'hub', are dropped.
- Hub-authored removes (hide on audience change, corrections) carry
editor: 'hub' and a version.
- Peer floor
@fieldnotes/core raised to >=0.93.0; depends on @fieldnotes/sync 0.28.0.
Migration guide
Custom HubBackend implementations must implement getRecord, applyElement and the new
snapshot shape, write atomically only when the stored record’s version and editor equal
expected (absent editor equals absent; null: no record may exist; a clear’s expected map
holds { version, editor } per element), store tombstones, and drop expired ones when building a
snapshot. Server plugins must tolerate process running more than once per op.