Files
cleveragents-core/features/devcontainer_handler.feature
T
CoreRasurae cf67ba0a86
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 35s
CI / typecheck (pull_request) Successful in 37s
CI / unit_tests (pull_request) Successful in 2m27s
CI / docker (pull_request) Successful in 49s
CI / integration_tests (pull_request) Successful in 3m46s
CI / coverage (pull_request) Successful in 4m56s
CI / lint (push) Successful in 12s
CI / build (push) Successful in 14s
CI / quality (push) Successful in 16s
CI / security (push) Successful in 32s
CI / typecheck (push) Successful in 36s
CI / benchmark-regression (push) Has been skipped
CI / unit_tests (push) Successful in 4m7s
CI / integration_tests (push) Successful in 4m41s
CI / docker (push) Successful in 44s
CI / coverage (push) Successful in 4m56s
CI / benchmark-publish (push) Successful in 17m17s
CI / benchmark-regression (pull_request) Successful in 31m25s
feat(devcontainer): add lazy activation and lifecycle management
Implemented lazy container activation for devcontainer-instance resources
with ContainerLifecycleState enum tracking six states (inactive, starting,
active, stopping, stopped, error) with validated transitions. Extended
DevcontainerHandler with devcontainer up CLI integration and JSON output
parsing for container start. Added periodic health checking via
devcontainer exec ping with configurable interval. Added agents resource
stop and agents resource rebuild CLI commands for manual lifecycle
control. Wired session close and plan completion hooks to automatic
container cleanup. Includes lifecycle state persistence in resource
registry with timestamped transitions. Added Behave BDD tests, Robot
integration tests, and ASV activation latency benchmarks.

- Added remoteWorkspaceFolder absolute-path validation
- Aligned spec: handler name, rebuild types, --yes flag on stop/rebuild
- Added registry re-read in stop_container success path for consistency
- Added session_id field to ContainerLifecycleTracker for scoped cleanup
- Scoped stop_all_active_containers to session_id when provided
- Wired _cleanup_devcontainers into fail_apply and fail_execute
- Wired start_health_check into activate_container success path
- Restructured facade session close to always run container cleanup
  even without session service (F4)
- Re-read tracker from registry in activate_container success path
- Added evict_terminal_trackers to cap registry growth
- Updated devcontainer_resources.md: health check auto-start, scoped
  cleanup hooks, known limitations for eviction and sandbox_strategy
- Wired evict_terminal_trackers into stop_all_active_containers so
  terminal-state trackers are actually evicted in production
- Made stop_container idempotent: returns early when container is
  already in a terminal state instead of raising ValueError
- Fixed benchmark health check thread leak in TimeActivationLatency
  by clearing registry after each timing loop
- Added rebuild pass-through (--reset-container flag to devcontainer up)
- Added host_workspace_path field on ContainerLifecycleTracker so
  health probes use the host-side path for devcontainer exec
- Wired lazy activation into DevcontainerHandler.resolve() for
  devcontainer-instance resources in non-running states
- Changed _default_strategy from SNAPSHOT to NONE (container
  itself provides isolation; SandboxFactory raises NotImplementedError
  for snapshot)
- Restricted _STOPPABLE_TYPES to devcontainer-instance only
  (container-instance is not directly stoppable via CLI)

ISSUES CLOSED: #514
2026-03-10 12:17:51 +00:00

114 lines
5.4 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 "none"
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
# ── 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