@phase2 @acms @analyzer @docker_compose_analyzer
Feature: DockerComposeAnalyzer
  As a CleverAgents developer
  I want a Docker Compose analyzer that produces UKO triples from YAML files
  So that the ACMS can index infrastructure definitions into the UKO knowledge graph

  Scenario: Analyze services
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
        api:
          image: node:18
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:DeploymentUnit"
    And the triples should include predicate "rdf:type" with object_uri "uko-infra:Service"
    And the triples should include predicate "uko:contains" linking subject "deployment" to object "web"

  Scenario: Analyze ports
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          ports:
            - "8080:80"
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:Port"
    And the triples should include predicate "uko-infra:exposes"

  Scenario: Analyze environment variables
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        api:
          image: node:18
          environment:
            DATABASE_URL: postgres://localhost/db
            NODE_ENV: production
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:EnvironmentVariable"
    And the triples should include predicate "rdfs:label" with object_value "DATABASE_URL"
    And the triples should include predicate "rdfs:label" with object_value "NODE_ENV"

  Scenario: Analyze depends_on
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          depends_on:
            - api
            - redis
        api:
          image: node:18
        redis:
          image: redis:7
      """
    Then the triples should include predicate "uko-infra:connectsTo"

  Scenario: Analyze depends_on as single string
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          depends_on: db
        db:
          image: postgres
      """
    Then the triples should include predicate "uko-infra:connectsTo"

  Scenario: Analyze depends_on as dict form
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          depends_on:
            db:
              condition: service_healthy
        db:
          image: postgres
      """
    Then the triples should include predicate "uko-infra:connectsTo"

  Scenario: Analyze volumes
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          volumes:
            - ./data:/app/data
      """
    Then the triples should include predicate "uko:contains" linking subject "web" to object "volume"

  Scenario: Analyze environment as list form
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        api:
          image: node:18
          environment:
            - DATABASE_URL=postgres://localhost/db
            - NODE_ENV=production
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:EnvironmentVariable"
    And the triples should include predicate "rdfs:label" with object_value "DATABASE_URL"

  Scenario: Analyze service with null body
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        placeholder:
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:Service"
    And the triples should include predicate "rdfs:label" with object_value "placeholder"

  Scenario: Analyze dict-form port mapping
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          ports:
            - target: 80
              published: 8080
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:Port"
    And the triples should include predicate "rdfs:label" with object_value "8080:80"

  Scenario: Analyze dict-form volume mapping
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          image: nginx
          volumes:
            - type: bind
              source: ./data
              target: /data
      """
    Then the triples should include predicate "rdf:type" with object_uri "uko-infra:ConfigKey"
    And the triples should include predicate "rdfs:label" with object_value "./data:/data"

  Scenario: Analyze empty Docker Compose content raises ValueError
    Given a DockerComposeAnalyzer analyzer
    Then analyzing empty content with this analyzer should raise ValueError

  Scenario: Analyze whitespace-only Docker Compose content raises ValueError
    Given a DockerComposeAnalyzer analyzer
    Then analyzing whitespace-only content with this analyzer should raise ValueError

  Scenario: Analyze Docker Compose with empty resource_uri raises ValueError
    Given a DockerComposeAnalyzer analyzer
    Then analyzing content with empty resource_uri should raise ValueError

  Scenario: Analyze version-only YAML returns empty list
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      version: "3.8"
      """
    Then no triples should be returned

  Scenario: Analyze non-compose YAML returns empty list
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      name: my-application
      settings:
        debug: true
        log_level: info
      """
    Then no triples should be returned

  Scenario: Analyze invalid YAML returns empty list
    Given a DockerComposeAnalyzer analyzer
    When I analyze the Docker Compose content:
      """
      services:
        web:
          ports:
            - this: is: broken: yaml: [
      """
    Then no triples should be returned
