Skip to content

test: rector edit-staleness regression (warm container re-reads edited files)#1

Merged
fdaviddpt merged 1 commit into
mainfrom
fix/bump-rector-and-staleness-test
May 30, 2026
Merged

test: rector edit-staleness regression (warm container re-reads edited files)#1
fdaviddpt merged 1 commit into
mainfrom
fix/bump-rector-and-staleness-test

Conversation

@fdaviddpt
Copy link
Copy Markdown
Contributor

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, asserts changed_files 0→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.lock pinned rector 2.2.7, which is incompatible with phpstan 2.1.55 (OptimizedSingleFileSourceLocator $cache arg changed string→Cache) → errored on single-file analysis. composer.lock is gitignored, so a fresh composer install resolves 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.json floor rector/rector: ^2.0^2.4 so 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.

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>
@fdaviddpt fdaviddpt force-pushed the fix/bump-rector-and-staleness-test branch from 3e2773b to 66f4663 Compare May 30, 2026 08:07
@fdaviddpt fdaviddpt merged commit 7882aba into main May 30, 2026
3 checks passed
@fdaviddpt fdaviddpt deleted the fix/bump-rector-and-staleness-test branch May 30, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant