pubsat 0.1.0

Building blocks for SAT-based dependency resolvers: a node-semver-compatible range parser, an ecosystem-independent constraint vocabulary, and a backend-agnostic SAT problem/solver abstraction with a Varisat backend.
Documentation
//! # pubsat — SAT-based dependency resolution
//!
//! `pubsat` is a backend-agnostic, ecosystem-agnostic SAT-based
//! dependency resolver for semver-shaped constraint problems. The
//! same engine should serve a JS-style package manager, a private
//! artifact registry, a build-tool internal resolver, or any
//! other workflow with a "pick the right versions" sub-problem.
//!
//! ## Modules
//!
//! - [`version`] — node-semver-compatible range parser (caret,
//!   tilde, hyphen, x-ranges, unions, dist tags) with
//!   [`VersionSet`](version::VersionSet) operations.
//! - [`constraint`] — ecosystem-independent
//!   [`Constraint`](constraint::Constraint) vocabulary.
//! - [`registry`] — [`PackageRegistry`](registry::PackageRegistry)
//!   trait, single-flighted [`CachedRegistry`](registry::CachedRegistry)
//!   wrapper, and in-process [`MockRegistry`](registry::MockRegistry).
//! - [`graph`] — [`DependencyGraph`](graph::DependencyGraph)
//!   (petgraph-backed) with cycle detection.
//! - [`encoding`] —
//!   [`ConstraintEncoder`](encoding::ConstraintEncoder) lowering
//!   constraints to CNF.
//! - [`builder`] —
//!   [`DependencyGraphBuilder`](builder::DependencyGraphBuilder)
//!   that walks a registry concurrently.
//! - [`resolver`] —
//!   [`DependencyResolver`](resolver::DependencyResolver) that
//!   orchestrates the full pipeline with greedy "prefer newest"
//!   SAT assumptions.
//! - [`sat`] — backend-agnostic SAT types and the
//!   [`SatSolver`](sat::SatSolver) trait, with a
//!   [`VarisatSolver`](sat::VarisatSolver) impl behind the default
//!   `varisat-solver` feature.
//! - [`error`] — [`ResolutionError`](error::ResolutionError),
//!   [`SatError`](error::SatError), and their `Result` aliases.
//!
//! ## Example: parse and evaluate a range
//!
//! ```
//! use pubsat::version::VersionSet;
//! use semver::Version;
//! use std::str::FromStr;
//!
//! let range: VersionSet = "^1.2.3".parse().unwrap();
//! assert!(range.satisfies(&Version::from_str("1.5.0").unwrap()));
//! assert!(range.satisfies(&Version::from_str("1.2.3").unwrap()));
//! assert!(!range.satisfies(&Version::from_str("2.0.0").unwrap()));
//! assert!(!range.satisfies(&Version::from_str("1.2.2").unwrap()));
//! ```
//!
//! ## Example: end-to-end resolution
//!
//! ```
//! # #[cfg(feature = "varisat-solver")]
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() {
//! use std::sync::Arc;
//! use pubsat::builder::DependencyGraphBuilder;
//! use pubsat::registry::{MockRegistry, VersionMetadata};
//! use pubsat::resolver::DependencyResolver;
//! use pubsat::version::VersionSet;
//! use semver::Version;
//!
//! let vs = |s: &str| -> VersionSet { s.parse().unwrap() };
//!
//! let registry = Arc::new(
//!     MockRegistry::new()
//!         .with_versions("chalk", &["4.1.0", "5.0.0"])
//!         .with_versions("ansi-styles", &["4.3.0", "6.2.1"])
//!         .with_dependency("chalk", "4.1.0", "ansi-styles", vs("^4.0.0"))
//!         .with_dependency("chalk", "5.0.0", "ansi-styles", vs("^6.0.0")),
//! );
//!
//! let root = VersionMetadata::new("my-app", Version::new(1, 0, 0))
//!     .with_dependency("chalk", vs("^5.0.0"));
//!
//! let graph = DependencyGraphBuilder::new(registry.clone())
//!     .build(root)
//!     .await
//!     .unwrap();
//!
//! let resolution = DependencyResolver::new(registry)
//!     .resolve(graph)
//!     .await
//!     .unwrap();
//!
//! // resolution.packages: [ansi-styles@6.2.1, chalk@5.0.0]
//! assert_eq!(resolution.packages.len(), 2);
//! # }
//! ```
//!
//! ## Design context
//!
//! See [`docs/design/architecture.md`][arch] for the design
//! rationale (why SAT and not PubGrub, hot-path lessons, the
//! comparison with prior art).
//!
//! [arch]: https://github.com/cygnus-io/pubsat/blob/main/docs/design/architecture.md

#![doc(html_root_url = "https://docs.rs/pubsat")]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod builder;
pub mod constraint;
pub mod encoding;
pub mod error;
pub mod graph;
pub mod registry;
pub mod resolver;
pub mod sat;
pub mod version;

#[cfg(test)]
mod tests {
    #[test]
    fn crate_compiles() {
        // Per-module tests cover real behavior.
    }
}