Skip to content

Instantly share code, notes, and snippets.

@whilo
Created November 5, 2013 16:27
Show Gist options
  • Save whilo/7321697 to your computer and use it in GitHub Desktop.
Save whilo/7321697 to your computer and use it in GitHub Desktop.
CRDT braindump
;; Example repository-format for automatic server-side synching (p2p-web)
;; commutative merging must be possible, it is (almost) a converging and commutative distributed data type(?)
#_{:uuid "blib" ;; used to ensure universal identity on repo creation (cannot conflict)
:schema {:type "http://github.com/ghubber/geschichte" ;; might not change, if it does warn and drop merge
:version (max v1 v2)} ;; internal only, allows update to server side synching software
:public (or p1 p2) ;; might only turn to true, always false initially, allows public access to repo meta-data, no strong safety, all values are still distributed!; if false only read access from user itself allowed; must be true for pull-requests
:causal-order {12344 #{3774 23} ;; use uuids as commit ids, unionize, no conflicts, removal impossible
3774 #{12}
23 #{12}
12 #{}}
:branches {"master" #{12344} ;; conflict possible -> each lca + union, >1 marks conflict
"back75664" #{23}}
:head "back75664" ;; conflict possible -> use time-stamp as heuristic(!)
:last-update (max ts1 ts2) ;; not used for critical fields (e.g. synching decisions)
:pull-requests {"test1@mail.com" {"master" {:backways {}
:cut #{}}}}} ;; unionized, filtered by value
;; if not in causal-order keys; if empty remove
;; if >1 conflict, try to resolve with lca; should be avoided by applications, if not ask user
;; 'test@mail.com' is place of remote-metadata, 4588 as head requested, branch-data not transferred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment