# Regression tests for bug #2609: actor add must reject re-adding an existing
# actor unless --update is provided.
Feature: agents actor add enforces --update flag for existing actors
  As a user of the CleverAgents CLI
  I want `agents actor add` to fail with a clear error when re-adding an existing actor
  So that I cannot accidentally overwrite actor configurations without explicit intent

  @tdd_issue @tdd_issue_2609 @tdd_issue_4178
  Scenario: Re-adding an existing actor without --update fails with error panel
    Given an actor add CLI runner where the actor already exists
    When I run actor add without the --update flag
    Then the actor-add-enforcement exit code should be 1
    And the actor-add-enforcement output should contain an error panel with "Actor already exists"
    And the actor-add-enforcement output should contain "Use --update to replace the existing actor definition"
    And the actor-add-enforcement output should contain the registration timestamp

  @tdd_issue @tdd_issue_2609 @tdd_issue_4178
  Scenario: Re-adding an existing actor without --update shows error status line
    Given an actor add CLI runner where the actor already exists
    When I run actor add without the --update flag
    Then the actor-add-enforcement exit code should be 1
    And the actor-add-enforcement output should contain "Actor already registered"
    And the actor-add-enforcement output should contain "use --update to replace"

  @tdd_issue @tdd_issue_2609 @tdd_issue_4178
  Scenario: Re-adding an existing actor with --update succeeds
    Given an actor add CLI runner where the actor already exists
    When I run actor add with the --update flag
    Then the actor-add-enforcement exit code should be 0
    And the actor-add-enforcement output should contain "Actor updated"

  @tdd_issue @tdd_issue_2609 @tdd_issue_4178
  Scenario: Adding a new actor without --update succeeds
    Given an actor add CLI runner where the actor does not exist
    When I run actor add without the --update flag
    Then the actor-add-enforcement exit code should be 0
    And the actor-add-enforcement output should contain "Actor added"
