UAT: NamespacedProjectRepository missing list_all() method — cannot list all projects via the spec-aligned repository #2872

Open
opened 2026-04-04 21:17:02 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/namespaced-project-repository-list-all
  • Commit Message: fix(repositories): add list_all() method to NamespacedProjectRepository
  • Milestone: v3.7.0
  • Parent Epic: #398

Background & Context

During UAT testing of the Data Models & Persistence feature area, NamespacedProjectRepository was found to be missing a list_all() method. The spec requires that projects can be listed, and the repository pattern used throughout the codebase (e.g., ActionRepository, LifecyclePlanRepository) consistently provides a list_all() method. This omission means the agents project list CLI command cannot use the spec-aligned repository, and any service needing to enumerate all projects is blocked.

Code location: src/cleveragents/infrastructure/database/repositories.pyNamespacedProjectRepository class

Current Behavior

NamespacedProjectRepository does not have a list_all() method. Verified by inspection:

from cleveragents.infrastructure.database.repositories import NamespacedProjectRepository
repo_methods = [m for m in dir(NamespacedProjectRepository) if not m.startswith('_')]
print(repo_methods)
# Missing: 'list_all'
# Present: 'create', 'get', 'update', 'delete', ...

Steps to reproduce:

from cleveragents.infrastructure.database.repositories import NamespacedProjectRepository
if not hasattr(NamespacedProjectRepository, 'list_all'):
    print("MISSING: NamespacedProjectRepository.list_all()")

Expected Behavior

NamespacedProjectRepository should provide a list_all() method consistent with other repositories (ActionRepository.list_all(), LifecyclePlanRepository.list_all()). The ActionRepository (for comparison) has list_all(), list_available(), get_by_namespace(), and get_by_state() — all of which are needed for the agents project list CLI command to work correctly.

The required implementation:

@database_retry
def list_all(self, namespace: str | None = None) -> list[NamespacedProject]:
    """List all persisted projects, optionally filtered by namespace."""
    session = self._session()
    try:
        query = session.query(NamespacedProjectModel)
        if namespace is not None:
            query = query.filter_by(namespace=namespace)
        rows = query.order_by(
            NamespacedProjectModel.namespace,
            NamespacedProjectModel.namespaced_name,
        ).all()
        return [row.to_domain() for row in rows]
    except (OperationalError, SQLAlchemyDatabaseError) as exc:
        raise DatabaseError(f"Failed to list projects: {exc}") from exc

Impact

  • Medium: agents project list cannot enumerate all projects — the CLI command must either use a different (potentially legacy) code path or fail
  • Medium: Any service that needs to list all projects (e.g., for multi-project plan validation) cannot use the spec-aligned NamespacedProjectRepository
  • Low: Inconsistency with other repositories (ActionRepository, LifecyclePlanRepository) that all provide list_all()

Subtasks

  • Add list_all(namespace: str | None = None) method to NamespacedProjectRepository
  • Add list_by_namespace(namespace: str) convenience method for consistency with ActionRepository
  • Add Behave scenarios covering list_all() with and without namespace filter
  • Verify agents project list CLI command uses list_all() correctly
  • Run nox -e typecheck to confirm no type regressions
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • NamespacedProjectRepository.list_all() returns all projects ordered by namespace then name
  • NamespacedProjectRepository.list_all(namespace='local') returns only local-namespace projects
  • agents project list CLI command works correctly using the new method
  • Behave scenario added covering the new 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 lines providing relevant details about the implementation
  • 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%

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

