UAT: Devcontainer auto-discovery not wired into resource registration flow — discover_devcontainers() is never called #3536

Closed
opened 2026-04-05 19:02:28 +00:00 by freemo · 2 comments
Owner

Metadata

  • Branch: fix/resource-registration-devcontainer-auto-discovery
  • Commit Message: fix(resource): wire discover_devcontainers() into register_resource() for git-checkout and fs-directory types
  • Milestone: (none — backlog)
  • Parent Epic: #398

Backlog note: This issue was discovered during autonomous operation
on milestone v3.6.0. It does not block milestone completion and has been
placed in the backlog for human review and future milestone assignment.

Background and Context

Per docs/specification.md (line 24834):

A git-checkout or fs-directory handler additionally detects .devcontainer/devcontainer.json and creates a devcontainer-instance child in discovered state.

Per ADR-043 §Auto-Discovery:

During filesystem scanning, if a .devcontainer/ directory is found:
a. Look for devcontainer.json inside it (required).
b. If found, create a devcontainer-instance child resource with provisioning_state: discovered.

The discover_devcontainers() function exists in src/cleveragents/resource/handlers/discovery.py and correctly scans for .devcontainer/devcontainer.json files, but it is never called from any application service, CLI command, or resource registration flow. The wiring between the discovery function and the resource registration pipeline is entirely absent.

Current Behavior (Bug)

  • discover_devcontainers() in src/cleveragents/resource/handlers/discovery.py (line 71) is only imported in test files (features/steps/devcontainer_handler_steps.py, robot/helper_devcontainer_handler.py, benchmarks/devcontainer_handler_bench.py) — never in production code.
  • ResourceRepository.auto_discover_children() exists in src/cleveragents/infrastructure/database/repositories.py (line 2556) but is also never called from any application service or CLI command.
  • Registering a git-checkout resource pointing to a directory with .devcontainer/devcontainer.json produces no devcontainer-instance child resource.

Steps to Reproduce

  1. Create a directory with .devcontainer/devcontainer.json
  2. Run agents resource add git-checkout local/test-repo --path <directory>
  3. Run agents resource list --all
  4. Observe: no devcontainer-instance child resource is created

Expected Behavior

After agents resource add git-checkout local/test-repo --path <directory>:

Added resource: local/test-repo (id: ...)
⚠ Devcontainer detected at .devcontainer/devcontainer.json

And agents resource list --all should show a devcontainer-instance child resource in discovered state linked to local/test-repo in the DAG.

Code Locations

File Symbol Line Issue
src/cleveragents/resource/handlers/discovery.py discover_devcontainers() 71 Exists but never called from production code
src/cleveragents/infrastructure/database/repositories.py ResourceRepository.auto_discover_children() 2556 Exists but never called from any service
src/cleveragents/application/services/_resource_registry_ops.py register_resource() 100 Missing call to auto-discovery after registration

Fix Direction

The register_resource() method in _resource_registry_ops.py should:

  1. After successfully registering a git-checkout or fs-directory resource, call discover_devcontainers(resource.path) (or equivalent)
  2. For each discovered devcontainer config, create a devcontainer-instance child resource in discovered state
  3. Call ResourceRepository.auto_discover_children() (or equivalent) to persist the child resource and link it to the parent in the DAG
  4. Emit the ⚠ Devcontainer detected at .devcontainer/devcontainer.json console message per spec

