diff --git a/features/sandbox_dirs_cache.feature b/features/sandbox_dirs_cache.feature index fc5c0eae5..0f785fed0 100644 --- a/features/sandbox_dirs_cache.feature +++ b/features/sandbox_dirs_cache.feature @@ -38,18 +38,18 @@ Feature: Sandbox directories cache tracking and invalidation (#7527) 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 result should be True + 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 result should be False + 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 result should be False + 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" diff --git a/features/steps/sandbox_dirs_cache_steps.py b/features/steps/sandbox_dirs_cache_steps.py index 814d10946..36c0bf602 100644 --- a/features/steps/sandbox_dirs_cache_steps.py +++ b/features/steps/sandbox_dirs_cache_steps.py @@ -20,17 +20,13 @@ def step_given_empty_cache(context): context._sdc = SandboxDirsCache() -@given( - 'a sandbox dirs cache with one path "{dir_path}" for plan "{plan_id}"' -) +@given('a sandbox dirs cache with one path "{dir_path}" for plan "{plan_id}"') def step_given_one_dir(context, dir_path, plan_id): context._sdc = SandboxDirsCache() context._sdc.record(plan_id, dir_path) -@given( - 'a sandbox dirs cache with paths for plans "{plan_a}" and "{plan_b}"' -) +@given('a sandbox dirs cache with paths for plans "{plan_a}" and "{plan_b}"') def step_given_two_plans(context, plan_a, plan_b): context._sdc = SandboxDirsCache() context._sdc.record(plan_a, f"/tmp/sandboxes/{plan_a}-dir") @@ -117,12 +113,12 @@ def step_then_no_plans_removed(context): assert context._sdc.plan_count == 0 -@then("the result should be True") +@then("the dir membership result should be True") def step_then_membership_true(context): assert context._check_result is True -@then("the result should be False") +@then("the dir membership result should be False") def step_then_membership_false(context): assert context._check_result is False diff --git a/src/cleveragents/application/services/cleanup_service.py b/src/cleveragents/application/services/cleanup_service.py index 3aff5501c..8d7a33432 100644 --- a/src/cleveragents/application/services/cleanup_service.py +++ b/src/cleveragents/application/services/cleanup_service.py @@ -191,6 +191,7 @@ class CleanupService: report.sandboxes.removed += 1 except OSError: report.sandboxes.skipped += 1 + self._sandbox_dirs_cache = None # ── Checkpoint cleanup ──────────────────────────────────────── diff --git a/src/cleveragents/infrastructure/sandbox/dirs_cache.py b/src/cleveragents/infrastructure/sandbox/dirs_cache.py index 6fbd7335e..b0d8c7108 100644 --- a/src/cleveragents/infrastructure/sandbox/dirs_cache.py +++ b/src/cleveragents/infrastructure/sandbox/dirs_cache.py @@ -12,7 +12,6 @@ from __future__ import annotations import logging import threading -from typing import Any logger = logging.getLogger(__name__) @@ -87,9 +86,7 @@ class SandboxDirsCache: removed = list(self._dirs.pop(plan_id, set())) if removed: - logger.info( - "Purged %d sandbox dir(s) for plan=%s", len(removed), plan_id - ) + logger.info("Purged %d sandbox dir(s) for plan=%s", len(removed), plan_id) return removed