From 5b767cdd832d39816ee4c2dbf94274c0130dd572 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 2 May 2026 17:01:54 +0900 Subject: refactor(registry): route Packagist queries through RepositorySet Replace direct packagist::fetch_package_versions calls in resolver::resolve (seed + transitive loops) and lockfile::generate_lock_file with repo_set.load_packages calls. PackagistRepository now propagates errors instead of swallowing them, so the seed loop's strictness and the transitive loop's local-leniency are both preserved exactly. VCS and inline-package repositories are still preloaded directly into the pool builder for now, with their names tracked in skip lists so we don't double-load them through the trait. Migrating them through RepositorySet is a follow-up - vcs_to_pool_inputs and packagist_to_pool_inputs differ in dev-branch handling that needs to be unified first. All 136 enabled installer fixtures + 114 mozart-registry tests + 541 mozart lib tests remain green; clippy clean. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../src/repository/packagist_repo.rs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'crates/mozart-registry/src/repository') diff --git a/crates/mozart-registry/src/repository/packagist_repo.rs b/crates/mozart-registry/src/repository/packagist_repo.rs index 17208c1..a3bbf40 100644 --- a/crates/mozart-registry/src/repository/packagist_repo.rs +++ b/crates/mozart-registry/src/repository/packagist_repo.rs @@ -32,19 +32,19 @@ impl Repository for PackagistRepository { async fn load_packages(&self, queries: &[PackageQuery<'_>]) -> anyhow::Result { let mut result = LoadResult::default(); for query in queries { - // Mirror the existing transitive-loop tolerance: a 404 / network - // failure for one name is not fatal — it just means this repo - // contributes nothing for that name. `RepositorySet` falls - // through, and the solver fails later if no repo knows it. + // Errors propagate to the caller. Composer's + // `ComposerRepository::loadAsyncPackages` distinguishes 404 + // (empty result, no error) from transport failures (exception); + // Mozart's underlying `fetch_package_versions` doesn't yet make + // that distinction, so for now both surface as `Err` and the + // caller decides whether the loop wants to continue (transitive + // exploration) or abort (seed-time fetch failure). let versions = - match packagist::fetch_package_versions(query.name, &self.cache).await { - Ok(v) => v, - Err(_) => continue, - }; - // `fetch_package_versions` returning Ok counts as "this repo - // authoritatively knows the name", even if the version list is - // empty (matches Composer `ArrayRepository::loadPackages` which - // adds the name to `namesFound` regardless of constraint match). + packagist::fetch_package_versions(query.name, &self.cache).await?; + // A successful fetch counts as "this repo authoritatively knows + // the name", even if the version list is empty — mirrors + // Composer's `ArrayRepository::loadPackages` which adds the + // name to `namesFound` regardless of constraint match. result.names_found.push(query.name.to_string()); for version in versions { result.packages.push(NamedPackagistVersion { -- cgit v1.3.1