mamba-org / resolvo

Fast package resolver written in Rust (CDCL based SAT solving)
BSD 3-Clause "New" or "Revised" License
160 stars 13 forks source link

feat(solver)!: Solve for optional solvables in addition to the root solvable #54

Closed eviltak closed 3 months ago

eviltak commented 3 months ago

Adds a new Solver::solve_with_additional method, that solves for the provided root_requirements and root_constraints, along with a set of additional (optional) solvables. Unless the corresponding package has been requested by a version set in another solvable's clauses, each additional solvable is not subject to the package-level clauses introduced in DependencyProvider::get_candidates since the solvables have been requested specifically (and not through a version set).

This feature is useful for situations where you want to ensure that particular solvables (for example, previously installed solvables) are compatible with the solution to the root requirements and constraints.

The implementation is facilitated by making the run_sat method solve for arbitrary solvables at arbitrary levels, not just the root solvable. This allows the solver to solve for the additional solvables after solving for the root solvable while taking into account the clauses and decisions introduced in the solving process.

Breaking changes

Existing users will have to change the code that calls Solver::solve to pass in an instance of the Problem struct rather than passing in the root_requirements and root_constraints directly as arguments to the method.

baszalmstra commented 3 months ago

Sorry, Im a bit busy with other things atm! Will get back to this PR as soon as I can.

eviltak commented 3 months ago

I'll do this in the next few hours, so it should be ready for you to merge tomorrow. Thanks for your help!

eviltak commented 3 months ago

Rebased onto main with all conflicts fixed.

baszalmstra commented 3 months ago

Thank you!