UAT: agents resource remove does not cascade-remove children and lacks --format flag #6337

Open
opened 2026-04-09 20:11:40 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Spec Reference

docs/specification.md lines 11000–11031 — the resource remove JSON output includes:

{
  "data": {
    "name": "local/api-repo",
    "type": "git-checkout",
    "children_removed": 395,
    "projects_unlinked": 0
  }
}

The children_removed: 395 field implies that when a resource is removed, its auto-discovered children are also removed (cascaded). This matches the spec description at lines 24932–24970 where auto-discovered children are owned by their parent resource.

Code Location

/app/src/cleveragents/cli/commands/resource.pyresource_remove(), lines 1345–1428.

The implementation:

  1. No --format flag — the command has no --format/-f option, so JSON/YAML output is entirely missing (separate but related to #6333).
  2. No child cascade — the delete logic (lines 1400–1407) only deletes the single ResourceModel row:
row = (
    session.query(ResourceModel)
    .filter_by(resource_id=res.resource_id)
    .first()
)
if row is not None:
    session.delete(row)
    session.commit()

There is no code to find and delete auto-discovered children, or to unlink the resource from projects.

Steps to Reproduce

# Add a git-checkout resource (auto-discovery would normally create children)
agents resource add git-checkout local/my-repo --path /some/repo

# Manually link a child to simulate auto-discovered children
agents resource add fs-directory local/my-dir --path /some/repo/src
agents resource link-child local/my-repo local/my-dir  # note: uses resource_links table

# Remove the parent
agents resource remove local/my-repo --yes

# Check: child still exists
agents resource show local/my-dir  # still shows up — not removed

Expected (per spec)

When a resource is removed:

  1. All auto-discovered children (those with auto_discovered=True flag) should be recursively removed.
  2. All project-resource links should be unlinked.
  3. Output should include children_removed count and projects_unlinked count.
  4. A --format json flag should be available to get structured output.

Actual

  • The parent resource is deleted.
  • Auto-discovered children remain as orphaned records in the resources table.
  • Project links are not cleaned up (would rely only on FK cascade, which is not guaranteed to exist for project-resource links).
  • No --format flag is available.

Note

This bug is distinct from #6329 (wrong edge table). Even after fixing the edge-table bug, the cascade-removal logic is entirely absent. Both bugs need separate fixes.


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

## Bug Report ### Spec Reference `docs/specification.md` lines 11000–11031 — the `resource remove` JSON output includes: ```json { "data": { "name": "local/api-repo", "type": "git-checkout", "children_removed": 395, "projects_unlinked": 0 } } ``` The `children_removed: 395` field implies that when a resource is removed, its auto-discovered children are also removed (cascaded). This matches the spec description at lines 24932–24970 where auto-discovered children are owned by their parent resource. ### Code Location `/app/src/cleveragents/cli/commands/resource.py` — `resource_remove()`, lines 1345–1428. The implementation: 1. **No `--format` flag** — the command has no `--format/-f` option, so JSON/YAML output is entirely missing (separate but related to #6333). 2. **No child cascade** — the delete logic (lines 1400–1407) only deletes the single `ResourceModel` row: ```python row = ( session.query(ResourceModel) .filter_by(resource_id=res.resource_id) .first() ) if row is not None: session.delete(row) session.commit() ``` There is no code to find and delete auto-discovered children, or to unlink the resource from projects. ### Steps to Reproduce ```bash # Add a git-checkout resource (auto-discovery would normally create children) agents resource add git-checkout local/my-repo --path /some/repo # Manually link a child to simulate auto-discovered children agents resource add fs-directory local/my-dir --path /some/repo/src agents resource link-child local/my-repo local/my-dir # note: uses resource_links table # Remove the parent agents resource remove local/my-repo --yes # Check: child still exists agents resource show local/my-dir # still shows up — not removed ``` ### Expected (per spec) When a resource is removed: 1. All auto-discovered children (those with `auto_discovered=True` flag) should be recursively removed. 2. All project-resource links should be unlinked. 3. Output should include `children_removed` count and `projects_unlinked` count. 4. A `--format json` flag should be available to get structured output. ### Actual - The parent resource is deleted. - Auto-discovered children remain as orphaned records in the `resources` table. - Project links are not cleaned up (would rely only on FK cascade, which is not guaranteed to exist for project-resource links). - No `--format` flag is available. ### Note This bug is distinct from #6329 (wrong edge table). Even after fixing the edge-table bug, the cascade-removal logic is entirely absent. Both bugs need separate fixes. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
Author
Owner

Automated transition report for issue #6337

Two-step transition completed via Forgejo Label Manager:

  1. From State/Unverified to State/Verified
  • Removed: State/Unverified
  • Added: State/Verified
  • Precondition: None
  1. From State/Verified to State/In Progress
  • Removed: State/Verified
  • Added: State/In Progress
  • Precondition: None

PR state synchronization:

  • No associated PRs referencing issue #6337 were found. No PRs updated.

Compliance notes (non-blocking warnings):

  • Milestone missing: assign a milestone to satisfy triage requirements.
  • Points/ label missing: add a Points/ label to reflect estimated effort.
  • Assignee missing: assign yourself to this issue.

Current issue state:

  • State/In Progress
  • Labels: State/In Progress, Priority/High, Type/Bug

Next steps:

  • Consider assigning milestone and Points/ label to satisfy CONTRIBUTING.md requirements.

Automated by CleverAgents Bot
Supervisor: Implementation | Agent: issue-state-updater

Automated transition report for issue #6337 Two-step transition completed via Forgejo Label Manager: 1) From State/Unverified to State/Verified - Removed: State/Unverified - Added: State/Verified - Precondition: None 2) From State/Verified to State/In Progress - Removed: State/Verified - Added: State/In Progress - Precondition: None PR state synchronization: - No associated PRs referencing issue #6337 were found. No PRs updated. Compliance notes (non-blocking warnings): - Milestone missing: assign a milestone to satisfy triage requirements. - Points/ label missing: add a Points/ label to reflect estimated effort. - Assignee missing: assign yourself to this issue. Current issue state: - State/In Progress - Labels: State/In Progress, Priority/High, Type/Bug Next steps: - Consider assigning milestone and Points/ label to satisfy CONTRIBUTING.md requirements. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: issue-state-updater
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#6337
No description provided.