Files
cleveragents-core/features/actor_run_signature.feature
CoreRasurae e4c01492d5
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 15s
CI / lint (pull_request) Successful in 3m18s
CI / quality (pull_request) Successful in 3m47s
CI / typecheck (pull_request) Successful in 3m52s
CI / security (pull_request) Successful in 4m1s
CI / integration_tests (pull_request) Successful in 6m53s
CI / unit_tests (pull_request) Successful in 7m9s
CI / docker (pull_request) Successful in 1m9s
CI / e2e_tests (pull_request) Successful in 11m5s
CI / coverage (pull_request) Successful in 11m15s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 3m16s
CI / build (push) Successful in 31s
CI / typecheck (push) Successful in 4m0s
CI / security (push) Successful in 4m1s
CI / benchmark-regression (push) Has been skipped
CI / quality (push) Successful in 4m8s
CI / integration_tests (push) Successful in 6m10s
CI / unit_tests (push) Successful in 7m35s
CI / docker (push) Successful in 1m9s
CI / e2e_tests (push) Successful in 9m58s
CI / coverage (push) Successful in 11m7s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Failing after 17m22s
CI / benchmark-regression (pull_request) Successful in 56m7s
refactor(cli): align actor run signature with spec positional args
Aligned the `agents actor run` command signature with the
specification by introducing positional NAME and PROMPT arguments.
The --config/-c option is preserved as an optional fallback for
direct YAML invocation. When NAME is provided without --config,
the actor is resolved from the Actor Registry.

Updated both actor_run.py and actor.py run commands. Added backward
compatibility: if --config is provided, it takes precedence over
name-based resolution.

Review fixes applied (code review round 1):
- P1-1: Narrowed bare `except Exception` to `except NotFoundError`
  in _resolve_config_files to avoid masking infrastructure errors.
- P1-2: Moved _resolve_config_files call inside the try block in
  run() so container/registry init errors get user-friendly messages.
  Added `except click.exceptions.Exit: raise` to let typer.Exit
  propagate through the broadened try scope.
- P1-3: Added atexit.register cleanup for temp files created by
  _resolve_config_files (resource leak fix).
- P1-4: Added CHANGELOG.md entry for the breaking CLI change.
- P2-1: Extracted duplicated _resolve_config_files to shared module
  `_resolve_actor.py`; both actor.py and actor_run.py now import it.
- P2-2: Added guard for actors with no configuration data
  (config_blob=None) to produce a clear error instead of invalid YAML.
- P2-3/P2-4: Added 5 BDD scenarios exercising the real
  resolve_config_files function (registry path, yaml_text path,
  config_blob fallback, no-config-data error, not-found error).
- P2-5: Added @coverage tags to all new BDD scenarios.
- P3-1: Added timeout=120s and on_timeout=kill to Robot tests.
- Fixed rxpy_route_validation.robot tests that used the removed
  --prompt/-p option (replaced with positional NAME + PROMPT args).

Review fixes applied (code review round 2):
- P2-1: Aligned actor_run.py exception handler from
  `CleverAgentsException` to `CleverAgentsError`, matching actor.py
  so infrastructure errors from registry resolution get user-friendly
  messages instead of falling through to the generic handler.
- P2-2: Changed `yaml.dump` to `yaml.safe_dump` in _resolve_actor.py
  for fail-fast behavior on unexpected types, consistent with the
  codebase's dominant pattern.
- P3-6: Replaced defensive `getattr(actor, ...)` calls with direct
  Pydantic model attribute access (`actor.yaml_text`, `actor.config_blob`)
  for type-checker coverage.
- P3-1: Switched BDD temp file cleanup from post-assertion
  `unlink()` to `context.add_cleanup()` for leak-proof teardown.
- P2-3/P3-2/P3-3/P3-4: Added 3 BDD edge-case scenarios
  (empty config_blob dict, infrastructure error propagation, empty
  string name) and 1 Robot test case (actor_app registry resolution).

Review fixes applied (code review round 3):
- P1-1: Migrated 48 remaining `-p` invocations across 9 Robot test
  files to the new positional `NAME PROMPT` pattern (context_delete_all_yes,
  load_context_test, scientific_paper_e2e_test, routing_prefix_stripping,
  scientific_paper_basic, scientific_paper_writer_test,
  context_management_test, initial_next_command_test,
  system_prompt_template_rendering).
- P2-1: Documented `--config/-c` as a spec deviation in
  `_resolve_actor.py` module docstring (spec lines 4562-4566 define
  `actor run` with no --config option; issue #901 AC accepts keeping
  it as optional).
- P2-2: Corrected `--config` help text from "fallback" to "overrides
  registry-based name resolution" — the option takes precedence, not
  the other way around.
- P3-1: Added `.strip()` to `yaml_text` emptiness check in
  `_resolve_actor.py` to handle whitespace-only values that would
  otherwise bypass the `config_blob` fallback.
- P3-2: Added `from None` to the no-configuration-data
  `typer.Exit(code=2)` for consistency with the not-found path.
- P3-3: Added BDD scenario testing `--config` precedence for
  `actor_run_app` (was only tested for `actor_app`).
- P3-4: Strengthened config_blob BDD scenario to verify generated
  YAML is parseable via `yaml.safe_load` round-trip.
- P3-7: Replaced hardcoded `/tmp/dummy.yaml` with
  `tempfile.gettempdir()` for portability.
- P3-8: Moved 5 inline imports to module level per CONTRIBUTING.md
  §1292-1294 (3x `import click`, 1x InfrastructureError in steps;
  1x `import typer` in robot helper).
- P3-9: Added `encoding="utf-8"` to `_write_yaml` in Robot helper
  for consistency with production code.

Review fixes applied (code review round 4):
- P2-1: Wrapped `yaml.safe_dump` in `_resolve_actor.py` with
  `try/except yaml.YAMLError` so non-serialisable config_blob values
  produce a user-friendly error message instead of a raw traceback.
- P2-2: Moved remaining inline `import yaml` to module level in
  `actor_run_signature_steps.py` per CONTRIBUTING.md §1292-1294.
- P2-3: Replaced 3 bare `assert` statements in Robot helper
  `helper_actor_run_signature.py` with diagnostic `if/print/sys.exit`
  pattern matching the rest of the file, improving failure diagnostics.

Review fixes applied (code review round 5):
- P3-4: Replaced per-call `atexit.register(lambda)` in
  `_resolve_actor.py` with a module-level `_temp_files` set and a
  single `atexit` handler (`_cleanup_temp_files`) to prevent
  unbounded handler accumulation in same-process usage (e.g. test
  suites running multiple CliRunner invocations).
- P3-1/P3-2/P3-3: Added 4 BDD scenarios: whitespace-only
  `yaml_text` fallback to config_blob, config-precedence
  registry-not-consulted assertion for both `actor_app` and
  `actor_run_app`, multiple `--config` files with positional NAME.
- P4-1: Strengthened error-path BDD assertions to verify error
  message content (not-found, no-config-data, serialisation-error)
  alongside exit codes via captured stderr.
- P4-2: Added Robot test case for `actor_app` unknown-name error
  path and corresponding helper function.

ISSUES CLOSED: #901
2026-03-26 13:41:31 +00:00

131 lines
6.2 KiB
Gherkin

@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