Module context

Source
Expand description

Evaluation context for expression evaluation within AIM workflows.

The context module provides the runtime environment for evaluating AIMX expressions within the context of AIM workflows. It handles:

  • Variable resolution across multi-level workflow hierarchies
  • Function and method dispatch through the global function registry
  • Closure parameter management for functional programming constructs
  • Caching of evaluation results within a single evaluation session
  • Circular reference detection to prevent infinite loops
  • Inference operations for agentic workflow execution

§Context Architecture

The module defines two primary components:

  1. ContextLike - A trait that defines the interface for evaluation contexts
  2. Context - A complete implementation that integrates with AIM workflows

The Context struct implements the ContextLike trait and provides a full implementation for workflow-based expression evaluation with proper scoping, caching, and inference capabilities.

§Workflow Integration

The context maintains references to workflows at different levels:

  • workflow: The current read-only workflow context
  • workflow_mut: A mutable workflow for making changes during inference
  • scope: The current reference scope for resolving relative references

When evaluating expressions within workflows, the context automatically handles:

  • Multi-part reference resolution (e.g., parent.child.value)
  • Type promotion and validation for assignments
  • Caching of computed values within a session
  • Circular reference detection to prevent stack overflows

§Thread Safety

Each thread should use its own context instance to evaluate a workflow . Context instances are not thread-safe and should not be shared between threads.

Structs§

Context
A default context for evaluating expressions within AIM workflows.

Traits§

ContextLike
Trait for evaluation contexts that provide runtime environment for expression evaluation.