@wildshard/shard-format 0.70.0 → 0.71.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 (63) 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-deprecations.ts +53 -0
  16. package/src/format/cook-preparation.ts +2 -1
  17. package/src/format/creature-rest-rig.ts +248 -0
  18. package/src/format/creature-skin-bounds.ts +146 -0
  19. package/src/format/deprecations.ts +18 -21
  20. package/src/format/edge-observations.ts +67 -0
  21. package/src/format/empty-shardfile.ts +4 -2
  22. package/src/format/entry-read-set.ts +147 -0
  23. package/src/format/format-migrate-rebuild.ts +4 -1
  24. package/src/format/format-migrate.ts +7 -1
  25. package/src/format/format-migration-envelope.ts +19 -0
  26. package/src/format/format-migration-prune.ts +42 -1
  27. package/src/format/format-migrations.ts +8 -1
  28. package/src/format/format-window.ts +71 -0
  29. package/src/format/immutable.ts +4 -1
  30. package/src/format/json-schema.ts +1468 -0
  31. package/src/format/lootEconomy.ts +4 -1
  32. package/src/format/mat4.ts +225 -0
  33. package/src/format/memory-armed.json +1 -9
  34. package/src/format/memory-armed.ts +46 -17
  35. package/src/format/memory-epoch.ts +10 -3
  36. package/src/format/memory-line.ts +17 -6
  37. package/src/format/outputFields.ts +3 -2
  38. package/src/format/outputIndex.ts +14 -1
  39. package/src/format/platformDataSections.ts +5 -0
  40. package/src/format/platformFileFamilies.ts +3 -3
  41. package/src/format/play-area.ts +95 -0
  42. package/src/format/policy-verdict.ts +12 -2
  43. package/src/format/registeredJson.ts +2 -2
  44. package/src/format/runtime-tier.ts +14 -7
  45. package/src/format/save-revision.ts +105 -0
  46. package/src/format/schema-source.ts +70 -0
  47. package/src/format/sections.ts +4 -1
  48. package/src/format/server-plan.ts +42 -0
  49. package/src/format/server-reads.ts +23 -0
  50. package/src/format/shardSchema.ts +9 -4
  51. package/src/format/shardSections.ts +17 -7
  52. package/src/format/shardfile-assets.ts +5 -5
  53. package/src/format/shardfile-stream-admit.ts +19 -10
  54. package/src/format/shardfile-stream-facts.ts +2 -1
  55. package/src/format/shardfile-stream.ts +2 -3
  56. package/src/format/shardfileValidation.ts +16 -9
  57. package/src/format/species-deprecations.ts +79 -0
  58. package/src/format/stateLineage.ts +12 -6
  59. package/src/format/tread-boxes.ts +65 -0
  60. package/src/format/vehicle-hulls.ts +124 -0
  61. package/src/format/version.ts +74 -17
  62. package/src/format/whole-inputs.ts +51 -0
  63. package/src/tools/runtime-hosts.json +4 -0
@@ -76,7 +76,7 @@ export function parseLootEconomy(input: unknown): LootEconomy {
76
76
  }
77
77
 
78
78
  /** Barter admission keeps cards and transactions in one order, without coin-only ownership fields. */
