Reconcile dependency overlay to consumer autoload layout#1955
Merged
Conversation
A composer-package dependency overlay is mounted at the consumer's vendor/<package> path and autoloaded through the consumer's committed PSR-4 map, not the override's own. When the override ships a different PSR-4 source layout than the consumer recorded (e.g. a repo published as src/ but consumed as php-transformer/src/), the mounted class files landed where the consumer autoloader never looks, so the override was silently ignored and the pinned released version kept running. Relocate the staged overlay's PSR-4 source directories to the paths the consumer's autoloader resolves before mounting, staging a copy so the caller's checkout is never restructured in place. Add a regression smoke.
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
A
composer-packagedependency overlay is mounted at the consumer plugin'svendor/<package>path and autoloaded through the consumer's committed PSR-4 map, not the override's own. When the override checkout ships a different PSR-4 source layout than the consumer recorded, the mounted class files land where the consumer autoloader never looks, so the override is silently ignored and the consumer keeps running its pinned, released dependency.Concrete repro: the Blocks Engine PHP transformer publishes its classes under
src/(the package root isphp-transformer/), but a consumer that installs it from the GitHub release zip records it underphp-transformer/src/(the zip extracts the whole repo). Overlaying the override'sphp-transformer/subdir mounts itssrc/atvendor/<pkg>/src/, while the consumer's autoloader resolvesvendor/<pkg>/php-transformer/src/. The override never loads.Fix
Before mounting, reconcile the staged overlay's PSR-4 source directories to the paths the consumer's committed autoloader resolves for the same package (read from the consumer's
vendor/composer/installed.json). The single vendor-path mount contract is unchanged. The caller's checkout is never restructured in place — when the hydrated source is still the original directory, a copy is staged first.Reconciliation is conservative: it only relocates single-directory PSR-4 mappings whose namespace exists in both the consumer and override maps and whose normalized source dirs differ. Multi-directory prefixes and
..-bearing paths are left untouched.Tests
scripts/composer-package-overlay-autoload-layout-smoke.tsproving an override published assrc/and consumed asphp-transformer/src/is relocated to the consumer layout, that the override checkout is not mutated in place, and that the vendor-path mount target is unchanged. Registered inpackage.jsonandsmoke-manifest.ts.composer-backed-source-hydration-smoke(overlay revision preservation) still passes.tsc -bclean.Reproduce