[ax] Add --max-changes option to stop after N changes - #8449
Merged
Conversation
TomasVotruba
force-pushed
the
tv-max-changes
branch
from
September 3, 2026 21:47
27df6ec to
01c9334
Compare
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.
Why
Agents and scripts running Rector unattended need a blast-radius rail: apply a bounded number of changes per run, review, then continue - instead of rewriting a whole codebase in one pass. There was no way to cap how much a single run does.
What
New
--max-changes=Noption. Once N changes (rule applications) have been made, the run stops and leaves the remaining files untouched.rector process --dry-run --max-changes=50 # > stops once 50 changes are reached, rest skippedNcounts changes (rule applications, i.e.RectorWithLineChangeentries), not files - a single file can carry several.ApplicationFileProcessor::processFiles): after each file, if the cumulative change count reached the limit, break.--max-changesforces a single-process run (same approach--debuguses).Nmust be a positive integer;0or non-numeric is rejected.The changes made before the stop are kept (written on a real run, shown on
--dry-run) - the point is a bounded chunk of work, not a rollback.Tests
testMaxChangesStopsAfterLimitinApplicationFileProcessorTest: two files, 2 closures (= 2 changes) each;--max-changes=2stops after the first file -> only 1 file diff, proving changes are counted, not files.composer check-cs,composer phpstanclean; verified on the CLI.