fix(acms): resolve remaining AmbiguousStep conflicts, NameError bugs, and function name duplicates

Fix two critical issues identified by HAL9001 review #8271:

1. Rename literal step 'policy{1,2} has priority_weight' in loader
   steps to 'loader policy{1,2} has priority_weight' to disambiguate
   from parameterised 'policy(\d+) has priority_weight' in integration
   steps (fixes AmbiguousStep Conflicts 1 & 2 - root cause of CI failures).

2. Fix NameError: change undefined variable 'weight' to float(weight_str)
   in step_policy1_priority and step_policy2_priority functions.

3. Rename duplicate Python function names across step files to prevent
   namespace shadowing: step_check_view_name, step_have_multiple_policies,
   step_have_policy_config, step_policy_not_applied → suffixed with _loader
   or _integration.

ISSUES CLOSED: #9584
This commit is contained in:
2026-05-09 10:33:07 +00:00
committed by Forgejo
parent a8cfee5b37
commit 8280bd5ee2
3 changed files with 13 additions and 13 deletions
+2 -2
View File
@@ -90,8 +90,8 @@ Feature: ACMS Context Policy Configuration Loader
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
And loader policy1 has priority_weight 1.0
And loader policy2 has priority_weight 2.0
When I assemble context with both policies
Then policy2 should be applied before policy1
@@ -81,7 +81,7 @@ def step_try_load_toml_file(context: Any) -> None:
@then("the configuration should have view_name {view_name}")
def step_check_view_name(context: Any, view_name: str) -> None:
def step_check_view_name_loader(context: Any, view_name: str) -> None:
"""Check the view name in the configuration."""
assert context.loaded_config is not None
assert context.loaded_config.view_name == view_name
@@ -215,7 +215,7 @@ def step_load_toml_string(context: Any) -> None:
@given("I have a context policy configuration with:")
def step_have_policy_config(context: Any) -> None:
def step_have_policy_config_loader(context: Any) -> None:
"""Create a context policy configuration from table."""
config_dict: dict[str, Any] = {}
@@ -265,7 +265,7 @@ def step_policy_matches_context(context: Any) -> None:
@given("I have a context policy configuration with multiple policies")
def step_have_multiple_policies(context: Any) -> None:
def step_have_multiple_policies_loader(context: Any) -> None:
"""Create a configuration with multiple policies."""
context.policy_config = ViewPolicyConfiguration(
view_name="test_view",
@@ -276,11 +276,11 @@ def step_have_multiple_policies(context: Any) -> None:
)
@given(r"policy1 has priority_weight ([\d.]+)")
def step_policy1_priority(context: Any, weight_str: str) -> None:
@given(r"loader policy1 has priority_weight ([\d.]+)")
def step_policy1_priority_loader(context: Any, weight_str: str) -> None:
"""Set priority weight for policy1."""
if context.policy_config.policies:
context.policy_config.policies[0].priority_weight = weight
context.policy_config.policies[0].priority_weight = float(weight_str)
# Reinitialize integration if present (for plan execution integration tests)
if hasattr(context, "integration"):
context.integration = PlanExecutionACMSIntegration(
@@ -288,11 +288,11 @@ def step_policy1_priority(context: Any, weight_str: str) -> None:
)
@given(r"policy2 has priority_weight ([\d.]+)")
def step_policy2_priority(context: Any, weight_str: str) -> None:
@given(r"loader policy2 has priority_weight ([\d.]+)")
def step_policy2_priority_loader(context: Any, weight_str: str) -> None:
"""Set priority weight for policy2."""
if len(context.policy_config.policies) > 1:
context.policy_config.policies[1].priority_weight = weight
context.policy_config.policies[1].priority_weight = float(weight_str)
# Reinitialize integration if present (for plan execution integration tests)
if hasattr(context, "integration"):
context.integration = PlanExecutionACMSIntegration(
@@ -348,7 +348,7 @@ def step_policy_disabled(context: Any) -> None:
@then("the policy should not be applied")
def step_policy_not_applied(context: Any) -> None:
def step_policy_not_applied_loader(context: Any) -> None:
"""Check that the policy was not applied."""
# Support both direct assembler context and integration context
assembled = getattr(context, "assembled", None) or getattr(
@@ -289,7 +289,7 @@ def step_policy_applied(context: Any) -> None:
@then("the policy should not be applied to the LLM context")
def step_policy_not_applied(context: Any) -> None:
def step_policy_not_applied_integration(context: Any) -> None:
"""Check that the policy was NOT applied."""
assert context.llm_context is not None
policies_applied = context.llm_context.get("policies_applied", [])