Documentation
¶
Overview ¶
Package starmap provides the small, provider-independent entry point for the Starmap AI model catalog system.
Starmap wraps the underlying catalog system with additional features including: - Event hooks for model changes (added, updated, removed) - Thread-safe access to an immutable canonical catalog - Explicit, serialized publication of complete catalog generations - Flexible configuration through functional options
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)
}
// Provider acquisition is an explicit opt-in composition.
syncer, err := acquisition.New(sm)
if err != nil {
log.Fatal(err)
}
result, err := syncer.Sync(ctx,
sync.WithProvider("openai"),
sync.WithDryRun(true),
)
if err != nil {
log.Fatal(err)
}
Package starmap provides immutable AI model catalog reads, explicit generation publication, event hooks, and caller-selected generation storage.
Index ¶
- Constants
- type Candidate
- type CatalogPublishedEvent
- type CatalogPublishedHook
- type CatalogReadiness
- type CatalogState
- type Client
- func (c *Client) Activate(ctx context.Context, generation catalogstore.Generation) (Publication, error)
- 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) Rollback(ctx context.Context, generationID string) (*RollbackResult, error)
- func (c *Client) Save() error
- func (c *Client) SaveTo(path string) error
- func (c *Client) Update(ctx context.Context, update UpdateFunc) (Publication, error)
- func (c *Client) WorkspacePath() string
- type EmbeddedBootstrapInfo
- type HookDeliveryStats
- type ModelAddedHook
- type ModelRemovedHook
- type ModelUpdatedHook
- type Option
- type Publication
- type ReadinessIssue
- type RollbackResult
- 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 Candidate ¶ added in v0.2.0
type Candidate struct {
// contains filtered or unexported fields
}
Candidate is a complete immutable catalog prepared off to the side for one atomic publication. Source observations are immutable generation evidence; they do not alter catalog facts.
func NewCandidate ¶ added in v0.2.0
func NewCandidate( catalog *catalogs.Catalog, observations ...catalogs.SourceObservationLink, ) (*Candidate, error)
NewCandidate validates and returns a publication candidate. An empty observation list is permitted for custom acquisition; Client.Update records a deterministic custom-update observation in that case.
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. Sequence increases with each in-process activation; gaps tell observers that pending callback delivery coalesced to a newer generation. 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
type CatalogState struct {
Catalog *catalogs.Catalog
GenerationID string
GeneratedAt time.Time
Sequence uint64
}
CatalogState atomically pairs the current immutable catalog with its logical generation identity and generation timestamp for freshness, 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 publication, persistence, and event hooks. It owns no provider acquisition, scheduling goroutine, or cadence.
func New ¶
New creates a Client using a background context. Call NewContext when construction may perform storage I/O that must be canceled by the caller.
func NewContext ¶ added in v0.2.0
NewContext creates a Client with the given options. The caller-owned context bounds durable generation loading and workspace repair and must be non-nil. When a durable generation and a marker-backed unchanged YAML workspace are both configured, construction repairs a stale or interrupted projection by digest. It never overwrites an unrecognized semantic workspace change.
func (*Client) Activate ¶ added in v0.2.0
func (c *Client) Activate(ctx context.Context, generation catalogstore.Generation) (Publication, error)
Activate validates, durably commits, and atomically activates an immutable generation obtained by an explicit trusted distribution adapter.
func (*Client) Catalog ¶ added in v0.1.0
Catalog returns the current immutable canonical catalog. It returns nil when called on a nil Client. After New or NewContext succeeds, Catalog is non-failing, non-nil, O(1), allocation-free, and safe to retain across goroutines.
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. Generations begin callback delivery in sequence order. When callbacks lag, delivery retains the running generation and coalesces pending work to the newest committed generation.
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) Rollback ¶ added in v0.2.0
Rollback atomically makes a retained generation current and projects its exact catalog semantics and provenance into the configured human workspace. Repeating a rollback to the current durable generation is idempotent.
func (*Client) Save ¶ added in v0.1.0
Save atomically materializes the current committed generation into a YAML workspace configured at construction. It never publishes a new generation.
func (*Client) SaveTo ¶ added in v0.2.0
SaveTo atomically materializes the current committed generation into path. It never publishes a new generation.
func (*Client) Update ¶ added in v0.1.0
func (c *Client) Update(ctx context.Context, update UpdateFunc) (Publication, error)
Update serializes candidate construction, generation-store CAS, and atomic in-memory publication. Acquisition and scheduling remain explicit caller composition above Client.
func (*Client) WorkspacePath ¶ added in v0.2.0
WorkspacePath returns the configured human-editable YAML workspace. An empty path means this client has no filesystem projection.
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 is the number of callback invocations that returned or panicked.
Completed uint64
// Failures is the number of callbacks that returned an error or panicked.
Failures uint64
// Panics is the number of isolated callback panics.
Panics uint64
// Coalesced is the number of pending catalog generations superseded by a
// newer committed generation before callback delivery began.
Coalesced uint64
// LastLatency is the duration of the most recently completed callback.
LastLatency time.Duration
// MaxLatency is the longest completed callback 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 WithCatalogPath ¶ added in v0.2.0
WithCatalogPath configures the human-editable provider YAML workspace used for both local observation and post-commit materialization. Immutable generation state remains in the separately supplied CatalogStore.
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. Starmap provides memory, filesystem, and conditional object-storage implementations; embedding applications own and inject any database-backed implementation.
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.
type Publication ¶ added in v0.2.0
type Publication struct {
Published bool
GenerationID string
PayloadChecksum string
SyncRunID string
}
Publication identifies the durable generation produced by a successful update. Published is false when the update function intentionally returns no candidate or an identical retained generation is activated again.
type ReadinessIssue ¶ added in v0.1.0
ReadinessIssue is one stable machine-readable reason a client is not ready.
type RollbackResult ¶ added in v0.2.0
type RollbackResult struct {
// FromGenerationID is the generation active before rollback.
FromGenerationID string
// GenerationID is the retained generation selected by rollback.
GenerationID string
// PayloadChecksum identifies the exact immutable generation payload.
PayloadChecksum string
// Sequence is the in-process publication sequence after rollback.
Sequence uint64
// Projection reports exact workspace restoration or pending repair.
Projection *catalogmeta.ProjectionResult
}
RollbackResult describes activation of a retained immutable generation.
type UpdateFunc ¶ added in v0.1.0
UpdateFunc builds and validates a complete candidate while Client.Update holds the client's mutation transaction. Returning nil performs no publication. The current catalog is immutable and safe to retain.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package acquisition composes provider and external-source acquisition above the small immutable Starmap client.
|
Package acquisition composes provider and external-source acquisition above the small immutable Starmap client. |
|
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 one exact committed generation as immutable catalog release assets.
|
Command starmap-catalog-release stages one exact committed 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. |
|
internal
|
|
|
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/authority
Package authority defines the executable field policy used by reconciliation.
|
Package authority defines the executable field policy used by reconciliation. |
|
catalog/pipeline
Package pipeline owns acquisition orchestration behind the public acquisition package.
|
Package pipeline owns acquisition orchestration behind the public acquisition package. |
|
catalog/query
Package query provides shared catalog list/detail query behavior.
|
Package query provides shared catalog list/detail query behavior. |
|
catalog/reconciler
Package reconciler provides catalog synchronization and reconciliation capabilities.
|
Package reconciler provides catalog synchronization and reconciliation capabilities. |
|
catalog/workspace
Package workspace atomically projects committed catalogs into the optional human-editable provider YAML workspace.
|
Package workspace atomically projects committed catalogs into the optional human-editable provider YAML workspace. |
|
cli/alerts
Package alerts provides a structured system for status notifications.
|
Package alerts provides a structured system for status notifications. |
|
cli/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. |
|
cli/commands/auth
Package auth provides cloud provider authentication helpers for Starmap.
|
Package auth provides cloud provider authentication helpers for Starmap. |
|
cli/commands/authors
Package authors provides the authors resource command.
|
Package authors provides the authors resource command. |
|
cli/commands/completion
Package completion provides shell completion management commands.
|
Package completion provides shell completion management commands. |
|
cli/commands/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. |
|
cli/commands/embed
Package embed provides commands for exploring the embedded filesystem.
|
Package embed provides commands for exploring the embedded filesystem. |
|
cli/commands/migrate
Package migrate provides explicit local storage migration commands.
|
Package migrate provides explicit local storage migration commands. |
|
cli/commands/models
Package models provides the models resource command and subcommands.
|
Package models provides the models resource command and subcommands. |
|
cli/commands/providers
Package providers provides the providers resource command and subcommands.
|
Package providers provides the providers resource command and subcommands. |
|
cli/commands/serve
Package serve provides HTTP server commands for the Starmap CLI.
|
Package serve provides HTTP server commands for the Starmap CLI. |
|
cli/commands/update
Package update provides the update command implementation.
|
Package update provides the update command implementation. |
|
cli/commands/validate
Package validate provides catalog validation commands.
|
Package validate provides catalog validation commands. |
|
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 common output formatting utilities for CLI commands.
|
Package format provides common output formatting utilities for CLI commands. |
|
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. |
|
constants
Package constants defines shared implementation limits and defaults.
|
Package constants defines shared implementation limits and defaults. |
|
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/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/openrouter
Package openrouter adapts Starmap's immutable catalog read model to the OpenRouter model and endpoint discovery HTTP contracts.
|
Package openrouter adapts Starmap's immutable catalog read model to the OpenRouter model and endpoint discovery HTTP contracts. |
|
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 the sole reactive catalog-publication transport.
|
Package sse provides the sole reactive catalog-publication transport. |
|
sourcepayload
Package sourcepayload enforces bounded resource use before source decoding.
|
Package sourcepayload enforces bounded resource use before source decoding. |
|
sources/embedded
Package embedded exposes the verified compiled catalog as a versioned, lowest-authority synchronization observation.
|
Package embedded exposes the verified compiled catalog as a versioned, lowest-authority synchronization observation. |
|
sources/providers
Package providers implements the provider-backed catalog source.
|
Package providers implements the provider-backed catalog source. |
|
testlogging
Package testlogging provides repository-internal structured logging test helpers.
|
Package testlogging provides repository-internal structured logging test helpers. |
|
pkg
|
|
|
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. |
|
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 implements the versioned online Starmap-to-Starmap generation protocol and its verified client.
|
Package catalogremote implements the versioned online Starmap-to-Starmap generation protocol and its verified client. |
|
catalogs
Package catalogs defines Starmap's authored-model and provider-serving construction records plus its immutable canonical read model.
|
Package catalogs defines Starmap's authored-model and provider-serving construction records plus its immutable canonical read model. |
|
catalogstore
Package catalogstore provides durable generation-oriented catalog storage.
|
Package catalogstore provides durable generation-oriented catalog storage. |
|
catalogstore/s3
Package s3 provides an S3-compatible implementation of catalogstore.ObjectBackend.
|
Package s3 provides an S3-compatible implementation of catalogstore.ObjectBackend. |
|
differ
Package differ provides functionality for comparing catalogs and detecting changes.
|
Package differ provides functionality for comparing catalogs and detecting changes. |
|
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. |
|
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. |
|
Package remote provides a reactive Starmap catalog consumer.
|
Package remote provides a reactive Starmap catalog consumer. |
|
Package server provides an embeddable HTTP server for a Starmap catalog.
|
Package server provides an embeddable HTTP server for a Starmap catalog. |