From 94b905fb987c36d0f1567e6b075a40d9d5a6a630 Mon Sep 17 00:00:00 2001 From: Oleksii Dolhov Date: Mon, 15 Jun 2026 12:21:45 +0300 Subject: [PATCH] fix(db): delegate get/set_full_capabilities onto DatabaseManager facade (#1200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GET/PUT /api/agents/{name}/capabilities 500'd with `AttributeError: 'DatabaseManager' object has no attribute 'get_full_capabilities'`. The #1093 db decomposition added explicit pass-throughs for most agent settings but missed the full-capabilities pair — the methods live on SecurityMixin (composed into AgentOperations / self._agent_ops) but had no delegating method on the facade the routers call. Add the two pass-throughs alongside the read-only delegations, and remove them from the test_database_facade_delegation KNOWN_FACADE_GAPS allowlist so the static guard now enforces them. Add an explicit #1200 regression check. Related to #1200. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/backend/database.py | 6 ++++++ tests/unit/test_database_facade_delegation.py | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/backend/database.py b/src/backend/database.py index 0f742141..cd36b711 100644 --- a/src/backend/database.py +++ b/src/backend/database.py @@ -591,6 +591,12 @@ def get_read_only_mode(self, agent_name: str): def set_read_only_mode(self, agent_name: str, enabled: bool, config: dict = None): return self._agent_ops.set_read_only_mode(agent_name, enabled, config) + def get_full_capabilities(self, agent_name: str) -> bool: + return self._agent_ops.get_full_capabilities(agent_name) + + def set_full_capabilities(self, agent_name: str, enabled: bool) -> bool: + return self._agent_ops.set_full_capabilities(agent_name, enabled) + # ========================================================================= # Agent Guardrails (GUARD-001) # ========================================================================= diff --git a/tests/unit/test_database_facade_delegation.py b/tests/unit/test_database_facade_delegation.py index bc4658ea..3500747f 100644 --- a/tests/unit/test_database_facade_delegation.py +++ b/tests/unit/test_database_facade_delegation.py @@ -41,8 +41,6 @@ "get_agent_last_activity", "get_agent_permissions", "get_agent_schedules", - "get_full_capabilities", - "set_full_capabilities", "update_business_status", } ) @@ -137,3 +135,19 @@ def test_webhook_001_methods_delegated(): f"WEBHOOK-001 methods missing from DatabaseManager: {sorted(missing)}. " "Add pass-through methods that delegate to self._schedule_ops." ) + + +def test_1200_capabilities_methods_delegated(): + """Regression check for #1200: the full-capabilities pair must be delegated + on DatabaseManager. They exist on SecurityMixin (composed into + AgentOperations) but the #1093 db decomposition forgot the facade + pass-through, so GET/PUT /api/agents/{name}/capabilities 500'd with + AttributeError. + """ + methods = _databasemanager_methods() + required = {"get_full_capabilities", "set_full_capabilities"} + missing = required - methods + assert not missing, ( + f"capabilities methods missing from DatabaseManager: {sorted(missing)}. " + "Add pass-through methods that delegate to self._agent_ops." + )