UAT: agents resource remove does not cascade-delete child resources and blocks on DAG edges instead of project links #1935

Closed
opened 2026-04-03 00:17:30 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/resource-remove-cascade-delete-and-project-link-guard
  • Commit Message: fix(cli): correct resource remove to cascade-delete children and block on project links
  • Milestone: v3.5.0
  • Parent Epic: #936

Background and Context

During UAT testing of the agents resource remove command, two critical behavioral defects were identified in src/cleveragents/cli/commands/resource.py. The implementation diverges from the specification in both its deletion logic and its blocking condition, and also fails to render the required rich output panel.

Current Behavior

In src/cleveragents/cli/commands/resource.py, the resource_remove() function (approximately lines 1280–1330):

  1. Does NOT cascade-delete child resources — only deletes the single resource row, leaving all auto-discovered child resources (files, directories, etc.) orphaned in the database.
  2. Blocks on DAG edges (not project links): raises Cannot remove resource: N edge(s) still reference it — this checks ResourceEdgeModel (parent-child relationships), which is incorrect; the spec requires blocking on project links, not edges.
  3. Shows a one-liner: Removed resource: <name> — missing the required "Resource Removed" rich panel.
  4. Does NOT count or report children removed or projects unlinked.

Expected Behavior

Per docs/specification.md (agents resource remove section):

Cascading Deletion: Removes a registered resource and all its auto-discovered child resources. A git-checkout resource can have hundreds of child resources (files, directories). This operation fails if the resource is linked to any project — use agents project unlink-resource first.

The implementation must:

  1. Cascade-delete all auto-discovered child resources when removing a resource.
  2. Block deletion if and only if the resource is linked to any project (not if it has DAG edges).
  3. Render a "Resource Removed" rich panel with Name, Type, Children Removed, and Projects Unlinked fields.
  4. Show ✓ OK Resource removed status message.

Expected rich output:

╭─ Resource Removed ──────────────────────────────────╮
│ Name: local/api-repo                                │
│ Type: git-checkout                                  │
│ Children Removed: 395                               │
│ Projects Unlinked: 0                                │
╰─────────────────────────────────────────────────────╯

✓ OK Resource removed

Spec References

  • docs/specification.md — agents resource remove section
  • "Removes a registered resource and all its auto-discovered child resources"
  • "This operation fails if the resource is linked to any project"

Subtasks

  • Fix blocking condition: replace DAG-edge check with project-link check (query project-resource association table, not ResourceEdgeModel)
  • Implement cascade deletion: query and delete all child resources before deleting the parent resource; count children removed
  • Render "Resource Removed" rich panel with Name, Type, Children Removed, Projects Unlinked
  • Render ✓ OK Resource removed status message
  • Tests (Behave): Add/update BDD scenarios covering cascade deletion, project-link blocking, and output panel rendering
  • Tests (Robot): Add/update integration test for agents resource remove end-to-end behavior
  • 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.
  • The blocking condition correctly prevents removal when the resource is linked to a project, and does not block on DAG edges alone.
  • Cascade deletion removes all auto-discovered child resources and reports the count.
  • The "Resource Removed" rich panel is rendered with all four fields (Name, Type, Children Removed, Projects Unlinked).
  • 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-new-issue-creator

## Metadata - **Branch**: `fix/resource-remove-cascade-delete-and-project-link-guard` - **Commit Message**: `fix(cli): correct resource remove to cascade-delete children and block on project links` - **Milestone**: v3.5.0 - **Parent Epic**: #936 ## Background and Context During UAT testing of the `agents resource remove` command, two critical behavioral defects were identified in `src/cleveragents/cli/commands/resource.py`. The implementation diverges from the specification in both its deletion logic and its blocking condition, and also fails to render the required rich output panel. ## Current Behavior In `src/cleveragents/cli/commands/resource.py`, the `resource_remove()` function (approximately lines 1280–1330): 1. **Does NOT cascade-delete child resources** — only deletes the single resource row, leaving all auto-discovered child resources (files, directories, etc.) orphaned in the database. 2. **Blocks on DAG edges** (not project links): raises `Cannot remove resource: N edge(s) still reference it` — this checks `ResourceEdgeModel` (parent-child relationships), which is incorrect; the spec requires blocking on project links, not edges. 3. **Shows a one-liner**: `Removed resource: <name>` — missing the required "Resource Removed" rich panel. 4. **Does NOT count or report children removed or projects unlinked**. ## Expected Behavior Per `docs/specification.md` (agents resource remove section): > **Cascading Deletion**: Removes a registered resource and all its auto-discovered child resources. A `git-checkout` resource can have hundreds of child resources (files, directories). This operation fails if the resource is linked to any project — use `agents project unlink-resource` first. The implementation must: 1. **Cascade-delete all auto-discovered child resources** when removing a resource. 2. **Block deletion if and only if the resource is linked to any project** (not if it has DAG edges). 3. **Render a "Resource Removed" rich panel** with Name, Type, Children Removed, and Projects Unlinked fields. 4. **Show `✓ OK Resource removed`** status message. Expected rich output: ``` ╭─ Resource Removed ──────────────────────────────────╮ │ Name: local/api-repo │ │ Type: git-checkout │ │ Children Removed: 395 │ │ Projects Unlinked: 0 │ ╰─────────────────────────────────────────────────────╯ ✓ OK Resource removed ``` ## Spec References - `docs/specification.md` — agents resource remove section - "Removes a registered resource and all its auto-discovered child resources" - "This operation fails if the resource is linked to any project" ## Subtasks - [ ] Fix blocking condition: replace DAG-edge check with project-link check (query project-resource association table, not `ResourceEdgeModel`) - [ ] Implement cascade deletion: query and delete all child resources before deleting the parent resource; count children removed - [ ] Render "Resource Removed" rich panel with Name, Type, Children Removed, Projects Unlinked - [ ] Render `✓ OK Resource removed` status message - [ ] Tests (Behave): Add/update BDD scenarios covering cascade deletion, project-link blocking, and output panel rendering - [ ] Tests (Robot): Add/update integration test for `agents resource remove` end-to-end behavior - [ ] 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. - The blocking condition correctly prevents removal when the resource is linked to a project, and does **not** block on DAG edges alone. - Cascade deletion removes all auto-discovered child resources and reports the count. - The "Resource Removed" rich panel is rendered with all four fields (Name, Type, Children Removed, Projects Unlinked). - 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-new-issue-creator
freemo added this to the v3.5.0 milestone 2026-04-03 00:17:54 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Should Have — bug or error handling improvement.

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Should Have — bug or error handling improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

Closing as duplicate of #2447.

Both issues describe the same bug: agents resource remove blocks on DAG edges instead of cascade-deleting auto-discovered children as the spec requires. Issue #2447 is the established tracking issue (Priority/Critical, State/Verified). Please track this work in #2447.


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

Closing as duplicate of #2447. Both issues describe the same bug: `agents resource remove` blocks on DAG edges instead of cascade-deleting auto-discovered children as the spec requires. Issue #2447 is the established tracking issue (`Priority/Critical`, `State/Verified`). Please track this work in #2447. --- **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.

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