compile

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package compile turns a validated spec.Workflow into a frozen, acyclic graph.Graph: it resolves every reroute loop by unrolling it up to the workflow's budgets.maxReroutes bound, so the engine only ever walks a DAG.

A node's own retry (the same node re-attempted up to budgets.maxNodeAttempts) is a runtime engine concern, not a graph edge, and so is never unrolled here: it never appears as a cycle in the compiled graph. What compile unrolls is a *reroute* loop — one or more routes that send work back to an earlier node (e.g. a failure-triage node routing back to the implementer it came from, or a review disposition doing the same). A workflow's reroute loops commonly share nodes — triage, disposition and the human-scope gate can all route back into the same pick-implementer — so the unit of unrolling is a whole strongly connected component (SCC), not one cycle at a time: unrolling cycles independently when they overlap does not converge (each unroll can re-close a different cycle through the nodes it shares with the first).

Within an SCC, compile runs one DFS from a deterministic start node and classifies each internal edge as either a *tree/forward/cross* edge (target not currently on the DFS stack) or a *back* edge (target currently on the stack, i.e. an ancestor) — the standard compiler notion of a retreating edge that closes a loop. budgets.maxReroutes+1 layered copies of the SCC are built: every non-back edge stays within its own layer, every back edge advances to the next layer, and the last layer's back edges are redirected to a synthesized terminal node instead of layer 0, so a run can never loop forever.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(w *spec.Workflow) (*graph.Graph, error)

Compile validates w, then builds and freezes the DAG.

Types

type CycleError

type CycleError struct {
	Cycle []string
}

CycleError names a cycle compile could not resolve. Reaching this after unrollSCC has run over every SCC would mean the SCC decomposition itself was wrong, since every nontrivial SCC is unrolled into an acyclic layered copy; it is kept as a defensive final check, not a documented failure mode.

func (*CycleError) Error

func (e *CycleError) Error() string

Jump to

Keyboard shortcuts

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