oficina / docs Public
Local patches
Original crates.io yrs 0.23.5 package SHA-256: 197c2b4b298f35c3ba4d549884ac872a961112095b29f173ab45e3d5cf609018.
Only src/transaction.rs, src/block.rs, src/block_iter.rs, src/gc.rs and src/undo.rs differ from the published Rust source. On a yrs bump, check each patch below against the new release: drop it if upstream has it, re-apply it if not, and keep its regression tests either way.
Deletion backports (src/transaction.rs)
- Move the deletion scan outside the initial item-split guard so a range beginning at a garbage-collected block still deletes later live blocks. Adapted from upstream PR 614, commit
97095f2e27e4045002b656cec6347e9f9a989c89. - Store an unapplied deletion tail beginning at the known client state, rather than the original range start; this matches current upstream
apply_deleteand preserves deletion when missing inserts arrive later.
- Retain complete deletion ranges for clients whose first insert has not arrived yet, matching the upstream missing-client branch.
Regressions live in native/crdt/tests/rule_delta_convergence.rs, native/crdt/tests/delete_tail_review.rs, and the server core native-rule fixture tests.
Undo-kept children of a collected type (src/block.rs Item::gc, src/gc.rs)
Backport of upstream commit 0e5df000867d703cbc403feece4312900b954565 ("fix relation between Item::gc and keep flag", issues #667 and #676), first released in yrs 0.28.1. oficina/docs discussion #145, finding 1.
Item::gcno longer checks the keep flag.GCCollector::mark_in_scopeandmark_allcheck it for the top-level candidates instead, andcollect_markedreplaces every marked item.- So the children of a collected type are collected whatever their keep flag, as Yjs's
ContentType.gcdoes. Before, clearing the redo stack un-kept an item's whole parent chain (Item::keep(false)) while a sibling on the undo stack stayed kept; when a peer then deleted that parent, the parent's branch was freed and the kept child still pointed into it. The next snapshot panicked (slice.rs, "Could not get parent branch info for item") or, in WASM, read freed memory and wrote a struct a fresh document could not integrate. - Drop on a bump to yrs 0.28.1 or later.
Regressions: native/crdt/tests/gc_undo_kept.rs (the editor repro and upstream's own test on this API), native/crdt/tests/gc_undo_kept_fuzz.rs, and the browser replay native/crdt/src/bin/gc_undo_kept_probe.rs with native/scripts/check-gc-undo-kept-wire.mjs.
Local inserts into a deleted parent (src/block.rs ItemPtr::redo, src/transaction.rs TransactionMut::create_item, src/block_iter.rs BlockIter::insert_contents)
Local patch; upstream has the same behaviour since its integration refactor (0e450204ae, "refactored transactions and correlated apply update / integrate block logic", yrs 0.27), where TransactionMut::integrate_item deletes an item whose parent is deleted for every caller. oficina/docs discussion #145, finding 9.
Item::integrateanswers true when the new item's parent is deleted. The remote path (Update::integrate) then deletes the item, as Yjs'sItem.integratedoes for every insert, local or remote. The three local paths dropped the answer, so the inserting replica alone kept the item live: invisible under its deleted parent, but with a delete set no peer shared. Each now deletes the item after storing it, asUpdate::integratedoes.ItemPtr::redois how the editor reaches it: undo follows a deleted parent'sredonechain to its restored copy, which a peer may since have deleted.create_item(text, element and attribute inserts) andinsert_contents(array inserts) are patched for parity; the editor's commands address live nodes, so they are not known to be reachable from it.- Drop on a bump to yrs 0.27 or later, after checking
integrate_itemstill deletes for all three.
Regressions: native/crdt/tests/insert_into_deleted_parent.rs (the undo case, and every local insert path into a type a peer deleted; each fails without its patch). gc_undo_kept_fuzz.rs found the undo case at seed 42, and the engine branch's convergence_fuzz.rs at seeds 76 and 113. check-gc-undo-kept-wire.mjs checks Yjs deletes a local insert into a deleted parent.
Redo origins (src/block.rs ItemPtr::redo)
Local patch; neither upstream yrs (main, November 2026) nor Yjs 13.6.27 has it. oficina/docs discussion #145, found by gc_undo_kept_fuzz.rs at seed 98.
redofinds the restored item's neighbours by followingredonechains, and both can land on the same restored item: the left neighbour traces to it directly, the right one through an original whose restored copy starts there. Both libraries then integrate the item right after it locally, but write origins (after the end of the merged block that item now ends, before the item inside it) that every receiver resolves to a place before it. Yjs's ownredoItemandgetMissingdo the same (checked: Yjs's editor shows "Axz", a Yjs peer "Azx").- When the traced right neighbour is not to the right of the left one,
redonow names the item actually after the left one instead. The item still goes after the left neighbour, but local placement can change slightly. Before, the local integrate scanned from the left neighbour's right for conflicts and could step past siblings with the same origin from a lower client. Now nothing lies between the two neighbours, so it goes directly after the left one, which is where the origins put it on every receiver, Yjs's included. The walk that checks the right neighbour is linear in the parent's length only in this case; otherwise the neighbours are adjacent or the right one is absent. - Keep on a bump unless upstream has changed
redo's right-hand trace.
Regression: native/crdt/tests/insert_into_deleted_parent.rs, an_undo_whose_neighbours_trace_to_one_item_places_it_as_every_peer_does ("Azx" at the peer without the patch).
Redo order (src/undo.rs UndoManager::pop)
Local patch. oficina/docs discussion #145.
popcollected the items to restore in aHashSet<ItemPtr>and restored them in its iteration order, which depends on the process's random hash keys. Restoration order decides where restored items are placed relative to each other, so the same undo could come out differently from run to run: the redo-origins failure above appeared in about one run in four. Yjs restores in itsSet's insertion order, the order the deletions are found.- Items are now restored in the order the deletions are found, the
HashSetkept for membership. yrs's delete set iterates clients in a fixed order (ClientHasher); Yjs's is the order the deletions were made, so the order across clients can still differ from Yjs, but it no longer differs between runs. - Keep on a bump unless upstream has made the order deterministic.
Unchanged
Garbage collection remains enabled. Wire format, client IDs, undo policy, and sandbox limits are unchanged.
The registry package omits its license text; LICENSE is copied from the exact upstream VCS commit 3996e91df00acdb67334695944bc43f60627103f recorded in .cargo_vcs_info.json. Original attribution is retained.