UAT: agents resource stop rejects container-instance resources — spec requires both container-instance and devcontainer-instance to be stoppable #2588

Closed
opened 2026-04-03 19:02:44 +00:00 by freemo · 4 comments
Owner

Bug Report

What Was Tested

The agents resource stop CLI command and its underlying _STOPPABLE_TYPES guard in src/cleveragents/cli/commands/resource.py.

Expected Behavior (from spec)

The specification (line 12018) states:

Stop an active devcontainer-instance or container-instance resource. Transitions the container through running → stopping → stopped. Only container-typed resources may be stopped; attempting to stop other resource types produces an error.

Both container-instance and devcontainer-instance resources should be stoppable via agents resource stop.

Actual Behavior

In src/cleveragents/cli/commands/resource.py (lines 1221–1224):

# F19 fix: restricted to devcontainer-instance only — container-instance
# has no lifecycle tracker wiring, so stop/rebuild would fail at runtime.
_STOPPABLE_TYPES = frozenset({"devcontainer-instance"})

When a user attempts to stop a container-instance resource, the command rejects it with:

Resource 'local/my-container' is type 'container-instance', not a stoppable container type.

The docstring of resource_stop() even acknowledges the spec requirement ("Only devcontainer-instance and container-instance resources may be stopped") but the implementation contradicts it.

Code Location

  • File: src/cleveragents/cli/commands/resource.py
  • Lines: 1221–1224 (_STOPPABLE_TYPES definition)
  • Lines: 1261–1265 (type guard in resource_stop())

Root Cause

The comment "F19 fix: restricted to devcontainer-instance only — container-instance has no lifecycle tracker wiring" indicates this was intentionally restricted as a workaround. However, the spec clearly requires container-instance to be stoppable. The lifecycle tracker wiring for container-instance needs to be implemented rather than the spec requirement being silently dropped.

Steps to Reproduce

  1. Add a container-instance resource: agents resource add container-instance local/my-ctr --image ubuntu:latest
  2. Attempt to stop it: agents resource stop local/my-ctr
  3. Observe error: resource type not in stoppable types

Severity

High — This is a spec-required feature that is completely missing for container-instance resources. Users cannot stop generic container resources via the CLI.

Subtasks

  • Add container-instance to _STOPPABLE_TYPES in resource.py
  • Wire lifecycle tracker support for container-instance resources (or use docker stop directly with the container ID from properties)
  • Add unit tests for stopping container-instance resources
  • Add integration tests verifying both types can be stopped

Definition of Done

  • agents resource stop accepts both container-instance and devcontainer-instance resources
  • Stopping a container-instance transitions it through running → stopping → stopped
  • Attempting to stop a non-container resource type still produces an error
  • Tests pass at unit and integration levels

Metadata

Commit message: fix(cli): allow container-instance resources to be stopped via agents resource stop
Branch: fix/container-instance-stop

Parent Epic: #825 (ResourceHandler Protocol Completion)


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

## Bug Report ### What Was Tested The `agents resource stop` CLI command and its underlying `_STOPPABLE_TYPES` guard in `src/cleveragents/cli/commands/resource.py`. ### Expected Behavior (from spec) The specification (line 12018) states: > Stop an active `devcontainer-instance` **or `container-instance`** resource. Transitions the container through `running → stopping → stopped`. Only container-typed resources may be stopped; attempting to stop other resource types produces an error. Both `container-instance` and `devcontainer-instance` resources should be stoppable via `agents resource stop`. ### Actual Behavior In `src/cleveragents/cli/commands/resource.py` (lines 1221–1224): ```python # F19 fix: restricted to devcontainer-instance only — container-instance # has no lifecycle tracker wiring, so stop/rebuild would fail at runtime. _STOPPABLE_TYPES = frozenset({"devcontainer-instance"}) ``` When a user attempts to stop a `container-instance` resource, the command rejects it with: ``` Resource 'local/my-container' is type 'container-instance', not a stoppable container type. ``` The docstring of `resource_stop()` even acknowledges the spec requirement ("Only devcontainer-instance and container-instance resources may be stopped") but the implementation contradicts it. ### Code Location - **File**: `src/cleveragents/cli/commands/resource.py` - **Lines**: 1221–1224 (`_STOPPABLE_TYPES` definition) - **Lines**: 1261–1265 (type guard in `resource_stop()`) ### Root Cause The comment "F19 fix: restricted to devcontainer-instance only — container-instance has no lifecycle tracker wiring" indicates this was intentionally restricted as a workaround. However, the spec clearly requires `container-instance` to be stoppable. The lifecycle tracker wiring for `container-instance` needs to be implemented rather than the spec requirement being silently dropped. ### Steps to Reproduce 1. Add a `container-instance` resource: `agents resource add container-instance local/my-ctr --image ubuntu:latest` 2. Attempt to stop it: `agents resource stop local/my-ctr` 3. Observe error: resource type not in stoppable types ### Severity **High** — This is a spec-required feature that is completely missing for `container-instance` resources. Users cannot stop generic container resources via the CLI. ### Subtasks - [ ] Add `container-instance` to `_STOPPABLE_TYPES` in `resource.py` - [ ] Wire lifecycle tracker support for `container-instance` resources (or use `docker stop` directly with the container ID from properties) - [ ] Add unit tests for stopping `container-instance` resources - [ ] Add integration tests verifying both types can be stopped ### Definition of Done - `agents resource stop` accepts both `container-instance` and `devcontainer-instance` resources - Stopping a `container-instance` transitions it through `running → stopping → stopped` - Attempting to stop a non-container resource type still produces an error - Tests pass at unit and integration levels ### Metadata **Commit message**: `fix(cli): allow container-instance resources to be stopped via agents resource stop` **Branch**: `fix/container-instance-stop` **Parent Epic**: #825 (ResourceHandler Protocol Completion) --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: Should Have

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

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: Should Have --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.6.0 milestone 2026-04-05 04:53:17 +00:00
Author
Owner

