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 ¶
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. A bundle that fails to open is an internal error. Storage passes textvalue.ErrUnstorable and adminaudit.ErrInvalidSource through unchanged.
Functions ¶
func ShouldObserveProvider ¶
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 a stored default with its key opened 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 *ProviderErrorCode
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 ProviderErrorCode ¶ added in v0.0.10
type ProviderErrorCode string
const ( ProviderAuthenticationError ProviderErrorCode = "authentication_error" ProviderConnectionFailed ProviderErrorCode = "connection_failed" ProviderRateLimitExceeded ProviderErrorCode = "rate_limit_exceeded" ProviderUsageLimitExceeded ProviderErrorCode = "usage_limit_exceeded" ProviderServerOverloaded ProviderErrorCode = "server_overloaded" ProviderServerError ProviderErrorCode = "server_error" ProviderResourceNotFound ProviderErrorCode = "resource_not_found" ProviderRequestTimeout ProviderErrorCode = "request_timeout" ProviderInvalidRequest ProviderErrorCode = "invalid_request" )
type Record ¶
type Record struct {
Harness string
Provider v1.ModelProviderView
Model string
HarnessConfig json.RawMessage
APIKey string
}
Record is a validated deployment default ready to store: its columns and the provider key, 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 provider key to its Harness; every other field is stored plainly.
func (*Service) Delete ¶
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.
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 the key 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 key 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 provider key. Replace and Delete record the administrator mutation in the same transaction, from the provenance the context carries; an audit failure aborts the change.