ExMaude.AI.Validator (ExMaude v0.2.0)

View Source

Validates AI rule structures before encoding to Maude.

Companion to ExMaude.IoT.Validator. Catches shape errors, unsupported predicate types, and obviously-malformed values before they reach the Maude port worker. Validation here is cheap; rejecting at this layer avoids the cost of a Maude round trip for a malformed rule.

An AI rule is a map with these required fields:

  • :id — non-empty string
  • :agent_id{tenant_id :: String.t(), agent_name :: String.t()}
  • :trigger — predicate (see Encoder docs for predicate shapes)
  • :invocations — list of tool invocations (may be empty)

Optional fields:

  • :capability_grants — list of {:cap, name, shape} or bare strings
  • :authority_required — non-negative integer (default 0)
  • :priority — non-negative integer (default 1)

Summary

Functions

Validates a single AI rule.

Validates a list of rules. Returns :ok if all rules pass, or {:error, %{rule_id => errors}} mapping failing rule ids to their error lists.

Functions

validate_rule(rule)

@spec validate_rule(term()) :: :ok | {:error, [String.t()]}

Validates a single AI rule.

Returns :ok on success, or {:error, [error_msg]} listing all validation failures.

validate_rules(rules)

@spec validate_rules([term()]) ::
  :ok | {:error, %{required(String.t()) => [String.t()]}}

Validates a list of rules. Returns :ok if all rules pass, or {:error, %{rule_id => errors}} mapping failing rule ids to their error lists.