Skip to main content

Module sync_merge

Module sync_merge 

Source
Expand description

What the Vault does when a record arrives from another machine (docs/specs/SPEC_VAULT_SHARED_ACROSS_MACHINES_LAN_AND_CLOUD_2026_11_01.md sections 6.2 to 6.5): the answer the sync layer asks of an adapter, Applied, KeptLocal or Conflict(both).

A value is never merged and never lost to a clock. When two machines change an entry before either has seen the other’s change, the later version becomes current and the other is kept, as a version called “changed on at the same time” that is not pruned after 7 days. A delete is a version like any other: apart from a change, the later of the two is current and the other is kept, so the answer is the same on every machine in whatever order the records arrive. A rotation in progress is never overwritten, nor deleted until it ends. Only the tags are merged, as a union.

Every function is pure over versions and tags: no store, no clock, no network. The records’ bodies stay sealed in super::sync_seal; what is decided here needs only their versions.

Structs§

Change
A record arriving from another machine, as far as the merge needs to know it.
Held
What this machine holds of the same record.

Enums§

Decision
The adapter’s answer to the layer (spec 6.3).
Kept
The state of the version that did not become current.
Side
Which of two versions is the one every machine uses from now on.

Functions§

merge
What to do with change when this machine holds held (None, or no versions, if it has never had the record).
only_here
After a full resync: the records only this machine has (mine, against theirs, the ids every other member holds). They are shown to the person as “Only on this machine: keep or delete”, never brought back or deleted silently.
union_tags
a’s tags, then those of b that a does not have.