From 4c6b3146b5107b9f1269ebe4c5bba198b4ce284c Mon Sep 17 00:00:00 2001 From: Logan Tibbetts Date: Mon, 16 Mar 2026 08:35:00 -0500 Subject: [PATCH 1/2] Fix for potential cyclical reference creation in RGAs --- ron-rdt/CHANGELOG.md | 5 +++++ ron-rdt/lib/RON/Data/RGA.hs | 4 ++-- ron-rdt/ron-rdt.cabal | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ron-rdt/CHANGELOG.md b/ron-rdt/CHANGELOG.md index 95f76bbd..b213809e 100644 --- a/ron-rdt/CHANGELOG.md +++ b/ron-rdt/CHANGELOG.md @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0) and this project adheres to [Compatible Versioning](https://github.com/staltz/comver). +## [0.12.1] - 2026-03-16 +* Added some duplicate operation removal to `vertexListFromOps` +* Changed `applyPatch` to prefer new operations over existing ones when + updating the `HashMap UUID VertexListItem`. + ## [0.12] - 2022-03-11 - Added `Editable` typeclass which generalizes RON.Data.RGA.edit diff --git a/ron-rdt/lib/RON/Data/RGA.hs b/ron-rdt/lib/RON/Data/RGA.hs index 75a70b30..ca5ea914 100644 --- a/ron-rdt/lib/RON/Data/RGA.hs +++ b/ron-rdt/lib/RON/Data/RGA.hs @@ -119,7 +119,7 @@ vertexListToOps v@VertexList {..} = go listHead listItems in itemValue : rest vertexListFromOps :: [Vertex] -> Maybe VertexList -vertexListFromOps = foldr go mempty +vertexListFromOps = foldr go mempty . nubBy (\Op{opId = opIdA} Op{opId = opIdB} -> opIdA == opIdB) where go v@Op{opId} vlist = Just VertexList{listHead = opId, listItems = vlist'} where @@ -276,7 +276,7 @@ applyPatch parent patch targetItems = case parent of Nothing -> patch Just next -> VertexList next targetItems <> patch let item' = item {itemNext = Just next'} - pure $ HashMap.insert parent item' targetItems <> newItems + pure $ HashMap.insert parent item' newItems <> targetItems reapplyRemovalsToState :: (RgaRep, PatchSet) -> Maybe (RgaRep, PatchSet) reapplyRemovalsToState (RgaRep rstate, ps@PatchSet {..}) = do diff --git a/ron-rdt/ron-rdt.cabal b/ron-rdt/ron-rdt.cabal index ceb17b46..7f6c9b85 100644 --- a/ron-rdt/ron-rdt.cabal +++ b/ron-rdt/ron-rdt.cabal @@ -1,7 +1,7 @@ cabal-version: 2.2 name: ron-rdt -version: 0.10 +version: 0.12.1 bug-reports: https://github.com/ff-notes/ron/issues category: Distributed Systems, Protocol, Database From 948fb77b71612679791c4445cb22249f2ba91429 Mon Sep 17 00:00:00 2001 From: Logan Tibbetts Date: Mon, 16 Mar 2026 08:51:13 -0500 Subject: [PATCH 2/2] Build fixes --- ron-rdt/lib/RON/Data/LWW.hs | 1 + ron-rdt/lib/RON/Data/ORSet/Experimental.hs | 1 + ron-rdt/lib/RON/Data/RGA.hs | 1 + 3 files changed, 3 insertions(+) diff --git a/ron-rdt/lib/RON/Data/LWW.hs b/ron-rdt/lib/RON/Data/LWW.hs index 5387f3e6..a2099e0d 100644 --- a/ron-rdt/lib/RON/Data/LWW.hs +++ b/ron-rdt/lib/RON/Data/LWW.hs @@ -9,6 +9,7 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} -- | LWW-per-field RDT module RON.Data.LWW ( diff --git a/ron-rdt/lib/RON/Data/ORSet/Experimental.hs b/ron-rdt/lib/RON/Data/ORSet/Experimental.hs index d8864232..31d6cb31 100644 --- a/ron-rdt/lib/RON/Data/ORSet/Experimental.hs +++ b/ron-rdt/lib/RON/Data/ORSet/Experimental.hs @@ -5,6 +5,7 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} module RON.Data.ORSet.Experimental ( ORSet, diff --git a/ron-rdt/lib/RON/Data/RGA.hs b/ron-rdt/lib/RON/Data/RGA.hs index ca5ea914..58cf3cbe 100644 --- a/ron-rdt/lib/RON/Data/RGA.hs +++ b/ron-rdt/lib/RON/Data/RGA.hs @@ -48,6 +48,7 @@ import qualified Data.HashMap.Strict as HashMap import Data.Map.Strict ((!?)) import qualified Data.Map.Strict as Map import qualified Data.Text as Text +import Data.List (nubBy) import RON.Data.Internal (MonadObjectState, Editable (..),