modelinventory

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package modelinventory defines the backend-owned model inventory contract.

Index

Constants

View Source
const (
	ErrorCodeNone             = ""
	ErrorCodeUnavailable      = "unavailable"
	ErrorCodeTimeout          = "timeout"
	ErrorCodeCanceled         = "canceled"
	ErrorCodeEmpty            = "empty"
	ErrorCodeInvalidInventory = "invalid_inventory"
)

Stable machine-readable inventory error codes. Never carry raw provider error text.

Variables

View Source
var ErrNilContext = errors.New("modelinventory: nil context")

Functions

func IsOperational

func IsOperational(err error) bool

IsOperational reports whether err is an operational (fail-soft) inventory failure.

Types

type AcceptedInventory

type AcceptedInventory interface {
	AcceptInventory(models []Model)
}

AcceptedInventory is optionally implemented by Provider values that maintain a local allowlist aligned with inventory accepted into the aggregate registry. Core calls AcceptInventory after publishing a registry snapshot: accepted backends receive their published models, and omitted backends receive a nil or empty slice (both must clear). An empty/nil slice must clear the allowlist.

type Discovery

type Discovery struct {
	Status     DiscoveryStatus
	Source     Source
	ModelCount int
	ErrorCode  string
}

Discovery is protocol-neutral per-inventory discovery metadata.

func DiscoveryFromLoadError

func DiscoveryFromLoadError(err error) Discovery

DiscoveryFromLoadError builds discovery metadata for a LoadModels failure. Raw error text is not copied; only a stable ErrorCode is retained.

func DiscoveryFromSnapshot

func DiscoveryFromSnapshot(snap Snapshot) Discovery

DiscoveryFromSnapshot builds discovery metadata for a successful LoadModels snapshot.

type DiscoveryStatus

type DiscoveryStatus string

DiscoveryStatus is protocol-neutral inventory discovery outcome for one backend instance.

const (
	DiscoveryStatusOK          DiscoveryStatus = "ok"
	DiscoveryStatusEmpty       DiscoveryStatus = "empty"
	DiscoveryStatusUnavailable DiscoveryStatus = "unavailable"
	DiscoveryStatusCached      DiscoveryStatus = "cached"
)

type ErrorProvider

type ErrorProvider struct {
	Err error
}

func (ErrorProvider) LoadModels

func (p ErrorProvider) LoadModels(ctx context.Context) (Snapshot, error)

func (ErrorProvider) StaticInventory

func (p ErrorProvider) StaticInventory() bool

StaticInventory marks ErrorProvider as non-refreshable so a cached snapshot loaded at startup is not repeatedly overwritten by the same construction error.

type Model

type Model struct {
	CanonicalID string
	NativeID    string
	DisplayName string
}

type OperationalError

type OperationalError struct {
	Code string
	Err  error
}

OperationalError marks a fail-soft inventory load failure. Aggregators omit the backend without aborting unrelated successful inventories.

func (*OperationalError) Error

func (e *OperationalError) Error() string

func (*OperationalError) Operational

func (e *OperationalError) Operational() bool

Operational reports that this error is safe to fail soft during inventory aggregation.

func (*OperationalError) Unwrap

func (e *OperationalError) Unwrap() error

type Provider

type Provider interface {
	LoadModels(ctx context.Context) (Snapshot, error)
}

Provider loads model inventory for one configured backend instance.

type Snapshot

type Snapshot struct {
	Source   Source
	LoadedAt time.Time
	Models   []Model
	Warnings []string
}

type Source

type Source string
const (
	SourceUnknown       Source = ""
	SourceRemote        Source = "remote"
	SourceStaticFile    Source = "static_file"
	SourceStaticInline  Source = "static_inline"
	SourceStaticBuiltin Source = "static_builtin"
)

type StaticInventory

type StaticInventory interface {
	StaticInventory() bool
}

StaticInventory marks providers whose inventory is local and does not require periodic remote refresh.

type StaticProvider

type StaticProvider struct {
	Source   Source
	LoadedAt time.Time
	Models   []Model
	Warnings []string
}

StaticProvider returns a fixed inventory snapshot. Models and Warnings slices are treated as immutable after construction; LoadModels returns them without cloning. Callers must not mutate the returned Snapshot slices.

func (StaticProvider) LoadModels

func (p StaticProvider) LoadModels(ctx context.Context) (Snapshot, error)

func (StaticProvider) StaticInventory

func (p StaticProvider) StaticInventory() bool

Jump to

Keyboard shortcuts

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