feat(storage): add list_filenames, delete, delete_many primitives#553
Merged
Conversation
Internal storage API additions enabling per-resource file enumeration and deletion across all four backends (LocalFile, S3, GCS, Azure). Required for the upcoming `prune` command which removes orphaned state files when source resources are deleted upstream. - BaseStorage gains concrete defaults that raise NotImplementedError for list_filenames/delete (out-of-tree backends fail loudly rather than silently no-op'ing). delete_many has a working default that loops delete(), so backends only need to override the single-key delete to get batch deletion for free. - LocalFile: os.listdir + filename prefix filter; os.remove with FileNotFoundError handling. - AWSS3Bucket: paginated list_objects_v2; idempotent delete_object. - GCSBucket: list_blobs(prefix=...); blob.delete() wrapped in try/except NotFound. - AzureBlobContainer: list_blobs(name_starts_with=...); delete_blob wrapped in try/except ResourceNotFoundError. 35 new unit tests across all backends; existing 412 tests unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced May 7, 2026
riyazsh
previously approved these changes
May 11, 2026
heyronhay
previously approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of three stacked PRs adding a top-level
prunecommand that deletes orphaned per-resource state files when source resources are removed upstream.This PR adds the storage-layer primitives that the upcoming
State.compute_stale_files/delete_stale_fileshelpers (PR 2) andprunecommand (PR 3) will build on. Internal API only — no user-visible behavior change.What changed
BaseStoragegains three methods:list_filenames(origin, resource_type) -> Set[str]— full filenames under<base>/<resource_type>.*.json, opaque strings (no parsing).delete(origin, filename) -> None— single-file delete, no-op if absent.delete_many(origin, filenames) -> Dict[str, str]— batch wrapper returning{filename: "ok" | error}. Concrete default loopsdelete(); backends like S3 may override withDeleteObjectslater.NotImplementedErroronBaseStoragerather than@abstractmethod, so out-of-tree backends fail loudly rather than silently returning empty results.LocalFile:os.listdir+os.remove(idempotent onFileNotFoundError).AWSS3Bucket: paginatedlist_objects_v2;delete_object(idempotent at the AWS layer).GCSBucket:list_blobs(prefix=...);blob.delete()wrapped intry/except NotFound.AzureBlobContainer:list_blobs(name_starts_with=...);delete_blobwrapped intry/except ResourceNotFoundError.Test plan
tests/unit/test_storage_list_filenames.py,tests/unit/test_storage_delete.py).tox -e py3 -- tests/unit/) passes — 447 tests, no regressions.Stacked PR context
This is PR 1 of 3. Subsequent PRs:
🤖 Generated with Claude Code