Skip to main content

Module vault

Module vault 

Source
Expand description

Repository identity and the local map of resolved Cloud vaults.

The identity Cloud sees is stable_identity(project_identity(root)) salted by the org (identity_digest). It is the same for every checkout of a repository on every machine (.lean-ctx-id > git origin > manifests) and never contains a path, user name or credential.

Structs§

VaultMap
<data_dir>/cloud/projects.json: stable identity → resolved vault.
VaultRecord
A vault as Cloud resolved it, plus the local checkouts seen for it.

Functions§

connected_map
The vault map of the store as the connected Cloud and account see it (VaultMap::for_scope): no records of another Cloud or account (rc3-81 S1, rc4-2). Not connected: the map as it is on disk.
connected_scope
The scope (vault_scope) the store is connected to: None when it is not connected; an unreadable instance record gives a scope no stamped map matches (fail closed).
for_connected
connected_map for a map already loaded from the store.
identity_digest
hex(HMAC-SHA256(org_salt, stable_identity)).
in_scope
map as scope sees it (VaultMap::for_scope); None (not connected) leaves it as it is.
link_made_id
Whether a .lean-ctx-id value has the shape cloud link writes: 32 lowercase hex characters (16 random bytes).
map_in
The vault map as the Cloud and account at scope (vault_scope) see it, None when it belongs to another one (an enrollment elsewhere since the caller’s session was loaded). A sender then sends nothing and keeps its queue for the scope it was queued in (rc3-81, bd 39791 M1/M2).
normalize_git_url
github.com/acme/payments for every spelling of the same remote: scheme, credentials, .git suffix, scp syntax and host case removed.
project_identity
The machine-independent identity of the project at root, if it has one.
resolve_request
The resolve request for the project at root.
restore_root
Put the records of the checkout root back as they were in snapshot (the map before a change that was refused), under one hold of the map’s lock, and only while the map on disk and the snapshot belong to scope, the Cloud and account the snapshot was taken for (rc3-81, bd 39540 S-a, bd 39791 S1): records of other checkouts and an enrollment elsewhere since then are left as they are. Returns whether it was put back.
update_map
Load, change and save projects.json at data_dir under its state lock (rc3-81 S2), so a sync that resolves a checkout and an enrollment that switches the Cloud never write over each other. The file is written only when change changed the map; the lock is held for local file work only.
vault_scope
The scope a vault id is valid in (rc3-81, rc4-2, rc4-6): the Cloud at origin and the account (org) org_id on it, as one string so projects.json keeps its shape (the origin field): <origin>#org=<org_id>, the origin normalized like stored_origin. An empty org_id gives the origin alone.