greencontract

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package greencontract records validation requirements for completed work.

Index

Constants

View Source
const (
	LevelTargetedTests = "targeted_tests"
	LevelPackage       = "package"
	LevelWorkspace     = "workspace"
	LevelMergeReady    = "merge_ready"

	RequirementRequiredLevel          = "required_level"
	RequirementTestCommandProvenance  = "test_command_provenance"
	RequirementBaseBranchFreshness    = "base_branch_freshness"
	RequirementRecoveryAttemptContext = "recovery_attempt_context"
	OutcomeSatisfied                  = "satisfied"
	OutcomeUnsatisfied                = "unsatisfied"
	StatusSatisfied                   = "satisfied"
	StatusUnsatisfied                 = "unsatisfied"
)

Variables

This section is empty.

Functions

func LevelSatisfies

func LevelSatisfies(required string, observed string) bool

func NormalizeLevel

func NormalizeLevel(level string) (string, error)

func StatusForOutcome

func StatusForOutcome(outcome Outcome) string

Types

type Contract

type Contract struct {
	RequiredLevel    string   `json:"required_level"`
	Requirements     []string `json:"requirements,omitempty"`
	BlockKnownFlakes bool     `json:"block_known_flakes"`
}

func MergeReady

func MergeReady(requiredLevel string) (Contract, error)

func New

func New(requiredLevel string) (Contract, error)

func (Contract) EvaluateEvidence

func (c Contract) EvaluateEvidence(e Evidence) (Outcome, error)

func (Contract) EvaluateLevel

func (c Contract) EvaluateLevel(observedLevel string) (Outcome, error)

type Evidence

type Evidence struct {
	ObservedLevel                  string                  `json:"observed_level"`
	TestCommands                   []TestCommandProvenance `json:"test_commands,omitempty"`
	BaseBranchFresh                bool                    `json:"base_branch_fresh"`
	KnownFlakes                    []KnownFlake            `json:"known_flakes,omitempty"`
	RecoveryAttemptContextRecorded bool                    `json:"recovery_attempt_context_recorded"`
}

func (Evidence) HasPassingTestCommand

func (e Evidence) HasPassingTestCommand() bool

type KnownFlake

type KnownFlake struct {
	TestName    string `json:"test_name"`
	BlocksGreen bool   `json:"blocks_green"`
}

type Outcome

type Outcome struct {
	Outcome        string       `json:"outcome"`
	RequiredLevel  string       `json:"required_level"`
	ObservedLevel  string       `json:"observed_level,omitempty"`
	Missing        []string     `json:"missing,omitempty"`
	BlockingFlakes []KnownFlake `json:"blocking_flakes,omitempty"`
}

func (Outcome) Satisfied

func (o Outcome) Satisfied() bool

type TestCommandProvenance

type TestCommandProvenance struct {
	Command  string `json:"command"`
	ExitCode int    `json:"exit_code"`
}

func (TestCommandProvenance) Passed

func (p TestCommandProvenance) Passed() bool

Jump to

Keyboard shortcuts

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