From a55664810c9277f8f56c7fa906894744defb8adb Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Sun, 15 Feb 2026 00:53:27 +0530 Subject: [PATCH] refactor(constants): initialize LEAD_TEMPLATE_MAP as an empty dictionary refactor(page): clean up import statements for better readability fix(tests): update assertions for clarity and consistency --- backend/app/services/openclaw/constants.py | 3 +-- backend/tests/test_agent_provisioning_utils.py | 8 +++++--- backend/tests/test_task_agent_permissions.py | 12 +++++++++--- backend/tests/test_template_size_budget.py | 4 +--- frontend/src/app/agents/[agentId]/edit/page.tsx | 4 +--- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/backend/app/services/openclaw/constants.py b/backend/app/services/openclaw/constants.py index b623849a..a310d10e 100644 --- a/backend/app/services/openclaw/constants.py +++ b/backend/app/services/openclaw/constants.py @@ -110,8 +110,7 @@ BOARD_SHARED_TEMPLATE_MAP = { "TOOLS.md": "BOARD_TOOLS.md.j2", } -LEAD_TEMPLATE_MAP = { -} +LEAD_TEMPLATE_MAP: dict[str, str] = {} _TOOLS_KV_RE = re.compile(r"^(?P[A-Z0-9_]+)=(?P.*)$") _NON_TRANSIENT_GATEWAY_ERROR_MARKERS = ("unsupported file",) diff --git a/backend/tests/test_agent_provisioning_utils.py b/backend/tests/test_agent_provisioning_utils.py index 39669681..f538d1ff 100644 --- a/backend/tests/test_agent_provisioning_utils.py +++ b/backend/tests/test_agent_provisioning_utils.py @@ -10,9 +10,9 @@ import pytest import app.services.openclaw.internal.agent_key as agent_key_mod import app.services.openclaw.provisioning as agent_provisioning -from app.services.souls_directory import SoulRef from app.services.openclaw.provisioning_db import AgentLifecycleService from app.services.openclaw.shared import GatewayAgentIdentity +from app.services.souls_directory import SoulRef def test_slugify_normalizes_and_trims(): @@ -67,7 +67,7 @@ def test_templates_root_points_to_repo_templates_dir(): root = agent_provisioning._templates_root() assert root.name == "templates" assert root.parent.name == "backend" - assert (root / "AGENTS.md").exists() + assert (root / "BOARD_AGENTS.md.j2").exists() @dataclass @@ -372,7 +372,9 @@ def test_select_role_soul_ref_prefers_exact_slug() -> None: @pytest.mark.asyncio -async def test_resolve_role_soul_markdown_returns_best_effort(monkeypatch: pytest.MonkeyPatch) -> None: +async def test_resolve_role_soul_markdown_returns_best_effort( + monkeypatch: pytest.MonkeyPatch, +) -> None: refs = [SoulRef(handle="team", slug="data-scientist")] async def _fake_list_refs() -> list[SoulRef]: diff --git a/backend/tests/test_task_agent_permissions.py b/backend/tests/test_task_agent_permissions.py index 2d6361bd..4a568de5 100644 --- a/backend/tests/test_task_agent_permissions.py +++ b/backend/tests/test_task_agent_permissions.py @@ -4,8 +4,8 @@ from uuid import uuid4 import pytest from fastapi import HTTPException -from sqlmodel import col, select, SQLModel from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine +from sqlmodel import SQLModel, col, select from sqlmodel.ext.asyncio.session import AsyncSession from app.api import tasks as tasks_api @@ -165,7 +165,10 @@ async def test_non_lead_agent_forbidden_without_assigned_task() -> None: assert exc.value.status_code == 403 assert isinstance(exc.value.detail, dict) assert exc.value.detail["code"] == "task_assignee_required" - assert exc.value.detail["message"] == "Agents can only change status on tasks assigned to them." + assert ( + exc.value.detail["message"] + == "Agents can only change status on tasks assigned to them." + ) finally: await engine.dispose() @@ -247,7 +250,10 @@ async def test_non_lead_agent_forbidden_when_task_assigned_to_other_agent() -> N assert exc.value.status_code == 403 assert isinstance(exc.value.detail, dict) assert exc.value.detail["code"] == "task_assignee_mismatch" - assert exc.value.detail["message"] == "Agents can only change status on tasks assigned to them." + assert ( + exc.value.detail["message"] + == "Agents can only change status on tasks assigned to them." + ) finally: await engine.dispose() diff --git a/backend/tests/test_template_size_budget.py b/backend/tests/test_template_size_budget.py index e16e2e38..f5da7459 100644 --- a/backend/tests/test_template_size_budget.py +++ b/backend/tests/test_template_size_budget.py @@ -11,9 +11,7 @@ TEMPLATES_DIR = Path(__file__).resolve().parents[1] / "templates" def test_heartbeat_templates_fit_in_injected_context_limit() -> None: """Heartbeat templates must stay under gateway injected-context truncation limit.""" - targets = ( - "BOARD_HEARTBEAT.md.j2", - ) + targets = ("BOARD_HEARTBEAT.md.j2",) for name in targets: size = (TEMPLATES_DIR / name).stat().st_size assert ( diff --git a/frontend/src/app/agents/[agentId]/edit/page.tsx b/frontend/src/app/agents/[agentId]/edit/page.tsx index dd6d11bb..a2e608a5 100644 --- a/frontend/src/app/agents/[agentId]/edit/page.tsx +++ b/frontend/src/app/agents/[agentId]/edit/page.tsx @@ -31,9 +31,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; -import { - DEFAULT_IDENTITY_PROFILE, -} from "@/lib/agent-templates"; +import { DEFAULT_IDENTITY_PROFILE } from "@/lib/agent-templates"; type IdentityProfile = { role: string;