Files
cleveragents-core/features/devcontainer_handler.feature
T
HAL9000 be45020a5c feat(resource): add --clone-into to container-instance and fix devcontainer-instance sandbox strategy
- Adds a --clone-into option to the container-instance command to clone repository contents into a specified path during container setup.
- Fixes the devcontainer-instance sandbox strategy to ensure proper isolation, correct mount permissions, and deterministic behavior across environments.
- Updates related validation and error handling to reflect the new option and sandbox changes.

ISSUES CLOSED: #7555
2026-06-02 02:39:58 -04:00

165 lines
7.9 KiB
Gherkin

Feature: Devcontainer Resource Handler
As a CleverAgents developer
I want devcontainer resources to be auto-discovered and manually registered
So that devcontainer environments integrate into the resource model
# Manual registration
Scenario: Register devcontainer-instance manually
Given a temporary directory with a valid devcontainer.json
When I create a devcontainer-instance resource at that path
Then the resource should have type "devcontainer-instance"
And the resource should have a non-empty resource_id
Scenario: Register container-instance manually
When I create a container-instance resource with image "ubuntu:latest"
Then the container resource should have type "container-instance"
# ── Auto-discovery from git resource ───────────────────────
Scenario: Auto-discover devcontainer from git-checkout resource
Given a temporary directory simulating a git checkout
And the directory has a .devcontainer/devcontainer.json file
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 1 result
And the discovered config path should end with "devcontainer.json"
Scenario: Auto-discover root devcontainer.json from git-checkout
Given a temporary directory simulating a git checkout
And the directory has a root .devcontainer.json file
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 1 result
Scenario: Auto-discover both devcontainer locations
Given a temporary directory simulating a git checkout
And the directory has a .devcontainer/devcontainer.json file
And the directory has a root .devcontainer.json file
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 2 results
# ── Auto-discovery from filesystem resource ─────────────────
Scenario: Auto-discover devcontainer from fs-directory resource
Given a temporary directory simulating a filesystem mount
And the directory has a .devcontainer/devcontainer.json file
When I run devcontainer discovery on the directory as "fs-directory"
Then discovery should return 1 result
Scenario: No discovery for non-trigger resource types
Given a temporary directory simulating a filesystem mount
And the directory has a .devcontainer/devcontainer.json file
When I run devcontainer discovery on the directory as "fs-file"
Then discovery should return 0 results
# ── Invalid devcontainer.json handling ──────────────────────
Scenario: Skip invalid JSON in devcontainer.json
Given a temporary directory with an invalid devcontainer.json
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 0 results
Scenario: Skip non-object JSON in devcontainer.json
Given a temporary directory with a non-object devcontainer.json
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 0 results
Scenario: Handle missing devcontainer directory gracefully
Given a temporary directory with no devcontainer configuration
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 0 results
# ── Resource tree display ──────────────────────────────────
Scenario: Devcontainer types appear in resource type list
Given the built-in resource type registry
When I list all built-in type names
Then the type list should contain "devcontainer-instance"
And the type list should contain "devcontainer-file"
And the type list should contain "container-instance"
# ── Handler protocol conformance ───────────────────────────
Scenario: DevcontainerHandler satisfies ResourceHandler protocol
When I instantiate DevcontainerHandler
Then it should satisfy the ResourceHandler protocol
Scenario: DevcontainerHandler has correct default strategy
When I instantiate DevcontainerHandler
Then its default strategy should be "snapshot"
Scenario: DevcontainerHandler has correct type label
When I instantiate DevcontainerHandler
Then its type label should be "devcontainer"
# ── Discovery result validation ────────────────────────────
Scenario: Discovery result requires valid config_path
When I create a discovery result with valid parameters
Then the result should have a config_path attribute
Scenario: Discovery result rejects empty parent_location
When I create a discovery result with empty parent_location
Then it should raise a ValueError
# ── Named configuration discovery (monorepo support) ──────
Scenario: Auto-discover named devcontainer configuration
Given a temporary directory simulating a git checkout
And the directory has a named devcontainer configuration "api"
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 1 result
And the first result should have config name "api"
Scenario: Auto-discover multiple named devcontainer configurations
Given a temporary directory simulating a git checkout
And the directory has a named devcontainer configuration "api"
And the directory has a named devcontainer configuration "frontend"
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 2 results
And the result config names should include "api"
And the result config names should include "frontend"
Scenario: Auto-discover mixed root and named devcontainer configurations
Given a temporary directory simulating a git checkout
And the directory has a .devcontainer/devcontainer.json file
And the directory has a named devcontainer configuration "api"
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 2 results
Scenario: Root devcontainer.json has no config name
Given a temporary directory simulating a git checkout
And the directory has a .devcontainer/devcontainer.json file
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 1 result
And the first result should have no config name
Scenario: Root .devcontainer.json has no config name
Given a temporary directory simulating a git checkout
And the directory has a root .devcontainer.json file
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 1 result
And the first result should have no config name
Scenario: Named config with invalid JSON is skipped
Given a temporary directory simulating a git checkout
And the directory has a named devcontainer configuration "broken" with invalid JSON
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 0 results
Scenario: Empty .devcontainer directory returns no results
Given a temporary directory simulating a git checkout
And the directory has an empty .devcontainer directory
When I run devcontainer discovery on the directory as "git-checkout"
Then discovery should return 0 results
# ── is_trigger_type checks ────────────────────────────────
Scenario: git-checkout is a trigger type
Then "git-checkout" should be a trigger type
Scenario: fs-directory is a trigger type
Then "fs-directory" should be a trigger type
Scenario: devcontainer-instance is not a trigger type
Then "devcontainer-instance" should not be a trigger type