Shard format format 0.1.0.6 · npm 0.80.0

Tour of a built shard

On this page
  1. shard.json, the index
  2. sections/, the rows
  3. blobs/, the bytes
  4. cook.json and mounts/
  5. validation.json, the receipt
  6. Try it

This is a real built shard, Brasscap Mesa (brasscap-mesa): a canyon with bandit camps, a sheriff's quest and a boss that burrows. The repo keeps a copy of its build in corpus/exports/brasscap-mesa for its tests; its source is in shard-brasscap at 9d885aac94f9. The numbers on this page are read from that copy whenever the site is built.

It is format 0.1.0.6, requires engine 0.1.84, and has 37 sections and 182 immutable files. 5 models over the repo's 1 MB file cap are left out of the copy; the index still lists them.

brasscap-mesa/
  shard.json          the index: everything else is listed here
  cook.json           preparation: mounts, and what the cook needs
  validation.json     the build's receipt
  sections/           JSON rows, one file per registered section
  blobs/              immutable bytes, named by SHA-256
  mounts/             files the cook publishes at a public URL

shard.json, the index

The one file a reader opens first. Its top-level keys:

Every byte of every other file is reachable from here, by hash. A file on disk the index doesn't list is refused without being read.

sections/, the rows

Each section is one canonical JSON file under sections/<area>/, with a registered schema, wildshard:<name>@1. The validator parses each against its schema; unknown keys fail. Brasscap Mesa ships these:

SectionBytes
actors/creatures5.4 kB
actors/crowds14 B
actors/moves639 B
actors/species6.5 kB
audio/audio111 B
combat/encounters483 B
combat/items4.4 kB
combat/strikes2.1 kB
economy/ledger364 B
economy/loot757 B
look/look6.8 kB
look/materials1.9 kB
quests/quests8.7 kB
sim/client-scripts11.1 kB
sim/hooks669 B
sim/plumbing18 B
sim/scripts1.5 kB
sim/sim315 B
state/migrations18 B
state/state860 B
ui/card18 B
ui/compendium28 B
ui/level4.1 kB
ui/ui2.8 kB
world/collision23 B
world/days21 B
world/edge64.7 kB
world/movers715 B
world/navigation20 B
world/props19.5 kB
world/spawn47 B
world/targets96 B
world/terrain7.9 kB
world/tiles30.7 kB
world/traversal30 B
world/water13 B
world/weather24 B

What each section means, and which engine host reads it, is in the runtime contract. Some examples from this shard:

blobs/, the bytes

Everything that isn't a row is a blob at blobs/<kind>/<sha256>.<ext>. The name is the hash of the bytes, so a blob is immutable and can be cached forever. By kind:

KindFilesWire bytes
glb8319.65 MB
image4255.6 kB
json75.5 kB
ktx242.4 kB
tile811.46 MB
wasm312.2 kB

glb models, ktx2 and image textures, tile terrain tiles (.wtt), json pages too big for a section, and wasm: the shard's only code, compiled AssemblyScript. A Wasm blob is admitted by reading it (its imports, exports, memory and instructions), never by running it. See the script ABI.

cook.json and mounts/

cook.json is preparation: values computed from the shard before upload so the server, the cook and the API don't compute them again. Here it lists one mount, mounts/shardfiles/brasscap-mesa/discovery.json, which the cook publishes at /shardfiles/brasscap-mesa/discovery.json.

validation.json, the receipt

The build's own verdict: the hash of the index it checked, the validator revision, the worst-location memory totals and a grid-readiness check (baked tiles, the four entryways at y=0, edge profiles, the HUD accent). It is a cache hint for a host that built the file itself. It never stands in for validation of a file that came over the network: that file is validated in full.

Try it

From a checkout of the repo:

node src/cli/main.ts validate src/test/fixtures/cli-fixture

prints ok cli-fixture r1: … and the deprecations it carries. The Brasscap copy in the repo does not validate as it stands: its 5 largest models are left out. To check a shard of your own, see the agent skill; it works for people too.