@coverage @context
Feature: PlanExecutionContext coverage boost
  As a developer
  I want complete coverage of PlanExecutionContext and RuntimeExecuteActor
  So that all uncovered lines in plan_execution_context.py are exercised

  Scenario: PlanExecutionContext rejects empty plan_id
    Given a pec fresh context
    When I pec construct PlanExecutionContext with empty plan_id
    Then a pec ValidationError should be raised with "plan_id must not be empty"

  Scenario: PlanExecutionContext properties return configured values
    Given a pec PlanExecutionContext with all optional fields set
    Then pec the automation_profile property should return the configured value
    And pec the plan_env property should return the configured value
    And pec the project_env property should return the configured value
    And pec the project_resources property should return the configured dict
    And pec the resource_bindings property should return the configured dict
    And pec the changeset_store property should return the configured store
    And pec the active_changeset_ids property should return a list

  Scenario: record_change raises PlanError when no changeset is active
    Given a pec PlanExecutionContext with a valid plan_id
    When I pec call record_change without starting a changeset
    Then a pec PlanError should be raised about no active changeset

  Scenario: get_changeset returns None for unknown changeset
    Given a pec PlanExecutionContext with a valid plan_id
    When I pec call get_changeset with a nonexistent changeset_id
    Then pec the result should be None

  Scenario: summarize returns metadata for execution context
    Given a pec PlanExecutionContext with a valid plan_id
    When I pec call summarize on the execution context
    Then pec the summary should contain plan_id and decision_root_id
    And pec the summary should contain counts for resources and bindings

  Scenario: RuntimeExecuteActor rejects None tool_runner
    Given a pec valid PlanExecutionContext
    When I pec construct RuntimeExecuteActor with None tool_runner
    Then a pec ValidationError should be raised with "tool_runner must not be None"

  Scenario: RuntimeExecuteActor rejects None execution_context
    Given a pec mock ToolRunner
    When I pec construct RuntimeExecuteActor with None execution_context
    Then a pec ValidationError should be raised with "execution_context must not be None"

  Scenario: RuntimeExecuteActor properties return configured values
    Given a pec RuntimeExecuteActor with valid tool_runner and execution_context
    Then pec the tool_runner property should return the configured ToolRunner
    And pec the execution_context property should return the configured PlanExecutionContext

  Scenario: RuntimeExecuteActor execute with stream callback produces events
    Given a pec RuntimeExecuteActor with valid tool_runner and execution_context with sandbox_root
    And a pec stream event collector
    When I pec execute with decisions and stream callback
    Then pec the stream events should include "runtime_execute_started"
    And pec the stream events should include "runtime_execute_complete"

  Scenario: RuntimeExecuteActor execute without stream callback still works
    Given a pec RuntimeExecuteActor with valid tool_runner and execution_context
    When I pec execute with decisions and no stream callback
    Then pec the result should be a RuntimeExecuteResult with a valid changeset_id

  Scenario: RuntimeExecuteActor execute with sandbox_root populates sandbox_refs
    Given a pec RuntimeExecuteActor with valid tool_runner and execution_context with sandbox_root
    When I pec execute with decisions and no stream callback
    Then pec the result sandbox_refs should include the sandbox_root
