Module validate

Source
Expand description

Response validation for AIM (Agentic Inference Markup) workflows.

This module provides the core functionality for validating and assigning inference responses to AIM rules. The validation process ensures type safety and proper assignment of values to rules that are designed to receive inference results from AI models.

§Overview

The validation system bridges the gap between raw AI model responses and structured AIM workflow rules. It follows a systematic process:

  1. Rule Identification - Iterates through all rules in an AIM structure
  2. Assignment Detection - Identifies assignment rules (underscore prefixes)
  3. Response Matching - Converts rule identifiers to uppercase for matching
  4. Type Validation - Validates responses against rule type definitions
  5. Value Assignment - Assigns validated values to rules via context

This module is designed to be fault-tolerant, recognizing that AI model responses can be probabilistic and sometimes malformed.

§Assignment Rule Convention

AIM workflows use a special naming convention for rules that accept inference results:

  • Assignment Rules: Identifiers starting with _ (e.g., _summary, _sentiment)
  • Uppercase Matching: Rules like _example match responses keyed as EXAMPLE

This convention allows workflows to clearly separate inference-assigned values from statically defined ones.

§Typical Usage Flow

AI Model Response → Response Parsing → Validation → Rule Assignment

The module is typically used after parsing inference responses to automatically populate AIM rules with validated results.

Functions§

validate_responses
Validates inference responses and assigns them to matching assignment rules in an AIM structure.