3 releases (breaking)

Uses new Rust 2024

0.3.0 Mar 15, 2026
0.2.0 Feb 28, 2026
0.1.0 Feb 8, 2026

#373 in Rust patterns

MIT license

265KB
5.5K SLoC

portage-atom-resolvo

LICENSE Build Status codecov Crates.io dependency status docs.rs

Bridge between portage-atom and the resolvo SAT-based dependency solver.

Warning: This codebase was largely AI-generated (slop-coded) and has not yet been thoroughly audited. It may contain bugs, incomplete PMS coverage, or surprising edge-case behaviour. Use at your own risk and please report issues.

Quick start

cargo run --example resolve
cargo run --example resolve_conflict

See examples/resolve.rs for a complete walkthrough that builds an in-memory repository, declares transitive / any-of / slotted / USE-conditional dependencies, and prints the solved package set.

See examples/resolve_conflicts.rs for a the initial error reporting layout.

Feature checklist

Working

  • Version matching - all 7 PMS 8.3.1 operators (< <= = >= > ~ =*)
  • Transitive dependency resolution via resolvo's CDCL SAT solver
  • Newest-first version preference (sort_candidates descending)
  • || ( a b ) any-of groups -> Requirement::Union
  • USE-conditional deps (use? ( ... ), !use? ( ... )) - eagerly evaluated or solver-decided via UseConfig
  • Blockers (!atom, !!atom) -> resolvo constrains, with weak/strong distinction tracked via blocker_type()
  • Multi-slot coexistence (python:3.11 + python:3.12 in same solution)
  • Unslotted deps resolve across all known slots (union)
  • Slot-specific deps (:3.12) target only that slot's candidates
  • Slot operator :* (accept any slot)
  • Slot operator := tracking - is_rebuild_trigger() flags deps that need rebuilds on slot/subslot changes
  • Sub-slot matching - :SLOT/SUBSLOT constraints checked in filter_candidates
  • Strong vs weak blocker distinction - blocker_type() returns Blocker::Weak or Blocker::Strong
  • Repository constraint (::gentoo) - PackageMetadata::repo + VersionConstraint::repo filtering in filter_candidates
  • USE dep constraints on atoms ([ssl,-debug]) - all 6 PMS 8.3.4 variants, conditional forms resolved eagerly against UseConfig
  • DEPEND / RDEPEND / BDEPEND / PDEPEND / IDEPEND separation - PackageDeps struct with per-class fields, all treated as requirements
  • Arena-based interning with dedup for names and version sets
  • InMemoryRepository for testing
  • Public API: intern_requirement() -> Problem -> Solver::solve()
  • Circular dependency handling via PDEPEND - dependency_graph() returns dep-class–labeled edges, install_order() uses Kahn's toposort with PDEPEND relaxation
  • Installed-package database - InstalledSet + with_installed() constructor; Candidates::favored (soft preference) and Candidates::locked (hard constraint) per name

Not yet implemented

  • Better human-readable conflict/error reporting

Architecture

lib.rs               re-exports
version_match.rs     version_matches(candidate, op, constraint) -> bool
pool.rs              PortagePool arena (resolvo IDs <-> portage-atom types)
repository.rs        PackageRepository trait + InMemoryRepository
provider.rs          Interner + DependencyProvider impl

Running checks

cargo test                        # 75 tests
cargo clippy -- -D warnings       # clean
cargo fmt --check                 # formatted
cargo doc --no-deps               # no warnings
  • PMS - Package Manager Specification
  • Portage - Reference Gentoo package manager
  • pkgcraft - Full-featured Gentoo package manager library

License

MIT

Contributing

Contributions welcome! Please ensure:

  • Tests pass (cargo test)
  • Code is formatted (cargo fmt)
  • No clippy warnings (cargo clippy)
  • PMS compliance is maintained

Conventional Commits

This project uses Conventional Commits. Prefix your commit messages with a type:

  • feat: — new functionality
  • fix: — bug fix
  • refactor: — code restructuring without behaviour change
  • docs: — documentation only
  • test: — adding or updating tests
  • chore: — maintenance (CI, dependencies, tooling)

Author

Luca Barbato lu_zero@gentoo.org

Dependencies

~14MB
~187K SLoC