21ba6dbc9e
CI / load-versions (pull_request) Successful in 14s
CI / push-validation (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 41s
CI / typecheck (pull_request) Successful in 59s
CI / security (pull_request) Successful in 1m12s
CI / quality (pull_request) Successful in 42s
CI / build (pull_request) Successful in 52s
CI / helm (pull_request) Successful in 39s
CI / unit_tests (pull_request) Successful in 5m21s
CI / docker (pull_request) Successful in 1m40s
CI / integration_tests (pull_request) Successful in 8m59s
CI / coverage (pull_request) Successful in 9m44s
CI / status-check (pull_request) Successful in 3s
Add five behave scenarios exercising the previously-uncovered error branches in AdaptiveContextSelector (select_strategy and select_strategies with an unconfigured plan_type) and ContextFusion (fuse_results and fuse_with_selector with an unconfigured plan_type), plus a scenario constructing a valid-weight StrategyWeight to cover the success path of the field_validator. ISSUES CLOSED: #5255
212 lines
9.1 KiB
Gherkin
212 lines
9.1 KiB
Gherkin
Feature: Adaptive Context Strategy Selector and Context Fusion
|
|
As a context assembly system
|
|
I want to intelligently select context strategies based on plan type
|
|
And combine results from multiple strategies with configurable weights
|
|
So that I can provide optimal context for different types of plans
|
|
|
|
Background:
|
|
Given I have an adaptive context selector
|
|
And I have a context fusion engine
|
|
|
|
Scenario: Register a context strategy
|
|
When I register a strategy named "semantic" with a mock implementation
|
|
Then the strategy "semantic" should be registered
|
|
And the list of registered strategies should contain "semantic"
|
|
|
|
Scenario: Register configuration for a plan type
|
|
Given I have registered a strategy named "semantic"
|
|
When I register configuration for plan type "coding" with primary strategy "semantic"
|
|
Then the configuration for plan type "coding" should exist
|
|
And the primary strategy for "coding" should be "semantic"
|
|
|
|
Scenario: Select strategy for a plan type
|
|
Given I have registered a strategy named "semantic"
|
|
And I have registered configuration for plan type "coding" with primary strategy "semantic"
|
|
When I select a strategy for plan type "coding"
|
|
Then the selected strategy should be "semantic"
|
|
|
|
Scenario: Select multiple strategies including fallbacks
|
|
Given I have registered strategies: "semantic", "syntactic", "lexical"
|
|
And I have registered configuration for plan type "analysis" with:
|
|
| primary_strategy | semantic |
|
|
| fallback_strategies | syntactic, lexical |
|
|
When I select all strategies for plan type "analysis"
|
|
Then I should get 3 strategies in order: "semantic", "syntactic", "lexical"
|
|
|
|
Scenario: Reject duplicate strategy registration
|
|
Given I have registered a strategy named "semantic"
|
|
When I try to register a strategy named "semantic" again
|
|
Then I should get an error about duplicate registration
|
|
|
|
Scenario: Reject configuration with unregistered primary strategy
|
|
When I try to register configuration with unregistered primary strategy "unknown"
|
|
Then I should get an error about unregistered strategy
|
|
|
|
Scenario: Reject configuration with unregistered fallback strategy
|
|
Given I have registered a strategy named "semantic"
|
|
When I try to register configuration with primary "semantic" and fallback "unknown"
|
|
Then I should get an error about unregistered fallback strategy
|
|
|
|
Scenario: Fuse results from multiple strategies with equal weights
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with:
|
|
| primary_strategy | semantic |
|
|
| fallback_strategies | syntactic |
|
|
And I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8, file2.py:0.6 |
|
|
| syntactic | file1.py:0.7, file3.py:0.5 |
|
|
When I fuse the results for plan type "coding" with equal weights
|
|
Then the fused result should have ranked files:
|
|
| file | score |
|
|
| file1.py | 1.5 |
|
|
| file2.py | 0.6 |
|
|
| file3.py | 0.5 |
|
|
|
|
Scenario: Fuse results with custom weights
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with:
|
|
| primary_strategy | semantic |
|
|
| fallback_strategies | syntactic |
|
|
And I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8, file2.py:0.6 |
|
|
| syntactic | file1.py:0.7, file3.py:0.5 |
|
|
When I fuse the results with custom weights:
|
|
| semantic | 0.7 |
|
|
| syntactic | 0.3 |
|
|
Then the fused result should have ranked files:
|
|
| file | score |
|
|
| file1.py | 0.77 |
|
|
| file2.py | 0.42 |
|
|
| file3.py | 0.15 |
|
|
|
|
Scenario: Get top files from fused result
|
|
Given I have a fused result with ranked files:
|
|
| file | score |
|
|
| file1.py | 1.5 |
|
|
| file2.py | 0.6 |
|
|
| file3.py | 0.5 |
|
|
When I get the top 2 files
|
|
Then I should get: "file1.py", "file2.py"
|
|
|
|
Scenario: Get file score from fused result
|
|
Given I have a fused result with ranked files:
|
|
| file | score |
|
|
| file1.py | 1.5 |
|
|
| file2.py | 0.6 |
|
|
When I get the score for "file1.py"
|
|
Then the file score should be 1.5
|
|
|
|
Scenario: Get file score for non-existent file
|
|
Given I have a fused result with ranked files:
|
|
| file | score |
|
|
| file1.py | 1.5 |
|
|
When I get the score for "nonexistent.py"
|
|
Then the file score should be None
|
|
|
|
Scenario: Reject fusion with no results
|
|
Given I have registered configuration for plan type "coding"
|
|
When I try to fuse with empty results
|
|
Then I should get an error about no results provided
|
|
|
|
Scenario: Reject fusion with invalid weights
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with primary strategy "semantic"
|
|
And I have strategy results with "semantic" and "syntactic"
|
|
When I try to fuse with negative weight for "semantic"
|
|
Then I should get an error about invalid weight
|
|
|
|
Scenario: Normalize weights to sum to 1.0
|
|
Given I have a context fusion engine
|
|
When I normalize weights: semantic=2.0, syntactic=1.0
|
|
Then the normalized weights should be:
|
|
| semantic | 0.6666666666666666 |
|
|
| syntactic | 0.3333333333333333 |
|
|
|
|
Scenario: Get fusion metadata
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with:
|
|
| primary_strategy | semantic |
|
|
| fallback_strategies | syntactic |
|
|
And I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8 |
|
|
| syntactic | file2.py:0.6 |
|
|
When I fuse the results for plan type "coding"
|
|
Then the fusion metadata should contain:
|
|
| plan_type | coding |
|
|
| num_strategies | 2 |
|
|
| num_files | 2 |
|
|
|
|
Scenario: List configured plan types
|
|
Given I have registered configuration for plan types: "coding", "analysis", "testing"
|
|
When I list all configured plan types
|
|
Then I should get plan types: "coding", "analysis", "testing"
|
|
|
|
Scenario: Get configuration for plan type
|
|
Given I have registered configuration for plan type "coding" with primary strategy "semantic"
|
|
When I get the configuration for plan type "coding"
|
|
Then the configuration should have primary strategy "semantic"
|
|
|
|
Scenario: Get configuration for non-existent plan type
|
|
When I get the configuration for plan type "unknown"
|
|
Then the configuration should be None
|
|
|
|
Scenario: Fuse with selector configuration weights
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with:
|
|
| primary_strategy | semantic |
|
|
| fallback_strategies | syntactic |
|
|
| fusion_weights | semantic=0.7, syntactic=0.3 |
|
|
And I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8 |
|
|
| syntactic | file1.py:0.7 |
|
|
When I fuse with selector configuration weights
|
|
Then the fused result should have file "file1.py" with score 0.77
|
|
|
|
Scenario: Handle strategy results without ranked_files attribute
|
|
Given I have registered strategies: "semantic", "syntactic"
|
|
And I have registered configuration for plan type "coding" with primary strategy "semantic"
|
|
And I have strategy results where "syntactic" has no ranked_files attribute
|
|
When I fuse the results for plan type "coding"
|
|
Then the fusion should skip the strategy without ranked_files
|
|
|
|
Scenario: Validate strategy weight configuration
|
|
When I try to create a strategy weight with negative weight
|
|
Then I should get an error about invalid weight
|
|
|
|
Scenario: Validate adaptive strategy config
|
|
When I try to create adaptive strategy config without primary strategy
|
|
Then I should get an error about missing primary strategy
|
|
|
|
Scenario: Plan type enumeration
|
|
Then I should have plan types: "coding", "analysis", "documentation", "refactoring", "testing", "debugging", "unknown"
|
|
|
|
Scenario: Select strategy for unconfigured plan type raises error
|
|
When I try to select a strategy for unconfigured plan type "coding"
|
|
Then I should get an error about no configuration
|
|
|
|
Scenario: Select all strategies for unconfigured plan type raises error
|
|
When I try to select all strategies for unconfigured plan type "coding"
|
|
Then I should get an error about no configuration
|
|
|
|
Scenario: Fuse results for unconfigured plan type raises error
|
|
Given I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8 |
|
|
When I try to fuse results for unconfigured plan type "coding"
|
|
Then I should get an error about no configuration
|
|
|
|
Scenario: Fuse with selector for unconfigured plan type raises error
|
|
Given I have strategy results:
|
|
| strategy | files |
|
|
| semantic | file1.py:0.8 |
|
|
When I try to fuse with selector for unconfigured plan type "coding"
|
|
Then I should get an error about no configuration
|
|
|
|
Scenario: Create strategy weight with valid positive weight
|
|
When I create a strategy weight named "semantic" with weight 0.5
|
|
Then the strategy weight should have name "semantic" and weight 0.5
|