← Runtimes
Runtimes

Versions, lockfiles, and reproducible builds

Version order, ranges, minimum version selection, and what a lockfile pins.

Distinguish an allowed version from a recorded selection.

Outcome

Predict which version a tool selects for a requirement, say when a lock entry is reused or refused, and name what a lockfile or baseline does and does not pin.

Terminology (6)Terms used in this lesson

Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.

Semantic version
A major.minor.patch version where a major change signals incompatibility.
Caret range
For complete stable triples, a range bounded by the first nonzero part: ^1.4.0 stays below 2.0.0, ^0.2.3 below 0.3.0, and ^0.0.4 below 0.0.5.
Lockfile
A file recording the exact versions a resolve chose, so later installs can reuse them.
Frozen install
An install that fails rather than change the lockfile.
Minimal version selection
Go’s rule: use the highest of the minimum versions that the build’s go.mod files require.
go.sum
Checksums for module versions, used to verify downloads; it does not choose versions.

Requirements, selections and build inputs

A dependency requirement describes versions a project can accept. Resolution applies the tool’s rules to the available releases and the dependency graph to select concrete versions. A lockfile records a selection for reuse; it serves a different purpose from a range that permits several releases. Other tools record minimums, checksums or baselines, so their metadata needs its own interpretation.

Reproducing a build also requires controlling inputs beyond dependency version labels: source content, the invoked toolchain and build configuration matter too. Keeping a reviewed selection and producing identical artifact bytes are distinct goals. We will separate version ordering, eligibility and reuse before asking what each tool’s recorded metadata guarantees.

01Version order

Which release is newest?

A document-export worker has a dependency-plan report for release review. It labels hyphen-rules 2.9.0 as newest even though the catalog contains 2.10.1. Before promoting a reviewed plan to CI, fix what the report means by newest, allowed and already selected.

The report ranks a supplied release catalog before anyone chooses an update. Its newest label should follow version precedence, not display-text order. In these examples, stable versions have three numeric parts, with no prerelease or build suffix. A version such as 2.10.1 has three numbers: major, minor and patch. Comparing two versions means comparing the major numbers, then the minor numbers, then the patch numbers. Each program sorts four releases with its language’s standard sort for strings.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
// Picks the newest release by sorting the version strings.
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	releases := []string{"2.4.0", "2.10.1", "2.9.0", "2.5.3"}

	sort.Strings(releases)

	fmt.Println("sorted:", strings.Join(releases, " "))
	fmt.Println("newest:", releases[len(releases)-1])
}
Which version does the program print as newest?
Go · terminal.sh
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
go run .

The first program reproduces the report’s text-order bug. The document-export task is authored; no rendering or package installation is performed by that program. The version-selection claims below were checked offline: npm ranges with node-semver 7.8 (the library npm uses), Cargo 1.99 with a local path crate, and Go 1.27 with local module replacements. vcpkg behavior is quoted from its documentation and was not run.

02Requirements

Which version does a requirement select?

Correct ordering does not mean every newer release is eligible for the worker. Review the requirement as well as the catalog. A manifest says which versions are acceptable; the tool then picks one. npm and Cargo read a caret requirement as a range and pick the newest version inside it. ^X.Y.Z admits versions from X.Y.Z up to, but not including, the next change to the leftmost nonzero part: ^2.5.0 admits up to 3.0.0, and ^0.2.3 only up to 0.3.0. For complete stable versions, ^0.0.4 admits 0.0.4 but not 0.0.5; ^0.0.0 admits only 0.0.0. Partial versions and prereleases need additional rules outside this model. Go and vcpkg read requirements as minimums instead and pick the lowest version that meets all of them.

How each tool reads a requirement
ToolWritten asMeansChooses
npm"tiny": "^0.2.3"≥ 0.2.3 and < 0.3.0The newest version in range
Cargotiny = "0.2.3"Same as ^0.2.3; =0.2.3 is exactThe newest version in range
Go modulesrequire tiny v0.2.3At least v0.2.3The highest minimum any go.mod requires
vcpkg"version>=": "0.2.3"At least 0.2.3, and at least the baseline versionThe lowest version meeting every minimum
app’s go.mod requires tiny v0.2.3 and fonts v1.0.0; fonts’ go.mod requires tiny v0.2.9. tiny v0.3.0 also exists. Which tiny does the build use?

03Lockfiles

What does a lockfile pin?

The report now identifies an eligible release, but release replay has another requirement: keep the reviewed selection when it is still valid. npm and Cargo record selections in lockfiles. With an otherwise compatible graph, a normal install reuses a locked version as long as the requirement still admits it, and resolves again only when it does not. Their frozen/locked commands reject a required lock change. Go’s module graph and checksums, and vcpkg’s baselines, have different roles; do not treat every metadata file as the same kind of lock.

Recorded selections and frozen modes
ToolRecordsRelease replay behavior
npmpackage-lock.jsonnpm ci
CargoCargo.lockcargo build --locked
Go modulesgo.mod selection, go.sum checksums-mod=readonly protects go.mod; go.sum is not frozen
vcpkgbuiltin-baseline and overrides in vcpkg.jsonUse consistent registries, baseline, constraints and features
What does go build -mod=readonly guarantee about dependency metadata?

04Practice

Finish the release-plan report

Finish the worker’s dry-run dependency-plan report. It ranks supplied releases, checks a stable three-part caret policy, then proposes whether to keep or replace a reviewed selection. This deliberately small policy resembles part of npm/Cargo selection. Go and C++ implementations build the same reporting tool; they do not imitate Go modules or vcpkg. It reads authored input and prints a plan, without contacting a registry, installing packages or persisting a lockfile.

The worker’s dependency plan

Find the newest release, resolve caret ranges, then report whether the reviewed selection can be reused.

  1. easy · R-LOCK-V4-1 Find the newest release
  2. medium · R-LOCK-V4-2 Resolve a caret range
  3. hard · R-LOCK-V4-3 Replay the reviewed selection
Sources

Report a problem in this lesson

For typos, mistakes and things that don’t work. We read every report and fix what’s wrong, but we don’t reply here, so a question won’t get an answer.