UAT: infrastructure/database/repositories.py is 6035 lines — violates 500-line file size limit from CONTRIBUTING.md #3809

Open
opened 2026-04-06 06:30:54 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: refactor/repositories-modular-split
  • Commit Message: refactor(infrastructure): split repositories.py into focused per-domain modules
  • Milestone: (none — backlog)
  • Parent Epic: #946

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

Description

The file src/cleveragents/infrastructure/database/repositories.py is 6,035 lines long. CONTRIBUTING.md explicitly states under "General Principles":

"Modular Design: Keep files under 500 lines. Break large files into focused, cohesive modules."

The file contains 26 repository classes, all in a single monolithic file:

  • ProjectRepository
  • PlanRepository (deprecated)
  • ContextRepository
  • ChangeRepository (deprecated)
  • DebugAttemptRepository
  • ActorRepository
  • ActionRepository
  • LifecyclePlanRepository
  • ResourceTypeRepository
  • ResourceRepository
  • NamespacedProjectRepository
  • ProjectResourceLinkRepository
  • ToolRegistryRepository
  • ToolRepository (compatibility wrapper)
  • ValidationAttachmentRepository
  • SessionRepository
  • SessionMessageRepository
  • AutomationProfileRepository
  • SkillRepository
  • DecisionRepository
  • CheckpointRepository
  • CorrectionAttemptRepository
  • (plus several exception classes and helper functions)

Expected behavior: The file should be split into focused, cohesive modules of under 500 lines each. Each repository class (or related group of classes) should have its own module file within the cleveragents.infrastructure.database package, with a top-level __init__.py re-exporting all public symbols for backward compatibility.

Actual behavior: All 26 repository classes are in a single 6,035-line file, making it extremely difficult to navigate, review, and maintain.

Code location: src/cleveragents/infrastructure/database/repositories.py — 6,035 lines

Steps to reproduce:

wc -l src/cleveragents/infrastructure/database/repositories.py
# Output: 6035

This was discovered during UAT testing of the Repository Pattern and Data Layer feature area.

Subtasks

  • Audit repositories.py and group the 26 classes into cohesive domain modules (e.g., plan_repositories.py, project_repositories.py, actor_repositories.py, session_repositories.py, resource_repositories.py, decision_repositories.py, correction_repositories.py, tool_repositories.py)
  • Create a repositories/ sub-package under src/cleveragents/infrastructure/database/ with an __init__.py that re-exports all public symbols for backward compatibility
  • Move each repository class (and its associated exceptions/helpers) into the appropriate module file, keeping each file under 500 lines
  • Update all import sites across the codebase that reference cleveragents.infrastructure.database.repositories to use the new module paths (or rely on the re-export __init__.py)
  • Write/update Behave unit tests for any new module boundaries introduced
  • Verify nox -e typecheck passes (Pyright) with no new type errors
  • Verify nox -e lint passes after the split
  • Verify nox -e unit_tests passes with coverage >= 97%
  • Verify nox -e integration_tests passes

Definition of Done

  • src/cleveragents/infrastructure/database/repositories.py no longer exists as a monolithic file — replaced by a repositories/ sub-package
  • Every new module file is under 500 lines
  • All public symbols remain importable from the original path via __init__.py re-exports (backward compatibility preserved)
  • All import sites updated and verified
  • All nox stages pass
  • Coverage >= 97%
  • PR reviewed and merged

Automated by CleverAgents Bot
Supervisor: Acting on behalf of: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `refactor/repositories-modular-split` - **Commit Message**: `refactor(infrastructure): split repositories.py into focused per-domain modules` - **Milestone**: *(none — backlog)* - **Parent Epic**: #946 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Description The file `src/cleveragents/infrastructure/database/repositories.py` is **6,035 lines** long. CONTRIBUTING.md explicitly states under "General Principles": > "Modular Design: Keep files under 500 lines. Break large files into focused, cohesive modules." The file contains **26 repository classes**, all in a single monolithic file: - `ProjectRepository` - `PlanRepository` *(deprecated)* - `ContextRepository` - `ChangeRepository` *(deprecated)* - `DebugAttemptRepository` - `ActorRepository` - `ActionRepository` - `LifecyclePlanRepository` - `ResourceTypeRepository` - `ResourceRepository` - `NamespacedProjectRepository` - `ProjectResourceLinkRepository` - `ToolRegistryRepository` - `ToolRepository` *(compatibility wrapper)* - `ValidationAttachmentRepository` - `SessionRepository` - `SessionMessageRepository` - `AutomationProfileRepository` - `SkillRepository` - `DecisionRepository` - `CheckpointRepository` - `CorrectionAttemptRepository` - *(plus several exception classes and helper functions)* **Expected behavior:** The file should be split into focused, cohesive modules of under 500 lines each. Each repository class (or related group of classes) should have its own module file within the `cleveragents.infrastructure.database` package, with a top-level `__init__.py` re-exporting all public symbols for backward compatibility. **Actual behavior:** All 26 repository classes are in a single 6,035-line file, making it extremely difficult to navigate, review, and maintain. **Code location:** `src/cleveragents/infrastructure/database/repositories.py` — 6,035 lines **Steps to reproduce:** ```bash wc -l src/cleveragents/infrastructure/database/repositories.py # Output: 6035 ``` This was discovered during UAT testing of the Repository Pattern and Data Layer feature area. ## Subtasks - [ ] Audit `repositories.py` and group the 26 classes into cohesive domain modules (e.g., `plan_repositories.py`, `project_repositories.py`, `actor_repositories.py`, `session_repositories.py`, `resource_repositories.py`, `decision_repositories.py`, `correction_repositories.py`, `tool_repositories.py`) - [ ] Create a `repositories/` sub-package under `src/cleveragents/infrastructure/database/` with an `__init__.py` that re-exports all public symbols for backward compatibility - [ ] Move each repository class (and its associated exceptions/helpers) into the appropriate module file, keeping each file under 500 lines - [ ] Update all import sites across the codebase that reference `cleveragents.infrastructure.database.repositories` to use the new module paths (or rely on the re-export `__init__.py`) - [ ] Write/update Behave unit tests for any new module boundaries introduced - [ ] Verify `nox -e typecheck` passes (Pyright) with no new type errors - [ ] Verify `nox -e lint` passes after the split - [ ] Verify `nox -e unit_tests` passes with coverage >= 97% - [ ] Verify `nox -e integration_tests` passes ## Definition of Done - [ ] `src/cleveragents/infrastructure/database/repositories.py` no longer exists as a monolithic file — replaced by a `repositories/` sub-package - [ ] Every new module file is under 500 lines - [ ] All public symbols remain importable from the original path via `__init__.py` re-exports (backward compatibility preserved) - [ ] All import sites updated and verified - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] PR reviewed and merged --- **Automated by CleverAgents Bot** Supervisor: Acting on behalf of: 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.

Reference
cleveragents/cleveragents-core#3809
No description provided.