Update conflict logic for offline entities #698
Labels
backend
Requires a change to the API server
entities
Multiple Encounter workflows
needs testing
Needs manual testing
Problem description
In #669, I thought that offline entities wouldn't requires us to change much (if anything) about the
conflict
property. Specifically, I thought:However, it's looking like that isn't the ideal behavior after all. Even if the current server version is the previous version from the branch, the update being processed may conflict with a separate update between the trunk version and the previous version. For example:
As things are currently implemented, v3 will be marked as a soft conflict because there was an update between it and its base version. However, v4 is not marked as a conflict because it immediately follows its base version (the previous version from the branch). There are a few issues that stem from the fact that v4 is not marked as a conflict:
allReceived
logic in theEntityConflictTable
component). If v4 is not marked as a conflict, then the only version that is a conflict is v3, and only the one property that v3 updated will be shown in the table. That means that the property that v2 and v4 updated will not be shown in the table. Upon seeing the conflict summary table, the user might double-check all the properties listed in the table. If we don't list the property that v2 and v4 updated, the user might not realize that it also warrants a double-check.Expected behavior
As I wrote on Slack:
In the example above, v3 is not contiguous with the trunk version (v1), because v2 is between the two. The same is true of v4. This rule would cause v4 to be marked as a conflict.
I think this is a good rule, though I am slightly concerned about the ramifications. I would guess that there are places in Backend and/or Frontend where we consider something a conflict if and only if it does not immediately follow its base version (
version !== baseVersion + 1
). If we implement the proposed rule, that logic won't be true anymore. If anything needs to change in this area about Frontend, I think I could do so quickly.I also wrote the following on Slack, but I no longer think that it's always true:
I do think this is true if the updates are processed in order. However, if an update is force-processed out of order, it may be a conflict even if an update that follows it is not a conflict. For example:
In this example, even though v3 and v4 are from the same branch, and v3 is a conflict, we do not expect v4 to be a conflict. v2, v3, and v4 are all contiguous with the trunk version (v1): there's no conflict with some interweaving update from another source, as in the first example above. To summarize: if the versions from an offline branch were force-processed out of order, then even if all the versions are contiguous with their trunk version, it may be the case that an earlier version from the branch is a conflict while a later version is not.
So when evaluating whether an offline update being processed is a conflict, I think the question should be, "Are there any versions after the trunk version that are from outside the branch?" The question should not be, "Was the previous version in the branch a conflict?"
In terms of figuring out whether the conflict is soft or hard (which properties are conflicting, if any), I'm not so sure about the logic. We can't just compare the offline update being processed against its trunk version, because if two updates from the same branch change the same property and are processed in the correct order, there should not be a conflict: in that case, everything happened in sequence, not in parallel. It's only if there was an update from outside the branch that changed the same property as an update from the branch that there should be a hard conflict, as in the first example above.
The text was updated successfully, but these errors were encountered: