piece

open override fun piece(other: Rga<V>): Rga<V>

Merge two replicas' op-logs. The result is the idempotent union — both replicas converge to the same toList after piece.

This satisfies the Quilted lattice laws:

  • Idempotent: a.piece(a) == a (set union with itself)

  • Commutative: a.piece(b) == b.piece(a) (set union is commutative)

  • Associative: a.piece(b).piece(c) == a.piece(b.piece(c)) (set union)

Any RgaOp.Compact ops in the union are applied eagerly so that Insert/Remove ops already GC'd on one peer do not re-inflate the op-log on merge.

Derived caches are merged incrementally — no full O(ops) rescan on the merged result.