Expand description
Special value types for AIMX expressions.
This module provides specialized value types that extend the core crate::value::Value enum
with domain-specific functionality for agentic workflow applications. These types
represent runtime values with specific semantics beyond basic literals and arrays.
§Overview
The values module contains:
Errata- Error representation with diagnostic informationEval- Evaluation scoring and statisticsFormat- Output formatting instructionsNode- Workflow node references with lazy loading
These types are integrated into the AIMX expression system and can be used alongside standard literals and arrays in expressions and workflow rules.
§Usage
use aimx::values::*;
use aimx::Reference;
// Create error values with diagnostic information
let error = Errata::new_reason_formula(
"Division by zero".to_string(),
"10 / 0".to_string()
);
// Create evaluation scoring values
let eval = Eval::new(5, 10); // 5 successes out of 10 attempts
// Create formatting instructions
let format = Format::new(
"Display as currency".to_string(),
"$0.00".to_string(),
vec!["$42.00".to_string(), "$123.45".to_string()]
);
// Create workflow node references
let node = Node::new(Reference::new("workflow/path"));§Integration with Core Types
These value types are wrapped in the main crate::value::Value enum variants:
Value::Errata(Errata)- Error valuesValue::Eval(Eval)- Evaluation statisticsValue::Format(Format)- Formatting instructionsValue::Node(Node)- Workflow node references
They implement the crate::evaluate::ExpressionLike trait and can be evaluated, written,
and formatted like any other AIMX value.
§Error Handling
The Errata type provides comprehensive error reporting with three levels
of detail:
- Level 1: Basic error reason only
- Level 2: Error reason and problematic formula
- Level 3: Full diagnostic with reason, formula, and location
This enables detailed error reporting throughout the expression evaluation pipeline.
§Workflow Integration
The Node type provides lazy-loaded workflow references that support
concurrent access patterns. Nodes can be in one of two states:
- Unloaded: Contains only the reference path, loads on first access
- Loaded: Contains the actual workflow as an immutable snapshot
This architecture supports the MVCC (Multi-Version Concurrency Control) model used throughout the AIMX system.
§Examples
§Error Handling
use aimx::{values::Errata, evaluate::ExpressionLike, context::Context};
let error = Errata::new_reason_formula_location(
"Syntax error".to_string(),
"1 + * 2".to_string(),
"* 2".to_string()
);
let mut context = Context::new();
let result = error.evaluate(&mut context).unwrap();
assert!(result.has_error());§Evaluation Scoring
use aimx::{values::Eval, evaluate::ExpressionLike, context::Context};
let eval = Eval::new(3, 5); // 3 successes out of 5 attempts
let mut context = Context::new();
let result = eval.evaluate(&mut context).unwrap();
assert!(result.is_eval());§Formatting Instructions
use aimx::{values::Format, evaluate::ExpressionLike, context::Context};
let format = Format::new(
"Format as percentage".to_string(),
"0.0%".to_string(),
vec!["42.5%".to_string(), "99.9%".to_string()]
);
let mut context = Context::new();
let result = format.evaluate(&mut context).unwrap();
assert!(result.is_format());Re-exports§
pub use errata::Errata;pub use eval::Eval;pub use eval::parse_eval;pub use format::Format;pub use format::parse_format;pub use node::Node;