UAT: agents actor remove Cleanup panel hardcodes 0 orphaned contexts — actual orphaned context count is never computed #3608

Open
opened 2026-04-05 20:22:48 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/actor-remove-orphaned-context-count
  • Commit Message: fix(cli): compute actual orphaned context count in actor remove cleanup panel
  • Milestone: Backlog (see note below)
  • Parent Epic: #392

Background and Context

The specification defines that agents actor remove should display a "Cleanup" panel showing the number of orphaned contexts after actor removal. This count is intended to give the operator visibility into how many stored contexts are now unreachable because their owning actor no longer exists.

Current Behavior

In src/cleveragents/cli/commands/actor.py, the remove() function (~line 770–774) hardcodes the Cleanup panel output:

# Display Cleanup panel
cleanup_info = (
    "[blue]Config:[/blue] kept on disk\n[blue]Contexts:[/blue] 0 orphaned"
)

The value 0 orphaned is always hardcoded regardless of how many actor contexts actually exist for the removed actor. This means the panel is always factually incorrect whenever any contexts are associated with the actor being removed.

Expected Behavior

Per the specification, the Cleanup panel should display the actual number of orphaned contexts:

╭─ Cleanup ──────────────╮
│ Config: kept on disk   │
│ Contexts: 1 orphaned   │
╰────────────────────────╯

The actual count must be computed by querying the context storage for contexts associated with the removed actor name before deletion occurs, so the count reflects what was orphaned by the removal operation.

Code Location

  • File: src/cleveragents/cli/commands/actor.py
  • Function: remove() (~line 770–774)
  • Offending string: hardcoded "0 orphaned"

Acceptance Criteria

  • The remove() function queries context storage to count contexts associated with the actor being removed (query performed before deletion)
  • The Cleanup panel displays the actual orphaned context count rather than the hardcoded 0
  • If context storage is unavailable or raises an exception, the count defaults to 0 with a defensive fallback (no crash)
  • The JSON/YAML structured output (when --format is added per issue #3405) also includes the correct count
  • Existing tests continue to pass
  • New regression test added: scenario where actor has ≥1 associated context verifies the correct count appears in the Cleanup panel

Subtasks

  • Identify the context storage query API used elsewhere in the codebase for looking up contexts by actor name
  • Add a pre-deletion context count query in remove() using the identified API
  • Replace the hardcoded "0 orphaned" string with the dynamically computed count
  • Wrap the context storage query in a try/except with a 0 fallback for resilience
  • Write a BDD regression scenario: actor with existing contexts → remove → Cleanup panel shows correct non-zero count
  • Run nox (all default sessions) and fix any errors
  • Verify coverage ≥ 97% via nox -s coverage_report

Definition of Done

  • All subtasks above are checked off
  • A Git commit is created with the exact subject line: fix(cli): compute actual orphaned context count in actor remove cleanup panel
  • The commit is pushed to branch fix/actor-remove-orphaned-context-count
  • A Pull Request is submitted, reviewed, and merged
  • All nox stages pass
  • Coverage ≥ 97%

Backlog note: This issue was discovered during autonomous operation
on milestone v3.2.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**: `fix/actor-remove-orphaned-context-count` - **Commit Message**: `fix(cli): compute actual orphaned context count in actor remove cleanup panel` - **Milestone**: Backlog (see note below) - **Parent Epic**: #392 ## Background and Context The specification defines that `agents actor remove` should display a "Cleanup" panel showing the number of orphaned contexts after actor removal. This count is intended to give the operator visibility into how many stored contexts are now unreachable because their owning actor no longer exists. ## Current Behavior In `src/cleveragents/cli/commands/actor.py`, the `remove()` function (~line 770–774) hardcodes the Cleanup panel output: ```python # Display Cleanup panel cleanup_info = ( "[blue]Config:[/blue] kept on disk\n[blue]Contexts:[/blue] 0 orphaned" ) ``` The value `0 orphaned` is always hardcoded regardless of how many actor contexts actually exist for the removed actor. This means the panel is always factually incorrect whenever any contexts are associated with the actor being removed. ## Expected Behavior Per the specification, the Cleanup panel should display the **actual** number of orphaned contexts: ``` ╭─ Cleanup ──────────────╮ │ Config: kept on disk │ │ Contexts: 1 orphaned │ ╰────────────────────────╯ ``` The actual count must be computed by querying the context storage for contexts associated with the removed actor name **before** deletion occurs, so the count reflects what was orphaned by the removal operation. ## Code Location - **File**: `src/cleveragents/cli/commands/actor.py` - **Function**: `remove()` (~line 770–774) - **Offending string**: hardcoded `"0 orphaned"` ## Acceptance Criteria - [ ] The `remove()` function queries context storage to count contexts associated with the actor being removed (query performed before deletion) - [ ] The Cleanup panel displays the actual orphaned context count rather than the hardcoded `0` - [ ] If context storage is unavailable or raises an exception, the count defaults to `0` with a defensive fallback (no crash) - [ ] The JSON/YAML structured output (when `--format` is added per issue #3405) also includes the correct count - [ ] Existing tests continue to pass - [ ] New regression test added: scenario where actor has ≥1 associated context verifies the correct count appears in the Cleanup panel ## Subtasks - [ ] Identify the context storage query API used elsewhere in the codebase for looking up contexts by actor name - [ ] Add a pre-deletion context count query in `remove()` using the identified API - [ ] Replace the hardcoded `"0 orphaned"` string with the dynamically computed count - [ ] Wrap the context storage query in a `try/except` with a `0` fallback for resilience - [ ] Write a BDD regression scenario: actor with existing contexts → `remove` → Cleanup panel shows correct non-zero count - [ ] Run `nox` (all default sessions) and fix any errors - [ ] Verify coverage ≥ 97% via `nox -s coverage_report` ## Definition of Done - [ ] All subtasks above are checked off - [ ] A Git commit is created with the exact subject line: `fix(cli): compute actual orphaned context count in actor remove cleanup panel` - [ ] The commit is pushed to branch `fix/actor-remove-orphaned-context-count` - [ ] A Pull Request is submitted, reviewed, and merged - [ ] All nox stages pass - [ ] Coverage ≥ 97% > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.2.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
freemo added this to the v3.7.0 milestone 2026-04-05 20:29:26 +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.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3608
No description provided.