@coverage @coverage_actor_run_signature
Feature: Actor run command positional arguments
  The `agents actor run` command accepts positional NAME and PROMPT arguments
  per the specification. The --config/-c option is preserved as an optional
  fallback for direct YAML invocation.

  Background:
    Given an actor CLI runner
    And I have an actor JSON config file

  # ---------- Positional NAME and PROMPT arguments ----------

  Scenario: Run with positional NAME and PROMPT using --config fallback
    When I run actor run with positional args and config fallback
    Then the actor run should call single shot without context manager

  Scenario: Run with positional NAME resolved from actor registry
    When I run actor run with name resolved from the actor registry
    Then the actor run should call single shot without context manager

  Scenario: Run with positional PROMPT containing flag-like text
    When I run actor run with a positional prompt containing flag-like text
    Then the actor run should pass the exact positional prompt

  Scenario: Run with positional NAME through registry integration path
    When I run actor run through registry integration path
    Then the actor run should call single shot without context manager
    And the actor registry should have been consulted with requested actor name

  # ---------- Backward compatibility with --config ----------

  Scenario: Config flag takes precedence over name-based resolution
    When I run actor run with config flag taking precedence
    Then the actor run should call single shot without context manager

  # ---------- Error: actor name not found in registry ----------

  Scenario: Error when actor name not found in registry
    When I run actor run with an unknown actor name
    Then the actor run should exit with registry not found error

  # ---------- actor_run.py positional args ----------

  Scenario: Actor-run module config flag takes precedence over name
    When I invoke the actor-run module with config flag taking precedence
    Then the actor run should call single shot without context manager

  Scenario: Actor-run module with positional NAME and PROMPT
    When I invoke the actor-run module with positional args and config fallback
    Then the actor run should call single shot without context manager

  Scenario: Actor-run module with name from registry
    When I invoke the actor-run module with name from the actor registry
    Then the actor run should call single shot without context manager

  Scenario: Actor-run module error when name not found
    When I invoke the actor-run module with an unknown actor name
    Then the actor run should exit with registry not found error

  # ---------- resolve_config_files unit tests ----------

  Scenario: resolve_config_files returns config when provided
    When I call resolve_config_files with a config list
    Then the original config list is returned unchanged

  Scenario: resolve_config_files resolves actor from registry with yaml_text
    When I call resolve_config_files with a name and no config
    Then a temporary YAML file is created from the registry actor

  Scenario: resolve_config_files falls back to config_blob when yaml_text is empty
    When I call resolve_config_files with an actor that has no yaml_text
    Then a temporary YAML file is created from config_blob

  Scenario: resolve_config_files raises exit when actor has no config data
    When I call resolve_config_files with an actor that has no config data
    Then it should exit with a no-configuration-data error

  Scenario: resolve_config_files raises exit for unknown actor
    When I call resolve_config_files with an unknown actor name directly
    Then it should exit with a not-found error

  # ---------- Edge cases and error propagation ----------

  Scenario: resolve_config_files raises exit when config_blob is empty dict
    When I call resolve_config_files with an actor that has empty config_blob
    Then it should exit with a no-configuration-data error

  Scenario: Infrastructure errors propagate through resolve_config_files
    When I call resolve_config_files and the container raises an infrastructure error
    Then the infrastructure error should propagate uncaught

  Scenario: resolve_config_files rejects empty string name with validation error
    When I call resolve_config_files with an empty string name
    Then the empty name should be rejected with a validation error

  Scenario: resolve_config_files sanitizes control characters in actor name errors
    When I call resolve_config_files with a control-character actor name
    Then the not-found error should not include control characters

  Scenario: resolve_config_files exits when config_blob cannot be serialised to YAML
    When I call resolve_config_files with an actor whose config_blob is not YAML-serialisable
    Then it should exit with a serialisation error

  # ---------- Review round 5 fixes ----------

  Scenario: resolve_config_files falls back to config_blob when yaml_text is whitespace-only
    When I call resolve_config_files with an actor that has whitespace-only yaml_text
    Then a temporary YAML file is created from the whitespace actor config_blob

  Scenario: Config precedence does not consult the actor registry
    When I run actor run with config flag and a registry spy
    Then the actor registry should not have been consulted

  Scenario: Actor-run config precedence does not consult the actor registry
    When I invoke the actor-run module with config flag and a registry spy
    Then the actor registry should not have been consulted

  Scenario: Multiple config files are forwarded with positional NAME
    When I run actor run with multiple config files and a positional name
    Then all config files should be passed to the application

  # ---------- Review round 6 fixes ----------

  Scenario: _cleanup_temp_files removes tracked temporary files
    When I call resolve_config_files and then cleanup_temp_files
    Then the temporary file should be removed by cleanup

  Scenario: actor_registry() infrastructure error propagates through resolve_config_files
    When I call resolve_config_files and actor_registry raises an infrastructure error
    Then the actor_registry infrastructure error should propagate uncaught
