UAT: agents tool remove does not automatically remove all validation attachments as required by spec #5025

Open
opened 2026-04-09 00:49:19 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Tools & Skills — agents tool remove (Validation removal)

Severity: High (data integrity issue — orphaned attachments after validation removal)


What Was Tested

agents tool remove <VALIDATION_NAME> behavior when the tool is a Validation with existing attachments.


Expected Behavior (from spec)

The spec (§ agents validation, line ~9268) explicitly states:

Remove a validation: agents tool remove <NAME> (automatically removes all attachments)

This means when a validation is removed via agents tool remove, all of its resource attachments (across all scopes — direct, project-scoped, plan-scoped) must be automatically deleted as part of the removal operation.


Actual Behavior (from code)

The remove command in src/cleveragents/cli/commands/tool.py (lines 286–335) calls service.remove_tool(name) which delegates to ToolRegistryRepository.delete().

The ToolRegistryService.remove_tool() method (lines 84–105 in tool_registry_service.py) does NOT cascade-delete validation attachments. It only removes the tool record itself.

This leaves orphaned ValidationAttachment records in the database that reference a non-existent validation, which can cause:

  1. Stale attachments appearing in resource validation queries
  2. Errors when the runtime tries to execute a deleted validation
  3. Inability to re-register a validation with the same name if orphaned attachments block the operation

Steps to Reproduce

# Register a validation
agents validation add --config my-validation.yaml

# Attach it to a resource
agents validation attach local/my-repo local/my-validation

# Remove the validation
agents tool remove --yes local/my-validation

# The attachment should be gone, but it may still exist in the DB
# (observable via project show or validation pipeline execution)

Code Location

  • src/cleveragents/application/services/tool_registry_service.pyremove_tool() method, lines 84–105
  • src/cleveragents/infrastructure/database/repositories.pyToolRegistryRepository.delete() method

Fix Required

ToolRegistryService.remove_tool() must be updated to:

  1. Check if the tool being removed is a Validation (by checking tool_type)
  2. If it is a Validation, call self._attachment_repo.delete_all_for_validation(name) to remove all attachments before (or atomically with) removing the tool record
  3. The removal should be atomic (both the tool and its attachments removed in a single transaction)

The ValidationAttachmentRepository needs a delete_all_for_validation(validation_name) method if it doesn't already have one.


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

## Bug Report **Feature Area:** Tools & Skills — `agents tool remove` (Validation removal) **Severity:** High (data integrity issue — orphaned attachments after validation removal) --- ## What Was Tested `agents tool remove <VALIDATION_NAME>` behavior when the tool is a Validation with existing attachments. --- ## Expected Behavior (from spec) The spec (§ `agents validation`, line ~9268) explicitly states: > **Remove a validation**: `agents tool remove <NAME>` **(automatically removes all attachments)** This means when a validation is removed via `agents tool remove`, all of its resource attachments (across all scopes — direct, project-scoped, plan-scoped) must be automatically deleted as part of the removal operation. --- ## Actual Behavior (from code) The `remove` command in `src/cleveragents/cli/commands/tool.py` (lines 286–335) calls `service.remove_tool(name)` which delegates to `ToolRegistryRepository.delete()`. The `ToolRegistryService.remove_tool()` method (lines 84–105 in `tool_registry_service.py`) does NOT cascade-delete validation attachments. It only removes the tool record itself. This leaves orphaned `ValidationAttachment` records in the database that reference a non-existent validation, which can cause: 1. Stale attachments appearing in resource validation queries 2. Errors when the runtime tries to execute a deleted validation 3. Inability to re-register a validation with the same name if orphaned attachments block the operation --- ## Steps to Reproduce ```bash # Register a validation agents validation add --config my-validation.yaml # Attach it to a resource agents validation attach local/my-repo local/my-validation # Remove the validation agents tool remove --yes local/my-validation # The attachment should be gone, but it may still exist in the DB # (observable via project show or validation pipeline execution) ``` --- ## Code Location - `src/cleveragents/application/services/tool_registry_service.py` — `remove_tool()` method, lines 84–105 - `src/cleveragents/infrastructure/database/repositories.py` — `ToolRegistryRepository.delete()` method --- ## Fix Required `ToolRegistryService.remove_tool()` must be updated to: 1. Check if the tool being removed is a Validation (by checking `tool_type`) 2. If it is a Validation, call `self._attachment_repo.delete_all_for_validation(name)` to remove all attachments before (or atomically with) removing the tool record 3. The removal should be atomic (both the tool and its attachments removed in a single transaction) The `ValidationAttachmentRepository` needs a `delete_all_for_validation(validation_name)` method if it doesn't already have one. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 01:01:28 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — Spec compliance bug that breaks documented behavior
  • Milestone: v3.2.0
  • Story Points: 3 — M
  • MoSCoW: Must Have — Spec compliance is required

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: High — Spec compliance bug that breaks documented behavior - **Milestone**: v3.2.0 - **Story Points**: 3 — M - **MoSCoW**: Must Have — Spec compliance is required --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
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#5025
No description provided.