Feature: Devcontainer auto-discovery wired into git-checkout and fs-directory handlers
  As a CleverAgents user
  I want devcontainer configurations to be automatically discovered
  When I register a git-checkout or fs-directory resource
  So that devcontainer-instance child resources are created without manual intervention

  Scenario: git-checkout discover_children finds root devcontainer config
    Given dcwire a git repo with a ".devcontainer/devcontainer.json" file
    When dcwire I call discover_children on the git-checkout resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"
    And dcwire the devcontainer child has provisioning_state "discovered"
    And dcwire the devcontainer child has devcontainer_json_path set

  Scenario: git-checkout discover_children finds named devcontainer config
    Given dcwire a git repo with a ".devcontainer/api/devcontainer.json" named config
    When dcwire I call discover_children on the git-checkout resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-api"
    And dcwire the devcontainer child has config_name "api"

  Scenario: git-checkout discover_children with no devcontainer returns only directories
    Given dcwire a git repo with no devcontainer configuration
    When dcwire I call discover_children on the git-checkout resource
    Then dcwire no devcontainer-instance children are present

  Scenario: git-checkout discover_children includes both fs-directory and devcontainer children
    Given dcwire a git repo with a subdirectory "src" and a ".devcontainer/devcontainer.json" file
    When dcwire I call discover_children on the git-checkout resource
    Then dcwire the children include a "fs-directory" resource named "src"
    And dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"

  Scenario: fs-directory discover_children finds root devcontainer config
    Given dcwire a filesystem directory with a ".devcontainer/devcontainer.json" file
    When dcwire I call discover_children on the fs-directory resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"
    And dcwire the devcontainer child has provisioning_state "discovered"

  Scenario: fs-directory discover_children finds named devcontainer config
    Given dcwire a filesystem directory with a ".devcontainer/frontend/devcontainer.json" named config
    When dcwire I call discover_children on the fs-directory resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-frontend"
    And dcwire the devcontainer child has config_name "frontend"

  Scenario: fs-directory discover_children with no devcontainer returns only directories
    Given dcwire a filesystem directory with no devcontainer configuration
    When dcwire I call discover_children on the fs-directory resource
    Then dcwire no devcontainer-instance children are present

  Scenario: fs-directory discover_children includes both fs-directory and devcontainer children
    Given dcwire a filesystem directory with a subdirectory "lib" and a ".devcontainer/devcontainer.json" file
    When dcwire I call discover_children on the fs-directory resource
    Then dcwire the children include a "fs-directory" resource named "lib"
    And dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"

  Scenario: git-checkout discover_children finds root-level .devcontainer.json
    Given dcwire a git repo with a root-level ".devcontainer.json" file
    When dcwire I call discover_children on the git-checkout resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"

  Scenario: fs-directory discover_children finds root-level .devcontainer.json
    Given dcwire a filesystem directory with a root-level ".devcontainer.json" file
    When dcwire I call discover_children on the fs-directory resource
    Then dcwire the children include a "devcontainer-instance" resource named "devcontainer-default"
