UAT: UnitOfWorkContext missing repository accessors for Session, Resource, Skill, Tool, AutomationProfile #4711

Open
opened 2026-04-08 18:11:00 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Database layer and repository patterns — UnitOfWork
Severity: Medium — repositories exist but are not accessible via the UnitOfWork pattern
Source: src/cleveragents/infrastructure/database/unit_of_work.py


What Was Tested

Code-level analysis of UnitOfWorkContext to verify that all repository implementations are accessible via the Unit of Work pattern.

Expected Behavior

All repository implementations in repositories.py should be accessible via UnitOfWorkContext properties, following the session-factory pattern documented in ADR-007. The UoW is the primary transaction management mechanism and should expose all repositories.

Actual Behavior

UnitOfWorkContext exposes only these repositories:

  • projects (ProjectRepository)
  • plans (PlanRepository — deprecated)
  • lifecycle_plans (LifecyclePlanRepository)
  • actions (ActionRepository)
  • decisions (DecisionRepository)
  • checkpoints (CheckpointRepository)
  • correction_attempts (CorrectionAttemptRepository)
  • actors (ActorRepository)
  • contexts (ContextRepository)
  • changes (ChangeRepository — deprecated)
  • debug_attempts (DebugAttemptRepository)

Missing from UnitOfWorkContext:

  • sessions (SessionRepository — exists at line 4010)
  • session_messages (SessionMessageRepository — exists at line 4211)
  • resources (ResourceRepository — exists at line 2090)
  • resource_types (ResourceTypeRepository — exists at line 1747)
  • skills (SkillRepository — exists at line 4726)
  • tools (ToolRegistryRepository — exists at line 3362)
  • automation_profiles (AutomationProfileRepository — exists at line 4352)
  • validation_attachments (ValidationAttachmentRepository — exists at line 3771)
  • project_resource_links (ProjectResourceLinkRepository — exists at line 3139)

Impact

Application services that need to perform cross-repository transactions (e.g., creating a session while updating a plan) cannot use the UoW pattern for these repositories. They must manage sessions independently, breaking transactional atomicity.

For example, SessionService cannot participate in a UoW transaction that also touches plans or decisions.

Code Location

  • src/cleveragents/infrastructure/database/unit_of_work.pyUnitOfWorkContext class (lines 155–320)
  • src/cleveragents/infrastructure/database/repositories.py — all repository classes

Fix Required

Add @property accessors to UnitOfWorkContext for each missing repository, following the existing pattern:

@property
def sessions(self) -> SessionRepository:
    if self._sessions is None:
        self._sessions = SessionRepository(session_factory=self._session_factory)
    return self._sessions

Also add corresponding _sessions, _resources, etc. instance variables to __init__.


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

## Bug Report **Feature Area:** Database layer and repository patterns — UnitOfWork **Severity:** Medium — repositories exist but are not accessible via the UnitOfWork pattern **Source:** `src/cleveragents/infrastructure/database/unit_of_work.py` --- ## What Was Tested Code-level analysis of `UnitOfWorkContext` to verify that all repository implementations are accessible via the Unit of Work pattern. ## Expected Behavior All repository implementations in `repositories.py` should be accessible via `UnitOfWorkContext` properties, following the session-factory pattern documented in ADR-007. The UoW is the primary transaction management mechanism and should expose all repositories. ## Actual Behavior `UnitOfWorkContext` exposes only these repositories: - `projects` (ProjectRepository) - `plans` (PlanRepository — deprecated) - `lifecycle_plans` (LifecyclePlanRepository) - `actions` (ActionRepository) - `decisions` (DecisionRepository) - `checkpoints` (CheckpointRepository) - `correction_attempts` (CorrectionAttemptRepository) - `actors` (ActorRepository) - `contexts` (ContextRepository) - `changes` (ChangeRepository — deprecated) - `debug_attempts` (DebugAttemptRepository) **Missing from `UnitOfWorkContext`:** - `sessions` (SessionRepository — exists at line 4010) - `session_messages` (SessionMessageRepository — exists at line 4211) - `resources` (ResourceRepository — exists at line 2090) - `resource_types` (ResourceTypeRepository — exists at line 1747) - `skills` (SkillRepository — exists at line 4726) - `tools` (ToolRegistryRepository — exists at line 3362) - `automation_profiles` (AutomationProfileRepository — exists at line 4352) - `validation_attachments` (ValidationAttachmentRepository — exists at line 3771) - `project_resource_links` (ProjectResourceLinkRepository — exists at line 3139) ## Impact Application services that need to perform cross-repository transactions (e.g., creating a session while updating a plan) cannot use the UoW pattern for these repositories. They must manage sessions independently, breaking transactional atomicity. For example, `SessionService` cannot participate in a UoW transaction that also touches plans or decisions. ## Code Location - `src/cleveragents/infrastructure/database/unit_of_work.py` — `UnitOfWorkContext` class (lines 155–320) - `src/cleveragents/infrastructure/database/repositories.py` — all repository classes ## Fix Required Add `@property` accessors to `UnitOfWorkContext` for each missing repository, following the existing pattern: ```python @property def sessions(self) -> SessionRepository: if self._sessions is None: self._sessions = SessionRepository(session_factory=self._session_factory) return self._sessions ``` Also add corresponding `_sessions`, `_resources`, etc. instance variables to `__init__`. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — spec compliance bug identified by UAT testing
  • Story Points: 3 (M) — targeted fix to align implementation with spec
  • MoSCoW: Must Have — spec compliance is required for correct system behavior

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — spec compliance bug identified by UAT testing - **Story Points**: 3 (M) — targeted fix to align implementation with spec - **MoSCoW**: Must Have — spec compliance is required for correct system behavior --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:06:14 +00:00
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#4711
No description provided.