eclipsesource / eclipsesource/json-reconcile

1_4 (also 4_11) - delete with implicit index reordering and use (update) - conflict not detected

Open
#11 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Example Test Case:
Image

A conflict needs to be detected because the category edge is updated and on the other side it is deleted.

## Problem
Core Problem here with the differences:

Since I have no information anymore that `/package/classes/1` is actually Project now on the right side, I can not match it with `/package/classes/2/name` and therefore can not detect the conflict.

```js
// in base the classes are ordered like
{
"classes": [
{ "id": "Smart City" },
{ "id": "Category" },
{ "id": "Project" }
]
}

// right:
{
"classes": [
{ "id": "Smart City" },
{ "id": "Project" } // Project is now index 1
]
}

// left:
{
"classes": [
{ "id": "Smart City" },
{ "id": "Category" },
{ "id": "Project" } // // Project is index 2
]
}

// difference base-left includes:
{ "op": "update", "path": "/package/classes/2/name" }

// differences base-right includes:
{ "op": "delete", "path": "/package/classes/1" }
{ "op": "delete", "path": "/package/classes/1/references/0" } // this is the reference between Project and Category
// this is a patch like differences format
// index 1 deleted, so on the new index 1 is Project where a "delete" happen
```

This is the problem of jsondiffpatch, because goal of minimal diff. The differences are patch operations.
Means if index 0 got deleted, and there was an update at index 1, this elem is the new index 0, because from the first patch operation index 0 is already deleted.
Index change is not recorded, but on the other side this would also be a tradeoff because an index-change difference need to be recorded for every following object (which can be hundreds).

But this also means:
**Order of the differences matter !!**

---

## Similar case for 4_11,

index 0 class got deleted, and from class one the reference got deleted, but as a result, the patch operations are the following:
```js
{ "kind": "delete", "path": "/package/classes/0" },
{ "kind": "delete", "path": "/package/classes/0/references/0" }
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the 1_4 and 4_11 examples from the issue, focusing on conflict detection for ordered patch operations. Done means conflicts are detected when implicit index reordering makes an update and delete refer to the same logical object, while preserving the required operation order.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.