Terminology (4)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.
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.
// Picks the newest release by sorting the version strings.
const releases = ["2.4.0", "2.10.1", "2.9.0", "2.5.3"];
releases.sort();
console.log(`sorted: ${releases.join(" ")}`);
console.log(`newest: ${releases[releases.length - 1]}`);
npx tsc main.ts --noEmit --strict && node main.ts
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.
| Tool | Written as | Means | Chooses |
|---|---|---|---|
| npm | "tiny": "^0.2.3" | ≥ 0.2.3 and < 0.3.0 | The newest version in range |
| Cargo | tiny = "0.2.3" | Same as ^0.2.3; =0.2.3 is exact | The newest version in range |
| Go modules | require tiny v0.2.3 | At least v0.2.3 | The highest minimum any go.mod requires |
| vcpkg | "version>=": "0.2.3" | At least 0.2.3, and at least the baseline version | The lowest version meeting every minimum |
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.
| Tool | Records | Release replay behavior |
|---|---|---|
| npm | package-lock.json | npm ci |
| Cargo | Cargo.lock | cargo build --locked |
| Go modules | go.mod selection, go.sum checksums | -mod=readonly protects go.mod; go.sum is not frozen |
| vcpkg | builtin-baseline and overrides in vcpkg.json | Use consistent registries, baseline, constraints and features |
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.
Sources
Sign in to keep your read marks on every device. Sign in
Was this helpful?