Files
freemo 2a9e03d6c8 fix(tool-registry): reject plain Tools in attach_validation type-discriminator check
- Implemented ToolTypeMismatchError in cleveragents/core/exceptions.py as a DomainError subclass. The error provides a descriptive message including the offending tool name and its actual type to aid debugging.

- Added a type-discriminator guard in attach_validation (tool_registry_service.py, around lines 170-192) that validates tool_type for both dict-based representations and domain-object representations of registered tools. If a non-validation entry is encountered, the guard raises ToolTypeMismatchError to abort the operation with a clear explanation.

- Updated the CLI attach command (validation.py) to catch ToolTypeMismatchError and display a clean [red]Type error:[/red] message before aborting, improving user-facing error clarity.

- Added Behave feature validation_attach_type_guard.feature with four scenarios (two rejection cases and two happy-path cases) to codify expected behavior and ensure regression coverage.

- Added Robot Framework integration test validation_attach_type_guard.robot along with a helper script to validate the end-to-end handling of type-discriminator guards in automated tests.

Key design decisions:
- Reused the existing DomainError hierarchy instead of introducing a new exception type, maintaining consistency with the project's error handling strategy.
- The type-discriminator guard accounts for both dict and domain-object representations of tools, ensuring robust protection regardless of input form.
- ToolType comparisons leverage .value to correctly handle both string inputs and enum values, preventing subtle mismatches.
- The CLI presents a consistent and user-friendly error prefix ("Type error:") to clearly convey type-related issues to users.

ISSUES CLOSED: #2826

The Forgejo PAT for pushing is: 995071a3f80a883356bfa742ba1efd66b0e43ef5
The remote URL is: https://995071a3f80a883356bfa742ba1efd66b0e43ef5@git.cleverthis.com/cleveragents/cleveragents-core.git
The upstream remote is /app (local path).
Branch name: fix/validation-attach-rejects-plain-tools
2026-04-05 03:26:37 +00:00
..