Skip to content

feat(workflows/condition-evaluator): support shorthand path $nodeId.field and unquoted numeric/boolean RHS #1763

@Wirasm

Description

@Wirasm

Spun out from closed PR #1282 (3 features bundled — landing them one at a time).

What

Two ergonomic improvements to the existing condition-evaluator.ts used by when: clauses on DAG nodes:

  1. Shorthand path — accept $nodeId.field as equivalent to $nodeId.output.field. Today you must write the full .output. segment.
  2. Unquoted RHS for numbers and booleans — accept $nodeId.exit_code == 0 and $nodeId.passed == true. Today only single-quoted string literals are accepted on the right-hand side, even for numeric comparisons.

Why

Both reduce friction when authoring when: clauses. Number comparisons especially read awkwardly today: $test.exit_code > '0' quotes a number as a string and relies on the evaluator's coercion path.

Scope boundary

  • Atom regex change only — the existing AND/OR splitter, the resolveOutputRef helper, and the numeric coercion path stay exactly as they are.
  • No new operators, no parentheses, no function calls.
  • No semantic change for existing expressions — every currently-valid when: clause must continue to evaluate identically.

Reference implementation

@Dev-Force already implemented this in PR #1282. Suggested regex (lifted from their diff):

const atomPattern =
  /^\$([a-zA-Z_][a-zA-Z0-9_-]*)\.([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z_][a-zA-Z0-9_]*))?\s*(==|!=|<=|>=|<|>)\s*(?:'([^']*)'|(-?\d+(?:\.\d+)?|true|false))$/;

Then in evaluateAtom:

  • If segment1 === 'output', effective field is segment2 (canonical form preserved)
  • Else effective field is segment1 (shorthand path)
  • Reject $nodeId.field.subfield (shorthand can't have a sub-field)
  • Quoted RHS takes precedence; unquoted RHS covers numbers + booleans

Acceptance

  • Test coverage in condition-evaluator.test.ts for: shorthand path, sub-field rejection on shorthand, unquoted integer RHS, unquoted decimal RHS, unquoted true/false, mixed quoted+unquoted inside AND/OR compounds.
  • No regressions in existing tests.

Suggested PR title

feat(workflows/condition-evaluator): support shorthand path and unquoted numeric/boolean RHS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions