@mock_only @subplan @plan_executor @tdd_issue @tdd_issue_10268
Feature: PlanExecutor hierarchical execution wiring
  As a system executing hierarchical plans via the production CLI
  I want SubplanExecutionService to be available when SubplanService is wired
  So that child plan execution works without a pre-configured execution service

  # ------------------------------------------------------------------
  # SubplanExecutionService lazy creation (Forgejo #10268)
  # ------------------------------------------------------------------

  Scenario: PlanExecutor lazily creates SubplanExecutionService when SubplanService is present
    Given a PlanExecutor with SubplanService but no SubplanExecutionService
    And a parent plan in Execute phase with a subplan_spawn decision
    When I call run_execute on the parent plan
    Then SubplanService.get_spawn_decisions should have been called
    And SubplanService.spawn should have been called with the spawn entries
    And SubplanExecutionService.execute_all should have been called via lazy creation

  # ------------------------------------------------------------------
  # _execute_child_plan callback (Forgejo #10268)
  # ------------------------------------------------------------------

  Scenario: _execute_child_plan callback invokes strategize for a child plan
    Given a PlanExecutor with SubplanService but no SubplanExecutionService
    And a parent plan in Execute phase with a subplan_spawn decision
    And a child plan ready for execution in the lifecycle service
    When I call run_execute on the parent plan
    Then SubplanExecutionService.execute_all should have been called via lazy creation
