Files
cleveragents-core/features/actor_subgraph_cycle_detection.feature
HAL9000 5db663cb63 fix(actor): read actor_ref from NodeDefinition field in _detect_subgraph_cycles
Fix cross-actor subgraph cycle detection in the actor compiler by reading
actor_ref from the top-level NodeDefinition field instead of the config dict.

The _detect_subgraph_cycles(), _map_node(), and compile_actor() functions
were all reading node.config.get("actor_ref", "") instead of node.actor_ref.
Because actor_ref is a typed, validated Pydantic field on NodeDefinition (not
a key inside the untyped config dict), the old code always returned an empty
string, causing cross-actor cycle detection to silently fail and leaving the
system vulnerable to infinite recursion at runtime.

Changes:
- Fix all three call sites in src/cleveragents/actor/compiler.py
- Add Behave regression tests (features/actor_subgraph_cycle_detection.feature)
  with @tdd_issue and @tdd_issue_1431 tags on all scenarios
- Add Robot Framework integration test (robot/actor_compiler.robot)
- Fix existing test helpers to use actor_ref as top-level field
- Add CHANGELOG entry

ISSUES CLOSED: #1431
2026-05-06 04:08:25 +00:00

39 lines
2.1 KiB
Gherkin

Feature: Cross-actor subgraph cycle detection reads actor_ref field
As a CleverAgents developer
I want the actor compiler to correctly detect cross-actor subgraph cycles
So that mutually-referencing actors raise SubgraphCycleError at compile time
Background:
Given the actor compiler is available
# ────────────────────────────────────────────────────────────
# Bug fix: actor_ref is a top-level NodeDefinition field
# ────────────────────────────────────────────────────────────
@tdd_issue @tdd_issue_1431
Scenario: Mutually-referencing actors raise SubgraphCycleError
Given actor "test/actor-a" has a subgraph node with actor_ref "test/actor-b"
And actor "test/actor-b" has a subgraph node with actor_ref "test/actor-a"
And a registry containing both actors
When I compile actor "test/actor-a" with the registry resolver
Then the compilation should raise SubgraphCycleError
And the cycle error message should mention "cycle"
@tdd_issue @tdd_issue_1431
Scenario: Non-cyclic subgraph reference compiles successfully
Given actor "test/actor-x" has a subgraph node with actor_ref "test/actor-y"
And actor "test/actor-y" has no subgraph nodes
And a registry containing both actors
When I compile actor "test/actor-x" with the registry resolver
Then the actor compilation should succeed
And the actor subgraph_refs should map "sub" to "test/actor-y"
@tdd_issue @tdd_issue_1431
Scenario: Subgraph node actor_ref is reflected in compiled metadata
Given actor "test/actor-p" has a subgraph node with actor_ref "test/actor-q"
And actor "test/actor-q" has no subgraph nodes
And a registry containing both actors
When I compile actor "test/actor-p" with the registry resolver
Then the actor compilation should succeed
And the compiled node "sub" should have subgraph set to "test/actor-q"