Help us shape the future of Go! Take the 2026 Go Developer Survey

capacityfit

package
v0.53.17 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package capacityfit is the shared numerical authority for selected module demand and capacity assessment. Callers bind profile facts and policy to the owning CUE catalog; this package neither selects profiles nor attests hosts.

Index

Constants

View Source
const SchemaVersion = "stackkit.capacity-assessment/v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Assessment

type Assessment struct {
	SchemaVersion string           `json:"schemaVersion"`
	Nodes         []NodeAssessment `json:"nodes"`
	Overall       Verdict          `json:"overall"`
	PolicyRef     string           `json:"policyRef,omitempty"`
}

func Assess

func Assess(input Input) (Assessment, error)

func WithDataStorageChecks

func WithDataStorageChecks(assessment Assessment, checks map[string]Check) (Assessment, error)

WithDataStorageChecks composes the same compiler checks into advisory fit. It accepts already bound checks; it neither calculates new budgets nor authorizes Apply. Known data-space failure outranks a passing module floor.

type Axis

type Axis string
const (
	CPU         Axis = "cpuCores"
	RAM         Axis = "ramGB"
	Storage     Axis = "storageGB"
	DataStorage Axis = "dataStorageGiB"
)

type Check

type Check struct {
	Axis        Axis     `json:"axis"`
	Observed    *float64 `json:"observed,omitempty"`
	Minimum     *float64 `json:"minimum,omitempty"`
	Recommended *float64 `json:"recommended,omitempty"`
	Status      Verdict  `json:"status"`
	ReasonCode  string   `json:"reasonCode"`
}

func DataStorageCheck

func DataStorageCheck(required float64, observed *float64) (Check, error)

DataStorageCheck compares the CUE-derived reservation with free GiB for the exact resolved filesystem. Total disk size must never substitute for free space.

type Demand

type Demand struct {
	NodeRef              string   `json:"nodeRef"`
	ModuleRefs           []string `json:"moduleRefs"`
	UnverifiedModuleRefs []string `json:"unverifiedModuleRefs"`
	UnverifiedAxes       []Axis   `json:"unverifiedAxes"`
	HostFloor            Vector   `json:"hostFloor"`
	Reservation          Vector   `json:"reservation"`
	Recommended          Vector   `json:"recommended"`
	Headroom             Vector   `json:"headroom"`
}

func Aggregate

func Aggregate(modules []Module) ([]Demand, error)

Aggregate uses a stable module order for floating-point budget sums. Plans normalize module sets before verification; that must not change their demand.

type Input

type Input struct {
	Modules    []Module       `json:"modules"`
	Capacities []NodeCapacity `json:"capacities"`
	Policy     *Policy        `json:"policy,omitempty"`
}

type Load

type Load struct {
	Residency string `json:"residency"`
	Baseline  string `json:"baseline"`
	Burst     string `json:"burst"`
}

type Module

type Module struct {
	ID string `json:"id"`
	// Existing projections may explicitly label a profile undeclared even
	// while carrying partial numerical facts. Known failures still take precedence.
	CapacityDeclaration    string   `json:"capacityDeclaration,omitempty"`
	NodeRefs               []string `json:"nodeRefs"`
	Compute                Profile  `json:"compute"`
	OrthogonalReservations []Vector `json:"orthogonalReservations,omitempty"`
	Load                   *Load    `json:"load,omitempty"`
}

type NodeAssessment

type NodeAssessment struct {
	NodeRef     string   `json:"nodeRef"`
	Origin      Origin   `json:"origin"`
	Demand      Demand   `json:"demand"`
	Checks      []Check  `json:"checks"`
	Overall     Verdict  `json:"overall"`
	ReasonCodes []string `json:"reasonCodes"`
	Advice      []string `json:"advice"`
}

type NodeCapacity

type NodeCapacity struct {
	NodeRef string `json:"nodeRef"`
	Origin  Origin `json:"origin"`
	Values  Vector `json:"values"`
}

Inventory identifies the supplied inventory boundary, not cryptographic or current host attestation. The compiler and Apply retain those separate gates.

type Origin

type Origin string
const (
	Declared    Origin = "declared"
	Inventory   Origin = "inventory"
	Unavailable Origin = "unavailable"
)

type Policy

type Policy struct {
	Ref               string   `json:"ref"`
	HeadroomFactor    *float64 `json:"headroomFactor,omitempty"`
	MaxAlwaysOnPerCPU *float64 `json:"maxAlwaysOnPerCPU,omitempty"`
}

Policy has no defaults: every supplied threshold must come from the caller's bound CUE policy. Ref preserves that source; it does not authenticate it.

type Profile

type Profile struct {
	HostFloor   Vector `json:"hostFloor"`
	Reservation Vector `json:"reservation"`
	Recommended Vector `json:"recommended"`
	Headroom    Vector `json:"headroom"`
}

type Vector

type Vector struct {
	CPUCores  *float64 `json:"cpuCores,omitempty"`
	RAMGB     *float64 `json:"ramGB,omitempty"`
	StorageGB *float64 `json:"storageGB,omitempty"`
}

Vector retains unknown axes as nil. Missing facts never become zero.

func Add

func Add(left, right Vector) Vector

func InventoryMinimum

func InventoryMinimum(minimum Vector) Vector

InventoryMinimum is the exact whole-unit threshold used by current compiler inventory admission. It never changes the underlying persisted budgets.

func Max

func Max(left, right Vector) Vector

func Minimum

func Minimum(demand Demand) Vector

Minimum preserves exact budgets; only the inventory comparison rounds up, since current inventory facts attest whole cores/GiB.

func (Vector) Map

func (v Vector) Map() map[string]any

func (*Vector) Set

func (v *Vector) Set(axis Axis, value float64)

func (Vector) Value

func (v Vector) Value(axis Axis) *float64

type Verdict

type Verdict string
const (
	Pass       Verdict = "pass"
	Warning    Verdict = "warning"
	Unverified Verdict = "unverified"
	Fail       Verdict = "fail"
)

func AdmitMinimum

func AdmitMinimum(minimum Vector, capacity NodeCapacity) (Verdict, error)

AdmitMinimum is the compiler's existing hard numeric gate. It evaluates only declared requirements; recommendations and incomplete profile declarations stay outside this narrow call, as in the original admission composition.

func Overall

func Overall(verdicts ...Verdict) Verdict

Jump to

Keyboard shortcuts

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