Skip to content

Own the autoload map through ComposerAutoloadMapReader - #641

Merged
Firehed merged 8 commits into
mainfrom
step/11-autoload-map-source
Sep 27, 2026
Merged

Firehed merged 8 commits into
mainfrom
step/11-autoload-map-source

Conversation

@Firehed

@Firehed Firehed commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Summary

One service now owns reading the Composer autoload map.
ComposerAutoloadMapReader reads the map on first use and re-reads it when any file under vendor/composer/ changes — the one invalidatable for that path.
Both disk backends (AutoloadFilesBackend and ComposerMapBackend) hold the reader instead of a map snapshot and rebuild their derived indexes when the map instance changes.

Previously, the map was read once at boot into a value passed by construction to both backends, and a composer install that regenerated the autoload files could not reach either backend's derived state.
Now a regeneration reaches lookup, enumeration and search on the next query.

The invalidation composite routes vendor/composer/ paths through a wholesale flush of the maps cache decorator, since its per-path accounting cannot describe the blast radius of a whole-map change.

Test plan

  • composer test (phpstan, deptrac, phpunit, phpcs) green
  • New unit tests for ComposerAutoloadMapReader cover current/invalidate/fromMap and the vendor/composer prefix match
  • New integration test covers the end-to-end flow: a regenerated autoload_psr4.php and autoload_files.php each reach both lookup and enumeration on the next query

🤖 Generated with Claude Code

A single service now reads the Composer autoload map and re-reads it on
vendor/composer changes. Both disk backends hold the reader instead of a
snapshot and rebuild their derived indexes when the map instance changes,
so a composer install reaches lookup, enumeration and search on the next
query rather than being trapped in a map copied at boot.

The invalidation composite routes vendor/composer paths past the maps
cache decorator's per-path accounting through a wholesale flush, since
every remembered lookup can point at pre-install data.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.65%. Comparing base (259ce1a) to head (36b3e4f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #641   +/-   ##
=========================================
  Coverage     99.65%   99.65%           
- Complexity     1901     1913   +12     
=========================================
  Files           133      134    +1     
  Lines          4905     4940   +35     
=========================================
+ Hits           4888     4923   +35     
  Misses           17       17           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Firehed
Firehed marked this pull request as ready for review September 26, 2026 17:02
Firehed and others added 6 commits September 26, 2026 11:12
Adds unit tests for the flush() method on the maps cache decorator, the
composer-file branch of the invalidation composite, and the map-change
branch of ComposerMapBackend's invalidate. Integration coverage stays,
but those tests are #[CoversNothing] so their execution did not attribute
line coverage to the classes under test.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Firehed
Firehed merged commit 4c534ba into main Sep 27, 2026
9 checks passed
@Firehed
Firehed deleted the step/11-autoload-map-source branch September 27, 2026 14:58
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