@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
