UAT: CleanupService session scan and purge are placeholder stubs — agents cleanup cannot clean sessions #3941

Open
opened 2026-04-06 07:39:55 +00:00 by freemo · 0 comments
Owner

Background and Context

The CleanupService in src/cleveragents/application/services/cleanup_service.py contains two placeholder methods for session cleanup: _scan_sessions (lines 304–310) and _purge_sessions (lines 314–320). Both are explicitly documented as "not yet implemented in MVP" and contain only TODO(CONC3) comments. The CLI command agents cleanup also surfaces a user-visible note that session cleanup is not yet implemented.

Per docs/specification.md, session lifecycle management is a core feature of the platform. The agents cleanup command is expected to clean up stale sessions as part of its operation. This gap means session data accumulates indefinitely with no automated cleanup mechanism.

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.

Related issue: #3843 covers the same TODO(CONC3) comments from an architecture-guard perspective (Type/Refactor). This issue tracks the same gap as a UAT bug with full reproduction steps and impact assessment.

Current Behavior

# src/cleveragents/application/services/cleanup_service.py lines 304-320:
def _scan_sessions(self, report: CleanupReport) -> None:
    """Placeholder scan — session cleanup requires DB access.
    Session cleanup is not yet implemented in MVP.
    """
    # TODO(CONC3): Wire DB session query when Container is available at CLI startup.

def _purge_sessions(self, report: CleanupReport) -> None:
    """Placeholder purge — session cleanup requires DB access.
    Session deletion is not yet implemented in MVP.
    """
    # TODO(CONC3): Wire DB session deletion when Container is available at CLI startup.

The CLI also displays: "Note: Session cleanup is not yet implemented." (cleanup.py line 150).

Running agents cleanup produces a session cleanup section that reports nothing cleaned, with no error — silently skipping the operation.

Expected Behavior

Per docs/specification.md, the agents cleanup command should scan for and purge stale sessions as part of its cleanup lifecycle. Session lifecycle management (create, list, show, delete, export, import) is a core platform feature. The cleanup command must be able to identify and remove sessions that are stale or orphaned.

Acceptance Criteria

  • CleanupService._scan_sessions() queries the database for stale/orphaned sessions and populates the CleanupReport with findings.
  • CleanupService._purge_sessions() deletes the sessions identified by _scan_sessions() from the database.
  • The agents cleanup CLI command no longer displays "Session cleanup is not yet implemented."
  • The agents cleanup command correctly reports the number of sessions scanned and purged.
  • All existing cleanup tests continue to pass; new Behave scenarios cover the session scan and purge paths.

Supporting Information

Code locations:

  • src/cleveragents/application/services/cleanup_service.py lines 304–320
  • src/cleveragents/cli/commands/cleanup.py line 150

Steps to reproduce:

  1. Read src/cleveragents/application/services/cleanup_service.py around lines 304–320
  2. Observe placeholder methods with TODO(CONC3) comments
  3. Run agents cleanup — session cleanup section shows "not yet implemented"

Impact: Session data accumulates indefinitely with no automated cleanup. This is a functional gap in the session lifecycle management described in the specification.

Related issues: #3843 (same TODO, Type/Refactor perspective)

Metadata

  • Branch: feat/cleanup-session-scan-purge
  • Commit Message: feat(cleanup): implement session scan and purge in CleanupService
  • Milestone: (backlog — no milestone assigned)
  • Parent Epic: #365 (Epic: Concurrency & Cleanup — closed; no active replacement epic found)

Subtasks

  • Implement _scan_sessions() — query DB for stale/orphaned sessions and populate CleanupReport
  • Implement _purge_sessions() — delete sessions identified by _scan_sessions() from the DB
  • Remove "Session cleanup is not yet implemented" note from cleanup.py (line 150)
  • Tests (Behave): Add scenarios for session scan (stale sessions found, no sessions found)
  • Tests (Behave): Add scenarios for session purge (sessions deleted, dry-run mode)
  • Tests (Robot): Add integration test for agents cleanup session cleanup path
  • Verify coverage ≥ 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors
  • Close or link related issue #3843

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • _scan_sessions() and _purge_sessions() are fully implemented with DB access wired through the Container.
  • The agents cleanup CLI no longer shows "Session cleanup is not yet implemented."
  • 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

