Files
cleveragents-core/features/cleanup_service_cache_invalidation.feature
HAL9000 8f6dc11cc6 fix(cleanup): invalidate sandbox_dirs_cache after purge (#7527)
Implemented cache invalidation for CleanupService to fix stale sandbox paths
being reported after purge() completes. The _sandbox_dirs_cache is now
invalidated after _purge_sandboxes() so subsequent scan() calls re-read the
filesystem instead of returning already-deleted paths.

Changes:
- Added self._sandbox_dirs_cache = None at end of _purge_sandboxes()
- Updated docstring to document cache invalidation behavior
- Created comprehensive BDD test coverage with 5 scenarios under new
  features/cleanup_service_cache_invalidation.feature and step definitions
- Updated CHANGELOG.md with bug fix entry
- Updated CONTRIBUTORS.md with PR #8257

ISSUES CLOSED: #7527
2026-06-13 09:29:11 -04:00

34 lines
1.9 KiB
Gherkin

@unit @mock_only
Feature: CleanupService sandbox cache invalidation after purge (#7527)
As a platform operator running CleanupService in a daemon context
I want the sandbox directory cache to be invalidated after purge()
So that a subsequent scan() reflects the actual filesystem state
and does not report already-deleted paths as stale items
# Cache invalidation after purge
Scenario: cache is None after _purge_sandboxes completes
Given cache invalidation has a CleanupService with a pre-populated sandbox cache
When cache invalidation calls _purge_sandboxes
Then cache invalidation sandbox dirs cache should be None
Scenario: scan after purge does not return the previously created sandbox directories
Given cache invalidation has a CleanupService with stale sandbox directories on disk
When cache invalidation calls scan then purge then scan again
Then cache invalidation second scan should not contain the previously created sandbox directories
Scenario: scan after purge does not return previously cached paths
Given cache invalidation has a CleanupService with a pre-populated sandbox cache
When cache invalidation calls purge then scan
Then cache invalidation scan result should not contain the pre-cached paths
Scenario: cache is repopulated on next _get_sandbox_dirs call after purge
Given cache invalidation has a CleanupService with a pre-populated sandbox cache
When cache invalidation calls _purge_sandboxes then _get_sandbox_dirs
Then cache invalidation cache should be repopulated from filesystem
Scenario: purge with no stale sandboxes still invalidates cache
Given cache invalidation has a CleanupService with a fresh non-stale sandbox cache
When cache invalidation calls _purge_sandboxes
Then cache invalidation sandbox dirs cache should be None