53. Bring in assets

Status: partly implemented. A realm's asset pack (VPK1) is read whole or refused by the OpenAgents Metaverse Engine's reader in Coax (metaverse-engine/editor/pack.coax, #authority). The reader checks the pack's budget, its layout and a licence on every asset, and admits the pack into a realm's assets by content (chapter 16). The pack is written again byte for byte as metaverse/tools/pack_realm.py writes it. Both committed packs (Everglade's and the fixture's) read, write again to the same bytes and are admitted. The trace below is worked by hand and run in metaverse-engine/examples/bring-in-assets.coax. Not built yet: the import from sources (scene meshes, images, sounds) that would retire pack_realm.py, unit checks with a recorded rescale, uploads as typed states, and the cast and drop packers on the same path. See Still to do.

Planned interoperability extension: the Omniverse comparison adds reusable assembly metadata, workflow-specific asset-readiness reports and bounded USDA export from a resolved admitted world. Extend this chapter's registry/pack/import owners; preserve immutable sources, explicit instance overrides and closed content-hashed dependencies. Compare the first static export with an independent USD tool and report unsupported/lost properties. VPK1 remains the existing runtime pack path. Chapter 35 owns later physical USD import; a general USD composition engine is not implied. This proposal changes neither the chapter's status nor the published V1 pack contract.

An asset arrives from outside the engine: a CC0 kit's mesh, a character with its clips, a photo of someone's dog, a model a project owner dropped. Before a realm may use it, the engine must know what it is (a content hash), what it may be used for (a licence), what it measures (units and bounds) and what it costs (bytes against a budget). Chapter 16 gave identities and budgets; this chapter is the door they are checked at. Physics imports (URDF, MJCF, tetrahedral meshes) are chapter 35's.

What this chapter teaches

  • Packing many assets into one streamed file with a table, a catalog and a budget.
  • A licence on every asset, from its source, refused when it is missing or doesn't match its catalog line.
  • Reading untrusted bytes whole: every field checked before anything is kept, and a refusal that names what it refused.
  • A pack's entries admitted into a realm's assets by their content.

The format

The shared reader supports VPK1's published 48-entry ceiling and the separately versioned VPK2 128-entry ceiling. pack_write preserves VPK1; pack_write_v2 explicitly selects VPK2. For large browser-streamed worlds, page-pack.coax (7a845fd450) adds lossless VPK3 paged packs with two bit-exact codecs (PPK_DEFLATE_T32S 32-byte stride delta+transpose and PPK_DEFLATE_IDX32 u32 delta+zigzag+transpose), shrinking everglade2.vpk3 from 31.78 MB to 27.28 MB (-14.2%) and cutting throttled cold loads from 4,397 ms to 2,537 ms (-42.3%) and warm loads from 3,597 ms to 803 ms (4.5x) with Coax SHA-256 admission over Cache API pages. On the Desktop viewer side, `metaverse-engine/content/model-view.coax` adds direct pure-Coax loading for glTF/GLB, OBJ, STL, PLY, RBA1 skeletal animation archives (#14041/#14042), and .splat / 3D Gaussian Splatting point clouds (#14046). The listings below follow the current source. The new RCM1 cost companion does not change either pack's bytes or asset identity.

The bounded streaming consumer authenticates actual HTTP container bytes and admitted entry spans before its canonical codecs and SDK uploads. Its allocation and per-paid-step replay receipts use an original CC0 corridor fixture with both visual tiers. This is a separate resource-cost/ownership profile; it does not complete this chapter's source import, rescale or generalized cast/drop teaching work. The additive HTP1 companion now derives the whole container and exact source span needed for each RCM1 payload. Known raw/public reader operations reserve their reactor/byte-array peak before effects. The actual corridor now binds HTP1 to each complete fetched source and exact live attempt, recording allocation and joined-release histories. Its additive diagnostic/capture profile prepays temporary copy/text storage and preserves cleanup after trace pressure. The adapter inventory bounds adoption. The broader import work below remains unfinished.

A pack is a header, a table of entries (kind, licence, offset, bytes, name) and their data on 4-byte boundaries. There is one catalog, one vertex buffer and one index buffer, then the texture layers, then the linear data layers (normal and ORM maps), then the sounds. The catalog is text: it states the pack's budget and size again, declares each licensed source (L K NAME|LICENCE|URL), names every mesh's index range, source and bounds in metres (M), and says which source each layer (T), data layer (D) and sound (S) comes from. A realm draws a mesh as [first, count, instance, 1] without parsing geometry.

The header's and table's sizes and an entry's fields are the engine's, in metaverse-engine/host/pack-table.coax, because every host reads a pack's table through that file (pack_table, GitHub #13304) and the Metaverse Engine loads it:

jai
PACK_MAGIC :: "VPK1";PACK_HEADER :: 32;PACK_ENTRY :: 48;// An entry's kind.PACK_CATALOG :: 1;PACK_VERTICES :: 2;PACK_INDICES :: 3;PACK_LAYER :: 4;PACK_SOUND :: 5;PACK_DATA :: 6;       // linear data layers (normal, ORM): between the texture layers and the soundsPACK_RIG :: 7;        // the rigs (VRG1, metaverse-engine/anim/rig-pack.coax): at most one, after the soundsPACK_CELLS :: 8;      // a world's content by cell (GitHub #13280): at most one, the last entry; the catalog's Z lines (pack-cells.coax) name each cell's bytes in it// One entry as the table has it: its bytes are p[at..<at + n] of the pack read.PackEntry :: struct { kind: int; licence: int; at: int; n: int; name: string; }
jai
PACK_READ_MAX :: 128; // VPK2; VPK1 retains its published 48-entry ceiling.PACK_MAX :: 48;        // entries a pack has at most (metaverse/tools/pack-files.coax's limit too)PACK_NAME :: 32;       // a name's field; a name is 1 to 31 bytesPACK_SOURCES :: 32;    // licensed sources (L lines) a catalog declares at mostPACK_MANY :: 255;      // the licence of the catalog, vertices and indices: every source'sPackRead :: struct {  ok: bool;  why: string; entry: int = -1;      // the refusal, and the entry it names (-1: the pack as a whole)  count: int; bytes: int; budget: int;  entries: [PACK_READ_MAX] PackEntry;  sources: int;                      // licensed sources the catalog declares}// An entry to write: kind, licence, name and bytes.PackSource :: struct { kind: int; licence: int; name: string; data: string; }

The catalog, vertices and indices hold every source's assets, so their licence is PACK_MANY (255). A layer or a sound has exactly one source. pack_realm.py gives a layer that meshes of two sources share the licence 255 and refuses it, so a pack never holds such a layer.

Reading a pack whole

The reader takes the pack's bytes as untrusted. It checks the header, then every entry in table order: its kind in the format's order, its reserved fields zero, its name plain, its bytes starting exactly where the last entry's padding ended, and the padding zero. Only then does it read the catalog. Nothing is kept until all of it holds:

jai
// Read a pack whole: its header, its table in the format's order and layout, and its catalog's// account of every licence. False, with why and the entry, at the first thing that doesn't hold.pack_read :: (p: string, r: [] PackRead) -> bool #effects(all) {  if p.count < PACK_HEADER || !pack_magic_ok(p[0..<4]) { return pack_why(r, "not a VPK1 pack", -1); }  pk_count := pack_u32(p, 4);  if pack_u32(p, 8) != p.count { return pack_why(r, "its stated size isn't its size", -1); }  if pk_count < 3 || pk_count > (ifx p[3]=='2' then PACK_READ_MAX else PACK_MAX) || pack_u32(p, 16) != PACK_HEADER || pack_u32(p, 20) != PACK_HEADER + PACK_ENTRY * pk_count      || pack_u32(p, 24) != 0 || pack_u32(p, 28) != 0 || p.count < PACK_HEADER + PACK_ENTRY * pk_count {    return pack_why(r, "a malformed header", -1);  }  if p.count > pack_u32(p, 12) { return pack_why(r, "over its budget", -1); }  got: [1] PackRead;  got[0].count = pk_count; got[0].bytes = p.count; got[0].budget = pack_u32(p, 12);  pk_at := PACK_HEADER + PACK_ENTRY * pk_count;   // where the next entry's bytes must start  pk_prev: int;                                   // the kind of the entry before this one  for pk_k: 0..<pk_count {    pk_e := PACK_HEADER + PACK_ENTRY * pk_k;    pk_kind := cast(int) p[pk_e];    pk_lic := cast(int) p[pk_e + 1];    pk_off := pack_u32(p, pk_e + 4);    pk_n := pack_u32(p, pk_e + 8);    pk_name := pack_name(p[pk_e + 16..<pk_e + PACK_ENTRY]);    pk_first := ifx pk_k < 3 then pk_kind == pk_k + 1 else pk_kind == PACK_LAYER || pk_kind == PACK_SOUND || pk_kind == PACK_DATA || pk_kind == PACK_RIG || pk_kind == PACK_CELLS;    if !pk_first || pk_prev == PACK_CELLS || (pk_prev == PACK_RIG && pk_kind != PACK_CELLS) || (pk_kind == PACK_LAYER && (pk_prev == PACK_SOUND || pk_prev == PACK_DATA)) || (pk_kind == PACK_DATA && pk_prev == PACK_SOUND) { return pack_why(r, "an entry out of order", pk_k); }    if p[pk_e + 2] != 0 || p[pk_e + 3] != 0 || pack_u32(p, pk_e + 12) != 0 || pk_name.count == 0 { return pack_why(r, "a malformed entry", pk_k); }    if pk_off != pk_at || pk_off + pack_pad(pk_n) > p.count { return pack_why(r, "an entry out of place", pk_k); }    for pk_z: pk_off + pk_n..<pk_off + pack_pad(pk_n) { if p[pk_z] != 0 { return pack_why(r, "an entry out of place", pk_k); } }    if (pk_k < 3) != (pk_lic == PACK_MANY) { return pack_why(r, "an asset without one licence", pk_k); }    got[0].entries[pk_k] = PackEntry.{kind = pk_kind, licence = pk_lic, at = pk_off, n = pk_n, name = pk_name};    pk_at = pk_off + pack_pad(pk_n);    pk_prev = pk_kind;  }  if pk_at != p.count { return pack_why(r, "bytes after the last entry", -1); }  pk_cat := got[0].entries[0];  if !pack_catalog(p[pk_cat.at..<pk_cat.at + pk_cat.n], got[..]) { r[0] = got[0]; return false; }  got[0].ok = true;  r[0] = got[0];  return true;}

The catalog must account for the pack. Its stated budget and size are the header's, its sources are numbered 0, 1, ... in order, and every mesh names a declared source. Each layer and sound has exactly one line, naming the licence its own table entry carries:

jai
// The catalog's account: the pack's budget and size again, its sources in order, every mesh's// source declared, and each layer and sound the source its own entry says.pack_catalog :: (t: string, r: [] PackRead) -> bool #effects(all) {  if t.count == 0 || t[t.count - 1] != '\n' { return pack_why(r, "a catalog that doesn't end its last line", 0); }  pk_stated := 0; pk_layer := 0; pk_sound := 0; pk_at := 0;  pk_layers := 0; pk_sounds := 0; pk_datas := 0; pk_data := 0; pk_rigs := 0; pk_rig := 0; pk_worlds := 0; pk_world := 0;  for pk_k: 3..<r[0].count { pk_t := r[0].entries[pk_k].kind; if pk_t == PACK_LAYER { pk_layers += 1; } else if pk_t == PACK_DATA { pk_datas += 1; } else if pk_t == PACK_RIG { pk_rigs += 1; } else if pk_t == PACK_CELLS { pk_worlds += 1; } else { pk_sounds += 1; } }  for pk_i: 0..<t.count {    if t[pk_i] != '\n' { continue; }    pk_line := t[pk_at..<pk_i]; pk_at = pk_i + 1;    pk_what := pack_field(pk_line, 0);    if pk_what == "budget" || pk_what == "bytes" {      pk_v := pack_number(pack_field(pk_line, 1));      if pk_v != (ifx pk_what == "budget" then r[0].budget else r[0].bytes) { return pack_why(r, "a catalog that misstates the pack", 0); }      pk_stated += 1;    }    if pk_what == "L" {      if pack_number(pack_field(pk_line, 1)) != r[0].sources || r[0].sources == PACK_SOURCES { return pack_why(r, "a source out of order", 0); }      r[0].sources += 1;    }    if pk_what == "M" || pk_what == "C" {      pk_m := pack_number(pack_field(pk_line, 4));      if pk_m < 0 || pk_m >= r[0].sources { return pack_why(r, "a mesh without a declared licence", 0); }    }    if pk_what == "T" || pk_what == "S" {      pk_kind := ifx pk_what == "T" then PACK_LAYER else PACK_SOUND;      pk_nth := ifx pk_what == "T" then pk_layer else pk_sound;      pk_e := pack_nth(r, pk_kind, pk_nth);      if pk_e == -1 { return pack_why(r, "a catalog line for an entry the pack doesn't have", 0); }      pk_lic := pack_number(pack_field(pk_line, ifx pk_what == "T" then 3 else 2));      pk_ok := ifx pk_what == "T" then pack_number(pack_field(pk_line, 1)) == pk_layer else pack_field(pk_line, 1) == r[0].entries[pk_e].name;      if !pk_ok || !pack_licensed(r, pk_e, pk_lic) { return pack_why(r, "an asset without a declared licence", pk_e); }      if pk_what == "T" { pk_layer += 1; } else { pk_sound += 1; }    }    if pk_what == "D" {      pk_e := pack_nth(r, PACK_DATA, pk_data);      if pk_e == -1 { return pack_why(r, "a catalog line for an entry the pack doesn't have", 0); }      pk_lic := pack_number(pack_field(pk_line, 3));      if pack_number(pack_field(pk_line, 1)) != pk_data || !pack_licensed(r, pk_e, pk_lic) { return pack_why(r, "an asset without a declared licence", pk_e); }      pk_data += 1;    }    if pk_what == "R" {      pk_e := pack_nth(r, PACK_RIG, pk_rig);      if pk_e == -1 { return pack_why(r, "a catalog line for an entry the pack doesn't have", 0); }      if pack_field(pk_line, 1) != r[0].entries[pk_e].name || !pack_licensed(r, pk_e, pack_number(pack_field(pk_line, 2))) { return pack_why(r, "an asset without a declared licence", pk_e); }      pk_rig += 1;    }    if pk_what == "W" {      pk_e := pack_nth(r, PACK_CELLS, pk_world);      if pk_e == -1 { return pack_why(r, "a catalog line for an entry the pack doesn't have", 0); }      if pack_field(pk_line, 1) != r[0].entries[pk_e].name || !pack_licensed(r, pk_e, pack_number(pack_field(pk_line, 2))) { return pack_why(r, "an asset without a declared licence", pk_e); }      pk_world += 1;    }  }  if pk_stated != 2 { return pack_why(r, "a catalog that misstates the pack", 0); }  if pk_layer != pk_layers { return pack_why(r, "an asset without a declared licence", pack_nth(r, PACK_LAYER, pk_layer)); }  if pk_data != pk_datas { return pack_why(r, "an asset without a declared licence", pack_nth(r, PACK_DATA, pk_data)); }  if pk_sound != pk_sounds { return pack_why(r, "an asset without a declared licence", pack_nth(r, PACK_SOUND, pk_sound)); }  if pk_rig != pk_rigs { return pack_why(r, "an asset without a declared licence", pack_nth(r, PACK_RIG, pk_rig)); }  if pk_world != pk_worlds { return pack_why(r, "an asset without a declared licence", pack_nth(r, PACK_CELLS, pk_world)); }  return true;}

A refusal says why and which entry: −1 for the pack as a whole, 0 for the catalog, or the table index of the layer or sound without a declared licence. A refused read leaves an empty PackRead, so no partly read pack can be admitted.

Writing a pack

The writer lays entries out exactly as pack_realm.py does. It writes every byte once, so a buffer's old contents never show through. It doesn't check licences or the catalog; pack_read does, so what it writes is read back before it is kept:

jai
// The bytes a pack of these entries takes: header, table, and each entry padded to 4 bytes.pack_size :: (s: [] PackSource) -> int #effects(all) {  pk_n := PACK_HEADER + PACK_ENTRY * s.count;  for pk_e: s { pk_n += pack_pad(pk_e.data.count); }  return pk_n;}// Write a pack as pack_realm.py does: the bytes written, or -1 when out can't hold them, there are// more than PACK_MAX entries, or a name isn't 1 to 31 bytes. Nothing is checked beyond the layout:// pack_read is the check, so what this writes is read back before it is kept.pack_write :: (s: [] PackSource, budget: int, out: [] u8) -> int #effects(all) {return pack_write_version(s,budget,out,false);}pack_write_v2 :: (s: [] PackSource, budget: int, out: [] u8) -> int #effects(all) {return pack_write_version(s,budget,out,true);}pack_write_version :: (s: [] PackSource, budget: int, out: [] u8,wide:bool) -> int #effects(all) {  pk_total := pack_size(s);  if s.count > (ifx wide then PACK_READ_MAX else PACK_MAX) || pk_total > out.count { return -1; }  for pk_e: s { if pk_e.name.count == 0 || pk_e.name.count >= PACK_NAME { return -1; } }  // Every byte is written once: the header, each entry of the table, each entry's bytes and padding.  for pk_c, pk_k: PACK_MAGIC { out[pk_k] = pk_c; }  if wide {out[3]='2';}  pack_put32(out, 4, s.count); pack_put32(out, 8, pk_total); pack_put32(out, 12, budget);  pack_put32(out, 16, PACK_HEADER); pack_put32(out, 20, PACK_HEADER + PACK_ENTRY * s.count);  pack_put32(out, 24, 0); pack_put32(out, 28, 0);  pk_at := PACK_HEADER + PACK_ENTRY * s.count;  for pk_e, pk_k: s {    pk_t := PACK_HEADER + PACK_ENTRY * pk_k;    out[pk_t] = cast,trunc(u8) pk_e.kind; out[pk_t + 1] = cast,trunc(u8) pk_e.licence; out[pk_t + 2] = 0; out[pk_t + 3] = 0;    pack_put32(out, pk_t + 4, pk_at); pack_put32(out, pk_t + 8, pk_e.data.count); pack_put32(out, pk_t + 12, 0);    for pk_j: 0..<PACK_NAME { out[pk_t + 16 + pk_j] = ifx pk_j < pk_e.name.count then pk_e.name[pk_j] else 0; }    for pk_j: 0..<pack_pad(pk_e.data.count) { out[pk_at + pk_j] = ifx pk_j < pk_e.data.count then pk_e.data[pk_j] else 0; }    pk_at += pack_pad(pk_e.data.count);  }  return pk_total;}

Admitted by content

A pack read whole becomes a realm's assets entry by entry, each known by the SHA-256 of its bytes, through chapter 16's registry. The registry takes the whole pack or none of it. Bytes it already holds are shared, not counted twice:

jai
// A pack read takes its place in a realm's assets as its entries, each known by its content// (chapter 16): taken whole, or refused whole and nothing held changes.pack_admit :: (reg: [] AssetRegistry, p: string, r: [] PackRead) -> int #effects(all) {  if !r[0].ok { return asset_refuse(reg, ASSET_MALFORMED, ASSET_NONE, 0, reg[0].held); }  pk_content: [PACK_READ_MAX] string; pk_table: [PACK_READ_MAX] AssetId;  for pk_k: 0..<r[0].count { pk_content[pk_k] = pack_bytes(p, r, pk_k); pk_table[pk_k] = asset_id(pk_content[pk_k]); }  return asset_admit(reg, pk_content[0..<r[0].count], pk_table[0..<r[0].count]);}

Worked by hand

A tiny pack has five entries: a crate's catalog (206 bytes), 6 bytes of vertices, 12 of indices, one texture layer of 5 bytes from the kit (source 0) and a door's sound of 3 bytes (source 1). The header and table take 32 + 5 × 48 = 272 bytes, so the catalog starts at 272. Its 206 bytes pad to 208, so the vertices start at 480. The vertices pad from 6 to 8 (indices at 488), the indices take 12 (layer at 500), and the layer pads from 5 to 8 (sound at 508). The sound pads from 3 to 4, so the pack ends at 512. That is the bytes 512 its catalog states, under a budget of 600.

The entries' bytes add up to 206 + 6 + 12 + 5 + 3 = 232. A realm whose assets may hold 232 bytes admits the pack: five assets, 232 bytes. The same pack again adds a use to each entry and no bytes. A realm with 231 bytes refuses it and holds nothing.

Three broken packs:

  • The same entries with the layer under source 1, while its catalog line T 0 layer3.jpg 0 says source 0. The catalog's account fails at the layer, entry 3.
  • The same bytes under a budget of 511. The header says the pack is over its budget.
  • The pack one byte short. Its header's size, 512, isn't its size, 511.

Bring in a crate

The program is metaverse-engine/examples/bring-in-assets.coax:

jai
#load "../editor/pack.coax";#import "Basic";CATALOG :: "pack tiny\nbudget 600\nbytes 512\nL 0 Kit|CC0 1.0 Universal|https://example.org/\nL 1 Sounds|CC0 1.0 Universal|https://example.org/\nM Crate 0 3 0 -0.500 0.000 -0.500 0.500 1.000 0.500\nT 0 layer3.jpg 0\nS door 1\n";// The tiny pack's five entries: a crate's catalog, vertices and indices, one texture layer from// the kit (source 0) and a door's sound (source 1).sources :: (out: [] PackSource, layer_licence: int) {  out[0] = PackSource.{kind = PACK_CATALOG, licence = PACK_MANY, name = "catalog", data = CATALOG};  out[1] = PackSource.{kind = PACK_VERTICES, licence = PACK_MANY, name = "vertices", data = "vvvvvv"};  out[2] = PackSource.{kind = PACK_INDICES, licence = PACK_MANY, name = "indices", data = "iiiiiiiiiiii"};  out[3] = PackSource.{kind = PACK_LAYER, licence = layer_licence, name = "layer0", data = "JPEG!"};  out[4] = PackSource.{kind = PACK_SOUND, licence = 1, name = "door", data = "mp3"};}// Why a pack is refused, or "read whole".verdict :: (p: string) -> string {  r: [1] PackRead;  if pack_read(p, r[..]) { return "read whole"; }  return r[0].why;}main :: () {  s: [5] PackSource; sources(s[..], 0);  print("the pack takes % bytes\n", pack_size(s[..]));  b: [600] u8; n := pack_write(s[..], 600, b[..]);  p := cast(string) b[0..<n];  r: [1] PackRead;  print("read: %, % entries, % sources\n", pack_read(p, r[..]), r[0].count, r[0].sources);  for k: 0..<r[0].count {    e := r[0].entries[k];    print("  % kind % licence %: % bytes at %\n", e.name, e.kind, e.licence, e.n, e.at);  }  hex: [64] u8; ok := asset_hex(asset_id(pack_bytes(p, r[..], 3)), hex[..]);  print("layer0 is asset %\n", cast(string) hex[..]);  // Admitted into a realm's assets: 206 + 6 + 12 + 5 + 3 = 232 bytes.  reg: [1] AssetRegistry; reg[0] = asset_registry(232);  print("admitted under 232 bytes: %, % assets, % bytes\n", pack_admit(reg[..], p, r[..]) == ASSET_OK, reg[0].held, reg[0].used);  print("the same pack again: %, % bytes, layer0 used % times\n", pack_admit(reg[..], p, r[..]) == ASSET_OK, reg[0].used, asset_uses(reg[0], asset_id("JPEG!")));  small: [1] AssetRegistry; small[0] = asset_registry(231);  print("under 231 bytes: refused % (asked %), % held\n", pack_admit(small[..], p, r[..]) == ASSET_OVER_BYTES, small[0].first.asked, small[0].held);  // Broken packs. The layer given the sounds' licence, while its catalog line says the kit's:  t: [5] PackSource; sources(t[..], 1);  c: [600] u8; m := pack_write(t[..], 600, c[..]);  q := cast(string) c[0..<m];  bad: [1] PackRead; refused := !pack_read(q, bad[..]);  print("layer0 under source 1: refused %: % (entry %); the read keeps % entries\n", refused, bad[0].why, bad[0].entry, bad[0].count);  // The same bytes under a 511-byte budget, and one byte cut off the end.  d: [600] u8; m = pack_write(s[..], 511, d[..]);  print("a 511-byte budget: %\n", verdict(cast(string) d[0..<m]));  print("one byte short: %\n", verdict(p[0..<n - 1]));}
shell
coax/bin/coax run metaverse-engine/examples/bring-in-assets.coax
text
the pack takes 512 bytes
read: true, 5 entries, 2 sources
  catalog kind 1 licence 255: 206 bytes at 272
  vertices kind 2 licence 255: 6 bytes at 480
  indices kind 3 licence 255: 12 bytes at 488
  layer0 kind 4 licence 0: 5 bytes at 500
  door kind 5 licence 1: 3 bytes at 508
layer0 is asset c579f80088119b4b77f6a8b32c542ce2ab6033574361a03c08ab6c32fb5b9487
admitted under 232 bytes: true, 5 assets, 232 bytes
the same pack again: true, 232 bytes, layer0 used 2 times
under 231 bytes: refused true (asked 232), 0 held
layer0 under source 1: refused true: an asset without a declared licence (entry 3); the read keeps 0 entries
a 511-byte budget: over its budget
one byte short: its stated size isn't its size

Every number is the hand-worked one. The layer's id is its SHA-256, which printf 'JPEG!' | sha256sum agrees with:

text
c579f80088119b4b77f6a8b32c542ce2ab6033574361a03c08ab6c32fb5b9487  -

The committed packs

The independent check is pack_realm.py itself. It wrote both committed packs, and the Coax writer, fed what the Coax reader read, must give back the same bytes. metaverse-engine/tools/pack-check.coax reads each pack, writes it again, compares the bytes and admits the pack under its own budget:

shell
coax/web/tool.sh metaverse-engine/tools/pack-check.coax apps/openagents-web/realms/fixture/assets/fixture.pack apps/openagents-web/realms/everglade/assets/everglade.pack
text
apps/openagents-web/realms/fixture/assets/fixture.pack: 1267160 bytes of a 1500000-byte budget, 11 entries, 4 sources
  ...
  10 sound chime licence 3, 10100 bytes at 1257060
  sha256 df9c027378c87383f5be40d61c764b9fb615148524388d4b310229e9b0e39ad9
  written again from what was read: the same bytes
  admitted under its budget: true, 11 assets, 1266591 bytes
apps/openagents-web/realms/everglade/assets/everglade.pack: 9039012 bytes of a 9050000-byte budget, 39 entries, 6 sources
  ...
  38 layer layer35 licence 4, 6157 bytes at 9032852
  sha256 5595e2a3839bb38bd2cd839c688bb9a13a64ed23958fda84907e03c0dc90f8d8
  written again from what was read: the same bytes
  admitted under its budget: true, 38 assets, 9035236 bytes

Both SHA-256s are the ones sha256sum prints for the files. The fixture's df9c027378c8 is also the content name its engine manifest uses (chapter 54). The fixture admits 11 assets but holds 1,266,591 bytes: its file's 1,267,160 bytes less the header, the table and the padding. Everglade's 39 entries are 38 assets, because layer18 and layer19 are the same 1,820 bytes, held once. (Only each pack's last lines are shown; the tool prints every entry.)

