@wildshard/shard-format 0.4.10 → 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 (41) hide show
  1. package/package.json +9 -8
  2. package/src/cli/main.ts +2 -2
  3. package/src/cli/pack.ts +3 -3
  4. package/src/cli/validate.ts +33 -27
  5. package/src/format/assembly-hosts.ts +77 -0
  6. package/src/format/assetAdmission.ts +5 -5
  7. package/src/format/cook-preparation.ts +2 -2
  8. package/src/format/deviceMemoryCost.ts +2 -2
  9. package/src/format/{directorProduct.ts → directorDocument.ts} +3 -3
  10. package/src/format/entryClearance.ts +1 -1
  11. package/src/format/glbCost.ts +1 -1
  12. package/src/format/immutable.ts +1 -1
  13. package/src/format/issue-codes.ts +1 -1
  14. package/src/format/ktx2Cost.ts +1 -1
  15. package/src/format/materials.ts +1 -1
  16. package/src/format/namedJsonContracts.ts +1 -1
  17. package/src/format/nearPlaceholderAssets.ts +1 -1
  18. package/src/format/outputDownload.ts +1 -1
  19. package/src/format/outputIndex.ts +1 -1
  20. package/src/format/platformFileFamilies.ts +3 -2
  21. package/src/format/receipt-cost.ts +3 -3
  22. package/src/format/registeredJson.ts +4 -4
  23. package/src/format/script-side-grandfather.ts +5 -5
  24. package/src/format/script-sides.ts +3 -3
  25. package/src/format/shardSchema.ts +1 -1
  26. package/src/format/{product-audio.ts → shardfile-audio.ts} +7 -7
  27. package/src/format/{product-stream-admit.ts → shardfile-stream-admit.ts} +11 -8
  28. package/src/format/{product-stream-assets.ts → shardfile-stream-assets.ts} +7 -7
  29. package/src/format/{product-stream-facts.ts → shardfile-stream-facts.ts} +3 -3
  30. package/src/format/{product-stream-node.ts → shardfile-stream-node.ts} +2 -2
  31. package/src/format/{product-stream-packs.ts → shardfile-stream-packs.ts} +1 -1
  32. package/src/format/{product-stream-rows.ts → shardfile-stream-rows.ts} +6 -6
  33. package/src/format/{product-stream.ts → shardfile-stream.ts} +25 -25
  34. package/src/format/{productValidation.ts → shardfileValidation.ts} +14 -14
  35. package/src/format/sourceResidency.ts +4 -4
  36. package/src/format/tar.ts +1 -1
  37. package/src/format/validationReceipt.ts +2 -2
  38. /package/src/format/{product.ts → shardfile-assets.ts} +0 -0
  39. /package/src/format/{product-reads.ts → shardfile-reads.ts} +0 -0
  40. /package/src/format/{product-stream-miss.ts → shardfile-stream-miss.ts} +0 -0
  41. /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.10",
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",
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 {
@@ -52,7 +52,7 @@ export function graphFileJson(hash: string, file: (hash: string) => Uint8Array |
52
52
  * preset reference or a missing or invalid file.
53
53
  */
54
54
  export function materialGraphIr(entry: MaterialEntry, file: (hash: string) => Uint8Array | undefined): GraphIr {
55
- if (entry.family !== 'graph' || !('file' in entry)) throw new Error('material graph IR needs a graph file (a built product carries no inline graph)');
55
+ if (entry.family !== 'graph' || !('file' in entry)) throw new Error('material graph IR needs a graph file (a built shard file carries no inline graph)');
56
56
  const checked = validateGraph(graphFileJson(entry.file, file), { trustedBudget: true });
57
57
  if (!checked.ok) throw new Error(`material graph file ${entry.file}: ${checked.errors.join('; ')}`);
58
58
  return checked.graph;
@@ -82,7 +82,7 @@ export const HEADLESS_ASSEMBLY_JSON_SCHEMA: { $schema: string; type: string; add
82
82
  ] } } } },
83
83
  },
84
84
  properties: { version: { const: 1 }, modules: { type: 'object', propertyNames: {
85
- type: 'string', pattern: '^(?:@wildshard/[a-z]+/|src/(?:shards|game|engine|sdk)/)[A-Za-z0-9_./-]+$',
85
+ type: 'string', pattern: '^src/(?:shards|game|engine|sdk)/[A-Za-z0-9_./-]+$',
86
86
  }, additionalProperties: { type: 'array', maxItems: 256, uniqueItems: true, items: { $ref: '#/definitions/key' } } },
87
87
  constants: { $ref: '#/definitions/value' }, prepare: { $ref: '#/definitions/rows' }, install: { $ref: '#/definitions/installRows' },
88
88
  level: { $ref: '#/definitions/value' }, ports: { $ref: '#/definitions/value' }, entries: { $ref: '#/definitions/value' } },
@@ -1,7 +1,7 @@
1
1
  import type { NearPlaceholder } from './nearPlaceholder.ts';
2
2
  import { decodeTerrainTile } from './terrainTileBytes.ts';
3
3
  import { CELL_ABOVE, CELL_BELOW, CHUNK_HALF } from './contentBounds.ts';
4
- import { visitGlbTriangles } from './product.ts';
4
+ import { visitGlbTriangles } from './shardfile-assets.ts';
5
5
 
6
6
  /** Validate actual visual payloads: exact L1 tiles and cell-local GLBs, with no collider-only terrain. */
7
7
  export function validateNearPlaceholderAssets(near: NearPlaceholder, assets: ReadonlyMap<string, Uint8Array>): void {
@@ -29,6 +29,6 @@ export function readOutputDownloadIndex(input: unknown): OutputDownloadIndex {
29
29
  packs: v.exactOptional(v.pipe(v.array(v.object({ ...measured, entries: v.pipe(v.array(v.object({ hash, offset: bytes, bytes })), v.maxLength(8192)) })), v.maxLength(64))),
30
30
  }), input);
