Documentation
¶
Overview ¶
Package catalogdistribution provides the versioned hosted catalog distribution contract used by starmap.agentstation.ai and Starport clients.
Index ¶
- Constants
- type AssetDescriptor
- type Channel
- type Client
- type Handler
- type LatestPointer
- type MemoryRepository
- func (r *MemoryRepository) Get(generationID string) (PublishedGeneration, error)
- func (r *MemoryRepository) Latest(schemaVersion uint64) (PublishedGeneration, error)
- func (r *MemoryRepository) LatestForChannel(channel Channel, schemaVersion uint64) (PublishedGeneration, error)
- func (r *MemoryRepository) Promote(channel Channel, generationID string, probe *PromotionProbe) error
- func (r *MemoryRepository) PromotionEvents() []PromotionEvent
- func (r *MemoryRepository) Publish(published PublishedGeneration) error
- func (r *MemoryRepository) Rollback(channel Channel, generationID, reason string) error
- type PromotionAction
- type PromotionEvent
- type PromotionPolicy
- type PromotionProbe
- type PublishedGeneration
- type Repository
Constants ¶
const ( // DefaultBaseURL is the canonical hosted catalog distribution origin. DefaultBaseURL = "https://starmap.agentstation.ai" // APIPrefix is the versioned hosted catalog route prefix. APIPrefix = "/v1/catalogs" // PointerVersion is the current latest-pointer schema. PointerVersion uint64 = 1 // ImmutableCacheControl is sent for generation-addressed assets. ImmutableCacheControl = "public, max-age=31536000, immutable" // LatestCacheControl is sent for the mutable latest-compatible pointer. LatestCacheControl = "public, max-age=60, must-revalidate" )
const ( // DefaultMaxGenerationAge is the default stable-promotion freshness SLO. DefaultMaxGenerationAge = 7 * 24 * time.Hour // DefaultMaxProbeAge is the maximum age of hosted canary evidence used for // stable promotion. DefaultMaxProbeAge = 5 * time.Minute // DefaultMaxProbeLatency is the default hosted canary response SLO. DefaultMaxProbeLatency = 2 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetDescriptor ¶
type AssetDescriptor struct {
URL string `json:"url"`
MediaType string `json:"media_type"`
Checksum string `json:"checksum"`
SizeBytes int64 `json:"size_bytes"`
}
AssetDescriptor identifies one immutable hosted byte object.
type Channel ¶
type Channel string
Channel is a mutable hosted pointer with an explicit promotion role.
const ( // ChannelDev receives a published generation first. ChannelDev Channel = "dev" // ChannelCanary receives only the generation currently selected in dev. ChannelCanary Channel = "canary" // ChannelStable receives only a canary generation with passing hosted SLO evidence. ChannelStable Channel = "stable" )
func ParseChannel ¶
ParseChannel parses a channel query value. An empty value defaults to stable for backward-compatible consumer behavior.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client fetches and verifies hosted catalog generations.
func (*Client) FetchChannel ¶
func (c *Client) FetchChannel(ctx context.Context, channel Channel) (catalogstore.Generation, error)
FetchChannel resolves, downloads, and verifies the latest compatible immutable generation selected for one explicit promotion channel.
func (*Client) FetchLatest ¶
func (c *Client) FetchLatest(ctx context.Context) (catalogstore.Generation, error)
FetchLatest resolves, downloads, and verifies the latest compatible immutable generation before returning it.
func (*Client) ProbeChannel ¶
func (c *Client) ProbeChannel(ctx context.Context, channel Channel, policy PromotionPolicy, observedAt time.Time) PromotionProbe
ProbeChannel fetches a hosted channel through the public HTTP protocol and returns evidence suitable for stable promotion under the supplied policy.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves latest-compatible pointers and immutable generation assets.
func NewHandler ¶
func NewHandler(repository Repository) (*Handler, error)
NewHandler creates the versioned hosted distribution HTTP adapter.
type LatestPointer ¶
type LatestPointer struct {
Version uint64 `json:"version"`
Channel Channel `json:"channel"`
GenerationID string `json:"generation_id"`
SchemaVersion uint64 `json:"schema_version"`
ConsumerCompatibility catalogs.ConsumerCompatibility `json:"consumer_compatibility"`
Artifact AssetDescriptor `json:"artifact"`
Attestation AssetDescriptor `json:"attestation"`
}
LatestPointer selects one immutable generation compatible with a consumer's catalog schema.
func (LatestPointer) String ¶
func (p LatestPointer) String() string
String returns a concise latest-pointer description.
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository is a thread-safe immutable hosted repository for tests and single-process deployments.
func NewMemoryRepository ¶
func NewMemoryRepository() *MemoryRepository
NewMemoryRepository creates an empty hosted repository.
func NewMemoryRepositoryWithPolicy ¶
func NewMemoryRepositoryWithPolicy(policy PromotionPolicy) (*MemoryRepository, error)
NewMemoryRepositoryWithPolicy creates an empty repository with explicit stable-promotion SLO budgets.
func (*MemoryRepository) Get ¶
func (r *MemoryRepository) Get(generationID string) (PublishedGeneration, error)
Get returns one immutable generation by logical ID.
func (*MemoryRepository) Latest ¶
func (r *MemoryRepository) Latest(schemaVersion uint64) (PublishedGeneration, error)
Latest returns the stable generation only when its catalog schema range is compatible with the requested consumer schema.
func (*MemoryRepository) LatestForChannel ¶
func (r *MemoryRepository) LatestForChannel(channel Channel, schemaVersion uint64) (PublishedGeneration, error)
LatestForChannel returns the selected channel generation only when its catalog schema range is compatible with the requested consumer schema.
func (*MemoryRepository) Promote ¶
func (r *MemoryRepository) Promote(channel Channel, generationID string, probe *PromotionProbe) error
Promote atomically advances a published generation through dev, canary, or stable. Canary requires the same dev selection. Stable additionally requires recent passing hosted canary evidence bound to the archive checksum.
func (*MemoryRepository) PromotionEvents ¶
func (r *MemoryRepository) PromotionEvents() []PromotionEvent
PromotionEvents returns caller-owned promotion and rollback telemetry, including rejected attempts.
func (*MemoryRepository) Publish ¶
func (r *MemoryRepository) Publish(published PublishedGeneration) error
Publish adds an immutable generation. An exact retry is idempotent; reuse of an existing generation ID with different bytes is a conflict.
type PromotionAction ¶
type PromotionAction string
PromotionAction describes a pointer-control operation.
const ( // PromotionActionPromote advances a generation through a channel. PromotionActionPromote PromotionAction = "promote" // PromotionActionRollback returns a channel to a prior generation. PromotionActionRollback PromotionAction = "rollback" )
type PromotionEvent ¶
type PromotionEvent struct {
Sequence uint64
Action PromotionAction
Channel Channel
From string
To string
ObservedAt time.Time
Success bool
Reason string
}
PromotionEvent is immutable queryable pointer-control telemetry.
type PromotionPolicy ¶
type PromotionPolicy struct {
MaxGenerationAge time.Duration
MaxProbeAge time.Duration
MaxProbeLatency time.Duration
}
PromotionPolicy defines freshness and availability evidence required before a canary generation may become stable.
func DefaultPromotionPolicy ¶
func DefaultPromotionPolicy() PromotionPolicy
DefaultPromotionPolicy returns the production default hosted SLO policy.
func (PromotionPolicy) Validate ¶
func (p PromotionPolicy) Validate() error
Validate verifies positive promotion SLO budgets.
type PromotionProbe ¶
type PromotionProbe struct {
Channel Channel
GenerationID string
ArtifactChecksum string
ObservedAt time.Time
Latency time.Duration
Available bool
Fresh bool
Failure string
}
PromotionProbe is hosted availability, freshness, latency, and identity evidence for one channel generation.
type PublishedGeneration ¶
type PublishedGeneration struct {
Generation catalogstore.Generation
Artifact catalogartifact.Artifact
}
PublishedGeneration is one verified generation and its exact distribution artifact set.
func (PublishedGeneration) Validate ¶
func (p PublishedGeneration) Validate() error
Validate verifies that the artifact opens to exactly the supplied generation.
type Repository ¶
type Repository interface {
LatestForChannel(channel Channel, schemaVersion uint64) (PublishedGeneration, error)
Get(generationID string) (PublishedGeneration, error)
}
Repository is the narrow hosted read boundary.