Skip to main content

Module sync_links

Module sync_links 

Source
Expand description

An entry’s link ids on several machines. A link id is the opaque name a deep link gives a Vault entry (agentmux://vault/entry/<link id>): it says nothing about the entry and each machine gives one on first use. A link made on one machine of a shared Vault has to open the entry on the others, so the ids travel in the entry’s sealed body.

The build guarantees:

  • When two machines each gave the same entry an id before they first synced, the entry keeps both: one is its own id, the other an alias, and a link made with either opens the entry on both machines.
  • An id is never reassigned: one that names another entry here, or that named an entry that was removed, is not taken for this one.
  • The set is small and bounded (MAX_LINKS) and the same on every machine whatever order the records arrive in.
  • A machine keeps the id it gave an entry as that entry’s own: it never changes under a link it showed.

Pure functions over ids: the store tells which entry owns an id and which ids were retired through LinkOwners.

Structs§

Links
The link ids of one entry on this machine.

Constants§

MAX_LINKS
The most ids an entry keeps, its own and its aliases together.

Traits§

LinkOwners
What the store knows of link ids, besides this entry’s own.

Functions§

is_link_id
Whether s has the shape of a link id: the prefix and 16 lowercase letters and digits. Anything else in a received body is dropped.
settle
The ids of entry_id after a record for it arrived carrying incoming: what this machine had, plus the ids it did not have, except those it must not take. An id held by another entry here, or retired, is refused; so is anything that does not have the shape of an id. The result does not depend on the order records arrive in: the aliases are kept in sorted order and cut to the bound.