0239. Minimal version selection
- Status: Accepted (maintainer, 2026-11-15); supersedes 0202
- Date: 2026-11-15
- Plan: M15.5; RG1.2, RG2.1
- Review: Data, schemas and wire formats
Context
ADR-0202 proposed exact and caret requirements solved by deterministic bounded backtracking in descending order, with a search budget that can refuse a solvable graph. Harness allows one version and one source per package name (E0939), and manifests validate three decimal components. Go's minimal version selection (research.swtch.com/vgo-mvs) is a graph traversal with no search: the answer depends only on the manifests, so a newly published release never changes a build.
Decision
Keep exact (1.2.3 / =1.2.3) and caret
(^1.2.3) requirements with 0202's caret table:
^1.2.3 is >=1.2.3,<2.0.0,
^0.2.3 is >=0.2.3,<0.3.0,
^0.0.3 is exactly 0.0.3. No prerelease,
ranges, wildcards or latest in manifests.
Resolve with Go-style MVS. For each package name, select the maximum of the minimum versions required by any node reachable in the requirement graph; this is the oldest version that satisfies every minimum. Then check the selection is below every caret upper bound and equals every exact pin; if not, fail with both requirer chains. No backtracking and no search budget. If the selected minimum is unpublished or yanked, take the oldest unyanked published version above it within all bounds. Versions compare numerically by component, by digit count then bytes, with no overflow.
Resolution happens only in fetch. Upgrades are
explicit: harness add [email protected] or
fetch --update util, which rewrite the manifest
minimum. The lock pins integrity hashes; it is not needed to
reproduce the selection. Yanked versions are skipped for new
selection but keep building when locked.
Alternatives considered
- Bounded backtracking, newest first (0202) — a new release can change a fresh resolution, and the budget makes some solvable graphs fail with a limit error.
- PubGrub / SAT (Dart pub, uv) — good errors for multi-version ecosystems; more code than a one-version-per-name world needs.
- Newest compatible greedy — not reproducible without a lock.
- Exact pins only — smallest, but every transitive bump is manual.
Consequences
The resolver is a few hundred lines and deterministic. Users get the oldest version that works, so upgrades are slower and deliberate. A caret upper bound below another package's minimum is an error with a clear chain; no single-version solution exists then anyway. Git tags are versions for git sources (0242).