@wildshard/shard-format 0.70.0 → 0.72.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 (67) hide show
  1. package/package.json +15 -3
  2. package/src/cli/corpus-candidate.ts +228 -0
  3. package/src/cli/corpus-command.ts +32 -3
  4. package/src/cli/corpus-pins.ts +73 -0
  5. package/src/cli/corpus-report.ts +36 -0
  6. package/src/cli/corpus-tar.ts +28 -0
  7. package/src/cli/corpus-usage.ts +24 -3
  8. package/src/cli/corpus.ts +50 -68
  9. package/src/cli/format-diff-range.ts +112 -0
  10. package/src/cli/main.ts +39 -9
  11. package/src/cli/pack.ts +20 -3
  12. package/src/cli/validate.ts +1 -1
  13. package/src/format/clientOwnership.ts +1 -1
  14. package/src/format/clientTrails.ts +121 -46
  15. package/src/format/cook-data.ts +19 -1
  16. package/src/format/cook-deprecations.ts +53 -0
  17. package/src/format/cook-preparation.ts +2 -1
  18. package/src/format/creature-rest-rig.ts +248 -0
  19. package/src/format/creature-skin-bounds.ts +146 -0
  20. package/src/format/deprecations.ts +18 -21
  21. package/src/format/edge-observations.ts +67 -0
  22. package/src/format/empty-shardfile.ts +5 -3
  23. package/src/format/entry-read-set.ts +147 -0
  24. package/src/format/format-migrate-rebuild.ts +4 -1
  25. package/src/format/format-migrate.ts +7 -1
  26. package/src/format/format-migration-envelope.ts +19 -0
  27. package/src/format/format-migration-prune.ts +42 -1
  28. package/src/format/format-migrations.ts +8 -1
  29. package/src/format/format-window.ts +71 -0
  30. package/src/format/immutable.ts +4 -1
  31. package/src/format/json-schema.ts +1474 -0
  32. package/src/format/lootEconomy.ts +4 -1
  33. package/src/format/mat4.ts +225 -0
  34. package/src/format/memory-armed.json +1 -9
  35. package/src/format/memory-armed.ts +46 -17
  36. package/src/format/memory-epoch.ts +10 -3
  37. package/src/format/memory-line.ts +17 -6
  38. package/src/format/outputFields.ts +3 -2
  39. package/src/format/outputIndex.ts +25 -8
  40. package/src/format/platformDataSections.ts +5 -0
  41. package/src/format/platformFileFamilies.ts +3 -3
  42. package/src/format/play-area.ts +95 -0
  43. package/src/format/policy-verdict.ts +12 -2
  44. package/src/format/preparation-checks.ts +12 -1
  45. package/src/format/preparation-spec.ts +24 -0
  46. package/src/format/registeredJson.ts +2 -2
  47. package/src/format/runtime-tier.ts +14 -7
  48. package/src/format/save-revision.ts +105 -0
  49. package/src/format/schema-source.ts +70 -0
  50. package/src/format/sections.ts +4 -1
  51. package/src/format/server-plan.ts +42 -0
  52. package/src/format/server-reads.ts +23 -0
  53. package/src/format/shardSchema.ts +9 -4
  54. package/src/format/shardSections.ts +17 -7
  55. package/src/format/shardfile-assets.ts +5 -5
  56. package/src/format/shardfile-stream-admit.ts +19 -10
  57. package/src/format/shardfile-stream-assets.ts +11 -2
  58. package/src/format/shardfile-stream-facts.ts +2 -1
  59. package/src/format/shardfile-stream.ts +2 -3
  60. package/src/format/shardfileValidation.ts +16 -9
  61. package/src/format/species-deprecations.ts +79 -0
  62. package/src/format/stateLineage.ts +12 -6
  63. package/src/format/tread-boxes.ts +65 -0
  64. package/src/format/vehicle-hulls.ts +124 -0
  65. package/src/format/version.ts +74 -17
  66. package/src/format/whole-inputs.ts +51 -0
  67. package/src/tools/runtime-hosts.json +4 -0
@@ -163,5 +163,23 @@ function readCookData(input: unknown): CookData {
163
163
  return data
164
164
  }
165
165
 
