UAT: Devcontainer lifecycle state not persisted to database — state lost on process restart (F20) #4912

Open
opened 2026-04-08 20:19:03 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: Devcontainer Integration — Lifecycle State Persistence
ADR Reference: ADR-043 §devcontainer-instance Properties (provisioning_state)
Severity: Medium (state loss on restart; CLI stop/rebuild commands non-functional across process boundaries)


What Was Tested

ADR-043 defines provisioning_state as a property of devcontainer-instance resources. This implies it should be persisted as part of the resource model so it survives process restarts.

Expected Behavior (from ADR-043)

| provisioning_state | enum | discovered | building | active | stopped | failed |

The provisioning_state should be stored on the resource model and persisted to the database, so that:

  1. After a process restart, agents resource show local/my-devcontainer shows the correct state.
  2. agents resource stop local/my-devcontainer in a new process can find and stop the container.
  3. agents resource rebuild local/my-devcontainer in a new process can find and rebuild the container.

Actual Behavior

Lifecycle state is tracked in an in-memory dictionary (_lifecycle_registry in _devcontainer_internals.py):

# src/cleveragents/resource/handlers/_devcontainer_internals.py:44
_lifecycle_registry: dict[str, ContainerLifecycleTracker] = {}

This state is not persisted to the database. The ContainerLifecycleTracker model is never written to any database table.

This is documented in docs/reference/devcontainer_resources.md:

In-memory lifecycle state (F20): Lifecycle state is tracked in an in-memory registry (_lifecycle_registry dict), not persisted on the resource model or database. State is lost on process restart. CLI stop/rebuild in a new process cannot see trackers from a previous process.

Code Locations

  • In-memory registry: src/cleveragents/resource/handlers/_devcontainer_internals.py:44
  • ContainerLifecycleTracker model: src/cleveragents/domain/models/core/container_lifecycle.py:124
  • Known limitation: docs/reference/devcontainer_resources.md:249

Impact

  1. State loss on restart: After agents process exits, all container lifecycle state is lost. Running containers appear as detected (not built) in a new process.
  2. CLI commands broken across processes: agents resource stop local/my-devcontainer in a new process cannot find the container ID (stored only in the in-memory tracker) and cannot stop it.
  3. agents resource rebuild in a new process cannot find the workspace folder from the tracker and fails.
  4. Monitoring: agents resource list cannot show accurate lifecycle states after restart.
  5. ADR-043 compliance: The provisioning_state property is not queryable via the resource API because it's not stored on the resource model.

Fix Required

Persist provisioning_state (and container_id, workspace_path) on the Resource model's properties field:

  1. When ContainerLifecycleTracker state changes, update the resource's properties["activation_state"] in the database.
  2. On DevcontainerHandler.resolve(), hydrate the tracker from resource.properties["activation_state"] if the in-memory registry is empty.
  3. Store container_id and workspace_path in resource.properties so they survive restarts.

This is planned for M7+ per the documentation.


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

## Bug Report **Feature Area:** Devcontainer Integration — Lifecycle State Persistence **ADR Reference:** ADR-043 §`devcontainer-instance` Properties (`provisioning_state`) **Severity:** Medium (state loss on restart; CLI stop/rebuild commands non-functional across process boundaries) --- ## What Was Tested ADR-043 defines `provisioning_state` as a property of `devcontainer-instance` resources. This implies it should be persisted as part of the resource model so it survives process restarts. ## Expected Behavior (from ADR-043) > | `provisioning_state` | enum | `discovered` \| `building` \| `active` \| `stopped` \| `failed` | The `provisioning_state` should be stored on the resource model and persisted to the database, so that: 1. After a process restart, `agents resource show local/my-devcontainer` shows the correct state. 2. `agents resource stop local/my-devcontainer` in a new process can find and stop the container. 3. `agents resource rebuild local/my-devcontainer` in a new process can find and rebuild the container. ## Actual Behavior Lifecycle state is tracked in an **in-memory dictionary** (`_lifecycle_registry` in `_devcontainer_internals.py`): ```python # src/cleveragents/resource/handlers/_devcontainer_internals.py:44 _lifecycle_registry: dict[str, ContainerLifecycleTracker] = {} ``` This state is **not persisted** to the database. The `ContainerLifecycleTracker` model is never written to any database table. This is documented in `docs/reference/devcontainer_resources.md`: > **In-memory lifecycle state (F20):** Lifecycle state is tracked in an in-memory registry (`_lifecycle_registry` dict), **not** persisted on the resource model or database. State is lost on process restart. CLI `stop`/`rebuild` in a new process cannot see trackers from a previous process. ## Code Locations - In-memory registry: `src/cleveragents/resource/handlers/_devcontainer_internals.py:44` - ContainerLifecycleTracker model: `src/cleveragents/domain/models/core/container_lifecycle.py:124` - Known limitation: `docs/reference/devcontainer_resources.md:249` ## Impact 1. **State loss on restart**: After `agents` process exits, all container lifecycle state is lost. Running containers appear as `detected (not built)` in a new process. 2. **CLI commands broken across processes**: `agents resource stop local/my-devcontainer` in a new process cannot find the container ID (stored only in the in-memory tracker) and cannot stop it. 3. **`agents resource rebuild`** in a new process cannot find the workspace folder from the tracker and fails. 4. **Monitoring**: `agents resource list` cannot show accurate lifecycle states after restart. 5. **ADR-043 compliance**: The `provisioning_state` property is not queryable via the resource API because it's not stored on the resource model. ## Fix Required Persist `provisioning_state` (and `container_id`, `workspace_path`) on the `Resource` model's `properties` field: 1. When `ContainerLifecycleTracker` state changes, update the resource's `properties["activation_state"]` in the database. 2. On `DevcontainerHandler.resolve()`, hydrate the tracker from `resource.properties["activation_state"]` if the in-memory registry is empty. 3. Store `container_id` and `workspace_path` in `resource.properties` so they survive restarts. This is planned for M7+ per the documentation. --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.5.0 milestone 2026-04-08 23:00:11 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Medium — devcontainer lifecycle state is lost on process restart; CLI stop/rebuild commands non-functional across process boundaries
  • Milestone: v3.5.0 — Autonomy Hardening milestone; devcontainer persistence is part of the ADR-043 compliance work scoped to M6+
  • Story Points: 5 — L — requires persisting provisioning_state, container_id, workspace_path to DB and hydrating on startup; moderate complexity
  • MoSCoW: Should Have — ADR-043 compliance; documented as planned for M7+ but important for production use; not blocking core devcontainer functionality
  • Parent Epic: Devcontainer Integration epic (v3.5.0)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: Medium — devcontainer lifecycle state is lost on process restart; CLI stop/rebuild commands non-functional across process boundaries - **Milestone**: v3.5.0 — Autonomy Hardening milestone; devcontainer persistence is part of the ADR-043 compliance work scoped to M6+ - **Story Points**: 5 — L — requires persisting `provisioning_state`, `container_id`, `workspace_path` to DB and hydrating on startup; moderate complexity - **MoSCoW**: Should Have — ADR-043 compliance; documented as planned for M7+ but important for production use; not blocking core devcontainer functionality - **Parent Epic**: Devcontainer Integration epic (v3.5.0) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner
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#4912
No description provided.