Documentation
¶
Overview ¶
Package delegation runs an explicit bounded local-first task policy. It can escalate once after a known complete durable answer fails declared checks; it never retries uncertain calls, intercepts an agent session, or picks models.
Index ¶
- Variables
- func NewOutcomeRunID() (string, error)
- func OutcomeRecord(request Request, result Result, runID string) outcomes.Run
- func RecordOutcome(ctx context.Context, broker inference.Broker, request Request, result *Result, ...)
- func Validate(request Request, allowPaid bool) error
- type Attempt
- type OutcomeTracking
- type Policy
- type Request
- type Result
- type Router
- type Runner
- type RunnerFactory
- type Tier
Constants ¶
This section is empty.
Variables ¶
var ( ErrQualityFailed = errors.New("delegated task did not satisfy every declared quality check") ErrStopped = errors.New("delegated task stopped without escalating; inspect its recorded outcome") )
Functions ¶
func NewOutcomeRunID ¶ added in v0.9.0
func OutcomeRecord ¶ added in v0.9.0
func RecordOutcome ¶ added in v0.9.0
Types ¶
type Attempt ¶
type Attempt struct {
TierID string `json:"tier_id"`
Result inference.Result `json:"result"` // Response.Text is always stripped.
Checks []evaluation.CheckResult `json:"checks"`
QualityPassed bool `json:"quality_passed"`
OutputSHA256 string `json:"output_sha256,omitempty"`
ErrorCategory string `json:"error_category,omitempty"`
}
type OutcomeTracking ¶ added in v0.4.0
type OutcomeTracking struct {
Status string `json:"status"` // recorded or failed
RunID string `json:"run_id"`
Task outcomes.Task `json:"task"`
Receipt *outcomes.Receipt `json:"receipt,omitempty"`
Record *outcomes.Run `json:"record,omitempty"`
}
OutcomeTracking is separate from answer quality. Registration failure never changes a checked answer or authorizes another model call. Record is returned on failure so the exact metadata can be reconciled without regenerating text.
type Request ¶
type Request struct {
TrackOutcome bool `json:"track_outcome,omitempty"` // Opt-in shared accounting; excluded from generation identity.
Spec inference.Spec `json:"spec"`
Policy Policy `json:"policy"`
Checks []evaluation.Check `json:"checks"`
}
Request.Spec supplies approved task, revision, prompt and context only. Every model and resource setting comes from the explicit tier templates.
type Result ¶
type Result struct {
OutcomeTracking *OutcomeTracking `json:"outcome_tracking,omitempty"`
RequestSHA256 string `json:"request_sha256"`
Attempts []Attempt `json:"attempts"`
SelectedTier string `json:"selected_tier,omitempty"`
Response *inference.Response `json:"response,omitempty"` // Only a passing answer is exposed.
Status string `json:"status"` // completed, quality_failed, stopped
}
type Router ¶
type Router struct {
Factory RunnerFactory
AllowPaid bool // Caller permission, never read from request JSON or environment.
}
func (Router) Run ¶
Run executes at most two explicitly configured tiers. A second tier is reached only after error-free, known complete and durable output fails the declared checks. Every provider/accounting error stops the whole policy. Repeated calls retain the same request/tier identity and the Runner's reuse behavior; the Router never changes a revision to force another generation.