## Metadata - **Branch**: `fix/namespaced-project-repository-list-all` - **Commit Message**: `fix(repositories): add list_all() method to NamespacedProjectRepository` - **Milestone**: v3.7.0 - **Parent Epic**: #398 ## Background & Context During UAT testing of the Data Models & Persistence feature area, `NamespacedProjectRepository` was found to be missing a `list_all()` method. The spec requires that projects can be listed, and the repository pattern used throughout the codebase (e.g., `ActionRepository`, `LifecyclePlanRepository`) consistently provides a `list_all()` method. This omission means the `agents project list` CLI command cannot use the spec-aligned repository, and any service needing to enumerate all projects is blocked. **Code location**: `src/cleveragents/infrastructure/database/repositories.py` — `NamespacedProjectRepository` class ## Current Behavior `NamespacedProjectRepository` does not have a `list_all()` method. Verified by inspection: ```python from cleveragents.infrastructure.database.repositories import NamespacedProjectRepository repo_methods = [m for m in dir(NamespacedProjectRepository) if not m.startswith('_')] print(repo_methods) # Missing: 'list_all' # Present: 'create', 'get', 'update', 'delete', ... ``` Steps to reproduce: ```python from cleveragents.infrastructure.database.repositories import NamespacedProjectRepository if not hasattr(NamespacedProjectRepository, 'list_all'): print("MISSING: NamespacedProjectRepository.list_all()") ``` ## Expected Behavior `NamespacedProjectRepository` should provide a `list_all()` method consistent with other repositories (`ActionRepository.list_all()`, `LifecyclePlanRepository.list_all()`). The `ActionRepository` (for comparison) has `list_all()`, `list_available()`, `get_by_namespace()`, and `get_by_state()` — all of which are needed for the `agents project list` CLI command to work correctly. The required implementation: ```python @database_retry def list_all(self, namespace: str | None = None) -> list[NamespacedProject]: """List all persisted projects, optionally filtered by namespace.""" session = self._session() try: query = session.query(NamespacedProjectModel) if namespace is not None: query = query.filter_by(namespace=namespace) rows = query.order_by( NamespacedProjectModel.namespace, NamespacedProjectModel.namespaced_name, ).all() return [row.to_domain() for row in rows] except (OperationalError, SQLAlchemyDatabaseError) as exc: raise DatabaseError(f"Failed to list projects: {exc}") from exc ``` ## Impact - **Medium**: `agents project list` cannot enumerate all projects — the CLI command must either use a different (potentially legacy) code path or fail - **Medium**: Any service that needs to list all projects (e.g., for multi-project plan validation) cannot use the spec-aligned `NamespacedProjectRepository` - **Low**: Inconsistency with other repositories (`ActionRepository`, `LifecyclePlanRepository`) that all provide `list_all()` ## Subtasks - [ ] Add `list_all(namespace: str | None = None)` method to `NamespacedProjectRepository` - [ ] Add `list_by_namespace(namespace: str)` convenience method for consistency with `ActionRepository` - [ ] Add Behave scenarios covering `list_all()` with and without namespace filter - [ ] Verify `agents project list` CLI command uses `list_all()` correctly - [ ] Run `nox -e typecheck` to confirm no type regressions - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - [ ] `NamespacedProjectRepository.list_all()` returns all projects ordered by namespace then name - [ ] `NamespacedProjectRepository.list_all(namespace='local')` returns only local-namespace projects - [ ] `agents project list` CLI command works correctly using the new method - [ ] Behave scenario added covering the new 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 lines providing relevant details about the implementation - [ ] 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% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
freemo added this to the v3.7.0 milestone 2026-04-04 21:17:08 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — Missing list_all() method is an API gap that blocks the agents project list CLI command from using the spec-aligned repository. Other repositories consistently provide this method.
  • Milestone: v3.7.0 (already set correctly)
  • MoSCoW: Should Have — The repository pattern requires consistent API across all repositories. The spec requires project listing capability. This is important for API consistency but the system can function via alternative code paths.
  • Parent Epic: #398 (Epic: Post-MVP Resources)

Well-described issue with clear reproduction steps, expected implementation, and definition of done. Valid UAT finding.


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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — Missing `list_all()` method is an API gap that blocks the `agents project list` CLI command from using the spec-aligned repository. Other repositories consistently provide this method. - **Milestone**: v3.7.0 (already set correctly) - **MoSCoW**: Should Have — The repository pattern requires consistent API across all repositories. The spec requires project listing capability. This is important for API consistency but the system can function via alternative code paths. - **Parent Epic**: #398 (Epic: Post-MVP Resources) Well-described issue with clear reproduction steps, expected implementation, and definition of done. Valid UAT finding. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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
#398 Epic: Post-MVP Resources
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2872
No description provided.