budget

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package budget measures the checked-in catalog and applies release policy.

Index

Constants

View Source
const (
	// CurrentPolicyVersion identifies the machine-readable release policy shape.
	CurrentPolicyVersion uint64 = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Classification

type Classification string

Classification controls whether a policy finding blocks a release.

const (
	// ClassificationHardGate blocks a release when a correctness invariant fails.
	ClassificationHardGate Classification = "hard_gate"
	// ClassificationReviewThreshold records a review trigger without rejecting a release.
	ClassificationReviewThreshold Classification = "review_threshold"
)

type Finding

type Finding struct {
	Code           string         `json:"code"`
	Classification Classification `json:"classification"`
	Message        string         `json:"message"`
}

Finding records one measurement that crossed a classified policy boundary.

type Policy

type Policy struct {
	Version uint64 `json:"version"`
	Rules   []Rule `json:"rules"`
}

Policy is the versioned catalog release policy applied to one measurement.

func DefaultPolicy

func DefaultPolicy() Policy

DefaultPolicy returns the reviewed catalog release policy.

func (Policy) Validate

func (p Policy) Validate() error

Validate rejects an incomplete or unsupported policy before measurement.

type Report

type Report struct {
	SchemaVersion     uint64    `json:"schema_version"`
	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"`
	Policy            Policy    `json:"policy"`
	Passed            bool      `json:"passed"`
	Findings          []Finding `json:"findings,omitempty"`
}

Report records exact catalog measurements and the policy applied to them.

func Check

func Check(generation catalogs.Generation, measuredAt time.Time, policy Policy) (Report, error)

Check measures one validated generation and applies the supplied policy.

type Rule

type Rule struct {
	Code              string         `json:"code"`
	Classification    Classification `json:"classification"`
	Objective         string         `json:"objective"`
	MeasurementMethod string         `json:"measurement_method"`
	Unit              string         `json:"unit"`
	ApprovedLimit     string         `json:"approved_limit"`
	Consequence       string         `json:"consequence"`
	Owner             string         `json:"owner"`
	ExceptionPath     string         `json:"exception_path"`
	ReopenCondition   string         `json:"reopen_condition"`
}

Rule defines one classified release-policy decision.

Jump to

Keyboard shortcuts

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