UAT: UnitOfWorkContext missing repository accessors for Tool, Skill, and Resource entities #3801

Open
opened 2026-04-06 06:27:09 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/uow-missing-tool-skill-resource-accessors
  • Commit Message: fix(infrastructure): add missing UoW repository accessors for Tool, Skill, and Resource entities
  • Milestone: (none — backlog)
  • Parent Epic: #397

Background

The UnitOfWorkContext class in cleveragents.infrastructure.database.unit_of_work is responsible for providing access to all repositories within a transaction. However, it is missing repository accessors for three core domain entities:

  1. Tools — No tools property returning a ToolRegistryRepository
  2. Skills — No skills property returning a SkillRepository
  3. Resources — No resources property returning a ResourceRepository

The specification states: "The UoW is responsible for managing the lifecycle of repository instances." The current UnitOfWorkContext only exposes: projects, plans, actions, lifecycle_plans, checkpoints, contexts, changes, debug_attempts, actors, decisions, correction_attempts.

This means that code needing to atomically persist both a Tool and a Plan (or a Resource and a Project) cannot do so through the UoW pattern — it must bypass the UoW and use separate sessions, breaking transaction atomicity.

Expected behavior: UnitOfWorkContext should expose tools, skills, and resources properties that return the appropriate repository instances bound to the current transaction session.

Actual behavior: UnitOfWorkContext has no tools, skills, or resources properties. Code that needs to persist these entities must create separate sessions outside the UoW transaction.

Code location: cleveragents.infrastructure.database.unit_of_work.UnitOfWorkContext — the class is missing _tools, _skills, _resources instance variables and corresponding @property accessors.

Steps to reproduce:

from cleveragents.infrastructure.database.unit_of_work import UnitOfWork
uow = UnitOfWork("sqlite:///:memory:")
uow.init_database()
with uow.transaction() as ctx:
    ctx.tools     # AttributeError: 'UnitOfWorkContext' object has no attribute 'tools'
    ctx.skills    # AttributeError: 'UnitOfWorkContext' object has no attribute 'skills'
    ctx.resources # AttributeError: 'UnitOfWorkContext' object has no attribute 'resources'

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 _tools instance variable to UnitOfWorkContext.__init__() initialized to None
  • Add _skills instance variable to UnitOfWorkContext.__init__() initialized to None
  • Add _resources instance variable to UnitOfWorkContext.__init__() initialized to None
  • Add tools @property to UnitOfWorkContext returning a ToolRegistryRepository bound to the current transaction session
  • Add skills @property to UnitOfWorkContext returning a SkillRepository bound to the current transaction session
  • Add resources @property to UnitOfWorkContext returning a ResourceRepository bound to the current transaction session
  • Ensure all three new accessors follow the same lazy-initialization pattern as existing accessors (e.g., projects, plans, actions)
  • Write Behave unit tests (in features/) covering the new tools, skills, and resources accessors
  • Verify that atomic transactions spanning Tool+Plan, Skill+Project, and Resource+Project work correctly via the UoW
  • Ensure all new properties carry full static type annotations (no # type: ignore)

Definition of Done

  • UnitOfWorkContext.tools returns a ToolRegistryRepository instance bound to the current transaction session
  • UnitOfWorkContext.skills returns a SkillRepository instance bound to the current transaction session
  • UnitOfWorkContext.resources returns a ResourceRepository instance bound to the current transaction session
  • All three accessors follow the same lazy-initialization pattern as existing accessors
  • Atomic transactions spanning Tool+Plan, Skill+Project, and Resource+Project work correctly via the UoW
  • 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/uow-missing-tool-skill-resource-accessors` - **Commit Message**: `fix(infrastructure): add missing UoW repository accessors for Tool, Skill, and Resource entities` - **Milestone**: *(none — backlog)* - **Parent Epic**: #397 ## Background The `UnitOfWorkContext` class in `cleveragents.infrastructure.database.unit_of_work` is responsible for providing access to all repositories within a transaction. However, it is missing repository accessors for three core domain entities: 1. **Tools** — No `tools` property returning a `ToolRegistryRepository` 2. **Skills** — No `skills` property returning a `SkillRepository` 3. **Resources** — No `resources` property returning a `ResourceRepository` The specification states: *"The UoW is responsible for managing the lifecycle of repository instances."* The current `UnitOfWorkContext` only exposes: `projects`, `plans`, `actions`, `lifecycle_plans`, `checkpoints`, `contexts`, `changes`, `debug_attempts`, `actors`, `decisions`, `correction_attempts`. This means that code needing to atomically persist both a Tool and a Plan (or a Resource and a Project) cannot do so through the UoW pattern — it must bypass the UoW and use separate sessions, **breaking transaction atomicity**. **Expected behavior**: `UnitOfWorkContext` should expose `tools`, `skills`, and `resources` properties that return the appropriate repository instances bound to the current transaction session. **Actual behavior**: `UnitOfWorkContext` has no `tools`, `skills`, or `resources` properties. Code that needs to persist these entities must create separate sessions outside the UoW transaction. **Code location**: `cleveragents.infrastructure.database.unit_of_work.UnitOfWorkContext` — the class is missing `_tools`, `_skills`, `_resources` instance variables and corresponding `@property` accessors. **Steps to reproduce**: ```python from cleveragents.infrastructure.database.unit_of_work import UnitOfWork uow = UnitOfWork("sqlite:///:memory:") uow.init_database() with uow.transaction() as ctx: ctx.tools # AttributeError: 'UnitOfWorkContext' object has no attribute 'tools' ctx.skills # AttributeError: 'UnitOfWorkContext' object has no attribute 'skills' ctx.resources # AttributeError: 'UnitOfWorkContext' object has no attribute 'resources' ``` *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 `_tools` instance variable to `UnitOfWorkContext.__init__()` initialized to `None` - [ ] Add `_skills` instance variable to `UnitOfWorkContext.__init__()` initialized to `None` - [ ] Add `_resources` instance variable to `UnitOfWorkContext.__init__()` initialized to `None` - [ ] Add `tools` `@property` to `UnitOfWorkContext` returning a `ToolRegistryRepository` bound to the current transaction session - [ ] Add `skills` `@property` to `UnitOfWorkContext` returning a `SkillRepository` bound to the current transaction session - [ ] Add `resources` `@property` to `UnitOfWorkContext` returning a `ResourceRepository` bound to the current transaction session - [ ] Ensure all three new accessors follow the same lazy-initialization pattern as existing accessors (e.g., `projects`, `plans`, `actions`) - [ ] Write Behave unit tests (in `features/`) covering the new `tools`, `skills`, and `resources` accessors - [ ] Verify that atomic transactions spanning Tool+Plan, Skill+Project, and Resource+Project work correctly via the UoW - [ ] Ensure all new properties carry full static type annotations (no `# type: ignore`) ## Definition of Done - [ ] `UnitOfWorkContext.tools` returns a `ToolRegistryRepository` instance bound to the current transaction session - [ ] `UnitOfWorkContext.skills` returns a `SkillRepository` instance bound to the current transaction session - [ ] `UnitOfWorkContext.resources` returns a `ResourceRepository` instance bound to the current transaction session - [ ] All three accessors follow the same lazy-initialization pattern as existing accessors - [ ] Atomic transactions spanning Tool+Plan, Skill+Project, and Resource+Project work correctly via the UoW - [ ] 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#3801
No description provided.