Skip to main content

Module ops

Module ops 

Source
Expand description

The bodies of the sync.* ops as pure functions (SPEC_USER_DATA_SYNC_LAYER §3.1, §4): hello, pull, push, members and join, over the log, the membership chains and the caller’s proven machine id. Nothing here opens a connection or sends anything: a request comes in, an answer goes out, and what a function may touch is what Ctx hands it. The transport (the remote-ops route on the LAN) is wired to these separately.

Every op starts with the same two checks: this install holds the computer’s sync lock (otherwise it answers nothing), and the caller is a current member of the collection it names (a stranger, and a collection this machine does not hold, get the same refusal). Both answers are capped: at the handler on the way out, and by check_pull_answer on the way in.

Structs§

Ctx
Everything an op may touch.
Held
What a machine holds of one collection.
JoinReq
KeysAns
KeysReq
Me
This machine as a member: its id and its signing key’s seed (held only while it holds the lock).
MembersAns
MembersReq
PendingJoin
A machine waiting for a person to confirm its join on this member.
PullAns
PullReq
PushAns
PushReq

Enums§

JoinNo
Why a joiner did not take the chain it was given.
Joined
OpError
Why an op did not run.

Constants§

AUTO_JOIN_KINDS
Kinds of collection whose joins may go ahead without a person confirming (a Vault never does yet).
MAX_BATCH_BYTES
Most bytes in one batch, counting each record’s body and a fixed amount for its header. One record larger than this goes alone (up to MAX_RECORD_BYTES).
MAX_BATCH_RECORDS
Most records in one pull answer or push request.
MAX_ENTRIES
Most entries of a membership chain one answer carries; a longer chain is not served until it is compacted.
MAX_NAMES
Most collections one hello may ask about, and most origins one vector may name.
MAX_PENDING
Most join requests one collection keeps waiting for a person.
MAX_WIRE_BYTES
The most bytes of JSON params a sync op takes: a batch at its largest as base64, its headers, and what is around them. A record too large for a push is pulled by the peer instead (an answer is not held to this).
PENDING_TTL_MS
How long a join waits for a person before it is dropped (the machine asks again).

Traits§

KeyDelivery
Seals the collection’s keys to a new member’s box key: one sealed key for each epoch the member needs.
Proof
Whether a machine asking to join is proven enough for a join without a person: pinned here for at least a minimum age, listed in the account’s directory, and hosted by an install whose certificate chain is the one remote writes already require. The transport supplies it.

Functions§

admit
The checks every op that reads or writes makes first (this install holds the lock, the caller is a current member), for a caller that has more to look up before the op itself: nothing about a collection (its kind, whether this build merges it) is told to a caller that fails them.
adopt
A joiner keeps the chain it took (take_join): the collection in the log, the chain in the store, and the log’s key epoch where the chain says it is.
approve
A person confirmed, on this member, that a waiting machine may join: the signed Add (the member then answers the machine’s next join with the chain and keys).
cap_bytes
Cuts a batch to the byte cap (a first record always stays): whether anything was cut.
change
A membership change signed by this machine and taken into its own chain (the key epoch moves too, for a removal): the entry to hand to the other members. Nothing is signed unless this install holds the lock.
check_pull_answer
The asker’s side of the cap: an answer over what was asked, or over the byte cap, is refused whole.
found
Founds a collection here: its first entry, signed by this machine, and the collection in the log.
hello
sync.hello: for each named collection the caller is a member of, the chain position, the key epoch and what this machine holds. A collection the caller is not a member of is left out, as if it did not exist.
join
sync.join: a machine asks to be added. The caller must be the machine the subject names. If it is already a member it is answered again (a retry after a person confirmed). Otherwise it joins at once only when the collection’s policy is auto_proven, the collection is of a kind that allows it and the caller is proven; any other join waits for a person to confirm on a member (approve).
keys
sync.keys: the collection’s keys a current member lacks (it learned of a removal, or lost one), sealed to it. A machine that is not a current member is given none, and never a key of an epoch the chain has not reached.
kind_of
may_seal
Whether this machine may seal a new record for the collection. Not while a removal at the chain’s head is contested: the key epoch it would seal at may be replaced by another’s.
members
sync.members: takes the entries a member offers (each one verified against the chain, so an entry no member signed is refused), and answers with the entries after the caller’s position. A machine that was removed may ask too, and learns up to its own removal.
pull
sync.pull: the records the caller lacks, capped in count and bytes.
push
sync.push: records from the caller (its own, or ones it forwards). A request over the caps is refused before anything is applied; each record is checked and applied on its own.
reissue
Writes again, at the collection’s current key epoch, what this machine wrote at an older epoch beyond the end its removal-of-another entry named (those writes are refused by the others): each record whose current state is one of them is opened with the key of its epoch and sealed with the current one. Returns how many were re-issued.
sync_epoch
Puts the log’s key epoch, and the end each remaining member had at each epoch left, exactly where the chain says (one removal moves it one epoch): in either direction, so a removal that lost a fork to another entry leaves nothing behind. Called after every change to a chain.
take_join
The joiner’s side: takes a chain only if every entry verifies, it lists this machine and at least one of its machine members is one this machine itself trusts. The peer that sent it is not taken on its word.