pipeline

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package pipeline implements the spec pipeline stage machine.

Package pipeline implements the spec pipeline stage machine.

Index

Constants

View Source
const (
	// StatusBlocked is the escape hatch status.
	StatusBlocked = "blocked"
)

Variables

This section is empty.

Functions

func AllGatesPassed

func AllGatesPassed(results []GateResult) bool

AllGatesPassed returns true if all gates passed.

func EffectiveStages

func EffectiveStages(resolved *ResolvedPipeline, ctx expr.Context) []config.StageConfig

EffectiveStages returns the stages that apply to a spec after evaluating skip_when. This is used for determining the actual pipeline path for a spec.

func NextEffectiveStage

func NextEffectiveStage(resolved *ResolvedPipeline, current string, ctx expr.Context) (string, bool)

NextEffectiveStage returns the next stage that isn't skipped.

func NextStage

func NextStage(pipeline config.PipelineConfig, current string, includeOptional bool) (string, error)

NextStage returns the next non-optional stage, or the next stage if includeOptional.

func PresetInfo

func PresetInfo(name string) (description string, features []string, stageNames []string, err error)

PresetInfo returns metadata about a preset for display.

func PresetNames

func PresetNames() []string

PresetNames returns the names of all available presets.

func Resume

func Resume(path string, meta *markdown.SpecMeta, previousStage string) error

Resume returns a blocked spec to its pre-block stage.

func Revert

func Revert(path string, meta *markdown.SpecMeta, targetStage, reason, user string) error

Revert sends a spec back to a previous stage.

func ShouldSkipStage

func ShouldSkipStage(resolved *ResolvedPipeline, stageName string, ctx expr.Context) (bool, string)

ShouldSkipStage checks if a specific stage should be skipped for a spec.

func SkippedStages

func SkippedStages(pipeline config.PipelineConfig, from, to string) []string

SkippedStages returns the stages that would be skipped in a fast-track.

func StageHasOwner

func StageHasOwner(pipeline config.PipelineConfig, stageName, role string) bool

StageHasOwner returns true if the given role is an owner of the stage.

func StageOwner

func StageOwner(pipeline config.PipelineConfig, stageName string) string

StageOwner returns the owner role for a stage as a display string.

func TerminalStages

func TerminalStages(pipeline config.PipelineConfig) []string

TerminalStages returns stages that represent completion. The last required stage and any auto-archive stages are considered terminal. Falls back to "done" and "closed" if nothing else matches.

func ValidateAdvance

func ValidateAdvance(pipeline config.PipelineConfig, currentStage, targetStage, userRole string) error

ValidateAdvance checks if advancing from the current stage is permitted.

func ValidateRevert

func ValidateRevert(pipeline config.PipelineConfig, currentStage, targetStage, userRole string) error

ValidateRevert checks if reverting to a previous stage is permitted.

Types

type AdvanceResult

type AdvanceResult struct {
	PreviousStage string
	NewStage      string
	SkippedStages []string
}

AdvanceResult contains the result of advancing a spec.

func Advance

func Advance(path string, meta *markdown.SpecMeta, target string) (*AdvanceResult, error)

Advance updates the spec's status to the next (or target) stage.

type EjectResult

type EjectResult struct {
	PreviousStage string
}

EjectResult contains the result of ejecting a spec.

func Eject

func Eject(path string, meta *markdown.SpecMeta, reason, user string) (*EjectResult, error)

Eject transitions a spec to blocked status.

type GateResult

type GateResult struct {
	Gate   string
	Passed bool
	Reason string
}

GateResult represents the result of a gate check.

func EvaluateGates

func EvaluateGates(pipeline config.PipelineConfig, currentStage string, sections []markdown.Section, hasPRStack bool, prsApproved bool, meta *markdown.SpecMeta) []GateResult

EvaluateGates checks all gates for the current stage by building a context from raw parameters.

func EvaluateGatesWithContext

func EvaluateGatesWithContext(pipeline config.PipelineConfig, currentStage string, ctx expr.Context) []GateResult

EvaluateGatesWithContext checks all gates using a pre-built expression context.

func FailedGates

func FailedGates(results []GateResult) []GateResult

FailedGates returns only the gates that did not pass.

type PresetConfig

type PresetConfig struct {
	Name        string               `yaml:"name"`
	Description string               `yaml:"description"`
	Features    []string             `yaml:"features"`
	Stages      []config.StageConfig `yaml:"stages"`
}

PresetConfig holds a preset pipeline definition.

func LoadPreset

func LoadPreset(name string) (*PresetConfig, error)

LoadPreset returns the preset configuration for the given name.

type ResolvedPipeline

type ResolvedPipeline struct {
	// Stages is the final list of stages in order.
	Stages []config.StageConfig

	// StageIndex maps stage name to index for fast lookup.
	StageIndex map[string]int

	// PresetName is the preset that was used (empty if none).
	PresetName string

	// VariantName is the variant that was selected (empty if default).
	VariantName string

	// SkippedStages lists stages that were removed via Skip config.
	SkippedStages []string
}

ResolvedPipeline is a fully resolved pipeline configuration with all presets expanded, stages skipped, and overrides applied.

func Resolve

Resolve takes a pipeline config and returns a fully resolved pipeline. It handles: 1. Loading the preset (if specified) 2. Removing skipped stages 3. Merging/overriding stages from config

func ResolveForSpec

func ResolveForSpec(cfg config.PipelineConfig, labels []string) (*ResolvedPipeline, error)

ResolveForSpec returns the pipeline variant for a specific spec based on its labels.

func (*ResolvedPipeline) IsValidReversion

func (r *ResolvedPipeline) IsValidReversion(from, to string) bool

IsValidReversion checks if reverting from 'from' to 'to' is valid.

func (*ResolvedPipeline) IsValidTransition

func (r *ResolvedPipeline) IsValidTransition(from, to string) bool

IsValidTransition checks if advancing from 'from' to 'to' is valid.

func (*ResolvedPipeline) NextStage

func (r *ResolvedPipeline) NextStage(current string) (string, bool)

NextStage returns the next stage after the given one.

func (*ResolvedPipeline) PrevStage

func (r *ResolvedPipeline) PrevStage(current string) (string, bool)

PrevStage returns the previous stage before the given one.

func (*ResolvedPipeline) StageByName

func (r *ResolvedPipeline) StageByName(name string) *config.StageConfig

StageByName returns the stage with the given name, or nil if not found.

func (*ResolvedPipeline) StageOwner

func (r *ResolvedPipeline) StageOwner(name string) string

StageOwner returns the owner role for a stage.

type SkipWhenResult

type SkipWhenResult struct {
	StageName string
	Skipped   bool
	Reason    string // The skip_when expression that matched
}

SkipWhenResult holds the result of evaluating skip_when for a stage.

func EvaluateSkipWhen

func EvaluateSkipWhen(resolved *ResolvedPipeline, ctx expr.Context) []SkipWhenResult

EvaluateSkipWhen evaluates skip_when expressions for all stages given a context. Returns the stages that should be skipped for this spec.

Directories

Path Synopsis
Package effects executes pipeline transition effects.
Package effects executes pipeline transition effects.
Package expr provides expression evaluation for pipeline gates.
Package expr provides expression evaluation for pipeline gates.

Jump to

Keyboard shortcuts

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