Feature: Actor compiler reads actor_ref from NodeDefinition field
  As a CleverAgents developer
  I want the actor compiler to read actor_ref from the NodeDefinition.actor_ref field
  So that SUBGRAPH nodes correctly populate NodeConfig.subgraph and metadata.subgraph_refs

  Background:
    Given the actor compiler is available

  # Issue #1429: _map_node() and compile_actor() were reading
  # node.config.get("actor_ref") instead of node.actor_ref, causing SUBGRAPH
  # nodes to silently lose their actor references during compilation.

  @tdd_issue @tdd_issue_1429
  Scenario: Compiled SUBGRAPH node has subgraph field populated from actor_ref
    Given actor "test/outer-1429-a" has a subgraph node with actor_ref "test/inner-1429-a"
    And actor "test/inner-1429-a" has no subgraph nodes
    And a registry containing both actors
    When I compile actor "test/outer-1429-a" with the registry resolver
    Then the actor compilation should succeed
    And the compiled node "sub" should have subgraph set to "test/inner-1429-a"

  @tdd_issue @tdd_issue_1429
  Scenario: Compiled actor metadata subgraph_refs populated from actor_ref field
    Given actor "test/outer-1429-b" has a subgraph node with actor_ref "test/inner-1429-b"
    And actor "test/inner-1429-b" has no subgraph nodes
    And a registry containing both actors
    When I compile actor "test/outer-1429-b" with the registry resolver
    Then the actor compilation should succeed
    And the actor subgraph_refs should map "sub" to "test/inner-1429-b"

  @tdd_issue @tdd_issue_1429
  Scenario: Both NodeConfig.subgraph and subgraph_refs populated for SUBGRAPH node
    Given actor "test/outer-1429-c" has a subgraph node with actor_ref "local/code-reviewer"
    And actor "local/code-reviewer" has no subgraph nodes
    And a registry containing both actors
    When I compile actor "test/outer-1429-c" with the registry resolver
    Then the actor compilation should succeed
    And the compiled node "sub" should have subgraph set to "local/code-reviewer"
    And the actor subgraph_refs should map "sub" to "local/code-reviewer"
