@phase1 @domain @skill_add_persist
Feature: Skill add persists to database
  As a developer
  I want skills added via the CLI to persist across process invocations
  So that skill list shows previously added skills

  Background:
    Given a fresh skill service backed by an in-memory database

  # ───────────────────────────────────────────────────────
  # Persistence round-trip
  # ───────────────────────────────────────────────────────

  @skill_add_persist_roundtrip
  Scenario: Skill add followed by skill list shows the added skill
    Given a skill config YAML for "local/persist-test" at a temp path
    When I add the skill via the persistent service
    And I create a second service instance from the same database
    And I list skills from the second service instance
    Then the listed persistent skills should contain "local/persist-test"

  @skill_add_persist_multiple
  Scenario: Multiple skills added and listed
    Given a skill config YAML for "local/alpha-skill" at a temp path
    And a skill config YAML for "local/beta-skill" at a temp path
    When I add all pending skill configs via the persistent service
    And I create a second service instance from the same database
    And I list skills from the second service instance
    Then the listed persistent skills should contain "local/alpha-skill"
    And the listed persistent skills should contain "local/beta-skill"
    And the listed persistent skills count should be 2

  @skill_add_persist_duplicate
  Scenario: Skill add with duplicate name produces error
    Given a skill config YAML for "local/dup-skill" at a temp path
    When I add the skill via the persistent service
    Then adding a duplicate "local/dup-skill" should raise ValueError

  @skill_add_persist_remove
  Scenario: Skill remove persists deletion to database
    Given a skill config YAML for "local/remove-me" at a temp path
    When I add the skill via the persistent service
    And I remove the skill "local/remove-me" via the persistent service
    And I create a second service instance from the same database
    And I list skills from the second service instance
    Then the listed persistent skills should not contain "local/remove-me"
