Skip to main content

Module repository

Module repository 

Source
Expand description

Which repository and which runtime a mesh participant is — independently of any path.

A repository’s mesh identity must be the same on every machine that holds a clone of it and different for every other repository. The path of the git directory (what server.status digests to tell checkouts apart) is neither: a macOS checkout path and the Linux checkout path of the same clone are one repository with two spellings. So the mesh identity is derived from the repository’s root commits — content every full clone shares and no unrelated repository has — or, when a person declares one, from the declared identity (cooperation.repository), which is what a shallow clone needs and what separates a fork that should not cooperate with its origin.

A runtime is one server of one node: one per checkout. Its id is a digest of the checkout id, so a restarted server of the same checkout is the same runtime (a new instance of it), and two worktrees of one machine are two runtimes.

use majordomus_cli::mesh::repository::{declared, of_root_commits, runtime_id};

let a = of_root_commits(&["b".repeat(40), "a".repeat(40)]);
let b = of_root_commits(&["a".repeat(40), "b".repeat(40)]);
assert_eq!(a.id, b.id, "the order git lists roots in does not matter");
assert_ne!(a.id, declared("majordomus").unwrap().id);
assert_eq!(runtime_id("checkout-1").len(), 16);

Structs§

MeshRepositoryIdentity
A repository’s mesh identity, carried by every advertisement, link and event, together with the account of where it came from. The detail exists so that a person told two checkouts are not the same repository can see what each one was derived from instead of comparing two opaque digests.

Enums§

MeshRepositoryBasis
What the repository identity was derived from, which a reader needs in order to judge it: an identity taken from the root commits is a fact about the history two clones share, while a declared one is a decision somebody made, and only the second can be changed by editing a file.

Functions§

declared
The identity a declared value yields: what a shallow clone, which cannot see its own root commit, must use, and what separates a fork that should not cooperate with the repository it came from. The value is a name chosen by the people who run the mesh, not a digest, so it is bounded and must not be empty — an empty declaration would put every repository that forgot to fill it in on one mesh.
of_root_commits
The identity a set of root commits yields. The roots are treated as a set rather than a list, because git rev-list makes no promise about the order it prints them in and two machines that disagreed about that order would decide they held different repositories; for the same reason the same root named twice is one root.
resolve
Resolve the mesh identity of the repository at root: the declared value when there is one; otherwise its root commits, refusing a shallow clone (whose “root” is only where its history was cut) and a repository with no commit yet.
runtime_id
The runtime slot of a checkout: 16 hex of a digest of its checkout id. A runtime is one server of one node, so this is what makes a restarted server the same runtime as the one it replaced — a new instance of it rather than a new participant — while two worktrees of one machine stay two runtimes that can claim against each other.