Module registry

Module registry 

Source
Expand description

Adapter registration lifecycle (M5-D2, REQ-INSTALL-4) — the node-local registered-adapter set under {SPT_HOME}/adapters/.

spt adapter add validates the manifest first (nothing is recorded for an invalid one), then records it (PRD R-INSTALL-4): a copy of the manifest for file_pull / avenue-less adapters (spt-core owns the bytes), a pointer back to the source tree for delegated ones (the adapter’s own updater owns its install; we re-read its manifest live so a delegated self-update never leaves a stale copy behind). One command and one dir for both kind = "harness" and kind = "shell".

Registration is node-local capability (may this node drive/launch the adapter), not subnet advertisement — discovery rides the registry/broadcast gates elsewhere. The registered set is the single source consumed by: creation-time adapter selection (auto-if-one/ask-if-many over hostable_types), shell discovery (D3d), and the R-UPD-5 self-update ripple.

spt adapter remove is a soft-deregister: the record stays with active = false, so new creation no longer offers the adapter while existing/live instances keep running off it. The manifest’s optional [update] uninstall template is returned to the caller to conduct once the adapter is quiesced — this module records state, it never execs. Re-adding a deregistered name re-activates it (refreshing the record).

Layout per adapter: adapters/<name>/record.toml (+ manifest.toml in copy mode). Records write atomically (REQ-HAZARD-EBUSY-RENAME stance via spt_store::atomic).

Structs§

AdapterRecord
One registered adapter’s durable record (adapters/<name>/record.toml).

Enums§

RecordMode
How the manifest is held: a copy under adapters/<name>/, or a pointer re-read from the source tree per load.
RegistryError
Registration failures — adapter-author-facing, so they carry the why.

Functions§

all_records
Every record under adapters/ (active and not — callers filter), sorted by name for a stable order. Tolerant: an unreadable entry is skipped, the rest still list (the stale-registry degrade stance).
create_local_profile
Create (or overwrite) a local profile for adapter from a sparse overlay TOML document. Refuses an invalid name, a name that shadows a shipped profile, an overlay that fails to parse, or one that — once merged onto the parent — breaks a manifest invariant or loosens a consent floor (tighten-only). Nothing is written unless every check passes.
delete_local_profile
Delete a local profile. Refuses a shipped profile name (adapter-owned, immutable) and errors if no local file exists.
deregister
Soft-deregister name: flip active = false (the record + any manifest copy stay — existing instances keep running off them). Returns the manifest’s optional [update] uninstall template for the caller to conduct once the adapter is quiesced (spt adapter remove’s optional second half); None = spt-core default cleanup. Idempotent on an already-inactive record.
get_string
Read a [strings] dot-path from an adapter option’s merged view — the spt adapter get-string <adapter-option> <key.path> resolver. Resolves the option (bare = parent, else shipped/local overlay) exactly as every other consumer, then dot-path-traverses the merged [strings] tree. Ok(None) = the key is absent (a clean “not set”, distinct from an unresolvable option).
load_local_overlay
The local profile overlay [Value] for <adapter>/profiles/<profile>.toml.
load_manifest
The record’s manifest: the held copy in copy mode, the live source tree in pointer mode (a delegated adapter’s self-updates are always honored).
load_record
One adapter’s record by name.
local_profile_names
Local profile names registered for adapter, sorted (drops unreadable entries — the tolerant-registry stance).
register
Register (or re-register) the adapter whose manifest lives at source (a directory containing manifest.toml, or the manifest path itself). Validate-first: an invalid manifest records nothing. Mode falls out of the [update] avenue — delegated ⇒ pointer, file_pull/absent ⇒ copy. Re-adding an existing name refreshes the record and re-activates a soft-deregistered one. Returns the record; the caller conducts install-is-first-update through the manifest’s [update] avenue.
registered
The active registered set with manifests resolved — the single source for creation-time adapter selection, shell discovery, and the R-UPD-5 ripple. A pointer-mode record whose source tree has vanished is skipped (tolerant), not fatal.
resolve_option
Resolve an adapter option (<adapter> or <adapter>:<profile>) to its record and complete, validated manifest — the single entry point every composite-addressing consumer calls. A bare name returns the parent unmodified (short-circuit). A profile is looked up shipped-first (the adapter’s [profiles.<name>]), then as a local overlay file; the two namespaces are disjoint (locals may not shadow shipped).
resolve_option_in
Resolve an adapter option against an already-loaded registered set — the daemon seam. registered() is called once per edge event, then every hosted shell is re-resolved against the in-memory slice rather than reloading each parent from disk. Same contract as resolve_option (split → parent lookup → overlay), but the parent comes from the slice; local overlays still read from adapters_dir. Returns the merged, validated manifest (the record already lives in the slice).
resolve_option_onto
Resolve an adapter option onto a caller-supplied parent manifest — the runtime-manifest seam (spt api --adapter <option> --manifest <file>). The parent comes from the adapter’s own manifest file (authoritative at runtime, possibly newer than the registry copy), not a registry load; the :<profile> segment of option is then overlaid: a shipped profile from the parent file’s own [profiles], a local one from adapters_dir. A bare option returns the parent unmodified. The caller has already matched the parent segment against parent.adapter.name.
set_local_string
Set a [strings] dot-path on a local profile’s overlay — the spt adapter set-string sugar. Edits only the node-local overlay file (profiles/<profile>.toml); a shipped profile name is refused (adapter-owned, immutable) and a missing local profile errors (create-profile first). The edited overlay is re-validated through the same create-time guards (manifest invariants + tighten-only floor) before it is written.