engine

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engine is the deterministic orchestrator core for RFC 0010 workflow compositions. It resolves ${...} references against a scope, evaluates the constrained predicate language, merges parallel outputs, and walks the step DAG. Step side-effects run through an injected StepExecutor, so this package imports neither runtime/pipeline nor runtime/providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the deterministic composition scheduler.

func New

func New(exec StepExecutor) *Engine

New builds an Engine around a StepExecutor.

func NewWithRecorder

func NewWithRecorder(exec StepExecutor, rec Recorder) *Engine

NewWithRecorder builds an Engine that records step observations via rec. A nil rec is equivalent to calling New(exec).

func (*Engine) Execute

func (e *Engine) Execute(
	ctx context.Context, comp *composition.Composition, input json.RawMessage,
) (json.RawMessage, error)

Execute walks the composition's step DAG to completion and returns the bound output (comp.Output, or the last output-producing step). The scope map is not safe for concurrent mutation; parallel branches (Task 7) read it during fan-out and their merged result is written back only at the join.

type NamedOutput

type NamedOutput struct {
	ID     string
	Output any
}

NamedOutput pairs a parallel branch id with its decoded output, in branch order.

type Recorder

type Recorder interface {
	RecordStepStarted(stepID, kind string, input json.RawMessage)
	RecordStepCompleted(stepID, kind string, input, output json.RawMessage, attempt int, err error)
	RecordBranch(stepID string, takenTarget string)
	RecordParallel(stepID string, branches []NamedOutput)
}

Recorder observes step execution for observability (Arena testability). Methods are called during Execute; a nil Recorder disables recording. RecordStepStarted and RecordStepCompleted may be called concurrently from parallel branches — implementations must be safe.

type Scope

type Scope map[string]any

Scope holds the composition input plus each completed step's output, shaped for ${input.X} and ${stepID.output.X} resolution.

type StepExecutor

type StepExecutor func(ctx context.Context, step *composition.Step, input json.RawMessage) (json.RawMessage, error)

StepExecutor runs one leaf step (prompt|agent|tool) and returns its raw output. input is the step's resolved Input (prompt/agent) or resolved Args (tool), marshaled to JSON. Injected so the orchestrator core is testable without a pipeline; Plan 2b supplies the production implementation. For an arg-less tool (nil Args) or nil Input, input is the JSON literal `null`; production executors must treat `null` as "no input/args".

Jump to

Keyboard shortcuts

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