Feature: v3 actor config parser synthesises execution routes
  As a developer using v3 actor YAML configs
  I want ReactiveConfigParser to automatically create graph routes for agents
  So that run_single_shot() can invoke the LLM instead of silently returning empty

  # --- Fix A: _build_from_v3() route synthesis for type:llm / type:tool --------

  @tdd_issue @tdd_issue_10807
  Scenario: v3 flat LLM actor build produces non-empty routes
    Given a flat v3 LLM actor config for route synthesis
    When I build the flat v3 config through ReactiveConfigParser
    Then the reactive config routes should not be empty
    And the reactive config should have exactly one route
    And the synthesised route should be a graph route
    And the synthesised route entry point should be the router

  @tdd_issue @tdd_issue_10807
  Scenario: v3 flat tool actor build produces non-empty routes
    Given a flat v3 tool actor config for route synthesis
    When I build the flat v3 config through ReactiveConfigParser
    Then the reactive config routes should not be empty
    And the reactive config should have exactly one route
    And the synthesised route should be a graph route

  @tdd_issue @tdd_issue_10807
  Scenario: v3 flat LLM route has router-plus-actor graph structure
    Given a flat v3 LLM actor config for route synthesis
    When I build the flat v3 config through ReactiveConfigParser
    Then the synthesised route should have exactly two nodes
    And the synthesised route should have a message router node
    And the synthesised route node should reference the actor name
    And the synthesised route should have an edge to end

  # --- Fix B: _build() route synthesis for nested actors: map format -----------

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map format produces non-empty routes
    Given a nested actors map config with cleveragents version 3
    When I build the nested actors config through ReactiveConfigParser
    Then the reactive config routes should not be empty
    And the reactive config should have exactly one route
    And the synthesised route should be a graph route

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map uses default_actor for route actor node
    Given a nested actors map config with default_actor set
    When I build the nested actors config through ReactiveConfigParser
    Then the synthesised route should target the default actor

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map without default_actor uses first agent
    Given a nested actors map config without default_actor
    When I build the nested actors config through ReactiveConfigParser
    Then the reactive config routes should not be empty
    And the synthesised route should target the first agent

  # --- Fix C: nested actors: map translates actor key to provider/model -------

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map with actor key infers provider and model
    Given a nested actors map config with actor key "anthropic/claude-sonnet-4-5"
    When I build the nested actors config through ReactiveConfigParser
    Then the agent config should have provider "anthropic"
    And the agent config should have model "claude-sonnet-4-5"

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map with actor key without slash sets model only
    Given a nested actors map config with actor key "gpt-4"
    When I build the nested actors config through ReactiveConfigParser
    Then the agent config should have model "gpt-4"
    And the agent config should not have provider set

  @tdd_issue @tdd_issue_10807
  Scenario: Nested actors map with explicit provider keeps it unchanged
    Given a nested actors map config with explicit provider "openai" and model "gpt-4o"
    When I build the nested actors config through ReactiveConfigParser
    Then the agent config should have provider "openai"
    And the agent config should have model "gpt-4o"

  # --- Existing route configs are not affected --------------------------------

  @tdd_issue @tdd_issue_10807
  Scenario: Config with explicit routes does not get extra synthesised routes
    Given a config with agents and explicit routes
    When I build the explicit routes config through ReactiveConfigParser
    Then the reactive config should have exactly one route
    And the route should be the explicitly defined one

  # --- End-to-end: run_single_shot with synthesised route ---------------------

  @tdd_issue @tdd_issue_10807
  Scenario: run_single_shot returns non-empty output with synthesised v3 LLM route
    Given a ReactiveCleverAgentsApp configured from a flat v3 LLM config
    When I call run_single_shot with a test prompt
    Then the result should be non-empty

  @tdd_issue @tdd_issue_10807
  Scenario: run_single_shot returns non-empty output with nested actors map config
    Given a ReactiveCleverAgentsApp configured from a nested actors map config
    When I call run_single_shot with a test prompt
    Then the result should be non-empty

  # --- v3 graph actors still work (regression guard) --------------------------

  @tdd_issue @tdd_issue_10807
  Scenario: v3 graph actor build still produces routes as before
    Given a v3 graph actor config dict with route for regression check
    When I build the v3 graph config through ReactiveConfigParser
    Then the reactive config routes should not be empty
    And the reactive config should have exactly one route

  # --- Fix: _build_from_v3 respects explicit provider field (issue #10926) ---

  @tdd_issue @tdd_issue_10926
  Scenario: v3 actor with explicit provider field uses it without inference
    Given a flat v3 LLM actor config with explicit provider and model without slash
    When I build the flat v3 config through ReactiveConfigParser
    Then the agent config should have provider "anthropic"
    And the agent config should have model "claude-sonnet-4-20250514"

  @tdd_issue @tdd_issue_10926
  Scenario: v3 actor without explicit provider falls back to inference from model with slash
    Given a flat v3 LLM actor config with model containing slash and no explicit provider
    When I build the flat v3 config through ReactiveConfigParser
    Then the agent config should have provider "openrouter"
    And the agent config should have model "openrouter/anthropic-claude-sonnet"

  @tdd_issue @tdd_issue_10926
  Scenario: v3 actor with model without slash and no explicit provider gets custom provider
    Given a flat v3 LLM actor config with model without slash and no explicit provider
    When I build the flat v3 config through ReactiveConfigParser
    Then the agent config should have provider "custom"
    And the agent config should have model "gpt-4-turbo"
