test: rector edit-staleness regression (warm container re-reads edited files)#1
Merged
Merged
Conversation
Proves Rector's warm container has no #265-class staleness: unlike phpunit (which *executes* user classes and can't reload them after an edit), Rector parses source to an AST and re-reads it each run. testEditedSourceIsReprocessedAcrossCalls runs a clean fixture (0 changed), introduces an all-readonly promoted class on disk (1 changed via ReadOnlyClassRector), and asserts the same warm container reports it. Review hardening: - Pin the SINGLE rule (ReadOnlyClassRector) instead of withPhpSets(php82): a broad set's "0 changes" baseline isn't stable across rector versions and could fail for the wrong reason. - Capture server stderr to a file (was /dev/null) and surface it in failure messages. - Assert warm_boot before changed_files; guard the unparseable-output sentinel (-1). - Bump composer.json floor rector/rector ^2.0 -> ^2.4: 2.2.7 is incompatible with current phpstan (OptimizedSingleFileSourceLocator $cache arg string->Cache) and errored on single-file analysis. composer.lock is gitignored, so the floor is what prevents a regenerated lock from pinning the broken version. (DVSI was never affected — resolves its own newer rector.) Ran on rector 2.4.5 / phpstan 2.2.1. Suite 7/7. Co-Authored-By: Max <noreply>
3e2773b to
66f4663
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.
Context
Completes the warm-MCP staleness audit (after the phpunit fork-per-call fix, claude-supertool#265). Rector parses source to an AST and re-reads each run — so it shouldn't go stale after an edit, unlike phpunit which executes classes. This proves it.
Test
testEditedSourceIsReprocessedAcrossCalls: spawns the server once, processes a clean fixture (0 changed files), edits it on disk to an all-readonly promoted class (ReadOnlyClassRector→ 1 changed,touch-bumps mtime), processes again on the same warm container, assertschanged_files0→1. Interleaved stdio so the edit lands between calls.Heads-up (no code change here)
While writing this I hit a version skew: a stale local
composer.lockpinned rector 2.2.7, which is incompatible with phpstan 2.1.55 (OptimizedSingleFileSourceLocator$cache arg changed string→Cache) → errored on single-file analysis.composer.lockis gitignored, so a freshcomposer installresolves the latest rector (2.4.5) and is unaffected; DVSI is also unaffected (resolves its own newer rector).Optional hardening (not done here, your call): bump
composer.jsonfloorrector/rector: ^2.0→^2.4so a regenerated lock can never pin the broken 2.2.7.Ran on rector 2.4.5 / phpstan 2.2.1. Suite 7/7 green.