How reliable is the clock as far as version comparison goes?
Well, this is an extremely complex problem and I have seen its effects with BTSync.
Basically, you can not rely upon a local clock on some node, simply because his clock is not necessarily synced to the global atomic clocks. Plus, you have to consider a time zone issue. I have seen up to 30% of all nodes differing in time by +/- one hour. I have also seen the nodes with different dates, not only hours, and nodes within +/- 10 minutes are quite common.
So, assume some node modifies some file. If file mtime is stamped in UTC format and its clock is synced to the atomic clock, then it is reliable. Otherwise, its file may look in the past or future, and, if no file hash is calculated to make sure that it is indeed a different file, then file mtime can not be trusted. So, the primary method of discovering the difference between the files on different nodes is the file hash.
Basically, unless you have some global reference of either clock or version, I do not see how could you resolve this conflict in a reliable way. And to have a global reference, you need to make sure that the reference node is always on line, 100% of the time, no matter what. Otherwise, the strategy may be to simply postpone the distribution and/or update of some specific file.
The problem with sync, especially in general public situations, is that you have no idea which nodes are on or off line, and even in private networks some of your devices may be off line, at least for some periods of time.
The way, for example, BTSync does it is that it syncs only files if the time difference between the nodes is less than 10 minutes (default that can be changed). Otherwise, it simply refuses to sync ANY files, regardless of anything else. I do not know their exact logic, but I know for fact that it has some bizarre and even destructive effects.
For example, I want to screw up your repo/share. ALL I have to do is to fully download it and then replace the contents of any files in the share with anything I want, including the truncation of the file to some one line bizarre string, and after that simply run a single line command to set the mtime on all the files somewhere in the future. As soon as I do that, I can destroy any cluster with total garbage, and that could be an immense amount of information, and it isn’t even clear how do you restore the healthy state of the cluster. Which node and file version do you trust?
That is why I proposed a while back a reference node and a master node concept. In case of doubt, only the reference node can be trusted to resolve the conflicts. The master node means that even if the reference node is off line, the master node is guaranteed to have an exact copy of ALL the files. The whole node is exactly the same as the reference node.
Furthermore, when you want some or any of nodes to be able to update others, behaving like master nodes and having the write permission to other nodes, then things get even hairier than that.
And it is much easier to assure the presence of the master nodes because there may be several of them on line. The question becomes is how do you pass the master node status to some file from the reference node, or do you assign the permanent master node status regardless of any specific files? This also may become not as simple as it might look if you consider all sorts of issues.
So, basically, the r/o nodes should not be allowed to update the master nodes or the reference nodes under ANY circumstances whatsoever. Otherwise, you do not have full control over the repo and things may and are likely to go wacky at some point.