@wildshard/shard-format 0.75.0 → 0.76.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.75.0",
3
+ "version": "0.76.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": {
@@ -124,6 +124,7 @@
124
124
  "./fur-strands": "./src/format/fur-strands.ts",
125
125
  "./scene-render": "./src/format/scene-render.ts",
126
126
  "./look-level": "./src/format/look-level.ts",
127
+ "./engine-floor": "./src/format/engine-floor.ts",
127
128
  "./level-start": "./src/format/level-start.ts",
128
129
  "./level-start-rows": "./src/format/level-start-rows.ts",
129
130
  "./look-sky": "./src/format/look-sky.ts",
@@ -3,7 +3,11 @@
3
3
  * both validators warn on it and the corpus counts its kept users (`shard-format corpus`). A path with a migration is
4
4
  * mended by the chain; one without is deleted once no kept file uses it. */
5
5
  import { COOK_DEPRECATIONS } from './cook-deprecations.ts'
6
- import { MANIFEST_MOVED_DEPRECATIONS } from './manifest-deprecations.ts'
6
+ import {
7
+ LEVEL_DEPRECATIONS,
8
+ MANIFEST_MOVED_DEPRECATIONS,
9
+ MAP_IMAGE_DEPRECATION,
10
+ } from './manifest-deprecations.ts'
7
11
  import { SAVE_REVISION_DEPRECATION } from './save-revision.ts'
8
12
  import { SCHEMA_SOURCE_DEPRECATION } from './schema-source.ts'
9
13
  import {
@@ -157,6 +161,8 @@ const RULES: readonly DeprecationRule[] = [
157
161
  ) !== undefined,
158
162
  },
159
163
  ...MANIFEST_MOVED_DEPRECATIONS,
164
+ ...LEVEL_DEPRECATIONS,
165
+ MAP_IMAGE_DEPRECATION,
160
166
  {
161
167
  id: 'runtime.trust',
162
168
  path: 'shard.json runtime.trust',
@@ -0,0 +1,68 @@
1
+ import { maxLength, pipe, regex, string } from 'valibot'
2
+
3
+ import type { GenericSchema } from 'valibot'
4
+
5
+ // FORMAT-PRUNE FP47b (coordinator, 2026-11-24, J505): a product names the lowest engine release that can draw it
6
+ // (`requires.engine`, from format 0.1.0.6). The SDK stamps the engine release it builds against; the cook, a pin and a
7
+ // grid's admission refuse a product whose floor is above the engine they run, so a product built for a newer engine
8
+ // never lands on an older grid. An older engine's format has no such word and refuses the product outright.
9
+
10
+ const RELEASE = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u
11
+ /** A running engine's version: a release, or a release's prerelease or build (`0.1.83-next.839c8ba0`). */
12
+ const RUNNING =
13
+ /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:[-+][0-9A-Za-z.-]+)?$/u
14
+ const MAX_RELEASE = 32
15
+ const SAME = 0
16
+
17
+ /** An engine release, `X.Y.Z`. */
18
+ const EngineReleaseSchema: GenericSchema<string, string> = pipe(
19
+ string(),
20
+ maxLength(MAX_RELEASE),
21
+ regex(RELEASE),
22
+ )
23
+
24
+ /** A version's release numbers; a prerelease of `X.Y.Z` (an engine `next` build) counts as `X.Y.Z`. */
25
+ function releaseParts(version: string): readonly number[] | undefined {
26
+ const groups = RUNNING.exec(version)?.groups
27
+ return groups === undefined
28
+ ? undefined
29
+ : [groups['major'], groups['minor'], groups['patch']].map(Number)
30
+ }
31
+
32
+ /** Positive when `left` is the newer release. */
33
+ function compareReleases(
34
+ left: readonly number[],
35
+ right: readonly number[],
36
+ ): number {
37
+ const differs = left.findIndex(
38
+ (part: number, index: number): boolean => part !== right[index],
39
+ )
40
+ return differs < SAME
41
+ ? SAME
42
+ : (left[differs] ?? SAME) - (right[differs] ?? SAME)
43
+ }
44
+
45
+ /**
46
+ * Why an engine running `running` refuses a product whose floor is `required`, or undefined when it may draw it (no
47
+ * floor, or a floor at or below it). An unreadable running version refuses any floor.
48
+ */
49
+ function engineFloorRefusal(
50
+ required: string | undefined,
51
+ running: string,
52
+ ): string | undefined {
53
+ if (required === undefined) {
54
+ return undefined
55
+ }
56
+ const need = releaseParts(required)
57
+ const have = releaseParts(running)
58
+ if (
59
+ need !== undefined &&
60
+ have !== undefined &&
61
+ compareReleases(have, need) >= SAME
62
+ ) {
63
+ return undefined
64
+ }
65
+ return `This shard needs engine ${required} or newer; this engine is ${running} (requires.engine)`
66
+ }
67
+
68
+ export { EngineReleaseSchema, engineFloorRefusal }
@@ -0,0 +1,183 @@
1
+ // oxlint-disable typescript/prefer-readonly-parameter-types -- a step edits the shard it is handed, in place
2
+ /** FORMAT-PRUNE FP34 (J486; ONE-FORMAT OF9b5a): format 0.1.0.6 takes the moved words out of the level manifest. The
3
+ * page-start words move into their sections as `liftLevelStart` moves them at the door (a section's own value wins):
4
+ * `spawn` into `world/spawn` when the shard never set one, `loadout` into `combat/items`' `loadout.level`, `audio` into
5
+ * `audio/audio`'s `level`. `weapon` has no reader (`combat/items` arms the player) and leaves. The herd fields
6
+ * (`species`, `spawns`, `faunaTuning`) became declared rows in the build (OF9b4), which a copy of the file can't redo, so
7
+ * they leave too: a file that still needs them is rebuilt on SDK 0.4.25 or later. */
8
+ import { DEFAULT_SPAWN } from './level-start.ts'
9
+ import {
10
+ LEVEL_WORDS,
11
+ NO_LEVEL_WORDS,
12
+ isDiscoveryMount,
13
+ } from './manifest-deprecations.ts'
14
+
15
+ import type { FormatMigration, MigratingShard } from './format-migrations.ts'
16
+
17
+ type JsonRecord = Record<string, unknown>
18
+
19
+ const MANIFEST_WORDS_GONE = '0.1.0.6'
20
+ const MOVED_WORDS: readonly string[] = [
21
+ 'spawn',
22
+ 'loadout',
23
+ 'audio',
24
+ 'weapon',
25
+ 'species',
26
+ 'spawns',
27
+ 'faunaTuning',
28
+ ]
29
+
30
+ function isRecord(value: unknown): value is JsonRecord {
31
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
32
+ }
33
+
34
+ /** `field` of section `name`, when both are objects. */
35
+ function sectionField(
36
+ shard: Readonly<MigratingShard>,
37
+ name: string,
38
+ field: string,
39
+ ): JsonRecord | undefined {
40
+ const section = shard.sections.get(name)
41
+ const value = isRecord(section) ? section[field] : undefined
42
+ return isRecord(value) ? value : undefined
43
+ }
44
+
45
+ /** Whether a world spawn is the default one, a shard that never set `world/spawn`. */
46
+ function defaultSpawn(spawn: Readonly<JsonRecord>): boolean {
47
+ return (
48
+ spawn['x'] === DEFAULT_SPAWN.x &&
49
+ spawn['y'] === DEFAULT_SPAWN.y &&
50
+ spawn['z'] === DEFAULT_SPAWN.z &&
51
+ spawn['yaw'] === DEFAULT_SPAWN.yaw
52
+ )
53
+ }
54
+
55
+ /** The manifest's spawn stands the world spawn, keeping the section's height when it has none (a page on terrain). */
56
+ function liftSpawn(
57
+ shard: MigratingShard,
58
+ manifest: Readonly<JsonRecord>,
59
+ ): void {
60
+ const spawn = sectionField(shard, 'world/spawn', 'spawn')
61
+ const from = manifest['spawn']
62
+ if (spawn === undefined || !isRecord(from) || !defaultSpawn(spawn)) {
63
+ return
64
+ }
65
+ // oxlint-disable-next-line eslint/id-length -- world/spawn names its height y
66
+ Object.assign(spawn, { ...from, y: from['y'] ?? spawn['y'] })
67
+ }
68
+
69
+ /** The manifest's loadout and audio fill their sections' empty `level`. */
70
+ function liftLevels(
71
+ shard: MigratingShard,
72
+ manifest: Readonly<JsonRecord>,
73
+ ): void {
74
+ const items = sectionField(shard, 'combat/items', 'items')
75
+ const loadout = isRecord(items) ? items['loadout'] : undefined
76
+ if (
77
+ isRecord(loadout) &&
78
+ loadout['level'] === undefined &&
79
+ manifest['loadout'] !== undefined
80
+ ) {
81
+ loadout['level'] = manifest['loadout']
82
+ }
83
+ const audio = sectionField(shard, 'audio/audio', 'audio')
84
+ if (
85
+ audio !== undefined &&
86
+ audio['level'] === undefined &&
87
+ manifest['audio'] !== undefined
88
+ ) {
89
+ audio['level'] = manifest['audio']
90
+ }
91
+ }
92
+
93
+ /** Lift a manifest-shaped object's start words into their sections, then drop every moved word and the old pointer. */
94
+ function liftAndDrop(shard: MigratingShard, manifest: JsonRecord): void {
95
+ liftSpawn(shard, manifest)
96
+ liftLevels(shard, manifest)
97
+ for (const word of [...MOVED_WORDS, 'gridShardfile']) {
98
+ Reflect.deleteProperty(manifest, word)
99
+ }
100
+ }
101
+
102
+ /** FORMAT-PRUNE FP34: the level manifest carries none of the moved words. */
103
+ const manifestMovedWords: FormatMigration = {
104
+ id: 'fp34-manifest-moved-words',
105
+ to: MANIFEST_WORDS_GONE,
106
+ touches: 'data',
107
+ affects: [],
108
+ apply: (shard: MigratingShard): void => {
109
+ const manifest = sectionField(shard, 'ui/level', 'manifest')
110
+ if (manifest === undefined) {
111
+ return
112
+ }
113
+ liftAndDrop(shard, manifest)
114
+ // FORMAT-PRUNE FP47c: the map image leaves too, as `liftLevelStart` drops it at the door (look/map draws the map)
115
+ const map = manifest['minimap']
116
+ if (isRecord(map)) {
117
+ Reflect.deleteProperty(map, 'image')
118
+ }
119
+ },
120
+ }
121
+
122
+ /** FORMAT-PRUNE FP36: the discovery mount's `data` repeats the level manifest; it carries none of the moved words either.
123
+ * Runs after FP34's step, so a section the level manifest already filled keeps its value. */
124
+ const discoveryMovedWords: FormatMigration = {
125
+ id: 'fp36-discovery-moved-words',
126
+ to: MANIFEST_WORDS_GONE,
127
+ touches: 'data',
128
+ affects: [],
129
+ apply: (shard: MigratingShard): void => {
130
+ for (const [path, mount] of shard.mounts) {
131
+ const data = isRecord(mount) ? mount['data'] : undefined
132
+ if (isDiscoveryMount(path) && isRecord(data)) {
133
+ liftAndDrop(shard, data)
134
+ }
135
+ }
136
+ },
137
+ }
138
+
139
+ /** FORMAT-PRUNE FP47b: a manifest-shaped object's level look (sky, atmosphere and grade, and a horizon when it paints
140
+ * one) fills `look/look`'s empty `level`, as `liftLevelLook` does at the door; the look's own wins. Then the four words
141
+ * leave the object. A partial look (no sky, atmosphere or grade) has no level to give and only leaves. */
142
+ function liftLevelWords(shard: MigratingShard, manifest: JsonRecord): void {
143
+ const look = sectionField(shard, 'look/look', 'look')
144
+ const { sky, atmosphere, grade, horizon } = manifest
145
+ if (
146
+ look !== undefined &&
147
+ look['level'] === undefined &&
148
+ sky !== undefined &&
149
+ atmosphere !== undefined &&
150
+ grade !== undefined
151
+ ) {
152
+ look['level'] =
153
+ horizon === undefined
154
+ ? { sky, atmosphere, grade }
155
+ : { sky, atmosphere, grade, horizon }
156
+ }
157
+ for (const word of LEVEL_WORDS) {
158
+ Reflect.deleteProperty(manifest, word)
159
+ }
160
+ }
161
+
162
+ /** FORMAT-PRUNE FP47b: format 0.1.0.6 takes the level look out of the level manifest and the discovery mount; it lives
163
+ * in `look/look`'s `level` (ONE-FORMAT OF9b2). The level manifest gives first, then each discovery mount. */
164
+ const levelLook: FormatMigration = {
165
+ id: 'fp47b-level-look',
166
+ to: NO_LEVEL_WORDS,
167
+ touches: 'data',
168
+ affects: [],
169
+ apply: (shard: MigratingShard): void => {
170
+ const manifest = sectionField(shard, 'ui/level', 'manifest')
171
+ if (manifest !== undefined) {
172
+ liftLevelWords(shard, manifest)
173
+ }
174
+ for (const [path, mount] of shard.mounts) {
175
+ const data = isRecord(mount) ? mount['data'] : undefined
176
+ if (isDiscoveryMount(path) && isRecord(data)) {
177
+ liftLevelWords(shard, data)
178
+ }
179
+ }
180
+ },
181
+ }
182
+
183
+ export { MOVED_WORDS, discoveryMovedWords, levelLook, manifestMovedWords }
@@ -144,4 +144,4 @@ const schemaSource: FormatMigration = {
144
144
  staleSchemaBlocks(shard).length > NONE,
145
145
  }
146
146
 
147
- export { dropRuntimeTrust, schemaSource, shardfilePointer }
147
+ export { OLD_POINTER, dropRuntimeTrust, schemaSource, shardfilePointer }
@@ -12,6 +12,11 @@ import {
12
12
  } from './format-migration-envelope.ts'
13
13
  import { homesToMembers } from './format-migration-homes.ts'
14
14
  import { journalGlyphImages } from './format-migration-journal.ts'
15
+ import {
16
+ discoveryMovedWords,
17
+ levelLook,
18
+ manifestMovedWords,
19
+ } from './format-migration-manifest.ts'
15
20
  import {
16
21
  dropRuntimeTrust,
17
22
  schemaSource,
@@ -86,6 +91,9 @@ const FORMAT_MIGRATIONS: readonly FormatMigration[] = [
86
91
  dropRequiresCapabilities,
87
92
  dropRequiresSdk,
88
93
  homesToMembers,
94
+ manifestMovedWords,
95
+ discoveryMovedWords,
96
+ levelLook,
89
97
  ]
90
98
 
91
99
  /** Whether a file at `version` still needs a step that writes `to`. The legacy two-part spelling sits just below its
@@ -1,8 +1,11 @@
1
1
  /** ONE-FORMAT OF9b5 under J486: the level manifest's moved words. SDK 0.4.25 builds write none of them (OF9b3b moved
2
2
  * the page-start words to their sections, OF9b4 the herd fields to declared rows), but every product built before it
3
- * still carries some in `ui/level`. FE7 counts each one's kept users; OF9b5a deletes the field from
4
- * `ManifestMetadataSchema` at zero users. No data migration exists: the start words have a lift at the door
5
- * (`level-start.ts`), and the herd fields became declared rows in the build, which a copy of the file can't redo. */
3
+ * still carries some in `ui/level`. FE7 counts each one's kept users. FORMAT-PRUNE FP34 deletes them from
4
+ * `ManifestMetadataSchema` at format 0.1.0.6, and its chain step (`fp34-manifest-moved-words`) lifts the start words into
5
+ * their sections and drops the rest: the herd fields became declared rows in the build, which a copy can't redo. */
6
+
7
+ import { OLD_POINTER } from './format-migration-prune.ts'
8
+ import { compareShardfileVersions } from './version.ts'
6
9
 
7
10
  /** The registry's row shape (`deprecations.ts`). */
8
11
  interface ManifestDeprecation {
@@ -10,7 +13,7 @@ interface ManifestDeprecation {
10
13
  readonly path: string
11
14
  readonly since: string
12
15
  readonly replacement: string
13
- readonly migration: undefined
16
+ readonly migration: string
14
17
  readonly uses: (
15
18
  shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
16
19
  ) => boolean
@@ -40,7 +43,7 @@ const MANIFEST_MOVED_DEPRECATIONS: readonly ManifestDeprecation[] = MOVED.map(
40
43
  path: `sections/ui/level manifest.${word} (ONE-FORMAT OF9b5)`,
41
44
  since: '0.1.0.4',
42
45
  replacement,
43
- migration: undefined,
46
+ migration: 'fp34-manifest-moved-words',
44
47
  uses: (
45
48
  shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
46
49
  ): boolean => {
@@ -54,4 +57,169 @@ const MANIFEST_MOVED_DEPRECATIONS: readonly ManifestDeprecation[] = MOVED.map(
54
57
  }),
55
58
  )
56
59
 
57
- export { MANIFEST_MOVED_DEPRECATIONS }
60
+ /** FORMAT-PRUNE FP47b: each level look word the manifest carried before OF9b2, and the chain step that lifts it. */
61
+ const LEVEL_DEPRECATIONS: readonly ManifestDeprecation[] = [
62
+ 'sky',
63
+ 'atmosphere',
64
+ 'grade',
65
+ 'horizon',
66
+ ].map((word: string): ManifestDeprecation => ({
67
+ id: `manifest.${word}`,
68
+ path: `sections/ui/level manifest.${word} (and the discovery mount; ONE-FORMAT OF9b2)`,
69
+ since: '0.1.0.4',
70
+ replacement: `look/look's level.${word} (OF9b2)`,
71
+ migration: 'fp47b-level-look',
72
+ uses: (
73
+ shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
74
+ ): boolean => {
75
+ const manifest = manifestOf(shard.sections)
76
+ return (
77
+ typeof manifest === 'object' &&
78
+ manifest !== null &&
79
+ Object.hasOwn(manifest, word)
80
+ )
81
+ },
82
+ }))
83
+ /** FORMAT-PRUNE FP34: the first format whose level manifest carries none of the moved words, nor the old pointer. */
84
+ // 0.75.0 shipped format 0.1.0.5 without FP34 and FP36, so they ride 0.1.0.6 with FP47b.
85
+ const NO_MOVED_WORDS = '0.1.0.6'
86
+ const NONE = 0
87
+ // The old pointer's spelling is FP8's chain step's (format's one-way `format.grid-pointer-references` counts each one).
88
+ const GONE_WORDS: readonly string[] = [
89
+ OLD_POINTER,
90
+ ...MOVED.map(([word]: readonly [string, string]): string => word),
91
+ ]
92
+
93
+ /** FORMAT-PRUNE FP47b: the first format whose level manifest and discovery data carry no level look (OF9b2 moved it
94
+ * to `look/look`'s `level`), and the four words. */
95
+ const NO_LEVEL_WORDS = '0.1.0.6'
96
+ const LEVEL_WORDS: readonly string[] = ['sky', 'atmosphere', 'grade', 'horizon']
97
+ /** FORMAT-PRUNE FP36: the discovery mount, which repeats the level manifest as its `data`. */
98
+ const DISCOVERY_MOUNT =
99
+ /^mounts\/shardfiles\/(?:_[a-z]+|[a-z][a-z0-9-]*)\/discovery\.json$/u
100
+
101
+ /** Whether a format version is one that carries none of the gone words. */
102
+ function gated(version: unknown): version is string {
103
+ return (
104
+ typeof version === 'string' &&
105
+ compareShardfileVersions(version, NO_MOVED_WORDS) >= NONE
106
+ )
107
+ }
108
+
109
+ /** The gone words a manifest-shaped object still carries at `version`: the moved words and the level look's
110
+ * from 0.1.0.6 (FP47b). */
111
+ function keptWords(version: string, manifest: unknown): readonly string[] {
112
+ if (typeof manifest !== 'object' || manifest === null) {
113
+ return []
114
+ }
115
+ const gone =
116
+ compareShardfileVersions(version, NO_LEVEL_WORDS) >= NONE
117
+ ? [...GONE_WORDS, ...LEVEL_WORDS]
118
+ : GONE_WORDS
119
+ return gone.filter((word: string): boolean => Object.hasOwn(manifest, word))
120
+ }
121
+
122
+ /** FORMAT-PRUNE FP47c: a level manifest's map image, which `look/map` replaced (OF9b3); gone with the moved words. */
123
+ function keptMapImage(manifest: unknown): readonly string[] {
124
+ const map: unknown =
125
+ typeof manifest === 'object' && manifest !== null
126
+ ? Reflect.get(manifest, 'minimap')
127
+ : undefined
128
+ return typeof map === 'object' && map !== null && Object.hasOwn(map, 'image')
129
+ ? ['minimap.image']
130
+ : []
131
+ }
132
+
133
+ /** FORMAT-PRUNE FP47c: the level manifest's map image (OF9b3 moved the map to `look/map`); FP34's step drops it. */
134
+ const MAP_IMAGE_DEPRECATION: ManifestDeprecation = {
135
+ id: 'manifest.minimap.image',
136
+ path: 'sections/ui/level manifest.minimap.image (ONE-FORMAT OF9b3)',
137
+ since: '0.1.0.4',
138
+ replacement: 'look/map (OF9b3)',
139
+ migration: 'fp34-manifest-moved-words',
140
+ uses: (
141
+ shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
142
+ ): boolean => keptMapImage(manifestOf(shard.sections)).length > NONE,
143
+ }
144
+ /** The row that refuses the kept words: FP47b when they are all the level look's, else the moved words' row. */
145
+ function prune(kept: readonly string[], moved = 'FP36'): string {
146
+ return kept.every((word: string): boolean => LEVEL_WORDS.includes(word))
147
+ ? 'FP47b'
148
+ : moved
149
+ }
150
+ /** Parsed JSON, or nothing for bytes that are none (another check's refusal). */
151
+ function jsonOf(bytes: Readonly<Uint8Array>): unknown {
152
+ try {
153
+ return JSON.parse(new TextDecoder().decode(bytes))
154
+ } catch {
155
+ return undefined
156
+ }
157
+ }
158
+
159
+ /** Whether a product path is a shard's discovery mount. */
160
+ function isDiscoveryMount(path: string): boolean {
161
+ return DISCOVERY_MOUNT.test(path)
162
+ }
163
+
164
+ /** A mount or pack the stream validator checks as it passes and does not hold; the discovery mount it holds (FP36). */
165
+ function unheldMount(path: string): boolean {
166
+ return (
167
+ path.startsWith('packs/') ||
168
+ (path.startsWith('mounts/') && !isDiscoveryMount(path))
169
+ )
170
+ }
171
+
172
+ /** FORMAT-PRUNE FP36 (the FP33 pattern): format 0.1.0.6 on refuses a discovery mount whose `data` carries a moved word or
173
+ * the old pointer; an older file keeps them as written, and the chain step (`fp36-discovery-moved-words`) lifts them.
174
+ * Bytes that are no JSON object are another check's refusal. Answers the bytes it checked. */
175
+ function checkDiscoveryMount(
176
+ version: unknown,
177
+ path: string,
178
+ bytes: Readonly<Uint8Array>,
179
+ ): Readonly<Uint8Array> {
180
+ if (!isDiscoveryMount(path) || !gated(version)) {
181
+ return bytes
182
+ }
183
+ const parsed = jsonOf(bytes)
184
+ const data: unknown =
185
+ typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
186
+ ? Reflect.get(parsed, 'data')
187
+ : undefined
188
+ const kept = keptWords(version, data)
189
+ if (kept.length > NONE) {
190
+ throw new Error(
191
+ `Format ${version} carries no ${kept.map((word: string): string => `data.${word}`).join(', ')} (${path}; FORMAT-PRUNE ${prune(kept)})`,
192
+ )
193
+ }
194
+ return bytes
195
+ }
196
+
197
+ /** FORMAT-PRUNE FP34 (the FP33 pattern): format 0.1.0.6 on refuses a level manifest carrying a moved word or the old
198
+ * pointer; an older file keeps them as written, so its source hash still matches, and the chain step
199
+ * (`fp34-manifest-moved-words`) lifts them. */
200
+ function checkNoMovedWords(version: unknown, level: unknown): void {
201
+ if (!gated(version)) {
202
+ return
203
+ }
204
+ const manifest = manifestOf(new Map([['ui/level', level]]))
205
+ const kept = [...keptWords(version, manifest), ...keptMapImage(manifest)]
206
+ if (kept.length > NONE) {
207
+ throw new Error(
208
+ `Format ${version} carries no ${kept.map((word: string): string => `manifest.${word}`).join(', ')} (sections/ui/level; FORMAT-PRUNE ${prune(kept, 'FP34')})`,
209
+ )
210
+ }
211
+ }
212
+
213
+ export {
214
+ GONE_WORDS,
215
+ LEVEL_DEPRECATIONS,
216
+ LEVEL_WORDS,
217
+ MANIFEST_MOVED_DEPRECATIONS,
218
+ MAP_IMAGE_DEPRECATION,
219
+ NO_LEVEL_WORDS,
220
+ NO_MOVED_WORDS,
221
+ checkDiscoveryMount,
222
+ checkNoMovedWords,
223
+ isDiscoveryMount,
224
+ unheldMount,
225
+ }
@@ -1,209 +1,7 @@
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. 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.",
2
+ "$doc": "J426 (Jake, 2026-11-18): the J410 memory lines every memory gate judges an armed shard by. Which shards are armed is the API catalogue's word (FORMAT-PRUNE FP27, `/api/catalogue` `armed`, its `memory_armed` table seeded from this file's former `zones`): admission passes it to the format (FP27b), and since FP27c the format keeps no list of its own, so a gate given no catalogue word reports only (J424). An armed shard's offline estimate refuses over lines.loadingBytes (J445); playing and runtime overages report. Decimal bytes.",
3
3
  "lines": {
4
4
  "playingBytes": 1000000000,
5
5
  "loadingBytes": 1500000000
6
- },
7
- "zones": {
8
- "brasscap-mesa": {
9
- "armed": "2026-11-18",
10
- "by": "mini-pinemem5",
11
- "epoch": 8,
12
- "playingBytes": 679221837,
13
- "loadingBytes": 984731013,
14
- "evidence": "engine-pinned product revision 6 (tar f42fe0449a93), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
15
- },
16
- "far-reach": {
17
- "armed": "2026-11-18",
18
- "by": "mini-pinemem5",
19
- "epoch": 8,
20
- "playingBytes": 999952196,
21
- "loadingBytes": 1415754105,
22
- "evidence": "engine-pinned product revision 4 (tar 5bc5adcf764a), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
23
- },
24
- "ink-cel-valley": {
25
- "armed": "2026-11-18",
26
- "by": "mini-pinemem5",
27
- "epoch": 8,
28
- "playingBytes": 636979847,
29
- "loadingBytes": 925290035,
30
- "evidence": "engine-pinned product revision 1 (tar 5764c86a258a), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
31
- },
32
- "open-plot-alien-plain": {
33
- "armed": "2026-11-18",
34
- "by": "mini-pinemem5",
35
- "epoch": 8,
36
- "playingBytes": 665173554,
37
- "loadingBytes": 967392441,
38
- "evidence": "engine-pinned product revision 1 (tar c32cd9fb9229), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
39
- },
40
- "open-plot-clockwork-canyon": {
41
- "armed": "2026-11-18",
42
- "by": "mini-pinemem5",
43
- "epoch": 8,
44
- "playingBytes": 675751489,
45
- "loadingBytes": 982935896,
46
- "evidence": "engine-pinned product revision 1 (tar 3b322eccd99e), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
47
- },
48
- "open-plot-coral-drift": {
49
- "armed": "2026-11-18",
50
- "by": "mini-pinemem5",
51
- "epoch": 8,
52
- "playingBytes": 681768940,
53
- "loadingBytes": 992453778,
54
- "evidence": "engine-pinned product revision 1 (tar 87841749dc3f), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
55
- },
56
- "open-plot-desert-ruin": {
57
- "armed": "2026-11-18",
58
- "by": "mini-pinemem5",
59
- "epoch": 8,
60
- "playingBytes": 686478807,
61
- "loadingBytes": 997958716,
62
- "evidence": "engine-pinned product revision 1 (tar 3b65bfef7275), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
63
- },
64
- "open-plot-ember-forge": {
65
- "armed": "2026-11-18",
66
- "by": "mini-pinemem5",
67
- "epoch": 8,
68
- "playingBytes": 679682616,
69
- "loadingBytes": 987005255,
70
- "evidence": "engine-pinned product revision 1 (tar e1a3a9325e8e), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
71
- },
72
- "open-plot-fossil-badlands": {
73
- "armed": "2026-11-18",
74
- "by": "mini-pinemem5",
75
- "epoch": 8,
76
- "playingBytes": 671308241,
77
- "loadingBytes": 976533532,
78
- "evidence": "engine-pinned product revision 1 (tar 5bbdd51b8db9), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
79
- },
80
- "open-plot-frostline-peaks": {
81
- "armed": "2026-11-18",
82
- "by": "mini-pinemem5",
83
- "epoch": 8,
84
- "playingBytes": 694731191,
85
- "loadingBytes": 1007041500,
86
- "evidence": "engine-pinned product revision 1 (tar ec7b8879a343), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
87
- },
88
- "open-plot-jungle-ziggurat": {
89
- "armed": "2026-11-18",
90
- "by": "mini-pinemem5",
91
- "epoch": 8,
92
- "playingBytes": 683128342,
93
- "loadingBytes": 992540003,
94
- "evidence": "engine-pinned product revision 1 (tar 62fdb3cc7e41), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
95
- },
96
- "open-plot-lantern-bayou": {
97
- "armed": "2026-11-18",
98
- "by": "mini-pinemem5",
99
- "epoch": 8,
100
- "playingBytes": 679945285,
101
- "loadingBytes": 989938627,
102
- "evidence": "engine-pinned product revision 1 (tar 1f9fb1cba098), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
103
- },
104
- "open-plot-mosslight-ruins": {
105
- "armed": "2026-11-18",
106
- "by": "mini-pinemem5",
107
- "epoch": 8,
108
- "playingBytes": 693006386,
109
- "loadingBytes": 1006944516,
110
- "evidence": "engine-pinned product revision 1 (tar 19840339238b), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
111
- },
112
- "open-plot-night-market": {
113
- "armed": "2026-11-18",
114
- "by": "mini-pinemem5",
115
- "epoch": 8,
116
- "playingBytes": 709180040,
117
- "loadingBytes": 1028237840,
118
- "evidence": "engine-pinned product revision 1 (tar d8fe11c2db67), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
119
- },
120
- "open-plot-patchwork-fairground": {
121
- "armed": "2026-11-18",
122
- "by": "mini-pinemem5",
123
- "epoch": 8,
124
- "playingBytes": 670516626,
125
- "loadingBytes": 974863462,
126
- "evidence": "engine-pinned product revision 1 (tar e517f4814ef6), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
127
- },
128
- "open-plot-saltwind-lighthouse": {
129
- "armed": "2026-11-18",
130
- "by": "mini-pinemem5",
131
- "epoch": 8,
132
- "playingBytes": 657567209,
133
- "loadingBytes": 956173411,
134
- "evidence": "engine-pinned product revision 1 (tar 2e37a04b0c9e), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
135
- },
136
- "open-plot-sky-harbor": {
137
- "armed": "2026-11-18",
138
- "by": "mini-pinemem5",
139
- "epoch": 8,
140
- "playingBytes": 671985118,
141
- "loadingBytes": 977835231,
142
- "evidence": "engine-pinned product revision 1 (tar 9aa4a9839015), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
143
- },
144
- "open-plot-sky-race": {
145
- "armed": "2026-11-18",
146
- "by": "mini-pinemem5",
147
- "epoch": 8,
148
- "playingBytes": 671490214,
149
- "loadingBytes": 977159704,
150
- "evidence": "engine-pinned product revision 1 (tar a5633d8eee7f), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
151
- },
152
- "open-plot-starfall-observatory": {
153
- "armed": "2026-11-18",
154
- "by": "mini-pinemem5",
155
- "epoch": 8,
156
- "playingBytes": 674717033,
157
- "loadingBytes": 981241332,
158
- "evidence": "engine-pinned product revision 1 (tar 25331b613be1), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
159
- },
160
- "open-plot-thin-ice": {
161
- "armed": "2026-11-18",
162
- "by": "mini-pinemem5",
163
- "epoch": 8,
164
- "playingBytes": 657896658,
165
- "loadingBytes": 957357794,
166
- "evidence": "engine-pinned product revision 1 (tar 4546f70ddac2), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
167
- },
168
- "pastel-plain": {
169
- "armed": "2026-11-18",
170
- "by": "mini-pinemem5",
171
- "epoch": 8,
172
- "playingBytes": 636958876,
173
- "loadingBytes": 925256481,
174
- "evidence": "engine-pinned product revision 1 (tar e42e2f5f5793), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
175
- },
176
- "sunscar-dunes": {
177
- "armed": "2026-11-18",
178
- "by": "mini-pinemem5",
179
- "epoch": 8,
180
- "playingBytes": 772000529,
181
- "loadingBytes": 1108011593,
182
- "evidence": "engine-pinned product revision 2 (tar f4a1d611cccc), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
183
- },
184
- "driftwood-isle": {
185
- "armed": "2026-11-18",
186
- "by": "mini-pinemem5",
187
- "epoch": 8,
188
- "playingBytes": 820905616,
189
- "loadingBytes": 1157545785,
190
- "evidence": "shard-driftwood e736730 built with format 0.37 (epoch 8); codex-nalati locked pairs on the EM11 upper read 990.5 / 1,344.7 MB (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"
191
- },
192
- "nalati-grasslands": {
193
- "armed": "2026-11-18",
194
- "by": "mini-pinemem5",
195
- "epoch": 8,
196
- "playingBytes": 945736154,
197
- "loadingBytes": 1328901899,
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
- },
200
- "pine-hollow": {
201
- "armed": "2026-11-18",
202
- "by": "mini-pinemem5",
203
- "epoch": 8,
204
- "playingBytes": 920666659,
205
- "loadingBytes": 1298769921,
206
- "evidence": "shard-pine-hollow 400ed4b7 built with format 0.37 (epoch 8); mini-pinemem6 prepared online boot on engine f0a96518, 9 pairs: playing upper 0.969 GB, loading upper 1.407 GB (meta 118a2b13); 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
6
  }
209
7
  }
@@ -1,20 +1,9 @@
1
1
  import armed from './memory-armed.json' with { type: 'json' }
2
2
 
3
- /** The armed-zone readings are shared with the engine. J445 uses the common
4
- * loading ceiling for offline refusal and the playing line for reporting. */
5
- interface ArmedZone {
6
- readonly armed: string
7
- readonly by: string
8
- readonly epoch: number
9
- readonly playingBytes: number
10
- readonly loadingBytes: number
11
- readonly evidence: string
12
- }
13
-
14
3
  type ArmedKind = 'playing' | 'loading'
15
4
 
16
5
  /** 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. */
6
+ * (`{ slug, armed }`); since FP27c the format keeps no list, so a bare slug is not armed and reports only (J424). */
18
7
  type ZoneRef =
19
8
  | string
20
9
  | undefined
@@ -45,18 +34,10 @@ const ARMED_LINES: Readonly<Record<ArmedKind, number>> = Object.freeze({
45
34
  loading: armed.lines.loadingBytes,
46
35
  })
47
36
 
48
- const ARMED_ZONES: Readonly<Record<string, ArmedZone>> = Object.freeze(
49
- armed.zones,
50
- )
51
-
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
53
- * that reads over its line. It reports only; it moves back to `zones` (re-armed) when its engine re-pin lands. */
54
- /** True when the zone is armed (J426): the catalogue's word when admission passed it, else the format's list. */
37
+ /** True when the zone is armed (J426): the API catalogue's word, which admission passes (FP27b). A bare slug carries no
38
+ * word: since FP27c the format keeps no armed list, so it reports only (J424). */
55
39
  function zoneArmed(zone?: ZoneRef): boolean {
56
- if (typeof zone === 'object') {
57
- return zone.armed
58
- }
59
- return zone !== undefined && Object.hasOwn(ARMED_ZONES, zone)
40
+ return typeof zone === 'object' && zone.armed
60
41
  }
61
42
 
62
43
  /** The common lines for an armed zone. A revision's own reading is evidence,
@@ -103,9 +84,7 @@ function staleReadingAdmitted(zone: ZoneRef): boolean {
103
84
 
104
85
  export {
105
86
  ARMED_LINES,
106
- ARMED_ZONES,
107
87
  type ArmedKind,
108
- type ArmedZone,
109
88
  type ZoneRef,
110
89
  armedLine,
111
90
  armedZone,
@@ -47,7 +47,7 @@ function staleRuntimeIssues(
47
47
  identity?: Readonly<{
48
48
  slug: string
49
49
  saveRevision: number
50
- /** FP27b: the API catalogue's armed state; absent, the format's own list decides. */
50
+ /** FP27b: the API catalogue's armed state; absent, the shard is not armed (FP27c). */
51
51
  armed?: boolean | ReadonlySet<string> | undefined
52
52
  }>,
53
53
  ): StaleRuntimeIssue[] {
@@ -33,7 +33,9 @@ function overHardLine(bytes: number): string {
33
33
  function hardLineIssue(
34
34
  kind: 'playing' | 'loading',
35
35
  bytes: number,
36
- zone?: ZoneRef | Readonly<{ slug: string; line: number }>,
36
+ zone?:
37
+ | ZoneRef
38
+ | Readonly<{ slug?: string | undefined; armed?: boolean; line: number }>,
37
39
  ): {
38
40
  readonly code: 'perf-playing-memory' | 'perf-loading-memory'
39
41
  readonly metric: string
@@ -41,9 +43,16 @@ function hardLineIssue(
41
43
  readonly limit: number
42
44
  readonly severity: 'refusal' | 'warning'
43
45
  } {
46
+ // FP27c: a zone with its own line carries the catalogue's armed word beside its slug, as a ZoneRef does.
44
47
  const { slug, line } =
45
48
  typeof zone === 'object' && 'line' in zone
46
- ? zone
49
+ ? {
50
+ slug:
51
+ zone.armed === undefined
52
+ ? zone.slug
53
+ : { slug: zone.slug, armed: zone.armed },
54
+ line: zone.line,
55
+ }
47
56
  : { slug: zone, line: ARMED_LINES[kind] }
48
57
  const severity = ratchetSeverity(slug, kind, { line, actual: bytes })
49
58
  const over =
@@ -95,7 +104,7 @@ type MemoryContext =
95
104
  mountedImages: number
96
105
  index?: TierIndex
97
106
  judged?: 'upload' | 'stored'
98
- /** FP27b: the API catalogue's armed state for this shard; absent, the format's own list decides. */
107
+ /** FP27b: the API catalogue's armed state for this shard; absent, the shard is not armed (FP27c). */
99
108
  armed?: boolean | ReadonlySet<string> | undefined
100
109
  }>
101
110
 
@@ -17,7 +17,8 @@ import { ClientPlanRuntimeSchema } from './runtime.ts';
17
17
  import { RuntimeSpawnsSchema } from './runtimeSpawns.ts';
18
18
  import { RowsSchema } from './rows.ts';
19
19
  import { ShardHashSchema, ShardNaturalSchema, IdentitySchema, RequiresSchema, FilesSchema, type ShardIdentityInput, type ShardRequiresInput, type ShardReferencesInput, type ShardIdentity, type ShardRequires, type ShardReferences } from './shardSections.ts';
20
- import { LEGACY_LAYOUT, writesNoRequiresSdk, writesPreparationMarker, writesSaveRevision } from './version.ts';
20
+ import { LEGACY_LAYOUT, carriesEngineFloor, writesNoRequiresSdk, writesPreparationMarker, writesSaveRevision } from './version.ts';
21
+ import { checkNoMovedWords } from './manifest-deprecations.ts';
21
22
  import { IndexFormatVersionSchema, LegacyIndexVersionSchema } from './index-format-version.ts';
22
23
  import type { IndexFormatVersion, LegacyIndexVersion } from './version.ts';
23
24
  import { isJsonData, isJsonDataWithFileSchemas } from './json.ts';
@@ -138,11 +139,18 @@ function checkNoRequiresSdk(index: OutputIndex): void {
138
139
  const version = index.formatVersion === LEGACY_LAYOUT ? undefined : index.formatVersion;
139
140
  if (version !== undefined && writesNoRequiresSdk(version) && index.requires.sdk !== undefined) { throw new Error(`Format ${version} carries no requires.sdk (shard.json; FORMAT-PRUNE FP33)`); }
140
141
  }
142
+ /** FP47b: `requires.engine` is a 0.1.0.6 word; an older file never carries it (an engine on that format refuses it). */
143
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot output, only read
144
+ function checkEngineFloorVersion(index: OutputIndex): void {
145
+ const version = index.formatVersion === LEGACY_LAYOUT ? undefined : index.formatVersion;
146
+ if (index.requires.engine !== undefined && (version === undefined || !carriesEngineFloor(version))) { throw new Error(`Format ${String(version ?? index.formatVersion)} carries no requires.engine (shard.json; from 0.1.0.6, FORMAT-PRUNE FP47b)`); }
147
+ }
141
148
  function parseOutputIndexRows(input: unknown): OutputIndex {
142
149
  const index = v.parse(OutputIndexSchema, input);
143
150
  checkIndexEnvelope(index);
144
151
  checkSaveRevisionSpelling(input, index);
145
152
  checkNoRequiresSdk(index);
153
+ checkEngineFloorVersion(index);
146
154
  const prepared = preparationSpecOf(index) !== undefined || unreadPreparationSpec(index) !== undefined;
147
155
  if (prepared && index.cook === undefined) { throw new Error(`Missing cook preparation: run wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`); }
148
156
  if (prepared && index.cook !== undefined && index.cook.bytes > MAX_COOK_BYTES) { throw new Error('Cook preparation exceeds byte cap'); }
@@ -230,7 +238,9 @@ export function assembleOutputFields(index: OutputIndex, sections: ReadonlyMap<s
230
238
  }
231
239
  /** The default untrusted reader always checks sections and the full host schema. */
232
240
  export function assembleOutputShardfile(input: unknown, sections: ReadonlyMap<string, unknown>): Shardfile {
233
- const source = parseShardfile(assembleOutputFields(parseOutputIndex(input), sections), sections);
241
+ const index = parseOutputIndex(input);
242
+ checkNoMovedWords(index.formatVersion, sections.get('ui/level'));
243
+ const source = parseShardfile(assembleOutputFields(index, sections), sections);
234
244
  const errors = clientOwnershipRules(source, sections); if (errors.length > 0) throw new Error(errors.join('; '));
235
245
  return source;
236
246
  }
@@ -13,7 +13,7 @@ import type { ZoneRef } from './memory-armed.ts'
13
13
  type Judged = 'upload' | 'stored'
14
14
 
15
15
  /** How admission judges a shard: CP10's `judged`, and FP27b's `armed`, the API catalogue's armed state for it (absent,
16
- * the format's own list decides until FP27c removes it). */
16
+ * the shard is not armed: since FP27c the format keeps no list). */
17
17
  interface JudgedPorts {
18
18
  readonly judged?: Judged | undefined
19
19
  readonly armed?: boolean | ReadonlySet<string> | undefined
@@ -11,6 +11,7 @@ import type { FormatVersion } from './version.ts';
11
11
  import { RuntimeCostSchema } from './runtimeCost.ts';
12
12
  import { CommonsCostsSchema } from './commonsCosts.ts';
13
13
  import { ScriptBindingsSchema } from './scripts.ts';
14
+ import { EngineReleaseSchema } from './engine-floor.ts';
14
15
 
15
16
  const CHUNK_HALF = WIRE_CELL.half, CELL_BELOW = WIRE_CELL.below, CELL_ABOVE = WIRE_CELL.above;
16
17
  /** Nonnegative safe wire integer. */
@@ -45,7 +46,7 @@ const IdentityRowSchema = v.strictObject({ slug: name, name: v.pipe(v.string(),
45
46
  function identityWithSaveRevision(row: Readonly<v.InferOutput<typeof IdentityRowSchema>>): ShardIdentity { const { revision: _old, saveRevision: _new, ...rest } = row; return { ...rest, saveRevision: saveRevisionOf(row) }; }
46
47
  export const IdentitySchema: v.GenericSchema<ShardIdentityInput, ShardIdentity> = v.pipe(IdentityRowSchema, v.check(oneSaveRevisionSpelling, 'Shard identity needs exactly one of saveRevision or revision'), v.transform(identityWithSaveRevision));
47
48
  /** Wire revision, capabilities and exact commons declarations. */
48
- export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.exactOptional(v.picklist(SHARDFILE_VERSIONS)), capabilities: v.exactOptional(ShardNamesSchema), commons: v.pipe(v.array(ShardHashSchema), v.maxLength(limits.commons)), commonsWire: v.optional(v.record(ShardHashSchema, ShardNaturalSchema), {}), commonsCosts: v.optional(CommonsCostsSchema, {}) });
49
+ export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.exactOptional(v.picklist(SHARDFILE_VERSIONS)), capabilities: v.exactOptional(ShardNamesSchema), engine: v.exactOptional(EngineReleaseSchema), commons: v.pipe(v.array(ShardHashSchema), v.maxLength(limits.commons)), commonsWire: v.optional(v.record(ShardHashSchema, ShardNaturalSchema), {}), commonsCosts: v.optional(CommonsCostsSchema, {}) });
49
50
  /** Authored compressed and resident ceilings. */
50
51
  export const BudgetsSchema: v.GenericSchema<ShardBudgetsInput, ShardBudgets> = v.strictObject({
51
52
  /** Reviewed whole-client floor retained when an opaque runtime becomes declared data. */
@@ -236,6 +237,8 @@ interface ShardRequiresInputFields {
236
237
  sdk?: FormatVersion;
237
238
  /** FORMAT-PRUNE FP4: deprecated (always empty, never read); the chain drops it and writers stop sourcing it. */
238
239
  capabilities?: ShardNamesInput;
240
+ /** FORMAT-PRUNE FP47b (J505): the lowest engine release that can draw this product (0.1.0.6 on; `engine-floor.ts`). */
241
+ engine?: string;
239
242
  commons: (ShardHashInput)[];
240
243
  commonsWire?: Record<string, ShardNaturalInput> | undefined;
241
244
  commonsCosts?: v.InferInput<typeof CommonsCostsSchema> | undefined;
@@ -244,6 +247,7 @@ export type ShardRequiresInput = { [Key in keyof ShardRequiresInputFields]: Shar
244
247
  interface ShardRequiresFields {
245
248
  sdk?: FormatVersion;
246
249
  capabilities?: ShardNames;
250
+ engine?: string;
247
251
  commons: (ShardHash)[];
248
252
  commonsWire: Record<string, ShardNatural>;
249
253
  commonsCosts: v.InferOutput<typeof CommonsCostsSchema>;
@@ -10,6 +10,10 @@ import { cookMountPath, readCookData } from './cook-data.ts'
10
10
  import { requireCookPreparation } from './cook-preparation.ts'
11
11
  import { deprecationReport } from './deprecations.ts'
12
12
  import { issueError, withIssueCode } from './issue-codes.ts'
13
+ import {
14
+ checkDiscoveryMount,
15
+ isDiscoveryMount,
16
+ } from './manifest-deprecations.ts'
13
17
  import { validatePlatformFile } from './platformFileFamilies.ts'
14
18
  import { decisionModuleContracts } from './scriptContract.ts'
15
19
  import { mountSharesBlob } from './shardfile-reads.ts'
@@ -174,7 +178,15 @@ function cookSteps(replay: Readonly<Replay>, index: OutputIndex): void {
174
178
  if (mount.path !== cookMountPath(mount.url)) {
175
179
  throw new Error(`Mount path differs from its URL: ${mount.url}`)
176
180
  }
177
- readListed(replay, mount)
181
+ if (isDiscoveryMount(mount.path)) {
182
+ checkDiscoveryMount(
183
+ index.formatVersion,
184
+ mount.path,
185
+ listedBytes(replay, mount),
186
+ )
187
+ } else {
188
+ readListed(replay, mount)
189
+ }
178
190
  }
179
191
  }
180
192
  }
@@ -16,6 +16,7 @@
16
16
  import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts'
17
17
  import { assertSectionSides } from './feature-sides.ts'
18
18
  import { issueError, withIssueCode } from './issue-codes.ts'
19
+ import { unheldMount } from './manifest-deprecations.ts'
19
20
  import { parseOutputIndex, validateOutputSection } from './outputIndex.ts'
20
21
  import { admittedVerdict } from './policy-verdict.ts'
21
22
  import { assertScriptSides } from './script-sides.ts'
@@ -102,9 +103,9 @@ const STREAM_KEPT_CAP = 48_000_000
102
103
  const NONE = 0
103
104
  const NEXT = 1
104
105
 
105
- /** Whether a member is held whole after its check: everything but blobs, mounts and packs, and JSON and Wasm blobs. */
106
+ /** Whether a member is held whole after its check: everything but blobs, `unheldMount`s, and JSON and Wasm blobs. */
106
107
  function keptPath(path: string): boolean {
107
- if (path.startsWith('mounts/') || path.startsWith('packs/')) {
108
+ if (unheldMount(path)) {
108
109
  return false
109
110
  }
110
111
  const extension = path.slice(path.lastIndexOf('.') + NEXT)
@@ -1,4 +1,5 @@
1
1
  import { cookMountPath, readCookData } from './cook-data.ts';
2
+ import { checkDiscoveryMount } from './manifest-deprecations.ts';
2
3
  import { requireCookPreparation } from './cook-preparation.ts';
3
4
  import { parseOutputIndex, validateOutputSection, assembleOutputShardfile, type OutputFile, type OutputIndex } from './outputIndex.ts';
4
5
  import { asWrittenIdentity } from './save-revision.ts';
@@ -65,7 +66,7 @@ export interface ShardfileValidationPorts {
65
66
  * and budget policy only reports, since it was judged at upload. Default `'upload'`: the policy refuses. */
66
67
  readonly judged?: Judged;
67
68
  /** FORMAT-PRUNE FP27b: whether the API catalogue arms this shard (`/api/catalogue` `armed`). Admission passes it; absent,
68
- * the format's own armed list decides until FP27c removes it. */
69
+ * the shard is not armed: since FP27c the format keeps no list. */
69
70
  readonly armed?: boolean | ReadonlySet<string> | undefined;
70
71
  /** D31: hold no file's bytes between checks. `assets`, here and in the result, reads each file again from `files`, so a
71
72
  * host's peak is its largest file rather than the shard, at the cost of those repeat reads. */
@@ -218,7 +219,7 @@ function readCook(index: OutputIndex, read: ReadListed, ports: Pick<ShardfileVal
218
219
  if (!mountSharesBlob(mount, index.files)) {
219
220
  if (mount.path !== cookMountPath(mount.url)) { throw new Error(`Mount path differs from its URL: ${mount.url}`); }
220
221
  // MG6 epoch 3: the engine images a shard mounts decode at boot like its own (Far Reach's sky and textures).
221
- mountedImages += mountedImageBytes(mount.path, read(mount));
222
+ mountedImages += mountedImageBytes(mount.path, checkDiscoveryMount(index.formatVersion, mount.path, read(mount)));
222
223
  }
223
224
  }
224
225
  return { cook, mountedImages };
@@ -5,7 +5,7 @@ import { LEGACY_PREPARATION_SPEC, PREPARED_SDK } from './preparation-spec.ts'
5
5
  const ZERO = 0
6
6
  const ONE = 1
7
7
 
8
- const SHARDFILE_VERSION = '0.1.0.5'
8
+ const SHARDFILE_VERSION = '0.1.0.6'
9
9
  /** Formats whose `shard.json` names its version in `version`, beside the frozen layout marker `formatVersion: 2`.
10
10
  * Legacy 0.1 is the byte-preserving spelling of 0.1.0.0. */
11
11
  const LEGACY_INDEX_VERSIONS: readonly ['0.1', '0.1.0.0', '0.1.0.1'] = [
@@ -19,8 +19,9 @@ const INDEX_FORMAT_VERSIONS: readonly [
19
19
  '0.1.0.2',
20
20
  '0.1.0.3',
21
21
  '0.1.0.4',
22
+ '0.1.0.5',
22
23
  typeof SHARDFILE_VERSION,
23
- ] = ['0.1.0.2', '0.1.0.3', '0.1.0.4', SHARDFILE_VERSION] as const
24
+ ] = ['0.1.0.2', '0.1.0.3', '0.1.0.4', '0.1.0.5', SHARDFILE_VERSION] as const
24
25
  const SHARDFILE_VERSIONS: readonly [
25
26
  ...typeof LEGACY_INDEX_VERSIONS,
26
27
  ...typeof INDEX_FORMAT_VERSIONS,
@@ -44,6 +45,9 @@ const SHARDFILE_VERSION_SAVE_REVISION = '0.1.0.4'
44
45
  /** The first format whose `shard.json` carries no `requires.sdk` (FORMAT-PRUNE FP33, SHARD-COMPAT CP8): it only ever
45
46
  * copied the format version, and nothing reads it. */
46
47
  const SHARDFILE_VERSION_NO_REQUIRES_SDK = '0.1.0.5'
48
+ /** The first format whose `shard.json` may name the lowest engine release that draws it, `requires.engine` (FORMAT-PRUNE
49
+ * FP47b, J505): an engine on an older format refuses the word, so the floor holds there too. */
50
+ const SHARDFILE_VERSION_ENGINE_FLOOR = '0.1.0.6'
47
51
  /** A format version's four parts. */
48
52
  type FormatVersionParts = readonly [number, number, number, number]
49
53
  /** @deprecated SHARD-COMPAT SP10: use `FormatVersionParts`. */
@@ -152,6 +156,13 @@ function writesNoRequiresSdk(version: string): boolean {
152
156
  )
153
157
  }
154
158
 
159
+ /** Whether a format version may carry `requires.engine` (0.1.0.6 on, FP47b). */
160
+ function carriesEngineFloor(version: string): boolean {
161
+ return (
162
+ compareShardfileVersions(version, SHARDFILE_VERSION_ENGINE_FLOOR) >= ZERO
163
+ )
164
+ }
165
+
155
166
  /** FP26: a copy of an identity row with `revision` spelled `saveRevision`; anything else as it is. */
156
167
  function withSaveRevision(identity: unknown): unknown {
157
168
  if (
@@ -183,6 +194,14 @@ function withoutKeys(value: unknown, keys: readonly string[]): unknown {
183
194
  )
184
195
  }
185
196
 
197
+ /** `requires` as `version` writes it: no `sdk` from 0.1.0.5 (FORMAT-PRUNE FP33), no `engine` floor below 0.1.0.6 (FP47b). */
198
+ function requiresAt(requires: unknown, version: string): unknown {
199
+ return withoutKeys(requires, [
200
+ ...(writesNoRequiresSdk(version) ? ['sdk'] : []),
201
+ ...(carriesEngineFloor(version) ? [] : ['engine']),
202
+ ])
203
+ }
204
+
186
205
  /** The rows a version from 0.1.0.3 on changes in place: PR4's preparation marker, FP26's save lineage, then FP33's
187
206
  * `requires.sdk`. */
188
207
  function laterEnvelopeRows(
@@ -203,10 +222,7 @@ function laterEnvelopeRows(
203
222
  if (writesSaveRevision(version)) {
204
223
  envelope['identity'] = withSaveRevision(envelope['identity'])
205
224
  }
206
- // FORMAT-PRUNE FP33: from 0.1.0.5 `requires` carries no `sdk`.
207
- if (writesNoRequiresSdk(version)) {
208
- envelope['requires'] = withoutKeys(envelope['requires'], ['sdk'])
209
- }
225
+ envelope['requires'] = requiresAt(envelope['requires'], version)
210
226
  }
211
227
 
212
228
  /** The rows `outputIndexEnvelope` returns: the writer's own rows, typed so it keeps reading them, with `version` and
@@ -262,6 +278,8 @@ export {
262
278
  writesPreparationMarker,
263
279
  writesSaveRevision,
264
280
  writesNoRequiresSdk,
281
+ carriesEngineFloor,
282
+ SHARDFILE_VERSION_ENGINE_FLOOR,
265
283
  SHARDFILE_VERSION_PREPARATION,
266
284
  SHARDFILE_VERSION_SAVE_REVISION,
267
285
  SHARDFILE_VERSION_NO_REQUIRES_SDK,