Skip to content

Reconcile dependency overlay to consumer autoload layout#1955

Merged
chubes4 merged 1 commit into
mainfrom
fix/dependency-overlay-consumer-autoload-path
Jul 22, 2026
Merged

Reconcile dependency overlay to consumer autoload layout#1955
chubes4 merged 1 commit into
mainfrom
fix/dependency-overlay-consumer-autoload-path

Conversation

@chubes4

@chubes4 chubes4 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

A composer-package dependency overlay is mounted at the consumer plugin's vendor/<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 is php-transformer/), but a consumer that installs it from the GitHub release zip records it under php-transformer/src/ (the zip extracts the whole repo). Overlaying the override's php-transformer/ subdir mounts its src/ at vendor/<pkg>/src/, while the consumer's autoloader resolves vendor/<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

  • New scripts/composer-package-overlay-autoload-layout-smoke.ts proving an override published as src/ and consumed as php-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 in package.json and smoke-manifest.ts.
  • Existing composer-backed-source-hydration-smoke (overlay revision preservation) still passes.
  • tsc -b clean.

Reproduce

npm install
npm run test:composer-package-overlay-autoload-layout
npm run test:composer-package-overlay-revision

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.
@chubes4
chubes4 merged commit 9f14491 into main Jul 22, 2026
4 checks passed
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