Transition plan for issue #2588 to State/In Progress:

  • Current labels: State/Verified, MoSCoW/Should have, Priority/High, Type/Bug
  • Preconditions: No Blocked label present, so preconditions are satisfied for a standard state transition.
  • Actions to perform (what would be done if label APIs were available):
    • Remove old state label: State/Verified (ALWAYS remove ALL existing State/* labels before adding the new one).
    • Add new state label: State/In Progress
  • Status in this environment: I could not apply label changes programmatically because the Forgejo API wrapper available here does not expose add/remove label endpoints. Please apply the label changes via the Forgejo UI or provide an API-capable endpoint so I can perform the update automatically.
  • Notes: There are no blocker-related preconditions to verify for this transition since Blocked is not present.

If you’d like, I can post a follow-up with the exact UI steps to perform the label changes, and then confirm once the labels reflect the new state.


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

Transition plan for issue #2588 to State/In Progress: - Current labels: State/Verified, MoSCoW/Should have, Priority/High, Type/Bug - Preconditions: No Blocked label present, so preconditions are satisfied for a standard state transition. - Actions to perform (what would be done if label APIs were available): - Remove old state label: State/Verified (ALWAYS remove ALL existing State/* labels before adding the new one). - Add new state label: State/In Progress - Status in this environment: I could not apply label changes programmatically because the Forgejo API wrapper available here does not expose add/remove label endpoints. Please apply the label changes via the Forgejo UI or provide an API-capable endpoint so I can perform the update automatically. - Notes: There are no blocker-related preconditions to verify for this transition since Blocked is not present. If you’d like, I can post a follow-up with the exact UI steps to perform the label changes, and then confirm once the labels reflect the new state. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-state-updater
Author
Owner

PR #3250 created on branch fix/container-instance-stop. PR review and merge handled by continuous review stream.

Implementation summary:

  • Added container-instance to _STOPPABLE_TYPES in resource.py — the stop_container() function already uses docker stop <container_id> generically, so no lifecycle layer changes were needed
  • Updated the F19 regression test in devcontainer_cleanup.feature to expect success (not rejection) for container-instance stop
  • Added tdd_container_instance_stop_2588.feature + step definitions as a dedicated regression guard

All 3 unit tests pass. Quality gates (ruff lint + format) pass.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

PR #3250 created on branch `fix/container-instance-stop`. PR review and merge handled by continuous review stream. **Implementation summary:** - Added `container-instance` to `_STOPPABLE_TYPES` in `resource.py` — the `stop_container()` function already uses `docker stop <container_id>` generically, so no lifecycle layer changes were needed - Updated the F19 regression test in `devcontainer_cleanup.feature` to expect success (not rejection) for `container-instance` stop - Added `tdd_container_instance_stop_2588.feature` + step definitions as a dedicated regression guard All 3 unit tests pass. Quality gates (ruff lint + format) pass. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

PR #3250 reviewed, approved, and merge scheduled (will merge automatically when all CI checks pass).

The fix correctly adds container-instance to _STOPPABLE_TYPES, aligning the implementation with the specification. All core CI checks (lint, typecheck, security, quality, unit_tests, integration_tests, e2e_tests) are passing. Coverage and status-check consolidation are still pending.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer

PR #3250 reviewed, approved, and merge scheduled (will merge automatically when all CI checks pass). The fix correctly adds `container-instance` to `_STOPPABLE_TYPES`, aligning the implementation with the specification. All core CI checks (lint, typecheck, security, quality, unit_tests, integration_tests, e2e_tests) are passing. Coverage and status-check consolidation are still pending. --- **Automated by CleverAgents Bot** Supervisor: PR Review | Agent: ca-pr-self-reviewer
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#2588
No description provided.