fix(config): allow --minimize-reads type-scoped mode with --cleanup - #653
Merged
Merged
Conversation
--minimize-reads has two sub-modes: ID-targeted (--filter exact-ids or --id-file) and type-scoped (--resources only). Type-scoped loads state.destination[type] fully per type via prefix listing, so the cleanup diff destination[type] - source[type] is well-defined. ID- targeted loads only listed IDs, and cleanup's diff over that scope would delete legitimate destination records outside the scope. Refine the guardrail to fire only on ID-targeted + cleanup. Guard is placed after the ID-targeting decision and gates on the actual scoping variable (_state_exact_ids is not None), so an --id-file whose types are disjoint from --resources correctly falls through to type-scoped and is accepted.
michael-richey
approved these changes
Jul 30, 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.
What
--minimize-readshas two sub-modes selected inconfiguration.py:--filterexact-ids or--id-file):state.destination[type]loads only the listed IDs.--resourcesonly):state.destination[type]loads all IDs of the requested types via the storage backend's prefix listing.The blanket rejection at the old
configuration.py:590-591conflated the two. Cleanup's diffdestination[type] - source[type]over an ID-targeted load is unsafe (would delete legitimate destination records outside the scope), but over a type-scoped load it is well-defined and functionally identical to full-load-then-cleanup for the types in scope.Fix
Refine the guardrail to fire only on ID-targeted + cleanup. Move the check after the ID-targeting decision so it can gate on the actual scoping variable (`_state_exact_ids is not None`), not on flag presence. An `--id-file` whose types are disjoint from `--resources` correctly falls through to type-scoped and is accepted.
Tests
Full unit suite passes locally (1082 tests, no regressions).