Checking for missing updates prior to applying new ones

I have the following scenario. Document D1 has an update history of [U1…U5], which include some insertions, updates, deletes. Document D2 is aware of [U1…U3], but not yet [U4,U5].

On D1, updates [U6, U7] are made, and these are transmitted to D2. Attempting to apply them to D2, if I understand correctly, will “work” but none of the changes in [U6, U7] will be readable from D2 until [U4, U5] are applied to D2.

My question is: is there a way to know, prior to actually applying [U6, U7] to D2, that there are missing updates?

For context, what I’m trying to do is create a validation layer prior to irrevocably mutating the update history of D2, by applying prospective updates to a copy D2’. I would like to check that [U6, U7] will result in a valid state for D2’ before applying them to D2. If D2’ (being an exact copy of D2) is missing intermediate updates, then I will not have a resolved state that includes [U6, U7], and I will not be able to validate the resulting state. In this case I would like to initiate something like a sync to ensure that [U4…U7] are available to D2/D2’ so that validation can start at U4.

Thanks for any tips here, CRDTs are fascinating and Yjs is an amazing library, hoping to continue working with it.

Hi, welcome :).

You can check

Thanks Raine I’ll give that a shot tomorrow