Documentation
¶
Overview ¶
Package parse decodes and validates workflow.yaml bodies. Pure in-memory transforms over the types defined in `workflow` root pkg — no filesystem, no engine, no executors.
Use Parse to turn a byte slice into a Workflow + a synthesized ID, then Validate to gather every static problem (errors that block load + warnings that don't) before handing the workflow to engine or service layers.
Index ¶
- Variables
- func BfsReachable(g workflow.Graph, roots map[string]bool) map[string]bool
- func DetectCycle(g workflow.Graph) []string
- func Marshal(w workflow.Workflow) ([]byte, error)
- func Parse(id string, data []byte) (workflow.Workflow, error)
- func ValidateID(id string) error
- func ValidateLabel(label string) error
- func ValidateNodeID(id string) error
- type Error
- type Result
Constants ¶
This section is empty.
Variables ¶
var IDRe = regexp.MustCompile(`^[a-z0-9-]+$`)
IDRe is the canonical id pattern. Folder names and trigger path templates must match.
var IdentRe = regexp.MustCompile(`^[A-Za-z_][A-Za-z0-9_]*$`)
IdentRe is the Go-template identifier pattern. Used for node ids, trigger ids, and labels — anything that will appear as a key in `{{.Node.<key>.…}}`. Letters/digits/underscore, must start with letter or underscore. Dashes are banned so the template parser doesn't choke with "bad character U+002D".
var NodeIDRe = regexp.MustCompile(`^[a-z0-9_-]+$`)
NodeIDRe accepts id charset plus underscore. Underscore is allowed because palette node-type names (e.g. `session_init`, `dataset_query`) are reused as the seeded ID on drop — rejecting `_` here would force every Go const to dual-spell as `session-init` solely for the validator. Folder names still use IDRe (hyphen-only).
Functions ¶
func BfsReachable ¶
BfsReachable returns the set of node IDs reachable from any root.
func DetectCycle ¶
DetectCycle returns the IDs of nodes participating in a cycle, or nil if the graph is acyclic. Uses Kahn's topological sort.
func Parse ¶
Parse decodes a workflow.yaml body. The folder name is the authoritative ID — it overwrites whatever `id:` happens to be in the YAML so renaming a folder always wins over a stale value. The returned workflow has not yet been validated; call Validate after.
func ValidateID ¶
ValidateID rejects names that would break path math.
func ValidateLabel ¶
ValidateLabel rejects bad labels. Same rule as ValidateNodeID since labels are how operators reference nodes in templates.
func ValidateNodeID ¶
ValidateNodeID rejects bad node IDs. Strict identifier rule — must work as a Go-template path segment in `{{.Node.<id>.…}}`.
Types ¶
type Error ¶
Error is returned by Parse with a path-style locator for the offending field so callers (UI, MCP) can surface "yaml: graph.edges[2]: ...".
type Result ¶
Result is the aggregate of static checks performed by Validate. Ok() == true means no Errors (Warnings always allowed). Implements error so callers can `if err := r.AsError(); err != nil`.