Builtin Library
README.md
world_vcs.derive.snapshot
A read-only view of an asset as a stage holds it, and the one fingerprint rule shared with preview.inputsFingerprint.
of(assetPath, staged, opts?)builds aDeriveSnapshotfrom staged entries shaped like the statusstagedrows,{ path, staged_action?, staged_checksum, blob_sha256?, deps? }, laid overopts.base, the files of the asset in the tree the stage's commit lands on ({ path, checksum_sha256, blob_sha256?, refs_json? }, the dependencies read fromrefs_json); adeleterow removes a file, andopts.excludenames relative paths left out, such as the output a hook computes. An entry another entry lies beneath, staged or in the base, is a folder (a folder asset nested in the asset, such as a material'stextures/basecolor.texture) and is left out: the asset holds the files beneath it (foldersOf(paths)names them). A base file with no blob address is read as text through its content address.filesmaps each file's path relative to the asset to its content address;read(rel)fetches the staged blob on first use, decodes it and keeps it on the snapshot, and answers nil for an absent file or an unreadable blob.opts.placed(fromplacedFiles) names files of the asset an install places where the world holds no row of its own, each with its content address, VFS path and references: one joinsofat a path no base or staged entry holds, is read from the working tree, and counts toward the version a pin of a folder asset nested in the asset states, so an installed asset the world edited fingerprints whole, the way the live asset does.placedFiles(path, isPlaced, opts?)lists the live files of the asset thatisPlacedsays an install places.laidOver(base, stages)lays the staged entries of each commit, oldest first, over thebaserows and answers the tree in the base shape; a staged delete removes the path.live(path, opts?)builds the same shape over the live files of the asset, with each file's dependencies fromasset.deps.fingerprintLines(s)returns the lines a fingerprint hashes:f <relative path> <address>per file in path order, each followed byd <guid> <checksum>per asset the file references.EXCLUDEDnames the files that are never inputs:preview.png,README.mdand.metadata.
local snapshot = require("modules.world_vcs.derive.snapshot")
local s = snapshot.live("/zero/source/a.material")
print(__crypto.sha256_hex(table.concat(snapshot.fingerprintLines(s), "\n")))