Files
cleveragents-core/features/resource_registry_model.feature
T
khyari hamza f89c60595f
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 26s
CI / security (pull_request) Successful in 21s
CI / quality (pull_request) Successful in 15s
CI / integration_tests (pull_request) Successful in 4m21s
CI / build (pull_request) Successful in 16s
CI / unit_tests (pull_request) Successful in 8m19s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 6m29s
feat(domain): add spec-aligned Resource and Project models
Implement the B1 (Project Data Models) domain models from scratch,
aligned with docs/specification.md:

- Resource model: ULID PK, PhysVirt enum (physical|virtual),
  SandboxStrategy enum (5 spec values), ResourceCapabilities,
  extensible resource_type_name, DAG relationships, frozen model

- NamespacedProject model: identified solely by [[server:]namespace/]name,
  LinkedResource for project-resource links, ContextConfig with memory
  tiers/retention/temporal scope, domain methods (link/unlink/get)

- parse_namespaced_name(): full namespace parsing with reserved/provider
  namespace validation, bare name defaulting to local/

- Extract legacy Project/ProjectSettings/ProjectStats to project_legacy.py

- 81 Behave scenarios (233 steps), all passing
- Lint (ruff), typecheck (pyright) clean
- Full existing test suite (2336 scenarios) unaffected
2026-02-13 21:54:31 +00:00

172 lines
6.8 KiB
Gherkin

Feature: Resource Registry Domain Model
As a developer
I want spec-aligned Resource Registry domain models
So that resources are tracked with proper types, capabilities, and relationships
# PhysVirt enum
Scenario: PhysVirt has exactly two values
Then the PhysVirt enum should have values "physical, virtual"
Scenario: PhysVirt physical value
Given a PhysVirt value of "physical"
Then the PhysVirt string value should be "physical"
Scenario: PhysVirt virtual value
Given a PhysVirt value of "virtual"
Then the PhysVirt string value should be "virtual"
Scenario: PhysVirt rejects invalid value
When I try to create a PhysVirt with value "hybrid"
Then a resource validation error should be raised
# SandboxStrategy enum
Scenario: SandboxStrategy has exactly five values
Then the SandboxStrategy enum should have values "git_worktree, copy_on_write, transaction_rollback, snapshot, none"
Scenario Outline: SandboxStrategy accepts valid values
Given a SandboxStrategy value of "<strategy>"
Then the SandboxStrategy string value should be "<strategy>"
Examples:
| strategy |
| git_worktree |
| copy_on_write |
| transaction_rollback |
| snapshot |
| none |
Scenario: SandboxStrategy rejects overlay
When I try to create a SandboxStrategy with value "overlay"
Then a resource validation error should be raised
Scenario: SandboxStrategy rejects versioning
When I try to create a SandboxStrategy with value "versioning"
Then a resource validation error should be raised
# ResourceCapabilities model
Scenario: ResourceCapabilities defaults
Given default ResourceCapabilities
Then the capability readable should be true
And the capability writable should be true
And the capability sandboxable should be true
And the capability checkpointable should be false
Scenario: ResourceCapabilities with custom values
Given ResourceCapabilities with readable false and checkpointable true
Then the capability readable should be false
And the capability writable should be true
And the capability sandboxable should be true
And the capability checkpointable should be true
Scenario: ResourceCapabilities is frozen
Given default ResourceCapabilities
When I try to mutate a ResourceCapabilities field
Then a resource validation error should be raised
# Resource model - creation
Scenario: Create a minimal physical resource
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
Then the resource resource_id should be "01HZQX7K8M3N4P5R6S7T8V9W0X"
And the resource type name should be "git-checkout"
And the resource classification should be "physical"
And the resource name should be empty
And the resource description should be empty
And the resource properties should be empty
And the resource parents should be empty
And the resource children should be empty
And the resource linked_projects should be empty
And the resource created_at should be set
And the resource updated_at should be set
Scenario: Create a full resource with all fields
Given a full Resource with id "01HZQX7K8M3N4P5R6S7T8V9W0X" name "local/my-repo" type "git-checkout" classification "physical" description "Main repo"
Then the resource name should be "local/my-repo"
And the resource description should be "Main repo"
Scenario: Resource with sandbox strategy override
Given a Resource with sandbox strategy "git_worktree"
Then the resource sandbox strategy should be "git_worktree"
Scenario: Resource with capabilities
Given a Resource with sandboxable false and checkpointable true
Then the resource can_sandbox should be false
And the resource can_checkpoint should be true
# Resource model - validation
Scenario: Resource rejects invalid ULID
When I try to create a Resource with resource_id "invalid-ulid"
Then a resource validation error should be raised
Scenario: Resource rejects empty resource_type_name
When I try to create a Resource with empty resource_type_name
Then a resource validation error should be raised
Scenario: Resource rejects empty string name
When I try to create a Resource with empty string name
Then a resource validation error should be raised
Scenario: Resource accepts None name
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
Then the resource name should be empty
# Resource model - domain properties
Scenario: Physical resource is_physical
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
Then the resource is_physical should be true
And the resource is_virtual should be false
Scenario: Virtual resource is_virtual
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git" and classification "virtual"
Then the resource is_physical should be false
And the resource is_virtual should be true
Scenario: Read-only resource
Given a Resource with writable false
Then the resource is_read_only should be true
Scenario: Writable resource
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
Then the resource is_read_only should be false
# Resource model - frozen
Scenario: Resource is frozen
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
When I try to mutate a Resource field
Then a resource validation error should be raised
# Resource model - with_updated_at
Scenario: with_updated_at returns new instance
Given a Resource with resource_id "01HZQX7K8M3N4P5R6S7T8V9W0X" type "git-checkout" and classification "physical"
When I call with_updated_at on the resource
Then the new resource should have a different updated_at
And the new resource should have the same resource_id
# Resource model - content_hash and location
Scenario: Resource with content_hash
Given a Resource with content_hash "sha256:abc123"
Then the resource content_hash should be "sha256:abc123"
Scenario: Resource with location
Given a Resource with location "/home/user/repos/main"
Then the resource location should be "/home/user/repos/main"
Scenario: Resource rejects empty location string
When I try to create a Resource with empty location
Then a resource validation error should be raised
# Resource model - parents and children
Scenario: Resource with parents and children
Given a Resource with parents and children
Then the resource should have 1 parent
And the resource should have 2 children