166
+ /** SHARD-COMPAT SP1b1a: `cook.json`'s version alone, read without its rows, so a reader can name a newer spec
167
+ * (`unreadPreparationSpec`) before `readCookData` refuses it. `undefined` when it names no integer version. */
168
+ function cookDataSpec(input: unknown): number | undefined {
169
+ if (typeof input !== 'object' || input === null) {
170
+ return undefined
171
+ }
172
+ const version: unknown = (input as { version?: unknown }).version
173
+ return typeof version === 'number' && Number.isInteger(version)
174
+ ? version
175
+ : undefined
176
+ }
177
+
166
178
  export type { CookData, CookMount }
167
- export { COOK_DATA_PATH, CookDataSchema, cookMountPath, readCookData }
179
+ export {
180
+ COOK_DATA_PATH,
181
+ CookDataSchema,
182
+ cookDataSpec,
183
+ cookMountPath,
184
+ readCookData,
185
+ }
@@ -0,0 +1,53 @@
1
+ /** FORMAT-PRUNE FP19: unprepared originals and old cook data are deprecated. Neither can be mended by data alone; the
2
+ * box's cook prepares them (SP1b), and they are deleted at FP23 once FE7 counts no kept upload using them. No engine
3
+ * pin uses either. A 0.1.0.3 file with no `preparation` is an author's file before `wildshard prepare` and is not
4
+ * warned; only the old `sdk: '0.2'` marker says a stored original was never prepared. */
5
+
6
+ /** The registry's row shape (`deprecations.ts`), with what it reads: the index and, from the folder validator, the
7
+ * parsed `cook.json` (the stream validator has none, so it never warns on cook data). */
8
+ interface CookDeprecation {
9
+ readonly id: string
10
+ readonly path: string
11
+ readonly since: string
12
+ readonly replacement: string
13
+ readonly migration: undefined
14
+ readonly uses: (
15
+ shard: Readonly<{ index: unknown; cook?: unknown }>,
16
+ ) => boolean
17
+ }
18
+
19
+ const BUILT_SDK = '0.2'
20
+ const CURRENT_COOK_DATA = 3
21
+ const SINCE = '0.1.0.4'
22
+
23
+ function field(value: unknown, key: string): unknown {
24
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
25
+ ? Reflect.get(value, key)
26
+ : undefined
27
+ }
28
+
29
+ const COOK_DEPRECATIONS: readonly CookDeprecation[] = [
30
+ {
31
+ id: 'shard.unprepared',
32
+ path: "shard.json sdk '0.2': a stored original built and never prepared (FORMAT-PRUNE FP19)",
33
+ since: SINCE,
34
+ replacement:
35
+ 'a prepared file: run wildshard prepare before upload; the box cook prepares old ones (SP1b)',
36
+ migration: undefined,
37
+ uses: (shard: Readonly<{ index: unknown }>): boolean =>
38
+ field(shard.index, 'sdk') === BUILT_SDK,
39
+ },
40
+ {
41
+ id: 'cook.legacy-data',
42
+ path: 'cook.json version 1 or 2 (FORMAT-PRUNE FP19)',
43
+ since: SINCE,
44
+ replacement: 'cook.json version 3 or later, written by wildshard prepare',
45
+ migration: undefined,
46
+ uses: (shard: Readonly<{ cook?: unknown }>): boolean => {
47
+ const version = field(shard.cook, 'version')
48
+ return typeof version === 'number' && version < CURRENT_COOK_DATA
49
+ },
50
+ },
51
+ ]
52
+
53
+ export { COOK_DEPRECATIONS }
@@ -27,6 +27,7 @@ import {
27
27
  LEGACY_PREPARATION_SPEC,
28
28
  PREPARATION_SPEC,
29
29
  } from './preparation-spec.ts'
30
+ import { asWrittenIdentity } from './save-revision.ts'
30
31
  import { validationSourceBytes } from './validationReceipt.ts'
31
32
 
32
33
  import type { OutputIndex } from './outputIndex.ts'
