Files
cleveragents-core/features/resource_model.feature
khyari hamza 676810d62b feat: Add ValidationConfig and ContextConfig models with step definitions
- Introduced ValidationConfig for project validation commands including test, lint, type-check, and build commands.
- Added ContextConfig for project context indexing and filtering, with support for ignore/include patterns and file size limits.
- Implemented step definitions for both models in project_config_model_steps.py.
- Enhanced Project model to include validation_config and context_config fields.
- Created comprehensive step definitions for Resource model, including validation and manipulation steps in resource_model_steps.py.
- Updated resource.py to define Resource model with necessary fields and validation.
- Refactored project.py to integrate new models and maintain backward compatibility.
2026-02-12 14:32:10 +00:00

205 lines
8.8 KiB
Gherkin

Feature: Resource Domain Model
As a developer
I want resource types and sandbox strategies defined as domain enums
So that the system can classify project resources and determine sandboxing behavior
# ResourceType Enum Tests (B1.3)
Scenario: ResourceType has all required values
Then the resource types should be "git_repository, filesystem, database, api_endpoint, document_corpus, cloud_infrastructure"
Scenario: ResourceType GIT_REPOSITORY has correct value
When I access ResourceType.GIT_REPOSITORY
Then the resource type value should be "git_repository"
Scenario: ResourceType FILESYSTEM has correct value
When I access ResourceType.FILESYSTEM
Then the resource type value should be "filesystem"
Scenario: ResourceType DATABASE has correct value
When I access ResourceType.DATABASE
Then the resource type value should be "database"
Scenario: ResourceType API_ENDPOINT has correct value
When I access ResourceType.API_ENDPOINT
Then the resource type value should be "api_endpoint"
Scenario: ResourceType DOCUMENT_CORPUS has correct value
When I access ResourceType.DOCUMENT_CORPUS
Then the resource type value should be "document_corpus"
Scenario: ResourceType CLOUD_INFRASTRUCTURE has correct value
When I access ResourceType.CLOUD_INFRASTRUCTURE
Then the resource type value should be "cloud_infrastructure"
Scenario: ResourceType is a string enum
When I access ResourceType.GIT_REPOSITORY
Then the resource type should be a string
Scenario: ResourceType can be created from string value
When I create a ResourceType from string "filesystem"
Then the resource type value should be "filesystem"
Scenario: Invalid resource type string raises error
When I try to create a ResourceType from string "invalid_type"
Then a ValueError should be raised
# SandboxStrategy Enum Tests (B1.4)
Scenario: SandboxStrategy has all required values
Then the sandbox strategies should be "git_worktree, copy_on_write, overlay, transaction_rollback, versioning, none"
Scenario: SandboxStrategy GIT_WORKTREE has correct value
When I access SandboxStrategy.GIT_WORKTREE
Then the sandbox strategy value should be "git_worktree"
Scenario: SandboxStrategy COPY_ON_WRITE has correct value
When I access SandboxStrategy.COPY_ON_WRITE
Then the sandbox strategy value should be "copy_on_write"
Scenario: SandboxStrategy OVERLAY has correct value
When I access SandboxStrategy.OVERLAY
Then the sandbox strategy value should be "overlay"
Scenario: SandboxStrategy TRANSACTION_ROLLBACK has correct value
When I access SandboxStrategy.TRANSACTION_ROLLBACK
Then the sandbox strategy value should be "transaction_rollback"
Scenario: SandboxStrategy VERSIONING has correct value
When I access SandboxStrategy.VERSIONING
Then the sandbox strategy value should be "versioning"
Scenario: SandboxStrategy NONE has correct value
When I access SandboxStrategy.NONE
Then the sandbox strategy value should be "none"
Scenario: SandboxStrategy is a string enum
When I access SandboxStrategy.GIT_WORKTREE
Then the sandbox strategy should be a string
# SandboxStrategy.supports_rollback Tests (B1.4b)
Scenario: GIT_WORKTREE supports rollback
Then SandboxStrategy.GIT_WORKTREE should support rollback
Scenario: COPY_ON_WRITE supports rollback
Then SandboxStrategy.COPY_ON_WRITE should support rollback
Scenario: OVERLAY supports rollback
Then SandboxStrategy.OVERLAY should support rollback
Scenario: TRANSACTION_ROLLBACK supports rollback
Then SandboxStrategy.TRANSACTION_ROLLBACK should support rollback
Scenario: VERSIONING supports rollback
Then SandboxStrategy.VERSIONING should support rollback
Scenario: NONE does not support rollback
Then SandboxStrategy.NONE should not support rollback
# SandboxStrategy.is_copy_based Tests (B1.4b)
Scenario: COPY_ON_WRITE is copy based
Then SandboxStrategy.COPY_ON_WRITE should be copy based
Scenario: OVERLAY is copy based
Then SandboxStrategy.OVERLAY should be copy based
Scenario: GIT_WORKTREE is not copy based
Then SandboxStrategy.GIT_WORKTREE should not be copy based
Scenario: TRANSACTION_ROLLBACK is not copy based
Then SandboxStrategy.TRANSACTION_ROLLBACK should not be copy based
Scenario: VERSIONING is not copy based
Then SandboxStrategy.VERSIONING should not be copy based
Scenario: NONE is not copy based
Then SandboxStrategy.NONE should not be copy based
# Resource Pydantic Model Tests (B1.2)
# B1.2a - Model structure (frozen=True)
Scenario: Create a valid Resource with all required fields
Given a Resource with required fields id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo"
Then the resource name should be "my-repo"
And the resource type should be ResourceType.GIT_REPOSITORY
And the resource location should be "/tmp/repo"
Scenario: Resource model is frozen
Given I have a valid Resource
When I try to modify the resource name
Then a validation error should be raised
# B1.2b - All fields present with defaults
Scenario: Resource has correct default values
Given a Resource with required fields id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo"
Then the resource is_remote should be false
And the resource sandbox_strategy should be SandboxStrategy.NONE
And the resource read_only should be false
And the resource metadata should be empty
And the resource created_at should be set
Scenario: Create a remote Resource
Given a remote Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "api-svc" type "api_endpoint" location "https://api.example.com"
Then the resource is_remote should be true
Scenario: Create a read-only Resource
Given a read-only Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "docs" type "document_corpus" location "/data/docs"
Then the resource read_only should be true
Scenario: Create a Resource with custom sandbox strategy
Given a Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo" strategy "git_worktree"
Then the resource sandbox_strategy should be SandboxStrategy.GIT_WORKTREE
Scenario: Create a Resource with metadata
Given a Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo" metadata "branch=main,remote=origin"
Then the resource metadata should contain key "branch" with value "main"
And the resource metadata should contain key "remote" with value "origin"
# B1.2c - Validators
Scenario: Reject Resource with invalid ULID
When I try to create a Resource with id "not-a-ulid" name "my-repo" type "git_repository" location "/tmp/repo"
Then a validation error should be raised
Scenario: Reject Resource with empty name
When I try to create a Resource with an empty name
Then a validation error should be raised
Scenario: Reject Resource with empty location
When I try to create a Resource with an empty location
Then a validation error should be raised
Scenario: Resource name is lowercased
Given a Resource with required fields id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "My-Repo" type "git_repository" location "/tmp/repo"
Then the resource name should be "my-repo"
Scenario: Reject Resource with invalid name characters
When I try to create a Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my repo!!" type "git_repository" location "/tmp/repo"
Then a validation error should be raised
# B1.2d - Properties
Scenario: Resource with sandbox strategy supports sandbox
Given a Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo" strategy "git_worktree"
Then the resource supports_sandbox should be true
Scenario: Resource with NONE sandbox strategy does not support sandbox
Given a Resource with required fields id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo"
Then the resource supports_sandbox should be false
Scenario: Writable Resource can_write is true
Given a Resource with required fields id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo"
Then the resource can_write should be true
Scenario: Read-only Resource can_write is false
Given a read-only Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "docs" type "document_corpus" location "/data/docs"
Then the resource can_write should be false
Scenario: Resource get_sandbox_path returns correct path
Given a Resource with id "01ARZ3NDEKTSV4RRFFQ69G5FAV" name "my-repo" type "git_repository" location "/tmp/repo" strategy "git_worktree"
Then the resource get_sandbox_path with base "/sandbox" should end with "my-repo"