@phase1 @subplan @coverage
Feature: Subplan Service Coverage Boost
  Additional scenarios targeting uncovered code paths in
  SubplanService, SubplanSpawnError, and related helpers.

  # --- SubplanSpawnError direct instantiation (v3.3.0) ---

  @error_object
  Scenario: SubplanSpawnError message format includes errors
    When a SubplanSpawnError is created for errors "bad resource" and "missing merge"
    Then the SubplanSpawnError message should contain 1 semicolons
    And the SubplanSpawnError message should contain "Spawn validation failed"
    And the SubplanSpawnError message should contain "bad resource"
    And the SubplanSpawnError message should contain "missing merge"

  # --- decision_service property (line 167) ---

  @property_access
  Scenario: Accessing the decision_service property returns the injected service
    Given a subplan service constructed with a mock decision service
    When the decision_service property is accessed
    Then the returned decision service should be the injected mock

  # --- spawn() with config=None (line 207) ---

  @null_guard @spawn
  Scenario: Spawn raises ValueError when config is None
    Given a subplan service constructed with a mock decision service
    And a parent plan for coverage tests
    When spawn is called with config set to None
    Then a ValueError should be raised with text "config must not be None"

  # --- spawn() with spawn_entries=None (line 209) ---

  @null_guard @spawn
  Scenario: Spawn raises ValueError when spawn_entries is None
    Given a subplan service constructed with a mock decision service
    And a parent plan for coverage tests
    And a default subplan config for coverage tests
    When spawn is called with spawn_entries set to None
    Then a ValueError should be raised with text "spawn_entries must not be None"

  # --- spawn() raising SubplanSpawnError (v3.3.0) ---

  @spawn_validation_error
  Scenario: Spawn raises SubplanSpawnError when validation fails
    Given a subplan service constructed with a mock decision service
    And a parent plan for coverage tests
    And a subplan config with merge strategy forcibly set to None
    And a spawn entry with a valid spawn decision for coverage tests
    When spawn is called and validation is expected to fail
    Then a SubplanSpawnError should be raised
    And the SubplanSpawnError should mention "merge strategy"

  # --- validate_spawn() with config=None (line 301) ---

  @null_guard @validate
  Scenario: Validate spawn raises ValueError when config is None
    Given a subplan service constructed with a mock decision service
    And a spawn entry with a valid spawn decision for coverage tests
    When validate_spawn is called with config set to None
    Then a ValueError should be raised with text "config must not be None"

  # --- validate_spawn() with spawn_entries=None (line 303) ---

  @null_guard @validate
  Scenario: Validate spawn raises ValueError when spawn_entries is None
    Given a subplan service constructed with a mock decision service
    And a default subplan config for coverage tests
    When validate_spawn is called with spawn_entries set to None
    Then a ValueError should be raised with text "spawn_entries must not be None"

  # --- Empty action_name validation (lines 334-336) ---

  @validation @action_name
  Scenario: Validate spawn detects empty action_name on spawn entry
    Given a subplan service constructed with a mock decision service
    And a default subplan config for coverage tests
    And a spawn entry with an empty action_name
    When validate_spawn is called for coverage tests
    Then the validation result should not be valid
    And the validation errors should mention "empty action_name"

  @validation @action_name
  Scenario: Validate spawn detects whitespace-only action_name on spawn entry
    Given a subplan service constructed with a mock decision service
    And a default subplan config for coverage tests
    And a spawn entry with a whitespace-only action_name
    When validate_spawn is called for coverage tests
    Then the validation result should not be valid
    And the validation errors should mention "empty action_name"

  # --- get_spawn_decisions() with empty plan_id (line 375) ---

  @null_guard @get_decisions
  Scenario: Get spawn decisions raises ValueError for empty plan_id
    Given a subplan service constructed with a mock decision service
    When get_spawn_decisions is called with an empty plan_id
    Then a ValueError should be raised with text "plan_id must not be empty"

  @null_guard @get_decisions
  Scenario: Get spawn decisions raises ValueError for whitespace-only plan_id
    Given a subplan service constructed with a mock decision service
    When get_spawn_decisions is called with a whitespace-only plan_id
    Then a ValueError should be raised with text "plan_id must not be empty"

  # --- build_spawn_entries() with decisions=None (line 414) ---

  @null_guard @build_entries
  Scenario: Build spawn entries raises ValueError when decisions is None
    Given a subplan service constructed with a mock decision service
    When build_spawn_entries is called with decisions set to None
    Then a ValueError should be raised with text "decisions must not be None"