@@ -215,7 +216,7 @@ function cookPreparationBytes(
215
216
  ): Uint8Array {
216
217
  const { cook: _cook, ...inputs } = index
217
218
  return validationSourceBytes({
218
- index: inputs,
219
+ index: asWrittenIdentity(inputs, index.formatVersion),
219
220
  mounts,
220
221
  ...(renderer === undefined ? {} : { renderer }),
221
222
  })
@@ -0,0 +1,248 @@
1
+ /* oxlint-disable id-length, import/exports-last, import/no-namespace, max-params, max-statements, no-magic-numbers, no-use-before-define, prefer-destructuring, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/max-nested-calls -- a port of engine's GLB rest reading and three.js 0.186's matrix steps (SHARD-COMPAT PR6a), kept term for term so the values match the engine byte for byte */
2
+ // SHARD-COMPAT PR6a (J487): a creature skin's rest rig (each joint's parent and its rest offset from that parent),
3
+ // read from the admitted GLB with format code only, so the MMO server builds hit volumes, sockets and giant heights
4
+ // without engine code. Moved from engine `src/shared/game/shardfile/creatureRestRig.ts` (three's matrices replaced by
5
+ // `mat4.ts`, the same arithmetic): the position-only inverse-bind rest contract, meshopt buffer views included.
6
+ import * as v from 'valibot'
7
+
8
+ import { glbBuffers } from './glbBuffers.ts'
9
+ import { parseGlbData } from './glbCost.ts'
10
+ import { decompose, determinant, invert } from './mat4.ts'
11
+
12
+ /** One rest joint: its name, its parent's index in the rig (-1 at a root) and its offset from that parent. */
13
+ export interface CreatureRestJoint {
14
+ readonly name: string
15
+ readonly parent: number
16
+ readonly position: readonly [number, number, number]
17
+ }
18
+
19
+ const MAX_COUNT = 4_000_000
20
+ const MAX_JOINTS = 32
21
+ const MAT4_BYTES = 64
22
+ const FLOAT_BYTES = 4
23
+ const FLOAT = 5126
24
+ const ELEMENTS = 16
25
+ const HEADER = 20
26
+ const CHUNK = 8
27
+ const JSON_LENGTH_AT = 12
28
+ const SINGULAR = 1e-12
29
+ const UNIT = 1e-5
30
+
31
+ const count = v.pipe(
32
+ v.number(),
33
+ v.integer(),
34
+ v.minValue(0),
35
+ v.maxValue(MAX_COUNT),
36
+ )
37
+ const Doc = v.looseObject({
38
+ nodes: v.array(
39
+ v.object({
40
+ name: v.optional(v.string()),
41
+ children: v.optional(v.array(count), []),
42
+ skin: v.optional(count),
43
+ mesh: v.optional(count),
44
+ }),
45
+ ),
46
+ skins: v.array(
47
+ v.object({ joints: v.array(count), inverseBindMatrices: count }),
48
+ ),
49
+ accessors: v.array(v.unknown()),
50
+ })
51
+ const Accessor = v.object({
52
+ bufferView: count,
53
+ byteOffset: v.optional(count, 0),
54
+ componentType: v.literal(FLOAT),
55
+ type: v.literal('MAT4'),
56
+ count,
57
+ })
58
+ const View = v.object({
59
+ byteOffset: v.optional(count, 0),
60
+ byteStride: v.optional(count, MAT4_BYTES),
61
+ byteLength: count,
62
+ })
63
+
64
+ type GlbDoc = v.InferOutput<typeof Doc>
65
+ type Vec3 = readonly [number, number, number]
66
+
67
+ interface Joints {
68
+ readonly order: readonly number[]
69
+ readonly names: ReadonlyMap<number, string>
70
+ readonly positions: ReadonlyMap<number, Vec3>
71
+ readonly parents: ReadonlyMap<number, number>
72
+ }
73
+
74
+ function glbDoc(bytes: Uint8Array): {
75
+ readonly doc: GlbDoc
76
+ readonly length: number
77
+ } {
78
+ parseGlbData(bytes)
79
+ const length = new DataView(
80
+ bytes.buffer,
81
+ bytes.byteOffset,
82
+ bytes.byteLength,
83
+ ).getUint32(JSON_LENGTH_AT, true)
84
+ const text = new TextDecoder().decode(bytes.subarray(HEADER, HEADER + length))
85
+ return { doc: v.parse(Doc, JSON.parse(text)), length }
86
+ }
87
+
88
+ /** The one skinned mesh's skin, bounded and in the expected joint count. */
89
+ function oneSkin(
90
+ doc: GlbDoc,
91
+ expected: readonly string[],
92
+ ): GlbDoc['skins'][number] {
93
+ const meshes = doc.nodes.filter(
94
+ node => node.skin !== undefined && node.mesh !== undefined,
95
+ )
96
+ const mesh = meshes[0]
97
+ const skin = mesh?.skin === undefined ? undefined : doc.skins[mesh.skin]
98
+ if (
99
+ meshes.length !== 1 ||
100
+ skin === undefined ||
101
+ skin.joints.length !== expected.length ||
102
+ skin.joints.length > MAX_JOINTS
103
+ ) {
104
+ throw new Error('Creature rest rig needs one bounded skin')
105
+ }
106
+ return skin
107
+ }
108
+
109
+ /** Each node's one parent. */
110
+ function parentsOf(doc: GlbDoc): ReadonlyMap<number, number> {
111
+ const parents = new Map<number, number>()
112
+ for (const [parent, node] of doc.nodes.entries()) {
113
+ for (const child of node.children) {
114
+ if (parents.has(child)) {
115
+ throw new Error('Ambiguous creature rest parent')
116
+ }
117
+ parents.set(child, parent)
118
+ }
119
+ }
120
+ return parents
121
+ }
122
+
123
+ /** A joint's rest position: the translation of its inverse bind's inverse, which must be unrotated and unscaled. */
124
+ function restPosition(binary: DataView, at: number): Vec3 {
125
+ const matrix = Array.from({ length: ELEMENTS }, (_, field) =>
126
+ binary.getFloat32(at + field * FLOAT_BYTES, true),
127
+ )
128
+ if (Math.abs(determinant(matrix)) < SINGULAR) {
129
+ throw new Error('Singular creature inverse bind')
130
+ }
131
+ const { position, quaternion, scale } = decompose(invert(matrix))
132
+ const [sx, sy, sz] = scale
133
+ if (
134
+ Math.abs(Math.abs(quaternion[3]) - 1) > UNIT ||
135
+ Math.abs(sx - 1) + Math.abs(sy - 1) + Math.abs(sz - 1) > UNIT
136
+ ) {
137
+ throw new Error('Creature bind pose must be unrotated and unscaled')
138
+ }
139
+ return position
140
+ }
141
+
142
+ /** Every skin joint's name and rest position, in skin order. */
143
+ function readJoints(bytes: Uint8Array, expected: readonly string[]): Joints {
144
+ const { doc, length } = glbDoc(bytes)
145
+ const skin = oneSkin(doc, expected)
146
+ const data = glbBuffers(doc, bytes.subarray(HEADER + CHUNK + length))
147
+ const accessor = v.parse(Accessor, doc.accessors[skin.inverseBindMatrices])
148
+ const view = v.parse(View, data.views[accessor.bufferView])
149
+ if (
150
+ accessor.count !== skin.joints.length ||
151
+ view.byteStride < MAT4_BYTES ||
152
+ accessor.byteOffset + (accessor.count - 1) * view.byteStride + MAT4_BYTES >
153
+ view.byteLength
154
+ ) {
155
+ throw new Error('Invalid creature inverse binds')
156
+ }
157
+ const binary = new DataView(
158
+ data.bytes.buffer,
159
+ data.bytes.byteOffset,
160
+ data.bytes.byteLength,
161
+ )
162
+ const names = new Map<number, string>()
163
+ const positions = new Map<number, Vec3>()
164
+ for (const [index, node] of skin.joints.entries()) {
165
+ const name = doc.nodes[node]?.name
166
+ if (
167
+ name === undefined ||
168
+ name !== expected[index] ||
169
+ names.has(node) ||
170
+ [...names.values()].includes(name)
171
+ ) {
172
+ throw new Error('Creature rest joint order differs from skin')
173
+ }
174
+ names.set(node, name)
175
+ positions.set(
176
+ node,
177
+ restPosition(
178
+ binary,
179
+ view.byteOffset + accessor.byteOffset + index * view.byteStride,
180
+ ),
181
+ )
182
+ }
183
+ return { order: skin.joints, names, positions, parents: parentsOf(doc) }
184
+ }
185
+
186
+ /** The rig in parent-first order, each position relative to its parent joint. */
187
+ function ordered(joints: Joints): readonly CreatureRestJoint[] {
188
+ const result: CreatureRestJoint[] = []
189
+ const indices = new Map<number, number>()
190
+ const visiting = new Set<number>()
191
+ const append = (node: number): number => {
192
+ const previous = indices.get(node)
193
+ if (previous !== undefined) {
194
+ return previous
195
+ }
196
+ if (visiting.has(node)) {
197
+ throw new Error('Cyclic creature rest rig')
198
+ }
199
+ visiting.add(node)
200
+ const parentNode = joints.parents.get(node)
201
+ const parent =
202
+ parentNode !== undefined && joints.names.has(parentNode)
203
+ ? append(parentNode)
204
+ : -1
205
+ const index = result.length
206
+ result.push(
207
+ restJoint(joints, node, parent === -1 ? undefined : parentNode, parent),
208
+ )
209
+ indices.set(node, index)
210
+ visiting.delete(node)
211
+ return index
212
+ }
213
+ for (const node of joints.order) {
214
+ append(node)
215
+ }
216
+ return result
217
+ }
218
+
219
+ function restJoint(
220
+ joints: Joints,
221
+ node: number,
222
+ parentNode: number | undefined,
223
+ parent: number,
224
+ ): CreatureRestJoint {
225
+ const position = joints.positions.get(node)
226
+ const name = joints.names.get(node)
227
+ if (position === undefined || name === undefined) {
228
+ throw new Error('Missing creature rest joint')
229
+ }
230
+ const [px, py, pz] =
231
+ parentNode === undefined
232
+ ? [0, 0, 0]
233
+ : (joints.positions.get(parentNode) ?? [0, 0, 0])
234
+ const [x, y, z] = position
235
+ return {
236
+ name,
237
+ parent,
238
+ position: parentNode === undefined ? [x, y, z] : [x - px, y - py, z - pz],
239
+ }
240
+ }
241
+
242
+ /** The same position-only inverse-bind rest contract as engine's client skins, without a renderer. */
243
+ export function creatureRestRig(
244
+ bytes: Uint8Array,
245
+ expected: readonly string[],
246
+ ): readonly CreatureRestJoint[] {
247
+ return ordered(readJoints(bytes, expected))
248
+ }
@@ -0,0 +1,146 @@
1
+ /* oxlint-disable id-length, import/exports-last, import/no-namespace, max-statements, no-magic-numbers, no-plusplus, prefer-destructuring, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/max-nested-calls, unicorn/no-array-reduce -- a port of engine's GLB rest reading and three.js 0.186's matrix steps (SHARD-COMPAT PR6a), kept term for term so the values match the engine byte for byte */
2
+ // SHARD-COMPAT PR6a (J487): a creature skin's rest height, read from its admitted GLB with format code only, so the MMO
3
+ // server and the cook compute giant heights without engine code. Moved verbatim from engine
4
+ // `src/shared/game/shardfile/creatureSkinBounds.ts`: rest geometry as the skin instance draws it.
5
+ import * as v from 'valibot'
6
+
7
+ import { glbBuffers } from './glbBuffers.ts'
8
+ import { parseGlbData } from './glbCost.ts'
9
+
10
+ const MAX_COUNT = 4_000_000
11
+ const FLOAT = 5126
12
+ const SHORT = 5122
13
+ const FLOAT_BYTES = 4
14
+ const SHORT_BYTES = 2
15
+ const AXES = 3
16
+ const SHORT_MAX = 32_767
17
+ const HEADER = 20
18
+ const CHUNK = 8
19
+ const JSON_LENGTH_AT = 12
20
+
21
+ const count = v.pipe(
22
+ v.number(),
23
+ v.integer(),
24
+ v.minValue(0),
25
+ v.maxValue(MAX_COUNT),
26
+ )
27
+ const Doc = v.looseObject({
28
+ nodes: v.array(
29
+ v.object({ mesh: v.optional(count), skin: v.optional(count) }),
30
+ ),
31
+ meshes: v.array(
32
+ v.object({
33
+ primitives: v.array(
34
+ v.object({ attributes: v.object({ POSITION: count }) }),
35
+ ),
36
+ }),
37
+ ),
38
+ accessors: v.array(v.unknown()),
39
+ })
40
+ const Accessor = v.object({
41
+ bufferView: count,
42
+ byteOffset: v.optional(count, 0),
43
+ componentType: v.picklist([FLOAT, SHORT]),
44
+ type: v.literal('VEC3'),
45
+ count,
46
+ normalized: v.optional(v.boolean(), false),
47
+ })
48
+ const View = v.object({
49
+ byteOffset: v.optional(count, 0),
50
+ byteStride: v.optional(count),
51
+ byteLength: count,
52
+ })
53
+
54
+ type GlbDoc = v.InferOutput<typeof Doc>
55
+ type Primitive = GlbDoc['meshes'][number]['primitives'][number]
56
+
57
+ /** A skin's rest height range: the lowest and highest Y its vertices reach. */
58
+ export interface SkinBounds {
59
+ readonly lower: number
60
+ readonly upper: number
61
+ }
62
+
63
+ interface Stream {
64
+ readonly binary: DataView
65
+ readonly views: readonly unknown[]
66
+ readonly accessors: readonly unknown[]
67
+ }
68
+
69
+ function glbDoc(bytes: Uint8Array): {
70
+ readonly doc: GlbDoc
71
+ readonly length: number
72
+ } {
73
+ parseGlbData(bytes)
74
+ const length = new DataView(
75
+ bytes.buffer,
76
+ bytes.byteOffset,
77
+ bytes.byteLength,
78
+ ).getUint32(JSON_LENGTH_AT, true)
79
+ const text = new TextDecoder().decode(bytes.subarray(HEADER, HEADER + length))
80
+ return { doc: v.parse(Doc, JSON.parse(text)), length }
81
+ }
82
+
83
+ /** One primitive's Y range, folded into `bounds`. */
84
+ function primitiveBounds(
85
+ stream: Stream,
86
+ primitive: Primitive,
87
+ bounds: SkinBounds,
88
+ ): SkinBounds {
89
+ const accessor = v.parse(
90
+ Accessor,
91
+ stream.accessors[primitive.attributes.POSITION],
92
+ )
93
+ const view = v.parse(View, stream.views[accessor.bufferView])
94
+ const width = accessor.componentType === FLOAT ? FLOAT_BYTES : SHORT_BYTES
95
+ const stride = view.byteStride ?? width * AXES
96
+ if (
97
+ stride < width * AXES ||
98
+ accessor.byteOffset + (accessor.count - 1) * stride + width * AXES >
99
+ view.byteLength
100
+ ) {
101
+ throw new Error('Invalid creature position bounds')
102
+ }
103
+ let { lower, upper } = bounds
104
+ for (let index = 0; index < accessor.count; index++) {
105
+ const at = view.byteOffset + accessor.byteOffset + index * stride + width
106
+ const raw =
107
+ width === FLOAT_BYTES
108
+ ? stream.binary.getFloat32(at, true)
109
+ : stream.binary.getInt16(at, true)
110
+ const y =
111
+ width === SHORT_BYTES && accessor.normalized
112
+ ? Math.max(raw / SHORT_MAX, -1)
113
+ : raw
114
+ lower = Math.min(lower, y)
115
+ upper = Math.max(upper, y)
116
+ }
117
+ return { lower, upper }
118
+ }
119
+
120
+ /** Rest geometry as the skin instance draws it: static-prop triangle visitors refuse deforming skins, so this reads
121
+ * the admitted position streams directly. */
122
+ export function creatureSkinBounds(bytes: Uint8Array): SkinBounds {
123
+ const { doc, length } = glbDoc(bytes)
124
+ const nodes = doc.nodes.filter(
125
+ node => node.skin !== undefined && node.mesh !== undefined,
126
+ )
127
+ const node = nodes[0]
128
+ const mesh = node?.mesh === undefined ? undefined : doc.meshes[node.mesh]
129
+ if (nodes.length !== 1 || mesh === undefined) {
130
+ throw new Error('Creature bounds need one admitted skin')
131
+ }
132
+ const data = glbBuffers(doc, bytes.subarray(HEADER + CHUNK + length))
133
+ const binary = new DataView(
134
+ data.bytes.buffer,
135
+ data.bytes.byteOffset,
136
+ data.bytes.byteLength,
137
+ )
138
+ const stream = { binary, views: data.views, accessors: doc.accessors }
139
+ return mesh.primitives.reduce<SkinBounds>(
140
+ (bounds, primitive) => primitiveBounds(stream, primitive, bounds),
141
+ {
142
+ lower: 0,
143
+ upper: 0,
144
+ },
145
+ )
146
+ }
@@ -1,8 +1,15 @@
1
1
  // oxlint-disable typescript/prefer-readonly-parameter-types -- the index is valibot output, only read
2
- /** The deprecation counter (SHARD-COMPAT FE7, J486). A deprecated path still validates; it carries the version that
3
- * deprecated it and its replacement, both validators warn when a shard file uses it, and the corpus counts the kept
4
- * files using each (`shard-format corpus`). A path with a migration is mended by the chain; one without waits for its
5
- * users to reach zero before it is deleted. */
2
+ /** The deprecation counter (SHARD-COMPAT FE7, J486). A deprecated path still validates, with its version and replacement;
3
+ * both validators warn on it and the corpus counts its kept users (`shard-format corpus`). A path with a migration is
4
+ * mended by the chain; one without is deleted once no kept file uses it. */
5
+ import { COOK_DEPRECATIONS } from './cook-deprecations.ts'
6
+ import { SAVE_REVISION_DEPRECATION } from './save-revision.ts'
7
+ import { SCHEMA_SOURCE_DEPRECATION } from './schema-source.ts'
8
+ import {
9
+ SPECIES_FEATURE_DEPRECATIONS,
10
+ SPECIES_SECTION_DEPRECATIONS,
11
+ } from './species-deprecations.ts'
12
+
6
13
  import type { OutputIndex } from './outputIndex.ts'
7
14
 
8
15
  /** One deprecated path. */
@@ -19,10 +26,11 @@ interface Deprecation {
19
26
  readonly migration: string | undefined
20
27
  }
21
28
 
22
- /** What a deprecation test reads: the index and each section by name. */
29
+ /** What a deprecation test reads: the index, each section by name and, from the folder validator, `cook.json`. */
23
30
  interface DeprecationInput {
24
31
  readonly index: Readonly<OutputIndex> | Readonly<Record<string, unknown>>
25
32
  readonly sections: ReadonlyMap<string, unknown>
33
+ readonly cook?: unknown
26
34
  }
27
35
 
28
36
  interface DeprecationRule extends Deprecation {
@@ -44,12 +52,6 @@ const EMPTY_INDEX_FIELDS: readonly (readonly [string, string | undefined])[] = [
44
52
  ['runtime', 'files'],
45
53
  ['runtime', 'lines'],
46
54
  ]
47
- /** FORMAT-PRUNE FP15: OF30 cut B leaves these as plain JSON nothing reads. */
48
- const SPECIES_PROGRAM_FAMILY: readonly string[] = [
49
- 'actors/species-programs',
50
- 'look/hull-book',
51
- 'look/rigged-hulls',
52
- ]
53
55
 
54
56
  function field(value: unknown, key: string): unknown {
55
57
  return typeof value === 'object' && value !== null && !Array.isArray(value)
@@ -117,6 +119,10 @@ const RULES: readonly DeprecationRule[] = [
117
119
  uses: (shard: Readonly<DeprecationInput>): boolean =>
118
120
  field(shard.index, 'sdk') !== undefined,
119
121
  },
122
+ SAVE_REVISION_DEPRECATION,
123
+ SCHEMA_SOURCE_DEPRECATION,
124
+ ...COOK_DEPRECATIONS,
125
+ ...SPECIES_FEATURE_DEPRECATIONS,
120
126
  {
121
127
  id: 'requires.sdk',
122
128
  path: 'shard.json requires.sdk (SHARD-COMPAT CP8): a copy of the format version',
@@ -158,16 +164,7 @@ const RULES: readonly DeprecationRule[] = [
158
164
  uses: (shard: Readonly<DeprecationInput>): boolean =>
159
165
  field(field(shard.index, 'runtime'), 'trust') !== undefined,
160
166
  },
161
- ...SPECIES_PROGRAM_FAMILY.map((name: string): DeprecationRule => ({
162
- id: `section.${name}`,
163
- path: `sections/${name} (the species-program family, FORMAT-PRUNE FP15)`,
164
- since: CURRENT,
165
- replacement:
166
- 'species rows and authored looks (actors/species); nothing reads it once OF30 lands',
167
- migration: undefined,
168
- uses: (shard: Readonly<DeprecationInput>): boolean =>
169
- shard.sections.has(name),
170
- })),
167
+ ...SPECIES_SECTION_DEPRECATIONS,
171
168
  {
172
169
  id: 'items.legacySlot',
173
170
  path: 'an item equipment row legacySlot: a closed list of engine-native weapon names (FORMAT-PRUNE FP17)',
@@ -0,0 +1,67 @@
1
+ import {
2
+ exactOptional,
3
+ finite,
4
+ maxValue,
5
+ minValue,
6
+ number,
7
+ picklist,
8
+ pipe,
9
+ strictObject,
10
+ } from 'valibot'
11
+
12
+ import type { GenericSchema } from 'valibot'
13
+
14
+ /** Open water stands within the same bounds as an edge row's heights. */
15
+ const WATER_LIMIT = 250
16
+ const water = pipe(
17
+ number(),
18
+ finite(),
19
+ minValue(-WATER_LIMIT),
20
+ maxValue(WATER_LIMIT),
21
+ )
22
+ const geometry = picklist(['ground', 'void'])
23
+
24
+ interface EdgeObservationRowFields {
25
+ geometry?: 'ground' | 'void'
26
+ waterSurface?: number
27
+ }
28
+ type EdgeObservationRow = {
29
+ [Key in keyof EdgeObservationRowFields]: EdgeObservationRowFields[Key]
30
+ }
31
+ interface EdgeObservationsRowsFields {
32
+ north: EdgeObservationRow
33
+ east: EdgeObservationRow
34
+ south: EdgeObservationRow
35
+ west: EdgeObservationRow
36
+ }
37
+ type EdgeObservationsRows = {
38
+ [Key in keyof EdgeObservationsRowsFields]: EdgeObservationsRowsFields[Key]
39
+ }
40
+
41
+ /** PR6f1 (meta SHARD-COMPAT): what the cell's builder saw at one boundary, beside its rows. `geometry` says whether the
42
+ * edge stands on ground or drops to void; `waterSurface` is the open water's height there (0 is sea level). Engine's
43
+ * road strips read these; they never invent height at an entry. Optional: a file without them reads as before. */
44
+ const EdgeObservationSchema: GenericSchema<
45
+ EdgeObservationRow,
46
+ EdgeObservationRow
47
+ > = strictObject({
48
+ geometry: exactOptional(geometry),
49
+ waterSurface: exactOptional(water),
50
+ })
51
+ /** One observation per boundary, the same four sides as `edge`. */
52
+ const EdgeObservationsSchema: GenericSchema<
53
+ EdgeObservationsRows,
54
+ EdgeObservationsRows
55
+ > = strictObject({
56
+ north: EdgeObservationSchema,
57
+ east: EdgeObservationSchema,
58
+ south: EdgeObservationSchema,
59
+ west: EdgeObservationSchema,
60
+ })
61
+
62
+ export {
63
+ EdgeObservationSchema,
64
+ EdgeObservationsSchema,
65
+ type EdgeObservationRow,
66
+ type EdgeObservationsRows,
67
+ }
@@ -6,6 +6,7 @@ import { parseShardfile } from './shardSchema.ts'
6
6
  import { SHARDFILE_VERSION } from './version.ts'
7
7
 
8
8
  import type { Shardfile } from './shardSchema.ts'
9
+ import type { ShardIdentityInput } from './shardSections.ts'
9
10
 
10
11
  /** Each starting door is as wide as the format's entry width. */
11
12
  function widened(
@@ -14,8 +15,9 @@ function widened(
14
15
  return { edge: row.edge, at: row.at, width: ENTRY_WIDTH }
15
16
  }
16
17
 
17
- /** A valid empty world; add baked content before shipping a playable shard. */
18
- function emptyShardfile(identity: Readonly<Shardfile['identity']>): Shardfile {
18
+ /** A valid empty world, with no `requires.sdk` (SHARD-COMPAT CP8: a copy of the format version, deprecated); add baked content before shipping a playable shard. The identity takes `saveRevision`, or
19
+ * the spelling up to format 0.1.0.3, `revision` (FP26); the file comes back with `saveRevision`. */
20
+ function emptyShardfile(identity: Readonly<ShardIdentityInput>): Shardfile {
19
21
  const { edgeSamples, edgeGrey, edgeHeight, requires, entryways, ...rest } =
20
22
  start
21
23
  const edge = {
@@ -31,7 +33,7 @@ function emptyShardfile(identity: Readonly<Shardfile['identity']>): Shardfile {
31
33
  ...rest,
32
34
  version: SHARDFILE_VERSION,
33
35
  identity,
34
- requires: { sdk: SHARDFILE_VERSION, ...requires },
36
+ requires,
35
37
  entryways: entryways.map(
36
38
  (row: Readonly<{ edge: string; at: readonly number[] }>): object =>
37
39
  widened(row),