Documentation
¶
Overview ¶
Package starmap provides the main entry point for the Starmap AI model catalog system. It offers a high-level interface for managing AI model catalogs with explicit synchronization, event hooks, and provider synchronization capabilities.
Starmap wraps the underlying catalog system with additional features including: - Explicit, idempotent synchronization with provider APIs - Event hooks for model changes (added, updated, removed) - Thread-safe access to an immutable canonical catalog - Flexible configuration through functional options - Support for multiple data sources and merge strategies
Example usage:
// Create a starmap instance with default settings
sm, err := starmap.New()
if err != nil {
log.Fatal(err)
}
// Register event hooks
sm.OnModelAdded(func(model catalogs.Model) {
log.Printf("New model: %s", model.ID)
})
// Get the current immutable catalog
catalog := sm.Catalog()
model, err := catalog.FindModel("gpt-4o")
if err != nil {
log.Fatal(err)
}
// Manually trigger a dry run (read-only; no store required)
result, err := sm.Sync(ctx, sync.WithProvider("openai"), sync.WithDryRun(true))
if err != nil {
log.Fatal(err)
}
// Configure mutation with an explicit writable generation store
store, err := catalogstore.NewFilesystem("./catalog")
if err != nil {
log.Fatal(err)
}
sm, err = starmap.New(
WithCatalogStore(store),
WithCatalogExportPath("./catalog-export"),
)
Package starmap provides a unified AI model catalog system with automatic updates, event hooks, and support for multiple storage backends.
Index ¶
- Constants
- type CatalogPublishedEvent
- type CatalogPublishedHook
- type CatalogReadiness
- type CatalogState
- type Client
- func (c *Client) Catalog() *catalogs.Catalog
- func (c *Client) CurrentCatalogState() CatalogState
- func (c *Client) CurrentGeneration(ctx context.Context) (catalogstore.Generation, error)
- func (c *Client) CurrentGenerationID() string
- func (c *Client) Generation(ctx context.Context, id string) (catalogstore.Generation, error)
- func (c *Client) HookStats() HookDeliveryStats
- func (c *Client) OnCatalogPublished(fn CatalogPublishedHook)
- func (c *Client) OnModelAdded(fn ModelAddedHook)
- func (c *Client) OnModelRemoved(fn ModelRemovedHook)
- func (c *Client) OnModelUpdated(fn ModelUpdatedHook)
- func (c *Client) Readiness() CatalogReadiness
- func (c *Client) Save(opts ...save.Option) error
- func (c *Client) Sync(ctx context.Context, opts ...sync.Option) (*sync.Result, error)
- func (c *Client) Update(ctx context.Context) error
- type EmbeddedBootstrapInfo
- type HookDeliveryStats
- type ModelAddedHook
- type ModelRemovedHook
- type ModelUpdatedHook
- type Option
- func WithCatalogExportPath(path string) Option
- func WithCatalogStore(store catalogstore.Store) Option
- func WithEmbeddedBootstrapMaxAge(maxAge time.Duration) Option
- func WithEmbeddedBootstrapMaxSizeBytes(maxSizeBytes int64) Option
- func WithEmbeddedCatalog() Option
- func WithRemoteServerAPIKey(apiKey string) Option
- func WithRemoteServerOnly(url string) Option
- func WithRemoteServerURL(url string) Option
- func WithUpdateFunc(fn UpdateFunc) Option
- type ReadinessIssue
- type UpdateFunc
Constants ¶
const ( ReadinessIssueCatalogUnavailable = "catalog_unavailable" // ReadinessIssueEmbeddedBootstrapFuture means embedded metadata is dated in the future. ReadinessIssueEmbeddedBootstrapFuture = "embedded_bootstrap_future" // ReadinessIssueEmbeddedBootstrapStale means the configured age budget was exceeded. ReadinessIssueEmbeddedBootstrapStale = "embedded_bootstrap_stale" // ReadinessIssueEmbeddedBootstrapOversize means the configured size budget was exceeded. ReadinessIssueEmbeddedBootstrapOversize = "embedded_bootstrap_oversize" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogPublishedEvent ¶ added in v0.1.0
type CatalogPublishedEvent struct {
GenerationID string
SyncRunID string
Sequence uint64
Catalog *catalogs.Catalog
}
CatalogPublishedEvent identifies one durably committed immutable catalog. Catalog is safe to retain and share across goroutines.
type CatalogPublishedHook ¶ added in v0.1.0
type CatalogPublishedHook func(CatalogPublishedEvent) error
CatalogPublishedHook is called after a catalog generation is durably committed and atomically published.
type CatalogReadiness ¶ added in v0.1.0
type CatalogReadiness struct {
Ready bool `json:"ready"`
Embedded EmbeddedBootstrapInfo `json:"embedded_bootstrap"`
Issues []ReadinessIssue `json:"issues,omitempty"`
}
CatalogReadiness reports whether the current immutable catalog is safe to serve and includes embedded-bootstrap generation evidence.
type CatalogState ¶ added in v0.1.0
CatalogState atomically pairs the current immutable catalog with its logical generation identity for generation-scoped caches and responses.
type Client ¶ added in v0.0.15
type Client struct {
// contains filtered or unexported fields
}
Client manages an immutable canonical catalog, explicit synchronization, persistence, and event hooks. It owns no scheduling goroutine or cadence.
func (*Client) CurrentCatalogState ¶ added in v0.1.0
func (c *Client) CurrentCatalogState() CatalogState
CurrentCatalogState returns one atomic catalog/generation pair.
func (*Client) CurrentGeneration ¶ added in v0.1.0
func (c *Client) CurrentGeneration(ctx context.Context) (catalogstore.Generation, error)
CurrentGeneration returns the exact immutable generation currently published by this client. The embedded bootstrap is returned before durable mutation.
func (*Client) CurrentGenerationID ¶ added in v0.1.0
CurrentGenerationID returns the logical identity of the currently published catalog. Before the first durable mutation, this is the embedded bootstrap ID.
func (*Client) Generation ¶ added in v0.1.0
func (c *Client) Generation(ctx context.Context, id string) (catalogstore.Generation, error)
Generation returns one retained immutable generation by ID.
func (*Client) HookStats ¶ added in v0.1.0
func (c *Client) HookStats() HookDeliveryStats
HookStats returns a lock-free snapshot of callback delivery health.
func (*Client) OnCatalogPublished ¶ added in v0.1.0
func (c *Client) OnCatalogPublished(fn CatalogPublishedHook)
OnCatalogPublished registers a callback for durable catalog publication.
func (*Client) OnModelAdded ¶ added in v0.1.0
func (c *Client) OnModelAdded(fn ModelAddedHook)
OnModelAdded registers a callback for when models are added.
func (*Client) OnModelRemoved ¶ added in v0.1.0
func (c *Client) OnModelRemoved(fn ModelRemovedHook)
OnModelRemoved registers a callback for when models are removed.
func (*Client) OnModelUpdated ¶ added in v0.1.0
func (c *Client) OnModelUpdated(fn ModelUpdatedHook)
OnModelUpdated registers a callback for when models are updated.
func (*Client) Readiness ¶ added in v0.1.0
func (c *Client) Readiness() CatalogReadiness
Readiness evaluates catalog availability and configured embedded-bootstrap age/size budgets without performing I/O.
func (*Client) Save ¶ added in v0.1.0
Save persists the current catalog to disk using the catalog's native save functionality.
type EmbeddedBootstrapInfo ¶ added in v0.1.0
type EmbeddedBootstrapInfo struct {
Active bool `json:"active"`
ManifestVersion uint64 `json:"manifest_version"`
GenerationID string `json:"generation_id"`
GeneratedAt time.Time `json:"generated_at"`
AgeSeconds int64 `json:"age_seconds"`
SchemaVersion uint64 `json:"schema_version"`
PayloadChecksum string `json:"payload_checksum"`
PayloadSizeBytes int64 `json:"payload_size_bytes"`
MaximumAgeSeconds int64 `json:"maximum_age_seconds,omitempty"`
MaximumSizeBytes int64 `json:"maximum_size_bytes,omitempty"`
}
EmbeddedBootstrapInfo reports the exact offline generation embedded in the binary and the budgets applied while it remains active.
type HookDeliveryStats ¶ added in v0.1.0
type HookDeliveryStats struct {
Completed uint64
Failures uint64
Panics uint64
Dropped uint64
LastLatency time.Duration
MaxLatency time.Duration
}
HookDeliveryStats reports isolated callback delivery health.
type ModelAddedHook ¶
ModelAddedHook is called when a model is added to the catalog.
type ModelRemovedHook ¶
ModelRemovedHook is called when a model is removed from the catalog.
type ModelUpdatedHook ¶
ModelUpdatedHook is called when a model is updated in the catalog.
type Option ¶
type Option func(*options) error
Option is a function that configures a Starmap instance.
func WithCatalogExportPath ¶ added in v0.1.0
WithCatalogExportPath configures an optional editable YAML catalog tree for import and explicit materialization. It is not the durable catalog database.
func WithCatalogStore ¶ added in v0.1.0
func WithCatalogStore(store catalogstore.Store) Option
WithCatalogStore configures the writable generation store used by non-dry sync, manual, remote, and scheduled catalog updates. Read-only access and dry runs do not require a store.
func WithEmbeddedBootstrapMaxAge ¶ added in v0.1.0
WithEmbeddedBootstrapMaxAge fails readiness while the active catalog is the embedded bootstrap and its generation age exceeds maxAge.
func WithEmbeddedBootstrapMaxSizeBytes ¶ added in v0.1.0
WithEmbeddedBootstrapMaxSizeBytes fails readiness while the active embedded bootstrap canonical payload exceeds maxSizeBytes.
func WithEmbeddedCatalog ¶ added in v0.0.15
func WithEmbeddedCatalog() Option
WithEmbeddedCatalog configures whether to use an embedded catalog. It defaults to false, but takes precedence over WithCatalogExportPath if set.
func WithRemoteServerAPIKey ¶ added in v0.0.15
WithRemoteServerAPIKey configures the remote server API key.
func WithRemoteServerOnly ¶
WithRemoteServerOnly configures Client.Update to use only the versioned remote manifest and immutable generation snapshot contract at url.
func WithRemoteServerURL ¶ added in v0.0.15
WithRemoteServerURL configures a versioned remote API base URL, for example https://starmap.example.com/api/v1, without changing the update source. Use WithRemoteServerOnly to make Client.Update fetch exclusively from that server.
func WithUpdateFunc ¶ added in v0.1.0
func WithUpdateFunc(fn UpdateFunc) Option
WithUpdateFunc configures an explicit context-aware update implementation.
type ReadinessIssue ¶ added in v0.1.0
ReadinessIssue is one stable machine-readable reason a client is not ready.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
starmap
command
Package main provides the entry point for the starmap CLI tool.
|
Package main provides the entry point for the starmap CLI tool. |
|
starmap-bootstrap-manifest
command
Command starmap-bootstrap-manifest atomically refreshes embedded generation metadata only when canonical catalog bytes changed.
|
Command starmap-bootstrap-manifest atomically refreshes embedded generation metadata only when canonical catalog bytes changed. |
|
starmap-catalog-release
command
Command starmap-catalog-release stages the verified embedded generation as immutable catalog release assets.
|
Command starmap-catalog-release stages the verified embedded generation as immutable catalog release assets. |
|
starmap-embedded-budget
command
Command starmap-embedded-budget emits and enforces checked-in catalog freshness, size, and coverage measurements for CI.
|
Command starmap-embedded-budget emits and enforces checked-in catalog freshness, size, and coverage measurements for CI. |
|
starmap-modelsdev-promote
command
Command starmap-modelsdev-promote validates and atomically promotes one downloaded models.dev payload for the embedded catalog generation workflow.
|
Command starmap-modelsdev-promote validates and atomically promotes one downloaded models.dev payload for the embedded catalog generation workflow. |
|
starmap/app
Package app provides the application context and dependency management for the starmap CLI.
|
Package app provides the application context and dependency management for the starmap CLI. |
|
starmap/cmd/auth
Package auth provides cloud provider authentication helpers for Starmap.
|
Package auth provides cloud provider authentication helpers for Starmap. |
|
starmap/cmd/authors
Package authors provides the authors resource command.
|
Package authors provides the authors resource command. |
|
starmap/cmd/completion
Package completion provides shell completion management commands.
|
Package completion provides shell completion management commands. |
|
starmap/cmd/deps
Package deps provides commands for managing external dependencies required by data sources.
|
Package deps provides commands for managing external dependencies required by data sources. |
|
starmap/cmd/embed
Package embed provides commands for exploring the embedded filesystem.
|
Package embed provides commands for exploring the embedded filesystem. |
|
starmap/cmd/models
Package models provides the models resource command and subcommands.
|
Package models provides the models resource command and subcommands. |
|
starmap/cmd/providers
Package providers provides the providers resource command and subcommands.
|
Package providers provides the providers resource command and subcommands. |
|
starmap/cmd/serve
Package serve provides HTTP server commands for the Starmap CLI.
|
Package serve provides HTTP server commands for the Starmap CLI. |
|
starmap/cmd/update
Package update provides the update command implementation.
|
Package update provides the update command implementation. |
|
starmap/cmd/validate
Package validate provides catalog validation commands.
|
Package validate provides catalog validation commands. |
|
internal
|
|
|
application
Package application provides the application interface for Starmap commands.
|
Package application provides the application interface for Starmap commands. |
|
attribution
Package attribution provides model-to-author mapping functionality across multiple providers.
|
Package attribution provides model-to-author mapping functionality across multiple providers. |
|
attribution/matcher
Package matcher provides a unified interface for pattern matching using glob and regex patterns.
|
Package matcher provides a unified interface for pattern matching using glob and regex patterns. |
|
auth
Package auth provides authentication checking for AI model providers.
|
Package auth provides authentication checking for AI model providers. |
|
auth/adc
Package adc handles Google Application Default Credentials.
|
Package adc handles Google Application Default Credentials. |
|
bootstrap
Package bootstrap verifies the catalog generation embedded in the binary.
|
Package bootstrap verifies the catalog generation embedded in the binary. |
|
bootstrapmanifest
Package bootstrapmanifest derives embedded generation identity from canonical catalog bytes without rewriting unchanged generations.
|
Package bootstrapmanifest derives embedded generation identity from canonical catalog bytes without rewriting unchanged generations. |
|
catalog/pipeline
Package pipeline owns catalog sync orchestration behind *starmap.Client.Sync.
|
Package pipeline owns catalog sync orchestration behind *starmap.Client.Sync. |
|
catalog/query
Package query provides shared catalog list/detail query behavior.
|
Package query provides shared catalog list/detail query behavior. |
|
cli/alerts
Package alerts provides a structured system for status notifications.
|
Package alerts provides a structured system for status notifications. |
|
cli/completion
Package completion provides shared utilities for completion management.
|
Package completion provides shared utilities for completion management. |
|
cli/constants
Package constants provides shared constants for CLI commands.
|
Package constants provides shared constants for CLI commands. |
|
cli/embed
Package embed provides utilities for working with the embedded filesystem.
|
Package embed provides utilities for working with the embedded filesystem. |
|
cli/emoji
Package emoji provides symbol constants for CLI output.
|
Package emoji provides symbol constants for CLI output. |
|
cli/filter
Package filter provides model filtering functionality for starmap commands.
|
Package filter provides model filtering functionality for starmap commands. |
|
cli/format
Package format provides formatters for command output.
|
Package format provides formatters for command output. |
|
cli/globals
Package globals provides shared flag structures and utilities for CLI commands.
|
Package globals provides shared flag structures and utilities for CLI commands. |
|
cli/hints
Package hints provides formatting for hints in different output formats.
|
Package hints provides formatting for hints in different output formats. |
|
cli/notify
Package notify provides context detection for smart hint generation.
|
Package notify provides context detection for smart hint generation. |
|
cli/provider
Package provider provides common provider operations for CLI commands.
|
Package provider provides common provider operations for CLI commands. |
|
cli/table
Package table provides common table formatting utilities for CLI commands.
|
Package table provides common table formatting utilities for CLI commands. |
|
deps
Package deps provides dependency checking and management for sources.
|
Package deps provides dependency checking and management for sources. |
|
embedded/openapi
Package openapi embeds the OpenAPI 3.0 specification files for the Starmap HTTP API.
|
Package openapi embeds the OpenAPI 3.0 specification files for the Starmap HTTP API. |
|
embeddedbudget
Package embeddedbudget measures and enforces checked-in catalog budgets.
|
Package embeddedbudget measures and enforces checked-in catalog budgets. |
|
providers/anthropic
Package anthropic provides a client for the Anthropic API.
|
Package anthropic provides a client for the Anthropic API. |
|
providers/clients
Package clients provides provider client registry functions.
|
Package clients provides provider client registry functions. |
|
providers/google
Package google provides a unified, dynamic client for Google AI APIs (AI Studio and Vertex AI).
|
Package google provides a unified, dynamic client for Google AI APIs (AI Studio and Vertex AI). |
|
providers/openai
Package openai provides a unified, dynamic client for OpenAI-compatible APIs.
|
Package openai provides a unified, dynamic client for OpenAI-compatible APIs. |
|
providers/testhelper
Package testhelper provides utilities for managing testdata files in provider tests.
|
Package testhelper provides utilities for managing testdata files in provider tests. |
|
server
Package server provides HTTP server implementation for the Starmap API.
|
Package server provides HTTP server implementation for the Starmap API. |
|
server/cache
Package cache provides an in-memory caching layer for the HTTP server.
|
Package cache provides an in-memory caching layer for the HTTP server. |
|
server/events
Package events provides a unified event system for real-time catalog updates.
|
Package events provides a unified event system for real-time catalog updates. |
|
server/events/adapters
Package adapters provides transport-specific implementations of the Subscriber interface.
|
Package adapters provides transport-specific implementations of the Subscriber interface. |
|
server/handlers
Package handlers provides HTTP request handlers for the Starmap API.
|
Package handlers provides HTTP request handlers for the Starmap API. |
|
server/middleware
Package middleware provides HTTP middleware for the Starmap API server.
|
Package middleware provides HTTP middleware for the Starmap API server. |
|
server/params
Package params provides HTTP request parameter parsing for API handlers.
|
Package params provides HTTP request parameter parsing for API handlers. |
|
server/response
Package response provides standardized HTTP response structures and helpers for the Starmap API server.
|
Package response provides standardized HTTP response structures and helpers for the Starmap API server. |
|
server/sse
Package sse provides Server-Sent Events support for real-time updates.
|
Package sse provides Server-Sent Events support for real-time updates. |
|
server/websocket
Package websocket provides WebSocket support for real-time catalog updates.
|
Package websocket provides WebSocket support for real-time catalog updates. |
|
sources/providers
Package providers implements the provider-backed catalog source.
|
Package providers implements the provider-backed catalog source. |
|
utils/ptr
Package ptr provides utility functions for creating pointers to values.
|
Package ptr provides utility functions for creating pointers to values. |
|
pkg
|
|
|
authority
Package authority manages source authority for catalog data reconciliation.
|
Package authority manages source authority for catalog data reconciliation. |
|
catalogartifact
Package catalogartifact defines the deterministic distribution format for immutable Starmap catalog generations.
|
Package catalogartifact defines the deterministic distribution format for immutable Starmap catalog generations. |
|
catalogdistribution
Package catalogdistribution provides the versioned hosted catalog distribution contract used by starmap.agentstation.ai and Starport clients.
|
Package catalogdistribution provides the versioned hosted catalog distribution contract used by starmap.agentstation.ai and Starport clients. |
|
catalogmeta
Package catalogmeta provides shared catalog metadata definitions used across Starmap packages.
|
Package catalogmeta provides shared catalog metadata definitions used across Starmap packages. |
|
catalogremote
Package catalogremote defines the versioned online Starmap-to-Starmap generation protocol.
|
Package catalogremote defines the versioned online Starmap-to-Starmap generation protocol. |
|
catalogs
Package catalogs provides the core catalog system for managing AI model metadata.
|
Package catalogs provides the core catalog system for managing AI model metadata. |
|
catalogscheduler
Package catalogscheduler composes deployment-owned synchronization policy above Starmap's explicit idempotent Sync operation.
|
Package catalogscheduler composes deployment-owned synchronization policy above Starmap's explicit idempotent Sync operation. |
|
catalogstore
Package catalogstore provides durable generation-oriented catalog storage.
|
Package catalogstore provides durable generation-oriented catalog storage. |
|
constants
Package constants provides shared constants used throughout the starmap codebase.
|
Package constants provides shared constants used throughout the starmap codebase. |
|
differ
Package differ provides functionality for comparing catalogs and detecting changes.
|
Package differ provides functionality for comparing catalogs and detecting changes. |
|
enhancer
Package enhancer provides functionality to enrich model data with metadata from external sources.
|
Package enhancer provides functionality to enrich model data with metadata from external sources. |
|
errors
Package errors provides custom error types for the starmap system.
|
Package errors provides custom error types for the starmap system. |
|
logging
Package logging provides structured logging for the starmap system using zerolog.
|
Package logging provides structured logging for the starmap system using zerolog. |
|
provenance
Package provenance provides field-level tracking of data sources and modifications.
|
Package provenance provides field-level tracking of data sources and modifications. |
|
reconciler
Package reconciler provides catalog synchronization and reconciliation capabilities.
|
Package reconciler provides catalog synchronization and reconciliation capabilities. |
|
save
Package save provides options and utilities for saving catalogs in various formats.
|
Package save provides options and utilities for saving catalogs in various formats. |
|
sourceevidence
Package sourceevidence captures replayable normalized observations and protects short-lived raw upstream evidence.
|
Package sourceevidence captures replayable normalized observations and protects short-lived raw upstream evidence. |
|
sourcepayload
Package sourcepayload enforces bounded resource use before source decoding.
|
Package sourcepayload enforces bounded resource use before source decoding. |
|
sources
Package sources provides public APIs for working with AI model data sources.
|
Package sources provides public APIs for working with AI model data sources. |
|
sync
Package sync provides options and utilities for synchronizing the catalog with provider APIs.
|
Package sync provides options and utilities for synchronizing the catalog with provider APIs. |
|
types
Package types provides compatibility aliases for Starmap's former shared-type package.
|
Package types provides compatibility aliases for Starmap's former shared-type package. |