uv/vendor/pubgrub
Charlie Marsh 471a1d657d
Migrate resolver proof-of-concept to PubGrub (#97)
## Summary

This PR enables the proof-of-concept resolver to backtrack by way of
using the `pubgrub-rs` crate.

Rather than using PubGrub as a _framework_ (implementing the
`DependencyProvider` trait, letting PubGrub call us), I've instead
copied over PubGrub's primary solver hook (which is only ~100 lines or
so) and modified it for our purposes (e.g., made it async).

There's a lot to improve here, but it's a start that will let us
understand PubGrub's appropriateness for this problem space. A few
observations:

- In simple cases, the resolver is slower than our current (naive)
resolver. I think it's just that the pipelining isn't as efficient as in
the naive case, where we can just stream package and version fetches
concurrently without any bottlenecks.
- A lot of the code here relates to bridging PubGrub with our own
abstractions -- so we need a `PubGrubPackage`, a `PubGrubVersion`, etc.
2023-10-15 22:05:44 -04:00
..
benches Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
examples Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
src Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
test-examples Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
tests Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
Cargo.toml Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
CHANGELOG.md Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
LICENSE Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00
README.md Migrate resolver proof-of-concept to PubGrub (#97) 2023-10-15 22:05:44 -04:00

PubGrub version solving algorithm

license crates.io docs.rs guide

Version solving consists in efficiently finding a set of packages and versions that satisfy all the constraints of a given project dependencies. In addition, when that is not possible, PubGrub tries to provide a very human-readable and clear explanation as to why that failed. The introductory blog post about PubGrub presents one such example of failure explanation:

Because dropdown >=2.0.0 depends on icons >=2.0.0 and
  root depends on icons <2.0.0, dropdown >=2.0.0 is forbidden.

And because menu >=1.1.0 depends on dropdown >=2.0.0,
  menu >=1.1.0 is forbidden.

And because menu <1.1.0 depends on dropdown >=1.0.0 <2.0.0
  which depends on intl <4.0.0, every version of menu
  requires intl <4.0.0.

So, because root depends on both menu >=1.0.0 and intl >=5.0.0,
  version solving failed.

This pubgrub crate provides a Rust implementation of PubGrub. It is generic and works for any type of dependency system as long as packages (P) and versions (V) implement the provided Package and Version traits.

Using the pubgrub crate

A guide with both high-level explanations and in-depth algorithm details is available online. The API documentation is available on docs.rs. A version of the API docs for the unreleased functionality from dev branch is also accessible for convenience.

Contributing

Discussion and development happens here on GitHub and on our Zulip stream. Please join in!

Remember to always be considerate of others, who may have different native languages, cultures and experiences. We want everyone to feel welcomed, let us know with a private message on Zulip if you don't feel that way.

PubGrub

PubGrub is a version solving algorithm, written in 2018 by Natalie Weizenbaum for the Dart package manager. It is supposed to be very fast and to explain errors more clearly than the alternatives. An introductory blog post was published on Medium by its author.

The detailed explanation of the algorithm is provided on GitHub, and complemented by the "Internals" section of our guide. The foundation of the algorithm is based on ASP (Answer Set Programming), and a book called "Answer Set Solving in Practice" by Martin Gebser, Roland Kaminski, Benjamin Kaufmann and Torsten Schaub.