Files
cleveragents-core/features/sandbox_dirs_cache.feature
T
HAL9000 9d5128c265 fix(cleanup): fix CI failures and address review feedback (#7527)
- Remove unused typing.Any import from dirs_cache.py (ruff lint)
- Collapse multiline expressions without trailing commas (ruff format)
- Rename ambiguous behave step "the result should be {True,False}" to
  "the dir membership result should be {True,False}" — resolves conflict
  with existing step @then('the result should be {expected}') in
  cli_steps.py that caused all 31 feature workers to crash on load
- Add self._sandbox_dirs_cache = None invalidation to
  CleanupService._purge_sandboxes() — the actual fix for issue #7527;
  without this, subsequent scan() calls return stale deleted paths
- Fix CONTRIBUTORS.md PR reference from #10989 to #11091

ISSUES CLOSED: #7527
2026-06-12 12:08:13 -04:00

64 lines
3.1 KiB
Gherkin

@sandbox-dirs-cache
Feature: Sandbox directories cache tracking and invalidation (#7527)
Verifies that the SandboxDirsCache correctly records, tracks, and purges
sandbox directory paths by plan_id.
Scenario: Record a sandbox directory path for a plan
Given an empty sandbox dirs cache
When I record dir "/tmp/sandboxes/worktree-abc123" for plan "plan-001"
Then the cache should contain one path for plan "plan-001"
And the total tracked plan count should be 1
Scenario: Record multiple directories for the same plan
Given an empty sandbox dirs cache
When I record dir "/tmp/sandboxes/worktree-abc" for plan "plan-002"
And I record dir "/tmp/sandboxes/overlay-def456" for plan "plan-002"
Then the cache should contain two paths for plan "plan-002"
And the total tracked path count should be 2
Scenario: Record directories for different plans
Given an empty sandbox dirs cache
When I record dir "/tmp/sandboxes/plan-a-dir" for plan "plan-a"
And I record dir "/tmp/sandboxes/plan-b-dir" for plan "plan-b"
Then the cache should contain two distinct plans
And the total tracked plan count should be 2
Scenario: Purge a single plan invalidates all its dirs
Given a sandbox dirs cache with one path "/tmp/sandboxes/worktree-x" for plan "plan-purge"
When I purge sandbox dirs for plan "plan-purge"
Then the cache should contain no paths for plan "plan-purge"
And the total tracked plan count should be 0
Scenario: Purge non-existent plan returns empty list
Given an empty sandbox dirs cache
When I purge sandbox dirs for plan "nonexistent-plan"
Then the purged path count should be 0
And no plans should be removed from tracking
Scenario: Check membership for recorded path
Given a sandbox dirs cache with one path "/tmp/sandboxes/abc" for plan "plan-check"
When I check if dir "/tmp/sandboxes/abc" belongs to plan "plan-check"
Then the dir membership result should be True
Scenario: Check membership for non-recorded path returns False
Given a sandbox dirs cache with one path "/tmp/sandboxes/xyz" for plan "plan-wrong"
When I check if dir "/tmp/sandboxes/missing" belongs to plan "plan-wrong"
Then the dir membership result should be False
Scenario: Check membership after purge returns False
Given a sandbox dirs cache with one path "/tmp/sandboxes/cached-dir" for plan "plan-expired"
When I purge sandbox dirs for plan "plan-expired"
And I check if dir "/tmp/sandboxes/cached-dir" belongs to plan "plan-expired"
Then the dir membership result should be False
Scenario: Clear all entries empties the cache
Given a sandbox dirs cache with paths for plans "plan-clear-1" and "plan-clear-2"
When I clear all entries from the sandbox dirs cache
Then no plans should remain tracked
And total tracked path count should be 0
Scenario: Duplicate directory recording is idempotent
Given a sandbox dirs cache with one path "/tmp/sandboxes/uniq-dir" for plan "plan-uniq"
When I record dir "/tmp/sandboxes/uniq-dir" for plan "plan-uniq" again
Then the cache should still contain exactly one path for plan "plan-uniq"