Subtasks

  • Wire discover_devcontainers() call into register_resource() in _resource_registry_ops.py for git-checkout and fs-directory resource types
  • Wire ResourceRepository.auto_discover_children() (or equivalent) to persist discovered devcontainer-instance child resources after registration
  • Emit ⚠ Devcontainer detected at .devcontainer/devcontainer.json console message when a devcontainer is auto-discovered (per spec)
  • Link the devcontainer-instance child to the parent resource in the DAG with correct discovered provisioning state
  • Tests (Behave): Add @tdd_expected_fail scenario reproducing the bug (no child created) before fixing
  • Tests (Behave): Add scenario for git-checkout registration with .devcontainer/devcontainer.json present — assert child devcontainer-instance is created in discovered state
  • Tests (Behave): Add scenario for fs-directory registration with .devcontainer/devcontainer.json present — assert child devcontainer-instance is created in discovered state
  • Tests (Behave): Add scenario for registration of a resource with no .devcontainer/ directory — assert no child is created (no false positives)
  • Tests (Robot): Add integration test for end-to-end agents resource add git-checkoutagents resource list --all showing devcontainer-instance child
  • 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.
  • register_resource() calls discover_devcontainers() for git-checkout and fs-directory resource types and persists any discovered devcontainer-instance children.
  • agents resource add git-checkout local/test-repo --path <dir-with-devcontainer> produces a devcontainer-instance child resource in discovered state, visible in agents resource list --all.
  • 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-registration-devcontainer-auto-discovery` - **Commit Message**: `fix(resource): wire discover_devcontainers() into register_resource() for git-checkout and fs-directory types` - **Milestone**: *(none — backlog)* - **Parent Epic**: #398 > **Backlog note:** This issue was discovered during autonomous operation > on milestone v3.6.0. It does not block milestone completion and has been > placed in the backlog for human review and future milestone assignment. ## Background and Context Per `docs/specification.md` (line 24834): > A `git-checkout` or `fs-directory` handler additionally detects `.devcontainer/devcontainer.json` and creates a `devcontainer-instance` child in `discovered` state. Per ADR-043 §Auto-Discovery: > During filesystem scanning, if a `.devcontainer/` directory is found: > a. Look for `devcontainer.json` inside it (required). > b. If found, create a `devcontainer-instance` child resource with `provisioning_state: discovered`. The `discover_devcontainers()` function exists in `src/cleveragents/resource/handlers/discovery.py` and correctly scans for `.devcontainer/devcontainer.json` files, but it is **never called** from any application service, CLI command, or resource registration flow. The wiring between the discovery function and the resource registration pipeline is entirely absent. ## Current Behavior (Bug) - `discover_devcontainers()` in `src/cleveragents/resource/handlers/discovery.py` (line 71) is only imported in test files (`features/steps/devcontainer_handler_steps.py`, `robot/helper_devcontainer_handler.py`, `benchmarks/devcontainer_handler_bench.py`) — **never in production code**. - `ResourceRepository.auto_discover_children()` exists in `src/cleveragents/infrastructure/database/repositories.py` (line 2556) but is also **never called** from any application service or CLI command. - Registering a `git-checkout` resource pointing to a directory with `.devcontainer/devcontainer.json` produces **no `devcontainer-instance` child resource**. ### Steps to Reproduce 1. Create a directory with `.devcontainer/devcontainer.json` 2. Run `agents resource add git-checkout local/test-repo --path <directory>` 3. Run `agents resource list --all` 4. Observe: no `devcontainer-instance` child resource is created ## Expected Behavior After `agents resource add git-checkout local/test-repo --path <directory>`: ``` Added resource: local/test-repo (id: ...) ⚠ Devcontainer detected at .devcontainer/devcontainer.json ``` And `agents resource list --all` should show a `devcontainer-instance` child resource in `discovered` state linked to `local/test-repo` in the DAG. ## Code Locations | File | Symbol | Line | Issue | |---|---|---|---| | `src/cleveragents/resource/handlers/discovery.py` | `discover_devcontainers()` | 71 | Exists but never called from production code | | `src/cleveragents/infrastructure/database/repositories.py` | `ResourceRepository.auto_discover_children()` | 2556 | Exists but never called from any service | | `src/cleveragents/application/services/_resource_registry_ops.py` | `register_resource()` | 100 | Missing call to auto-discovery after registration | ## Fix Direction The `register_resource()` method in `_resource_registry_ops.py` should: 1. After successfully registering a `git-checkout` or `fs-directory` resource, call `discover_devcontainers(resource.path)` (or equivalent) 2. For each discovered devcontainer config, create a `devcontainer-instance` child resource in `discovered` state 3. Call `ResourceRepository.auto_discover_children()` (or equivalent) to persist the child resource and link it to the parent in the DAG 4. Emit the `⚠ Devcontainer detected at .devcontainer/devcontainer.json` console message per spec ## Subtasks - [ ] Wire `discover_devcontainers()` call into `register_resource()` in `_resource_registry_ops.py` for `git-checkout` and `fs-directory` resource types - [ ] Wire `ResourceRepository.auto_discover_children()` (or equivalent) to persist discovered `devcontainer-instance` child resources after registration - [ ] Emit `⚠ Devcontainer detected at .devcontainer/devcontainer.json` console message when a devcontainer is auto-discovered (per spec) - [ ] Link the `devcontainer-instance` child to the parent resource in the DAG with correct `discovered` provisioning state - [ ] Tests (Behave): Add `@tdd_expected_fail` scenario reproducing the bug (no child created) before fixing - [ ] Tests (Behave): Add scenario for `git-checkout` registration with `.devcontainer/devcontainer.json` present — assert child `devcontainer-instance` is created in `discovered` state - [ ] Tests (Behave): Add scenario for `fs-directory` registration with `.devcontainer/devcontainer.json` present — assert child `devcontainer-instance` is created in `discovered` state - [ ] Tests (Behave): Add scenario for registration of a resource with no `.devcontainer/` directory — assert no child is created (no false positives) - [ ] Tests (Robot): Add integration test for end-to-end `agents resource add git-checkout` → `agents resource list --all` showing `devcontainer-instance` child - [ ] 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. - `register_resource()` calls `discover_devcontainers()` for `git-checkout` and `fs-directory` resource types and persists any discovered `devcontainer-instance` children. - `agents resource add git-checkout local/test-repo --path <dir-with-devcontainer>` produces a `devcontainer-instance` child resource in `discovered` state, visible in `agents resource list --all`. - 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
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High — The discover_devcontainers() function exists but is never called from production code. This means the entire devcontainer auto-discovery pipeline is non-functional. The spec explicitly requires automatic detection.
  • Milestone: v3.6.0 — Devcontainer auto-discovery is in scope for M7.
  • Story Points: 5 — L — Requires wiring the discovery function into the resource registration flow, persisting child resources, emitting console messages, and comprehensive tests across Behave and Robot Framework.
  • MoSCoW: Should Have — The spec mandates auto-discovery for devcontainers, but manual registration via agents resource add works as a fallback. Important for UX but not blocking core functionality.
  • Parent Epic: #398 (Post-MVP Resources)

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

Issue triaged by project owner: - **State**: Verified - **Priority**: High — The `discover_devcontainers()` function exists but is never called from production code. This means the entire devcontainer auto-discovery pipeline is non-functional. The spec explicitly requires automatic detection. - **Milestone**: v3.6.0 — Devcontainer auto-discovery is in scope for M7. - **Story Points**: 5 — L — Requires wiring the discovery function into the resource registration flow, persisting child resources, emitting console messages, and comprehensive tests across Behave and Robot Framework. - **MoSCoW**: Should Have — The spec mandates auto-discovery for devcontainers, but manual registration via `agents resource add` works as a fallback. Important for UX but not blocking core functionality. - **Parent Epic**: #398 (Post-MVP Resources) --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo added this to the v3.6.0 milestone 2026-04-05 19:37:42 +00:00
Author
Owner

Closing as duplicate of #2122.

Both issues describe the same bug: discover_devcontainers() is never called during resource registration/linking, so devcontainer auto-discovery is not wired into the production code path. Issue #2122 is the established tracking issue (v3.7.0 milestone). Please track this work in #2122.


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

Closing as duplicate of #2122. Both issues describe the same bug: `discover_devcontainers()` is never called during resource registration/linking, so devcontainer auto-discovery is not wired into the production code path. Issue #2122 is the established tracking issue (v3.7.0 milestone). Please track this work in #2122. --- **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.

Blocks
#398 Epic: Post-MVP Resources
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#3536
No description provided.