Pipeline.Condition.Engine (pipeline v0.0.1)

View Source

Enhanced conditional execution engine supporting complex boolean expressions and mathematical operations.

Supports:

  • Boolean operators: and, or, not
  • Comparison operators: >, <, ==, !=, >=, <=, contains, matches
  • Mathematical expressions: +, -, *, /, % with proper precedence
  • Function calls: any(), all(), count(), sum(), length(), startsWith(), etc.
  • Date/time operations: now(), days(), hours(), minutes()
  • Pattern matching: regex matching and validation
  • Dot notation for nested field access: step_name.field.subfield
  • Backward compatibility with simple truthy conditions

Example condition YAML:

condition:
  and:
    - "analysis.score * analysis.confidence > 0.8"
    - "any(analysis.issues, 'severity == "high"') == false"
    - "length(analysis.recommendations) between 3 and 10"
    - "analysis.timestamp > now() - days(7)"
    - "analysis.file_path matches '.*\.ex'"

Summary

Functions

Evaluates a condition expression against the execution context.

Resolves a value expression in the given context.

Types

condition()

@type condition() :: String.t() | map() | list()

context()

@type context() :: map()

evaluation_result()

@type evaluation_result() :: boolean()

Functions

evaluate(condition, context)

@spec evaluate(condition(), context()) :: evaluation_result()

Evaluates a condition expression against the execution context.

Supports both simple conditions (strings) and complex boolean expressions (maps/lists).

resolve_value(value, context)

@spec resolve_value(String.t(), context()) :: any()

Resolves a value expression in the given context.

Public function for use by the Functions module.