Builtin Library
README.md
deps
A world's package dependencies: the version specs a package.yaml dependency
entry states, and the resolver that picks one release of each package a world
holds.
deps.semver: parse a release version (1.4.16,1.4.14-rc.1) and order two by semver precedence.deps.spec: parse a dependencyversioninto the releases it admits, and intersect several.deps.resolve: choose, for every package a world reaches, the newest release every explicit spec admits, or report the conflict.deps.lockfile: the world's lock,/zero/source/dependencies.lock(zero/deps-lock/v1): the release each package resolved to, in one canonical form, and the lines naming each package whose release moved.deps.worldSpec: the world's own specs,/zero/source/dependencies.json(zero/world-deps/v1): the spec the world asks for each package it installs,latestunless it pins one.
Specs
| Spec | Admits |
|---|---|
no version, latest, * | every release |
>=1.4, >1.4.2, <2, <=1.6.3 | the releases at or past (or before) the bound |
^1.4.10 | >=1.4.10 <2.0.0 (^0.3.1 is >=0.3.1 <0.4.0) |
~1.4.10 | >=1.4.10 <1.5.0 |
1.4.* | >=1.4.0 <1.5.0 |
=1.4.10 | exactly 1.4.10, the one form of an exact pin |
>=1.4 <1.6 | what every part admits (spaces or commas separate parts) |
A bare number with no operator (version: 1.4.10) is the form tooling
recorded before specs, and reads as latest. A spec in YAML is quoted, since
>, * and ~ start other YAML forms: version: ">=1.4".
Prereleases (1.5.0-rc.1) are admitted only by a spec with a part naming a
prerelease of the same MAJOR.MINOR.PATCH (>=1.5.0-rc.1). A release whose
version is not semver is admitted by latest and by an = spec naming it.
Resolving
local Deps = require("@builtin::modules.deps")
local result = Deps.resolve.resolve({
roots = { { package = "weaponsKit" } },
packages = {
weaponsKit = { releases = { { version = "1.3.11", dependencies = {
{ package = "controlsKit", spec = "1.4.10" },
} } } },
controlsKit = { releases = { { version = "1.4.10" }, { version = "1.4.16" } } },
},
lock = { controlsKit = "1.4.16" },
})
-- result.ok; result.packages[1] is { package = "controlsKit", version = "1.4.16", ... }
roots are the specs the world states; each release lists the specs it states
for its own dependencies. The resolver reads both to a fixed point. Each
package's choice is the newest release, not yanked, that every explicit spec
naming it admits; latest and legacy numbers add no constraint, so dependents
on latest always agree. A package moves below the version lock holds only
for a cause, which its entry names (cause). When the explicit specs on a
package exclude each other, the resolver sets the release of a requester aside
and tries its next-older one, at most MAX_STEPS times, and otherwise answers
ok = false with a report naming the package, each explicit spec and who
states it, any yanked release the specs would admit, the newest release and the
version held now.
The lock and the world's specs
world.resolveDependencies() (zm deps resolve) resolves the releases a world
holds and writes /zero/source/dependencies.lock and
/zero/source/dependencies.json. Both are canonical JSON, so the same world
gives the same bytes on every engine, and both are formats
@builtin::modules.fileFormats knows: a commit refuses either one that does
not read, and zm diff prints one line per package whose locked release
moved.