Merging #199
Labels
No labels
A-build
A-cli
A-core
A-design
A-edn
A-ffi
A-query
A-sdk
A-sdk-android
A-sdk-ios
A-sync
A-transact
A-views
A-vocab
P-Android
P-desktop
P-iOS
bug
correctness
dependencies
dev-ergonomics
discussion
documentation
duplicate
enhancement
enquiry
good first bug
good first issue
help wanted
hygiene
in progress
invalid
question
ready
size
speed
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: greg/mentat#199
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I thought I'd capture some notes around merging. There's more discussion in the wiki and in my paper notebooks!
If we allow users to establish multiple initial timelines — that is, to work offline from scratch on more than one device, and then to sign in later to the same account — we will need to support merges of current state.
That is: given a timeline of states
A -> B -> C
and a timeline of statesX -> Y -> Z
, produceM(C, Z)
which, in the simplest (totally disjoint) case is equivalent toC + Z
.This is not the same thing as attempting to rebase (
X -> Y -> Z + 𝛿A + 𝛿B + 𝛿C
); it's possible for conflicts to occur between intermediate states that would be resolved in aggregate, and it's also not correct in a theoretical sense to imply even an approximate happened-after relationship.This kind of merge is a three-way merge from the empty shared root. There are other kinds of merges we might consider: e.g., a long-lived divergence from a non-empty shared earlier state.
I sketched out how I think this might work:
av
pairs, take the remotee
andtx
for thatav
, renaming local identifiers. This is essentially discarding local duplicates. Idents are a special case of this, and need to be done first in order to resolve attributes! Now we have no uniqueness conflicts. There should be noe
conflicts (because we renumbered). This is our smushing step. Each time we rewrite an entity that is used elsewhere in thev
position we need to iterate until we converge, because the new localav
might yield another newe
. Once this step is complete we have fully smushed: all of our entities that can be linked via a unique-identity path to a value will have been unified.ea
pairs, look for a conflict between the two datoms tables and resolve according to rules. Resolving a conflict might mean taking the remote value, which might require further smushing.INSERT OR IGNORE
into remote. Synthesize a single merge tx if desired: using a single tx gives us more formal definition of a merge, but loses history (and either renders meaningless or discards tx metadata). We could point back to txids from the merge tx. Using multiple txes preserves granularity but obscures ordering, unless we reify multiple transaction logs.