Log inGet started

Dependencies: which copy of a package runs, and how a pinned version moves

Updated December 5, 2026

A file records the version of every asset it references

Every source file has a reference table: for each asset the file names (a require, an asset name in a data file, a dependencies entry of package.yaml), the table records the asset and the version the file was recorded against: the asset's guid with its checksum and release id, or, for a name that reaches into another world's content as a whole, that world's commit. asset.deps("<path>") reads a file's table; each entry names its literal, via (require, asset_ref, asset_type), asset_guid and the recorded checksum / asset_version_id or commit.

The recorded version is what the file runs. A require resolves its name to the copy the world holds at that version, so two files naming the same module at two releases run two copies of it, each loaded on its own: a component one registers, a value one sets, is invisible to the other.

Which version a file records depends on whose content it is:

  • A file this world authored records the version this world holds. When the world comes to hold another version of an asset the file references (you edit that asset, or an update moves it), the file's table moves with it: zm status lists the file with reason = "references moved", its bytes unchanged, and the next commit that takes it records the new version.
  • A file of installed content (an install, a dependency an install placed, pulled content, a mounted library) keeps the table its publisher recorded. An install does not re-record it.
  • Writing a file's own bytes back (vfs.write(p, vfs.read(p))) records nothing new: the table is derived from the bytes and from what the world holds, and both are unchanged.

Why a world holds one package at two releases

Installing a package installs the closure its files' tables name. The release a file's table names is placed where that package's name reaches (/zero/source/deps/<world>/<path>) unless the world already holds another release there. Then the recorded release lands in a recorded version's folder, /zero/source/deps/<world>/versions/<checksum>/<path>, which only the files recorded against that release run, and the world holds both:

SecondWind (world 7a497fbf-...): 2 copies, each loaded on its own
  1.4.21 94bdf7fcb033 at /zero/source/deps/7a497fbf-.../SecondWind.package, placed by the install at /zero/source/economyKit.package, a name reaches it; run by ...
  1.4.19 89b147bf6d2c at /zero/source/deps/7a497fbf-.../versions/89b147bf.../SecondWind.package, placed by the install at /zero/source/creepsKit.package, run only by the files recorded against it; run by /zero/source/creepsKit.package/waves.module/init.luau

That is the zm deps listing. world.dependencies() answers it as a table: each package's copies, each copy's form (install, dependency at the path its name reaches, or recorded), its version and checksum, the install whose record places it (placed_by), whether a name reaches it (reached_by_name), and users: for a copy under /zero/source/deps/, the files and dependency roots whose references run it, and for an install root its own record. A file whose reference table names a recorded version the world holds runs that copy and is among its users; a file naming the version a name reaches runs that copy; a file naming a version the world holds nowhere runs the version the engine fetches for it. Each package also lists requested, what the dependencies of every held package's package.yaml state for it, duplicated marks a package held as more than one copy, and resolves_to names the release latest resolves to among the releases the world holds (below). world.dependencies({ updates = true }) adds the newer release each copy's origin holds.

Before an install, zeromind.preview(guid, { detail = "full" }) names the same thing: a node whose dest_path stands under versions/<checksum>/ is a release the install would hold beside another one. The install's answer and zeromind.installs name it under releases.

How a dependency version is chosen

A dependencies entry's version in package.yaml is a spec: no version, latest or * admits every release; ">=1.4", "^1.4.10", "~1.4.10" and "1.4.*" admit a range; "=1.4.10" is the one exact pin; a bare number (1.4.10) reads as latest (types/package has the whole grammar). @builtin::modules.deps resolves a set of specs to one release of each package: the newest release every explicit spec naming it admits, or a report naming the specs that exclude each other.

world.dependencies() runs that resolution over the releases the world holds: each package's resolves_to is the newest held release the specs of the held packages admit, its specs lists each spec and who states it, and conflicts carries the report when explicit specs exclude each other. A package held at two releases whose resolves_to is the newer one is held at the older one only because files were recorded against it.

The lock and the world's specs: recording what the world resolved to

zm deps resolve (world.resolveDependencies() in Luau) runs the same resolution and writes it down in two files of the world:

  • /zero/source/dependencies.lock (zero/deps-lock/v1): one entry per package the world holds, directly or through another package, naming the release it resolved to (version, checksum, version id, where the copy stands, whether the world installed it itself) and every spec naming it, plus the @builtin commit the world pins. The engine writes it; a person does not.
  • /zero/source/dependencies.json (zero/world-deps/v1): the spec the world asks for each package it installs. Each install starts at latest. Edit an entry's spec to constrain it, "=1.5.0" to pin exactly that release, ">=1.4" for a floor, "^1.4.10" for a range, with the reason in reason, then run zm deps resolve again.

Both are written in one canonical form, so the same world gives the same bytes on every engine. They are ordinary files of the world: zm add /zero/source/dependencies.lock /zero/source/dependencies.json, zm commit and zm push carry them, and another engine reads them back after zm pull. zm commit refuses either one when it does not read (a lock edited by hand into invalid JSON, a spec that is not one), naming the file and the reason; zm deps resolve writes a broken lock again. zm diff prints one line per package whose locked release moved (controlsKit 1.4.16 -> 1.4.17) in place of the file's text hunks.