## Background and Context The `CleanupService` in `src/cleveragents/application/services/cleanup_service.py` contains two placeholder methods for session cleanup: `_scan_sessions` (lines 304–310) and `_purge_sessions` (lines 314–320). Both are explicitly documented as "not yet implemented in MVP" and contain only `TODO(CONC3)` comments. The CLI command `agents cleanup` also surfaces a user-visible note that session cleanup is not yet implemented. Per `docs/specification.md`, session lifecycle management is a core feature of the platform. The `agents cleanup` command is expected to clean up stale sessions as part of its operation. This gap means session data accumulates indefinitely with no automated cleanup mechanism. > **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. **Related issue:** #3843 covers the same `TODO(CONC3)` comments from an architecture-guard perspective (`Type/Refactor`). This issue tracks the same gap as a UAT bug with full reproduction steps and impact assessment. ## Current Behavior ```python # src/cleveragents/application/services/cleanup_service.py lines 304-320: def _scan_sessions(self, report: CleanupReport) -> None: """Placeholder scan — session cleanup requires DB access. Session cleanup is not yet implemented in MVP. """ # TODO(CONC3): Wire DB session query when Container is available at CLI startup. def _purge_sessions(self, report: CleanupReport) -> None: """Placeholder purge — session cleanup requires DB access. Session deletion is not yet implemented in MVP. """ # TODO(CONC3): Wire DB session deletion when Container is available at CLI startup. ``` The CLI also displays: `"Note: Session cleanup is not yet implemented."` (`cleanup.py` line 150). Running `agents cleanup` produces a session cleanup section that reports nothing cleaned, with no error — silently skipping the operation. ## Expected Behavior Per `docs/specification.md`, the `agents cleanup` command should scan for and purge stale sessions as part of its cleanup lifecycle. Session lifecycle management (create, list, show, delete, export, import) is a core platform feature. The cleanup command must be able to identify and remove sessions that are stale or orphaned. ## Acceptance Criteria - `CleanupService._scan_sessions()` queries the database for stale/orphaned sessions and populates the `CleanupReport` with findings. - `CleanupService._purge_sessions()` deletes the sessions identified by `_scan_sessions()` from the database. - The `agents cleanup` CLI command no longer displays "Session cleanup is not yet implemented." - The `agents cleanup` command correctly reports the number of sessions scanned and purged. - All existing cleanup tests continue to pass; new Behave scenarios cover the session scan and purge paths. ## Supporting Information **Code locations:** - `src/cleveragents/application/services/cleanup_service.py` lines 304–320 - `src/cleveragents/cli/commands/cleanup.py` line 150 **Steps to reproduce:** 1. Read `src/cleveragents/application/services/cleanup_service.py` around lines 304–320 2. Observe placeholder methods with `TODO(CONC3)` comments 3. Run `agents cleanup` — session cleanup section shows "not yet implemented" **Impact:** Session data accumulates indefinitely with no automated cleanup. This is a functional gap in the session lifecycle management described in the specification. **Related issues:** #3843 (same TODO, `Type/Refactor` perspective) ## Metadata - **Branch**: `feat/cleanup-session-scan-purge` - **Commit Message**: `feat(cleanup): implement session scan and purge in CleanupService` - **Milestone**: *(backlog — no milestone assigned)* - **Parent Epic**: #365 (Epic: Concurrency & Cleanup — closed; no active replacement epic found) ## Subtasks - [ ] Implement `_scan_sessions()` — query DB for stale/orphaned sessions and populate `CleanupReport` - [ ] Implement `_purge_sessions()` — delete sessions identified by `_scan_sessions()` from the DB - [ ] Remove "Session cleanup is not yet implemented" note from `cleanup.py` (line 150) - [ ] Tests (Behave): Add scenarios for session scan (stale sessions found, no sessions found) - [ ] Tests (Behave): Add scenarios for session purge (sessions deleted, dry-run mode) - [ ] Tests (Robot): Add integration test for `agents cleanup` session cleanup path - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors - [ ] Close or link related issue #3843 ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - `_scan_sessions()` and `_purge_sessions()` are fully implemented with DB access wired through the Container. - The `agents cleanup` CLI no longer shows "Session cleanup is not yet implemented." - 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
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
#365 Epic: Concurrency & Cleanup
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3941
No description provided.