Some thoughts...
- What about putting the
typein theContent-Typefield? Something likex-crdt-g-set-v1 - What's the rationale for representing things as a hash with lists as values instead of two hashes (in the OR and LWW set for example)? This to me seems closer to how it'll be represented in code (or at least how I've chosen to do with knockbox).
On JSON vs. Protobuf:
JSON has the advantage of easily being used in the browser, so you could actually use the browser's timestamp for some of the operations. This can be useful if for a single key, the single browser is the main actor doing writes. JSON also works easily with javascript mapreduce. If size is a concern, I'd be curious to see the size difference between compressed (snappy maybe?) JSON and Protobuf. I'm not saying Protobuf is a bad choice, just things to consider.
I was aiming for this originally, but I think composability may be more important. If we place type hints in the structure, you can walk any json object recognizing crdt types for merge:
{
'name': {'type': 'lww-register', ...},
'following': {'type': '2p-set', ...},
...
}
So, I would vote for optional subtype params for indicating the JSON object can be parsed with CRDT types inside.
{
element [[insert-tag1, insert-tag2], [remove-tag1]]
}
Might need to adapt to sets for large numbers of inserts and deletes, but that's a metaprogramming issue.
JSON vs Protobuf:
Why not both? I plan to export a .proto file for these types as well; you can drop them into your objects wherever. Downside is you can't type the sub-object, so I guess we'd have to leave the elements, tags, etc. as binary. We also have to standardize issues like string equality, sort orders, etc., instead of just "do whatever ecmascript does".