When the world's explicit specs exclude each other, zm deps resolve writes nothing and prints the resolver's report. Resolving a world whose files already state its resolution writes nothing.

The lock is what the world runs. Every require and asset name that reaches an asset of a locked package reaches it inside the copy the lock names, whichever version the requiring file's table records, so a package two installed kits depend on at different releases loads once, at the release the lock names. A lock is read again as soon as its bytes change: after zm deps resolve (or a zm pull that brings a new lock) the next require reads the new choice. The copies the lock does not run are listed by world.removeUnusedDeps({ dryRun = true }) once nothing else runs them, and world.removeUnusedDeps() removes them. An asset no locked copy holds, and a world with no lock, run as the sections above describe.

Repinning a file: what moves a recorded pin, and what does not

A file's pins are its reference table, and the table is derived. Nothing repins or re-records a file's references on request:

  • A file of this world's own content repins itself when the world holds a new version of what it requires: the table refreshes to the current version and zm status lists the file as references moved.
  • A file whose bytes and table did not change keeps the pins it has, and a release carries it with those pins. A stale pin of such a file moves only when the file is recorded again: change its bytes.
  • A file of installed content keeps its publisher's pins until its package is released again on the new version and the world updates to that release.

Updating the top-level copy does not move another package's recorded copy

zeromind.update("/zero/source/deps/<world>/SecondWind.package") moves the copy a name reaches, and the install record placing it. The files of another installed package keep the tables their publisher recorded: the ones recorded against the older release still run the recorded copy under versions/, and the update's answer names them under pinned (each <file>: <guid>@<checksum> ... runs <path>). A recorded copy moves only when the package whose files record it is released again on the new release and the world updates to that release.

zeromind.updates lists a dependency an install places as a unit of its own, under its path, and zeromind.update(<that path>) writes the install's record again with the dependency at the new release. An update is refused when it would move a dependency to an older release than the world holds ("would move a dependency it places to an older release than the one it holds"): release the package that records the older one on the newer release first.

Moving a package's recorded copy to the release the world installs

The recorded release lives in the reference tables of the package that records it, and a release of that package carries each file's table as the world it is published from recorded it. So the move is made in that package's own world, then taken in every world that installs it:

  1. In the world that authors the recording package, update the dependency: zeromind.reviewUpdate("<install path>"), then zeromind.update("<install path>"). Every file of this world whose table names the release the update moved from moves with it and reads references moved in zm status.
  2. Check every file of the package names the new release. world.dependencies({ package = "<dependency>" }) must list one copy, run by every file of the package, and asset.deps("<file>") reads each file's recorded checksum. A file of the package can name an older release than the one the update moved from (it was recorded against a release the world held before that): its table keeps that release while its bytes do not change, and there is no call that records an unchanged file again. Change such a file's bytes (its version comment, for example); it is then recorded against the release the world holds. The dependencies entries of package.yaml are references of the same kind and move the same way.
  3. Release the recording package: run its tests, then zm add <the package> <the install whose record moved>, zm commit, zm push; the push releases it under the next version and writes that version into its package.yaml. The pushed commit records each file at the release the world holds. A reference records a release ZeroMind's main holds for that dependency's world: a dependency whose new release is not pushed yet leaves the old one recorded.
  4. In every world that installs it, update the inner package before the outer one that carries it (zeromind.updates, zeromind.reviewUpdate, then zeromind.update(<path>) one install at a time, zm add and zm commit after each). Updating the outer one first re-applies its published records, old releases included; installing it again in place (zeromind.installAsset(guid, { path = "/source" })) takes them anew.
  5. Remove what nothing runs any more: world.dependencies() lists one copy of the package, then zeromind.removeUnusedDeps({ dryRun = true }) and zeromind.removeUnusedDeps() take out the recorded copy, then zm push.

A copy stays while any file in the world's closure runs it: when removeUnusedDeps answers "Nothing under /zero/source/deps is unused", the copy's users in world.dependencies() name the files still recorded against it, and those files' package is the one to release on the new release.

Before publishing: stale pinned references inside your own package

Before publishing a package of your own, read which releases its files pin: world.dependencies() in the authoring world lists every copy with the files that run it, and a package your files depend on should be held as one copy, run by every file. A commit records each file's table as the world holds it, and a file whose bytes and table did not change since the last release is published with the table it had. So after updating a dependency, check that each file referencing it reads references moved in zm status or names the new release in asset.deps; a file still naming an older release is re-recorded by changing its bytes, and staged with the rest of the release.

  • core/requiring-modules: how a require string resolves to an asset.
  • core/development: staging, references moved, the @builtin pin and zeromind.update("@builtin").
  • types/package: package.yaml and its dependencies.
  • zeromind.installs, zeromind.preview, zeromind.updates, zeromind.update, zeromind.removeUnusedDeps, zeromind.dependencies, zm deps resolve.