WplAi.Validator (WPL-AI v1.7.0)

Copy Markdown View Source

Semantic validator for WPL-AI AST documents.

Walks the AST after parsing and emits warnings (not errors) for values that don't match known WPL vocabulary. Plans with unknown values still compile, but this module flags them so the user gets actionable feedback.

Mirrors the TypeScript validateSemantics function in wpl-ai/src/validator.ts.

Summary

Functions

Validate a parsed AST document, returning a list of semantic warnings.

Types

warning()

@type warning() :: %{severity: :warning | :info, message: String.t()}

Functions

validate_semantics(doc)

@spec validate_semantics(WplAi.AST.Document.t()) :: [warning()]

Validate a parsed AST document, returning a list of semantic warnings.

Warnings are produced for values that don't match known WPL vocabulary. The plan is still valid (warnings, not errors).

Examples

iex> {:ok, doc} = WplAi.parse(source)
iex> warnings = WplAi.Validator.validate_semantics(doc)
iex> Enum.filter(warnings, &String.contains?(&1.message, "measurement metric"))
[]