collections/dependency_resolver_utils library
Dependency resolver with version constraints — roadmap #540.
Given a universe of available package versions (each with its own dependency
constraints) and a set of root requirements, pick one concrete version per
package that satisfies every accumulated constraint, then return a
topological install order (dependencies before dependents). Reuses the
existing compareVersions for version ordering and topologicalSort for the
install order + cycle detection.
Resolution is greedy highest-version over a fixpoint worklist: constraints accumulate monotonically and each package's chosen version only ever moves DOWN its candidate list as more constraints arrive, so it terminates. It does NOT backtrack — a constraint contributed by a later-superseded version is not retracted — so a pathological diamond can over-constrain. This matches simple lock-file resolution, not a full SAT solver.
Classes
- DependencyResolution
- The outcome of a successful resolution: the chosen versions per package and an installOrder with dependencies ahead of the packages that need them.
- PackageManifest
-
One available package version and the constraints it places on its own
dependencies (
depName → constraint string, e.g.'^1.2.0').
Functions
-
resolveDependencies(
{required Map< String, String> root, required List<PackageManifest> universe}) → DependencyResolution -
Resolves
root(depName → constraint) againstuniverse(every available package version), returning the chosen versions and a topological install order. Throws DependencyResolutionException on an unknown package, an unsatisfiable constraint set, or a cycle. Audited: 2026-06-12 11:26 EDT
Exceptions / Errors
- DependencyResolutionException
- Thrown when resolution cannot complete: an unknown package, no version satisfying the constraints, or a dependency cycle.