From e023366858f9f54446aeff98b74c83392d0cbcc6 Mon Sep 17 00:00:00 2001 From: CleverThis Date: Mon, 4 May 2026 22:07:10 +0000 Subject: [PATCH] style(acms): apply ruff format to fix CI lint format check failure The CI lint job runs both ruff check and ruff format --check. The format check was failing because 5 files had formatting inconsistencies. Applied ruff format to fix the CI lint failure. ISSUES CLOSED: #9584 --- benchmarks/acms_context_policy_bench.py | 10 ++----- .../steps/acms_context_policy_loader_steps.py | 27 +++++++++---------- .../acms_plan_execution_integration_steps.py | 20 ++++---------- .../acms/plan_execution_integration.py | 12 +++------ 4 files changed, 23 insertions(+), 46 deletions(-) diff --git a/benchmarks/acms_context_policy_bench.py b/benchmarks/acms_context_policy_bench.py index 82aba5d0f..752ea302e 100644 --- a/benchmarks/acms_context_policy_bench.py +++ b/benchmarks/acms_context_policy_bench.py @@ -43,18 +43,12 @@ policies: _YAML_CONFIG_10 = """ view_name: bench_view policies: -""" + "\n".join( - f" - name: policy{i}\n priority_weight: {i}.0" - for i in range(10) -) +""" + "\n".join(f" - name: policy{i}\n priority_weight: {i}.0" for i in range(10)) _YAML_CONFIG_100 = """ view_name: bench_view policies: -""" + "\n".join( - f" - name: policy{i}\n priority_weight: {i}.0" - for i in range(100) -) +""" + "\n".join(f" - name: policy{i}\n priority_weight: {i}.0" for i in range(100)) _TOML_CONFIG_1 = """ view_name = "bench_view" diff --git a/features/steps/acms_context_policy_loader_steps.py b/features/steps/acms_context_policy_loader_steps.py index 72a5183af..5ff034885 100644 --- a/features/steps/acms_context_policy_loader_steps.py +++ b/features/steps/acms_context_policy_loader_steps.py @@ -31,9 +31,7 @@ def step_have_loader(context: Any) -> None: @given("I have a YAML configuration file with:") def step_have_yaml_file(context: Any) -> None: """Create a temporary YAML configuration file.""" - with tempfile.NamedTemporaryFile( - mode="w", suffix=".yaml", delete=False - ) as tmp: + with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as tmp: tmp.write(context.text) context.config_path = tmp.name @@ -41,9 +39,7 @@ def step_have_yaml_file(context: Any) -> None: @given("I have a TOML configuration file with:") def step_have_toml_file(context: Any) -> None: """Create a temporary TOML configuration file.""" - with tempfile.NamedTemporaryFile( - mode="w", suffix=".toml", delete=False - ) as tmp: + with tempfile.NamedTemporaryFile(mode="w", suffix=".toml", delete=False) as tmp: tmp.write(context.text) context.config_path = tmp.name @@ -169,9 +165,7 @@ def step_check_file_not_found_error(context: Any) -> None: @given("I have a configuration file with unsupported format {fmt}") def step_have_unsupported_format(context: Any, fmt: str) -> None: """Create a file with unsupported format.""" - with tempfile.NamedTemporaryFile( - mode="w", suffix=fmt, delete=False - ) as tmp: + with tempfile.NamedTemporaryFile(mode="w", suffix=fmt, delete=False) as tmp: tmp.write("{}") context.config_path = tmp.name @@ -239,8 +233,7 @@ def step_have_policy_config(context: Any) -> None: context.policy_config = ViewPolicyConfiguration( view_name=config_dict.get("view_name", "default"), policies=[ - ContextPolicyConfig(name=p["name"]) - for p in config_dict.get("policies", []) + ContextPolicyConfig(name=p["name"]) for p in config_dict.get("policies", []) ], ) @@ -345,7 +338,9 @@ def step_apply_policy(context: Any) -> None: def step_check_assembled_budget(context: Any, budget: int) -> None: """Check the budget in the assembled context.""" # Support both direct assembler context and integration context - assembled = getattr(context, "assembled", None) or getattr(context, "llm_context", None) + assembled = getattr(context, "assembled", None) or getattr( + context, "llm_context", None + ) assert assembled is not None assert assembled["assembled_data"].get("budget") == budget @@ -368,7 +363,9 @@ def step_policy_disabled(context: Any) -> None: def step_policy_not_applied(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(context, "llm_context", None) + assembled = getattr(context, "assembled", None) or getattr( + context, "llm_context", None + ) assert assembled is not None assert "policy1" not in assembled.get("policies_applied", []) @@ -402,7 +399,9 @@ def step_policy_multiple_scopes(context: Any) -> None: context.policy_config.policies[0].scopes.append(scope) -@when("I apply the policy to context with multiple scopes: file_type {file_type} path {path}") +@when( + "I apply the policy to context with multiple scopes: file_type {file_type} path {path}" +) def step_apply_policy_multiple_scopes(context: Any, file_type: str, path: str) -> None: """Apply policy to context with multiple scope values.""" context.test_context = {"file_type": file_type, "path": path} diff --git a/features/steps/acms_plan_execution_integration_steps.py b/features/steps/acms_plan_execution_integration_steps.py index 46425d476..478e86ddf 100644 --- a/features/steps/acms_plan_execution_integration_steps.py +++ b/features/steps/acms_plan_execution_integration_steps.py @@ -35,9 +35,7 @@ def step_no_policy_config(context: Any) -> None: @given("I have a policy configuration with {count:d} policy") def step_have_policy_config(context: Any, count: int) -> None: """Create a policy configuration with specified number of policies.""" - policies = [ - ContextPolicyConfig(name=f"policy{i+1}") for i in range(count) - ] + policies = [ContextPolicyConfig(name=f"policy{i + 1}") for i in range(count)] context.policy_config = ViewPolicyConfiguration( view_name="test_view", policies=policies, @@ -61,9 +59,7 @@ def step_have_raw_context(context: Any) -> None: def step_prepare_llm_context(context: Any) -> None: """Prepare LLM context from raw context.""" context.raw_context = {"file_type": "python", "path": "src/module.py"} - context.llm_context = context.integration.prepare_llm_context( - context.raw_context - ) + context.llm_context = context.integration.prepare_llm_context(context.raw_context) @then("the LLM context should be the same as the raw context") @@ -88,9 +84,7 @@ def step_have_policy_file(context: Any) -> None: "view_name": "test_view", "policies": [{"name": "policy1"}], } - with tempfile.NamedTemporaryFile( - mode="w", suffix=".yaml", delete=False - ) as tmp: + with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as tmp: yaml.dump(config_data, tmp) context.config_path = tmp.name @@ -156,9 +150,7 @@ def step_load_toml_policy_string(context: Any) -> None: @when("I prepare LLM context for plan execution") def step_prepare_llm_context_plan(context: Any) -> None: """Prepare LLM context for plan execution.""" - context.llm_context = context.integration.prepare_llm_context( - context.raw_context - ) + context.llm_context = context.integration.prepare_llm_context(context.raw_context) @then("the LLM context should include applied policies") @@ -245,9 +237,7 @@ def step_scope_rule(context: Any, value: str) -> None: def step_prepare_context_file_type(context: Any, file_type: str) -> None: """Prepare LLM context with specific file type.""" context.raw_context = {"file_type": file_type} - context.llm_context = context.integration.prepare_llm_context( - context.raw_context - ) + context.llm_context = context.integration.prepare_llm_context(context.raw_context) @then("the policy should be applied") diff --git a/src/cleveragents/acms/plan_execution_integration.py b/src/cleveragents/acms/plan_execution_integration.py index f7f868951..adb8ee7c5 100644 --- a/src/cleveragents/acms/plan_execution_integration.py +++ b/src/cleveragents/acms/plan_execution_integration.py @@ -31,9 +31,7 @@ class ACMSContextAssembler: if policy_config is None: raise ValueError("policy_config must not be None") self.policy_config = policy_config - self.enabled_policies = [ - p for p in policy_config.policies if p.enabled - ] + self.enabled_policies = [p for p in policy_config.policies if p.enabled] def assemble_context(self, raw_context: dict[str, Any]) -> dict[str, Any]: """Assemble context using ACMS policies. @@ -82,9 +80,7 @@ class ACMSContextAssembler: return all(scope.matches(context) for scope in scopes) - def _apply_policy( - self, policy: Any, raw_context: dict[str, Any] - ) -> dict[str, Any]: + def _apply_policy(self, policy: Any, raw_context: dict[str, Any]) -> dict[str, Any]: """Apply a policy to the raw context. Args: @@ -147,9 +143,7 @@ class PlanExecutionACMSIntegration: if policy_config: self.assembler = ACMSContextAssembler(policy_config) - def prepare_llm_context( - self, raw_context: dict[str, Any] - ) -> dict[str, Any]: + def prepare_llm_context(self, raw_context: dict[str, Any]) -> dict[str, Any]: """Prepare context for LLM calls using ACMS assembly. This method is the integration point between the plan execution