From d18e92983c2d9c8b7fdc41e16aa75fdb74ef426d 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 ++++--------- scripts/validate_automation_tracking.py | 30 +++++++++---------- .../acms/plan_execution_integration.py | 12 ++------ 5 files changed, 38 insertions(+), 61 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/scripts/validate_automation_tracking.py b/scripts/validate_automation_tracking.py index 9957b8456..4cfdf1089 100755 --- a/scripts/validate_automation_tracking.py +++ b/scripts/validate_automation_tracking.py @@ -25,8 +25,8 @@ AGENT_PREFIXES = { } # Title format patterns -TRACKING_TITLE_PATTERN = re.compile(r'^\[AUTO-([A-Z-]+)\] (.+) \(Cycle (\d+)\)$') -ANNOUNCEMENT_TITLE_PATTERN = re.compile(r'^\[AUTO-([A-Z-]+)\] Announce: (.+)$') +TRACKING_TITLE_PATTERN = re.compile(r"^\[AUTO-([A-Z-]+)\] (.+) \(Cycle (\d+)\)$") +ANNOUNCEMENT_TITLE_PATTERN = re.compile(r"^\[AUTO-([A-Z-]+)\] Announce: (.+)$") def validate_tracking_title(title: str) -> tuple[bool, str]: @@ -95,15 +95,15 @@ def validate_automation_tracking_issue(issue_data: dict[str, Any]) -> list[str]: errors = [] # Validate title - title = issue_data.get('title', '') + title = issue_data.get("title", "") is_valid, message = validate_tracking_title(title) if not is_valid: errors.append(f"Title format error: {message}") # Validate labels - labels = issue_data.get('labels', []) + labels = issue_data.get("labels", []) label_names = [ - label.get('name', '') if isinstance(label, dict) else str(label) + label.get("name", "") if isinstance(label, dict) else str(label) for label in labels ] @@ -111,12 +111,12 @@ def validate_automation_tracking_issue(issue_data: dict[str, Any]) -> list[str]: errors.append("Missing required 'Automation Tracking' label") # Validate body content (basic checks) - body = issue_data.get('body', '') + body = issue_data.get("body", "") if not body.strip(): errors.append("Issue body cannot be empty") # Check for common required elements in body - if '**Automated by CleverAgents Bot**' not in body: + if "**Automated by CleverAgents Bot**" not in body: errors.append("Missing automation signature in body") return errors @@ -134,13 +134,13 @@ def get_tracking_issues_from_repo(owner: str, repo: str) -> list[dict[str, Any]] def main() -> int: """Run the validation script.""" - parser = argparse.ArgumentParser(description='Validate automation tracking issues') - parser.add_argument('--title', help='Validate a single title string') - parser.add_argument('--repo', help='Validate issues from repository (owner/repo)') + parser = argparse.ArgumentParser(description="Validate automation tracking issues") + parser.add_argument("--title", help="Validate a single title string") + parser.add_argument("--repo", help="Validate issues from repository (owner/repo)") parser.add_argument( - '--validate-all', - action='store_true', - help='Run comprehensive validation examples', + "--validate-all", + action="store_true", + help="Run comprehensive validation examples", ) args = parser.parse_args() @@ -154,7 +154,7 @@ def main() -> int: elif args.repo: try: - owner, repo_name = args.repo.split('/', 1) + owner, repo_name = args.repo.split("/", 1) get_tracking_issues_from_repo(owner, repo_name) print(f"Repository validation for {args.repo} completed") return 0 @@ -210,5 +210,5 @@ def main() -> int: return 1 -if __name__ == '__main__': +if __name__ == "__main__": sys.exit(main()) 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