Feature: BuiltinAdapter and MCP resource slot inference
  As a developer
  I want a formal BuiltinAdapter class with lifecycle methods
  And MCP resource slot inference from tool parameter schemas
  So that built-in tools follow the adapter pattern and MCP tools get automatic resource bindings

  # ---- BuiltinAdapter ----

  Scenario: BuiltinAdapter.discover returns all built-in tools
    Given a builtin adapter
    Then the builtin adapter should not be discovered yet
    When I call discover on the builtin adapter
    Then the builtin adapter should be discovered
    And the discovered tools should include all file tools
    And the discovered tools should include all git tools
    And the discovered tools should include all subplan tools
    And the total discovered tool count should be 11

  Scenario: BuiltinAdapter.register registers all tools in a ToolRegistry
    Given a builtin adapter
    And a tool registry
    When I call register on the builtin adapter
    Then the registry should contain 11 tools
    And the registry should contain tool "builtin/file-read"
    And the registry should contain tool "builtin/git-status"
    And the registry should contain tool "builtin/plan-subplan"

  Scenario: BuiltinAdapter.activate and deactivate are no-ops
    Given a builtin adapter
    When I call activate on the builtin adapter
    And I call deactivate on the builtin adapter
    Then the builtin adapter lifecycle calls should succeed without error

  Scenario: Tools registered through BuiltinAdapter have source builtin
    Given a builtin adapter
    And a tool registry
    When I call register on the builtin adapter
    Then all registered tools should have source "builtin"

  # ---- MCP Resource Slot Inference ----

  Scenario: MCP resource slot inference for file_path parameters
    Given an MCP tool input schema with a "file_path" property
    When I infer resource slots for the schema
    Then the inferred slots should contain a "file" slot
    And the "file" slot should have resource_type "file"
    And the "file" slot should have access "read_write"
    And the "file" slot should have binding "parameter"

  Scenario: MCP resource slot inference for directory parameters
    Given an MCP tool input schema with a "directory" property
    When I infer resource slots for the schema
    Then the inferred slots should contain a "directory" slot
    And the "directory" slot should have resource_type "directory"
    And the "directory" slot should have access "read_only"
    And the "directory" slot should have binding "parameter"

  Scenario: MCP resource slot inference for repo_path parameters
    Given an MCP tool input schema with a "repo_path" property
    When I infer resource slots for the schema
    Then the inferred slots should contain a "repository" slot
    And the "repository" slot should have resource_type "git-checkout"
    And the "repository" slot should have access "read_write"
    And the "repository" slot should have binding "contextual"

  # ---- Boundary / negative cases ----

  Scenario: MCP resource slot inference returns empty list for empty schema
    Given an MCP tool with an empty input schema
    When I infer resource slots for the schema
    Then the inferred slots should be empty

  Scenario: MCP resource slot inference returns empty list for schema with no properties key
    Given an MCP tool with an input schema missing the properties key
    When I infer resource slots for the schema
    Then the inferred slots should be empty

  Scenario: MCP resource slot inference deduplicates when multiple file params present
    Given an MCP tool with both "file_path" and "filepath" properties
    When I infer resource slots for the schema
    Then the inferred slots should contain a "file" slot
    And the inferred slot count should be 1
