@m7 @resource_type @lsp
Feature: LSP Resource Types
  As a developer using language tooling
  I want LSP-related resource types registered in the resource DAG
  So that actors can discover and use language servers

  # ── YAML loading ─────────────────────────────────────────────

  Scenario Outline: LSP type <type_name> loads from YAML for lsp_rt
    Given the built-in <type_name> YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt schema should be valid
    And the lsp_rt schema name should be "<type_name>"
    And the lsp_rt schema resource_kind should be "physical"
    And the lsp_rt schema sandbox_strategy should be "none"

    Examples:
      | type_name     |
      | executable    |
      | lsp-server    |
      | lsp-workspace |
      | lsp-document  |

  # ── User-addable flags ────────────────────────────────────────

  Scenario: executable is user-addable for lsp_rt
    Given the built-in executable YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt schema user_addable should be true

  Scenario: lsp-server is user-addable for lsp_rt
    Given the built-in lsp-server YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt schema user_addable should be true

  Scenario: lsp-workspace is not user-addable for lsp_rt
    Given the built-in lsp-workspace YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt schema user_addable should be false

  Scenario: lsp-document is not user-addable for lsp_rt
    Given the built-in lsp-document YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt schema user_addable should be false

  # ── Capabilities ──────────────────────────────────────────────

  Scenario: lsp-document has write capability for lsp_rt
    Given the built-in lsp-document YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt capability read should be true
    And the lsp_rt capability write should be true

  Scenario: executable has read-only capabilities for lsp_rt
    Given the built-in executable YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt capability read should be true
    And the lsp_rt capability write should be false

  # ── Parent/child hierarchy ────────────────────────────────────

  Scenario: lsp-server has lsp-workspace as child type for lsp_rt
    Given the built-in lsp-server YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt child_types should contain "lsp-workspace"

  Scenario: lsp-workspace has lsp-document as child type for lsp_rt
    Given the built-in lsp-workspace YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt child_types should contain "lsp-document"

  Scenario: lsp-workspace has lsp-server as parent type for lsp_rt
    Given the built-in lsp-workspace YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt parent_types should contain "lsp-server"

  Scenario: lsp-document has lsp-workspace as parent type for lsp_rt
    Given the built-in lsp-document YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt parent_types should contain "lsp-workspace"

  # ── Auto-discovery ────────────────────────────────────────────

  Scenario: executable has auto-discovery from container-exec-env for lsp_rt
    Given the built-in executable YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt auto_discovery should be present
    And the lsp_rt auto_discovery trigger_types should contain "container-exec-env"

  Scenario: lsp-workspace has auto-discovery from lsp-server for lsp_rt
    Given the built-in lsp-workspace YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt auto_discovery should be present
    And the lsp_rt auto_discovery trigger_types should contain "lsp-server"

  # ── BUILTIN_NAMES ─────────────────────────────────────────────

  Scenario: BUILTIN_NAMES includes all LSP types for lsp_rt
    Given the ResourceTypeSpec BUILTIN_NAMES set for lsp_rt
    Then BUILTIN_NAMES should contain "executable" for lsp_rt
    And BUILTIN_NAMES should contain "lsp-server" for lsp_rt
    And BUILTIN_NAMES should contain "lsp-workspace" for lsp_rt
    And BUILTIN_NAMES should contain "lsp-document" for lsp_rt

  # ── Bootstrap DB roundtrip ────────────────────────────────────

  Scenario: LSP types survive DB roundtrip after bootstrap for lsp_rt
    Given a lsp_rt fresh in-memory resource registry with bootstrap
    When I query the lsp_rt registry for type "executable"
    Then the lsp_rt db type "executable" should exist
    And the lsp_rt db type "executable" should have kind "physical"
    When I query the lsp_rt registry for type "lsp-server"
    Then the lsp_rt db type "lsp-server" should exist
    When I query the lsp_rt registry for type "lsp-workspace"
    Then the lsp_rt db type "lsp-workspace" should exist
    When I query the lsp_rt registry for type "lsp-document"
    Then the lsp_rt db type "lsp-document" should exist

  # ── Auto-discovery: lsp-document ──────────────────────────────

  Scenario: lsp-document has auto-discovery from lsp-workspace for lsp_rt
    Given the built-in lsp-document YAML file for lsp_rt
    When I load the YAML via schema for lsp_rt
    Then the lsp_rt auto_discovery should be present
    And the lsp_rt auto_discovery trigger_types should contain "lsp-workspace"

  # ── Negative tests ────────────────────────────────────────────

  Scenario: lsp-workspace rejects manual registration for lsp_rt
    Given a lsp_rt fresh in-memory resource registry with bootstrap
    When I attempt to manually register "lsp-workspace" for lsp_rt
    Then the lsp_rt manual registration should be rejected

  Scenario: lsp-document rejects manual registration for lsp_rt
    Given a lsp_rt fresh in-memory resource registry with bootstrap
    When I attempt to manually register "lsp-document" for lsp_rt
    Then the lsp_rt manual registration should be rejected
