UAT: PersistentSessionService.get() and list() use prohibited # type: ignore comments — violates spec type-checking contract #3688

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

Metadata

  • Branch: fix/session-service-type-ignore-removal
  • Commit Message: fix(session): remove prohibited type: ignore suppressions from PersistentSessionService
  • Milestone: None (Backlog)
  • Parent Epic: #2810

Background and Context

src/cleveragents/application/services/session_service.py contains two # type: ignore comments that directly violate the project's strict prohibition on type suppression. CONTRIBUTING.md states explicitly: "The use of # type: ignore or any other mechanism to suppress or disable type checking is strictly forbidden." All code must be statically typed and pass nox -e typecheck without any suppression.

This was discovered during UAT testing of the Session Management feature area.

Current Behavior

PersistentSessionService.get() (line 116) returns result with # type: ignore[return-value] because SessionRepository.get_by_id() returns Any | None instead of Session | None. Similarly, PersistentSessionService.list() (line 124) returns self._session_repo.list_all() with # type: ignore[return-value] because SessionRepository.list_all() returns list[Any] instead of list[Session].

Root cause: SessionRepository.get_by_id() and list_all() are typed with Any return types (lines 4050, 4071 in repositories.py) because the domain model import creates a circular dependency. The # type: ignore suppressions were added as a workaround instead of resolving the underlying typing problem properly.

Expected Behavior

Per CONTRIBUTING.md and the specification's type-checking contract:

  • All code must be statically typed with explicit annotations.
  • SessionRepository.get_by_id() must return Session | None (not Any | None).
  • SessionRepository.list_all() must return list[Session] (not list[Any]).
  • PersistentSessionService.get() and list() must have no # type: ignore comments.
  • nox -e typecheck must pass without any suppression.

The proper fix is to resolve the circular dependency using forward references (TYPE_CHECKING guard imports), a dedicated protocols.py / interfaces.py module, or proper generic typing — whichever approach is consistent with the existing architecture.

Steps to Reproduce

  1. Run nox -e typecheck — it would fail without the # type: ignore suppression.
  2. Inspect src/cleveragents/application/services/session_service.py lines 116 and 124.
  3. Inspect src/cleveragents/infrastructure/database/repositories.py lines 4050 and 4071.

Code Locations

  • src/cleveragents/application/services/session_service.py:116return result # type: ignore[return-value]
  • src/cleveragents/application/services/session_service.py:124return self._session_repo.list_all() # type: ignore[return-value]
  • src/cleveragents/infrastructure/database/repositories.py:4050SessionRepository.get_by_id() return type (Any | None)
  • src/cleveragents/infrastructure/database/repositories.py:4071SessionRepository.list_all() return type (list[Any])

Subtasks

  • Investigate the circular dependency between SessionRepository and the Session domain model in repositories.py
  • Resolve the circular dependency using TYPE_CHECKING guard imports, forward references, or a protocols/interfaces module
  • Update SessionRepository.get_by_id() return type annotation from Any | None to Session | None
  • Update SessionRepository.list_all() return type annotation from list[Any] to list[Session]
  • Remove # type: ignore[return-value] from PersistentSessionService.get() (line 116)
  • Remove # type: ignore[return-value] from PersistentSessionService.list() (line 124)
  • Verify nox -e typecheck passes with zero suppressions
  • Tests (Behave): Add/update BDD scenarios covering PersistentSessionService.get() and list() return type contracts
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • SessionRepository.get_by_id() is annotated to return Session | None with no Any.
  • SessionRepository.list_all() is annotated to return list[Session] with no Any.
  • No # type: ignore comments remain in session_service.py or the affected sections of repositories.py.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly (fix(session): remove prohibited type: ignore suppressions from PersistentSessionService), 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 (fix/session-service-type-ignore-removal).
  • 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-uat-tester

