132 lines
5.9 KiB
Gherkin
132 lines
5.9 KiB
Gherkin
@feature9982
|
|
Feature: ACMS context add command with --tag and --policy flags
|
|
As a CleverAgents user
|
|
I want to index files into the ACMS context with tags and policy hints
|
|
So that I can organize and control how context is assembled
|
|
|
|
Background:
|
|
Given an acms context add test runner
|
|
|
|
# -- ChunkedFileTraverser unit tests --
|
|
|
|
Scenario: ChunkedFileTraverser indexes a single file
|
|
Given a temporary directory with a single Python file "main.py"
|
|
When I traverse the file with ChunkedFileTraverser
|
|
Then the acms traversal should yield 1 entry
|
|
And the acms entry path should be absolute
|
|
And the acms entry content should be non-empty
|
|
And the acms entry content_hash should be a valid SHA-256 hex string
|
|
|
|
Scenario: ChunkedFileTraverser indexes a directory recursively
|
|
Given a temporary directory with 3 Python files
|
|
When I traverse the directory recursively with ChunkedFileTraverser
|
|
Then the acms traversal should yield 3 entries
|
|
And all acms entry paths should be absolute
|
|
|
|
Scenario: ChunkedFileTraverser non-recursive directory indexing
|
|
Given a temporary directory with files in subdirectory
|
|
When I traverse the directory non-recursively with ChunkedFileTraverser
|
|
Then the acms traversal should yield only top-level files
|
|
|
|
Scenario: ChunkedFileTraverser attaches tags to entries
|
|
Given a temporary directory with a single Python file "tagged.py"
|
|
When I traverse with tags "api" and "core"
|
|
Then all acms entries should have tags ["api", "core"]
|
|
|
|
Scenario: ChunkedFileTraverser attaches policy to entries
|
|
Given a temporary directory with a single Python file "policy.py"
|
|
When I traverse with policy "strict"
|
|
Then all acms entries should have policy "strict"
|
|
|
|
Scenario: ChunkedFileTraverser reports progress via callback
|
|
Given a temporary directory with 5 Python files
|
|
When I traverse with a progress callback and chunk_size 2
|
|
Then the acms progress callback should have been called at least once
|
|
And the acms final progress call should report total 5
|
|
|
|
Scenario: ChunkedFileTraverser skips ignored files
|
|
Given a temporary directory with a Python file and a .pyc file
|
|
When I traverse the directory recursively with ChunkedFileTraverser
|
|
Then the acms traversal should yield only the Python file
|
|
|
|
Scenario: ChunkedFileTraverser skips files inside ignored directories
|
|
Given a temporary directory with a Python file and an ignored __pycache__ file
|
|
When I traverse the directory recursively with ChunkedFileTraverser
|
|
Then the acms traversal should yield only the visible Python file
|
|
|
|
Scenario: ChunkedFileTraverser skips files larger than max_file_size
|
|
Given a temporary directory with a single Python file "large.py"
|
|
When I traverse the file with max_file_size 1
|
|
Then the acms traversal should yield 0 entries
|
|
|
|
Scenario: ChunkedFileTraverser skips unreadable file metadata and content
|
|
Given a temporary directory with a single Python file "broken.py"
|
|
When I read the file with a mocked stat OSError
|
|
Then the acms read result should be skipped
|
|
When I read the file with a mocked read_text OSError
|
|
Then the acms read result should be skipped
|
|
|
|
Scenario: ChunkedFileTraverser raises FileNotFoundError for missing path
|
|
When I traverse a non-existent path with ChunkedFileTraverser
|
|
Then an acms FileNotFoundError should be raised
|
|
|
|
Scenario: ChunkedFileTraverser raises ValueError for invalid chunk_size
|
|
When I create a ChunkedFileTraverser with chunk_size 0
|
|
Then an acms ValueError should be raised mentioning "chunk_size"
|
|
|
|
Scenario: AcmsIndexEntry requires absolute path
|
|
When I create an AcmsIndexEntry with a relative path
|
|
Then an acms ValueError should be raised mentioning "absolute"
|
|
|
|
Scenario: AcmsIndexEntry rejects negative size_bytes
|
|
When I create an AcmsIndexEntry with size_bytes -1
|
|
Then an acms ValueError should be raised mentioning "non-negative"
|
|
|
|
# -- CLI integration tests --
|
|
|
|
Scenario: context add with --tag flag attaches tags
|
|
Given a mocked context service for acms add
|
|
And a temporary file "src/main.py" exists
|
|
When I invoke context add with path "src/main.py" and tag "api"
|
|
Then the acms context add command should succeed
|
|
And the acms output should mention "api"
|
|
|
|
Scenario: context add with multiple --tag flags
|
|
Given a mocked context service for acms add
|
|
And a temporary file "src/main.py" exists
|
|
When I invoke context add with path "src/main.py" and tags "api" and "core"
|
|
Then the acms context add command should succeed
|
|
And the acms output should mention "api"
|
|
And the acms output should mention "core"
|
|
|
|
Scenario: context add with --policy flag
|
|
Given a mocked context service for acms add
|
|
And a temporary file "src/main.py" exists
|
|
When I invoke context add with path "src/main.py" and policy "strict"
|
|
Then the acms context add command should succeed
|
|
And the acms output should mention "strict"
|
|
|
|
Scenario: context add with --no-recursive flag
|
|
Given a mocked context service for acms add
|
|
And a temporary directory "src/" with files
|
|
When I invoke context add with directory "src/" and --no-recursive
|
|
Then the acms context add command should succeed
|
|
|
|
Scenario: context add shows progress for directory indexing
|
|
Given a mocked context service for acms add
|
|
And a temporary directory "src/" with 3 files
|
|
When I invoke context add with directory "src/"
|
|
Then the acms context add command should succeed
|
|
|
|
Scenario: add_command persists paths when traversal raises
|
|
Given a mocked context service for acms add
|
|
And a temporary file "src/main.py" exists
|
|
When I call add_command with a mocked traverser ValueError
|
|
Then the acms programmatic context add should persist the file
|
|
|
|
Scenario: context add --help shows usage examples
|
|
When I invoke context add --help
|
|
Then the acms help output should contain "--tag"
|
|
And the acms help output should contain "--policy"
|
|
And the acms help output should contain "--recursive"
|