Compact

@Serializable
data class Compact(val positions: Map<RgaId, RgaId>) : RgaOp<Nothing>

Records that the positions entries have been garbage-collected from the op-log.

The map carries each compacted id's predecessor at GC time (id → Insert.after). computeSequence uses this to reattach surviving successors to the nearest surviving ancestor (positional reroot, #293) rather than to RgaId.HEAD.

The ids that are purged are positions.keys. Merging two Compact ops via Rga.piece unions their positions maps — sound because a given id's after is fixed when its Insert was created, so two replicas always agree on the value.

Applying a Compact removes every Insert and Remove op whose id is in positions.keys. Receiving the same Compact twice is idempotent.

Constructors

Link copied to clipboard
constructor(positions: Map<RgaId, RgaId>)

Properties

Link copied to clipboard

Serialized in canonical key order (#1978): the map is built from a merge-ordered tombstone set, so two replicas at the same logical state hold equal Compact ops whose plain-map encodings differ. RgaOpSerializer — the wire path, via Rga.wireSerializer — applies the same CanonicalMapSerializer; the annotation covers the compiler-generated serializer a consumer reaches through Compact.serializer().