embeddedbudget

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package embeddedbudget measures and enforces checked-in catalog budgets.

Index

Constants

View Source
const (
	// DefaultMaxAge is the checked-in catalog freshness budget.
	DefaultMaxAge = 30 * 24 * time.Hour
	// DefaultMaxUncompressedBytes is the canonical payload size budget.
	DefaultMaxUncompressedBytes int64 = 16 << 20
	// DefaultMaxCompressedBytes is the deterministic archive size budget.
	DefaultMaxCompressedBytes int64 = 8 << 20
	// DefaultMinProviders is the minimum embedded provider coverage.
	DefaultMinProviders = 5
	// DefaultMinModels is the minimum embedded canonical model coverage.
	DefaultMinModels = 100
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	MaxAge               time.Duration `json:"-"`
	MaxUncompressedBytes int64         `json:"max_uncompressed_bytes"`
	MaxCompressedBytes   int64         `json:"max_compressed_bytes"`
	MinProviders         int           `json:"min_providers"`
	MinModels            int           `json:"min_models"`
}

Limits are the reviewed age, size, and coverage thresholds.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns the checked-in production budget policy.

func (Limits) MarshalJSON

func (l Limits) MarshalJSON() ([]byte, error)

MarshalJSON emits the age limit in seconds so CI reports have an explicit, language-independent unit rather than time.Duration nanoseconds.

func (Limits) Validate

func (l Limits) Validate() error

Validate verifies that every threshold is positive.

type Report

type Report struct {
	GenerationID      string      `json:"generation_id"`
	GeneratedAt       time.Time   `json:"generated_at"`
	MeasuredAt        time.Time   `json:"measured_at"`
	AgeSeconds        int64       `json:"age_seconds"`
	PayloadChecksum   string      `json:"payload_checksum"`
	UncompressedBytes int64       `json:"uncompressed_bytes"`
	CompressedBytes   int64       `json:"compressed_bytes"`
	ProviderCount     int         `json:"provider_count"`
	ModelCount        int         `json:"model_count"`
	Limits            Limits      `json:"limits"`
	OverrideReason    string      `json:"override_reason,omitempty"`
	Passed            bool        `json:"passed"`
	Violations        []Violation `json:"violations,omitempty"`
}

Report records exact embedded catalog measurements and applied limits.

func Check

func Check(generation catalogstore.Generation, measuredAt time.Time, limits Limits, overrideReason string) (Report, error)

Check measures one validated generation and applies age, compressed and uncompressed size, provider, and model budgets.

type Violation

type Violation struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Violation is one stable machine-readable budget failure.

Jump to

Keyboard shortcuts

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