Checks

  • coax/bin/coax test metaverse-engine/editor/pack.coax --library (34 checks with chapter 16's and SHA-256's): the layout written and read back; the writer's refusals and every byte written once; each header field refused whole; entries out of order, malformed or out of place, each named; the catalog's account of the budget, size, sources, meshes, layers and sounds; three and 48 entries, and a table that ends the pack; admission by content, whole or not at all.
  • coax/bin/coax mutate metaverse-engine/editor/pack.coax --root-only: 564 mutants, 564 killed.
  • coax/bin/coax run metaverse-engine/examples/bring-in-assets.coax (in the book's --coax runs, debug and release): the trace above.
  • coax/web/tool.sh metaverse-engine/tools/pack-check.coax PACK...: the committed packs, written again to the same bytes.

What exists beside it

Still to do

  • Import from sources. import_pack from a manifest (metaverse/packs/*.json): the scene's meshes, the images (with the painterly style's texture rules and paint pass), the sounds and the characters, giving packs byte-identical to pack_realm.py's for everglade.json and fixture.json, and then the Python retired. Today only the last step, laying out entries already made, is Coax.
  • Units. metaverse-engine/editor/units.coax: per-kind size ranges; a centimetre model rescaled into range with its factor in the report, and a kit mesh out of range refused. droprealm.coax scales dropped models today, without a report.
  • Uploads. metaverse-engine/editor/upload.coax: admit, upload and scan as typed states (sending, scanning, kept, refused, failed). An upload that fails its scan never reaches the realm's state.
  • One path for every pack. The Grid's cast, the drops packer (drops.c) and pack-files.coax reading and writing through pack.coax.
  • The licence report. licences.md written from the catalog the reader checked, not beside it by the packer.

Dependencies

Chapter 2 (units), chapter 14 (rigs and clips), chapter 16 (identities and budgets) and chapter 51 (what a document may name).

See also the runnable PLE data-hall scene fixture example in ple-data-hall.coax.