# Why these patches don't commute?

**URL:** <https://discourse.pijul.org/t/why-these-patches-dont-commute/449>\
**Category:** Question\
**Created:** [December 13, 2019, 9:05pm UTC](https://discourse.pijul.org/t/why-these-patches-dont-commute/449 "2019-12-13T21:05:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [December 13, 2019, 9:05pm UTC](https://discourse.pijul.org/t/why-these-patches-dont-commute/449/1 "2019-12-13T21:05:36Z")

</div>

I thought I roughly understood the idea, but when I try to unrecorded [this patch](https://nest.pijul.com/tae/setup:master/patches/7o7p2hSgN3cEh3Zbhv66oeYXkdAqKWhz618wZWP5aH7j8FttAKmYv4BkszobgxpNasFnseJJzyL5JrkHCzsKLcad) I get an error because [this one](https://nest.pijul.com/tae/setup:master/patches/8BVkSat61mSihtjAnu2WHAdyLatXWwTYxQCpdNj4xB9FZSnbS5RqmAuj8FSxnTjDeJsrcbvqCqvxLuQqJTaetx86) depends on it. Why? 🧐

---

<div class="post-metadata">

**Author:** ![pmeunier](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/pmeunier/32/4_2.png) [@pmeunier](https://discourse.pijul.org/u/pmeunier)\
**Post date:** [December 14, 2019, 12:49pm UTC](https://discourse.pijul.org/t/why-these-patches-dont-commute/449/2 "2019-12-14T12:49:34Z")

</div>

Very good question. The reason is quite subtle: suppose Alice records a patch introducing a line in a paragraph, while Bob deletes that paragraph in parallel. What should happen when they pull each other’s patch?

- On Bob’s side, it’s easy: the context of Alice’s patch has disappeared, yielding a clear conflict, that is easy to indentify.
- However, on Alice’s side, things are more complicated, since she has no way to tell that situation apart from the situation where Bob already knows about her patch, and chose to delete all the lines around hers.

This could potentially break patch commutation. The way Pijul solves that is by making Bob’s patch (the patch starting with `8BVkSa…` in your example) depend on all the lines around the deletion, allowing Alice to tell whether Bob was aware of her patch when creating his patch.

A different solution would be to not consider missing contexts as conflicts. That would totally work, but would give a different semantics to Pijul.

---

<div class="post-metadata">

**Author:** ![tae](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.pijul.org/tae/32/81_2.png) [@tae](https://discourse.pijul.org/u/tae)\
**Post date:** [December 16, 2019, 6:27pm UTC](https://discourse.pijul.org/t/why-these-patches-dont-commute/449/3 "2019-12-16T18:27:41Z")

</div>

Thanks for the answer! Pretty clear
