From b60cf8d9cb6776e5df85f080b5bb3fba252e154c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 2 May 2026 22:59:23 +0900 Subject: fix(resolver): honor root self-provide/replace as require fulfilment Port Composer's RuleSetGenerator::createRequireRule self-fulfilling branch: when the root composer.json's `provide` or `replace` covers a name it also requires (with intersecting constraints), skip emitting an install-one-of rule for that root require. Composer relies on the root package being a fixed entry in the pool so whatProvides() includes it; Mozart does not yet add the root to the pool, so the same decision is made via explicit `root_provide` / `root_replace` tables threaded through ResolveRequest. Without this, an inline repo package whose name matches the root's provide was being force-installed. Fixes installer fixtures `provider_satisfies_its_own_requirement` and `replacer_satisfies_its_own_requirement`. --- crates/mozart/src/commands/update.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/mozart/src/commands/update.rs') diff --git a/crates/mozart/src/commands/update.rs b/crates/mozart/src/commands/update.rs index 847ccf7..33b305a 100644 --- a/crates/mozart/src/commands/update.rs +++ b/crates/mozart/src/commands/update.rs @@ -887,6 +887,16 @@ pub async fn run( repositories: repositories.clone(), temporary_constraints, raw_repositories: composer_json.repositories.clone(), + root_provide: composer_json + .provide + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(), + root_replace: composer_json + .replace + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(), }; // Step 6: Print header and run resolver @@ -1994,6 +2004,8 @@ mod tests { ), temporary_constraints: HashMap::new(), raw_repositories: vec![], + root_provide: HashMap::new(), + root_replace: HashMap::new(), }; let resolved = resolve(&request).await.expect("Resolution should succeed"); -- cgit v1.3.1