Feature: Skill Context and Registry As a developer I want a runtime context for skill execution and a skill registry So that skills can access plan/project info, track changes, and be managed centrally # ---- SkillContext Creation ---- Scenario: Create SkillContext with plan/project/sandbox info When I create a skill_context with plan "plan-001" project "proj-alpha" and sandbox "/tmp/sandbox" Then the skill_context should be created And the skill_context plan_id should be "plan-001" And the skill_context project_id should be "proj-alpha" And the skill_context sandbox_path should be "/tmp/sandbox" And the skill_context should not be read_only Scenario: Create read-only SkillContext When I create a read_only skill_context with plan "plan-002" project "proj-beta" Then the skill_context should be created And the skill_context should be read_only Scenario: SkillContext with custom metadata When I create a skill_context with metadata key "env" value "staging" Then the skill_context plan metadata should contain key "env" And the skill_context plan metadata key "env" should be "staging" # ---- Resource Resolution ---- Scenario: Resolve bound resources from context When I create a skill_context with resource "git-checkout" bound to "/repo/checkout" And I resolve resource "git-checkout" from the skill_context Then the resolved resource should be "/repo/checkout" Scenario: Resolve missing resource raises SkillError When I create a skill_context with no resources And I try to resolve resource "missing-resource" from the skill_context Then a skill_context resolution error should be raised # ---- Change Tracking ---- Scenario: Register tool invocation in change tracker When I create a skill_context with plan "plan-003" project "proj-gamma" and sandbox "/tmp/sb" And I register a tool invocation for "local/edit-file" with duration 42.5 Then the skill_context change tracker should have 1 records And the last change tracker record tool_name should be "local/edit-file" And the last change tracker record duration_ms should be 42.5 Scenario: Multiple tool invocations are tracked in order When I create a skill_context with plan "plan-004" project "proj-delta" and sandbox "/tmp/sb2" And I register a tool invocation for "local/read-file" with duration 10.0 And I register a tool invocation for "local/write-file" with duration 20.0 Then the skill_context change tracker should have 2 records # ---- Write Guard ---- Scenario: Enforce read-only write guard raises SkillError When I create a read_only skill_context with plan "plan-005" project "proj-epsilon" And I try to enforce write guard for tool "local/write-file" Then a skill_context permission denied error should be raised And the skill_context permission error tool_name should be "local/write-file" Scenario: Write guard passes in writable context When I create a skill_context with plan "plan-006" project "proj-zeta" and sandbox "/tmp/sb3" And I enforce write guard for tool "local/write-file" in writable context Then no skill_context error should be raised # ---- Plan Metadata ---- Scenario: Get plan metadata includes plan_id and project_id When I create a skill_context with plan "plan-007" project "proj-eta" and sandbox "/tmp/sb4" Then the skill_context plan metadata should contain key "plan_id" And the skill_context plan metadata key "plan_id" should be "plan-007" And the skill_context plan metadata should contain key "project_id" And the skill_context plan metadata key "project_id" should be "proj-eta" # ---- SkillRegistry Register/Get/List/Unregister ---- Scenario: SkillRegistry register and get skill When I create a skill_registry And I register a skill "local/test-reg" in the registry And I get skill "local/test-reg" from the registry Then the registry skill name should be "local/test-reg" Scenario: SkillRegistry register duplicate raises error When I create a skill_registry And I register a skill "local/dup-skill" in the registry And I try to register a duplicate skill "local/dup-skill" Then a skill_context validation error should be raised Scenario: SkillRegistry get missing skill raises error When I create a skill_registry And I try to get skill "local/missing" from the registry Then a skill_context not found error should be raised Scenario: SkillRegistry list_all returns metadata When I create a skill_registry And I register a skill "local/skill-a" in the registry And I register a skill "local/skill-b" in the registry And I list all skills from the registry Then the registry should have 2 skills And the registry skill list should contain "local/skill-a" And the registry skill list should contain "local/skill-b" Scenario: SkillRegistry unregister removes skill When I create a skill_registry And I register a skill "local/to-remove" in the registry And I unregister skill "local/to-remove" from the registry And I try to get skill "local/to-remove" from the registry Then a skill_context not found error should be raised Scenario: SkillRegistry unregister missing skill raises error When I create a skill_registry And I try to unregister skill "local/nonexistent" from the registry Then a skill_context not found error should be raised # ---- SkillRegistry Tool Resolution ---- Scenario: SkillRegistry resolve_tools through tool references When I create a skill_registry And I register a skill "local/resolve-test" with tool refs in the registry And I resolve tools for "local/resolve-test" from the registry Then the resolved tools should have 2 entries And the resolved tools should contain "local/tool-a" And the resolved tools should contain "local/tool-b" # ---- SkillRegistry Validation ---- Scenario: SkillRegistry validate_skill detects missing tools When I create a skill_registry with a mock tool registry And I validate a skill with missing tool refs Then the validation errors should contain "not found in tool registry" Scenario: SkillRegistry validate_skill detects missing includes When I create a skill_registry And I validate a skill with missing includes Then the validation errors should contain "is not registered" Scenario: SkillRegistry validate_skill returns empty for valid skill When I create a skill_registry And I validate a skill with no issues Then the validation errors should be empty