Cotor logoCotor
docs/CONDITION_DSL.md

Condition Expression DSL

Condition Expression DSL

This document describes the syntax and features of the condition expression DSL used in Cotor pipelines.

Overview

The condition expression DSL allows you to define complex logical conditions for controlling pipeline flow. These expressions are evaluated against the pipeline context, which includes stage results, shared state, and other metadata.

Syntax

Expressions are composed of literals, variables, operators, and groupings.

Literals

  • Boolean: true, false
  • Number: 123, 45.67
  • String: 'hello', "world"

Variables

Variables are used to access data from the pipeline context. The following are supported:

  • Stage properties: stageId.property
    • stageId.success: true if the stage succeeded, false otherwise.
    • stageId.output: The output of the stage.
    • stageId.error: The error message if the stage failed.
    • stageId.metadata.key: A value from the stage's metadata.
  • Shared state: context.sharedState.key
  • Pipeline metadata: context.metadata.key
  • Elapsed time: context.elapsedTimeMs

Operators

The following operators are supported, in order of precedence:

OperatorDescriptionExample
!Logical NOT!step1.success
>Greater thanstep1.tokens > 1000
>=Greater than or equal tostep1.score >= 0.8
<Less thanstep2.retries < 3
<=Less than or equal tostep3.duration <= 10000
==Equal tostep1.status == 'completed'
!=Not equal tostep2.reason != 'timeout'
containsSubstring matchingstep3.output contains 'error'
matchesRegular expression matchingstep4.log matches '.*FATAL.*'
&&Logical ANDstep1.success && step2.success
``

Grouping

Parentheses can be used to group expressions and control the order of evaluation.

(step1.success && step2.tokens > 1000) || step3.fallback

Examples

Simple Comparison

quality-check.validationScore >= 0.8

Logical Expression

review.success == true && review.metadata.severity != "HIGH"

Nested Expression

(step1.success && step2.tokens > 1000) || !step3.is_critical