Files
cleveragents-core/features/acms_context_policy_loader.feature
T
HAL9000 7faab96582 fix(acms): resolve all reviewer feedback for context policy loader and plan execution integration
Fixed all blocking issues identified in 4 REQUEST_CHANGES reviews:

- Removed broken ContextPolicy import (root cause of all CI failures)
- Fixed all ruff lint violations: deprecated typing aliases, format parameter shadowing built-in, unused imports, imports inside functions, SIM115/SIM102
- Fixed Behave step ambiguity and duplicate step definitions across files
- Fixed context.config collision with Behave's internal config attribute
- Added CHANGELOG entry for the new ACMS context policy feature
- Added CONTRIBUTORS.md entry for HAL9000
- Added performance benchmark file: benchmarks/acms_context_policy_bench.py
- Fixed pre-existing lint errors in scripts/validate_automation_tracking.py
- Wired PlanExecutionACMSIntegration documentation to explain integration point

ISSUES CLOSED: #9584
2026-06-17 23:15:50 -04:00

172 lines
5.9 KiB
Gherkin

Feature: ACMS Context Policy Configuration Loader
As a developer
I want to load and validate context policy configurations from YAML/TOML files
So that context policies can be flexibly configured per view
Background:
Given I have a context policy configuration loader
Scenario: Load valid YAML configuration
Given I have a YAML configuration file with:
"""
view_name: test_view
default_priority_weight: 1.5
default_budget: 1000
policies:
- name: policy1
description: Test policy
priority_weight: 2.0
budget_override: 500
enabled: true
scopes:
- name: file_type
value: python
"""
When I load the configuration from the YAML file
Then the configuration should have view_name "test_view"
And the configuration should have 1 policy
And the first policy should have name "policy1"
And the first policy should have priority_weight 2.0
And the first policy should have budget_override 500
Scenario: Load valid TOML configuration
Given I have a TOML configuration file with:
"""
view_name = "test_view"
default_priority_weight = 1.5
default_budget = 1000
[[policies]]
name = "policy1"
description = "Test policy"
priority_weight = 2.0
budget_override = 500
enabled = true
[[policies.scopes]]
name = "file_type"
value = "python"
"""
When I load the configuration from the TOML file
Then the configuration should have view_name "test_view"
And the configuration should have 1 policy
Scenario: Validate schema - missing required fields
Given I have a YAML configuration file with:
"""
policies:
- description: Missing name field
"""
When I try to load the configuration from the YAML file
Then I should get a validation error about missing name field
Scenario: Validate schema - invalid policy type
Given I have a YAML configuration file with:
"""
policies:
- "invalid_policy_string"
"""
When I try to load the configuration from the YAML file
Then I should get a validation error about policy type
Scenario: Validate schema - invalid numeric fields
Given I have a YAML configuration file with:
"""
default_priority_weight: "not_a_number"
policies: []
"""
When I try to load the configuration from the YAML file
Then I should get a validation error about numeric field
Scenario: Apply per-view policy with scope rules
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy has scope rules:
| name | value |
| file_type | python |
When I apply the policy to context with file_type "python"
Then the policy should match the context
Scenario: Apply per-view policy with priority weights
Given I have a context policy configuration with multiple policies
And policy1 has priority_weight 1.0
And policy2 has priority_weight 2.0
When I assemble context with both policies
Then policy2 should be applied before policy1
Scenario: Apply per-view policy with budget overrides
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy has budget_override 500
When I apply the policy to context
Then the assembled context should have budget 500
Scenario: Load configuration from non-existent file
Given I have a configuration file path that does not exist
When I try to load the configuration from the file
Then I should get a FileNotFoundError
Scenario: Load configuration with unsupported format
Given I have a configuration file with unsupported format ".json"
When I try to load the configuration from the file
Then I should get a ValueError about unsupported format
Scenario: Load configuration from string - YAML
Given I have a YAML configuration string:
"""
view_name: string_view
policies:
- name: policy1
"""
When I load the configuration from the YAML string
Then the configuration should have view_name "string_view"
Scenario: Load configuration from string - TOML
Given I have a TOML configuration string:
"""
view_name = "string_view"
[[policies]]
name = "policy1"
"""
When I load the configuration from the TOML string
Then the configuration should have view_name "string_view"
Scenario: Multiple scopes in a policy
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy has multiple scope rules:
| name | value |
| file_type | python |
| path | src |
When I apply the policy to context with multiple scopes: file_type "python" path "src"
Then the policy should match the context
Scenario: Policy with list values in scope
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy has scope with name "file_type" and values ["python", "javascript"]
When I apply the policy to context with file_type "python"
Then the policy should match the context
Scenario: Disabled policy should not be applied
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy is disabled
When I assemble context
Then the policy should not be applied
Scenario: Policy metadata is preserved
Given I have a context policy configuration with:
| view_name | test_view |
| policies | 1 |
And the policy has metadata:
| key1 | value1 |
| key2 | value2 |
When I apply the policy to context
Then the assembled context should include the policy metadata