contextusage

package
v0.3.0-beta.30 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Turns

func Turns(in Input) ([]Turn, []Compaction)

Types

type Compaction

type Compaction struct {
	Sequence                 int64
	At                       time.Time
	TurnID                   string
	FromSequence, ToSequence int64
	Used, Size               int64
	Pressure                 float64
	Strategy                 string
	SpanArchived             bool
}

type ContextUsage

type ContextUsage struct {
	State             State
	Used, Size        *int64
	Ratio             *float64
	SizeSource        string
	Stale             *bool
	Sequence          *int64
	ReportedTurnID    string
	ReportedAt        *time.Time
	PressureThreshold *float64
	Injected          *Injected
}

func Derive

func Derive(in Input) ContextUsage

type Delivery

type Delivery struct {
	Sequence int64
	At       time.Time
	SentAt   time.Time
	TurnID   string
	Estimate string
	Spans    []Span
}

type Injected

type Injected struct {
	Estimate string
	Tokens   int64
	Stale    bool
	Rows     []Row
}

type Input

type Input struct {
	UsageEvents   []UsageEvent
	Deliveries    []Delivery
	Compactions   []Compaction
	Settled       *SettledTurn
	CatalogWindow *int64
	Threshold     *float64
	Available     bool
}

type Row

type Row struct {
	Key, Label, Kind, Delivery, Name string
	OwnerKind                        string
	Bytes                            int64
	Tokens                           *int64
	DeliveredTurnID                  string
	DeliverySequence                 int64
	SentAt                           time.Time
	LastSeenTurnID                   string
	Unchanged, Stale, HookModified   bool
}

type SettledTurn

type SettledTurn struct {
	TurnID   string
	Sequence int64
}

type Span

type Span struct {
	Key, Kind, Delivery, Name             string
	Bytes                                 int64
	Tokens                                *int64
	Unchanged, StartupDedup, HookModified bool
}

type State

type State string
const (
	StateReported      State = "reported"
	StateEstimatedSize State = "estimated_size"
	StateUnknown       State = "unknown"
	StateUnavailable   State = "unavailable"
)

type Turn

type Turn struct {
	TurnID        string
	Sequence      int64
	Usage         *store.TokenUsage
	UsageSequence *int64
	Injected      *Delivery
}

type UsageEvent

type UsageEvent struct {
	Sequence int64
	At       time.Time
	TurnID   string
	Usage    store.TokenUsage
}

Jump to

Keyboard shortcuts

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