Documentation
¶
Overview ¶
Package promptcache defines the provider-neutral host/plugin contract for prompt-cache residency. It deliberately contains no provider wire types, cache-key schema, request replay shape, or scheduling policy.
Index ¶
- Constants
- Variables
- func WithObservationLineage(ctx context.Context, lineage ObservationLineage) context.Context
- type AccountingAuthority
- type AccountingEvidence
- type AccountingPlane
- type AccountingSource
- type CacheEvidence
- type Controller
- type GenerationID
- type Handle
- type LifecycleKind
- type Observation
- type ObservationBuffer
- type ObservationLineage
- type ObservationSource
- type Profile
- type ReleaseRequest
- type RenewRequest
- type RenewResponse
- type RenewResult
- type RenewStatus
- type TargetID
- type Timing
Constants ¶
View Source
const ( MaxTargetIDBytes = 256 MaxGenerationIDBytes = 256 MaxHandleBytes = 256 MaxOperationIDBytes = 256 MaxLegIDBytes = 256 MaxObservationsPerLeg = 16 MaxLifecycleKinds = 5 )
View Source
const MaxAccountingDedupeKeyBytes = 256
Variables ¶
View Source
var ( ErrInvalid = errors.New("promptcache: invalid contract value") ErrOversized = errors.New("promptcache: value exceeds bound") ErrUnknownLifecycle = errors.New("promptcache: unknown lifecycle") ErrHandleRequired = errors.New("promptcache: renewable observation requires a handle") ErrControlUnsupported = errors.New("promptcache: control unsupported") ErrStaleHandle = errors.New("promptcache: stale handle") )
Functions ¶
func WithObservationLineage ¶
func WithObservationLineage(ctx context.Context, lineage ObservationLineage) context.Context
Types ¶
type AccountingAuthority ¶
type AccountingAuthority string
const ( AccountingAuthorityAuthoritative AccountingAuthority = "authoritative" AccountingAuthorityEstimated AccountingAuthority = "estimated" AccountingAuthorityDelegated AccountingAuthority = "delegated" AccountingAuthorityAdvisory AccountingAuthority = "advisory" )
type AccountingEvidence ¶
type AccountingEvidence struct {
InputTokens *int64
OutputTokens *int64
CacheReadTokens *int64
CacheWriteTokens *int64
ReasoningTokens *int64
TotalTokens *int64
Presence lipapi.UsagePresence
Source AccountingSource
Authority AccountingAuthority
Plane AccountingPlane
DedupeKey string
}
func (AccountingEvidence) Validate ¶
func (e AccountingEvidence) Validate() error
type AccountingPlane ¶
type AccountingPlane string
const AccountingPlaneProviderBillable AccountingPlane = "provider_billable"
type AccountingSource ¶
type AccountingSource string
const ( AccountingSourceProviderReported AccountingSource = "provider_reported" AccountingSourceProviderCountAPI AccountingSource = "provider_count_api" AccountingSourceLocalEstimator AccountingSource = "local_estimator" AccountingSourceLocalTokenizer AccountingSource = "local_tokenizer" )
type CacheEvidence ¶
type CacheEvidence struct {
InputTokens *int64
OutputTokens *int64
CacheReadTokens *int64
CacheWriteTokens *int64
TotalTokens *int64
}
func (CacheEvidence) Validate ¶
func (e CacheEvidence) Validate() error
type Controller ¶
type Controller interface {
Renew(context.Context, RenewRequest) (RenewResponse, error)
Release(context.Context, ReleaseRequest) error
}
type GenerationID ¶
type GenerationID string
func (GenerationID) Validate ¶
func (id GenerationID) Validate(required bool) error
type LifecycleKind ¶
type LifecycleKind string
const ( LifecycleUnknown LifecycleKind = "unknown" LifecycleSlidingExpiry LifecycleKind = "sliding_expiry" LifecycleFixedExpiry LifecycleKind = "fixed_expiry" LifecycleMinimumResidency LifecycleKind = "minimum_residency" LifecycleBestEffort LifecycleKind = "best_effort" )
func (LifecycleKind) Validate ¶
func (k LifecycleKind) Validate() error
type Observation ¶
type Observation struct {
ALegID string
BLegID string
BackendInstanceID string
TargetID TargetID
GenerationID GenerationID
Lifecycle LifecycleKind
Timing Timing
Renewable bool
Handle Handle
Evidence CacheEvidence
}
func (Observation) Validate ¶
func (o Observation) Validate() error
type ObservationBuffer ¶
type ObservationBuffer struct {
// contains filtered or unexported fields
}
func (*ObservationBuffer) Add ¶
func (b *ObservationBuffer) Add(o Observation) error
func (*ObservationBuffer) Commit ¶
func (b *ObservationBuffer) Commit()
func (*ObservationBuffer) Discard ¶
func (b *ObservationBuffer) Discard()
func (*ObservationBuffer) DrainPromptCacheObservations ¶
func (b *ObservationBuffer) DrainPromptCacheObservations() []Observation
type ObservationLineage ¶
type ObservationLineage struct {
ALegID string
BLegID string
BackendInstanceID string
CanonicalModelID string
}
ObservationLineage carries only bounded routing/session attribution needed by a provider adapter to associate a foreground observation with its B-leg. It is not a cache identity or a scheduling key.
func ObservationLineageFromContext ¶
func ObservationLineageFromContext(ctx context.Context) (ObservationLineage, bool)
type ObservationSource ¶
type ObservationSource interface{ DrainPromptCacheObservations() []Observation }
type Profile ¶
type Profile struct {
ObservationSupported bool
RenewalSupported bool
LifecycleKinds []LifecycleKind
}
type ReleaseRequest ¶
type ReleaseRequest struct{ Handle Handle }
func (ReleaseRequest) Validate ¶
func (r ReleaseRequest) Validate() error
type RenewRequest ¶
func (RenewRequest) Validate ¶
func (r RenewRequest) Validate() error
type RenewResponse ¶
type RenewResponse struct {
Result RenewResult
Accounting *AccountingEvidence
}
func (RenewResponse) Validate ¶
func (r RenewResponse) Validate() error
type RenewResult ¶
type RenewResult struct {
Status RenewStatus
Observation *Observation
Evidence CacheEvidence
}
func (RenewResult) Validate ¶
func (r RenewResult) Validate() error
type RenewStatus ¶
type RenewStatus string
const ( Renewed RenewStatus = "renewed" StillResident RenewStatus = "still_resident" ColdRecreated RenewStatus = "cold_recreated" Stale RenewStatus = "stale" Unsupported RenewStatus = "unsupported" ControlFailed RenewStatus = "control_failed" )
func (RenewStatus) Validate ¶
func (s RenewStatus) Validate() error
Click to show internal directories.
Click to hide internal directories.