Documentation
¶
Overview ¶
Package aifvalidate is a static, offline validator for AIgentFlow workflow YAML.
It reproduces the *static* verdicts of the AIgentFlow Go reference validator (Validator.ValidateFlowWithDetails + FlowParser.ValidateFlow) and is the Go counterpart of github.com/itsatony/aigentflow-flow-validator-js. Error Code strings are the cross-implementation parity contract; Message wording may differ between the two. See PARITY.md.
Scope: static checks only. Credentials, the model-compliance catalogue, and runtime template field-resolution require a live server and are out of scope.
The library performs no network or filesystem access and builds for GOOS=js GOARCH=wasm, so it can run in a server, a CLI, and a browser.
Index ¶
Constants ¶
const ( // MaxDocumentBytes is the largest flow document accepted. A flow is a // human-authored declaration; anything past this is not one. MaxDocumentBytes = 4 << 20 // 4 MiB // MaxAliasTokens bounds YAML alias (`*ref`) usage, the "billion laughs" // amplification vector. The JS port caps alias EXPANSION at 100 via the yaml // package's maxAliasCount; yaml.v3 has its own internal budget but exposes no // knob, so this is an explicit pre-parse guard on the same class of input. MaxAliasTokens = 100 )
Document limits. These bound the work an untrusted document can cause, which matters because this validator is designed to sit on a publish gate: a caller should be able to hand it arbitrary bytes.
Variables ¶
This section is empty.
Functions ¶
func ExecutorSchemes ¶
func ExecutorSchemes() []string
ExecutorSchemes returns the known executor URI schemes. Unknown schemes are WARNED, never rejected — the vendored list can lag the live registry.
func InputSchemaVersion ¶
func InputSchemaVersion() int
InputSchemaVersion is the only supported `input_schema.version` value.
func SpecVersion ¶
func SpecVersion() string
SpecVersion is the AIgentFlow flow-schema version whose static rules this validator tracks. Report it alongside any verdict: a consumer that BLOCKS on an error needs to tell an author which schema version judged their document, because a newer valid flow can legitimately fail an older pinned validator.
func TemplateFunctionNames ¶
func TemplateFunctionNames() []string
TemplateFunctionNames returns the recognised Go-template function names (Go builtins plus the AIgentFlow registry). Exported because a consumer may want to offer them as editor completions.
Types ¶
type Issue ¶
type Issue struct {
// Field is the dotted path to the offending value, e.g.
// "steps.fetch.query.url". It is the primary way an author locates the
// problem when Line is unavailable.
Field string `json:"field"`
// Message is the human-readable description. NOT part of the parity
// contract — wording may differ from the JS implementation.
Message string `json:"message"`
// Code is the stable, machine-readable identifier. This IS the
// cross-implementation parity contract; compare on Code, never Message.
Code string `json:"code"`
// Severity is "error" or "warning" ("info" reserved).
Severity Severity `json:"severity"`
// StepID names the step when the issue is step-specific.
StepID string `json:"step_id,omitempty"`
// Line and Column are 1-based positions in the source YAML, set only when
// the finding could be located (parse errors always; structural findings
// when the document was parsed with position tracking).
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
// Context carries extra orientation, e.g. the available step names.
Context string `json:"context,omitempty"`
// Suggestion is a concrete proposed fix.
Suggestion string `json:"suggestion,omitempty"`
}
Issue is a single validation finding. Errors and warnings share this shape; a warning simply carries SeverityWarning and never lowers Result.Valid.
The JSON tags mirror the JS validator's ValidationIssue so a consumer can serialise either implementation's findings and render them with one type.
type Options ¶
type Options struct {
// StrictRegistries promotes "unrecognised name" findings — an unknown
// orchestrator tool, an unknown template function — from warning to error.
//
// OFF by default, deliberately: the vendored allow-lists can lag the live
// AIgentFlow registries, and on a publish gate a false-positive error is
// strictly worse than a missed lint. Turn it on for authoring-time linting,
// not for admission control.
StrictRegistries bool
}
Options tunes validation.
type Result ¶
type Result struct {
// Valid is true when there are zero error-severity issues. Warnings never
// affect it.
Valid bool `json:"valid"`
// Errors are the blocking findings.
Errors []Issue `json:"errors"`
// Warnings are advisory findings. A consumer that treats these as blocking
// will reject legitimate flows, because the vendored allow-lists (executor
// schemes, template functions, orchestrator tools) can lag the live
// AIgentFlow registries.
Warnings []Issue `json:"warnings"`
// Summary is the roll-up.
Summary Summary `json:"summary"`
// SpecVersion records which AIgentFlow flow-schema version produced this
// verdict. Carried on the result (not just available via SpecVersion()) so a
// verdict remains self-describing after it is serialised and stored.
SpecVersion string `json:"spec_version"`
}
Result is the complete verdict for one flow.
Errors and Warnings are ALWAYS non-nil slices, even when empty, so the JSON encoding is `[]` and never `null`. A consumer's client code that calls an array method on a `null` is a real and expensive failure mode; a library is the right place to make it impossible.
func ValidateFlow ¶
ValidateFlow parses flow YAML and validates it.
Parse failures (syntax, duplicate keys, non-mapping root) come back as error-severity findings and the structural validators are skipped, because there is no usable document to inspect.
It never panics on malformed input, and never performs I/O. There is deliberately NO recover() at this boundary: a panic here would be a port bug, and swallowing it would report a broken document as valid — on a publish gate that is the worst possible failure. Every validator narrows `any` explicitly instead.
func ValidateFlowObject ¶
ValidateFlowObject validates an already-decoded flow mapping. Use it when the document came from a caller's own loader; use ValidateFlow to parse and validate in one step and to get source positions on findings.
type Severity ¶
type Severity string
Severity of a validation issue. Info is reserved for future lints.
type Summary ¶
type Summary struct {
TotalSteps int `json:"total_steps"`
ValidSteps int `json:"valid_steps"`
ErrorCount int `json:"error_count"`
WarningCount int `json:"warning_count"`
TemplatesFound int `json:"templates_found"`
TemplatesValid int `json:"templates_valid"`
}
Summary is the roll-up for one validation run.
Source Files
¶
- keys.go
- parse.go
- spec.go
- template.go
- types.go
- util.go
- validate.basicstructure.go
- validate.connectivity.go
- validate.credentialbindings.go
- validate.errorstrategy.go
- validate.executors.go
- validate.expressionfunctions.go
- validate.go
- validate.inputschema.go
- validate.loopforeachthrottle.go
- validate.nextlogic.go
- validate.orchestratorcampaign.go
- validate.outputschema.go
- validate.qualitygate.go
- validate.queryschema.go
- validate.responseexpectation.go
- validate.templates.go