UAT: agents actor add silently overwrites existing actor without --update flag #2393

Closed
opened 2026-04-03 17:31:10 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/actor-add-overwrite-guard
  • Commit Message: fix(cli): guard agents actor add against silent overwrite when actor already exists
  • Milestone: v3.2.0
  • Parent Epic: #392

Bug Report

Feature Area: Actor System — agents actor add command

What Was Tested

The agents actor add --config <FILE> command behaviour when an actor with the same name is already registered.

Expected Behavior (from spec §4937–4947)

"If a local actor with the same name already exists, the command fails unless the --update flag is provided, which replaces the existing actor."

When running agents actor add --config ./actors/reviewer.yaml on an already-registered actor, the command must fail with an error panel:

╭─ Error ─────────────────────────────────────────────────╮
│ Actor already exists: local/reviewer                    │
│ Registered: 2026-02-07 14:22                            │
│ Use --update to replace the existing actor definition.  │
╰─────────────────────────────────────────────────────────╯
✗ ERROR Actor already registered — use --update to replace

Actual Behavior

The add command calls registry.upsert_actor() unconditionally, which always creates or updates the actor. The update_existing flag (derived from --update) is only used to change the display title ("Actor added" vs "Actor updated") and whether to show the add-specific panels. The actor is silently overwritten in all cases — no existence check, no error, no guard.

Code Locations

  • src/cleveragents/cli/commands/actor.py lines 496–530 — add command handler: update_existing is passed to show_add_panels but not used to gate the upsert operation
  • src/cleveragents/application/services/actor_service.py lines 75–135 — upsert_actor() always upserts regardless of whether the actor already exists

Steps to Reproduce

# Step 1 — register the actor for the first time (succeeds as expected)
agents actor add --config examples/actors/simple_llm.yaml

# Step 2 — attempt to add the same actor again WITHOUT --update
agents actor add --config examples/actors/simple_llm.yaml

# Observed: second command succeeds silently — actor is overwritten
# Expected: second command fails with "Actor already exists" error panel

Spec Reference

docs/specification.md §4937–4947 (agents actor add section)


Subtasks

  • In actor_service.py (or the repository layer), add an existence check before upserting: if the actor already exists and update_existing=False, raise a domain exception (e.g., ActorAlreadyExistsError) with the actor name and registration timestamp
  • In the add command handler (actor.py lines 496–530), catch ActorAlreadyExistsError and render the spec-required error panel:
    ╭─ Error ─────────────────────────────────────────────────╮
    │ Actor already exists: local/<name>                      │
    │ Registered: <timestamp>                                 │
    │ Use --update to replace the existing actor definition.  │
    ╰─────────────────────────────────────────────────────────╯
    ✗ ERROR Actor already registered — use --update to replace
    
  • Ensure the command exits with a non-zero exit code when the error is raised
  • Verify that agents actor add --config <FILE> --update on an existing actor still succeeds (regression guard)
  • Write Behave scenarios covering:
    • add on a new actor → succeeds with "Actor added" output
    • add on an existing actor without --update → fails with ActorAlreadyExistsError and correct error panel
    • add on an existing actor with --update → succeeds with "Actor updated" output
  • Write Robot Framework integration test: agents actor add twice without --update → second invocation exits non-zero with error panel
  • Run nox -e typecheck — confirm no type errors and no # type: ignore suppressions
  • Run nox -e unit_tests — confirm all Behave scenarios pass
  • Run nox -e coverage_report — confirm coverage ≥ 97%
  • Run nox (all default sessions) — confirm clean

