governance

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsCostHook

func AsCostHook(ledger CostLedger, estimatedCostMicros int64, budgetLimitMicros int64) action.AnyHook

Types

type BudgetCheck

type BudgetCheck struct {
	Scope CostScope
	Key   string
	Limit int64
}

type CostEvent

type CostEvent struct {
	RunID      string    `json:"run_id"`
	TenantID   string    `json:"tenant_id"`
	SourceNode string    `json:"source_node"`
	RecordedAt time.Time `json:"recorded_at"`
	Usage      CostUsage `json:"usage"`
}

type CostLedger

type CostLedger interface {
	Reserve(ctx context.Context, event CostEvent, limits []BudgetCheck) error
	Events(ctx context.Context, runID string) ([]CostEvent, error)
}

type CostScope

type CostScope string
const (
	ScopeRun    CostScope = "run"
	ScopeDay    CostScope = "day"
	ScopeMonth  CostScope = "month"
	ScopeTenant CostScope = "tenant"
)

type CostUsage

type CostUsage struct {
	InputTokens  int64 `json:"input_tokens"`
	OutputTokens int64 `json:"output_tokens"`
	CostMicros   int64 `json:"cost_micros"`
}

type MemoryCostLedger

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

func NewMemoryCostLedger

func NewMemoryCostLedger() *MemoryCostLedger

func (*MemoryCostLedger) Events

func (l *MemoryCostLedger) Events(_ context.Context, runID string) ([]CostEvent, error)

func (*MemoryCostLedger) Reserve

func (l *MemoryCostLedger) Reserve(_ context.Context, event CostEvent, limits []BudgetCheck) error

Jump to

Keyboard shortcuts

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