Feature: ACMS Index Data Model and File Traversal Engine
  As a developer
  I want to index large projects with 10,000+ files
  So that I can efficiently query and manage context entries at scale

  Background:
    Given I have an ACMS index
    And I have a file traversal engine with chunk size 100

  Scenario: Create an index entry with file metadata
    When I create an index entry with:
      | key       | value               |
      | path      | /project/src/main.py |
      | file_type | python               |
      | size_bytes | 1024                 |
    Then the index entry should have path "/project/src/main.py"
    And the index entry should have file type "python"
    And the index entry should have size 1024 bytes

  Scenario: Add tags to an index entry
    Given I have an index entry with path "/project/src/main.py"
    When I add tag "core" to the entry
    And I add tag "important" to the entry
    Then the entry should have tag "core"
    And the entry should have tag "important"
    And the entry should have 2 tags

  Scenario: Set tier level for an index entry
    Given I have an index entry with path "/project/src/main.py"
    When I set the tier level to "hot"
    Then the entry should have tier level "hot"

  Scenario: Add entry to index
    Given I have an index entry with path "/project/src/main.py"
    When I add the entry to the index
    Then the index should contain 1 entry
    And I should be able to retrieve the entry by path "/project/src/main.py"

  Scenario: Query index by path pattern
    Given I have an index with entries:
      | path | file_type |
      | /project/src/main.py | python |
      | /project/src/utils.py | python |
      | /project/tests/test_main.py | python |
      | /project/docs/readme.md | markdown |
    When I query the index by path pattern "src"
    Then I should get 2 results
    And the results should include "/project/src/main.py"
    And the results should include "/project/src/utils.py"

  Scenario: Query index by file type
    Given I have an index with entries:
      | path | file_type |
      | /project/src/main.py | python |
      | /project/src/utils.py | python |
      | /project/src/app.js | javascript |
      | /project/docs/readme.md | markdown |
    When I query the index by file type "python"
    Then I should get 2 results
    And all results should have file type "python"

  Scenario: Query index by tag
    Given I have an index with entries:
      | path | tags |
      | /project/src/main.py | core,important |
      | /project/src/utils.py | supporting |
      | /project/tests/test_main.py | test,important |
    When I query the index by tag "important"
    Then I should get 2 results
    And the results should include "/project/src/main.py"
    And the results should include "/project/tests/test_main.py"

  Scenario: Query index by tier level
    Given I have an index with entries:
      | path | tier |
      | /project/src/main.py | hot |
      | /project/src/utils.py | warm |
      | /project/tests/test_main.py | cold |
    When I query the index by tier level "hot"
    Then I should get 1 result
    And the result should have path "/project/src/main.py"

  Scenario: Query index by recency
    Given I have an index with entries from different dates
    When I query the index for entries modified after "2026-04-01"
    Then I should get entries modified after that date

  Scenario: Traverse and index a directory with multiple files
    Given I have a test directory with 50 files
    When I traverse and index the directory
    Then the index should contain 50 entries
    And all entries should have valid file paths

  Scenario: Handle large project traversal with chunked processing
    Given I have a test directory with 1000 files
    When I traverse and index the directory with chunk size 100
    Then the index should contain 1000 entries
    And the traversal should complete without timeout

  Scenario: Exclude patterns during traversal
    Given I have a test directory with files including:
      | path |
      | /project/src/main.py |
      | /project/.git/config |
      | /project/__pycache__/main.cpython-39.pyc |
      | /project/src/utils.py |
    When I traverse and index the directory excluding ".git" and "__pycache__"
    Then the index should contain 2 entries
    And the index should not contain ".git" paths
    And the index should not contain "__pycache__" paths

  Scenario: Get all entries from index
    Given I have an index with 5 entries
    When I get all entries from the index
    Then I should get 5 results

  Scenario: Get entry count from index
    Given I have an index with 10 entries
    When I get the entry count
    Then idx the index count should be 10

  Scenario: Remove entry from index
    Given I have an index with 3 entries
    When I remove an entry by path
    Then the index should contain 2 entries

  Scenario: Combined query with multiple filters
    Given I have an index with entries:
      | path | file_type | tags | tier |
      | /project/src/main.py | python | core,important | hot |
      | /project/src/utils.py | python | supporting | warm |
      | /project/tests/test_main.py | python | test | cold |
      | /project/docs/readme.md | markdown | docs | cold |
    When I query the index with filters:
      | filter       | value |
      | path_pattern | src   |
      | file_type    | python |
      | tier         | hot   |
    Then I should get 1 result
    And the result should have path "/project/src/main.py"
