Documentation
¶
Overview ¶
Package optimization adapts captured Cortex executions to Sentinel scoring.
Index ¶
- func ConvertExecution(r opt.ExecutionRecord) (se.RecordedCase, error)
- type Binding
- type CaseBinding
- type CatalogAccess
- type CatalogAuthorizer
- type Config
- type Evaluator
- func (e *Evaluator) Compare(ctx context.Context, r opt.ComparisonRequest) (opt.Comparison, error)
- func (e *Evaluator) CompareControllers(ctx context.Context, request opt.ControllerComparisonRequest) (opt.Comparison, error)
- func (e *Evaluator) Evaluate(ctx context.Context, r opt.EvaluationRequest) (opt.Evaluation, error)
- func (e *Evaluator) Freeze(ctx context.Context, r opt.EvaluationSpec) (opt.EvaluationPlan, error)
- type JudgeConfig
- type MeteredJudge
- type ScopeMapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertExecution ¶
func ConvertExecution(r opt.ExecutionRecord) (se.RecordedCase, error)
ConvertExecution preserves original output, timing, usage quality and evidence identities.
Types ¶
type Binding ¶
type Binding struct {
Scope cortex.Scope
AppID, TenantID string
Plan opt.ContentRef
Cases []CaseBinding
}
Binding pins one exact source scope, evaluator and task roster.
type CaseBinding ¶
CaseBinding ties a frozen public task to its private Sentinel definition.
type CatalogAccess ¶
type CatalogAccess struct {
// contains filtered or unexported fields
}
CatalogAccess qualifies registered evaluation choices without running targets or judges. Use it with ApprovedCatalog and your host's creation preparation.
func NewCatalogAccess ¶
func NewCatalogAccess(evaluator *Evaluator, authorizer CatalogAuthorizer) (*CatalogAccess, error)
NewCatalogAccess requires explicit current-grant checks for private plan reads.
func (*CatalogAccess) Authorize ¶
func (a *CatalogAccess) Authorize(ctx context.Context, choice opt.CatalogChoice) error
Authorize checks an evaluation choice against the exact current scope, mapped source grant and frozen plan. Other catalog kinds need their host's authorizer.
func (*CatalogAccess) Freeze ¶
func (a *CatalogAccess) Freeze(ctx context.Context, spec opt.EvaluationSpec) (opt.EvaluationPlan, error)
Freeze checks the mapped source grant before reading private plan content and again before returning the qualified plan. It shares the evaluator's task, criterion and scorer revision checks. No evaluation is dispatched.
type CatalogAuthorizer ¶
type CatalogAuthorizer interface {
AuthorizeEvaluation(context.Context, opt.ContentRef) error
}
CatalogAuthorizer checks the current caller's evaluation grant in the mapped Sentinel app and tenant. Return ErrPolicyDenied to exclude a catalog choice; return an availability error when the grant cannot be checked. Scope mapping alone does not grant access. Implementations must preserve the context identity.
type Config ¶
type Config struct {
Engine *se.Engine
Mapper ScopeMapper
Bindings []Binding
Repository opt.Repository
Judges []*MeteredJudge
}
Config supplies a Sentinel engine and explicit scope and case bindings.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator scores recorded output without an executable target callback.
func NewEvaluator ¶
NewEvaluator installs explicit bindings. It does not start a global evaluation worker.
func (*Evaluator) Compare ¶
func (e *Evaluator) Compare(ctx context.Context, r opt.ComparisonRequest) (opt.Comparison, error)
Compare uses Sentinel's paired case bootstrap over exact persisted job sets. Unsupported confidence settings fail rather than changing the frozen objective.
func (*Evaluator) CompareControllers ¶
func (e *Evaluator) CompareControllers(ctx context.Context, request opt.ControllerComparisonRequest) (opt.Comparison, error)
CompareControllers reloads the frozen stream and compares its original child captures. It cannot execute a task or dispatch a judge call.
func (*Evaluator) Evaluate ¶
func (e *Evaluator) Evaluate(ctx context.Context, r opt.EvaluationRequest) (opt.Evaluation, error)
Evaluate scores one durable captured trial, reusing the recorded job on retry.
func (*Evaluator) Freeze ¶
func (e *Evaluator) Freeze(ctx context.Context, r opt.EvaluationSpec) (opt.EvaluationPlan, error)
Freeze resolves a previously frozen, host-bound Sentinel plan.
type JudgeConfig ¶
type JudgeConfig struct {
Name string
Repository opt.Repository
Authorizer opt.Authorizer
IdentityResolver opt.IdentityResolver
Model opt.ModelBinding
MaxInputBytes, MaxResponseBytes, MaxOutputTokens int
}
JudgeConfig pins a model route and local accounting services. The host must enforce the model revision and the provider's requested output cap.
type MeteredJudge ¶
type MeteredJudge struct {
// contains filtered or unexported fields
}
MeteredJudge registers a strict JSON scorer backed by the optimization ledger. A lost answer is incomplete evidence; a usage receipt never supplies a score.
func NewMeteredJudge ¶
func NewMeteredJudge(c JudgeConfig) (*MeteredJudge, error)
NewMeteredJudge freezes the model and limits into the scorer revision.
func (*MeteredJudge) Register ¶
func (j *MeteredJudge) Register(registry *scorer.Registry) error
Register installs this judge before the host freezes its Sentinel plan.
func (*MeteredJudge) Revision ¶
func (j *MeteredJudge) Revision() string
Revision identifies the scoring protocol, model revision and request limits.