composition

package
v1.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package composition defines RFC 0010 workflow-composition types and their validation. It is a leaf package: it imports neither runtime/pipeline nor runtime/workflow, so workflow.State can reference these types without a cycle.

Index

Constants

View Source
const (
	ReduceAppend  = "append"
	ReduceReplace = "replace"
	ReduceBarrier = "barrier"
)

Reduce strategies (RFC 0010 v1).

Variables

This section is empty.

Functions

func ParseConfig

func ParseConfig(raw interface{}) (map[string]*Composition, error)

ParseConfig parses an untyped compositions map (typically config.Compositions, stored as interface{}) into typed Compositions keyed by name. Returns nil, nil when raw is nil. Mirrors workflow.ParseConfig.

func StepInputValue added in v1.8.0

func StepInputValue(s *Step) any

StepInputValue returns a step's input in the form the resolver expects: the reference string, the literal object, or nil.

The spec models input as a union — a "${...}" reference or an object of literals and references — so the generated field is a small wrapper rather than `any`. This unwraps it in one place instead of at each call site.

Types

type Available

type Available struct {
	Prompts []string
	Tools   []string
	Evals   []string
}

Available holds the pack key sets a composition's references resolve against.

type Composition

type Composition = packspec.Composition

Composition is a named step graph over the pack's prompts, tools, and evals.

Generated from the schema: an ALIAS for packspec.Composition.

type Predicate

type Predicate = packspec.Predicate

Predicate is the constrained predicate language. Exactly one variant is set: compare (path+op+value), exists (path+exists), or a composite (all_of/any_of/not).

Generated from the schema: an ALIAS for packspec.Predicate. The schema expresses this as a oneOf union; Go has no sum type, so the generator flattens it exactly as this hand-written type already did.

type Reducer

type Reducer = packspec.Reducer

Reducer declares how parallel branch outputs merge. Both fields required. Generated from the schema: an ALIAS for packspec.Reducer, not a copy. The hand-written struct was field-for-field identical to $defs/Reducer.

type RetryModifier

type RetryModifier = packspec.StepModifiersRetry

RetryModifier re-runs a step on error up to MaxAttempts.

An ALIAS for the generated packspec.StepModifiersRetry — the schema nests this shape inside StepModifiers rather than naming it, so the generator hoists it under a derived name. Field-for-field identical; the alias keeps the local name every call site already uses.

type Step

type Step = packspec.Step

Step is a single node in a composition graph. Only the fields legal for Kind are set; per-kind legality is enforced by Validate.

Generated from the schema: an ALIAS for packspec.Step. The schema expresses this as a oneOf over the five *Step kinds; Go has no sum type, so the generator flattens it exactly as this hand-written type already did, keeping the `kind` discriminator.

type StepKind

type StepKind = string

StepKind identifies a composition step's kind.

const (
	KindPrompt   StepKind = "prompt"
	KindAgent    StepKind = "agent"
	KindTool     StepKind = "tool"
	KindBranch   StepKind = "branch"
	KindParallel StepKind = "parallel"
)

Step kinds (RFC 0010 v1).

type StepModifiers

type StepModifiers = packspec.StepModifiers

StepModifiers are optional per-step behaviors (RFC 0010 v1: retry, eval).

Generated from the schema: an ALIAS for packspec.StepModifiers.

type Termination

type Termination = packspec.TerminationPredicate

Termination bounds an agent step's tool loop. anyOf max_steps | tool_called.

Generated from the schema: an ALIAS for packspec.TerminationPredicate.

type ValidationResult

type ValidationResult struct {
	Errors   []string
	Warnings []string
}

ValidationResult holds blocking errors and non-blocking warnings.

func Validate

func Validate(name string, c *Composition, avail Available) *ValidationResult

Validate checks a single composition against the available pack key sets. It implements composition-internal rules 2–11 from the design (rule 1 and the workflow/pack-level rules live in ValidateAll and Plan 3 respectively).

func ValidateAll

func ValidateAll(comps map[string]*Composition, avail Available) *ValidationResult

ValidateAll validates every composition in a pack map and checks pack-wide rules (rule 1: key uniqueness is inherent to the map; reserved-name collision).

func (*ValidationResult) HasErrors

func (r *ValidationResult) HasErrors() bool

HasErrors reports whether there are blocking validation errors.

Directories

Path Synopsis
Package engine is the deterministic orchestrator core for RFC 0010 workflow compositions.
Package engine is the deterministic orchestrator core for RFC 0010 workflow compositions.

Jump to

Keyboard shortcuts

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