## Metadata - **Branch**: `fix/session-service-type-ignore-removal` - **Commit Message**: `fix(session): remove prohibited type: ignore suppressions from PersistentSessionService` - **Milestone**: None (Backlog) - **Parent Epic**: #2810 ## Background and Context `src/cleveragents/application/services/session_service.py` contains two `# type: ignore` comments that directly violate the project's strict prohibition on type suppression. CONTRIBUTING.md states explicitly: *"The use of `# type: ignore` or any other mechanism to suppress or disable type checking is strictly forbidden."* All code must be statically typed and pass `nox -e typecheck` without any suppression. This was discovered during UAT testing of the Session Management feature area. ## Current Behavior `PersistentSessionService.get()` (line 116) returns `result` with `# type: ignore[return-value]` because `SessionRepository.get_by_id()` returns `Any | None` instead of `Session | None`. Similarly, `PersistentSessionService.list()` (line 124) returns `self._session_repo.list_all()` with `# type: ignore[return-value]` because `SessionRepository.list_all()` returns `list[Any]` instead of `list[Session]`. **Root cause:** `SessionRepository.get_by_id()` and `list_all()` are typed with `Any` return types (lines 4050, 4071 in `repositories.py`) because the domain model import creates a circular dependency. The `# type: ignore` suppressions were added as a workaround instead of resolving the underlying typing problem properly. ## Expected Behavior Per CONTRIBUTING.md and the specification's type-checking contract: - All code must be statically typed with explicit annotations. - `SessionRepository.get_by_id()` must return `Session | None` (not `Any | None`). - `SessionRepository.list_all()` must return `list[Session]` (not `list[Any]`). - `PersistentSessionService.get()` and `list()` must have no `# type: ignore` comments. - `nox -e typecheck` must pass without any suppression. The proper fix is to resolve the circular dependency using forward references (`TYPE_CHECKING` guard imports), a dedicated `protocols.py` / `interfaces.py` module, or proper generic typing — whichever approach is consistent with the existing architecture. ## Steps to Reproduce 1. Run `nox -e typecheck` — it would fail without the `# type: ignore` suppression. 2. Inspect `src/cleveragents/application/services/session_service.py` lines 116 and 124. 3. Inspect `src/cleveragents/infrastructure/database/repositories.py` lines 4050 and 4071. ## Code Locations - `src/cleveragents/application/services/session_service.py:116` — `return result # type: ignore[return-value]` - `src/cleveragents/application/services/session_service.py:124` — `return self._session_repo.list_all() # type: ignore[return-value]` - `src/cleveragents/infrastructure/database/repositories.py:4050` — `SessionRepository.get_by_id()` return type (`Any | None`) - `src/cleveragents/infrastructure/database/repositories.py:4071` — `SessionRepository.list_all()` return type (`list[Any]`) ## Subtasks - [ ] Investigate the circular dependency between `SessionRepository` and the `Session` domain model in `repositories.py` - [ ] Resolve the circular dependency using `TYPE_CHECKING` guard imports, forward references, or a protocols/interfaces module - [ ] Update `SessionRepository.get_by_id()` return type annotation from `Any | None` to `Session | None` - [ ] Update `SessionRepository.list_all()` return type annotation from `list[Any]` to `list[Session]` - [ ] Remove `# type: ignore[return-value]` from `PersistentSessionService.get()` (line 116) - [ ] Remove `# type: ignore[return-value]` from `PersistentSessionService.list()` (line 124) - [ ] Verify `nox -e typecheck` passes with zero suppressions - [ ] Tests (Behave): Add/update BDD scenarios covering `PersistentSessionService.get()` and `list()` return type contracts - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `SessionRepository.get_by_id()` is annotated to return `Session | None` with no `Any`. - `SessionRepository.list_all()` is annotated to return `list[Session]` with no `Any`. - No `# type: ignore` comments remain in `session_service.py` or the affected sections of `repositories.py`. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly (`fix(session): remove prohibited type: ignore suppressions from PersistentSessionService`), 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 (`fix/session-service-type-ignore-removal`). - 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-uat-tester
Author
Owner

Label compliance fix applied:

  • Added missing labels: Type/Bug, State/Unverified, Priority/Backlog
  • Reason: Issue had no labels. Per CONTRIBUTING.md, every issue must have exactly one State/*, one Type/*, and one Priority/* label. This is a UAT bug report, so Type/Bug is correct. The issue body notes it is a backlog item, so Priority/Backlog and State/Unverified are appropriate.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Label compliance fix applied: - Added missing labels: `Type/Bug`, `State/Unverified`, `Priority/Backlog` - Reason: Issue had no labels. Per CONTRIBUTING.md, every issue must have exactly one `State/*`, one `Type/*`, and one `Priority/*` label. This is a UAT bug report, so `Type/Bug` is correct. The issue body notes it is a backlog item, so `Priority/Backlog` and `State/Unverified` are appropriate. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
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#3688
No description provided.