Expand description
A collective’s append-only logs as sets of content-addressed lines.
Every line of lessons.jsonl is addressed by its blake3 hash, so two
nodes compare what they hold without reading it, and a merge is a plain union: appending lines
the store lacks never rewrites or loses a line. Only complete JSON lines count, so a line a
hook is appending right now is picked up by the next sync rather than copied half-written.
Lessons are versioned in place (a consolidation appends the same id with version + 1) and
conscience::load keeps the last line per id. After a union the last line must therefore be
the winning version on every node, whatever order the lines arrived in: highest version, ties
(two nodes consolidated the same lesson concurrently) broken by the higher hash. settle
re-appends a winner that is not last; that repeats an existing line, so the hash set (and what
peers see) is unchanged.
Constants§
- ABSORBED
- The absorbs and releases of the collective’s lessons (
SYNCED, borg absorb.rsFILE): one line per id and command,{"id", "kind": "absorb" | "release", "ms", "by", "note"?, "version"?}. The mesh checks a line as borg reads it (travels), never what the note says. - REASONING
- Redacted reasoning excerpts behind git notes (
borg notes): replicated by their author tosync::REPLICASmembers, not reconciled with everyone (sync.rs, step 4). - SYNCED
- The logs a mesh syncs, relative to the collective’s store.
Functions§
- digest
- One hash for the whole set: equal digests mean there is nothing to exchange.
- hash
- logs
- The logs whose lines carry origins, in
home: the synced ones and reasoning. Stamping (origin.rsstamp), quarantine (origin::apply) and the daemon’s change fingerprint all cover what this lists. - merge
- Appends the
incominglinespathlacks, then settles lesson versions. Returns how many lines were new. - read
- The distinct complete lines of
pathby hash (empty if the file does not exist). - settle
- Makes the winning version of every versioned record the last line for its id (module doc).
Also after lines were removed (quarantine): the line that is now last may be an older version.
Not the absorbs (
ABSORBED): an absorb names its lesson’sidandversion, but it is no version of a record, and borg folds every line of that log whatever their order. - travels
- Whether
lineof the logfilemay be offered or stored under an origin ofkey, atnow. Any line but an absorb’s or a message’s. An absorb or a release must be a line borgmemory absorbandreleasecould have written atnow(borg absorb.rswritten: the record borg folds, its note at mostNOTE_CHARS, no other field, stamped no further ahead thanSKEW_MS), whoever stamped it. A message or a seen line must be one borg msg.rs could have written (Line::parse), namekeyas its node (the member key its sender or reader wrote, asborg topnames a remote node), and be fresh (msg.rsfresh_at: neither pastTTL_MSnor stamped further ahead of this clock thanSKEW_MS): a member’s forged node, or a far-future line that would outlive every prune, never reaches another member, and no node acknowledges for another’s sessions. A message to the sessions of its own node (local, msg.rsstays_here) never travels: it is for that machine alone.