Grove.GC.Structural (Grove v0.1.1)

View Source

Structural garbage collection for CRDTs.

This strategy removes structurally dead entries without requiring coordination between replicas. It is always safe to apply.

What Gets Cleaned

  • ORSet: Entries with empty tag sets (element was removed)
  • ORMap: Empty key entries + orphaned values not in keys

Safety

Structural cleanup is safe because:

  1. Empty tag sets mean no live adds exist for that element
  2. If a concurrent add arrives, it creates a new entry with new tags
  3. No replica coordination required - deterministic based on local state

Example

set = ORSet.new(:a) |> ORSet.add("x") |> ORSet.remove("x")
{:ok, cleaned, stats} = Grove.GC.Structural.collect(set)
# stats => %{removed_entries: 1, remaining_entries: 0}