31
31
  const paths = ['shard.json', 'validation.json', ...index.sections.map(row => row.path), ...index.schemas.map(row => row.path), ...index.files.map(row => row.path)];
32
- if (new Set(paths).size !== paths.length) throw new Error('Duplicate product download path');
32
+ if (new Set(paths).size !== paths.length) throw new Error('Duplicate shard file download path');
33
33
  return index;
34
34
  }
@@ -62,7 +62,7 @@ export function parseOutputDescriptorIndex(input: unknown): OutputIndex | null {
62
62
  }
63
63
  function parseOutputIndexRows(input: unknown): OutputIndex {
64
64
  const index = v.parse(OutputIndexSchema, input);
65
- if (index.sdk === '0.3' && index.cook === undefined) { throw new Error(`Missing cook preparation: run wildshard prepare <product-dir> --base <exact-preview-url> (${index.identity.slug})`); }
65
+ if (index.sdk === '0.3' && index.cook === undefined) { throw new Error(`Missing cook preparation: run wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`); }
66
66
  if (index.sdk === '0.3' && index.cook !== undefined && index.cook.bytes > MAX_COOK_BYTES) { throw new Error('Cook preparation exceeds byte cap'); }
67
67
  const paths = new Set(['shard.json', 'validation.json']), names = new Set<string>();
68
68
  if (index.ktx2Costs !== undefined) {
@@ -57,7 +57,7 @@ import { PageLifeSchema } from './pageLife.ts';
57
57
  import { ChapterDirectorSchema, ChapterWakeSchema } from './chapterDirector.ts';
58
58
  import { QuestPageInteractionsSchema } from './questInteractions.ts';
59
59
  import { QuestServiceActionsSchema, QuestHintRowsSchema, CarriedQuestSchema } from './questSteps.ts';
60
- import { DirectorProductSchema } from './directorProduct.ts';
60
+ import { DirectorDocumentSchema } from './directorDocument.ts';
61
61
  import { NativeAssemblySchema, NativeAssemblyDataSchema, NATIVE_ASSEMBLY_SCHEMA, NATIVE_ASSEMBLY_DATA_SCHEMA } from './nativeAssembly.ts';
62
62
  import { QuestPanelCatalogueSchema } from './panelTemplate.ts';
63
63
  import { ForestWeatherSchema } from './forestWeather.ts';
@@ -224,7 +224,8 @@ export const PLATFORM_FILE_FAMILIES: readonly PlatformFileFamily[] = [
224
224
  source: '@wildshard/format/questInteractions#QuestPageInteractionsSchema', reader: 'src/game/quest/pageComposition.ts' },
225
225
  { pattern: /^quests\/services\.json$/u, schema: QuestServiceActionsSchema,
226
226
  source: '@wildshard/format/questSteps#QuestServiceActionsSchema', reader: 'src/game/quest/effects.ts' },
227
- { pattern: /^directors\/main\.json$/u, schema: DirectorProductSchema,
227
+ // SA23: the source string is shard file data (each file's `jsonSchema.$comment`), so it keeps the old module name.
228
+ { pattern: /^directors\/main\.json$/u, schema: DirectorDocumentSchema,
228
229
  source: '@wildshard/format/directorProduct#DirectorProductSchema', reader: 'src/game/plugin/director.ts' },
229
230
  { pattern: /^quests\/panels\.json$/u, schema: QuestPanelCatalogueSchema,
230
231
  source: '@wildshard/format/panelTemplate#QuestPanelCatalogueSchema', reader: 'src/game/ui/dataPanels.ts' },
@@ -2,9 +2,9 @@
2
2
  import { preflightDeclaredCosts } from './assetAdmission.ts'
3
3
  import { structuralGridEvidence } from './gridReadiness.ts'
4
4
  import { postStackCost } from './postStack.ts'
5
- import { offlineMemoryAdmission } from './product.ts'
5
+ import { offlineMemoryAdmission } from './shardfile-assets.ts'
6
6
  import {
7
- productWireBytes,
7
+ shardfileWireBytes,
8
8
  publishedSourceResidency,
9
9
  } from './sourceResidency.ts'
10
10
 
@@ -59,7 +59,7 @@ function receiptResidencyShortfall(
59
59
  shard: Shardfile,
60
60
  ): string | undefined {
61
61
  const stamped = stampedResidency(receipt)
62
- const wire = productWireBytes(shard)
62
+ const wire = shardfileWireBytes(shard)
63
63
  if (stamped === undefined || stamped >= wire) {
64
64
  return undefined
65
65
  }
@@ -46,7 +46,7 @@ import { CaveFileSchema, CaveInteriorSchema } from './caveInterior.ts';
46
46
  import * as v from 'valibot';
47
47
  import { NativePopulationRowsSchema, parseNativePopulationRows, TamingPoseFileSchema } from './populationRoster.ts';
48
48
  import { EliteFeatureSchema, parseEliteFeature } from './eliteFeature.ts';
49
- import { DirectorProductSchema } from './directorProduct.ts';
49
+ import { DirectorDocumentSchema } from './directorDocument.ts';
50
50
  import { AudioSceneSchema } from './audioScene.ts';
51
51
  import { KitFigureCardsSchema } from './questFigures.ts';
52
52
  import {SceneBuffersSchema,parseSceneBuffers} from './sceneBuffers.ts';
@@ -128,7 +128,7 @@ export interface RegisteredJsonContracts {
128
128
  readonly 'world/dressing-phone.json':{readonly schema:typeof SceneDressingSchema;readonly source:'@wildshard/format/sceneDressing#SceneDressingSchema'};
129
129
  readonly 'world/building-sites.json':{readonly schema:typeof LivingPageSitesSchema;readonly source:'@wildshard/format/forestPage#LivingPageSitesSchema'};
130
130
  readonly 'models/shape-book.json':{readonly schema:typeof FixedDrawRowsSchema;readonly source:'@wildshard/format/fixedDraws#FixedDrawRowsSchema'};
131
- readonly 'directors/main.json':{readonly schema:typeof DirectorProductSchema;readonly source:'@wildshard/format/directorProduct#DirectorProductSchema'};
131
+ readonly 'directors/main.json':{readonly schema:typeof DirectorDocumentSchema;readonly source:'@wildshard/format/directorProduct#DirectorProductSchema'};
132
132
  readonly 'scenes/cascade.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
133
133
  readonly 'scenes/cove.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
134
134
  readonly 'scenes/hibiscus.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
@@ -250,7 +250,7 @@ export const REGISTERED_JSON:RegisteredJsonContracts = {
250
250
  'world/dressing-phone.json':{schema:SceneDressingSchema,source:'@wildshard/format/sceneDressing#SceneDressingSchema'},
251
251
  'world/building-sites.json':{schema:LivingPageSitesSchema,source:'@wildshard/format/forestPage#LivingPageSitesSchema'},
252
252
  'models/shape-book.json':{schema:FixedDrawRowsSchema,source:'@wildshard/format/fixedDraws#FixedDrawRowsSchema'},
253
- 'directors/main.json':{schema:DirectorProductSchema,source:'@wildshard/format/directorProduct#DirectorProductSchema'},
253
+ 'directors/main.json':{schema:DirectorDocumentSchema,source:'@wildshard/format/directorProduct#DirectorProductSchema'},
254
254
  'scenes/cascade.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
255
255
  'scenes/cove.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
256
256
  'scenes/hibiscus.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
@@ -476,7 +476,7 @@ export function validateRegisteredJson(name:string,value:unknown):void {
476
476
  case 'world/weather-observations.json':v.parse(ForestWeatherObservationSchema,value);break;
477
477
  case 'look/post.json':parsePostGraphDocument(value);break;
478
478
  case 'people/cards.json':v.parse(KitFigureCardsSchema,value);break;
479
- case 'directors/main.json':v.parse(DirectorProductSchema,value);break;
479
+ case 'directors/main.json':v.parse(DirectorDocumentSchema,value);break;
480
480
  case 'actors/roster.json':parseNativePopulationRows(value);break;
481
481
  case 'actors/elites.json':parseEliteFeature(value);break;
482
482
  case 'sim/keeper.json':v.parse(PopulationKeeperRowsSchema,value);break;
@@ -3,13 +3,13 @@
3
3
 
4
4
  /** The product a validator is admitting: its slug and declared source hash. Both validators check that hash against
5
5
  * the admitted sections before they return, so a forged index cannot borrow a grandfathered product's. */
6
- interface ScriptSideProduct {
6
+ interface ScriptSideShardfile {
7
7
  readonly slug: string
8
8
  readonly sourceHash: string
9
9
  }
10
10
 
11
11
  /** One live product admitted with a warning in place of a script side refusal. */
12
- interface GrandfatheredScript extends ScriptSideProduct {
12
+ interface GrandfatheredScript extends ScriptSideShardfile {
13
13
  /** The script id the refusal names. */
14
14
  readonly script: string
15
15
  /** Why it still passes, and the row that removes it. */
@@ -29,7 +29,7 @@ const SCRIPT_SIDE_GRANDFATHER: readonly GrandfatheredScript[] = []
29
29
  /** The grandfather entry that covers one refusal line of this product, or `undefined`. */
30
30
  function grandfatherFor(
31
31
  line: string,
32
- product: ScriptSideProduct,
32
+ product: ScriptSideShardfile,
33
33
  ): GrandfatheredScript | undefined {
34
34
  return SCRIPT_SIDE_GRANDFATHER.find(
35
35
  (entry: GrandfatheredScript): boolean =>
@@ -42,7 +42,7 @@ function grandfatherFor(
42
42
  /** A product's side refusal lines, split: lines a grandfather entry covers become warnings, the rest stay refusals. */
43
43
  function splitGrandfathered(
44
44
  lines: readonly string[],
45
- product: ScriptSideProduct,
45
+ product: ScriptSideShardfile,
46
46
  ): { refused: string[]; warnings: string[] } {
47
47
  const refused: string[] = []
48
48
  const warnings: string[] = []
@@ -58,4 +58,4 @@ function splitGrandfathered(
58
58
  }
59
59
 
60
60
  export { SCRIPT_SIDE_GRANDFATHER, splitGrandfathered }
61
- export type { GrandfatheredScript, ScriptSideProduct }
61
+ export type { GrandfatheredScript, ScriptSideShardfile }
@@ -16,7 +16,7 @@ import {
16
16
 
17
17
  import type { FeatureSide } from './feature-sides.ts'
18
18
  import type { OutputIndex } from './outputIndex.ts'
19
- import type { ScriptSideProduct } from './script-side-grandfather.ts'
19
+ import type { ScriptSideShardfile } from './script-side-grandfather.ts'
20
20
  import type { NamedFiles } from './script-view-returns.ts'
21
21
  import type { ScriptV1CommandName } from './scriptAbiV1.ts'
22
22
  import type { V2Lane } from './scriptFuelV2.ts'
@@ -69,7 +69,7 @@ const PAGE_ONLY_PROGRAM_HOSTS: ReadonlyMap<string, readonly string[]> = new Map(
69
69
  type NamedJson = (name: string) => unknown
70
70
 
71
71
  /** The product files a validator reads before its inventory pass, and its hash check (`whole` as in
72
- * `ProductValidationPorts.verify`). */
72
+ * `ShardfileValidationPorts.verify`). */
73
73
  interface UncheckedFiles {
74
74
  readonly read: (path: string, bytes: number) => Uint8Array | undefined
75
75
  readonly paths: () => Iterable<string>
@@ -227,7 +227,7 @@ function namedJsonFiles(index: OutputIndex, files: UncheckedFiles): NamedFiles {
227
227
  function scriptSideVerdict(
228
228
  sections: ReadonlyMap<string, unknown>,
229
229
  files: NamedFiles,
230
- product: ScriptSideProduct,
230
+ product: ScriptSideShardfile,
231
231
  ): { refused: string[]; warnings: string[] } {
232
232
  return splitGrandfathered(
233
233
  scriptSideRefusals(sections, files.read, files.names),
@@ -9,7 +9,7 @@ import { CELL_ABOVE, CELL_BELOW, CHUNK_HALF, CONTENT_CAPS } from './contentBound
9
9
  import { jsonDataNodes } from './json.ts';
10
10
  import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
11
11
  import { preflightShardfile } from './preflight.ts';
12
- import { preflightAssetGraph } from './product.ts';
12
+ import { preflightAssetGraph } from './shardfile-assets.ts';
13
13
  import { SHARDFILE_VERSION } from './version.ts';
14
14
  import { UiSchema, uiRules } from './ui.ts';
15
15
  import { scriptBindingRules } from './scripts.ts';
@@ -20,8 +20,8 @@ import type { Shardfile } from './shardSchema.ts'
20
20
  // section's non-commons `recordings` blobs. Commons recordings are shared, so
21
21
  // they are not the shard's own.
22
22
 
23
- /** What `productRecordings` reads from a validated product. */
24
- interface ProductAudioInput {
23
+ /** What `shardfileRecordings` reads from a validated product. */
24
+ interface ShardfileAudioInput {
25
25
  readonly cook: CookData | undefined
26
26
  readonly read: (path: string, maxBytes: number) => Uint8Array
27
27
  readonly shard: Readonly<{
@@ -33,9 +33,9 @@ interface ProductAudioInput {
33
33
  const COMMONS = 'commons:'
34
34
 
35
35
  /** Every own recording in a validated product, measured from its bytes. */
36
- function productRecordings(
36
+ function shardfileRecordings(
37
37
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's row types and a read port, only read
38
- input: Readonly<ProductAudioInput>,
38
+ input: Readonly<ShardfileAudioInput>,
39
39
  ): RecordingMeasure[] {
40
40
  const mounts = (input.cook?.mounts ?? [])
41
41
  .filter((mount: Readonly<CookMount>): boolean =>
@@ -58,7 +58,7 @@ function productRecordings(
58
58
 
59
59
  /** The product's audio against AU5's rules, its waiver read from `admission.audioWaiver`. A red report refuses only at
60
60
  * upload (`assertAudioAdmission`); pack prints it. `today` decides whether the waiver is still in date. */
61
- function productAudioReport(
61
+ function shardfileAudioReport(
62
62
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's row types, only read
63
63
  product: Readonly<{ index: OutputIndex; audio: readonly RecordingMeasure[] }>,
64
64
  today: Readonly<Date>,
@@ -71,5 +71,5 @@ function productAudioReport(
71
71
  })
72
72
  }
73
73
 
74
- export type { ProductAudioInput }
75
- export { productAudioReport, productRecordings }
74
+ export type { ShardfileAudioInput }
75
+ export { shardfileAudioReport, shardfileRecordings }
@@ -1,4 +1,4 @@
1
- // `admitShardfileProduct`'s steps around `validateShardfileAssets` for the
1
+ // `admitShardfileFolder`'s steps around `validateShardfileAssets` for the
2
2
  // streaming validator (API-CLOUDFLARE AC6a): the schema, declared costs and
3
3
  // targets before it; the world targets and the source hash after it.
4
4
 
@@ -10,18 +10,21 @@ import {
10
10
  } from './assetAdmission.ts'
11
11
  import { issueError, withIssueCode } from './issue-codes.ts'
12
12
  import { assembleOutputShardfile } from './outputIndex.ts'
13
- import { offlineMemoryAdmission } from './product.ts'
14
- import { assertProductTargets, checkWorldTargets } from './productValidation.ts'
13
+ import { offlineMemoryAdmission } from './shardfile-assets.ts'
14
+ import {
15
+ assertShardfileTargets,
16
+ checkWorldTargets,
17
+ } from './shardfileValidation.ts'
15
18
  import { parseShardfile } from './shardSchema.ts'
16
19
  import { validationSourceBytes } from './validationReceipt.ts'
17
20
 
18
21
  import type { AssetAdmission } from './assetAdmission.ts'
19
22
  import type { OutputIndex } from './outputIndex.ts'
20
- import type { AssetPasses } from './product-stream-assets.ts'
21
23
  import type { ScriptAdmissionRows } from './scriptContract.ts'
24
+ import type { AssetPasses } from './shardfile-stream-assets.ts'
22
25
  import type { Shardfile } from './shardSchema.ts'
23
26
 
24
- /** `admitShardfileProduct`'s steps before `validateShardfileAssets`: the schema, declared costs and targets. */
27
+ /** `admitShardfileFolder`'s steps before `validateShardfileAssets`: the schema, declared costs and targets. */
25
28
  function admitHead(
26
29
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
27
30
  index: OutputIndex,
@@ -34,13 +37,13 @@ function admitHead(
34
37
  preflightDeclaredCosts(shard, offlineMemoryAdmission('warn'))
35
38
  })
36
39
  withIssueCode('performance-targets', (): void => {
37
- assertProductTargets(shard, 'warn')
40
+ assertShardfileTargets(shard, 'warn')
38
41
  })
39
42
  return shard
40
43
  }
41
44
 
42
45
  /** The shard's head and its asset admission's first steps, or the refusal they gave: thrown only after the packs, the
43
- * cook and the inventory, as `validateShardfileProduct` orders them. */
46
+ * cook and the inventory, as `validateShardfileFolder` orders them. */
44
47
  function admitBeforeAssets(
45
48
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
46
49
  index: OutputIndex,
@@ -88,7 +91,7 @@ function admitAssets(
88
91
  })
89
92
  }
90
93
 
91
- /** `validateShardfileProduct`'s steps after the assets: the world targets and the source hash. */
94
+ /** `validateShardfileFolder`'s steps after the assets: the world targets and the source hash. */
92
95
  function admitTail(
93
96
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
94
97
  shard: Shardfile,
@@ -10,19 +10,19 @@
10
10
  // Wasm stay from the first read. A later check that asks for any other file
11
11
  // is refused, never answered from a guess (StreamMissError): the corpus and pin
12
12
  // tests prove no check does. Packs the reads' groups need come with them
13
- // (product-stream-packs.ts).
13
+ // (shardfile-stream-packs.ts).
14
14
 
15
15
  import { admitFileBytes } from './assetAdmission.ts'
16
16
  import { issueError, withIssueCodeAsync } from './issue-codes.ts'
17
- import { StreamMissError } from './product-stream-miss.ts'
18
- import { packGroups, packPass } from './product-stream-packs.ts'
19
- import { walkTar } from './product-stream-tar.ts'
17
+ import { StreamMissError } from './shardfile-stream-miss.ts'
18
+ import { packGroups, packPass } from './shardfile-stream-packs.ts'
19
+ import { walkTar } from './shardfile-stream-tar.ts'
20
20
 
21
21
  import type { AssetAdmission } from './assetAdmission.ts'
22
22
  import type { OutputIndex } from './outputIndex.ts'
23
- import type { PackPass, PackVerdicts } from './product-stream-packs.ts'
24
- import type { KeptMember } from './product-stream-rows.ts'
25
- import type { StreamHasher, StreamMember } from './product-stream-tar.ts'
23
+ import type { PackPass, PackVerdicts } from './shardfile-stream-packs.ts'
24
+ import type { KeptMember } from './shardfile-stream-rows.ts'
25
+ import type { StreamHasher, StreamMember } from './shardfile-stream-tar.ts'
26
26
 
27
27
  /** A stored object to read again: each call opens a fresh stream from its start. */
28
28
  type StoredSource = () =>
@@ -8,17 +8,17 @@
8
8
  import { parseNamedJson } from './json.ts'
9
9
  import { ktx2DeviceCosts } from './ktx2Cost.ts'
10
10
  import { validatePlatformFile } from './platformFileFamilies.ts'
11
- import { assetCost } from './product.ts'
12
- import { outputBlobExtension, outputBlobKind } from './productValidation.ts'
13
11
  import {
14
12
  registeredJsonContract,
15
13
  validateRegisteredJson,
16
14
  } from './registeredJson.ts'
15
+ import { assetCost } from './shardfile-assets.ts'
16
+ import { outputBlobExtension, outputBlobKind } from './shardfileValidation.ts'
17
17
  import { validationSourceBytes } from './validationReceipt.ts'
18
18
 
19
19
  import type { OutputFile } from './outputIndex.ts'
20
- import type { AssetCost } from './product.ts'
21
20
  import type { ScriptContract } from './scriptContract.ts'
21
+ import type { AssetCost } from './shardfile-assets.ts'
22
22
 
23
23
  /** A computed value, or the message of the refusal computing it threw: thrown later, in the old validator's order. */
24
24
  type Outcome<Value> =
@@ -9,8 +9,8 @@ import { Readable, pipeline } from 'node:stream'
9
9
  // oxlint-disable-next-line import/no-nodejs-modules -- a Node and Workers host adapter
10
10
  import { createBrotliDecompress } from 'node:zlib'
11
11
 
12
- import type { StreamHasher } from './product-stream-tar.ts'
13
- import type { StreamValidationPorts } from './product-stream.ts'
12
+ import type { StreamHasher } from './shardfile-stream-tar.ts'
13
+ import type { StreamValidationPorts } from './shardfile-stream.ts'
14
14
 
15
15
  function sha256(bytes: Readonly<Uint8Array>): string {
16
16
  return createHash('sha256').update(bytes).digest('hex')
@@ -11,7 +11,7 @@
11
11
  import { issueError } from './issue-codes.ts'
12
12
 
13
13
  import type { OutputIndex } from './outputIndex.ts'
14
- import type { StreamHasher } from './product-stream-tar.ts'
14
+ import type { StreamHasher } from './shardfile-stream-tar.ts'
15
15
 
16
16
  type Pack = NonNullable<OutputIndex['packs']>[number]
17
17
 
@@ -1,5 +1,5 @@
1
1
  // oxlint-disable import/max-dependencies -- the old validator's steps, each from its defining module
2
- // `validateShardfileProduct`'s inventory steps, replayed over what one
2
+ // `validateShardfileFolder`'s inventory steps, replayed over what one
3
3
  // streaming pass kept (API-CLOUDFLARE AC6a): each listed file's hash and
4
4
  // size, the blobs' facts, server files, KTX2 device costs, the cook and its
5
5
  // mounts, and no unlisted file. The order and the messages are the old ones.
@@ -10,16 +10,16 @@ import { cookMountPath, readCookData } from './cook-data.ts'
10
10
  import { requireCookPreparation } from './cook-preparation.ts'
11
11
  import { issueError, withIssueCode } from './issue-codes.ts'
12
12
  import { validatePlatformFile } from './platformFileFamilies.ts'
13
- import { mountSharesBlob } from './product-reads.ts'
14
- import { inspectFacts, ktx2Text } from './product-stream-facts.ts'
15
- import { outputBlobKind, readCanonicalJson } from './productValidation.ts'
16
13
  import { decisionModuleContracts } from './scriptContract.ts'
14
+ import { mountSharesBlob } from './shardfile-reads.ts'
15
+ import { inspectFacts, ktx2Text } from './shardfile-stream-facts.ts'
16
+ import { outputBlobKind, readCanonicalJson } from './shardfileValidation.ts'
17
17
  import { validationSourceBytes } from './validationReceipt.ts'
18
18
 
19
19
  import type { OutputIndex } from './outputIndex.ts'
20
- import type { FactsMember } from './product-stream-facts.ts'
21
- import type { StreamMember } from './product-stream-tar.ts'
22
20
  import type { ScriptAdmissionRows } from './scriptContract.ts'
21
+ import type { FactsMember } from './shardfile-stream-facts.ts'
22
+ import type { StreamMember } from './shardfile-stream-tar.ts'
23
23
 
24
24
  /** One tar member after the walk. */
25
25
  type KeptMember = FactsMember & StreamMember
@@ -1,51 +1,51 @@
1
1
  // oxlint-disable eslint/max-statements, import/max-dependencies -- the old validator's steps in its order
2
- // API-CLOUDFLARE AC6a: `validateShardfileProduct` over a stream, for a host
2
+ // API-CLOUDFLARE AC6a: `validateShardfileFolder` over a stream, for a host
3
3
  // with no disk and no synchronous reads (the API Worker: 128 MB, `node:zlib`,
4
4
  // no WebAssembly compiled from bytes). The first read of the stored object
5
5
  // takes its SHA-256, its decoding (Brotli, a host port), a strict ustar walk
6
6
  // and every member's SHA-256 and size. Blobs are checked as they stream and
7
- // only their facts kept (product-stream-facts.ts); JSON, Wasm and every file
7
+ // only their facts kept (shardfile-stream-facts.ts); JSON, Wasm and every file
8
8
  // outside `blobs/`, `mounts/` and `packs/` are kept whole. Then the old
9
9
  // validator's steps run in its order, so a refusal is the one it gives (its
10
10
  // message may differ only for a blob whose declared kind contradicts its path).
11
11
  //
12
12
  // AC6a2: `validateShardfileAssets`' byte checks and the pack checks read
13
13
  // assets by hash in any order (153 MB of blobs on the 327 MB pin), so they
14
- // take a second read of the stored object (product-stream-assets.ts), and a
15
- // further read per group of left-out packs (product-stream-packs.ts). Hence
14
+ // take a second read of the stored object (shardfile-stream-assets.ts), and a
15
+ // further read per group of left-out packs (shardfile-stream-packs.ts). Hence
16
16
  // `open`: a host passes a function that opens the stored object afresh.
17
17
 
18
18
  import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts'
19
19
  import { assertSectionSides } from './feature-sides.ts'
20
20
  import { issueError, withIssueCode } from './issue-codes.ts'
21
21
  import { parseOutputIndex, validateOutputSection } from './outputIndex.ts'
22
+ import { assertScriptSides } from './script-sides.ts'
23
+ import { scriptAdmissionRows } from './scriptContract.ts'
24
+ import { prepareAssetDecoders } from './shardfile-assets.ts'
22
25
  import {
23
26
  admitAssets,
24
27
  admitBeforeAssets,
25
28
  admitTail,
26
- } from './product-stream-admit.ts'
27
- import { assetPasses } from './product-stream-assets.ts'
28
- import { blobFacts } from './product-stream-facts.ts'
29
+ } from './shardfile-stream-admit.ts'
30
+ import { assetPasses } from './shardfile-stream-assets.ts'
31
+ import { blobFacts } from './shardfile-stream-facts.ts'
29
32
  import {
30
33
  listedBytes,
31
34
  replayBeforePacks,
32
35
  replayPacksToInventory,
33
- } from './product-stream-rows.ts'
34
- import { walkTar } from './product-stream-tar.ts'
35
- import { prepareAssetDecoders } from './product.ts'
36
- import { readCanonicalJson } from './productValidation.ts'
37
- import { assertScriptSides } from './script-sides.ts'
38
- import { scriptAdmissionRows } from './scriptContract.ts'
36
+ } from './shardfile-stream-rows.ts'
37
+ import { walkTar } from './shardfile-stream-tar.ts'
38
+ import { readCanonicalJson } from './shardfileValidation.ts'
39
39
 
40
40
  import type { OutputIndex } from './outputIndex.ts'
41
- import type { StoredSource } from './product-stream-assets.ts'
42
- import type { KeptMember, Replay } from './product-stream-rows.ts'
41
+ import type { ScriptAdmissionRows } from './scriptContract.ts'
42
+ import type { StoredSource } from './shardfile-stream-assets.ts'
43
+ import type { KeptMember, Replay } from './shardfile-stream-rows.ts'
43
44
  import type {
44
45
  StreamHasher,
45
46
  StreamMember,
46
47
  WalkPorts,
47
- } from './product-stream-tar.ts'
48
- import type { ScriptAdmissionRows } from './scriptContract.ts'
48
+ } from './shardfile-stream-tar.ts'
49
49
  import type { Shardfile } from './shardSchema.ts'
50
50
 
51
51
  /** The host services a streaming validation needs. */
@@ -61,7 +61,7 @@ interface StreamValidationPorts {
61
61
  }
62
62
 
63
63
  /** What one streaming validation found. */
64
- interface StreamedProduct {
64
+ interface StreamedShardfile {
65
65
  /** SHA-256 and byte length of the stored object, before decoding. */
66
66
  readonly hash: string
67
67
  readonly bytes: number
@@ -73,7 +73,7 @@ interface StreamedProduct {
73
73
  readonly scripts: ScriptAdmissionRows
74
74
  /** Admitted with a warning: grandfathered script side lines (`SCRIPT_SIDE_GRANDFATHER`, SERVER-PARITY SS11). */
75
75
  readonly warnings: readonly string[]
76
- /** True only when every check `validateShardfileProduct` runs has run: always, since AC6a2. */
76
+ /** True only when every check `validateShardfileFolder` runs has run: always, since AC6a2. */
77
77
  readonly complete: boolean
78
78
  /** The checks still to run, by name, while `complete` is false: none, since AC6a2. */
79
79
  readonly pending: readonly string[]
@@ -196,7 +196,7 @@ async function walkStored(
196
196
  }
197
197
  }
198
198
 
199
- /** `shard.json`, read as `validateShardfileProduct` reads it: bounded, canonical, then parsed. */
199
+ /** `shard.json`, read as `validateShardfileFolder` reads it: bounded, canonical, then parsed. */
200
200
  function readIndex(replay: Readonly<Replay>): OutputIndex {
201
201
  const shardJson = replay.members.get('shard.json')
202
202
  if (shardJson === undefined) {
@@ -218,7 +218,7 @@ function readSections(
218
218
  replay: Readonly<Replay>,
219
219
  // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
220
220
  index: OutputIndex,
221
- ): Pick<StreamedProduct, 'sections' | 'warnings' | 'scripts'> {
221
+ ): Pick<StreamedShardfile, 'sections' | 'warnings' | 'scripts'> {
222
222
  const payloads = new Map<string, unknown>()
223
223
  for (const entry of index.sections) {
224
224
  withIssueCode('section-invalid', (): void => {
@@ -245,11 +245,11 @@ function readSections(
245
245
  }
246
246
 
247
247
  /** Stream-validate a stored shardfile object (see the file comment): `open` gives a fresh stream of it on each call.
248
- * Rejects with the refusal `validateShardfileProduct` would give first. */
248
+ * Rejects with the refusal `validateShardfileFolder` would give first. */
249
249
  async function validateShardfileStream(
250
250
  open: StoredSource,
251
251
  ports: StreamValidationPorts,
252
- ): Promise<StreamedProduct> {
252
+ ): Promise<StreamedShardfile> {
253
253
  // GLB costs need the meshopt decoder before any blob streams (Codex review: a cold start refused valid GLBs).
254
254
  await prepareAssetDecoders()
255
255
  const walked = await walkStored(await open(), ports)
@@ -292,6 +292,6 @@ async function validateShardfileStream(
292
292
  }
293
293
  }
294
294
 
295
- export type { StoredSource } from './product-stream-assets.ts'
296
- export type { StreamValidationPorts, StreamedProduct }
295
+ export type { StoredSource } from './shardfile-stream-assets.ts'
296
+ export type { StreamValidationPorts, StreamedShardfile }
297
297
  export { STREAM_BLOB_CAP, STREAM_KEPT_CAP, validateShardfileStream }
@@ -10,14 +10,14 @@ import { isTerrainTileData } from './terrainTileBytes.ts';
10
10
  import { parseImageAsset } from './stillImage.ts';
11
11
  import { parseWorldTargets, worldTargetRules } from './worldTargets.ts';
12
12
  import { parseShardfile, type Shardfile } from './shardSchema.ts';
13
- import { assetCost, offlineMemoryAdmission, performanceTargetIssues } from './product.ts';
13
+ import { assetCost, offlineMemoryAdmission, performanceTargetIssues } from './shardfile-assets.ts';
14
14
  import { preflightDeclaredCosts, validateShardfileAssets } from './assetAdmission.ts';
15
15
  import { validationSourceBytes } from './validationReceipt.ts';
16
16
  import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
17
- import { assetStore, checkPacks, mountSharesBlob } from './product-reads.ts';
17
+ import { assetStore, checkPacks, mountSharesBlob } from './shardfile-reads.ts';
18
18
  import { assertSectionSides } from './feature-sides.ts';
19
19
  import { assertScriptSides } from './script-sides.ts';
20
- import { productRecordings } from './product-audio.ts';
20
+ import { shardfileRecordings } from './shardfile-audio.ts';
21
21
  import type { RecordingMeasure } from './audio-measure.ts';
22
22
  import { issueError, withIssueCode as coded } from './issue-codes.ts';
23
23
 
@@ -27,11 +27,11 @@ import { issueError, withIssueCode as coded } from './issue-codes.ts';
27
27
  * only this package. It never executes script bytes: re-running admitted WASM (G491) is the execution proof, which
28
28
  * stays with the author CLI and the cook worker.
29
29
  *
30
- * Call `prepareAssetDecoders()` (`@wildshard/shard-format/product`) once before validating; GLB costs need the decoder.
30
+ * Call `prepareAssetDecoders()` (`@wildshard/shard-format/shardfileAssets`) once before validating; GLB costs need the decoder.
31
31
  */
32
32
 
33
33
  /** Read access to one product folder. Paths are `/`-separated and relative to the product root. */
34
- export interface ProductFiles {
34
+ export interface ShardfileFiles {
35
35
  /** The bytes of one regular file, refusing symlinks and anything larger than `maxBytes`. */
36
36
  readonly read: (path: string, maxBytes: number) => Uint8Array;
37
37
  /** Every non-directory entry under the root (symlinks and special files included, so they are refused as unlisted). */
@@ -39,7 +39,7 @@ export interface ProductFiles {
39
39
  }
40
40
 
41
41
  /** The host services format validation needs but does not own. */
42
- export interface ProductValidationPorts {
42
+ export interface ShardfileValidationPorts {
43
43
  /** Lowercase hex SHA-256 of exact bytes. */
44
44
  readonly hash: (bytes: Uint8Array) => string;
45
45
  /** Whether bytes have the expected hash; `whole` marks a complete inventory file a caller may remember. Default: `hash`. */
@@ -55,7 +55,7 @@ export interface ProductValidationPorts {
55
55
  }
56
56
 
57
57
  /** A product that passed format validation. */
58
- export interface ValidatedProduct {
58
+ export interface ValidatedShardfile {
59
59
  readonly index: OutputIndex;
60
60
  readonly shard: Shardfile;
61
61
  /** Admitted bytes by hash (`commons:<hash>` for pinned commons). */
@@ -106,18 +106,18 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
106
106
  }
107
107
 
108
108
  /** Refuse the declared targets a policy treats as refusals, before any byte is read or executed. */
109
- export function assertProductTargets(source: Shardfile, policy: 'warn' | 'refuse'): void {
109
+ export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse'): void {
110
110
  const issues = performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal');
111
111
  if (issues.length === 0) return;
112
112
  throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
113
113
  }
114
114
 
115
115
  /** Admit a whole shardfile's declared costs and its actual immutable bytes through the defining contracts. */
116
- export function admitShardfileProduct(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
116
+ export function admitShardfileFolder(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
117
117
  policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = []): Shardfile {
118
118
  const source = coded('shard-schema', (): Shardfile => parseShardfile(input));
119
119
  coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy)); });
120
- coded('performance-targets', (): void => { assertProductTargets(source, policy); });
120
+ coded('performance-targets', (): void => { assertShardfileTargets(source, policy); });
121
121
  return coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy), undefined, scripts));
122
122
  }
123
123
 
@@ -128,7 +128,7 @@ export function checkWorldTargets(source: Shardfile, input: unknown): void {
128
128
  if (errors.length > 0) throw issueError('world-targets', errors.join('; '));
129
129
  }
130
130
 
131
- function inspectBlob(file: OutputFile, bytes: Uint8Array, ports: ProductValidationPorts, script?: ScriptContract): void {
131
+ function inspectBlob(file: OutputFile, bytes: Uint8Array, ports: ShardfileValidationPorts, script?: ScriptContract): void {
132
132
  const contract = file.name === undefined ? undefined : registeredJsonContract(file.name);
133
133
  if (contract !== undefined && (file.kind !== 'json' || file.jsonSchema === undefined)) throw new Error('Registered JSON requires its defining schema');
134
134
  if (file.jsonSchema !== undefined) {
@@ -203,7 +203,7 @@ function readCook(index: OutputIndex, read: ReadListed, hash: (bytes: Uint8Array
203
203
  * kind with no declared side (SERVER-PARITY SS2, `feature-sides.ts`) is refused by name before its section schema runs, and
204
204
  * a script run on the wrong side (SS7, `script-sides.ts`) once the sections are read. A refusal carries the `code` of the
205
205
  * check that refused (SA41, `issue-codes.ts`). */
206
- export function validateShardfileProduct(files: ProductFiles, ports: ProductValidationPorts): ValidatedProduct {
206
+ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileValidationPorts): ValidatedShardfile {
207
207
  const verify = ports.verify ?? ((bytes: Uint8Array, expected: string): boolean => ports.hash(bytes) === expected);
208
208
  const index = coded('index-invalid', (): OutputIndex => parseOutputIndex(readCanonicalJson(files.read('shard.json', limits.sourceBytes))));
209
209
  const listed = new Set(['shard.json', 'validation.json']), { assets, keep } = assetStore(files.read, ports.readThrough === true);
@@ -229,8 +229,8 @@ export function validateShardfileProduct(files: ProductFiles, ports: ProductVali
229
229
  coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
230
230
  }
231
231
  for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
232
- const shard = admitShardfileProduct(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts);
232
+ const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts);
233
233
  checkWorldTargets(shard, payloads.get('world/targets'));
234
234
  if (ports.hash(validationSourceBytes(shard)) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
235
- return { index, shard, assets, sections: payloads, scripts, warnings, audio: productRecordings({ cook, read: files.read, shard, assets }) };
235
+ return { index, shard, assets, sections: payloads, scripts, warnings, audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
236
236
  }
@@ -1,16 +1,16 @@
1
1
  import type {Shardfile} from './shardSchema.ts';
2
2
  import {preflightShardfile} from './preflight.ts';
3
3
 
4
- /** What `productWireBytes` reads of a product. */
4
+ /** What `shardfileWireBytes` reads of a product. */
5
5
  type Wire=Readonly<{files:readonly Readonly<{compressed:number}>[];requires:Readonly<{commons:readonly string[];commonsWire:Readonly<Record<string,number>>}>}>;
6
6
  /** The wire a product claim holds: every file's and pinned common's compressed bytes. No residency figure is below it. */
7
- function productWireBytes(source:Wire):number{
7
+ function shardfileWireBytes(source:Wire):number{
8
8
  return source.files.reduce((sum,file)=>sum+file.compressed,0)
9
9
  +source.requires.commons.reduce((sum,hash)=>sum+(source.requires.commonsWire[hash]??0),0);
10
10
  }
11
11
  /** Exact existing source/wire claim, computed once by the publisher for first-party clients. */
12
12
  function publishedSourceResidency(source:Shardfile):number{
13
13
  const accounting={heapBytes:0};preflightShardfile(source,accounting);
14
- return productWireBytes(source)+accounting.heapBytes*2+(source.files.length+source.requires.commons.length)*128+1024;
14
+ return shardfileWireBytes(source)+accounting.heapBytes*2+(source.files.length+source.requires.commons.length)*128+1024;
15
15
  }
16
- export {productWireBytes,publishedSourceResidency};
16
+ export {shardfileWireBytes,publishedSourceResidency};
package/src/format/tar.ts CHANGED
@@ -200,5 +200,5 @@ function readTar(bytes: Readonly<Uint8Array>): ReadonlyMap<string, Uint8Array> {
200
200
 
201
201
  export type { TarEntry, TarSource } from './tar-source.ts'
202
202
  export { writeTar } from './tar-write.ts'
203
- // `readTarHeader` is the streaming walk's (productStream.ts): one header, the same refusals.
203
+ // `readTarHeader` is the streaming walk's (shardfileStream.ts): one header, the same refusals.
204
204
  export { header as readTarHeader, indexTar, readTar }
@@ -9,7 +9,7 @@ export interface ValidationReceipt {
9
9
  residentBytes?:number;
10
10
  }
11
11
  /** Lookup of a build-stamped number, not a client cost/preflight calculation. */
12
- export function builtProductResidency(sourceHash:string):number|undefined{
12
+ export function builtShardfileResidency(sourceHash:string):number|undefined{
13
13
  const rows:unknown=typeof __SHARDFILE_VERDICTS__==='object'?__SHARDFILE_VERDICTS__:null;
14
14
  if(!Array.isArray(rows))return undefined;
15
15
  for(const item of rows){
@@ -19,7 +19,7 @@ export function builtProductResidency(sourceHash:string):number|undefined{
19
19
  return undefined;
20
20
  }
21
21
  /** Static post cost is validated with the published graph bytes, never recosted at entry. */
22
- export function builtProductPostCost(sourceHash:string):PostStackCost|undefined{
22
+ export function builtShardfilePostCost(sourceHash:string):PostStackCost|undefined{
23
23
  const rows:unknown=typeof __SHARDFILE_VERDICTS__==='object'?__SHARDFILE_VERDICTS__:null;
24
24
  if(!Array.isArray(rows))return undefined;
25
25
  for(const item of rows){
File without changes