@wildshard/shard-format 0.4.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/corpus/brasscap-mesa/sections/look/look.json +1 -1
  2. package/corpus/brasscap-mesa/shard.json +1 -1
  3. package/corpus/brasscap-mesa/validation.json +1 -1
  4. package/package.json +16 -15
  5. package/src/cli/main.ts +2 -2
  6. package/src/cli/pack.ts +3 -3
  7. package/src/cli/validate.ts +33 -27
  8. package/src/format/assembly-hosts.ts +77 -0
  9. package/src/format/assetAdmission.ts +5 -5
  10. package/src/format/cook-preparation.ts +2 -2
  11. package/src/format/deviceMemoryCost.ts +2 -2
  12. package/src/format/{directorProduct.ts → directorDocument.ts} +3 -3
  13. package/src/format/entryClearance.ts +1 -1
  14. package/src/format/glbCost.ts +1 -1
  15. package/src/format/immutable.ts +1 -1
  16. package/src/format/issue-codes.ts +1 -1
  17. package/src/format/ktx2Cost.ts +1 -1
  18. package/src/format/look-light.ts +78 -0
  19. package/src/format/materials.ts +1 -1
  20. package/src/format/namedJsonContracts.ts +1 -1
  21. package/src/format/nearPlaceholderAssets.ts +1 -1
  22. package/src/format/outputDownload.ts +1 -1
  23. package/src/format/outputIndex.ts +1 -1
  24. package/src/format/platformFileFamilies.ts +3 -2
  25. package/src/format/receipt-cost.ts +3 -3
  26. package/src/format/registeredJson.ts +4 -4
  27. package/src/format/script-side-grandfather.ts +12 -13
  28. package/src/format/script-sides.ts +36 -38
  29. package/src/format/script-view-returns.ts +142 -0
  30. package/src/format/shardSchema.ts +7 -5
  31. package/src/format/{product-audio.ts → shardfile-audio.ts} +7 -7
  32. package/src/format/{product-stream-admit.ts → shardfile-stream-admit.ts} +11 -8
  33. package/src/format/{product-stream-assets.ts → shardfile-stream-assets.ts} +7 -7
  34. package/src/format/{product-stream-facts.ts → shardfile-stream-facts.ts} +3 -3
  35. package/src/format/{product-stream-node.ts → shardfile-stream-node.ts} +2 -2
  36. package/src/format/{product-stream-packs.ts → shardfile-stream-packs.ts} +1 -1
  37. package/src/format/{product-stream-rows.ts → shardfile-stream-rows.ts} +6 -6
  38. package/src/format/{product-stream.ts → shardfile-stream.ts} +25 -25
  39. package/src/format/{productValidation.ts → shardfileValidation.ts} +14 -14
  40. package/src/format/sourceResidency.ts +4 -4
  41. package/src/format/tar.ts +1 -1
  42. package/src/format/validationReceipt.ts +2 -2
  43. /package/src/format/{product.ts → shardfile-assets.ts} +0 -0
  44. /package/src/format/{product-reads.ts → shardfile-reads.ts} +0 -0
  45. /package/src/format/{product-stream-miss.ts → shardfile-stream-miss.ts} +0 -0
  46. /package/src/format/{product-stream-tar.ts → shardfile-stream-tar.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "./arenaRoomDocument": "./src/format/arenaRoomDocument.ts",
46
46
  "./arenaScriptRows": "./src/format/arenaScriptRows.ts",
47
47
  "./arenaView": "./src/format/arenaView.ts",
48
+ "./assemblyHosts": "./src/format/assembly-hosts.ts",
48
49
  "./assetAdmission": "./src/format/assetAdmission.ts",
49
50
  "./audio": "./src/format/audio.ts",
50
51
  "./audioBank": "./src/format/audioBank.ts",
@@ -52,7 +53,7 @@
52
53
  "./audioMeasure": "./src/format/audio-measure.ts",
53
54
  "./audioRules": "./src/format/audio-rules.ts",
54
55
  "./audioWaiver": "./src/format/audio-waiver.ts",
55
- "./productAudio": "./src/format/product-audio.ts",
56
+ "./shardfileAudio": "./src/format/shardfile-audio.ts",
56
57
  "./audioRouting": "./src/format/audioRouting.ts",
57
58
  "./audioScene": "./src/format/audioScene.ts",
58
59
  "./bakedTerrainBytes": "./src/format/bakedTerrainBytes.ts",
@@ -104,7 +105,7 @@
104
105
  "./declaredQuestPage": "./src/format/declaredQuestPage.ts",
105
106
  "./deviceMemoryCost": "./src/format/deviceMemoryCost.ts",
106
107
  "./director": "./src/format/director.ts",
107
- "./directorProduct": "./src/format/directorProduct.ts",
108
+ "./directorDocument": "./src/format/directorDocument.ts",
108
109
  "./directorStages": "./src/format/directorStages.ts",
109
110
  "./directorWhen": "./src/format/directorWhen.ts",
110
111
  "./discoveryValues": "./src/format/discoveryValues.ts",
@@ -244,10 +245,10 @@
244
245
  "./practiceCourseRows": "./src/format/practiceCourseRows.ts",
245
246
  "./preflight": "./src/format/preflight.ts",
246
247
  "./presentation": "./src/format/presentation.ts",
247
- "./product": "./src/format/product.ts",
248
- "./productValidation": "./src/format/productValidation.ts",
249
- "./productStream": "./src/format/product-stream.ts",
250
- "./productStreamNode": "./src/format/product-stream-node.ts",
248
+ "./shardfileAssets": "./src/format/shardfile-assets.ts",
249
+ "./shardfileValidation": "./src/format/shardfileValidation.ts",
250
+ "./shardfileStream": "./src/format/shardfile-stream.ts",
251
+ "./shardfileStreamNode": "./src/format/shardfile-stream-node.ts",
251
252
  "./meshoptModule": "./src/format/meshopt-module.ts",
252
253
  "./meshoptStatic": "./src/format/meshopt-static.mjs",
253
254
  "./propMaterials": "./src/format/propMaterials.ts",
@@ -344,7 +345,7 @@
344
345
  "./stillImage": "./src/format/stillImage.ts",
345
346
  "./streamedCover": "./src/format/streamedCover.ts",
346
347
  "./surfaceLooks": "./src/format/surfaceLooks.ts",
347
- "./product-reads": "./src/format/product-reads.ts",
348
+ "./shardfile-reads": "./src/format/shardfile-reads.ts",
348
349
  "./tar": "./src/format/tar.ts",
349
350
  "./targets": "./src/format/targets.ts",
350
351
  "./terrain": "./src/format/terrain.ts",
@@ -393,22 +394,22 @@
393
394
  "packageManager": "pnpm@10.34.9",
394
395
  "scripts": {
395
396
  "pnpm:devPreinstall": "git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath .githooks || true",
396
- "typecheck": "tsc -p src/tsconfig.json && tsc -p src/format/tsconfig.json && tsc -p src/format/tsconfig.lib.json",
397
- "lint": "oxlint -c src/.oxlintrc.json --type-aware --deny-warnings --no-error-on-unmatched-pattern --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**' --ignore-pattern 'scripts/chromium-keychain*' --ignore-pattern 'scripts/worktree-ignore*' --ignore-pattern 'scripts/land*' --ignore-pattern 'scripts/worktree.mjs' --ignore-pattern 'scripts/worktree-reap.mjs' --ignore-pattern 'scripts/pid-lock*' --ignore-pattern 'scripts/apfs-clone.mjs' --ignore-pattern 'scripts/assert-store-layout.mjs' --ignore-pattern 'test/tooling/worktree-guard.test.mjs' --ignore-pattern 'scripts/vite-tmp*' --ignore-pattern 'vitest.config.ts' --ignore-pattern 'test/tooling/chrome-keychain.test.mjs' --ignore-pattern 'packages/wire/frozen/**' --ignore-pattern 'packages/wire/lib/**'",
398
- "lint:fix": "oxlint -c src/.oxlintrc.json --type-aware --fix --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**'",
397
+ "typecheck": "tsc -p kit/tsconfig.json && tsc -p src/format/tsconfig.json && tsc -p src/format/tsconfig.lib.json",
398
+ "lint": "node kit/scripts/lint.mjs --type-aware --deny-warnings --no-error-on-unmatched-pattern --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**' --ignore-pattern 'scripts/chromium-keychain*' --ignore-pattern 'scripts/worktree-ignore*' --ignore-pattern 'scripts/land*' --ignore-pattern 'scripts/worktree.mjs' --ignore-pattern 'scripts/worktree-reap.mjs' --ignore-pattern 'scripts/pid-lock*' --ignore-pattern 'scripts/apfs-clone.mjs' --ignore-pattern 'scripts/assert-store-layout.mjs' --ignore-pattern 'test/tooling/worktree-guard.test.mjs' --ignore-pattern 'scripts/vite-tmp*' --ignore-pattern 'vitest.config.ts' --ignore-pattern 'test/tooling/chrome-keychain.test.mjs' --ignore-pattern 'packages/wire/frozen/**' --ignore-pattern 'packages/wire/lib/**'",
399
+ "lint:fix": "node kit/scripts/lint.mjs --type-aware --fix --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**'",
399
400
  "lint:format": "node src/tools/format-ratchet.ts",
400
- "format": "oxfmt -c src/.oxfmtrc.json src '!src/format/**' '!src/test/fixtures/**'",
401
- "format:check": "oxfmt -c src/.oxfmtrc.json --check src '!src/format/**' '!src/test/fixtures/**'",
401
+ "format": "oxfmt -c kit/.oxfmtrc.json kit src '!src/format/**' '!src/test/fixtures/**'",
402
+ "format:check": "oxfmt -c kit/.oxfmtrc.json --check kit src '!src/format/**' '!src/test/fixtures/**'",
402
403
  "test": "node --test 'src/!(format|ci)/**/*.test.ts'",
403
404
  "test:ci": "node --test 'src/ci/**/*.test.ts'",
404
405
  "test:format": "vitest run src/format --testTimeout=30000 --maxWorkers=2",
405
- "check:asks": "node src/scripts/asks.mjs check",
406
+ "check:asks": "node kit/scripts/asks.mjs check",
406
407
  "check:agents": "node .githooks/agents-md.mjs lint",
407
408
  "check:parity": "node scripts/agent-parity.mjs --strict",
408
409
  "check:agent-sync": "node scripts/agent-sync.mjs --check",
409
410
  "test:agent-hooks": "node --test '.agents/hooks/test/*.test.mjs'",
410
411
  "agents:sync": "node scripts/agent-sync.mjs",
411
- "md:wrap": "node src/scripts/md-wrap.mjs",
412
+ "md:wrap": "node kit/scripts/md-wrap.mjs",
412
413
  "test:hooks": "node --test '.githooks/*.test.mjs'",
413
414
  "check": "pnpm typecheck && pnpm lint && pnpm lint:format && pnpm format:check && pnpm test && pnpm test:format && pnpm check:asks && pnpm check:agents && pnpm check:agent-sync && pnpm test:agent-hooks && pnpm check:parity && node --check scripts/chromium-keychain-check.mjs && node --test test/tooling/chrome-keychain.test.mjs && pnpm check:wire",
414
415
  "check:wire": "pnpm --dir packages/wire check && pnpm --dir packages/wire test && pnpm check:wire-proofs",
package/src/cli/main.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { parseArgs } from 'node:util'
3
3
 
4
4
  import { packFolder } from './pack.ts'
5
- import { summary, validateProduct } from './validate.ts'
5
+ import { summary, validateShardfile } from './validate.ts'
6
6
  import { readVersion } from './version.ts'
7
7
 
8
8
  const EXIT_OK = 0
@@ -77,7 +77,7 @@ async function validate(operands: readonly string[]): Promise<number> {
77
77
  return EXIT_USAGE
78
78
  }
79
79
  try {
80
- process.stdout.write(`${summary(await validateProduct(dir))}\n`)
80
+ process.stdout.write(`${summary(await validateShardfile(dir))}\n`)
81
81
  return EXIT_OK
82
82
  } catch (error: unknown) {
83
83
  const reason = error instanceof Error ? error.message : String(error)
package/src/cli/pack.ts CHANGED
@@ -6,11 +6,11 @@ import {
6
6
  assembleOutputShardfile,
7
7
  parseOutputIndex,
8
8
  } from '../format/outputIndex.ts'
9
- import { packFromMembers } from '../format/product-reads.ts'
10
9
  import { receiptCost } from '../format/receipt-cost.ts'
10
+ import { packFromMembers } from '../format/shardfile-reads.ts'
11
11
  import { writeTar } from '../format/tar.ts'
12
12
  import { validationSourceBytes } from '../format/validationReceipt.ts'
13
- import { productFiles, validateInMemory } from './validate.ts'
13
+ import { shardfileFiles, validateInMemory } from './validate.ts'
14
14
 
15
15
  // `shardfile pack <dir>`: a folder a person holds becomes a tarball, with
16
16
  // format alone (J168). An author edits a section and packs: what the sections
@@ -98,7 +98,7 @@ function jsonOf(bytes: Readonly<Uint8Array>): unknown {
98
98
  }
99
99
 
100
100
  function readFolder(dir: string): Files {
101
- const product = productFiles(dir)
101
+ const product = shardfileFiles(dir)
102
102
  const kept = [...product.paths()].filter(
103
103
  (file: string): boolean => !file.startsWith(PACKS),
104
104
  )
@@ -10,26 +10,26 @@ import {
10
10
  } from 'node:fs'
11
11
  import path from 'node:path'
12
12
 
13
- import { prepareAssetDecoders } from '../format/product.ts'
14
- import { validateShardfileProduct } from '../format/productValidation.ts'
15
13
  import { receiptResidencyShortfall } from '../format/receipt-cost.ts'
14
+ import { prepareAssetDecoders } from '../format/shardfile-assets.ts'
15
+ import { validateShardfileFolder } from '../format/shardfileValidation.ts'
16
16
  import { readTar } from '../format/tar.ts'
17
17
 
18
18
  import type {
19
- ProductFiles,
20
- ValidatedProduct,
21
- } from '../format/productValidation.ts'
19
+ ShardfileFiles,
20
+ ValidatedShardfile,
21
+ } from '../format/shardfileValidation.ts'
22
22
 
23
23
  // `shardfile validate <dir|tar>`: format validation of a built product, as a
24
24
  // folder or as the tarball a host takes (P1 F3 (a)): schema, inventory, hashes, sizes, costs, budgets and
25
25
  // admission rows. It never runs script bytes; that is the execution proof
26
26
  // in sharddev and the cook worker.
27
27
  //
28
- // Format's ProductFiles port is synchronous, so the reads here are too.
28
+ // Format's ShardfileFiles port is synchronous, so the reads here are too.
29
29
  // A read is bounded by the size the index declares, and an unlisted file
30
30
  // is refused without being read.
31
31
 
32
- interface ProductSummary {
32
+ interface ValidationSummary {
33
33
  readonly slug: string
34
34
  readonly revision: number
35
35
  readonly sections: number
@@ -53,12 +53,12 @@ function regularFile(root: string, file: string): string {
53
53
  let target = root
54
54
  for (const part of file.split('/')) {
55
55
  target = path.resolve(target, part)
56
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
56
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
57
57
  if (lstatSync(target).isSymbolicLink()) {
58
58
  throw new Error(`symlinks are refused: ${file}`)
59
59
  }
60
60
  }
61
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
61
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
62
62
  if (!lstatSync(target).isFile()) {
63
63
  throw new Error(`not a regular file: ${file}`)
64
64
  }
@@ -66,27 +66,27 @@ function regularFile(root: string, file: string): string {
66
66
  }
67
67
 
68
68
  function boundedRead(file: string, maxBytes: number): Uint8Array {
69
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
69
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
70
70
  const fd = openSync(file, 'r')
71
71
  try {
72
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
72
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
73
73
  const { size } = fstatSync(fd)
74
74
  if (size > maxBytes) {
75
75
  throw new Error(`larger than its declared size: ${file}`)
76
76
  }
77
77
  const bytes = new Uint8Array(size)
78
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
78
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
79
79
  readSync(fd, bytes, START, size, START)
80
80
  return bytes
81
81
  } finally {
82
- // oxlint-disable-next-line node/no-sync -- ProductFiles.read is synchronous
82
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.read is synchronous
83
83
  closeSync(fd)
84
84
  }
85
85
  }
86
86
 
87
87
  /** Every non-directory entry, symlinks included, as `/`-separated paths. */
88
88
  function productPaths(root: string): string[] {
89
- // oxlint-disable-next-line node/no-sync -- ProductFiles.paths is synchronous
89
+ // oxlint-disable-next-line node/no-sync -- ShardfileFiles.paths is synchronous
90
90
  const entries = readdirSync(root, { recursive: true, withFileTypes: true })
91
91
  const kept = entries.filter(
92
92
  (entry: Readonly<{ isDirectory: () => boolean }>): boolean =>
@@ -100,7 +100,7 @@ function productPaths(root: string): string[] {
100
100
  )
101
101
  }
102
102
 
103
- function productFiles(root: string): ProductFiles {
103
+ function shardfileFiles(root: string): ShardfileFiles {
104
104
  return {
105
105
  read: (file: string, maxBytes: number): Uint8Array =>
106
106
  boundedRead(regularFile(root, file), maxBytes),
@@ -111,7 +111,7 @@ function productFiles(root: string): ProductFiles {
111
111
  /** A product already in memory: an unpacked tarball, or `pack`'s result. */
112
112
  function memoryFiles(
113
113
  files: ReadonlyMap<string, Readonly<Uint8Array>>,
114
- ): ProductFiles {
114
+ ): ShardfileFiles {
115
115
  return {
116
116
  read: (file: string, maxBytes: number): Uint8Array => {
117
117
  const bytes = files.get(file)
@@ -130,14 +130,14 @@ function memoryFiles(
130
130
  /** A product already in memory, validated with format alone. */
131
131
  async function validateInMemory(
132
132
  files: ReadonlyMap<string, Readonly<Uint8Array>>,
133
- ): Promise<ValidatedProduct> {
133
+ ): Promise<ValidatedShardfile> {
134
134
  await prepareAssetDecoders()
135
- return validateShardfileProduct(memoryFiles(files), { hash: sha256 })
135
+ return validateShardfileFolder(memoryFiles(files), { hash: sha256 })
136
136
  }
137
137
 
138
138
  /** The receipt's JSON, or why it can't be read. */
139
139
  function readReceipt(
140
- files: ProductFiles,
140
+ files: ShardfileFiles,
141
141
  ): Readonly<{ receipt: unknown }> | string {
142
142
  try {
143
143
  const bytes = files.read(RECEIPT, RECEIPT_BYTES)
@@ -150,7 +150,7 @@ function readReceipt(
150
150
  /** The receipt's figures, or why they can't be read. A receipt is evidence
151
151
  * the validator never reads, so a bad one warns rather than refuses. */
152
152
  function receiptWarnings(
153
- files: ProductFiles,
153
+ files: ShardfileFiles,
154
154
  shortfall: (receipt: unknown) => string | undefined,
155
155
  ): readonly string[] {
156
156
  if (![...files.paths()].includes(RECEIPT)) {
@@ -164,20 +164,20 @@ function receiptWarnings(
164
164
  return found === undefined ? [] : [found]
165
165
  }
166
166
 
167
- function targetFiles(target: string): ProductFiles {
167
+ function targetFiles(target: string): ShardfileFiles {
168
168
  // oxlint-disable-next-line node/no-sync -- read before the sync validator
169
169
  if (lstatSync(target).isFile()) {
170
170
  // oxlint-disable-next-line node/no-sync -- read before the sync validator
171
171
  return memoryFiles(readTar(readFileSync(target)))
172
172
  }
173
- return productFiles(target)
173
+ return shardfileFiles(target)
174
174
  }
175
175
 
176
176
  /** Validates the built product at `target` with format alone. */
177
- async function validateProduct(target: string): Promise<ProductSummary> {
177
+ async function validateShardfile(target: string): Promise<ValidationSummary> {
178
178
  await prepareAssetDecoders()
179
179
  const files = targetFiles(path.resolve(target))
180
- const valid = validateShardfileProduct(files, { hash: sha256 })
180
+ const valid = validateShardfileFolder(files, { hash: sha256 })
181
181
  // A memory figure below the product's own files (Brasscap rev 3: 2,930,740
182
182
  // over 4,670,827) warns rather than refuses while a pinned product still
183
183
  // carries one; `pack` restamps it.
@@ -197,7 +197,7 @@ async function validateProduct(target: string): Promise<ProductSummary> {
197
197
  }
198
198
 
199
199
  /** One line for a product that passed, then one `warning:` line for each of its warnings. */
200
- function summary(product: ProductSummary): string {
200
+ function summary(product: ValidationSummary): string {
201
201
  const counts = `${String(product.sections)} sections, ${String(product.assets)} assets`
202
202
  const ok = `ok ${product.slug} r${String(product.revision)}: ${counts}, source ${product.sourceHash}`
203
203
  return [
@@ -206,5 +206,11 @@ function summary(product: ProductSummary): string {
206
206
  ].join('\n')
207
207
  }
208
208
 
209
- export type { ProductSummary }
210
- export { memoryFiles, productFiles, summary, validateInMemory, validateProduct }
209
+ export type { ValidationSummary }
210
+ export {
211
+ memoryFiles,
212
+ shardfileFiles,
213
+ summary,
214
+ validateInMemory,
215
+ validateShardfile,
216
+ }
@@ -0,0 +1,77 @@
1
+ // SHARD-AUTHORING SA20: named hosts for a headless assembly's `$ref`s.
2
+ // A shard's data never names an engine module path (J158). Where an
3
+ // assembly operand reads an engine function, it names a host instead:
4
+ // `{ "$ref": ["host", "proveTerrainEntries"] }`. The host list is closed
5
+ // and lives here, so a shard and the engine agree on it through the format.
6
+
7
+ /** Every host an assembly `$ref` may name, with what it is. */
8
+ const ASSEMBLY_HOSTS: Readonly<Record<string, string>> = Object.freeze({
9
+ clamp: 'clamp(value, min, max)',
10
+ proveTerrainEntries:
11
+ "the terrain entry walk: (physics, entryways, heightAt, spec) => the shard's proven entries",
12
+ })
13
+
14
+ /** The head of a host `$ref`: `["host", <name>, ...path]`. */
15
+ const ASSEMBLY_HOST_HEAD = 'host'
16
+
17
+ const MODULE_PATH = /^(?:@|src\/|\.{1,2}\/)/u
18
+
19
+ function refIssue(ref: readonly unknown[], where: string): string | undefined {
20
+ const [head, name] = ref
21
+ if (typeof head !== 'string') {
22
+ return undefined
23
+ }
24
+ if (MODULE_PATH.test(head)) {
25
+ return `${where}: $ref names the module path ${head}; name a host instead: ["${ASSEMBLY_HOST_HEAD}", <name>]`
26
+ }
27
+ if (
28
+ head === ASSEMBLY_HOST_HEAD &&
29
+ (typeof name !== 'string' || !Object.hasOwn(ASSEMBLY_HOSTS, name))
30
+ ) {
31
+ return `${where}: $ref names the unknown host ${String(name)}; hosts: ${Object.keys(ASSEMBLY_HOSTS).join(', ')}`
32
+ }
33
+ return undefined
34
+ }
35
+
36
+ type Child = readonly [here: string, key: string, item: unknown]
37
+
38
+ function childrenOf(value: unknown, where: string): readonly Child[] {
39
+ if (Array.isArray(value)) {
40
+ return value.map((item: unknown, index: number): Child => [
41
+ `${where}[${String(index)}]`,
42
+ String(index),
43
+ item,
44
+ ])
45
+ }
46
+ if (value === null || typeof value !== 'object') {
47
+ return []
48
+ }
49
+ return Object.entries(value).map(
50
+ ([key, item]: readonly [string, unknown]): Child => [
51
+ `${where}.${key}`,
52
+ key,
53
+ item,
54
+ ],
55
+ )
56
+ }
57
+
58
+ function collect(value: unknown, where: string): string[] {
59
+ const issues: string[] = []
60
+ for (const [here, key, item] of childrenOf(value, where)) {
61
+ const issue =
62
+ key === '$ref' && Array.isArray(item) ? refIssue(item, here) : undefined
63
+ if (issue !== undefined) {
64
+ issues.push(issue)
65
+ }
66
+ issues.push(...collect(item, here))
67
+ }
68
+ return issues
69
+ }
70
+
71
+ /** Every `$ref` in an assembly document that names a module path or an
72
+ * unknown host, as `<json path>: <fix>` lines; none means it passes. */
73
+ function assemblyRefIssues(document: unknown): string[] {
74
+ return collect(document, '$')
75
+ }
76
+
77
+ export { ASSEMBLY_HOST_HEAD, ASSEMBLY_HOSTS, assemblyRefIssues }
@@ -1,11 +1,11 @@
1
- import { acceptsProductCost, textureLibrarySource } from './deviceMemoryCost.ts';
1
+ import { acceptsShardfileCost, textureLibrarySource } from './deviceMemoryCost.ts';
2
2
  import { admitScriptContract, decisionModuleContracts, type ScriptAdmissionRows } from './scriptContract.ts';
3
3
  import type { TextureTranscodeSupport } from './contentBounds.ts';
4
4
  import { admitScript } from './scriptAdmission.ts';
5
5
  import { SCRIPT_LIMITS } from './scriptLimits.ts';
6
6
  import { worstContentCost } from './budget.ts';
7
7
  import { parseShardfile, type Shardfile } from './shardSchema.ts';
8
- import { assetCost, validateTerrainAssets, validatePropDrawBounds, preflightAssetGraph, type PropExtent } from './product.ts';
8
+ import { assetCost, validateTerrainAssets, validatePropDrawBounds, preflightAssetGraph, type PropExtent } from './shardfile-assets.ts';
9
9
  import type { MemoryAdmission } from './memoryAdmission.ts';
10
10
 
11
11
  import { validateMeshCollisionAssets } from './meshCollisionAssets.ts';
@@ -63,11 +63,11 @@ function preflightDeclaredCosts(source: Shardfile, memory?: MemoryAdmission): {
63
63
  }
64
64
  const resident = Object.values(commons).reduce((total, cost) => total + cost.decoded + cost.gpu, 0);
65
65
  const worst = worstContentCost(source, resident);
66
- if (!acceptsProductCost(memory, source, 'declared', worst)) throw new Error(`declared worst-location total exceeds envelope: ${worst.playing}`);
66
+ if (!acceptsShardfileCost(memory, source, 'declared', worst)) throw new Error(`declared worst-location total exceeds envelope: ${worst.playing}`);
67
67
  return { commons, worst };
68
68
  }
69
69
 
70
- /** One `validateShardfileAssets` run's state between its steps. The streaming validator (`product-stream-assets.ts`,
70
+ /** One `validateShardfileAssets` run's state between its steps. The streaming validator (`shardfile-stream-assets.ts`,
71
71
  * API-CLOUDFLARE AC6a2) runs `admitFileBytes` per file as its bytes stream past, then the rest in this order. */
72
72
  interface AssetAdmission {
73
73
  readonly shard: Shardfile;
@@ -248,7 +248,7 @@ function admitAfterFiles(state: AssetAdmission, assets: ReadonlyMap<string, Uint
248
248
  if (clientModules.size + new Set(scripts.filter(row => row.side === 'view').map(row => row.module)).size > SCRIPT_LIMITS.instances || clientMemory > SCRIPT_LIMITS.memoryBytes || libraryResident > s.budgets.library.resident) throw new Error('client script memory or view budget understated or above host cap');
249
249
  if (libraryResident + sketchResident > s.budgets.library.resident) throw new Error('compendium sketch raster budget understated');
250
250
  const cost = worstContentCost(textureLibrarySource(s, assets, textures), commons);
251
- if (!acceptsProductCost(memory, s, 'actual', cost)) throw new Error(`worst-location total exceeds envelope: ${cost.playing}`);
251
+ if (!acceptsShardfileCost(memory, s, 'actual', cost)) throw new Error(`worst-location total exceeds envelope: ${cost.playing}`);
252
252
  validateNavigationAssets(s, assets);
253
253
  validateNativeGround(s, assets);
254
254
  validateEntrywayTerrain(s, assets);
@@ -187,7 +187,7 @@ function programMountValid(
187
187
  mount?.hash !== digest(validationSourceBytes(cook.programs))
188
188
  ) {
189
189
  throw new Error(
190
- `stale GLSL program mount: run wildshard prepare <product-dir> --base <exact-preview-url> (${index.identity.slug})`,
190
+ `stale GLSL program mount: run wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`,
191
191
  )
192
192
  }
193
193
  }
@@ -211,7 +211,7 @@ function requireCookPreparation(
211
211
  | undefined,
212
212
  digest: (bytes: Readonly<Uint8Array>) => string,
213
213
  ): void {
214
- const fix = `wildshard prepare <product-dir> --base <exact-preview-url> (${index.identity.slug})`
214
+ const fix = `wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`
215
215
  if (index.sdk === '0.2' && cook?.version !== VERSION) {
216
216
  return
217
217
  }
@@ -5,7 +5,7 @@ import type { MemoryAdmission } from './memoryAdmission.ts';
5
5
  import { parseKtx2, ktx2DeviceGpu, type Ktx2DeviceCosts } from './ktx2Cost.ts';
6
6
 
7
7
  /** Apply the existing total-memory policy to declared or measured costs. */
8
- export function acceptsProductCost(memory: MemoryAdmission | undefined, source: Shardfile, stage: 'declared' | 'actual', cost: ReturnType<typeof worstContentCost>): boolean {
8
+ export function acceptsShardfileCost(memory: MemoryAdmission | undefined, source: Shardfile, stage: 'declared' | 'actual', cost: ReturnType<typeof worstContentCost>): boolean {
9
9
  if (memory === undefined) return cost.playing <= C.playing && cost.loading <= C.loading;
10
10
  return memory.accept({ stage, owner: source.identity.slug, id: `${source.identity.slug}:worst-location`,
11
11
  claimedBytes: cost.accounted, accountedBytes: cost.accounted, playingBytes: cost.playing, loadingBytes: cost.loading });
@@ -13,7 +13,7 @@ export function acceptsProductCost(memory: MemoryAdmission | undefined, source:
13
13
 
14
14
  /** Reapply the current trusted memory policy to a previously validated exact declaration. */
15
15
  export function acceptValidatedCost(source: Shardfile, cost: ReturnType<typeof worstContentCost>, memory?: MemoryAdmission): void {
16
- if (!acceptsProductCost(memory, source, 'declared', cost)) throw new Error(`declared worst-location total exceeds envelope: ${cost.playing}`);
16
+ if (!acceptsShardfileCost(memory, source, 'declared', cost)) throw new Error(`declared worst-location total exceeds envelope: ${cost.playing}`);
17
17
  }
18
18
 
19
19
  /** Device cost projection after byte admission; source ceilings retain their full RGBA fallback. A KTX2 file's declared
@@ -5,7 +5,7 @@ import { DirectorStagesSchema, type DirectorStagesData, type DirectorStagesDataI
5
5
  /** Complete existing director document shared by authored native director hosts.
6
6
  * Binary loading, declaration/hash agreement, ownership and fuel remain the
7
7
  * installing host's admission responsibilities. */
8
- export const DirectorProductSchema: v.GenericSchema<DirectorProductInput, DirectorProduct> = v.strictObject({
8
+ export const DirectorDocumentSchema: v.GenericSchema<DirectorDocumentInput, DirectorDocument> = v.strictObject({
9
9
  declaration: DirectorSchema,
10
10
  module: v.strictObject({ module: v.string(), bytes: v.string(),
11
11
  file: v.exactOptional(v.pipe(v.string(), v.minLength(1), v.maxLength(240))) }),
@@ -13,7 +13,7 @@ export const DirectorProductSchema: v.GenericSchema<DirectorProductInput, Direct
13
13
  });
14
14
 
15
15
  /** Authored transport envelope before director-stage defaults are admitted. */
16
- export interface DirectorProductInput {
16
+ export interface DirectorDocumentInput {
17
17
  declaration: DirectorData;
18
18
  module: { module: string; bytes: string; file?: string };
19
19
  stages: DirectorStagesDataInput;
@@ -22,6 +22,6 @@ export interface DirectorProductInput {
22
22
  }
23
23
 
24
24
  /** Structurally admitted document; not permission to install its native module. */
25
- export interface DirectorProduct extends Omit<DirectorProductInput, 'stages'> {
25
+ export interface DirectorDocument extends Omit<DirectorDocumentInput, 'stages'> {
26
26
  stages: DirectorStagesData;
27
27
  }
@@ -2,7 +2,7 @@ import type { ShardEntryways } from './entryways.ts';
2
2
  import type { ShardProps } from './props.ts';
3
3
  import type { ShardWater } from './water.ts';
4
4
  import { entryFootprints, clipEntryPolygon, obstructsEntry, type EntryVertex, type EntryFootprint } from './entryGeometry.ts';
5
- import { PropExtent, visitGlbTriangles } from './product.ts';
5
+ import { PropExtent, visitGlbTriangles } from './shardfile-assets.ts';
6
6
  import { glbPoint, glbTransform } from './glbTriangles.ts';
7
7
  import { WAVES } from './waterWaves.ts';
8
8
 
@@ -1,6 +1,6 @@
1
1
  /** Bounded GLB byte admission shared by build validation and runtime entry.
2
2
  * No product/schema graph is initialized to admit an equipment or skin model. */
3
- import type { AssetCost } from './product.ts';
3
+ import type { AssetCost } from './shardfile-assets.ts';
4
4
  import { glbBuffers, prepareGlbBuffers } from './glbBuffers.ts';
5
5
  import { glbImageCost } from './glbImages.ts';
6
6
  import { visitGlbGeometry, type GlbVertex } from './glbTriangles.ts';
@@ -1,7 +1,7 @@
1
1
  // Immutable wire bytes: one stable JSON encoding and the SHA-256 that names
2
2
  // it, shared by engine's host/immutable and the sdk (SHARD-COMPAT SI1). A
3
3
  // Node host module, not the portable library: tsconfig.lib.json leaves it
4
- // out, and only this module and product-stream-node.ts import `node:`.
4
+ // out, and only this module and shardfile-stream-node.ts import `node:`.
5
5
 
6
6
  // oxlint-disable-next-line import/no-nodejs-modules -- author tools hash exact immutable wire bytes
7
7
  import { createHash } from 'node:crypto'
@@ -5,7 +5,7 @@
5
5
  // part of the contract and keep their words.
6
6
  //
7
7
  // Where the code is:
8
- // - a validator refusal (`validateShardfileProduct`, `validateShardfileStream`, `readTar`): `error.code` on the thrown
8
+ // - a validator refusal (`validateShardfileFolder`, `validateShardfileStream`, `readTar`): `error.code` on the thrown
9
9
  // Error, its message unchanged. The validators tag by the check that refused; a more specific code set nearer the
10
10
  // throw wins. A code that is not the table's (Node's `ENOENT` from a host's file port,
11
11
  // `ERR_ENCODING_INVALID_ENCODED_DATA` from bad UTF-8) is replaced: such codes differ by host, and the message keeps
@@ -1,5 +1,5 @@
1
1
  import { textureMipBytes, type TextureTranscodeSupport } from './contentBounds.ts';
2
- import type { AssetCost } from './product.ts';
2
+ import type { AssetCost } from './shardfile-assets.ts';
3
3
 
4
4
  const MAX_BYTES = 25_000_000;
5
5
  function requireRange(bytes: Uint8Array, offset: number, size: number): void {