Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

content_version

Per-path content-version counters — a cheap, synchronous "has this file changed?" token. An assetType behavior memoizes its parse in the ref's `runtime` keyed by the counter `get(path)` returned when it parsed, then serves every later read as an integer compare instead of re-read…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

content_version

Per-path content-version counters — a cheap, synchronous "has this file changed?" token. An assetType behavior memoizes its parse in the ref's runtime keyed by the counter get(path) returned when it parsed, then serves every later read as an integer compare instead of re-reading and re-parsing the file.

Why it exists

A .data() behavior that re-reads and re-parses its source on every call is pure overhead when the file hasn't changed. This module gives it a version token to gate the rebuild on:

  • get(path) when the parse ran, stored alongside the parsed value.
  • On every later call, compare get(path) to the stored value — equal means the cache is still valid (no vfs.read, no parse); a bump means rebuild.

Exports

  • M.get(path: string) -> number — the path's current version counter (0 if never written this VM).
  • M.bump(path: string) — bump path's counter, invalidating every reader memoized against its previous value. Content code rarely calls this directly.

What bumps a counter

Two write surfaces feed it, so the token reflects a change no matter where it originated:

  • vfs.write / vfs.move / vfs.remove bump synchronously, in the same call — so a script that writes a file and reads it back in the same tick sees the new content immediately (the asset-change onChange dispatch fires a frame later, too late for a same-tick read).
  • the generic asset-change dispatcher bumps on every source write it routes, including peer-synced and engine-originated writes that never pass through the Luau vfs.* surface — with the engine's normalized path, the canonical form a reader keys on.

Per-path, not a global epoch

Counters are per path, not one global epoch. The per-frame dirty-entity writer churns scene-dirty paths every frame during play; a global epoch would let that churn invalidate every unrelated cache. Per-path isolation means only a change to the file a reader depends on rebuilds it.

The counter map lives on _G (__zero_content_versions), installed once before the global table is sealed at boot, so a single map is shared across every copy of this module that a require-cache reset (vfs.reload) might create. A module-upvalue map would let a bumper and a reader that landed on different module copies diverge, and the reader would serve stale content. Per-VM.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module ContentVersion Per-path content-version counters — a cheap, synchronous "has this file changed?" token that lets an assetType behavior memoize a parse in its ref's `runtime` and serve repeated reads as a pure table lookup instead of re-reading + re-parsing the file every call. require modules/content_version about A source write bumps the written path's counter. A memoized reader keyed by the value `get(path)` returned when it parsed can then check, on every later call, whether the counter still matches — an integer compare, no `vfs.read`, no parse. It rebuilds only when the counter moved. Two write surfaces feed it, so the token reflects a change no matter where it came from: * `vfs.write` / `vfs.move` / `vfs.remove` bump SYNCHRONOUSLY, in the same call — so a script that writes a file and reads it back in the SAME tick sees the new content immediately (the asset-change `onChange` dispatch fires a frame LATER, too late for a same-tick read). * the generic asset-change dispatcher bumps on every source write it routes, including peer-synced and engine-originated writes that never pass through the Luau `vfs.*` surface — with the engine's normalized path, which is the canonical form a reader keys on. A typed asset's FOLDER path carries a counter too: the dispatcher bumps it after it has routed a write inside the asset and the asset's type has reacted to it, so a reader of "anything in this asset" keys on one number. Counters are per PATH (not one global epoch): the per-frame dirty-entity writer churns scene-dirty paths every frame during play, and a global epoch would let that churn invalidate every unrelated cache. Per-path isolation means only a change to THE file a reader depends on rebuilds it. Per-VM. The map holds one small integer per distinct written source path.

versions( ) → void

get(path: string) → number

The current version counter for `path` (0 if never written this VM). A memoized reader stores the value it saw when it parsed, and treats a later call as a cache hit exactly while `get(path)` still returns it.

argtypedescription
pathstringNormalized VFS path.

examples

local v = require("modules.content_version").get(p)

bump(path: string) → void

Bump `path`'s version counter, invalidating every reader memoized against its previous value. Called by the `vfs.*` write surface and the asset-change dispatcher; content code rarely calls it directly.

argtypedescription
pathstringVFS path whose content changed.

examples

require("modules.content_version").bump(p)

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

2items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · modules/content_version.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.