Files
cleveractors-core/features/registry_template_integration.feature
CoreRasurae 517dfb4cce
CI / lint (pull_request) Successful in 35s
CI / quality (pull_request) Successful in 45s
CI / integration_tests (pull_request) Successful in 1m2s
CI / typecheck (pull_request) Successful in 1m10s
CI / security (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 42s
CI / unit_tests (pull_request) Successful in 3m21s
CI / coverage (pull_request) Successful in 3m7s
CI / status-check (pull_request) Successful in 3s
CI / quality (push) Successful in 50s
CI / security (push) Successful in 51s
CI / lint (push) Successful in 54s
CI / typecheck (push) Successful in 58s
CI / integration_tests (push) Successful in 1m0s
CI / build (push) Successful in 43s
CI / unit_tests (push) Successful in 3m23s
CI / coverage (push) Successful in 3m14s
CI / status-check (push) Successful in 3s
feat(registry): implement local namespace reference resolution
Implements the local:<path> reference scheme per Package Registry Standard v1.0.0 §5.3.

Closes #46
2026-06-12 17:11:35 +01:00

226 lines
12 KiB
Gherkin

Feature: Registry Template Integration
As a developer
I want templates to resolve package references from external registries
So that templates can reference remote packages via the Package Registry Standard
Background:
Given RTI: I have a clean test environment for registry template integration
Scenario: TemplateType includes new registry types
When RTI: I access all TemplateType enum values
Then RTI: all template types including new ones should be available
And RTI: new enum values should have correct string representations
Scenario: ComponentReference supports optional package_ref
Given RTI: I create a PackageReference from a registry string
When RTI: I create a ComponentReference with package_ref
Then RTI: the ComponentReference should have the package_ref set
And RTI: ref_type and ref_name should be accessible
Scenario: InstantiationContext resolves local components with package_ref
Given RTI: I have an InstantiationContext with a PackageContentResolver
And RTI: I add a component to the context
When RTI: I resolve a ComponentReference without package_ref
Then RTI: the local component should be returned
Scenario: InstantiationContext handles missing package_ref with resolver
Given RTI: I have an InstantiationContext without a PackageContentResolver
And RTI: I have a ComponentReference with package_ref
When RTI: I try to resolve the package reference
Then RTI: a TemplateError should be raised about missing resolver
Scenario: TemplateRegistry registers new template types
Given RTI: I have a clean TemplateRegistry
When RTI: I register a template with type TEMPLATE
Then RTI: the template should be registered successfully
And RTI: has_template should return true for TEMPLATE type
Scenario: TemplateRegistry registers SKILL type template
Given RTI: I have a clean TemplateRegistry
When RTI: I register a template with type SKILL
Then RTI: the template should be registered successfully
And RTI: has_template should return true for SKILL type
Scenario: TemplateRegistry registers ACTOR type template
Given RTI: I have a clean TemplateRegistry
When RTI: I register a template with type ACTOR
Then RTI: the template should be registered successfully
And RTI: has_template should return true for ACTOR type
Scenario: TemplateRegistry registers MCP type template
Given RTI: I have a clean TemplateRegistry
When RTI: I register a template with type MCP
Then RTI: the template should be registered successfully
And RTI: has_template should return true for MCP type
Scenario: TemplateRegistry registers LSP type template
Given RTI: I have a clean TemplateRegistry
When RTI: I register a template with type LSP
Then RTI: the template should be registered successfully
And RTI: has_template should return true for LSP type
Scenario: TemplateRegistry instantiate_from_config detects registry reference
Given RTI: I have a TemplateRegistry with PackageContentResolver
And RTI: I have a config with registry-style template reference
When RTI: I instantiate from config with registry reference
Then RTI: the result should include _original_reference
And RTI: the result should contain registry metadata
Scenario: TemplateRegistry instantiate_from_config with local template fallback
Given RTI: I have a clean TemplateRegistry
And RTI: I register a local template named "helper"
And RTI: I have a config referencing the local template
When RTI: I instantiate from config with local template
Then RTI: the local template should be used
And RTI: local template behavior should be unchanged
Scenario: TemplateRegistry list_templates includes new types
Given RTI: I have a clean TemplateRegistry
And RTI: I register templates of all types
When RTI: I list all templates
Then RTI: all eight template types should be included in list
Scenario: Registry reference with _original_reference in component metadata
Given RTI: I have an InstantiationContext with a PackageContentResolver
And RTI: I have a ComponentReference with a local package_ref
When RTI: I resolve the package reference
Then RTI: the resolved metadata should include _original_reference
Scenario: Registry fetch failure produces descriptive error
Given RTI: I have an InstantiationContext with a broken PackageContentResolver
And RTI: I have a ComponentReference with an invalid package_ref
When RTI: I try to resolve the invalid package reference
Then RTI: a TemplateError should be raised with reference info
Scenario: EnhancedTemplateRegistry accepts new template types
Given RTI: I have a clean EnhancedTemplateRegistry
When RTI: I register a template dict with type TEMPLATE in enhanced registry
Then RTI: the enhanced registry should accept the template
Scenario: EnhancedTemplateRegistry register_all_templates with new types
Given RTI: I have a clean EnhancedTemplateRegistry
And RTI: I have a multi-type templates configuration
When RTI: I register all templates in enhanced registry
Then RTI: all eight template types should be registered in enhanced registry
# ── Registry/Enhanced error and edge paths ──
Scenario: TemplateRegistry instantiate_from_config with failed resolve raises TemplateError
Given RTI: I have a clean TemplateRegistry with a mock raising context
When FBF: I instantiate from config with a registry reference that fails to resolve
Then FBF: a TemplateError should be raised about failed resolve
Scenario: TemplateRegistry instantiate_from_config resolved as None raises TemplateError
Given RTI: I have a cleanup TemplateRegistry with a mock returning None context
When FBF: I instantiate from config with a registry reference resolving to None
Then FBF: a TemplateError should be raised about failed resolve
Scenario: TemplateRegistry register_all_templates handles new template types
Given RTI: I have a clean TemplateRegistry
When FBF: I register all templates config with skills actors mcps lsps
Then FBF: TEMPLATE SKILL ACTOR MCP and LSP types should be registered
Scenario: TemplateRegistry _instantiate_from_registry_ref creates resolver when context has none
Given RTI: I have a TemplateRegistry with a context lacking reference_resolver
And FBF: I have a PackageContentResolver mock that returns content
When FBF: I instantiate from config with a registry reference through a resolver-free context
Then FBF: the resolved result should be returned
Scenario: TemplateRegistry handle close_all exception in ad-hoc resolver
Given RTI: I have a TemplateRegistry with a context lacking reference_resolver
And FBF: I have a PackageContentResolver mock that raises on close_all
When FBF: I instantiate from config with resolver-free context and failing close
Then FBF: the resolved result should still be returned despite registry close error
Scenario: EnhancedTemplateRegistry instantiate with registry reference resolves via resolver
Given RTI: I have a clean EnhancedTemplateRegistry with a PackageContentResolver context
When FBF: I instantiate a template with a registry-style name
Then FBF: the result should be the resolved package content
Scenario: EnhancedTemplateRegistry instantiate with None context creates ad-hoc resolver
Given RTI: I have a clean EnhancedTemplateRegistry
And FBF: I have a PackageContentResolver mock that returns content
When FBF: I instantiate with a registry ref and no context
Then FBF: the resolved content should include _original_reference
Scenario: EnhancedTemplateRegistry handle close_all exception in ad-hoc resolver
Given RTI: I have a clean EnhancedTemplateRegistry
And FBF: I have a PackageContentResolver mock that raises on close_all
When FBF: I instantiate with a registry ref and no context with failing close
Then FBF: the resolved content should still be returned despite close error
Scenario: EnhancedTemplateRegistry handle resolve returning None
Given RTI: I have a clean EnhancedTemplateRegistry
And FBF: I have a PackageContentResolver mock that returns None
When FBF: I instantiate with a registry ref and resolver that returns None
Then FBF: a TemplateError should be raised about failed registry resolve
Scenario: EnhancedTemplateRegistry handle resolve raising exception
Given RTI: I have a clean EnhancedTemplateRegistry
And FBF: I have a PackageContentResolver mock that raises on resolve
When FBF: I instantiate with a registry ref and resolver that raises
Then FBF: a TemplateError should be raised about failed registry resolve
# ── InstantiationContext / base / template_store edge paths ──
Scenario: InstantiationContext resolve_reference handles package_ref resolve exception
Given RTI: I have an InstantiationContext with a resolver that raises on resolve
And RTI: I have a ComponentReference with package_ref
When FBF: I try to resolve the ComponentReference
Then FBF: a TemplateError should be raised about failed package resolve
Scenario: InstantiationContext resolve_reference handles resolve returning None
Given RTI: I have an InstantiationContext with a resolver returning None
And RTI: I have a ComponentReference with package_ref
When FBF: I try to resolve the ComponentReference
Then FBF: a TemplateError should be raised about failed package resolve
Scenario: InstantiationContext add_component to existing category assigns correctly
Given RTI: I have an InstantiationContext
When FBF: I add a component to an existing category key
Then FBF: the component should be stored under that key
Scenario: InstantiationContext add_component with new category creates key
Given RTI: I have an InstantiationContext
When FBF: I add a component with a type that does not exist in components
Then FBF: the component should be stored under the new key
Scenario: InstantiationContext _resolve_package_reference sets _original_reference when missing
Given RTI: I have an InstantiationContext with a resolver returning dict without _original_reference
And RTI: I have a ComponentReference with package_ref
When FBF: I resolve the ComponentReference
Then FBF: the result should have _original_reference set from package_ref
Scenario: InstantiationContext _resolve_package_reference guards against None package_ref
Given RTI: I have an InstantiationContext
And FBF: I have a ComponentReference with NO package_ref
When FBF: I directly call _resolve_package_reference on the ComponentReference
Then FBF: the result should be None
Scenario: BaseTemplate abstract instantiate raises NotImplementedError
Given RTI: I have a concrete BaseTemplate subclass without instantiate override
When FBF: I call instantiate on the subclass
Then FBF: a NotImplementedError should be raised
Scenario: TemplateDefinition get_parameters raises on non-dict params
Given RTI: I have a TemplateDefinition with non-dict parameters
When FBF: I get parameters from the definition
Then FBF: a ValueError should be raised about params type
Scenario: TemplateDefinition get_type returns unknown for non-string type
Given RTI: I have a TemplateDefinition with a non-string type field
When FBF: I get the type from the definition
Then FBF: the type should be "unknown"
Scenario: TemplateDefinition instantiate raises on non-dict parsed without templates
Given RTI: I have a TemplateDefinition with non-dict parsed content and no templates
When FBF: I instantiate the definition
Then FBF: a ValueError should be raised about parsed type
# ── _resolve_package_ref ValueError path ──
Scenario: _resolve_package_ref raises TemplateError for invalid reference string
Given RTI: I have a clean test environment for registry template integration
When FBF: I call _resolve_package_ref with an invalid reference string
Then FBF: a TemplateError should be raised about invalid ref