registry

package
v0.39.9 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package registry exposes the StackKits catalog (tools, module versions, curated stackkits) to the CLI in an OSS-safe way.

The registry has one publication authority: the Git checkout. CUE owns the facts it models; the checked-in embedded snapshot owns remaining catalog facts and the baked projection consumed by the CLI. No account, database, or hosted service participates in publication. Manual snapshots remain a migration-only compatibility shape.

Index

Constants

View Source
const (
	SourceCUE    = "cue"
	SourceManual = "manual"
)

Snapshot is the envelope serialized to registry_snapshot.json.

All nested slices are sorted deterministically (by primary key) so that two snapshots with identical content produce byte-identical JSON -- this keeps diffs readable and `goimports`-style re-bakes idempotent. Source values for Snapshot.Source. Constants instead of bare strings so callers agree on spelling.

View Source
const SnapshotVersion = 4

SnapshotVersion is the current schema version for registry_snapshot.json. Bump when the on-disk shape changes in an incompatible way.

v3 (2026-06-10, WS-0 truth-consolidation): adds ContentHash, ServiceGroups, ToolDefaultConfigs and the StackKit sub-resources (service selections, spec-profile hashes, and tool configs. Those fields now remain versioned in the Git-owned embedded artifact used by emit-cue and the hash-parity gates.

v4 (2026-06-13, CP-2 discovery-to-docs pipeline): extended Tool with vendor, license, documentation_url, repo_url, use_cases and a Content block carrying the published sk_tool_content sections. Only the retired Administration snapshot endpoint wrote those fields, and only emit-mintlify read them. They were removed on 2026-09-17. The version stays 4 because the CUE bake never emitted them, so every Git-owned v4 snapshot re-bakes unchanged.

Variables

View Source
var ErrNotFound = fmt.Errorf("registry: not found")

ErrNotFound signals an unknown slug. Callers use errors.Is.

Functions

func EmbeddedSnapshotBytes

func EmbeddedSnapshotBytes() []byte

EmbeddedSnapshotBytes returns the raw JSON bytes of the baked-in snapshot. Useful for `registry info` which prints them verbatim.

Types

type Client

type Client interface {
	Source() string
	Snapshot(ctx context.Context) (Snapshot, error)

	// Tool / Module / StackKit return the matching entry or
	// ErrNotFound when the slug is unknown to the registry.
	Tool(ctx context.Context, slug string) (Tool, error)
	Module(ctx context.Context, slug string) (Module, error)
	StackKit(ctx context.Context, slug string) (StackKit, error)
}

Client abstracts the public, embedded registry read path.

type Delivery

type Delivery struct {
	ManagedBy string `json:"managedBy,omitempty"`
}

type EmbeddedClient

type EmbeddedClient struct {
	// contains filtered or unexported fields
}

EmbeddedClient serves the baked-in snapshot. It is the OSS default and only registry backend linked into public builds.

func NewEmbeddedClient

func NewEmbeddedClient() *EmbeddedClient

NewEmbeddedClient loads the embedded snapshot eagerly so that downstream calls are trivial. Decode errors are captured and returned from every method so the caller sees them as soon as they use the client.

func (*EmbeddedClient) Module

func (c *EmbeddedClient) Module(_ context.Context, slug string) (Module, error)

Module looks up a module by slug.

func (*EmbeddedClient) Snapshot

func (c *EmbeddedClient) Snapshot(_ context.Context) (Snapshot, error)

Snapshot returns a copy of the embedded snapshot.

func (*EmbeddedClient) Source

func (c *EmbeddedClient) Source() string

Source returns "embedded".

func (*EmbeddedClient) StackKit

func (c *EmbeddedClient) StackKit(_ context.Context, slug string) (StackKit, error)

StackKit looks up a stackkit by slug.

func (*EmbeddedClient) Tool

func (c *EmbeddedClient) Tool(_ context.Context, slug string) (Tool, error)

Tool looks up a tool by slug.

type Module

type Module struct {
	Slug              string   `json:"slug"`
	DisplayName       string   `json:"display_name,omitempty"`
	Version           string   `json:"version"`
	Layer             string   `json:"layer,omitempty"`
	Description       string   `json:"description,omitempty"`
	ContractHash      string   `json:"contract_hash"`
	SupportedContexts []string `json:"supported_contexts,omitempty"`
	Core              bool     `json:"core,omitempty"`
}

Module is the CLI-visible projection of one released sk_module_version. ContractHash is the SHA256 parity anchor (ADR-0010 §Parity contract).

type Service

type Service struct {
	Key                     string   `json:"key"`
	DisplayName             string   `json:"display_name"`
	Description             string   `json:"description,omitempty"`
	ToolName                string   `json:"tool_name"`
	ModuleSlug              string   `json:"module_slug"`
	Role                    string   `json:"role,omitempty"`
	DefaultTool             string   `json:"default_tool,omitempty"`
	Alternatives            []string `json:"alternatives,omitempty"`
	LocalSlug               string   `json:"local_slug"`
	PublicSlug              string   `json:"public_slug"`
	LegacyAliases           []string `json:"legacy_aliases,omitempty"`
	IdentityPolicy          string   `json:"identity_policy"`
	OwnerProvisioningPolicy string   `json:"owner_provisioning_policy"`
	Icon                    string   `json:"icon,omitempty"`
	LogoURL                 string   `json:"logo_url,omitempty"`
	Badge                   string   `json:"badge,omitempty"`
	Layer                   string   `json:"layer,omitempty"`
	Section                 string   `json:"section,omitempty"`
	Order                   int      `json:"order,omitempty"`
	EnableVar               string   `json:"enable_var,omitempty"`
	GuideURL                string   `json:"guide_url,omitempty"`
	SetupPolicy             string   `json:"setup_policy,omitempty"`
	SetupActionLabel        string   `json:"setup_action_label,omitempty"`
	Delivery                Delivery `json:"delivery,omitempty"`
	BootstrapProvider       string   `json:"bootstrap_provider,omitempty"`
	Default                 bool     `json:"default"`
}

Service mirrors the CLI-visible projection of sk_service joined with the current StackKit binding. It intentionally separates user-facing service identity from tool/module implementation names.

type ServiceGroup

type ServiceGroup struct {
	Slug              string `json:"slug"`
	DisplayName       string `json:"display_name,omitempty"`
	LayerSlug         string `json:"layer_slug,omitempty"`
	SelectionType     string `json:"selection_type,omitempty"` // "single" | "multi"
	DefaultModuleSlug string `json:"default_module_slug,omitempty"`
	YAMLSection       string `json:"yaml_section,omitempty"` // "foundation" | "platform" | "application"
	YAMLKey           string `json:"yaml_key,omitempty"`
}

ServiceGroup mirrors sk_service_group: canonical service-group taxonomy plus the ADR-0014 yaml-section mapping consumed by kitio (WS-5).

type Snapshot

type Snapshot struct {
	// SchemaVersion pins the shape of this envelope. Must equal
	// SnapshotVersion at load time; mismatches fail-fast.
	SchemaVersion int `json:"schema_version"`

	// Source identifies where the snapshot was produced.
	// One of: "cue" (Git/CUE bake) or "manual" (migration fallback).
	Source string `json:"source"`

	// GeneratedAt is the UTC time the snapshot was baked.
	GeneratedAt time.Time `json:"generated_at"`

	// ContentHash is the SHA-256 (hex) over the canonical
	// catalog payload, excluding volatile envelope fields (generated_at,
	// content_hash itself). Two snapshots with identical
	// catalog content carry the same hash regardless of when or where they
	// were fetched. Empty for CUE-baked snapshots.
	ContentHash string `json:"content_hash,omitempty"`

	// Tools is the unified tool catalog (sk_tool).
	Tools []Tool `json:"tools"`

	// Services is the product-facing service catalog mirror (sk_service +
	// sk_stackkit_service). It carries canonical service keys, URL slugs,
	// legacy aliases, and owner/SSO readiness policy, but composition defaults
	// still come from CUE/StackKit contracts and must be parity-tested here.
	Services []Service `json:"services"`

	// Modules is the latest-version view of the module registry
	// (sk_module_version, one row per slug -- the "released" version).
	Modules []Module `json:"modules"`

	// StackKits is the curated composition catalog (sk_stackkit).
	StackKits []StackKit `json:"stackkits"`

	// ServiceGroups mirrors sk_service_group: the canonical service-group
	// taxonomy including the yaml_section/yaml_key mapping (ADR-0014) that
	// kitio consumes instead of hardcoded Go/TS maps (WS-5).
	ServiceGroups []ServiceGroup `json:"service_groups,omitempty"`

	// ToolDefaultConfigs mirrors sk_tool_default_config: the kit-agnostic
	// baseline config per tool (Phase B).
	ToolDefaultConfigs []ToolDefaultConfig `json:"tool_default_configs,omitempty"`
}

func EmbeddedSnapshot

func EmbeddedSnapshot() (Snapshot, error)

EmbeddedSnapshot returns a freshly decoded copy of the baked-in snapshot. The returned value is safe to mutate by the caller.

type StackKit

type StackKit struct {
	Slug        string           `json:"slug"`
	DisplayName string           `json:"display_name"`
	Description string           `json:"description,omitempty"`
	Layers      []string         `json:"layers,omitempty"`
	Modules     []StackKitModule `json:"modules"`

	// Version and ReleaseChannel mirror sk_stackkit (ADR-0018): the kit
	// version and its promotion channel ("edge" | "beta" | "stable").
	// The WS-2 release gate compares against the stable-channel truth.
	Version        string `json:"version,omitempty"`
	ReleaseChannel string `json:"release_channel,omitempty"`

	// ServiceSelections mirrors sk_stackkit_service_selection: which module
	// is selected (and which alternatives are allowed) per service group.
	ServiceSelections []StackKitServiceSelection `json:"service_selections,omitempty"`

	// SpecProfiles mirrors sk_stackkit_spec_profile (default/saved kinds
	// only): the drift-detection hashes generate/verify compare against.
	// The full definition stays in the Git-owned Kit CUE/YAML source.
	SpecProfiles []StackKitSpecProfile `json:"spec_profiles,omitempty"`

	// ToolConfigs mirrors sk_stackkit_tool_config: the kit-specific,
	// schema-validated config per service group + module.
	ToolConfigs []StackKitToolConfig `json:"tool_configs,omitempty"`
}

StackKit is a curated composition (sk_stackkit) with its module roster frozen at the version the kit was pinned against.

type StackKitModule

type StackKitModule struct {
	Slug    string `json:"slug"`
	Version string `json:"version,omitempty"`
	Role    string `json:"role,omitempty"` // "ingress", "identity", "app", ...
}

StackKitModule is a module-in-a-stackkit reference: slug + pinned module-version plus the role the module plays in the composition.

type StackKitServiceSelection

type StackKitServiceSelection struct {
	ServiceGroupSlug       string   `json:"service_group_slug"`
	Role                   string   `json:"role,omitempty"` // "required" | "recommended" | "optional"
	SelectedModuleSlug     string   `json:"selected_module_slug,omitempty"`
	AlternativeModuleSlugs []string `json:"alternative_module_slugs,omitempty"`
}

StackKitServiceSelection mirrors sk_stackkit_service_selection.

type StackKitSpecProfile

type StackKitSpecProfile struct {
	Slug               string `json:"slug"`
	Kind               string `json:"kind,omitempty"` // "default" | "saved"
	IsDefault          bool   `json:"is_default,omitempty"`
	SpecHash           string `json:"spec_hash,omitempty"`
	KitDefinitionHash  string `json:"kit_definition_hash,omitempty"`
	ModuleContractHash string `json:"module_contract_hash,omitempty"`
}

StackKitSpecProfile mirrors the hash-relevant subset of Legacy spec-profile projection. The materialized definition remains in the Git-owned Kit CUE/YAML source; this snapshot carries only parity anchors.

type StackKitToolConfig

type StackKitToolConfig struct {
	ServiceGroupSlug string          `json:"service_group_slug"`
	ModuleSlug       string          `json:"module_slug,omitempty"`
	ModuleVersion    string          `json:"module_version,omitempty"`
	Config           json.RawMessage `json:"config,omitempty"`
}

StackKitToolConfig mirrors sk_stackkit_tool_config: the validated config payload generate consumes as kit-level defaults (WS-2).

type Tool

type Tool struct {
	Slug        string   `json:"slug"`
	DisplayName string   `json:"display_name"`
	Category    string   `json:"category"`
	Layer       string   `json:"layer,omitempty"`
	Status      string   `json:"status"` // sk_tool.maturity: "unknown" | "experimental" | "beta" | "ga"
	Homepage    string   `json:"homepage,omitempty"`
	Description string   `json:"description,omitempty"`
	LogoURL     string   `json:"logo_url,omitempty"`
	ImageURL    string   `json:"image_url,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

Tool mirrors the subset of sk_tool that the CLI needs: identity + evaluation status. Vendor, license, content, vulnerability and changelog fields are not part of the embedded StackKits contract.

type ToolDefaultConfig

type ToolDefaultConfig struct {
	ToolSlug        string          `json:"tool_slug"`
	Config          json.RawMessage `json:"config,omitempty"`
	ConfigSchemaRef string          `json:"config_schema_ref,omitempty"`
}

ToolDefaultConfig mirrors sk_tool_default_config: kit-agnostic baseline config per tool. Copied into StackKitToolConfig when a tool joins a kit.

Jump to

Keyboard shortcuts

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