modelconfiguration

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modelconfiguration owns each Harness's deployment default model configuration: its safe view, the encrypted complete bundle that Session creation freezes, the private revision that pairs with it, and the rules for replacing, removing and resolving it.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound reports a Harness without a deployment default.
	ErrNotFound = errors.New("the harness has no deployment default model configuration")
	// ErrInvalidObservation reports an Observation whose identifiers are not
	// nonzero UUIDs.
	ErrInvalidObservation = errors.New("an observation requires nonzero tenant, Session and Turn UUIDs")
)

Replace and Resolve report a configuration the Harness declaration rejects with the contract's *v1.ModelProviderError, which names the field, and a missing credential key with credentialcrypto.ErrUnavailable. A bundle that fails to open is an internal error. Storage passes textvalue.ErrUnstorable and adminaudit.ErrInvalidSource through unchanged.

Functions

func ShouldObserveProvider

func ShouldObserveProvider(status, errorCode, engineErrorCode string) bool

ShouldObserveProvider reports whether a committed root Turn outcome says something about its model provider: every completed Turn, and a failed Turn whose engine reported a provider error. It only spares a database round trip; the observation statement re-checks the committed outcome.

Types

type Bundle

type Bundle struct {
	Configuration v1.ModelConfigurationInput
	Revision      uuid.UUID
}

Bundle is an opened stored bundle and the revision read with it.

type Configuration

type Configuration struct {
	Harness       string
	Provider      v1.ModelProviderView
	Model         string
	HarnessConfig json.RawMessage
	UpdatedAt     time.Time
	LastUsedAt    *time.Time
	LastErrorCode *string
	LastErrorAt   *time.Time
}

Configuration is the safe view of one Harness's deployment default. The provider key is write-only; Provider reports only that one is configured. LastUsedAt, LastErrorCode and LastErrorAt are best-effort observations of committed root Turns that used this exact revision.

type Observation

type Observation struct {
	TenantID, SessionID, TurnID string
}

Observation names a root Turn whose committed outcome may update the last-use observations of the deployment default its Session froze.

type Observer

type Observer interface {
	ObserveDeploymentModelProvider(ctx context.Context, observation Observation) (int64, error)
}

Observer records a committed root Turn's outcome against the deployment default revision its Session froze. It runs after the Turn's commit, outside the execution lease, and the statement itself re-checks the committed outcome, the tenant, the provider source and the exact revision. It returns the number of defaults updated: zero when the Turn does not qualify, the default was replaced or removed, or the throttle skips the update.

type Reader

type Reader interface {
	List(ctx context.Context) ([]Configuration, error)
}

Reader lists the configured defaults without opening any bundle.

type Record

type Record struct {
	Harness       string
	Provider      v1.ModelProviderView
	Model         string
	HarnessConfig json.RawMessage
	Configuration v1.ModelConfigurationInput
}

Record is a validated deployment default ready to store: its safe columns and the complete bundle, provider key included, which storage seals to the Harness. Storage assigns a new revision to each Record it stores.

type Replacement

type Replacement struct {
	Harness       string
	Configuration v1.ModelConfigurationInput
}

Replacement is one complete deployment default for a Harness, including its write-only provider key.

type Service

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

Service replaces, removes and resolves deployment defaults. Storage seals the complete bundle, key included, to its Harness.

func NewService

func NewService(storage Storage) (*Service, error)

NewService requires storage.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, harness string) error

Delete removes the Harness's default. It is idempotent. Sessions that already froze the default keep it.

func (*Service) Replace

func (s *Service) Replace(ctx context.Context, replacement Replacement) (Configuration, error)

Replace validates the complete configuration through the Harness declaration and stores it under a new revision. Sessions that already froze a default keep theirs.

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, harness string) (*Snapshot, error)

Resolve opens the Harness's default for Session creation. It returns nil when the Harness has none, and credentialcrypto.ErrUnavailable without a credential key.

type Snapshot

type Snapshot struct {
	Provider      *v1.ModelProviderInput
	Model         string
	HarnessConfig json.RawMessage
	Revision      uuid.UUID
}

Snapshot is a decrypted deployment default for Session creation, paired with the private revision read with it. It never enters a public projection.

type Storage

type Storage interface {
	// Replace seals and stores record under a new revision and clears the
	// observations of the revision it replaces.
	Replace(ctx context.Context, record Record) (Configuration, error)
	// Delete removes the Harness's default. Removing a missing default succeeds
	// and is audited too.
	Delete(ctx context.Context, harness string) error
	// LoadBundle opens the Harness's bundle and returns it with its revision.
	// A Harness without a default is ErrNotFound, checked before the key.
	LoadBundle(ctx context.Context, harness string) (Bundle, error)
}

Storage keeps one deployment default per Harness and seals and opens its bundle; without a credential key, Replace and LoadBundle return credentialcrypto.ErrUnavailable. Replace and Delete record the administrator mutation in the same transaction, from the provenance the context carries; an audit failure aborts the change.

Jump to

Keyboard shortcuts

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