UAT: infrastructure/database/models.py exceeds 500-line limit at 3,594 lines — must be split into focused ORM model modules #4124

Closed
opened 2026-04-06 10:30:18 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: refactor/split-database-orm-models
  • Commit Message: refactor(infrastructure): split models.py into focused per-aggregate ORM model modules
  • Milestone: (none — backlog, see note below)
  • Parent Epic: #1020

Bug Report

Feature Area: Code Organization and Module Structure
Tested by: UAT tester instance uat-tester-code-org-001
Severity: Medium (CONTRIBUTING.md compliance violation)

What Was Tested

Checked all Python files in src/cleveragents/ for compliance with the 500-line file size limit specified in CONTRIBUTING.md line 399: "Keep files under 500 lines. Break large files into focused, cohesive modules."

Expected Behavior (from CONTRIBUTING.md)

All Python source files should be under 500 lines. Large files must be broken into focused, cohesive modules.

Actual Behavior

src/cleveragents/infrastructure/database/models.py contains 3,594 lines7.2× the allowed limit.

Evidence

$ wc -l src/cleveragents/infrastructure/database/models.py
3594 src/cleveragents/infrastructure/database/models.py

The file contains many SQLAlchemy ORM model classes that could each live in their own module. Additionally, the file contains multiple function-level imports inside to_domain() methods (e.g., lines 336, 343, 344, 431, 800, 1319, 2074, 2189, 2390, 2769) which violates the CONTRIBUTING.md rule against imports inside indented code blocks.

Steps to Reproduce

wc -l src/cleveragents/infrastructure/database/models.py
grep -n "^\s\+from cleveragents" src/cleveragents/infrastructure/database/models.py

Suggested Fix

Split into per-aggregate ORM model modules under src/cleveragents/infrastructure/database/:

  • plan_models.py
  • project_models.py
  • session_models.py
  • resource_models.py
  • skill_models.py
  • decision_models.py
  • etc.

Move function-level imports to module top level.

Code Location

src/cleveragents/infrastructure/database/models.py

Subtasks

  • Audit models.py and group ORM classes by aggregate/domain area
  • Create per-aggregate model modules under src/cleveragents/infrastructure/database/
  • Move plan-related ORM models to plan_models.py
  • Move project-related ORM models to project_models.py
  • Move session-related ORM models to session_models.py
  • Move resource-related ORM models to resource_models.py
  • Move skill-related ORM models to skill_models.py
  • Move decision-related ORM models to decision_models.py
  • Move any remaining ORM models to appropriately named modules
  • Hoist all function-level imports in to_domain() methods to module top level
  • Update __init__.py or re-export symbols to preserve backward compatibility
  • Update all import sites referencing models.py directly
  • Tests (Behave/Robot): Verify no regressions in ORM-dependent tests
  • Verify each new module is under 500 lines
  • Run nox (all default sessions), fix any errors
  • Verify coverage >= 97% via nox -s coverage_report

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • src/cleveragents/infrastructure/database/models.py no longer exists (or is a thin re-export shim under 500 lines)
  • All new per-aggregate model modules are under 500 lines
  • No function-level imports remain in any to_domain() method
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done
  • All nox stages pass
  • Coverage >= 97%

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


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

