Files
cleveragents-core/features/skills_registry_coverage_boost.feature
freemo 9f62f9c9c8
CI / lint (pull_request) Failing after 20s
CI / quality (pull_request) Successful in 34s
CI / typecheck (pull_request) Successful in 46s
CI / security (pull_request) Successful in 55s
CI / coverage (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 24s
CI / unit_tests (pull_request) Failing after 6m45s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 17m43s
CI / integration_tests (pull_request) Successful in 22m51s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
fix(skills): replace get_tool() calls with get() in SkillRegistry validation methods
SkillRegistry.validate_plan() and validate_skill() called the non-existent
ToolRegistry.get_tool() method, causing AttributeError at runtime. The correct
method is ToolRegistry.get(), which is already used by SkillRegistry.refresh().

Changes:
- Replace self._tool_registry.get_tool(entry.name) with self._tool_registry.get(entry.name)
  in validate_plan()
- Replace self._tool_registry.get_tool(ref) with self._tool_registry.get(ref)
  in validate_skill()
- Update Behave BDD tests to use mock.get instead of mock.get_tool
- Add new BDD scenarios covering validate_skill() happy path, not-found path,
  unregistered include path, and no-tool-registry path
- Remove stale get_tool mock setup from test helpers

ISSUES CLOSED: #2914
2026-04-05 08:59:59 +00:00

128 lines
6.6 KiB
Gherkin

@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