#pragma once #include #include #include #include #include #include #include #include #include namespace Void::Build::Package { // Registry authority is an explicit part of package identity to prevent cross-registry // substitution. struct PackageId { std::string registry_authority; std::string name; auto operator<=>(const PackageId &) const = default; [[nodiscard]] std::string format() const; }; struct DependencyConstraint { PackageId target; std::string range_expr; std::vector required_features; std::string origin_label; }; struct BinaryVariantMeta { std::string variant_id; std::string os; std::string architecture; std::string compiler_family; std::string compiler_abi; std::string stdlib_abi; std::string linkage; std::string cpu_features; std::string sanitizers_key; std::string lto_mode; std::string dependency_closure_hash; std::string sha256; std::string download_url; }; struct ReleaseRecord { PackageId id; Void::Semver::Version version; bool yanked{false}; std::string source_sha256; std::string source_url; std::vector dependencies; std::vector binaries; }; class PackageIndex { public: void add_release(ReleaseRecord release); [[nodiscard]] std::vector releases_for(const PackageId &id) const; private: std::map> releases_; }; struct SolvedPackage { PackageId id; Void::Semver::Version version; std::string source_sha256; std::string source_url; std::set enabled_features; std::vector dependencies; std::vector binaries; }; struct SolveResult { std::map packages; // Deterministically ordered. }; struct SolveOptions { // Already-pinned compatible versions from an existing lockfile (never silently upgraded!). std::map pinned_versions; bool allow_yanked_if_pinned{true}; std::size_t max_steps{50000}; }; // Deterministic PubGrub-style SemVer dependency solver (Plan 11): // - One version per PackageId per resolution context // - Prefers compatible pinned versions; otherwise picks highest non-yanked matching version // - Produces human-readable incompatibility chains on unsatisfiable graphs. [[nodiscard]] Void::Result::Result solve_dependencies(const std::vector &root_constraints, const PackageIndex &index, const SolveOptions &options = {}); } // namespace Void::Build::Package