From ba1463ea86ad25b910fff13d8527ac2c0f661ab4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 4 May 2026 09:54:09 +0900 Subject: fix(resolver): expose locked branch-alias entries in the pool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Composer's Locker::getLockedRepository runs each locked package through ArrayLoader::load, which materializes any extra.branch-alias as a separate AliasPackage in the locked repository. Mozart was only adding the base locked package to the pool, so a `dev-master` locked entry with branch alias `2.2.x-dev` was invisible to numeric root constraints like `~2.1` on a partial update — the resolver bailed with "no matching package found" even though Composer accepts the same lock. Surface each branch-alias as a sibling pool entry pointing at the base via is_alias_of. --- crates/mozart-registry/src/resolver.rs | 20 ++++++++++++++++++++ crates/mozart/tests/installer.rs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/mozart-registry/src/resolver.rs b/crates/mozart-registry/src/resolver.rs index 87a92e9..5dbe74f 100644 --- a/crates/mozart-registry/src/resolver.rs +++ b/crates/mozart-registry/src/resolver.rs @@ -1165,6 +1165,26 @@ pub async fn resolve(request: &ResolveRequest) -> Result, R is_alias_of: None, }; builder.add_package(input); + // Also expose each `extra.branch-alias` entry as a separate pool + // package, mirroring `Composer\Package\Locker::getLockedRepository` + // (which calls `ArrayLoader::load`, which materializes the + // branch-alias via `getBranchAlias`). Without this, a `dev-master` + // locked package with branch alias `2.2.x-dev` is only visible + // under `dev-master` in the pool, so root requires like `~2.1` + // see no candidate and the resolver fails on a partial update. + for (alias_pretty, alias_normalized) in &locked.branch_aliases { + builder.add_package(PoolPackageInput { + name: locked_name_lower.clone(), + version: alias_normalized.clone(), + pretty_version: alias_pretty.clone(), + requires: make_pool_links(&locked_name_lower, alias_normalized, &locked.requires), + replaces: make_pool_links(&locked_name_lower, alias_normalized, &locked.replaces), + provides: make_pool_links(&locked_name_lower, alias_normalized, &locked.provides), + conflicts: make_pool_links(&locked_name_lower, alias_normalized, &locked.conflicts), + is_fixed: false, + is_alias_of: Some(locked.version_normalized.clone()), + }); + } } // Scan VCS repositories and collect packages from them diff --git a/crates/mozart/tests/installer.rs b/crates/mozart/tests/installer.rs index 729e9db..b1c1968 100644 --- a/crates/mozart/tests/installer.rs +++ b/crates/mozart/tests/installer.rs @@ -314,7 +314,7 @@ installer_fixture!(partial_update_downgrades_non_allow_listed_unstable); installer_fixture!(partial_update_forces_dev_reference_from_lock_for_non_updated_packages); installer_fixture!(partial_update_from_lock); installer_fixture!(partial_update_from_lock_with_root_alias); -installer_fixture!(partial_update_installs_from_lock_even_missing, ignore); +installer_fixture!(partial_update_installs_from_lock_even_missing); installer_fixture!(partial_update_keeps_older_dep_if_still_required); installer_fixture!(partial_update_keeps_older_dep_if_still_required_with_provide); installer_fixture!(partial_update_loads_root_aliases_for_path_repos); -- cgit v1.3.1