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 LabelRe = regexp.MustCompile(`^[a-z_][a-z0-9_]*$`)
LabelRe is stricter than IdentRe — lowercase only. Keeps node labels predictable across the team (no `User` vs `user` aliases) and matches the canvas-side isValidIdent rule.
var NodeIDLooseRe = regexp.MustCompile(`^[A-Za-z0-9_][A-Za-z0-9_-]*$`)
NodeIDLooseRe matches the two ID shapes wick currently accepts:
- Go identifier (legacy, hand-edited YAML)
- UUID v4 (auto-minted by the canvas + MCP add_node)
Templates can't reference a UUID ID via the dotted form (UUID dashes break the parser) so when ID is a UUID the canvas falls back to the label for `{{.Node.<label>.…}}` refs. The struct-level fields (edges, entry_node, session_from) always use ID directly.
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`, `datatable_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. Accepts both Go identifiers (legacy human-typed) and UUID-shaped values (current default — UI + MCP mint one on add) so existing workflows keep loading.
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`.