From c53dfc52f6449c8d5ca0b160a2a25f99790711f2 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 3 May 2026 12:36:34 +0900 Subject: fix(resolver): carry root composer.json conflicts onto the in-pool root entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The root pool entry now seeded from composer.json carried provides and replaces but no conflicts, so a root-level conflict like \`{"some/dep": ">=1.3"}\` was silently dropped. Composer keeps these on the RootPackage (which lives in the pool via RootPackageRepository), and the SAT generator turns them into rules that forbid any candidate matching the constraint — including a branch alias that would resolve to a matching version. Without that, Mozart cheerfully installs both the required dev branch and its conflicting alias. Plumb composer.json's \`conflict\` map through ResolveRequest as root_conflict and project it onto the root pool entry as PoolLink conflicts; all callers updated. Unblocks conflict_on_root_with_alias_prevents_update_if_not_required and conflict_with_alias_prevents_update installer fixtures. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/mozart-registry/src/lockfile.rs | 1 + crates/mozart-registry/src/resolver.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'crates/mozart-registry/src') diff --git a/crates/mozart-registry/src/lockfile.rs b/crates/mozart-registry/src/lockfile.rs index 447e2cf..77a6b4c 100644 --- a/crates/mozart-registry/src/lockfile.rs +++ b/crates/mozart-registry/src/lockfile.rs @@ -1405,6 +1405,7 @@ mod tests { raw_repositories: vec![], root_provide: IndexMap::new(), root_replace: IndexMap::new(), + root_conflict: IndexMap::new(), }; let resolved = resolve(&resolve_request) diff --git a/crates/mozart-registry/src/resolver.rs b/crates/mozart-registry/src/resolver.rs index adc8780..48db7c3 100644 --- a/crates/mozart-registry/src/resolver.rs +++ b/crates/mozart-registry/src/resolver.rs @@ -611,6 +611,13 @@ pub struct ResolveRequest { /// Root composer.json's `replace` map. Same role as `root_provide` for the /// `replace` link: a replaced target counts as fulfilled by the root. pub root_replace: IndexMap, + /// Root composer.json's `conflict` map (target → constraint). Composer's + /// `RootPackageRepository` carries these onto the in-pool root package + /// entry; the SAT generator then forbids any candidate matching the + /// constraint, so a root `conflict` blocks both direct selection of the + /// targeted version and any alias / replace / provide that would resolve + /// to it. + pub root_conflict: IndexMap, } /// A single package in the resolution output. @@ -776,7 +783,15 @@ pub async fn resolve(request: &ResolveRequest) -> Result, R source: root_name_lower.clone(), }) .collect(), - conflicts: vec![], + conflicts: request + .root_conflict + .iter() + .map(|(target, constraint)| PoolLink { + target: target.to_lowercase(), + constraint: constraint.clone(), + source: root_name_lower.clone(), + }) + .collect(), is_fixed: true, is_alias_of: None, }; @@ -1410,6 +1425,7 @@ mod tests { raw_repositories: vec![], root_provide: IndexMap::new(), root_replace: IndexMap::new(), + root_conflict: IndexMap::new(), }; let result = resolve(&request).await; -- cgit v1.3.1