Definition of Done

  • agents actor add --config <FILE> on an already-registered actor (without --update) fails with the spec-required error panel and a non-zero exit code
  • agents actor add --config <FILE> --update on an already-registered actor succeeds and displays "Actor updated"
  • ActorAlreadyExistsError (or equivalent) is raised at the service/repository layer — not swallowed silently
  • Behave scenarios cover all three cases (new actor, existing without --update, existing with --update)
  • Robot Framework integration test verifies the non-zero exit and error panel on duplicate add
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(cli): guard agents actor add against silent overwrite when actor already exists), followed by a blank line, then additional lines providing relevant implementation details
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly (fix/actor-add-overwrite-guard)
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done
  • All nox stages pass
  • Coverage ≥ 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Metadata - **Branch**: `fix/actor-add-overwrite-guard` - **Commit Message**: `fix(cli): guard agents actor add against silent overwrite when actor already exists` - **Milestone**: v3.2.0 - **Parent Epic**: #392 ## Bug Report **Feature Area**: Actor System — `agents actor add` command ### What Was Tested The `agents actor add --config <FILE>` command behaviour when an actor with the same name is already registered. ### Expected Behavior (from spec §4937–4947) > "If a local actor with the same name already exists, the command fails unless the `--update` flag is provided, which replaces the existing actor." When running `agents actor add --config ./actors/reviewer.yaml` on an already-registered actor, the command **must** fail with an error panel: ``` ╭─ Error ─────────────────────────────────────────────────╮ │ Actor already exists: local/reviewer │ │ Registered: 2026-02-07 14:22 │ │ Use --update to replace the existing actor definition. │ ╰─────────────────────────────────────────────────────────╯ ✗ ERROR Actor already registered — use --update to replace ``` ### Actual Behavior The `add` command calls `registry.upsert_actor()` unconditionally, which always creates or updates the actor. The `update_existing` flag (derived from `--update`) is only used to change the display title ("Actor added" vs "Actor updated") and whether to show the add-specific panels. The actor is **silently overwritten** in all cases — no existence check, no error, no guard. ### Code Locations - `src/cleveragents/cli/commands/actor.py` lines 496–530 — `add` command handler: `update_existing` is passed to `show_add_panels` but **not** used to gate the upsert operation - `src/cleveragents/application/services/actor_service.py` lines 75–135 — `upsert_actor()` always upserts regardless of whether the actor already exists ### Steps to Reproduce ```bash # Step 1 — register the actor for the first time (succeeds as expected) agents actor add --config examples/actors/simple_llm.yaml # Step 2 — attempt to add the same actor again WITHOUT --update agents actor add --config examples/actors/simple_llm.yaml # Observed: second command succeeds silently — actor is overwritten # Expected: second command fails with "Actor already exists" error panel ``` ### Spec Reference `docs/specification.md` §4937–4947 (`agents actor add` section) --- ## Subtasks - [ ] In `actor_service.py` (or the repository layer), add an existence check before upserting: if the actor already exists and `update_existing=False`, raise a domain exception (e.g., `ActorAlreadyExistsError`) with the actor name and registration timestamp - [ ] In the `add` command handler (`actor.py` lines 496–530), catch `ActorAlreadyExistsError` and render the spec-required error panel: ``` ╭─ Error ─────────────────────────────────────────────────╮ │ Actor already exists: local/<name> │ │ Registered: <timestamp> │ │ Use --update to replace the existing actor definition. │ ╰─────────────────────────────────────────────────────────╯ ✗ ERROR Actor already registered — use --update to replace ``` - [ ] Ensure the command exits with a non-zero exit code when the error is raised - [ ] Verify that `agents actor add --config <FILE> --update` on an existing actor still succeeds (regression guard) - [ ] Write Behave scenarios covering: - `add` on a new actor → succeeds with "Actor added" output - `add` on an existing actor without `--update` → fails with `ActorAlreadyExistsError` and correct error panel - `add` on an existing actor with `--update` → succeeds with "Actor updated" output - [ ] Write Robot Framework integration test: `agents actor add` twice without `--update` → second invocation exits non-zero with error panel - [ ] Run `nox -e typecheck` — confirm no type errors and no `# type: ignore` suppressions - [ ] Run `nox -e unit_tests` — confirm all Behave scenarios pass - [ ] Run `nox -e coverage_report` — confirm coverage ≥ 97% - [ ] Run `nox` (all default sessions) — confirm clean ## Definition of Done - [ ] `agents actor add --config <FILE>` on an already-registered actor (without `--update`) fails with the spec-required error panel and a non-zero exit code - [ ] `agents actor add --config <FILE> --update` on an already-registered actor succeeds and displays "Actor updated" - [ ] `ActorAlreadyExistsError` (or equivalent) is raised at the service/repository layer — not swallowed silently - [ ] Behave scenarios cover all three cases (new actor, existing without `--update`, existing with `--update`) - [ ] Robot Framework integration test verifies the non-zero exit and error panel on duplicate add - [ ] A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(cli): guard agents actor add against silent overwrite when actor already exists`), followed by a blank line, then additional lines providing relevant implementation details - [ ] The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly (`fix/actor-add-overwrite-guard`) - [ ] The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done - [ ] All nox stages pass - [ ] Coverage ≥ 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.2.0 milestone 2026-04-03 17:31:15 +00:00
Author
Owner

Closing as duplicate — This issue is already addressed by open PR #1513 ("fix(v3.7.0): resolve issue #1500 - actor add --update flag enforcement"), which implements the --update flag enforcement for agents actor add. The fix is already in progress.


Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

**Closing as duplicate** — This issue is already addressed by open PR #1513 ("fix(v3.7.0): resolve issue #1500 - actor add --update flag enforcement"), which implements the `--update` flag enforcement for `agents actor add`. The fix is already in progress. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2393
No description provided.