registry

package
v0.0.0-...-de45444 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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).

View Source
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

func CompareVersions(a, b string) int

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

func Etag(doc []byte) string

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

func SubscriptionsPath(dataDir string) string

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

func (m *Manager) Add(ctx context.Context, address string) (*Status, error)

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

func (m *Manager) LatestVersion(ctx context.Context, name string, refresh bool) (string, string)

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

func (m *Manager) List(ctx context.Context, refresh bool) ([]Status, error)

List reports every subscription. refresh=true re-fetches each index first; failures degrade to the cache (offline browse) and surface in Err.

func (*Manager) Remove

func (m *Manager) Remove(address string) error

Remove drops a subscription and its cached index.

func (*Manager) Resolve

func (m *Manager) Resolve(ctx context.Context, name, version string) (*Resolved, error)

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).

func (*Manager) Search

func (m *Manager) Search(ctx context.Context, query string, refresh bool) ([]Hit, error)

Search matches query (substring, case-insensitive, "" = everything) against name + description across every subscription's verified index. First-subscription entries shadow later ones with the same name, matching Resolve's first-match-wins.

type PublishReply

type PublishReply struct {
	Etag    string `json:"etag"`
	Entries int    `json:"entries"`
}

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.

func (*Resolved) Label

func (r *Resolved) Label() string

Label renders the install.yaml provenance for a resolved artifact. The "registry:" prefix is what InstallRecord.Verified keys off.

type Status

type Status struct {
	Address     string
	Description string
	Entries     int
	FetchedAt   time.Time
	Err         string
}

Status is one subscription's health as reported by List/Add.

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 LoadStore

func LoadStore(path string) (*Store, error)

LoadStore reads the index store; a missing file is an empty registry.

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

func (s *Store) RemoveRelease(name, version string) error

RemoveRelease yanks one version (or, with version == "", the whole entry).

func (*Store) Save

func (s *Store) Save(path string) error

Save writes the store atomically (tmp + rename).

func (*Store) ToProto

func (s *Store) ToProto(now time.Time) *apipb.RegistryIndex

ToProto composes the wire index document from the store.

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

type YankRequest struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL