Feature: Virtual Core Resource Types
  As a CleverAgents developer
  I want built-in virtual resource type YAMLs (file, directory, commit, branch, tag, tree)
  So that cross-layer and cross-repo identity linking is available out of the box

  # ── YAML schema validation ────────────────────────────────

  Scenario Outline: Virtual core YAML validates against schema for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema should be valid
    And the vcore schema name should be "<type_name>"

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Resource kind is virtual ──────────────────────────────

  Scenario Outline: Virtual core types have resource_kind virtual for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema resource_kind should be "virtual"

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Sandbox strategy is none ──────────────────────────────

  Scenario Outline: Virtual core types have sandbox_strategy none for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema sandbox_strategy should be "none"

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Not user-addable ──────────────────────────────────────

  Scenario Outline: Virtual core types are not user-addable for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema user_addable should be false

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Built-in and unnamespaced ─────────────────────────────

  Scenario Outline: Virtual core types are built-in and unnamespaced for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema built_in should be true
    And the vcore schema name should not contain "/"

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── All capabilities disabled ─────────────────────────────

  Scenario Outline: Virtual core types have all capabilities disabled for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore capabilities should have read false
    And the vcore capabilities should have write false
    And the vcore capabilities should have sandbox false
    And the vcore capabilities should have checkpoint false

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── No CLI args ───────────────────────────────────────────

  Scenario Outline: Virtual core types have no cli_args for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema should have 0 cli_args

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── No parent types (top-level virtual) ───────────────────

  Scenario Outline: Virtual core types have no parent types for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema should have empty parent_types

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Child types per spec ──────────────────────────────────

  Scenario: file virtual type has correct child types for vcore
    Given the built-in file virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "fs-file"
    And the vcore schema child_types should contain "git-tree-entry"
    And the vcore schema child_types should have exactly 2 entries

  Scenario: directory virtual type has correct child types for vcore
    Given the built-in directory virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "fs-directory"
    And the vcore schema child_types should contain "git-tree"
    And the vcore schema child_types should have exactly 2 entries

  Scenario: commit virtual type has correct child types for vcore
    Given the built-in commit virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "git-commit"
    And the vcore schema child_types should have exactly 1 entries

  Scenario: branch virtual type has correct child types for vcore
    Given the built-in branch virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "git-branch"
    And the vcore schema child_types should have exactly 1 entries

  Scenario: tag virtual type has correct child types for vcore
    Given the built-in tag virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "git-tag"
    And the vcore schema child_types should have exactly 1 entries

  Scenario: tree virtual type has correct child types for vcore
    Given the built-in tree virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema child_types should contain "git-tree"
    And the vcore schema child_types should have exactly 1 entries

  # ── Equivalence metadata present ──────────────────────────

  Scenario: file virtual type has equivalence with content_hash for vcore
    Given the built-in file virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria should contain "content_hash"
    And the vcore equivalence criteria should contain "filename"
    And the vcore equivalence criteria should contain "permissions"
    And the vcore equivalence criteria count should be 3

  Scenario: directory virtual type has equivalence with merkle_hash for vcore
    Given the built-in directory virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria should contain "merkle_hash"
    And the vcore equivalence criteria should contain "name"
    And the vcore equivalence criteria should contain "permissions"
    And the vcore equivalence criteria count should be 3

  Scenario: commit virtual type has equivalence with commit_hash for vcore
    Given the built-in commit virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria should contain "commit_hash"
    And the vcore equivalence criteria count should be 1

  Scenario: branch virtual type has equivalence with name and head for vcore
    Given the built-in branch virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria should contain "name"
    And the vcore equivalence criteria should contain "head_commit_hash"
    And the vcore equivalence criteria count should be 2

  Scenario: tag virtual type has equivalence with name and target for vcore
    Given the built-in tag virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria should contain "name"
    And the vcore equivalence criteria should contain "target_sha"
    And the vcore equivalence criteria count should be 2

  Scenario: tree virtual type has equivalence with tree_hash for vcore
    Given the built-in tree virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema equivalence should not be none
    And the vcore equivalence criteria count should be 1
    And the vcore equivalence criteria should contain "tree_hash"

  # ── Domain model loading ──────────────────────────────────

  Scenario Outline: Virtual core YAMLs load as domain model for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML as a ResourceTypeSpec for vcore
    Then the vcore domain model should be valid
    And the vcore domain model name should be "<type_name>"
    And the vcore domain model resource_kind should be virtual
    And the vcore domain model should have equivalence

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Bootstrap registration includes virtual types ─────────

  Scenario: Bootstrap builtin types list includes virtual core types for vcore
    Given the bootstrap builtin type definitions for vcore
    Then the builtin definitions should include "file" for vcore
    And the builtin definitions should include "directory" for vcore
    And the builtin definitions should include "commit" for vcore
    And the builtin definitions should include "branch" for vcore
    And the builtin definitions should include "tag" for vcore
    And the builtin definitions should include "tree" for vcore

  Scenario Outline: Bootstrap virtual types have correct properties for vcore
    Given the bootstrap builtin type definitions for vcore
    When I find the virtual type "<type_name>" in builtin definitions for vcore
    Then the found builtin type user_addable should be false for vcore
    And the found builtin type resource_kind should be "virtual" for vcore
    And the found builtin type should have equivalence for vcore

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── BUILTIN_NAMES includes virtual types ──────────────────

  Scenario: ResourceTypeSpec BUILTIN_NAMES includes virtual core types for vcore
    Then the ResourceTypeSpec BUILTIN_NAMES should contain "file" for vcore
    And the ResourceTypeSpec BUILTIN_NAMES should contain "directory" for vcore
    And the ResourceTypeSpec BUILTIN_NAMES should contain "commit" for vcore
    And the ResourceTypeSpec BUILTIN_NAMES should contain "branch" for vcore
    And the ResourceTypeSpec BUILTIN_NAMES should contain "tag" for vcore
    And the ResourceTypeSpec BUILTIN_NAMES should contain "tree" for vcore

  # ── Auto-discovery is none for virtual types ──────────────

  Scenario Outline: Virtual core types have no auto-discovery for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema auto_discovery should be none

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Handler is none for virtual types ─────────────────────

  Scenario Outline: Virtual core types have no handler for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    When I load the virtual YAML via from_yaml_file for vcore
    Then the vcore schema handler should be none

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Negative / validation tests ──────────────────────────────

  Scenario: Virtual type without equivalence is rejected for vcore
    Given a virtual type config missing equivalence for vcore
    When I attempt to create a ResourceTypeSpec from it for vcore
    Then the vcore creation should fail with a validation error
    And the vcore error message should mention "equivalence"

  Scenario: Virtual type with empty criteria list is rejected for vcore
    Given a virtual type config with empty equivalence criteria for vcore
    When I attempt to create a ResourceTypeSpec from it for vcore
    Then the vcore creation should fail with a validation error
    And the vcore error message should mention "criteria"

  # ── YAML ↔ registry data consistency ─────────────────────

  Scenario Outline: YAML and registry data match for vcore
    Given the built-in <type_name> virtual YAML file for vcore
    And the bootstrap builtin type definitions for vcore
    When I load the virtual YAML as a ResourceTypeSpec for vcore
    And I find the virtual type "<type_name>" in builtin definitions for vcore
    Then the YAML and registry should have matching fields for vcore

    Examples:
      | type_name  |
      | file       |
      | directory  |
      | commit     |
      | branch     |
      | tag        |
      | tree       |

  # ── Virtual types cannot be user-added ───────────────────

  Scenario: Attempting to register a virtual resource instance is rejected for vcore
    Given a bootstrapped resource registry for vcore
    When I attempt to register a resource of virtual type "file" for vcore
    Then the vcore resource registration should fail with "not user-addable"
