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 ¶
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
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 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 ¶
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 ¶
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 ¶
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 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 ¶
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.