Pijul for application data sync

Currently afaik Pijul stores directories, text files, and maybe opaque binaries. I am wondering if it can be used for structured application data.

For example, currently I keep some app data in a json file, which naive text-based merging won’t do properly.

Is it possible to merge structured data with Pijul?

Like GitHub - automerge/automerge: A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically..

Hi! First, automerge doesn’t handle conflicts, which is the central point of Pijul.

One could write a diff algorithm that splits the data into words instead of lines: this would already make JSON merging better (hopefully). Other than that, diffing trees is not an easy algorithmic problem.

For json you’d probably want a slightly more aggressive variant of git word-diff: instead of splitting on whitespace, you’d split on every transition between alphanumeric and non-alphanumeric characters.

Or put the “word” boundaries inside every bracket or brace and after(before?) every comma and colon, but that’s less general-purpose :stuck_out_tongue:

(And for well-behaved operations on trees in general, yeah at minimum you’d want to extent the pijul “x line is after y line” model to include “x line is child of y line, and comes before any line z that is after but not a descendant of x”. Idk whether there are any indentation-based heuristics doing this sort of thing already.)