@container-handler
Feature: Container infrastructure resource handler module
  Verifies that the container handler module exists and implements all
  five handler classes referenced in _resource_registry_container.py:
  ContainerRuntimeHandler, ContainerImageHandler, ContainerChildHandler,
  ContainerVolumeHandler, ContainerNetworkHandler.

  All handlers must conform to the ResourceHandler protocol and be
  importable from cleveragents.resource.handlers.container.

  # ── Module importability ─────────────────────────────────

  Scenario: Container handler module is importable
    When I import the container handler module
    Then the container handler module import should succeed without errors

  Scenario Outline: Handler class is importable from container module
    When I import "<class_name>" from the container handler module
    Then the class should be importable

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  # ── Protocol conformance ─────────────────────────────────

  Scenario Outline: Handler class conforms to ResourceHandler protocol
    Given a "<class_name>" instance
    Then the instance should satisfy the ResourceHandler protocol

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  # ── Handler resolution via resolver ─────────────────────

  Scenario Outline: Handler resolves via resolve_handler for container types
    When I resolve the handler "<handler_ref>"
    Then the handler should resolve without HandlerResolutionError

    Examples:
      | handler_ref                                                              |
      | cleveragents.resource.handlers.container:ContainerRuntimeHandler         |
      | cleveragents.resource.handlers.container:ContainerImageHandler           |
      | cleveragents.resource.handlers.container:ContainerChildHandler           |
      | cleveragents.resource.handlers.container:ContainerVolumeHandler          |
      | cleveragents.resource.handlers.container:ContainerNetworkHandler         |

  # ── ContainerRuntimeHandler ──────────────────────────────

  Scenario: ContainerRuntimeHandler has correct type label
    Given a "ContainerRuntimeHandler" instance
    Then the handler type_label should be "container-runtime"

  Scenario: ContainerRuntimeHandler resolve raises NotImplementedError
    Given a "ContainerRuntimeHandler" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call resolve on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerRuntimeHandler read raises NotImplementedError
    Given a "ContainerRuntimeHandler" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call read on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerRuntimeHandler content_hash returns EMPTY_CONTENT_HASH for no location
    Given a "ContainerRuntimeHandler" instance
    And a container resource of type "container-runtime" with no location
    When I call content_hash on the container handler
    Then the content_hash result should be the EMPTY_CONTENT_HASH sentinel

  Scenario: ContainerRuntimeHandler content_hash returns identity hash for location
    Given a "ContainerRuntimeHandler" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call content_hash on the container handler
    Then the content_hash result should be a non-empty hex string

  # ── ContainerImageHandler ────────────────────────────────

  Scenario: ContainerImageHandler has correct type label
    Given a "ContainerImageHandler" instance
    Then the handler type_label should be "container-image"

  Scenario: ContainerImageHandler resolve raises NotImplementedError
    Given a "ContainerImageHandler" instance
    And a container resource of type "container-image" with location "ubuntu:22.04"
    When I call resolve on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerImageHandler content_hash returns identity hash for image ref
    Given a "ContainerImageHandler" instance
    And a container resource of type "container-image" with location "ubuntu:22.04"
    When I call content_hash on the container handler
    Then the content_hash result should be a non-empty hex string

  # ── ContainerChildHandler ────────────────────────────────

  Scenario: ContainerChildHandler has correct type label
    Given a "ContainerChildHandler" instance
    Then the handler type_label should be "container-child"

  Scenario: ContainerChildHandler resolve raises NotImplementedError
    Given a "ContainerChildHandler" instance
    And a container resource of type "container-mount" with location "/mnt/data"
    When I call resolve on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerChildHandler read raises NotImplementedError
    Given a "ContainerChildHandler" instance
    And a container resource of type "container-mount" with location "/mnt/data"
    When I call read on the container handler
    Then a container handler NotImplementedError should be raised

  # ── ContainerVolumeHandler ───────────────────────────────

  Scenario: ContainerVolumeHandler has correct type label
    Given a "ContainerVolumeHandler" instance
    Then the handler type_label should be "container-volume"

  Scenario: ContainerVolumeHandler resolve raises NotImplementedError
    Given a "ContainerVolumeHandler" instance
    And a container resource of type "container-volume" with location "my-volume"
    When I call resolve on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerVolumeHandler content_hash returns identity hash for volume name
    Given a "ContainerVolumeHandler" instance
    And a container resource of type "container-volume" with location "my-volume"
    When I call content_hash on the container handler
    Then the content_hash result should be a non-empty hex string

  # ── ContainerNetworkHandler ──────────────────────────────

  Scenario: ContainerNetworkHandler has correct type label
    Given a "ContainerNetworkHandler" instance
    Then the handler type_label should be "container-network"

  Scenario: ContainerNetworkHandler resolve raises NotImplementedError
    Given a "ContainerNetworkHandler" instance
    And a container resource of type "container-network" with location "bridge"
    When I call resolve on the container handler
    Then a container handler NotImplementedError should be raised

  Scenario: ContainerNetworkHandler content_hash returns identity hash for network name
    Given a "ContainerNetworkHandler" instance
    And a container resource of type "container-network" with location "bridge"
    When I call content_hash on the container handler
    Then the content_hash result should be a non-empty hex string

  # ── CRUD stubs ───────────────────────────────────────────

  Scenario Outline: Handler write raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call write on the container handler with data b"test"
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  Scenario Outline: Handler delete raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call delete on the container handler
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  Scenario Outline: Handler list_children raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call list_children on the container handler
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  Scenario Outline: Handler diff raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call diff on the container handler with other_location "/other"
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  Scenario Outline: Handler discover_children raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call discover_children on the container handler
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  # ── Lifecycle stubs ──────────────────────────────────────

  Scenario Outline: Handler create_checkpoint raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call create_checkpoint on the container handler
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  Scenario Outline: Handler rollback_to raises NotImplementedError
    Given a "<class_name>" instance
    And a container resource of type "container-runtime" with location "/var/run/docker.sock"
    When I call rollback_to on the container handler
    Then a container handler NotImplementedError should be raised

    Examples:
      | class_name                |
      | ContainerRuntimeHandler   |
      | ContainerImageHandler     |
      | ContainerChildHandler     |
      | ContainerVolumeHandler    |
      | ContainerNetworkHandler   |

  # ── Registry integration ─────────────────────────────────

  Scenario: container-runtime handler resolves without error after module creation
    When I resolve the handler for resource type "container-runtime"
    Then the handler should resolve without HandlerResolutionError

  Scenario: container-image handler resolves without error after module creation
    When I resolve the handler for resource type "container-image"
    Then the handler should resolve without HandlerResolutionError

  Scenario: container-volume handler resolves without error after module creation
    When I resolve the handler for resource type "container-volume"
    Then the handler should resolve without HandlerResolutionError

  Scenario: container-network handler resolves without error after module creation
    When I resolve the handler for resource type "container-network"
    Then the handler should resolve without HandlerResolutionError