79
- export const BarterEconomySchema: v.GenericSchema<BarterEconomyInput, BarterEconomy> = v.pipe(v.strictObject({ kind: v.literal('barter'),
79
+ export const BarterEconomySchema: v.GenericSchema<BarterEconomyInput, BarterEconomy> = v.pipe(v.strictObject({ kind: v.literal('barter'), currency: v.exactOptional(currency),
80
80
  goods: v.pipe(v.array(v.strictObject({ id: key, name: text, does: text,
81
81
  icon: v.picklist(['bolt', 'rifle', 'longbow', 'crossbow']), price: count, tile: text })), v.minLength(1), v.maxLength(64)),
82
82
  exchange: ExchangeSchema, tables: LootTablesSchema,
@@ -215,6 +215,8 @@ interface LootEconomyFields {
215
215
  export type LootEconomy = { [Key in keyof LootEconomyFields]: LootEconomyFields[Key] };
216
216
  interface BarterEconomyInputFields {
217
217
  kind: 'barter';
218
+ /** FORMAT-PRUNE FP31: a barter shard names its coin too (Pine). */
219
+ currency?: CurrencyRowsInput;
218
220
  goods: ({
219
221
  id: string;
220
222
  name: string;
@@ -229,6 +231,7 @@ interface BarterEconomyInputFields {
229
231
  export type BarterEconomyInput = { [Key in keyof BarterEconomyInputFields]: BarterEconomyInputFields[Key] };
230
232
  interface BarterEconomyFields {
231
233
  kind: 'barter';
234
+ currency?: CurrencyRows;
232
235
  goods: ({
233
236
  id: string;
234
237
  name: string;
@@ -0,0 +1,225 @@
1
+ /* oxlint-disable capitalized-comments, id-length, import/exports-last, import/group-exports, max-statements, no-magic-numbers, typescript/explicit-function-return-type, typescript/no-unsafe-type-assertion, unicorn/prefer-modern-math-apis -- 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): the 4 x 4 matrix steps the creature rest rig needs, with no renderer. Each is the same
3
+ // arithmetic, in the same order, as three.js 0.186 `Matrix4.determinant`, `Matrix4.invert`, `Matrix4.decompose` and
4
+ // `Quaternion.setFromRotationMatrix` (column-major elements), so a rest joint computed here is bit for bit the one
5
+ // engine computed with three. three.js is MIT licensed (Copyright 2010-2025 three.js authors).
6
+
7
+ /** A column-major 4 x 4 matrix, as glTF and three store it. */
8
+ export type Mat4 = readonly number[]
9
+
10
+ type Sixteen = readonly [
11
+ number,
12
+ number,
13
+ number,
14
+ number,
15
+ number,
16
+ number,
17
+ number,
18
+ number,
19
+ number,
20
+ number,
21
+ number,
22
+ number,
23
+ number,
24
+ number,
25
+ number,
26
+ number,
27
+ ]
28
+
29
+ /** A matrix's translation, unit-free rotation quaternion and axis scales. */
30
+ export interface Decomposed {
31
+ readonly position: readonly [number, number, number]
32
+ readonly quaternion: readonly [number, number, number, number]
33
+ readonly scale: readonly [number, number, number]
34
+ }
35
+
36
+ const QUARTER = 0.25
37
+ const HALF = 0.5
38
+ const TWO = 2
39
+ const SIZE = 16
40
+
41
+ function sixteen(te: Mat4): Sixteen {
42
+ if (te.length !== SIZE) {
43
+ throw new Error('A 4 x 4 matrix has 16 elements')
44
+ }
45
+ return te as Sixteen
46
+ }
47
+
48
+ /** three's `Matrix4.determinant`. */
49
+ export function determinant(te: Mat4): number {
50
+ const [
51
+ n11,
52
+ n21,
53
+ n31,
54
+ n41,
55
+ n12,
56
+ n22,
57
+ n32,
58
+ n42,
59
+ n13,
60
+ n23,
61
+ n33,
62
+ n43,
63
+ n14,
64
+ n24,
65
+ n34,
66
+ n44,
67
+ ] = sixteen(te)
68
+ const t11 = n23 * n34 - n24 * n33
69
+ const t12 = n22 * n34 - n24 * n32
70
+ const t13 = n22 * n33 - n23 * n32
71
+ const t21 = n21 * n34 - n24 * n31
72
+ const t22 = n21 * n33 - n23 * n31
73
+ const t23 = n21 * n32 - n22 * n31
74
+ return (
75
+ n11 * (n42 * t11 - n43 * t12 + n44 * t13) -
76
+ n12 * (n41 * t11 - n43 * t21 + n44 * t22) +
77
+ n13 * (n41 * t12 - n42 * t21 + n44 * t23) -
78
+ n14 * (n41 * t13 - n42 * t22 + n43 * t23)
79
+ )
80
+ }
81
+
82
+ /** three's `Matrix4.invert` intermediate terms t1 to t12. */
83
+ function inverseTerms(te: Sixteen): readonly number[] {
84
+ const [
85
+ n11,
86
+ n21,
87
+ n31,
88
+ n41,
89
+ n12,
90
+ n22,
91
+ n32,
92
+ n42,
93
+ n13,
94
+ n23,
95
+ n33,
96
+ n43,
97
+ n14,
98
+ n24,
99
+ n34,
100
+ n44,
101
+ ] = te
102
+ return [
103
+ n11 * n22 - n21 * n12,
104
+ n11 * n32 - n31 * n12,
105
+ n11 * n42 - n41 * n12,
106
+ n21 * n32 - n31 * n22,
107
+ n21 * n42 - n41 * n22,
108
+ n31 * n42 - n41 * n32,
109
+ n13 * n24 - n23 * n14,
110
+ n13 * n34 - n33 * n14,
111
+ n13 * n44 - n43 * n14,
112
+ n23 * n34 - n33 * n24,
113
+ n23 * n44 - n43 * n24,
114
+ n33 * n44 - n43 * n34,
115
+ ]
116
+ }
117
+
118
+ /** three's `Matrix4.invert`: all zeros for a singular matrix. */
119
+ export function invert(matrix: Mat4): Mat4 {
120
+ const te = sixteen(matrix)
121
+ const [
122
+ n11,
123
+ n21,
124
+ n31,
125
+ n41,
126
+ n12,
127
+ n22,
128
+ n32,
129
+ n42,
130
+ n13,
131
+ n23,
132
+ n33,
133
+ n43,
134
+ n14,
135
+ n24,
136
+ n34,
137
+ n44,
138
+ ] = te
139
+ const [t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12] = inverseTerms(
140
+ te,
141
+ ) as Sixteen
142
+ const det = t1 * t12 - t2 * t11 + t3 * t10 + t4 * t9 - t5 * t8 + t6 * t7
143
+ if (det === 0) {
144
+ return Array.from({ length: SIZE }, () => 0)
145
+ }
146
+ const detInv = 1 / det
147
+ return [
148
+ (n22 * t12 - n32 * t11 + n42 * t10) * detInv,
149
+ (n31 * t11 - n21 * t12 - n41 * t10) * detInv,
150
+ (n24 * t6 - n34 * t5 + n44 * t4) * detInv,
151
+ (n33 * t5 - n23 * t6 - n43 * t4) * detInv,
152
+ (n32 * t9 - n12 * t12 - n42 * t8) * detInv,
153
+ (n11 * t12 - n31 * t9 + n41 * t8) * detInv,
154
+ (n34 * t3 - n14 * t6 - n44 * t2) * detInv,
155
+ (n13 * t6 - n33 * t3 + n43 * t2) * detInv,
156
+ (n12 * t11 - n22 * t9 + n42 * t7) * detInv,
157
+ (n21 * t9 - n11 * t11 - n41 * t7) * detInv,
158
+ (n14 * t5 - n24 * t3 + n44 * t1) * detInv,
159
+ (n23 * t3 - n13 * t5 - n43 * t1) * detInv,
160
+ (n22 * t8 - n12 * t10 - n32 * t7) * detInv,
161
+ (n11 * t10 - n21 * t8 + n31 * t7) * detInv,
162
+ (n24 * t2 - n14 * t4 - n34 * t1) * detInv,
163
+ (n13 * t4 - n23 * t2 + n33 * t1) * detInv,
164
+ ]
165
+ }
166
+
167
+ /** three's `Matrix4.determinantAffine`. */
168
+ function determinantAffine(te: Sixteen): number {
169
+ const [n11, n21, n31, , n12, n22, n32, , n13, n23, n33] = te
170
+ return (
171
+ n11 * (n22 * n33 - n23 * n32) -
172
+ n12 * (n21 * n33 - n23 * n31) +
173
+ n13 * (n21 * n32 - n22 * n31)
174
+ )
175
+ }
176
+
177
+ /** three's `Quaternion.setFromRotationMatrix`, on the scaled-out 3 x 3 (m11 to m33, row by row). */
178
+ function rotationQuaternion(
179
+ m: readonly number[],
180
+ ): readonly [number, number, number, number] {
181
+ const [m11, m12, m13, m21, m22, m23, m31, m32, m33] = m as Sixteen
182
+ const trace = m11 + m22 + m33
183
+ if (trace > 0) {
184
+ const s = HALF / Math.sqrt(trace + 1)
185
+ return [(m32 - m23) * s, (m13 - m31) * s, (m21 - m12) * s, QUARTER / s]
186
+ }
187
+ if (m11 > m22 && m11 > m33) {
188
+ const s = TWO * Math.sqrt(1 + m11 - m22 - m33)
189
+ return [QUARTER * s, (m12 + m21) / s, (m13 + m31) / s, (m32 - m23) / s]
190
+ }
191
+ if (m22 > m33) {
192
+ const s = TWO * Math.sqrt(1 + m22 - m11 - m33)
193
+ return [(m12 + m21) / s, QUARTER * s, (m23 + m32) / s, (m13 - m31) / s]
194
+ }
195
+ const s = TWO * Math.sqrt(1 + m33 - m11 - m22)
196
+ return [(m13 + m31) / s, (m23 + m32) / s, QUARTER * s, (m21 - m12) / s]
197
+ }
198
+
199
+ /** three's `Matrix4.decompose`: position, rotation (x, y, z, w) and scale. */
200
+ export function decompose(matrix: Mat4): Decomposed {
201
+ const te = sixteen(matrix)
202
+ const [a0, a1, a2, , a4, a5, a6, , a8, a9, a10, , px, py, pz] = te
203
+ const position = [px, py, pz] as const
204
+ const det = determinantAffine(te)
205
+ if (det === 0) {
206
+ return { position, quaternion: [0, 0, 0, 1], scale: [1, 1, 1] }
207
+ }
208
+ const length = Math.sqrt(a0 * a0 + a1 * a1 + a2 * a2)
209
+ const sx = det < 0 ? -length : length
210
+ const sy = Math.sqrt(a4 * a4 + a5 * a5 + a6 * a6)
211
+ const sz = Math.sqrt(a8 * a8 + a9 * a9 + a10 * a10)
212
+ const [ix, iy, iz] = [1 / sx, 1 / sy, 1 / sz]
213
+ const rows = [
214
+ a0 * ix,
215
+ a4 * iy,
216
+ a8 * iz,
217
+ a1 * ix,
218
+ a5 * iy,
219
+ a9 * iz,
220
+ a2 * ix,
221
+ a6 * iy,
222
+ a10 * iz,
223
+ ]
224
+ return { position, quaternion: rotationQuaternion(rows), scale: [sx, sy, sz] }
225
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$doc": "J426 (Jake, 2026-11-18): the one armed-zone list. A zone named here has done the work to get under the J410 lines, and from then on every memory gate refuses it back over them, with no override flag and no report-only fallback: the format's offline estimate over lines.playingBytes / lines.loadingBytes (check, validate, cook, upload), the declared worst-location total over the J408 1.5 GB line, the runtime tier and a stale runtime reading; engine's ledger, footprint and boot-line guards read the same list. A zone not named here reports only (J424). Each zone's playingBytes / loadingBytes are its offline estimate when it was armed (memory epoch in `epoch`); the offline estimate refuses over the larger of the line and that reading plus 0.5% (memory-armed.ts ARMED_ALLOWANCE), so a zone EM11 measured under the line whose conservative estimate reads over it (Nine's playing) is locked at its armed state. Decimal bytes. Format memory-armed.ts reads this; engine reads @wildshard/format/src/format/memory-armed.json. CP10 judges a stored original by its stored verdict, so no pinned product is re-judged and nothing is held (FORMAT-PRUNE FP12): the four zones once held (Driftwood, Nalati, Nine Dragon, Pine) are armed again at their epoch-8 readings (SHARD-COMPAT CP10, after Pine r10 and Nalati r5 pinned), and only a new upload over a line is refused. Arming moves to the API catalogue at FP27.",
2
+ "$doc": "J426 (Jake, 2026-11-18): the one armed-zone list. A zone named here has done the work to get under the J410 lines, and from then on every memory gate refuses it back over them, with no override flag and no report-only fallback: the format's offline estimate over lines.playingBytes / lines.loadingBytes (check, validate, cook, upload), the declared worst-location total over the J408 1.5 GB line, the runtime tier and a stale runtime reading; engine's ledger, footprint and boot-line guards read the same list. A zone not named here reports only (J424). Each zone's playingBytes / loadingBytes are its offline estimate when it was armed (memory epoch in `epoch`); the offline estimate refuses over the larger of the line and that reading plus 0.5% (memory-armed.ts ARMED_ALLOWANCE), so a zone EM11 measured under the line whose conservative estimate reads over it (Nine's playing) is locked at its armed state. Decimal bytes. Format memory-armed.ts reads this; engine reads @wildshard/format/src/format/memory-armed.json. CP10 judges a stored original by its stored verdict, so no pinned product is re-judged and nothing is held (FORMAT-PRUNE FP12): the four zones once held (Driftwood, Nalati, Nine Dragon, Pine) are armed again at their epoch-8 readings (SHARD-COMPAT CP10, after Pine r10 and Nalati r5 pinned), and only a new upload over a line is refused. Nine Dragon is held again (SHARD-COMPAT SM4, 2026-11-22): its main source reads 1,963.9 MB loading offline (runtime, commons and boot included) against the 1.5 GB ceiling, so its next upload would be refused; it reports only (J424) until its source is under the line, then re-arms. Arming moves to the API catalogue at FP27.",
3
3
  "lines": {
4
4
  "playingBytes": 1000000000,
5
5
  "loadingBytes": 1500000000
@@ -197,14 +197,6 @@
197
197
  "loadingBytes": 1328901899,
198
198
  "evidence": "shard-nalati 1d5014e8 built with format 0.37 (epoch 8); mini-resweep EM11 upper on the J420 stand-in: playing 0.940 GB less the worker, loading 1.470 GB (meta MEMORY-GATES); re-armed 2026-11-21 by SHARD-COMPAT CP10 (J486): engine pins and cooks validate judged stored, so an older pinned product is never re-judged"
199
199
  },
200
- "nine-dragon-stack": {
201
- "armed": "2026-11-18",
202
- "by": "mini-pinemem5",
203
- "epoch": 8,
204
- "playingBytes": 1023504847,
205
- "loadingBytes": 1434692360,
206
- "evidence": "shard-nine-dragon 8779b872 built with format 0.37 (epoch 8); mini-pinemem6 prepared online boot on engine d0fd6e62, 9 pairs: playing upper 0.938 GB, loading upper 1.435 GB (meta 1677f091). The estimate's playing (1,023.5 MB) is over the 1.0 GB line, so it locks at that reading; re-armed 2026-11-21 by SHARD-COMPAT CP10 (J486): engine pins and cooks validate judged stored, so an older pinned product is never re-judged"
207
- },
208
200
  "pine-hollow": {
209
201
  "armed": "2026-11-18",
210
202
  "by": "mini-pinemem5",
@@ -13,6 +13,33 @@ interface ArmedZone {
13
13
 
14
14
  type ArmedKind = 'playing' | 'loading'
15
15
 
16
+ /** FORMAT-PRUNE FP27b: the zone a memory gate judges. Admission passes the API catalogue's `armed` beside the slug
17
+ * (`{ slug, armed }`); a bare slug still reads the format's own `zones` list until FP27c removes it. */
18
+ type ZoneRef =
19
+ | string
20
+ | undefined
21
+ | Readonly<{ slug?: string | undefined; armed: boolean }>
22
+
23
+ /** The zone as a gate takes it: the catalogue's word when admission gave one (this shard's, or the catalogue's armed
24
+ * slugs when the host reads the slug only from the file), else the bare slug. */
25
+ function armedZone(
26
+ slug: string | undefined,
27
+ catalogue?: boolean | ReadonlySet<string>,
28
+ ): ZoneRef {
29
+ if (catalogue === undefined) {
30
+ return slug
31
+ }
32
+ const word =
33
+ typeof catalogue === 'boolean'
34
+ ? catalogue
35
+ : slug !== undefined && catalogue.has(slug)
36
+ return { slug, armed: word }
37
+ }
38
+
39
+ function slugOf(zone: ZoneRef): string | undefined {
40
+ return typeof zone === 'object' ? zone.slug : zone
41
+ }
42
+
16
43
  const ARMED_LINES: Readonly<Record<ArmedKind, number>> = Object.freeze({
17
44
  playing: armed.lines.playingBytes,
18
45
  loading: armed.lines.loadingBytes,
@@ -24,54 +51,54 @@ const ARMED_ZONES: Readonly<Record<string, ArmedZone>> = Object.freeze(
24
51
 
25
52
  /** J424 (QA 11-18 row 29): a zone armed once but held out of `ARMED_ZONES` while engine pins an older product of it
26
53
  * that reads over its line. It reports only; it moves back to `zones` (re-armed) when its engine re-pin lands. */
27
- /** True when `slug` is in the armed list (J426). */
28
- function zoneArmed(slug?: string): boolean {
29
- return slug !== undefined && Object.hasOwn(ARMED_ZONES, slug)
54
+ /** True when the zone is armed (J426): the catalogue's word when admission passed it, else the format's list. */
55
+ function zoneArmed(zone?: ZoneRef): boolean {
56
+ if (typeof zone === 'object') {
57
+ return zone.armed
58
+ }
59
+ return zone !== undefined && Object.hasOwn(ARMED_ZONES, zone)
30
60
  }
31
61
 
32
62
  /** The common lines for an armed zone. A revision's own reading is evidence,
33
63
  * while the offline decision uses the shared target or ceiling (J445). */
34
- function armedLine(
35
- slug: string | undefined,
36
- kind: ArmedKind,
37
- ): number | undefined {
38
- return zoneArmed(slug) ? ARMED_LINES[kind] : undefined
64
+ function armedLine(zone: ZoneRef, kind: ArmedKind): number | undefined {
65
+ return zoneArmed(zone) ? ARMED_LINES[kind] : undefined
39
66
  }
40
67
 
41
68
  type RatchetMetric = 'playing' | 'loading' | 'runtime'
42
69
 
43
70
  /** J445: only the common loading ceiling can refuse an armed shard. Playing and runtime tier overages are reported. */
44
71
  function ratchetLimit(
45
- slug: string | undefined,
72
+ zone: ZoneRef,
46
73
  metric: RatchetMetric,
47
74
  line: number,
48
75
  ): number {
49
- return metric === 'loading' && zoneArmed(slug)
76
+ return metric === 'loading' && zoneArmed(zone)
50
77
  ? line
51
78
  : Number.POSITIVE_INFINITY
52
79
  }
53
80
 
54
81
  /** Describe the offline decision for a measured overage. */
55
82
  function ratchetSeverity(
56
- slug: string | undefined,
83
+ zone: ZoneRef,
57
84
  metric: RatchetMetric,
58
85
  reading: Readonly<{ line: number; actual: number }>,
59
86
  ): 'refusal' | 'warning' {
60
- return reading.actual > ratchetLimit(slug, metric, reading.line)
87
+ return reading.actual > ratchetLimit(zone, metric, reading.line)
61
88
  ? 'refusal'
62
89
  : 'warning'
63
90
  }
64
91
 
65
92
  /** The words a reported (not refused) issue carries: why it only reports (J424). */
66
- function ratchetNote(slug: string | undefined): string {
67
- return zoneArmed(slug)
93
+ function ratchetNote(zone: ZoneRef): string {
94
+ return zoneArmed(zone)
68
95
  ? ''
69
- : ` (report-only, J424: ${slug ?? 'this shard'} is not armed)`
96
+ : ` (report-only, J424: ${slugOf(zone) ?? 'this shard'} is not armed)`
70
97
  }
71
98
 
72
99
  /** True when a stale runtime reading only reports: J424, every zone not armed (J426). */
73
- function staleReadingAdmitted(slug: string | undefined): boolean {
74
- return !zoneArmed(slug)
100
+ function staleReadingAdmitted(zone: ZoneRef): boolean {
101
+ return !zoneArmed(zone)
75
102
  }
76
103
 
77
104
  export {
@@ -79,7 +106,9 @@ export {
79
106
  ARMED_ZONES,
80
107
  type ArmedKind,
81
108
  type ArmedZone,
109
+ type ZoneRef,
82
110
  armedLine,
111
+ armedZone,
83
112
  type RatchetMetric,
84
113
  ratchetLimit,
85
114
  ratchetNote,
@@ -1,4 +1,4 @@
1
- import { staleReadingAdmitted } from './memory-armed.ts'
1
+ import { armedZone, staleReadingAdmitted } from './memory-armed.ts'
2
2
 
3
3
  /** MEMORY-GATES MG5 (J408, Jake 2026-11-17: "a stale runtimeCost is refused"): the memory model a runtime home's
4
4
  * `runtimeCost` reading must have been taken against. It rises when the model changes what it charges (MG6 adds shader
@@ -44,9 +44,16 @@ function staleRuntimeCost(
44
44
  function staleRuntimeIssues(
45
45
  runtime: Readonly<{ cost?: EpochRow | undefined }> | null,
46
46
  current: number = OLDEST_CURRENT_EPOCH,
47
- identity?: Readonly<{ slug: string; revision: number }>,
47
+ identity?: Readonly<{
48
+ slug: string
49
+ saveRevision: number
50
+ /** FP27b: the API catalogue's armed state; absent, the format's own list decides. */
51
+ armed?: boolean | ReadonlySet<string> | undefined
52
+ }>,
48
53
  ): StaleRuntimeIssue[] {
49
- const admitted = staleReadingAdmitted(identity?.slug)
54
+ const admitted = staleReadingAdmitted(
55
+ armedZone(identity?.slug, identity?.armed),
56
+ )
50
57
  const rows: EpochRow[] = []
51
58
  const cost = runtime === null ? undefined : runtime.cost
52
59
  if (cost !== undefined) {
@@ -2,9 +2,15 @@ import { parse } from 'valibot'
2
2
 
3
3
  import { bootMemoryCosts } from './boot-memory-cost.ts'
4
4
  import { worstContentCost } from './budget.ts'
5
- import { ARMED_LINES, ratchetNote, ratchetSeverity } from './memory-armed.ts'
5
+ import {
6
+ ARMED_LINES,
7
+ armedZone,
8
+ ratchetNote,
9
+ ratchetSeverity,
10
+ } from './memory-armed.ts'
6
11
  import { runtimeAccountedBytes, RuntimeCostSchema } from './runtimeCost.ts'
7
12
 
13
+ import type { ZoneRef } from './memory-armed.ts'
8
14
  import type { TierIndex } from './phone-files.ts'
9
15
  import type { Shardfile } from './shardSchema.ts'
10
16
 
@@ -27,7 +33,7 @@ function overHardLine(bytes: number): string {
27
33
  function hardLineIssue(
28
34
  kind: 'playing' | 'loading',
29
35
  bytes: number,
30
- zone?: string | Readonly<{ slug: string; line: number }>,
36
+ zone?: ZoneRef | Readonly<{ slug: string; line: number }>,
31
37
  ): {
32
38
  readonly code: 'perf-playing-memory' | 'perf-loading-memory'
33
39
  readonly metric: string
@@ -36,7 +42,9 @@ function hardLineIssue(
36
42
  readonly severity: 'refusal' | 'warning'
37
43
  } {
38
44
  const { slug, line } =
39
- typeof zone === 'object' ? zone : { slug: zone, line: ARMED_LINES[kind] }
45
+ typeof zone === 'object' && 'line' in zone
46
+ ? zone
47
+ : { slug: zone, line: ARMED_LINES[kind] }
40
48
  const severity = ratchetSeverity(slug, kind, { line, actual: bytes })
41
49
  const over =
42
50
  kind === 'playing'
@@ -54,7 +62,7 @@ function hardLineIssue(
54
62
  /** The offline memory thresholds apply equally to a build and its report. */
55
63
  function memoryLineIssues(
56
64
  cost: Readonly<Record<'playing' | 'loading', number>>,
57
- slug: string,
65
+ slug: ZoneRef,
58
66
  ): ReturnType<typeof hardLineIssue>[] {
59
67
  return (['playing', 'loading'] as const)
60
68
  .filter((kind): boolean => cost[kind] > ARMED_LINES[kind])
@@ -87,6 +95,8 @@ type MemoryContext =
87
95
  mountedImages: number
88
96
  index?: TierIndex
89
97
  judged?: 'upload' | 'stored'
98
+ /** FP27b: the API catalogue's armed state for this shard; absent, the format's own list decides. */
99
+ armed?: boolean | ReadonlySet<string> | undefined
90
100
  }>
91
101
 
92
102
  function memoryContext(context: MemoryContext): Readonly<{
@@ -94,6 +104,7 @@ function memoryContext(context: MemoryContext): Readonly<{
94
104
  mountedImages: number
95
105
  index?: TierIndex
96
106
  judged?: 'upload' | 'stored'
107
+ armed?: boolean | ReadonlySet<string> | undefined
97
108
  }> {
98
109
  return context instanceof Map
99
110
  ? { sections: context, mountedImages: EMPTY_BYTES }
@@ -111,7 +122,7 @@ function offlineMemoryIssues(
111
122
  source: Shardfile,
112
123
  context: MemoryContext,
113
124
  ): ReturnType<typeof hardLineIssue>[] {
114
- const { sections, mountedImages, index } = memoryContext(context)
125
+ const { sections, mountedImages, index, armed } = memoryContext(context)
115
126
  const native = source.runtime?.cost
116
127
  const runtime =
117
128
  native === undefined ? EMPTY_BYTES : runtimeOfflineBytes(native)
@@ -123,7 +134,7 @@ function offlineMemoryIssues(
123
134
  commons: runtime + commons,
124
135
  boot: bootMemoryCosts(source, sections, { mountedImages, index }),
125
136
  })
126
- return memoryLineIssues(cost, source.identity.slug)
137
+ return memoryLineIssues(cost, armedZone(source.identity.slug, armed))
127
138
  }
128
139
 
129
140
  export {
@@ -7,10 +7,10 @@ import { shardfileFormatOf } from './version.ts';
7
7
  export interface SectionMapping { readonly name: PlatformSectionName; readonly fields: readonly (keyof Shardfile)[]; readonly row?: keyof Shardfile['rows']; readonly spawns?: true; }
8
8
  /** Root-key envelopes preserve optional-field absence and every existing host's values. */
9
9
  const ROW_SECTION_NAMES: { readonly species: 'actors/species'; readonly strikes: 'combat/strikes'; readonly loot: 'economy/loot'; readonly days: 'world/days'; readonly weather: 'world/weather'; readonly looks: 'look/materials'; readonly compendiums: 'ui/compendium'; } = {species:'actors/species',strikes:'combat/strikes',loot:'economy/loot',days:'world/days',weather:'world/weather',looks:'look/materials',compendiums:'ui/compendium'} as const;
10
- const OUTPUT_SECTION_FIELDS: readonly [{ readonly name: "world/tiles"; readonly fields: readonly ["tiles", "far", "near", "ring"]; }, { readonly name: "world/terrain"; readonly fields: readonly ["terrain", "nativeGround"]; }, { readonly name: "world/edge"; readonly fields: readonly ["edge", "entryways"]; }, { readonly name: "world/collision"; readonly fields: readonly ["meshCollision"]; }, { readonly name: "world/navigation"; readonly fields: readonly ["navigation"]; }, { readonly name: "world/props"; readonly fields: readonly ["props"]; }, { readonly name: "world/water"; readonly fields: readonly ["water"]; }, { readonly name: "world/movers"; readonly fields: readonly ["movers"]; }, { readonly name: "world/traversal"; readonly fields: readonly ["traversal"]; }, { readonly name: "world/spawn"; readonly fields: readonly ["spawn"]; }, { readonly name: "look/look"; readonly fields: readonly ["look", "presentation"]; }, { readonly name: "look/map"; readonly fields: readonly ["map"]; }, { readonly name: "actors/creatures"; readonly fields: readonly ["creatures"]; }, { readonly name: "actors/crowds"; readonly fields: readonly ["crowds"]; }, { readonly name: "actors/npcs"; readonly fields: readonly ["questNpcs"]; }, { readonly name: "actors/spawns"; readonly fields: readonly []; readonly spawns: true; }, { readonly name: "combat/items"; readonly fields: readonly ["items"]; }, { readonly name: "combat/encounters"; readonly fields: readonly ["encounters"]; }, { readonly name: "quests/quests"; readonly fields: readonly ["quests"]; }, { readonly name: "quests/host"; readonly fields: readonly ["questHost"]; }, { readonly name: "quests/directors"; readonly fields: readonly ["directors"]; }, { readonly name: "economy/ledger"; readonly fields: readonly ["ledger"]; }, { readonly name: "state/state"; readonly fields: readonly ["state"]; }, { readonly name: "state/migrations"; readonly fields: readonly ["migrations"]; }, { readonly name: "state/modes"; readonly fields: readonly ["modes"]; }, { readonly name: "sim/sim"; readonly fields: readonly ["sim"]; }, { readonly name: "sim/hooks"; readonly fields: readonly ["hooks"]; }, { readonly name: "sim/client-scripts"; readonly fields: readonly ["clientScripts"]; }, { readonly name: "sim/client-channels"; readonly fields: readonly ["clientChannels"]; }, { readonly name: "sim/plumbing"; readonly fields: readonly ["plumbing"]; }, { readonly name: "audio/audio"; readonly fields: readonly ["audio"]; }, { readonly name: "ui/card"; readonly fields: readonly ["accent"]; }, { readonly name: "ui/level"; readonly fields: readonly ["manifest"]; }, { readonly name: "ui/ui"; readonly fields: readonly ["ui", "targets"]; }, ...{ name: "world/days" | "world/weather" | "look/materials" | "actors/species" | "combat/strikes" | "economy/loot" | "ui/compendium"; fields: never[]; row: "species" | "strikes" | "loot" | "days" | "weather" | "looks" | "compendiums"; }[]] = [
10
+ const OUTPUT_SECTION_FIELDS: readonly [{ readonly name: "world/tiles"; readonly fields: readonly ["tiles", "far", "near", "ring"]; }, { readonly name: "world/terrain"; readonly fields: readonly ["terrain", "nativeGround"]; }, { readonly name: "world/edge"; readonly fields: readonly ["edge", "entryways", "edgeObservations"]; }, { readonly name: "world/collision"; readonly fields: readonly ["meshCollision"]; }, { readonly name: "world/navigation"; readonly fields: readonly ["navigation"]; }, { readonly name: "world/props"; readonly fields: readonly ["props"]; }, { readonly name: "world/water"; readonly fields: readonly ["water"]; }, { readonly name: "world/movers"; readonly fields: readonly ["movers"]; }, { readonly name: "world/traversal"; readonly fields: readonly ["traversal"]; }, { readonly name: "world/spawn"; readonly fields: readonly ["spawn"]; }, { readonly name: "look/look"; readonly fields: readonly ["look", "presentation"]; }, { readonly name: "look/map"; readonly fields: readonly ["map"]; }, { readonly name: "actors/creatures"; readonly fields: readonly ["creatures"]; }, { readonly name: "actors/crowds"; readonly fields: readonly ["crowds"]; }, { readonly name: "actors/npcs"; readonly fields: readonly ["questNpcs"]; }, { readonly name: "actors/spawns"; readonly fields: readonly []; readonly spawns: true; }, { readonly name: "combat/items"; readonly fields: readonly ["items"]; }, { readonly name: "combat/encounters"; readonly fields: readonly ["encounters"]; }, { readonly name: "quests/quests"; readonly fields: readonly ["quests"]; }, { readonly name: "quests/host"; readonly fields: readonly ["questHost"]; }, { readonly name: "quests/directors"; readonly fields: readonly ["directors"]; }, { readonly name: "economy/ledger"; readonly fields: readonly ["ledger"]; }, { readonly name: "state/state"; readonly fields: readonly ["state"]; }, { readonly name: "state/migrations"; readonly fields: readonly ["migrations"]; }, { readonly name: "state/modes"; readonly fields: readonly ["modes"]; }, { readonly name: "sim/sim"; readonly fields: readonly ["sim"]; }, { readonly name: "sim/hooks"; readonly fields: readonly ["hooks"]; }, { readonly name: "sim/client-scripts"; readonly fields: readonly ["clientScripts"]; }, { readonly name: "sim/client-channels"; readonly fields: readonly ["clientChannels"]; }, { readonly name: "sim/plumbing"; readonly fields: readonly ["plumbing"]; }, { readonly name: "audio/audio"; readonly fields: readonly ["audio"]; }, { readonly name: "ui/card"; readonly fields: readonly ["accent"]; }, { readonly name: "ui/level"; readonly fields: readonly ["manifest"]; }, { readonly name: "ui/ui"; readonly fields: readonly ["ui", "targets"]; }, ...{ name: "world/days" | "world/weather" | "look/materials" | "actors/species" | "combat/strikes" | "economy/loot" | "ui/compendium"; fields: never[]; row: "species" | "strikes" | "loot" | "days" | "weather" | "looks" | "compendiums"; }[]] = [
11
11
  {name:'world/tiles',fields:['tiles','far','near','ring']},
12
12
  {name:'world/terrain',fields:['terrain','nativeGround']},
13
- {name:'world/edge',fields:['edge','entryways']},
13
+ {name:'world/edge',fields:['edge','entryways','edgeObservations']},
14
14
  {name:'world/collision',fields:['meshCollision']},
15
15
  {name:'world/navigation',fields:['navigation']},
16
16
  {name:'world/props',fields:['props']},
@@ -60,6 +60,7 @@ const DATA_SECTION_NAMES: Readonly<Record<keyof PlatformDataSections, true>> = {
60
60
  "look/colour-functions": true,
61
61
  "look/keyed-sky": true,
62
62
  "client/plan": true,
63
+ "server/plan": true,
63
64
  "view/modules": true,
64
65
  "held/arms": true,
65
66
  "held/gear": true,
@@ -10,13 +10,14 @@ import type { AudioWaiver } from './audio-waiver.ts';
10
10
  import { isOutputIndex, outputBlobPath } from './outputAddress.ts';
11
11
  import { OUTPUT_SECTIONS, assembleOutputTransport, isPlatformDataSection, type OutputHostSectionName } from './outputFields.ts';
12
12
  import * as v from 'valibot';
13
+ import { assertFormatWindow } from './format-window.ts';
13
14
  import { assertCellBounds } from './cellBounds.ts';
14
15
  import { ShardfileFieldSchemas, parseShardfile, type Shardfile } from './shardSchema.ts';
15
16
  import { ClientPlanRuntimeSchema } from './runtime.ts';
16
17
  import { RuntimeSpawnsSchema } from './runtimeSpawns.ts';
17
18
  import { RowsSchema } from './rows.ts';
18
19
  import { ShardHashSchema, ShardNaturalSchema, IdentitySchema, RequiresSchema, FilesSchema, type ShardIdentityInput, type ShardRequiresInput, type ShardReferencesInput, type ShardIdentity, type ShardRequires, type ShardReferences } from './shardSections.ts';
19
- import { LEGACY_LAYOUT, writesPreparationMarker } from './version.ts';
20
+ import { LEGACY_LAYOUT, writesPreparationMarker, writesSaveRevision } from './version.ts';
20
21
  import { IndexFormatVersionSchema, LegacyIndexVersionSchema } from './index-format-version.ts';
21
22
  import type { IndexFormatVersion, LegacyIndexVersion } from './version.ts';
22
23
  import type { PreparationSpec } from './preparation-spec.ts';
@@ -70,6 +71,7 @@ export type OutputPlatformSectionName = OutputHostSectionName | keyof typeof OUT
70
71
  /** Parse the supported major and refuse duplicate, escaping or noncanonical inventory paths. */
71
72
  export function parseOutputIndex(input: unknown): OutputIndex {
72
73
  if (!isJsonDataWithFileSchemas(input)) throw new Error('Output index must contain plain JSON only');
74
+ assertFormatWindow(input);
73
75
  return parseOutputIndexRows(input);
74
76
  }
75
77
  /** Check plain data before detecting the disk envelope; legacy models return null.
@@ -118,9 +120,20 @@ function checkIndexEnvelope(index: OutputIndex): void {
118
120
  throw new Error(`Legacy shard.json (formatVersion 2) needs ${missing.join(', ')}`);
119
121
  }
120
122
  }
123
+ /** FP26: 0.1.0.4 on spells the save lineage `identity.saveRevision`; below it, `identity.revision` (or `saveRevision` when
124
+ * an already parsed index is read again). */
125
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot output, only read
126
+ function checkSaveRevisionSpelling(input: unknown, index: OutputIndex): void {
127
+ const identity: unknown = typeof input === 'object' && input !== null ? Reflect.get(input, 'identity') : undefined;
128
+ const spelled = typeof identity === 'object' && identity !== null && Object.hasOwn(identity, 'saveRevision') ? 'saveRevision' : 'revision';
129
+ const version = index.formatVersion === LEGACY_LAYOUT ? undefined : index.formatVersion;
130
+ // Only the old spelling in a new format refuses: a parsed index (any version) already reads back as `saveRevision`.
131
+ if (spelled === 'revision' && version !== undefined && writesSaveRevision(version)) { throw new Error(`Format ${version} names the save lineage identity.saveRevision (shard.json)`); }
132
+ }
121
133
  function parseOutputIndexRows(input: unknown): OutputIndex {
122
134
  const index = v.parse(OutputIndexSchema, input);
123
135
  checkIndexEnvelope(index);
136
+ checkSaveRevisionSpelling(input, index);
124
137
  const prepared = preparationSpecOf(index) !== undefined;
125
138
  if (prepared && index.cook === undefined) { throw new Error(`Missing cook preparation: run wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`); }
126
139
  if (prepared && index.cook !== undefined && index.cook.bytes > MAX_COOK_BYTES) { throw new Error('Cook preparation exceeds byte cap'); }
@@ -10,6 +10,8 @@ import { ExplorerCatalogueSchema, type ExplorerCatalogue } from './explorerCatal
10
10
  import { ToonLookSchema, type ToonLookRow } from './toonLook.ts';
11
11
  import { KEYED_SKY, type KeyedSkyStyle } from './keyedSky.ts';
12
12
  import { ClientPlanSchema, type ClientPlan } from './clientPlan.ts';
13
+ import { ServerPlanSchema } from './server-plan.ts';
14
+ import type { ServerPlan } from './server-plan.ts';
13
15
  import { SpawnScriptsSchema, type SpawnScriptRows } from './spawnScripts.ts';
14
16
  import { WorldScenesSchema, type WorldScenesSection } from './worldScenes.ts';
15
17
  import { HeldArmsSchema, type HeldArmsRows } from './heldArms.ts';
@@ -50,6 +52,8 @@ export interface PlatformDataSections {
50
52
  'look/colour-functions': ColourFunctionBook;
51
53
  'look/keyed-sky': KeyedSkyStyle;
52
54
  'client/plan': ClientPlan;
55
+ /** SHARD-COMPAT HS6b: the server's own copy of the feature rows, so `client/plan` stays the page's. */
56
+ 'server/plan': ServerPlan;
53
57
  'view/modules': ViewModuleRow[];
54
58
  'held/arms': HeldArmsRows;
55
59
  'held/gear': HeldGearRows;
@@ -89,6 +93,7 @@ export const PLATFORM_DATA_SECTIONS: Readonly<{ [Name in keyof PlatformDataSecti
89
93
  'look/colour-functions': { schema: ColourFunctionBookSchema },
90
94
  'look/keyed-sky': { schema: KEYED_SKY },
91
95
  'client/plan': { schema: ClientPlanSchema },
96
+ 'server/plan': { schema: ServerPlanSchema },
92
97
  'view/modules': { schema: ViewModulesSchema },
93
98
  'held/arms': { schema: HeldArmsSchema },
94
99
  'held/gear': { schema: HeldGearSchema },
@@ -8,6 +8,7 @@ import { HeldJianDocumentSchema } from './heldJianDocument.ts';
8
8
  import { BladeDocumentSchema, PolearmDocumentSchema, HeldSlotsDocumentSchema } from './heldWeaponDocuments.ts';
9
9
  import { HeldBowFileSchema, HeldFirearmPageSchema } from './weaponProfiles.ts';
10
10
  import { WaterWorldSchema } from './waterWorld.ts';
11
+ import { currentSchemaSource } from './schema-source.ts';
11
12
  import { ForestNativeInputsSchema } from './forestNativeInputs.ts';
12
13
  import { CaveFileSchema, CaveInteriorSchema } from './caveInterior.ts';
13
14
  import { ForestGroundLayoutSchema, ForestPageSchema, LivingPageSitesSchema } from './forestPage.ts';
@@ -224,9 +225,8 @@ export const PLATFORM_FILE_FAMILIES: readonly PlatformFileFamily[] = [
224
225
  source: '@wildshard/format/questInteractions#QuestPageInteractionsSchema', reader: 'src/game/quest/pageComposition.ts' },
225
226
  { pattern: /^quests\/services\.json$/u, schema: QuestServiceActionsSchema,
226
227
  source: '@wildshard/format/questSteps#QuestServiceActionsSchema', reader: 'src/game/quest/effects.ts' },
227
- // SA23: the source string is shard file data (each file's `jsonSchema.$comment`), so it keeps the old module name.
228
228
  { pattern: /^directors\/main\.json$/u, schema: DirectorDocumentSchema,
229
- source: '@wildshard/format/directorProduct#DirectorProductSchema', reader: 'src/game/plugin/director.ts' },
229
+ source: '@wildshard/format/directorDocument#DirectorDocumentSchema', reader: 'src/game/plugin/director.ts' },
230
230
  { pattern: /^quests\/panels\.json$/u, schema: QuestPanelCatalogueSchema,
231
231
  source: '@wildshard/format/panelTemplate#QuestPanelCatalogueSchema', reader: 'src/game/ui/dataPanels.ts' },
232
232
  { pattern: /^world\/forest-weather\.json$/u, schema: ForestWeatherSchema,
@@ -283,7 +283,7 @@ export const PLATFORM_FILE_FAMILIES: readonly PlatformFileFamily[] = [
283
283
  /** Match both logical name and defining schema identity. An unregistered or
284
284
  * differently typed named JSON remains custom, even under a shared prefix. */
285
285
  export function platformFileFamily(name: string, schemaSource: string | undefined): PlatformFileFamily | undefined {
286
- const matches = PLATFORM_FILE_FAMILIES.filter(family => family.source === schemaSource && family.pattern.test(name));
286
+ const matches = PLATFORM_FILE_FAMILIES.filter(family => family.source === currentSchemaSource(schemaSource) && family.pattern.test(name));
287
287
  if (matches.length > 1) throw new Error(`Ambiguous platform file family: ${name}`);
288
288
  return matches[0];
289
289
  }