runtimehistory

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRange  = errors.New("invalid Runtime history range")
	ErrInvalidResult = errors.New("invalid Runtime history result")
	ErrUnavailable   = errors.New("Runtime history is unavailable")
	ErrUnsupported   = errors.New("Runtime history is unsupported for this Session")
)

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	CollectionMode     CollectionMode
	SampleInterval     time.Duration
	Retention          time.Duration
	MinimumStep        time.Duration
	MaximumRange       time.Duration
	MaximumPoints      int
	MaximumSeries      int
	MaximumTotalPoints int
	Metrics            []Metric
}

Capabilities contains only backend-neutral facts safe to expose through a future public capability response. Backend names, endpoints, credentials and tenant identity are deliberately absent.

func (Capabilities) Durable

func (c Capabilities) Durable() bool

func (Capabilities) Validate

func (c Capabilities) Validate() error

type CollectionMode

type CollectionMode string
const (
	CollectionOnRead   CollectionMode = "on_read"
	CollectionPeriodic CollectionMode = "periodic"
)

type CoveragePoint

type CoveragePoint struct {
	Start, End                      time.Time
	FirstObservedAt, LastObservedAt time.Time
	ObservationCount                int
	ObservedCount, UnavailableCount int
}

type Metric

type Metric string
const (
	MetricCPU    Metric = "cpu"
	MetricMemory Metric = "memory"
	MetricTokens Metric = "tokens"
)

type Point

type Point struct {
	Start, End                            time.Time
	FirstObservedAt, LastObservedAt       time.Time
	ObservationCount                      int
	ObservedCount, UnavailableCount       int
	CPUContributorCount                   int
	MemoryContributorCount                int
	CPUUtilizationRatio, CPUCapacityCores *float64
	MemoryUsageBytes, MemoryLimitBytes    *uint64
}

Point represents one server-selected bucket. CPUUtilizationRatio is derived from ordered cumulative counters within this Series' allocation; a counter regression resets the rate baseline. A provider without cumulative CPU time (E2B) reports utilization directly, and the bucket holds the mean of those reports. Memory values are the final observed values in the bucket.

type Query

type Query struct {
	Scope
	Start, End                        time.Time
	Step                              time.Duration
	Retention                         time.Duration
	MaxPoints                         int
	MaximumSeries, MaximumTotalPoints int
}

type Range

type Range struct {
	Start, End time.Time
	MaxPoints  int
}

type Reader

type Reader interface {
	Capabilities() Capabilities
	Query(context.Context, Query) (Result, error)
}

type Response

type Response struct {
	Capabilities
	Scope
	Requested    Range
	Resolution   time.Duration
	GeneratedAt  time.Time
	RetainedFrom *time.Time
	Coverage     []CoveragePoint
	Series       []Series
	TokenUsage   []TokenUsagePoint
}

func (Response) Validate

func (r Response) Validate(now time.Time) error

type Result

type Result struct {
	GeneratedAt  time.Time
	RetainedFrom *time.Time
	Coverage     []CoveragePoint
	Series       []Series
	TokenUsage   []TokenUsagePoint
}

Result is returned by a backend Reader before the service validates identity, ordering, bounds and values. Empty retained ranges and missing metric values remain explicit; a Reader must never synthesize zeroes for absent samples.

type Scope

type Scope struct {
	TenantID, SessionID, EnvironmentID string
}

type ScopeResolver

type ScopeResolver interface {
	ResolveRuntimeHistoryScope(context.Context, string, string) (Scope, error)
}

type Series

type Series struct {
	Scope
	AllocationID string
	StartedAt    time.Time
	ProviderType string
	Points       []Point
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(resolver ScopeResolver, reader Reader) (*Service, error)

func (*Service) Capabilities

func (s *Service) Capabilities() Capabilities

func (*Service) QuerySession

func (s *Service) QuerySession(ctx context.Context, tenantID, sessionID string, requested Range) (Response, error)

QuerySession resolves authenticated Core ownership before issuing any backend request. The history Reader receives only Core identity and bounded range data; provider-native identity is never an authority-bearing input.

type TokenUsagePoint

type TokenUsagePoint struct {
	Start, End                time.Time
	SampledAt                 time.Time
	InputTokens, OutputTokens uint64
}

TokenUsagePoint is the final cumulative measured Session usage, active Turns included, in one bucket. Throughput is derived from ordered adjacent points by clients.

Directories

Path Synopsis
Package postgresreader stores and reads bounded periodic Runtime telemetry.
Package postgresreader stores and reads bounded periodic Runtime telemetry.

Jump to

Keyboard shortcuts

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