readiness

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package readiness derives operational readiness state from a contract's declared readiness section. It is a pure, provider-neutral library shared by the Pacto CLI and the Pacto operator: given the declared checks and a point in time it computes per-check status, weight totals, and an overall score. It does not verify that the referenced evidence actually exists.

Index

Constants

View Source
const DefaultMinScore = 100

DefaultMinScore is the gate threshold used when a contract declares readiness but omits minScore: every weighted check must be current.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult

type CheckResult struct {
	ID            string
	Type          string
	Evidence      string
	Weight        int
	Expires       string
	Description   string
	Status        Status
	DaysRemaining *int
}

CheckResult is the derived state of one declared readiness check. It echoes the declared fields and adds the computed Status and, for current checks, the number of whole days remaining until the evidence expires.

type Result

type Result struct {
	Score         int
	TotalWeight   int
	CurrentWeight int
	CurrentCount  int
	ExpiredCount  int
	InvalidCount  int
	// MinScore is the effective gate threshold (the declared readiness.minScore,
	// or DefaultMinScore when omitted).
	MinScore int
	// Passing reports whether the gate is met (Score >= MinScore).
	Passing bool
	Checks  []CheckResult
}

Result is the derived readiness assessment of a contract. Score is the percentage of declared weight that is currently satisfied (0 when no weight is declared, avoiding division by zero).

func Evaluate

func Evaluate(r *contract.Readiness, now time.Time) *Result

Evaluate derives readiness state from the declared readiness section as of now. It returns nil when no readiness is declared (a nil section or no checks), so callers can treat "no readiness" as an absent result. Evidence is considered current through the end of its expires date; the day boundary is computed in UTC so the result is independent of the caller's timezone.

type Status

type Status string

Status is the derived state of a single readiness check.

const (
	// StatusCurrent means the evidence has not yet expired.
	StatusCurrent Status = "Current"
	// StatusExpired means the expires date has passed.
	StatusExpired Status = "Expired"
	// StatusInvalid means the expires date could not be parsed.
	StatusInvalid Status = "Invalid"
)

Jump to

Keyboard shortcuts

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