Files
cleveragents-core/features/sandbox_factory_coverage.feature
khyari hamza cc45b5ff2c feat(sandbox): add git_worktree and copy_on_write sandbox strategies
Implement GitWorktreeSandbox (worktree creation, commit+merge, rollback,
cleanup, branch sanitization, git timeouts) and CopyOnWriteSandbox
(directory copy, diff-based commit, rollback, cleanup).

Update SandboxFactory to wire new strategies, remove stale overlay/
versioning constants, add snapshot placeholder, align resource type
mapping to spec types (git-checkout, fs-mount, fs-directory, fs-file).

Add 40 Behave scenarios (19 git_worktree + 21 copy_on_write) with gwt/cow
prefixed steps. Update existing sandbox_factory_coverage feature (21
scenarios) to reflect new factory behavior.

All quality gates pass: ruff, pyright, 2325 scenarios, 97% coverage.

TASK-006 / Stage B4
2026-02-14 04:01:20 +00:00

128 lines
6.2 KiB
Gherkin

@phase1 @infrastructure @sandbox @factory
Feature: Sandbox factory strategy routing
As a system that creates isolated environments for different resource types
I want a factory that routes strategy requests to the correct sandbox implementation
So that each resource gets the appropriate isolation mechanism or a clear rejection
# --- Input validation ---
Scenario: The factory rejects an empty resource identifier
Given the sandbox factory is available
When a sandbox is requested with an empty resource identifier
Then the factory should reject the request due to a missing resource identifier
Scenario: The factory rejects an empty resource path
Given the sandbox factory is available
When a sandbox is requested with an empty resource path
Then the factory should reject the request due to a missing resource path
# --- None strategy (passthrough) ---
Scenario: The none strategy produces a passthrough sandbox
Given the sandbox factory is available
When a sandbox is requested for resource "web-api" at "/srv/api" using the none strategy
Then the factory should produce a passthrough sandbox
And the produced sandbox should be in the pending state
# --- Implemented strategies ---
Scenario: The git worktree strategy produces a git worktree sandbox
Given the sandbox factory is available
When a sandbox is requested for resource "repo-1" at "/src/repo" using the git worktree strategy
Then the factory should produce a git worktree sandbox
And the produced git worktree sandbox should be in the pending state
Scenario: The copy-on-write strategy produces a copy-on-write sandbox
Given the sandbox factory is available
When a sandbox is requested for resource "docs" at "/srv/docs" using the copy-on-write strategy
Then the factory should produce a copy-on-write sandbox
And the produced copy-on-write sandbox should be in the pending state
# --- Unimplemented strategies ---
Scenario: The transaction rollback strategy is not yet available
Given the sandbox factory is available
When a sandbox is requested for resource "db-main" at "postgres://db/main" using the transaction rollback strategy
Then the factory should indicate the strategy is not yet implemented
Scenario: The snapshot strategy is not yet available
Given the sandbox factory is available
When a sandbox is requested for resource "corpus" at "/srv/corpus" using the snapshot strategy
Then the factory should indicate the strategy is not yet implemented
# --- Unknown strategy ---
Scenario: An unrecognised strategy name is rejected
Given the sandbox factory is available
When a sandbox is requested for resource "misc" at "/tmp/misc" using an unrecognised strategy
Then the factory should reject the request due to an unknown strategy
Scenario: The overlay strategy is now unknown and rejected
Given the sandbox factory is available
When a sandbox is requested for resource "fs-root" at "/mnt/data" using the overlay strategy
Then the factory should reject the request due to an unknown strategy
Scenario: The versioning strategy is now unknown and rejected
Given the sandbox factory is available
When a sandbox is requested for resource "corpus" at "/srv/corpus" using the versioning strategy
Then the factory should reject the request due to an unknown strategy
# --- Support checks ---
Scenario: The none strategy is reported as supported
Given the sandbox factory is available
When the factory is asked whether the none strategy is supported
Then the factory should confirm the strategy is supported
Scenario: The git worktree strategy is reported as supported
Given the sandbox factory is available
When the factory is asked whether the git worktree strategy is supported
Then the factory should confirm the strategy is supported
Scenario: The copy-on-write strategy is reported as supported
Given the sandbox factory is available
When the factory is asked whether the copy-on-write strategy is supported
Then the factory should confirm the strategy is supported
Scenario: An unrecognised strategy is reported as unsupported
Given the sandbox factory is available
When the factory is asked whether an unrecognised strategy is supported
Then the factory should indicate the strategy is not supported
# --- Resource type strategy lookup (spec-aligned types) ---
Scenario: A git-checkout resource supports worktree, copy-on-write, and none
Given the sandbox factory is available
When the compatible strategies for a "git-checkout" resource are queried
Then the factory should return git worktree, copy-on-write, and none as compatible
Scenario: A git resource supports only the none strategy
Given the sandbox factory is available
When the compatible strategies for a "git" resource are queried
Then the factory should return only the none strategy as compatible
Scenario: A fs-mount resource supports copy-on-write and none
Given the sandbox factory is available
When the compatible strategies for a "fs-mount" resource are queried
Then the factory should return copy-on-write and none as compatible
Scenario: A fs-directory resource supports copy-on-write and none
Given the sandbox factory is available
When the compatible strategies for a "fs-directory" resource are queried
Then the factory should return copy-on-write and none as compatible
Scenario: A fs-file resource supports copy-on-write and none
Given the sandbox factory is available
When the compatible strategies for a "fs-file" resource are queried
Then the factory should return copy-on-write and none as compatible
Scenario: An api_endpoint resource supports only the none strategy
Given the sandbox factory is available
When the compatible strategies for an "api_endpoint" resource are queried
Then the factory should return only the none strategy as compatible
Scenario: An unknown resource type falls back to the none strategy
Given the sandbox factory is available
When the compatible strategies for an unknown resource type are queried
Then the factory should return only the none strategy as compatible