From 1f3ac756b769541b69d06b26f98416ff963eeb14 Mon Sep 17 00:00:00 2001 From: projectedanx <238904666+projectedanx@users.noreply.github.com> Date: Sat, 23 May 2026 03:14:40 +0000 Subject: [PATCH] refactor: reduce cognitive complexity of NextjsFrontendEvaluator.route_request Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- nextjs_frontend_simulation.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/nextjs_frontend_simulation.py b/nextjs_frontend_simulation.py index 774f132..36b0eb5 100644 --- a/nextjs_frontend_simulation.py +++ b/nextjs_frontend_simulation.py @@ -40,6 +40,23 @@ def evaluate_dccd_schema_guard(self, schema_type: str, data: dict) -> bool: return required_keys.issubset(data.keys()) return False + def _check_adjectival_bound(self, intent: str) -> bool: + words = intent.split() + banned_adj = ["revolutionary", "fast", "seamless", + "disruptive", "amazing"] + adjective_count = sum(1 for word in words if word.lower() + in banned_adj) + return adjective_count <= 2 + + def _determine_target_agent(self, intent: str) -> str: + if "security" in intent or "trust" in intent: + return "cipher" + elif "developer" in intent or "code" in intent: + return "dax-01" + elif "validation" in intent or "ingress" in intent: + return "kira-7" + return "vulcan" + def route_request(self, user_id: str, data: dict) -> dict: """ Routes the user request to the appropriate agent \ @@ -55,25 +72,14 @@ def route_request(self, user_id: str, data: dict) -> dict: intent = data.get("agent_intent", "") # Enforce AdjectivalBound (max 2 limit) - words = intent.split() - banned_adj = ["revolutionary", "fast", "seamless", - "disruptive", "amazing"] - adjective_count = sum(1 for word in words if word.lower() - in banned_adj) - if adjective_count > 2: + if not self._check_adjectival_bound(intent): return { "error": "AdjectivalBound exceeded. " "Too many evaluative adjectives." } # Determine the target agent - target_agent = "vulcan" # Default fallback - if "security" in intent or "trust" in intent: - target_agent = "cipher" - elif "developer" in intent or "code" in intent: - target_agent = "dax-01" - elif "validation" in intent or "ingress" in intent: - target_agent = "kira-7" + target_agent = self._determine_target_agent(intent) # Log the request self.request_logs.append({