UAT: Missing domain repository protocols for Tool, Skill, Actor, and Resource entities — violates clean architecture dependency inversion #3793

Open
opened 2026-04-06 06:22:33 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/domain-repository-protocols-tool-skill-actor-resource
  • Commit Message: fix(domain): add missing repository protocols for Tool, Skill, Actor, Resource, and ResourceType entities
  • Milestone: (none — backlog)
  • Parent Epic: #397

Background

The specification describes a clean architecture where the domain layer defines repository protocols (ports) and infrastructure adapters implement them. The cleveragents.domain.repositories package currently only defines protocols for 4 entities:

  • LifecyclePlanRepositoryProtocol (for Plan)
  • ActionRepositoryProtocol (for Action)
  • DecisionRepositoryProtocol (for Decision)
  • ProjectRepositoryProtocol (for NamespacedProject)

However, the infrastructure layer has repository implementations for many more entities that lack corresponding domain-layer protocols:

  • ToolRegistryRepository / ToolRepository — no ToolRepositoryProtocol in domain layer
  • SkillRepository — no SkillRepositoryProtocol in domain layer
  • ActorRepository — no ActorRepositoryProtocol in domain layer
  • ResourceRepository — no ResourceRepositoryProtocol in domain layer
  • ResourceTypeRepository — no ResourceTypeRepositoryProtocol in domain layer

The specification states: "Following the dependency inversion principle, application services depend on these protocols rather than on the infrastructure implementations directly. This keeps the domain layer free of persistence concerns and allows persistence backends to be swapped without touching application code."

Expected behavior: All major domain entities (Tools, Skills, Actors, Resources, Resource Types) should have corresponding @runtime_checkable Protocol definitions in cleveragents.domain.repositories, following the same pattern as ActionRepositoryProtocol, LifecyclePlanRepositoryProtocol, etc.

Actual behavior: Tool, Skill, Actor, Resource, and ResourceType repositories exist only as concrete infrastructure implementations without domain-layer protocol abstractions. Application services that use these repositories (e.g., ToolRegistryService, SkillService) depend directly on infrastructure classes rather than domain protocols.

Code locations:

  • Missing protocols should be added to: cleveragents.domain.repositories
  • Existing infrastructure implementations: cleveragents.infrastructure.database.repositories.ToolRegistryRepository, cleveragents.infrastructure.database.repositories.SkillRepository, cleveragents.infrastructure.database.repositories.ActorRepository, cleveragents.infrastructure.database.repositories.ResourceRepository
  • Application services that should use protocols: cleveragents.application.services.tool_registry_service.ToolRegistryService, cleveragents.application.services.skill_service.SkillService

Discovered during UAT testing of the Repository Pattern and Data Layer feature area.

Backlog note: This issue was discovered during autonomous operation
on milestone v3.5.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Subtasks

  • Add ToolRepositoryProtocol to cleveragents.domain.repositories as a @runtime_checkable Protocol
  • Add SkillRepositoryProtocol to cleveragents.domain.repositories as a @runtime_checkable Protocol
  • Add ActorRepositoryProtocol to cleveragents.domain.repositories as a @runtime_checkable Protocol
  • Add ResourceRepositoryProtocol to cleveragents.domain.repositories as a @runtime_checkable Protocol
  • Add ResourceTypeRepositoryProtocol to cleveragents.domain.repositories as a @runtime_checkable Protocol
  • Update ToolRegistryService to depend on ToolRepositoryProtocol instead of the concrete infrastructure class
  • Update SkillService to depend on SkillRepositoryProtocol instead of the concrete infrastructure class
  • Verify all infrastructure implementations satisfy the new protocols (via isinstance() checks at runtime)
  • Write Behave unit tests (in features/) for each new protocol definition
  • Export all new protocols from the cleveragents.domain.repositories package __init__.py

