Expand description
Concurrent edits of one shared fact across Instances (#286).
A claim’s node id comes from its text, so two Instances that give the
same fact (category, key) different values write two unlinked nodes.
Capture therefore gives every shared fact node a subject reference in
its applies_to: subject:<id>, a digest of (category, key) keyed
with the place id key pk_id (like the dedupe key: two engines of a
place reach the same id, nobody without the key can confirm a guessed
key, and no local key text leaves the machine).
Every sync then folds the place and groups the live, not superseded
fact nodes by subject. Two nodes of one subject are linked, and which
link follows from the save history: each node’s first seq in the log
and the causal_base of that save (how far its writer had folded when
it wrote the fact: the sync stamps fact saves with the position before
its own pull, so a value pulled in the same sync never counts as seen).
- Sequential edit: the later save’s writer had already folded the
earlier one (
causal_base >= seqof the earlier). The later value replaces it: its author queuesedge.add supersedesfrom the newer node to the older one, so the older value is served as outdated and the newer as current. - Concurrent edit: neither writer had seen the other’s save, or the
history of either is unknown. That is a conflict: one
edge.add contradictsbetween them, and delivery serves both as[conflicting]on every Instance.
The resolution is deterministic, the same on every Instance that folded
the same log: the edge id is a keyed digest of its kind and its pair, so
a second write names the same edge (the place refuses it, nothing
doubles), and exactly one Instance writes it (the replica’s
own_sources know the authors): the newer node’s author a
supersedes, the larger node’s author a contradicts, which runs from
the larger node id to the smaller one. Others never race it.
A node superseded in the place (or by a queued supersedes) is no
longer linked, and two nodes of one subject from the same checkout are
left to the capture lifecycle.
Structs§
- Inputs
- What
planreads besides the folded graph. - Link
- One link edge to write.
- Own
- A fact node this Instance authored (
own_sources).
Enums§
- Kind
- What a link between two values of one fact says.
Constants§
- MAX_
PER_ SYNC - The most conflict edges one sync queues (the rest follow next sync).
- SUBJECT_
PREFIX - Prefix of the subject reference in a fact’s
applies_to.
Functions§
- contradiction
- The deterministic conflict edge between
aandbin a place with id keypk_id. - derived
- The links between the values of one fact that every Instance derives on
read, from the folded graph and the save history alone: the same
resolution as
plan, before (or without) its edge reaching this replica. Without it, an Instance that pulled both values of a fact served them as two plain claims until the one Instance the resolution names had written its edge and this one had pulled it (#286). - detect
- Fold the replica, plan and queue this Instance’s conflict edges.
- inputs
Inputsfrom the replica: own fact sources, the save history and the pending queue.- plan
- The link edges this Instance writes for
graph, in a stable order (at mostMAX_PER_SYNC). - queue_
all - Queue the signed link edges of
planned(the sync push sends them), continuingclock. Returns how many it queued and the clock. - subject_
of - The subject reference a folded node carries, if any.
- subject_
ref - The subject reference of the fact (
category,key) in a place with id keypk_id:subject:+ 26 base32 characters. - supersession
- The deterministic
supersedesedge from the newer valuenewto the older valueoldin a place with id keypk_id.