fix(actor): Fix GRAPH actor conditional node Python expression evaluation and subgraph config field alignment (fixes #5477, #5427) #8990

Open
opened 2026-04-14 04:35:37 +00:00 by HAL9000 · 1 comment
Owner

Background and Context

Two related issues affect GRAPH actor conditional routing and subgraph node configuration:

  1. Conditional nodes use simple field/equals check instead of Python expressions (UAT #5477): _execute_conditional() only supports field == expected checks, not the arbitrary Python expressions described in the spec (conditions[].check as Python expression). Complex routing logic like state.get('error_count') > 3 cannot be expressed.

  2. Subgraph node config field mismatch (UAT #5427): The spec uses actor_path, the schema stores actor_ref as a top-level NodeDefinition field, but the compiler reads actor_ref from node.config — a three-way inconsistency that prevents subgraph references from being resolved correctly.

Both issues are under Epic #5502.

Parent Epic: #5502 (EPIC: Actor Execution & Configuration — GRAPH Actor, Config Schema & CLI Compliance)

Acceptance Criteria

  • _execute_conditional() evaluates conditions[].check as a Python expression against the full GraphState
  • evaluate_edge_condition() supports Python expression evaluation (not just equals checks)
  • Python expression evaluation uses a sandboxed evaluator (e.g., ast module) for security
  • Spec, schema, and compiler are aligned on a single field name for subgraph actor references (actor_ref)
  • Compiler reads node.actor_ref (top-level field) instead of node.config.get("actor_ref")
  • _detect_subgraph_cycles() uses node.actor_ref consistently
  • All nox stages pass with coverage >= 97%

Subtasks

  • Implement Python expression evaluation in _execute_conditional() using ast-based sandboxed eval
  • Update evaluate_edge_condition() to support Python expression strings
  • Define sandboxed evaluation context with access to GraphState fields
  • Align NodeDefinition schema: confirm actor_ref as the canonical field name
  • Fix compiler _map_node() to read node.actor_ref (not node.config.get("actor_ref"))
  • Fix compiler _detect_subgraph_cycles() to read node.actor_ref
  • Update spec documentation if needed to use actor_ref instead of actor_path
  • Write unit tests for Python expression conditional evaluation
  • Write unit tests for subgraph field alignment
  • Run nox (all default sessions), fix any errors

Definition of Done

  • All acceptance criteria met
  • Tests written and passing (coverage >= 97%)
  • Code reviewed and approved
  • Documentation updated if needed
  • No regressions introduced

Metadata

  • Commit message: fix(actor): implement Python expression conditional routing and fix subgraph field alignment
  • Branch name: fix/v350/actor-conditional-subgraph-fields

Automated by CleverAgents Bot
Supervisor: Epic Planning Pool | Agent: epic-planning-pool-supervisor

## Background and Context Two related issues affect GRAPH actor conditional routing and subgraph node configuration: 1. **Conditional nodes use simple field/equals check instead of Python expressions** (UAT #5477): `_execute_conditional()` only supports `field == expected` checks, not the arbitrary Python expressions described in the spec (`conditions[].check` as Python expression). Complex routing logic like `state.get('error_count') > 3` cannot be expressed. 2. **Subgraph node config field mismatch** (UAT #5427): The spec uses `actor_path`, the schema stores `actor_ref` as a top-level `NodeDefinition` field, but the compiler reads `actor_ref` from `node.config` — a three-way inconsistency that prevents subgraph references from being resolved correctly. Both issues are under Epic #5502. Parent Epic: #5502 (EPIC: Actor Execution & Configuration — GRAPH Actor, Config Schema & CLI Compliance) ## Acceptance Criteria - [ ] `_execute_conditional()` evaluates `conditions[].check` as a Python expression against the full `GraphState` - [ ] `evaluate_edge_condition()` supports Python expression evaluation (not just `equals` checks) - [ ] Python expression evaluation uses a sandboxed evaluator (e.g., `ast` module) for security - [ ] Spec, schema, and compiler are aligned on a single field name for subgraph actor references (`actor_ref`) - [ ] Compiler reads `node.actor_ref` (top-level field) instead of `node.config.get("actor_ref")` - [ ] `_detect_subgraph_cycles()` uses `node.actor_ref` consistently - [ ] All nox stages pass with coverage >= 97% ## Subtasks - [ ] Implement Python expression evaluation in `_execute_conditional()` using `ast`-based sandboxed eval - [ ] Update `evaluate_edge_condition()` to support Python expression strings - [ ] Define sandboxed evaluation context with access to `GraphState` fields - [ ] Align `NodeDefinition` schema: confirm `actor_ref` as the canonical field name - [ ] Fix compiler `_map_node()` to read `node.actor_ref` (not `node.config.get("actor_ref")`) - [ ] Fix compiler `_detect_subgraph_cycles()` to read `node.actor_ref` - [ ] Update spec documentation if needed to use `actor_ref` instead of `actor_path` - [ ] Write unit tests for Python expression conditional evaluation - [ ] Write unit tests for subgraph field alignment - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done - [ ] All acceptance criteria met - [ ] Tests written and passing (coverage >= 97%) - [ ] Code reviewed and approved - [ ] Documentation updated if needed - [ ] No regressions introduced ## Metadata - **Commit message:** `fix(actor): implement Python expression conditional routing and fix subgraph field alignment` - **Branch name:** `fix/v350/actor-conditional-subgraph-fields` --- **Automated by CleverAgents Bot** Supervisor: Epic Planning Pool | Agent: epic-planning-pool-supervisor
HAL9000 added this to the v3.5.0 milestone 2026-04-14 04:44:57 +00:00
Author
Owner

Verified — GRAPH actor conditional node fix is required for actor execution correctness. MoSCoW: Must-have. Priority: Medium.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Verified** — GRAPH actor conditional node fix is required for actor execution correctness. MoSCoW: Must-have. Priority: Medium. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#8990
No description provided.