## Metadata - **Branch**: `refactor/split-database-orm-models` - **Commit Message**: `refactor(infrastructure): split models.py into focused per-aggregate ORM model modules` - **Milestone**: *(none — backlog, see note below)* - **Parent Epic**: #1020 ## Bug Report **Feature Area:** Code Organization and Module Structure **Tested by:** UAT tester instance uat-tester-code-org-001 **Severity:** Medium (CONTRIBUTING.md compliance violation) ### What Was Tested Checked all Python files in `src/cleveragents/` for compliance with the 500-line file size limit specified in CONTRIBUTING.md line 399: *"Keep files under 500 lines. Break large files into focused, cohesive modules."* ### Expected Behavior (from CONTRIBUTING.md) All Python source files should be under 500 lines. Large files must be broken into focused, cohesive modules. ### Actual Behavior `src/cleveragents/infrastructure/database/models.py` contains **3,594 lines** — **7.2× the allowed limit**. ### Evidence ``` $ wc -l src/cleveragents/infrastructure/database/models.py 3594 src/cleveragents/infrastructure/database/models.py ``` The file contains many SQLAlchemy ORM model classes that could each live in their own module. Additionally, the file contains multiple function-level imports inside `to_domain()` methods (e.g., lines 336, 343, 344, 431, 800, 1319, 2074, 2189, 2390, 2769) which violates the CONTRIBUTING.md rule against imports inside indented code blocks. ### Steps to Reproduce ```bash wc -l src/cleveragents/infrastructure/database/models.py grep -n "^\s\+from cleveragents" src/cleveragents/infrastructure/database/models.py ``` ### Suggested Fix Split into per-aggregate ORM model modules under `src/cleveragents/infrastructure/database/`: - `plan_models.py` - `project_models.py` - `session_models.py` - `resource_models.py` - `skill_models.py` - `decision_models.py` - etc. Move function-level imports to module top level. ### Code Location `src/cleveragents/infrastructure/database/models.py` ## Subtasks - [ ] Audit `models.py` and group ORM classes by aggregate/domain area - [ ] Create per-aggregate model modules under `src/cleveragents/infrastructure/database/` - [ ] Move `plan`-related ORM models to `plan_models.py` - [ ] Move `project`-related ORM models to `project_models.py` - [ ] Move `session`-related ORM models to `session_models.py` - [ ] Move `resource`-related ORM models to `resource_models.py` - [ ] Move `skill`-related ORM models to `skill_models.py` - [ ] Move `decision`-related ORM models to `decision_models.py` - [ ] Move any remaining ORM models to appropriately named modules - [ ] Hoist all function-level imports in `to_domain()` methods to module top level - [ ] Update `__init__.py` or re-export symbols to preserve backward compatibility - [ ] Update all import sites referencing `models.py` directly - [ ] Tests (Behave/Robot): Verify no regressions in ORM-dependent tests - [ ] Verify each new module is under 500 lines - [ ] Run `nox` (all default sessions), fix any errors - [ ] Verify coverage >= 97% via `nox -s coverage_report` ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `src/cleveragents/infrastructure/database/models.py` no longer exists (or is a thin re-export shim under 500 lines) - All new per-aggregate model modules are under 500 lines - No function-level imports remain in any `to_domain()` method - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional details - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done - All nox stages pass - Coverage >= 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.7.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
Author
Owner

DUPLICATE: Consolidated into Epic #4179 "Code Architecture Cleanup - Single Responsibility Principle Violations"

This UAT finding about infrastructure/database/models.py exceeding 500-line limit (3,594 lines) is part of the broader architectural cleanup effort. All Single Responsibility Principle violation fixes are being tracked collectively in the epic.

Action: Closing as duplicate in favor of Epic #4179

**DUPLICATE**: Consolidated into Epic #4179 "Code Architecture Cleanup - Single Responsibility Principle Violations" This UAT finding about `infrastructure/database/models.py` exceeding 500-line limit (3,594 lines) is part of the broader architectural cleanup effort. All Single Responsibility Principle violation fixes are being tracked collectively in the epic. **Action**: Closing as duplicate in favor of Epic #4179
Author
Owner

Milestone Triage Decision: Moved to Backlog

This CLI enhancement issue has been moved out of v3.3.0 during aggressive milestone triage. While useful for user experience, it does not relate to the core focus of Corrections + Subplans + Checkpoints.

Reasoning:

  • v3.3.0 focus: Essential corrections, subplan management, and checkpoint functionality
  • This issue: CLI validation enhancement - user experience improvement
  • Impact: UX enhancement, not core corrections/subplans/checkpoints functionality

Will be addressed in a future milestone focused on CLI polish and user experience enhancements.

**Milestone Triage Decision: Moved to Backlog** This CLI enhancement issue has been moved out of v3.3.0 during aggressive milestone triage. While useful for user experience, it does not relate to the core focus of Corrections + Subplans + Checkpoints. **Reasoning:** - v3.3.0 focus: Essential corrections, subplan management, and checkpoint functionality - This issue: CLI validation enhancement - user experience improvement - Impact: UX enhancement, not core corrections/subplans/checkpoints functionality Will be addressed in a future milestone focused on CLI polish and user experience enhancements.
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
Reference
cleveragents/cleveragents-core#4124
No description provided.