# Tour of a built shard

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`](https://github.com/project-wildshard/shard-format/tree/main/corpus/exports/brasscap-mesa)
for its tests; its source is in
[shard-brasscap](https://github.com/project-wildshard/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.

```text
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:

- `format`: always `"wildshard.shardfile"`.
- `formatVersion`: the four-part format version, here
  `"0.1.0.6"`. An older file still admits, and is
  migrated through the data-only steps in
  [`src/format/format-migrations.ts`](https://github.com/project-wildshard/shard-format/blob/main/src/format/format-migrations.ts).
- `identity`: slug, display name, author, `saveRevision` (keys the
  save lineage) and seed.
- `requires`: the engine it was built for and any shared *commons*
  assets it uses, with their exact wire bytes and costs.
- `sections`: each section's name, path, schema id, byte size and
  SHA-256.
- `files`: every blob, with its hash, kind, path, compressed and
  decoded bytes, GPU bytes, triangles, draw calls, dependencies and
  whether it is critical. These are measured by the build and measured
  again by the validator.
- `cook`: the hash and size of `cook.json`.
- `admission`: the budgets the shard declares for itself, its
  `critical` and `library` roots, the server budget and the author
  caps. Brasscap Mesa declares 3 critical roots,
  library wire of 1.71 MB and sim wire of
  275.7 kB, and caps a room at 32 players moving
  at up to 15 m/s.
- `build`: the source hash and the validator revision that built it.

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:

| Section | Bytes |
| --- | --- |
| `actors/creatures` | 5.4 kB |
| `actors/crowds` | 14 B |
| `actors/moves` | 639 B |
| `actors/species` | 6.5 kB |
| `audio/audio` | 111 B |
| `combat/encounters` | 483 B |
| `combat/items` | 4.4 kB |
| `combat/strikes` | 2.1 kB |
| `economy/ledger` | 364 B |
| `economy/loot` | 757 B |
| `look/look` | 6.8 kB |
| `look/materials` | 1.9 kB |
| `quests/quests` | 8.7 kB |
| `sim/client-scripts` | 11.1 kB |
| `sim/hooks` | 669 B |
| `sim/plumbing` | 18 B |
| `sim/scripts` | 1.5 kB |
| `sim/sim` | 315 B |
| `state/migrations` | 18 B |
| `state/state` | 860 B |
| `ui/card` | 18 B |
| `ui/compendium` | 28 B |
| `ui/level` | 4.1 kB |
| `ui/ui` | 2.8 kB |
| `world/collision` | 23 B |
| `world/days` | 21 B |
| `world/edge` | 64.7 kB |
| `world/movers` | 715 B |
| `world/navigation` | 20 B |
| `world/props` | 19.5 kB |
| `world/spawn` | 47 B |
| `world/targets` | 96 B |
| `world/terrain` | 7.9 kB |
| `world/tiles` | 30.7 kB |
| `world/traversal` | 30 B |
| `world/water` | 13 B |
| `world/weather` | 24 B |

What each section means, and which engine host reads it, is in
[the runtime contract](https://format.wildshard.io/docs/runtime-contract.md#1-sections). Some
examples from this shard:

- `world/terrain` binds the baked terrain: a collider and the tiles,
  each a blob by hash.
- `sim/scripts` declares the boss's decision script: its ABI
  (`"1.0"`), the encounter it binds to, the commands it may issue, the
  fields it reads, and `module`, the path of its compiled Wasm blob.
- `quests/quests` holds the dialogue and quest graph as plain rows:
  the sheriff's lines, the choices and the flags each one sets.

## `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:

| Kind | Files | Wire bytes |
| --- | --- | --- |
| `glb` | 83 | 19.65 MB |
| `image` | 4 | 255.6 kB |
| `json` | 7 | 5.5 kB |
| `ktx2` | 4 | 2.4 kB |
| `tile` | 81 | 1.46 MB |
| `wasm` | 3 | 12.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](https://format.wildshard.io/docs/script-abi.md).

## `cook.json` and `mounts/`

`cook.json` is [preparation](https://format.wildshard.io/docs/preparation.md): 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](https://github.com/project-wildshard/shard-format):

```sh
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](https://format.wildshard.io/agents/skill.md); it works for people too.
