Documentation
¶
Overview ¶
Package registry implements ADR-0009 §7: service distribution through registries that are themselves ensemble services, trusted by nothing but their E-address.
The wire protocol rides the platform's existing command envelope (COMMAND / COMMAND_RESULT — node→service request/response with correlation, timeouts, and the Tor fallback) rather than inventing a new one: arguments are JSON, the index reply carries a base64 SignedServiceDocument. The transport adds no trust requirements because the document is self-verifying against the subscribed address — the chain is address → Dilithium pub → IdentityBinding → ed25519 → index signature (identity.VerifyServiceDoc).
Package layout: this file is the shared protocol vocabulary; store.go is the registry-operator side (the published index as a yaml file); subscriptions.go + manager.go are the subscriber side (registries.yaml, the verified-doc cache, install-by-name resolution); host/ is the running registry service itself.
Index ¶
- Constants
- func CapabilitiesFromProto(p *apipb.CapabilitySummary) apps.Capabilities
- func CapabilitiesToProto(c apps.Capabilities) *apipb.CapabilitySummary
- func CompareVersions(a, b string) int
- func Etag(doc []byte) string
- func ParseSignedIndex(pinnedAddr string, sdocBytes []byte) (*apipb.RegistryIndex, error)
- func SaveSubscriptions(dataDir string, subs []Subscription) error
- func SubscriptionsPath(dataDir string) string
- type Artifact
- type CommandCaller
- type Entry
- type Hit
- type IndexReply
- type IndexRequest
- type Manager
- func (m *Manager) Add(ctx context.Context, address string) (*Status, error)
- func (m *Manager) LatestVersion(ctx context.Context, name string, refresh bool) (string, string)
- func (m *Manager) List(ctx context.Context, refresh bool) ([]Status, error)
- func (m *Manager) Remove(address string) error
- func (m *Manager) Resolve(ctx context.Context, name, version string) (*Resolved, error)
- func (m *Manager) Search(ctx context.Context, query string, refresh bool) ([]Hit, error)
- type PublishReply
- type PublishRequest
- type Release
- type Resolved
- type Status
- type Store
- type Subscription
- type YankRequest
Constants ¶
const ( CommandIndex = "registry-index" CommandPublish = "registry-publish" CommandYank = "registry-yank" )
Command names the registry service declares in its manifest. Prefixed so /help against a registry reads unambiguously and nothing collides with daemon built-ins.
const IndexFileName = "index.yaml"
IndexFileName is the registry's source of truth inside its data dir — a plain, operator-editable yaml file. The running service composes the signed RegistryIndex document from it (and notices external edits by content, so hand-editing the file works without a restart).
const SubscriptionsFileName = "registries.yaml"
SubscriptionsFileName is the daemon's ordered registry list at <data-dir>/registries.yaml — mutable runtime state, persisted-file-wins (the admin_key.hex pattern), not flags. Order is load-bearing: install-by- name resolves first-match in this order, apt-sources style.
Variables ¶
This section is empty.
Functions ¶
func CapabilitiesFromProto ¶
func CapabilitiesFromProto(p *apipb.CapabilitySummary) apps.Capabilities
CapabilitiesFromProto is CapabilitiesToProto's inverse (the subscriber renders a consent prompt from index data before any download).
func CapabilitiesToProto ¶
func CapabilitiesToProto(c apps.Capabilities) *apipb.CapabilitySummary
CapabilitiesToProto maps the manifest-shaped capability declaration onto the wire summary shown pre-install.
func CompareVersions ¶
CompareVersions orders two semver-ish strings: -1, 0, +1. Numeric dot-segments compare numerically; a malformed segment falls back to string comparison for that position. Good enough for "newest release" — the registry orders, it does not enforce a versioning religion.
func Etag ¶
Etag identifies an index document's content: the hex sha256 of the raw RegistryIndex bytes (not the signed envelope, so a pure re-sign of unchanged content keeps its etag and subscribers skip the transfer).
func ParseSignedIndex ¶
func ParseSignedIndex(pinnedAddr string, sdocBytes []byte) (*apipb.RegistryIndex, error)
ParseSignedIndex verifies a SignedServiceDocument against the pinned registry address and unmarshals its RegistryIndex. This is the ONLY way index bytes become trusted data on the subscriber side — both the network fetch and every cache read go through it.
func SaveSubscriptions ¶
func SaveSubscriptions(dataDir string, subs []Subscription) error
SaveSubscriptions writes the list atomically (tmp + rename).
func SubscriptionsPath ¶
SubscriptionsPath resolves the registries.yaml location under a data dir.
Types ¶
type Artifact ¶
type Artifact struct {
URL string `json:"url" yaml:"url"`
SHA256 string `json:"sha256,omitempty" yaml:"sha256"`
Size int64 `json:"size,omitempty" yaml:"size,omitempty"`
}
Artifact is one platform's release artifact in the publish protocol and the index store.
type CommandCaller ¶
type CommandCaller interface {
CallServiceCommand(ctx context.Context, address, name, args string) (text string, ok bool, err error)
}
CommandCaller invokes one command on a service by E-address and returns its reply. The api.Server satisfies it (CallServiceCommand) — connection establishment, the command envelope, correlation, and timeouts are all its problem. ok=false is a service-rendered failure (the text is the reason).
type Entry ¶
type Entry struct {
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Releases []Release `yaml:"releases,omitempty"` // newest first
}
Entry is one published service.
type Hit ¶
type Hit struct {
Name string
Description string
Version string
Registry string
Capabilities apps.Capabilities
}
Hit is one search result from the subscribed indices.
type IndexReply ¶
type IndexReply struct {
Etag string `json:"etag"`
Unchanged bool `json:"unchanged,omitempty"`
Doc string `json:"doc,omitempty"`
}
IndexReply is the JSON reply text of a registry-index command. Exactly one of Unchanged / Doc is meaningful: Unchanged echoes a still-current etag, Doc carries the base64-encoded SignedServiceDocument bytes.
type IndexRequest ¶
type IndexRequest struct {
Etag string `json:"etag,omitempty"`
}
IndexRequest is the JSON args of a registry-index command. An empty etag always returns the full document.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the subscriber side: the ordered subscription list, the verified index cache, and name resolution for install-by-name.
func NewManager ¶
func NewManager(dataDir string, caller CommandCaller) *Manager
NewManager builds a Manager rooted at the daemon data dir. caller may be nil until wired (offline operations — cache reads, list, remove — work without it).
func (*Manager) Add ¶
Add validates, fetches, verifies, and persists a new subscription. The fetch must succeed — subscribing to an address that doesn't serve a verifiable index is a typo, not a state to persist.
func (*Manager) LatestVersion ¶
LatestVersion reports the newest published version of name across the subscriptions (first match wins, like Resolve). Cache-only unless refresh — ListInstalledServices' update check refreshes once up front.
func (*Manager) List ¶
List reports every subscription. refresh=true re-fetches each index first; failures degrade to the cache (offline browse) and surface in Err.
func (*Manager) Resolve ¶
Resolve walks the subscriptions in order and returns the first entry matching name (and version, when non-empty) with an artifact for this platform. Refresh is attempted per registry, degrading to the verified cache — installs keep working when a registry is briefly unreachable, and integrity never depends on freshness (the hash pin travels with the doc).
type PublishReply ¶
PublishReply is the JSON reply text of a successful registry-publish or registry-yank command.
type PublishRequest ¶
type PublishRequest struct {
Name string `json:"name"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
Capabilities apps.Capabilities `json:"capabilities"`
Platforms map[string]Artifact `json:"platforms"`
}
PublishRequest is the JSON args of a registry-publish command — one release of one service. Capabilities reuse the package-manifest shape so the publisher can lift them straight from ensemble-service.yaml. An artifact with an empty sha256 asks the REGISTRY to fetch the URL and compute hash + size itself (the "ingest" path that keeps CI publishing to a one-liner).
type Release ¶
type Release struct {
Version string `yaml:"version"`
Capabilities apps.Capabilities `yaml:"capabilities"`
Platforms map[string]Artifact `yaml:"platforms"` // key: "<os>-<arch>"
}
Release is one published version of a service.
type Resolved ¶
type Resolved struct {
Name string
Version string
URL string
SHA256 string
Size int64
Registry string // the subscription that blessed it
Capabilities apps.Capabilities
// AlsoIn lists OTHER subscriptions publishing the same name — the
// apt-style collision warning (first match still wins).
AlsoIn []string
}
Resolved is a name resolved through the subscriptions into an installable, hash-pinned artifact.
type Store ¶
type Store struct {
Description string `yaml:"description,omitempty"`
Entries []Entry `yaml:"entries,omitempty"`
}
Store is the on-disk index of everything a registry publishes.
func (*Store) AddRelease ¶
func (s *Store) AddRelease(req PublishRequest) error
AddRelease appends (or replaces) one version of one service. Releases stay sorted newest-first; republishing an existing version overwrites it (CI re-runs must be idempotent).
func (*Store) RemoveRelease ¶
RemoveRelease yanks one version (or, with version == "", the whole entry).
type Subscription ¶
type Subscription struct {
Address string `yaml:"address"`
AddedAt time.Time `yaml:"added_at,omitempty"`
}
Subscription is one subscribed registry. The address is the entire trust decision (it pins the registry's Dilithium key — ADR-0009 §7); there is no separate signing key to manage.
func LoadSubscriptions ¶
func LoadSubscriptions(dataDir string) ([]Subscription, error)
LoadSubscriptions reads the ordered registry list; a missing file means no subscriptions.
type YankRequest ¶
YankRequest is the JSON args of a registry-yank command. An empty version removes the whole entry.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package host is the registry service runtime (ADR-0009 §7): a daemon child (or dev-run process) that registers over RegisterService, serves the signed index through the registry command protocol, and accepts publisher-gated releases.
|
Package host is the registry service runtime (ADR-0009 §7): a daemon child (or dev-run process) that registers over RegisterService, serves the signed index through the registry command protocol, and accepts publisher-gated releases. |