Fix ScanningRecipe accumulator loss in preconditioned DeclarativeRecipes across RecipeRunCycles#6913
Merged
jkschneider merged 2 commits intoopenrewrite:mainfrom Mar 10, 2026
Conversation
BellwetherDecoratedScanningRecipe gets a new UUID-based accumulator key each time it is instantiated. Since DeclarativeRecipe.getRecipeList() creates new wrapper instances on every call, a fresh RecipeStack (which triggers new getRecipeList() calls) causes accumulators stored under old keys to become unreachable. Override getAccumulator() to delegate to the wrapped recipe's stable UUID.
bryceatmoderne
approved these changes
Mar 10, 2026
jkschneider
approved these changes
Mar 10, 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.
Problem
When a
DeclarativeRecipehas preconditions (e.g.Singleton), itsgetRecipeList()wraps sub-recipes asBellwetherDecoratedScanningRecipe. These wrappers are newScanningRecipeinstances created on every call, each with a new UUID-based accumulator key.RecipeRunCyclecreates aRecipeStackwhich cachesgetRecipeList()results in anIdentityHashMap— so within a single cycle, the wrappers are stable. But when a newRecipeRunCycleis created (as happens when the Moderne platform yields on large repositories), the freshRecipeStackcallsgetRecipeList()again, producing new wrappers with different UUIDs.The accumulator data stored on the
rootCursorunder the old UUID becomes unreachable. The new wrapper creates a fresh empty accumulator, and all scan data collected in previous batches is lost. The edit phase then finds nothing to change.The wrapping cascades through the entire recipe tree —
BellwetherDecoratedRecipe.getRecipeList()andBellwetherDecoratedScanningRecipe.getRecipeList()both calldecorateWithPreconditionBellwether()on their delegate's children. So anyScanningRecipeat any depth under a preconditioned parent is affected.Solution
Override
getAccumulator()inBellwetherDecoratedScanningRecipeto delegate to the wrapped recipe's accumulator. This uses the delegate's stable UUID (assigned once at construction) instead of the wrapper's ephemeral one, so accumulators survive acrossRecipeRunCycleboundaries regardless of how many times the wrapper is recreated.