Skip to content

Conversation

@pzel
Copy link
Contributor

@pzel pzel commented Dec 8, 2025

I feel that in the existing code example, there is room for error of interpretation about conflict resolution.

Because we overwrite doc1 with the results of merge(doc1, doc2), it's unclear whether the result of merge(doc2, doc1) is influenced by the prior merge results or not.

I think it creates too much ambiguity when we pass in the modified doc1 as an input to the second merge. I caught myself thinking: "OH, so if doc1 := merge(doc1, doc2) was resolved by LWW, the values in doc1 are now newer than whatever we have in doc2, so it will automatically win again." I think that's not the intent of this section.

I propose storing the results of the two merges in fresh variables, to demonstrate that the order of arguments to merge does not affect the stability of winner selection.

I feel that in the existing code example, there is room for error of interpretation about  conflict resolution.

Because we overwrite doc1 with the results of merge(doc1, doc2), it's unclear that the result of merge(doc2, doc1) is influenced by the prior merge results or not.

I think it creates too much ambiguity when we pass in the modified `doc1` as an input to the second merge. I caught myself thinking: "OH, so if doc1 := merge(doc1, doc2) was resolved by LWW, the values in doc1 are now newer than whatever we have in doc2, so it will automatically win again." I think that's not the intent of this section.

I propose storing the results of the two merges in fresh variables, to demonstrate that the order of arguments to `merge` does not affect the stability of winner selection.
@ivanreese
Copy link
Member

Ah yeah, that's a great catch. Thank you so much!

@ivanreese ivanreese merged commit 39928de into automerge:main Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants