Grove.GC.Structural (Grove v0.1.1)
View SourceStructural 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:
- Empty tag sets mean no live adds exist for that element
- If a concurrent add arrives, it creates a new entry with new tags
- 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}