Skip to main content

Module lines

Module lines 

Source
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.rs FILE): 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 to sync::REPLICAS members, 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.rs stamp), quarantine (origin::apply) and the daemon’s change fingerprint all cover what this lists.
merge
Appends the incoming lines path lacks, then settles lesson versions. Returns how many lines were new.
read
The distinct complete lines of path by 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’s id and version, but it is no version of a record, and borg folds every line of that log whatever their order.
travels
Whether line of the log file may be offered or stored under an origin of key, at now. Any line but an absorb’s or a message’s. An absorb or a release must be a line borg memory absorb and release could have written at now (borg absorb.rs written: the record borg folds, its note at most NOTE_CHARS, no other field, stamped no further ahead than SKEW_MS), whoever stamped it. A message or a seen line must be one borg msg.rs could have written (Line::parse), name key as its node (the member key its sender or reader wrote, as borg top names a remote node), and be fresh (msg.rs fresh_at: neither past TTL_MS nor stamped further ahead of this clock than SKEW_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.rs stays_here) never travels: it is for that machine alone.

Type Aliases§

Hash