Definition of Done

  • ToolRepositoryProtocol, SkillRepositoryProtocol, ActorRepositoryProtocol, ResourceRepositoryProtocol, and ResourceTypeRepositoryProtocol are defined in cleveragents.domain.repositories as @runtime_checkable Protocol classes with full static type annotations
  • All new protocols follow the same structural pattern as ActionRepositoryProtocol and LifecyclePlanRepositoryProtocol
  • ToolRegistryService and SkillService (and any other affected application services) depend on domain protocols, not concrete infrastructure classes
  • All infrastructure repository implementations satisfy the new protocols (verified via isinstance() checks)
  • No # type: ignore suppressions introduced
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/domain-repository-protocols-tool-skill-actor-resource` - **Commit Message**: `fix(domain): add missing repository protocols for Tool, Skill, Actor, Resource, and ResourceType entities` - **Milestone**: *(none — backlog)* - **Parent Epic**: #397 ## Background The specification describes a clean architecture where the domain layer defines repository protocols (ports) and infrastructure adapters implement them. The `cleveragents.domain.repositories` package currently only defines protocols for 4 entities: - `LifecyclePlanRepositoryProtocol` (for Plan) - `ActionRepositoryProtocol` (for Action) - `DecisionRepositoryProtocol` (for Decision) - `ProjectRepositoryProtocol` (for NamespacedProject) However, the infrastructure layer has repository implementations for many more entities that lack corresponding domain-layer protocols: - `ToolRegistryRepository` / `ToolRepository` — no `ToolRepositoryProtocol` in domain layer - `SkillRepository` — no `SkillRepositoryProtocol` in domain layer - `ActorRepository` — no `ActorRepositoryProtocol` in domain layer - `ResourceRepository` — no `ResourceRepositoryProtocol` in domain layer - `ResourceTypeRepository` — no `ResourceTypeRepositoryProtocol` in domain layer The specification states: *"Following the dependency inversion principle, application services depend on these protocols rather than on the infrastructure implementations directly. This keeps the domain layer free of persistence concerns and allows persistence backends to be swapped without touching application code."* **Expected behavior**: All major domain entities (Tools, Skills, Actors, Resources, Resource Types) should have corresponding `@runtime_checkable Protocol` definitions in `cleveragents.domain.repositories`, following the same pattern as `ActionRepositoryProtocol`, `LifecyclePlanRepositoryProtocol`, etc. **Actual behavior**: Tool, Skill, Actor, Resource, and ResourceType repositories exist only as concrete infrastructure implementations without domain-layer protocol abstractions. Application services that use these repositories (e.g., `ToolRegistryService`, `SkillService`) depend directly on infrastructure classes rather than domain protocols. **Code locations**: - Missing protocols should be added to: `cleveragents.domain.repositories` - Existing infrastructure implementations: `cleveragents.infrastructure.database.repositories.ToolRegistryRepository`, `cleveragents.infrastructure.database.repositories.SkillRepository`, `cleveragents.infrastructure.database.repositories.ActorRepository`, `cleveragents.infrastructure.database.repositories.ResourceRepository` - Application services that should use protocols: `cleveragents.application.services.tool_registry_service.ToolRegistryService`, `cleveragents.application.services.skill_service.SkillService` *Discovered during UAT testing of the Repository Pattern and Data Layer feature area.* > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.5.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Subtasks - [ ] Add `ToolRepositoryProtocol` to `cleveragents.domain.repositories` as a `@runtime_checkable Protocol` - [ ] Add `SkillRepositoryProtocol` to `cleveragents.domain.repositories` as a `@runtime_checkable Protocol` - [ ] Add `ActorRepositoryProtocol` to `cleveragents.domain.repositories` as a `@runtime_checkable Protocol` - [ ] Add `ResourceRepositoryProtocol` to `cleveragents.domain.repositories` as a `@runtime_checkable Protocol` - [ ] Add `ResourceTypeRepositoryProtocol` to `cleveragents.domain.repositories` as a `@runtime_checkable Protocol` - [ ] Update `ToolRegistryService` to depend on `ToolRepositoryProtocol` instead of the concrete infrastructure class - [ ] Update `SkillService` to depend on `SkillRepositoryProtocol` instead of the concrete infrastructure class - [ ] Verify all infrastructure implementations satisfy the new protocols (via `isinstance()` checks at runtime) - [ ] Write Behave unit tests (in `features/`) for each new protocol definition - [ ] Export all new protocols from the `cleveragents.domain.repositories` package `__init__.py` ## Definition of Done - [ ] `ToolRepositoryProtocol`, `SkillRepositoryProtocol`, `ActorRepositoryProtocol`, `ResourceRepositoryProtocol`, and `ResourceTypeRepositoryProtocol` are defined in `cleveragents.domain.repositories` as `@runtime_checkable Protocol` classes with full static type annotations - [ ] All new protocols follow the same structural pattern as `ActionRepositoryProtocol` and `LifecyclePlanRepositoryProtocol` - [ ] `ToolRegistryService` and `SkillService` (and any other affected application services) depend on domain protocols, not concrete infrastructure classes - [ ] All infrastructure repository implementations satisfy the new protocols (verified via `isinstance()` checks) - [ ] No `# type: ignore` suppressions introduced - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
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.

Blocks
#397 Epic: Server & Autonomy Infrastructure
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3793
No description provided.