UAT: ResourceRegistryService missing delete_resource/remove_resource service method — CLI bypasses service layer #3698

Open
opened 2026-04-05 22:13:39 +00:00 by freemo · 0 comments
Owner

Bug Report

What Was Tested

The ResourceRegistryService in src/cleveragents/application/services/resource_registry_service.py and its mixin _resource_registry_ops.py were analyzed against the spec requirement for agents resource remove.

Expected Behavior (from spec)

The spec defines agents resource remove [--yes|-y] <NAME> (lines 10949-11017). Per clean architecture principles (ADR-007 Repository Pattern, ADR-003 Dependency Injection), the CLI command should delegate to a service-layer method such as ResourceRegistryService.delete_resource(name_or_id) or ResourceRegistryService.remove_resource(name_or_id).

The service should:

  1. Look up the resource by name or ULID
  2. Check for DAG edges (parent/child links) and reject if any exist
  3. Delete the resource from the registry
  4. Return success/failure

Actual Behavior (from code analysis)

The CLI command resource_remove in src/cleveragents/cli/commands/resource.py (lines 1345-1419) directly accesses the database session via service._session() — bypassing the service layer entirely:

# CLI code (resource.py:1377-1414)
session = service._session()  # Direct DB access — violates clean architecture
try:
    from cleveragents.infrastructure.database.models import (
        ResourceEdgeModel,
        ResourceModel,
    )
    edge_count = session.query(ResourceEdgeModel).filter(...).count()
    ...
    session.delete(row)
    session.commit()

Neither ResourceRegistryService, ResourceInstanceMixin, nor _resource_registry_ops.py define any delete_resource, remove_resource, or deregister_resource method.

Impact

  • Violates clean architecture: business logic (edge-count check) lives in the CLI layer
  • No service-level test coverage possible for resource deletion
  • Cannot be called from non-CLI contexts (A2A protocol, tests, other services)
  • Inconsistent with remove_type() which is properly implemented in the service layer

Code Locations

  • Missing method: src/cleveragents/application/services/_resource_registry_ops.py (ResourceInstanceMixin)
  • CLI bypass: src/cleveragents/cli/commands/resource.py lines 1376-1414

Steps to Reproduce

  1. Review ResourceRegistryService public API — no delete_resource method exists
  2. Review resource_remove CLI command — it calls service._session() directly

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Bug Report ### What Was Tested The `ResourceRegistryService` in `src/cleveragents/application/services/resource_registry_service.py` and its mixin `_resource_registry_ops.py` were analyzed against the spec requirement for `agents resource remove`. ### Expected Behavior (from spec) The spec defines `agents resource remove [--yes|-y] <NAME>` (lines 10949-11017). Per clean architecture principles (ADR-007 Repository Pattern, ADR-003 Dependency Injection), the CLI command should delegate to a service-layer method such as `ResourceRegistryService.delete_resource(name_or_id)` or `ResourceRegistryService.remove_resource(name_or_id)`. The service should: 1. Look up the resource by name or ULID 2. Check for DAG edges (parent/child links) and reject if any exist 3. Delete the resource from the registry 4. Return success/failure ### Actual Behavior (from code analysis) The CLI command `resource_remove` in `src/cleveragents/cli/commands/resource.py` (lines 1345-1419) **directly accesses the database session** via `service._session()` — bypassing the service layer entirely: ```python # CLI code (resource.py:1377-1414) session = service._session() # Direct DB access — violates clean architecture try: from cleveragents.infrastructure.database.models import ( ResourceEdgeModel, ResourceModel, ) edge_count = session.query(ResourceEdgeModel).filter(...).count() ... session.delete(row) session.commit() ``` Neither `ResourceRegistryService`, `ResourceInstanceMixin`, nor `_resource_registry_ops.py` define any `delete_resource`, `remove_resource`, or `deregister_resource` method. ### Impact - Violates clean architecture: business logic (edge-count check) lives in the CLI layer - No service-level test coverage possible for resource deletion - Cannot be called from non-CLI contexts (A2A protocol, tests, other services) - Inconsistent with `remove_type()` which is properly implemented in the service layer ### Code Locations - Missing method: `src/cleveragents/application/services/_resource_registry_ops.py` (ResourceInstanceMixin) - CLI bypass: `src/cleveragents/cli/commands/resource.py` lines 1376-1414 ### Steps to Reproduce 1. Review `ResourceRegistryService` public API — no `delete_resource` method exists 2. Review `resource_remove` CLI command — it calls `service._session()` directly --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#3698
No description provided.