@skill_registry_coverage
Feature: Skill Registry coverage boost
  As a developer improving test coverage
  I want to exercise the uncovered code paths in SkillRegistry
  So that validate_plan(), validate_skill(), refresh(), and related paths are covered

  Background:
    Given a fresh SkillRegistry instance

  # ---------------------------------------------------------------------------
  # validate_plan with tool registry configured (lines 270-278)
  # ---------------------------------------------------------------------------

  @validate_plan_tool_registry
  Scenario: validate_plan reports missing tool when tool registry returns None
    Given the registry has a tool registry mock configured
    And a registered skill "local/web-tools" having tool ref "local/fetch"
    And the tool registry mock returns None for tool "local/fetch"
    When I validate a plan referencing skill "local/web-tools"
    Then the skills validation errors should contain "Tool 'local/fetch' in skill 'local/web-tools' not found in tool registry"

  @validate_plan_tool_registry
  Scenario: validate_plan passes when all tool refs exist in tool registry
    Given the registry has a tool registry mock configured
    And a registered skill "local/web-tools" having tool ref "local/fetch"
    And the tool registry mock returns a tool for "local/fetch"
    When I validate a plan referencing skill "local/web-tools"
    Then the validation errors should be empty

  @validate_plan_tool_registry
  Scenario: validate_plan skips inline entries during tool registry validation
    Given the registry has a tool registry mock configured
    And a registered skill "local/inline-skill" having only an inline tool
    When I validate a plan referencing skill "local/inline-skill"
    Then the validation errors should be empty
    And the tool registry mock get should not have been called

  @validate_plan_tool_registry
  Scenario: validate_plan skips mcp-prefixed entries during tool registry validation
    Given the registry has a tool registry mock configured
    And a registered skill "local/mcp-skill" having only MCP tools
    When I validate a plan referencing skill "local/mcp-skill"
    Then the validation errors should be empty

  @validate_plan_tool_registry
  Scenario: validate_plan skips agent_skill-prefixed entries during tool registry validation
    Given the registry has a tool registry mock configured
    And a registered skill "local/agent-skill" having only agent skill sources
    When I validate a plan referencing skill "local/agent-skill"
    Then the validation errors should be empty

  # ---------------------------------------------------------------------------
  # refresh exception handling (lines 314-315)
  # ---------------------------------------------------------------------------

  @refresh_failure
  Scenario: refresh returns failed result when resolve_tools raises ValueError
    Given a registered skill "local/cyclic-a" including "local/cyclic-b"
    And a registered skill "local/cyclic-b" including "local/cyclic-a"
    When I refresh the coverage boost skill "local/cyclic-a"
    Then the refresh result should have "local/cyclic-a" in failed
    And the refresh result should have zero refreshed

  @refresh_failure
  Scenario: refresh returns failed result when resolve_tools raises RuntimeError
    Given a registered skill "local/broken" that will cause RuntimeError on resolve
    When I refresh the coverage boost skill "local/broken"
    Then the refresh result should have "local/broken" in failed
    And the refresh failed message for "local/broken" should contain "resolver broke"

  # ---------------------------------------------------------------------------
  # refresh skips inline / mcp / agent_skill entries (line 324)
  # ---------------------------------------------------------------------------

  @refresh_skip_inline
  Scenario: refresh skips inline tools when checking tool registry
    Given the registry has a tool registry mock configured
    And a registered skill "local/mixed" having inline tool plus tool ref "local/lint"
    And the tool registry mock returns a tool for "local/lint"
    When I refresh the coverage boost skill "local/mixed"
    Then the refresh result should have "local/mixed" in refreshed

  @refresh_skip_inline
  Scenario: refresh skips mcp-prefixed tools when checking tool registry
    Given the registry has a tool registry mock configured
    And a registered skill "local/mcp-check" having MCP tools plus tool ref "local/lint"
    And the tool registry mock returns a tool for "local/lint"
    When I refresh the coverage boost skill "local/mcp-check"
    Then the refresh result should have "local/mcp-check" in refreshed

  @refresh_skip_inline
  Scenario: refresh skips agent_skill-prefixed tools when checking tool registry
    Given the registry has a tool registry mock configured
    And a registered skill "local/agent-check" having agent skill plus tool ref "local/lint"
    And the tool registry mock returns a tool for "local/lint"
    When I refresh the coverage boost skill "local/agent-check"
    Then the refresh result should have "local/agent-check" in refreshed

  # ---------------------------------------------------------------------------
  # validate_skill with tool registry configured
  # ---------------------------------------------------------------------------

  @validate_skill_tool_registry
  Scenario: validate_skill reports missing tool ref when tool registry returns None
    Given the registry has a tool registry mock configured
    And the tool registry mock returns None for tool "local/missing-tool"
    When I validate a skill definition with tool ref "local/missing-tool"
    Then the skills validation errors should contain "Tool reference 'local/missing-tool' not found in tool registry"

  @validate_skill_tool_registry
  Scenario: validate_skill passes when all tool refs exist in tool registry
    Given the registry has a tool registry mock configured
    And the tool registry mock returns a tool for "local/existing-tool"
    When I validate a skill definition with tool ref "local/existing-tool"
    Then the validation errors should be empty

  @validate_skill_tool_registry
  Scenario: validate_skill reports unregistered included skill
    Given a fresh SkillRegistry instance
    When I validate a skill definition that includes unregistered skill "local/ghost"
    Then the skills validation errors should contain "Included skill 'local/ghost' is not registered"

  @validate_skill_tool_registry
  Scenario: validate_skill passes with no tool registry configured
    Given a fresh SkillRegistry instance
    When I validate a skill definition with tool ref "local/any-tool"
    Then the validation errors should be empty
