contextusage

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 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 ClearedBy

type ClearedBy struct {
	CompactionID string
	Sequence     int64
}

type Compaction

type Compaction struct {
	ContextAfter *ContextAfter
	Sequence     int64
	At           time.Time
	TurnID       string
	CompactionID string
	Trigger      string
	Status       string
	Used, Size   *int64
}

type ContextAfter

type ContextAfter struct {
	Used     int64
	Size     *int64
	Sequence int64
}

type ContextUsage

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

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 {
	WorkTime           WorkTime
	UsageEvents        []UsageEvent
	Deliveries         []Delivery
	Compactions        []Compaction
	Settled            *SettledTurn
	CatalogWindow      *int64
	CompactionBoundary *int64
	ClearedBy          *ClearedBy
	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
}

type WorkTime

type WorkTime struct {
	ActiveDurationMS    int64
	TurnCount           int64
	LastCompletedTurnID string
}

Jump to

Keyboard shortcuts

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