UAT: sqlalchemy not declared as a direct dependency in pyproject.toml — relies on transitive install via langchain-community #4046

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

Metadata

  • Branch: fix/declare-sqlalchemy-direct-dependency
  • Commit Message: fix(build): declare sqlalchemy as a direct dependency in pyproject.toml
  • Milestone: (none — backlog)
  • Parent Epic: #2810

Backlog note: This issue was discovered during autonomous UAT testing
of the Dependency Management and Package System feature area.
It does not block milestone completion and has been placed in the backlog
for human review and future milestone assignment.

Bug Report

What Was Tested

Code-level analysis of pyproject.toml dependencies vs actual third-party imports across the source codebase.

Expected Behavior (Best Practice)

sqlalchemy should be declared as a direct dependency in pyproject.toml because the codebase directly imports from it in multiple production files. Best practice (and PEP 517/518 guidance) requires that all packages you import directly be listed as direct dependencies — not relied upon as transitive dependencies that could be removed or version-changed by an upstream package.

Actual Behavior

sqlalchemy is not listed in pyproject.toml [project.dependencies]. It is only available as a transitive dependency via langchain-community>=0.2.14, which declares SQLAlchemy<3.0.0,>=1.4.0 as its own dependency.

Files That Directly Import SQLAlchemy

The following production source files import directly from sqlalchemy:

  1. src/cleveragents/infrastructure/database/models.py:

    from sqlalchemy import (JSON, Boolean, CheckConstraint, ...)
    from sqlalchemy.orm import (DeclarativeBase, Mapped, ...)
    
  2. src/cleveragents/infrastructure/database/repositories.py:

    from sqlalchemy import func as sa_func
    from sqlalchemy.exc import DatabaseError as SQLAlchemyDatabaseError
    from sqlalchemy.exc import IntegrityError, OperationalError
    from sqlalchemy.orm import Session
    
  3. src/cleveragents/infrastructure/database/unit_of_work.py:

    from sqlalchemy import create_engine
    from sqlalchemy.orm import Session, sessionmaker
    
  4. src/cleveragents/application/services/audit_service.py:

    from sqlalchemy import create_engine
    from sqlalchemy.orm import Session, sessionmaker
    

Risk

If langchain-community ever removes or changes its SQLAlchemy dependency (e.g., makes it optional or upgrades to SQLAlchemy 3.x), the entire database layer of CleverAgents will break at install time without any warning. This is a fragile dependency chain for a core infrastructure component.

Steps to Reproduce

  1. Read pyproject.toml — search for sqlalchemy in [project.dependencies]
  2. Observe it is absent
  3. Read src/cleveragents/infrastructure/database/models.py — observe direct from sqlalchemy import ... statements

Fix

Add sqlalchemy>=2.0.0 (or the appropriate minimum version) to [project.dependencies] in pyproject.toml:

dependencies = [
    ...
    "sqlalchemy>=2.0.0",  # ORM for database layer (models, repositories, unit of work)
    ...
]

Subtasks

  • Add sqlalchemy>=2.0.0 to [project.dependencies] in pyproject.toml
  • Verify the version constraint is compatible with langchain-community's SQLAlchemy<3.0.0,>=1.4.0
  • Run nox -e lint and nox -e typecheck to verify no regressions

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • sqlalchemy appears as a direct dependency in pyproject.toml
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly
  • 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.

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

## Metadata - **Branch**: `fix/declare-sqlalchemy-direct-dependency` - **Commit Message**: `fix(build): declare sqlalchemy as a direct dependency in pyproject.toml` - **Milestone**: *(none — backlog)* - **Parent Epic**: #2810 > **Backlog note:** This issue was discovered during autonomous UAT testing > of the Dependency Management and Package System feature area. > It does not block milestone completion and has been placed in the backlog > for human review and future milestone assignment. ## Bug Report ### What Was Tested Code-level analysis of `pyproject.toml` dependencies vs actual third-party imports across the source codebase. ### Expected Behavior (Best Practice) `sqlalchemy` should be declared as a **direct dependency** in `pyproject.toml` because the codebase directly imports from it in multiple production files. Best practice (and PEP 517/518 guidance) requires that all packages you import directly be listed as direct dependencies — not relied upon as transitive dependencies that could be removed or version-changed by an upstream package. ### Actual Behavior `sqlalchemy` is **not listed** in `pyproject.toml` `[project.dependencies]`. It is only available as a transitive dependency via `langchain-community>=0.2.14`, which declares `SQLAlchemy<3.0.0,>=1.4.0` as its own dependency. ### Files That Directly Import SQLAlchemy The following production source files import directly from `sqlalchemy`: 1. `src/cleveragents/infrastructure/database/models.py`: ```python from sqlalchemy import (JSON, Boolean, CheckConstraint, ...) from sqlalchemy.orm import (DeclarativeBase, Mapped, ...) ``` 2. `src/cleveragents/infrastructure/database/repositories.py`: ```python from sqlalchemy import func as sa_func from sqlalchemy.exc import DatabaseError as SQLAlchemyDatabaseError from sqlalchemy.exc import IntegrityError, OperationalError from sqlalchemy.orm import Session ``` 3. `src/cleveragents/infrastructure/database/unit_of_work.py`: ```python from sqlalchemy import create_engine from sqlalchemy.orm import Session, sessionmaker ``` 4. `src/cleveragents/application/services/audit_service.py`: ```python from sqlalchemy import create_engine from sqlalchemy.orm import Session, sessionmaker ``` ### Risk If `langchain-community` ever removes or changes its SQLAlchemy dependency (e.g., makes it optional or upgrades to SQLAlchemy 3.x), the entire database layer of CleverAgents will break at install time without any warning. This is a fragile dependency chain for a core infrastructure component. ### Steps to Reproduce 1. Read `pyproject.toml` — search for `sqlalchemy` in `[project.dependencies]` 2. Observe it is absent 3. Read `src/cleveragents/infrastructure/database/models.py` — observe direct `from sqlalchemy import ...` statements ### Fix Add `sqlalchemy>=2.0.0` (or the appropriate minimum version) to `[project.dependencies]` in `pyproject.toml`: ```toml dependencies = [ ... "sqlalchemy>=2.0.0", # ORM for database layer (models, repositories, unit of work) ... ] ``` ## Subtasks - [ ] Add `sqlalchemy>=2.0.0` to `[project.dependencies]` in `pyproject.toml` - [ ] Verify the version constraint is compatible with `langchain-community`'s `SQLAlchemy<3.0.0,>=1.4.0` - [ ] Run `nox -e lint` and `nox -e typecheck` to verify no regressions ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `sqlalchemy` appears as a direct dependency in `pyproject.toml` - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly - 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. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
HAL9000 added this to the v3.5.0 milestone 2026-04-09 03:11:34 +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.

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