@wildshard/shard-format 0.74.1 → 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 +2 -1
- package/src/format/clientNative.ts +0 -87
- package/src/format/clientOwnership.ts +3 -3
- package/src/format/clientPlan.ts +4 -4
- package/src/format/clientTrails.ts +9 -25
- package/src/format/cook-data.ts +5 -23
- package/src/format/deprecations.ts +9 -3
- package/src/format/engine-floor.ts +68 -0
- package/src/format/feature-sides.ts +0 -1
- package/src/format/format-migration-envelope.ts +17 -0
- package/src/format/format-migration-homes.ts +103 -0
- package/src/format/format-migration-manifest.ts +183 -0
- package/src/format/format-migration-prune.ts +1 -1
- package/src/format/format-migrations.ts +12 -0
- package/src/format/headless-sections.ts +2 -0
- package/src/format/manifest-deprecations.ts +174 -6
- package/src/format/memory-armed.json +1 -203
- package/src/format/memory-armed.ts +4 -25
- package/src/format/memory-epoch.ts +1 -1
- package/src/format/memory-line.ts +12 -3
- package/src/format/outputIndex.ts +19 -2
- package/src/format/policy-verdict.ts +1 -1
- package/src/format/primitive-table.ts +0 -1
- package/src/format/shardSections.ts +5 -1
- package/src/format/shardfile-stream-rows.ts +13 -1
- package/src/format/shardfile-stream.ts +3 -2
- package/src/format/shardfileValidation.ts +3 -2
- package/src/format/version.ts +51 -15
- package/src/tools/runtime-hosts.json +0 -4
|
@@ -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 }`);
|
|
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
|
-
|
|
49
|
-
armed.
|
|
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
|
-
|
|
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
|
|
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?:
|
|
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
|
-
?
|
|
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
|
|
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, 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';
|
|
@@ -132,10 +133,24 @@ function checkSaveRevisionSpelling(input: unknown, index: OutputIndex): void {
|
|
|
132
133
|
// Only the old spelling in a new format refuses: a parsed index (any version) already reads back as `saveRevision`.
|
|
133
134
|
if (spelled === 'revision' && version !== undefined && writesSaveRevision(version)) { throw new Error(`Format ${version} names the save lineage identity.saveRevision (shard.json)`); }
|
|
134
135
|
}
|
|
136
|
+
/** FP33: 0.1.0.5 on carries no `requires.sdk`; an older file keeps it as written, so its source hash still matches. */
|
|
137
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot output, only read
|
|
138
|
+
function checkNoRequiresSdk(index: OutputIndex): void {
|
|
139
|
+
const version = index.formatVersion === LEGACY_LAYOUT ? undefined : index.formatVersion;
|
|
140
|
+
if (version !== undefined && writesNoRequiresSdk(version) && index.requires.sdk !== undefined) { throw new Error(`Format ${version} carries no requires.sdk (shard.json; FORMAT-PRUNE FP33)`); }
|
|
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
|
+
}
|
|
135
148
|
function parseOutputIndexRows(input: unknown): OutputIndex {
|
|
136
149
|
const index = v.parse(OutputIndexSchema, input);
|
|
137
150
|
checkIndexEnvelope(index);
|
|
138
151
|
checkSaveRevisionSpelling(input, index);
|
|
152
|
+
checkNoRequiresSdk(index);
|
|
153
|
+
checkEngineFloorVersion(index);
|
|
139
154
|
const prepared = preparationSpecOf(index) !== undefined || unreadPreparationSpec(index) !== undefined;
|
|
140
155
|
if (prepared && index.cook === undefined) { throw new Error(`Missing cook preparation: run wildshard prepare <folder> --base <exact-preview-url> (${index.identity.slug})`); }
|
|
141
156
|
if (prepared && index.cook !== undefined && index.cook.bytes > MAX_COOK_BYTES) { throw new Error('Cook preparation exceeds byte cap'); }
|
|
@@ -223,7 +238,9 @@ export function assembleOutputFields(index: OutputIndex, sections: ReadonlyMap<s
|
|
|
223
238
|
}
|
|
224
239
|
/** The default untrusted reader always checks sections and the full host schema. */
|
|
225
240
|
export function assembleOutputShardfile(input: unknown, sections: ReadonlyMap<string, unknown>): Shardfile {
|
|
226
|
-
const
|
|
241
|
+
const index = parseOutputIndex(input);
|
|
242
|
+
checkNoMovedWords(index.formatVersion, sections.get('ui/level'));
|
|
243
|
+
const source = parseShardfile(assembleOutputFields(index, sections), sections);
|
|
227
244
|
const errors = clientOwnershipRules(source, sections); if (errors.length > 0) throw new Error(errors.join('; '));
|
|
228
245
|
return source;
|
|
229
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
|
|
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
|
-
|
|
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,
|
|
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 (
|
|
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
|
|
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 };
|
package/src/format/version.ts
CHANGED
|
@@ -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.
|
|
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'] = [
|
|
@@ -18,8 +18,10 @@ const LEGACY_INDEX_VERSIONS: readonly ['0.1', '0.1.0.0', '0.1.0.1'] = [
|
|
|
18
18
|
const INDEX_FORMAT_VERSIONS: readonly [
|
|
19
19
|
'0.1.0.2',
|
|
20
20
|
'0.1.0.3',
|
|
21
|
+
'0.1.0.4',
|
|
22
|
+
'0.1.0.5',
|
|
21
23
|
typeof SHARDFILE_VERSION,
|
|
22
|
-
] = ['0.1.0.2', '0.1.0.3', 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
|
|
23
25
|
const SHARDFILE_VERSIONS: readonly [
|
|
24
26
|
...typeof LEGACY_INDEX_VERSIONS,
|
|
25
27
|
...typeof INDEX_FORMAT_VERSIONS,
|
|
@@ -40,6 +42,12 @@ const SHARDFILE_VERSION_PREPARATION = '0.1.0.3'
|
|
|
40
42
|
/** The first format whose `shard.json` names the save lineage `identity.saveRevision` instead of `identity.revision`
|
|
41
43
|
* (FORMAT-PRUNE FP26, J493): the number keys saves and only ever rises; it is not the API's shard revision. */
|
|
42
44
|
const SHARDFILE_VERSION_SAVE_REVISION = '0.1.0.4'
|
|
45
|
+
/** The first format whose `shard.json` carries no `requires.sdk` (FORMAT-PRUNE FP33, SHARD-COMPAT CP8): it only ever
|
|
46
|
+
* copied the format version, and nothing reads it. */
|
|
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'
|
|
43
51
|
/** A format version's four parts. */
|
|
44
52
|
type FormatVersionParts = readonly [number, number, number, number]
|
|
45
53
|
/** @deprecated SHARD-COMPAT SP10: use `FormatVersionParts`. */
|
|
@@ -141,6 +149,20 @@ function writesSaveRevision(version: string): boolean {
|
|
|
141
149
|
)
|
|
142
150
|
}
|
|
143
151
|
|
|
152
|
+
/** Whether a format version writes no `requires.sdk` (0.1.0.5 on, FP33). */
|
|
153
|
+
function writesNoRequiresSdk(version: string): boolean {
|
|
154
|
+
return (
|
|
155
|
+
compareShardfileVersions(version, SHARDFILE_VERSION_NO_REQUIRES_SDK) >= ZERO
|
|
156
|
+
)
|
|
157
|
+
}
|
|
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
|
+
|
|
144
166
|
/** FP26: a copy of an identity row with `revision` spelled `saveRevision`; anything else as it is. */
|
|
145
167
|
function withSaveRevision(identity: unknown): unknown {
|
|
146
168
|
if (
|
|
@@ -160,7 +182,28 @@ function withSaveRevision(identity: unknown): unknown {
|
|
|
160
182
|
return Object.fromEntries(renamed)
|
|
161
183
|
}
|
|
162
184
|
|
|
163
|
-
/**
|
|
185
|
+
/** A copy of a JSON object without `keys`; anything else as it is. */
|
|
186
|
+
function withoutKeys(value: unknown, keys: readonly string[]): unknown {
|
|
187
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
188
|
+
return value
|
|
189
|
+
}
|
|
190
|
+
return Object.fromEntries(
|
|
191
|
+
Object.entries(value).filter(
|
|
192
|
+
([key]: readonly [string, unknown]): boolean => !keys.includes(key),
|
|
193
|
+
),
|
|
194
|
+
)
|
|
195
|
+
}
|
|
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
|
+
|
|
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
|
|
206
|
+
* `requires.sdk`. */
|
|
164
207
|
function laterEnvelopeRows(
|
|
165
208
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- it changes the writer's envelope in place
|
|
166
209
|
envelope: Record<string, unknown>,
|
|
@@ -179,18 +222,7 @@ function laterEnvelopeRows(
|
|
|
179
222
|
if (writesSaveRevision(version)) {
|
|
180
223
|
envelope['identity'] = withSaveRevision(envelope['identity'])
|
|
181
224
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/** A copy of a JSON object without `keys`; anything else as it is. */
|
|
185
|
-
function withoutKeys(value: unknown, keys: readonly string[]): unknown {
|
|
186
|
-
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
187
|
-
return value
|
|
188
|
-
}
|
|
189
|
-
return Object.fromEntries(
|
|
190
|
-
Object.entries(value).filter(
|
|
191
|
-
([key]: readonly [string, unknown]): boolean => !keys.includes(key),
|
|
192
|
-
),
|
|
193
|
-
)
|
|
225
|
+
envelope['requires'] = requiresAt(envelope['requires'], version)
|
|
194
226
|
}
|
|
195
227
|
|
|
196
228
|
/** The rows `outputIndexEnvelope` returns: the writer's own rows, typed so it keeps reading them, with `version` and
|
|
@@ -245,8 +277,12 @@ export {
|
|
|
245
277
|
writesIndexFormatVersion,
|
|
246
278
|
writesPreparationMarker,
|
|
247
279
|
writesSaveRevision,
|
|
280
|
+
writesNoRequiresSdk,
|
|
281
|
+
carriesEngineFloor,
|
|
282
|
+
SHARDFILE_VERSION_ENGINE_FLOOR,
|
|
248
283
|
SHARDFILE_VERSION_PREPARATION,
|
|
249
284
|
SHARDFILE_VERSION_SAVE_REVISION,
|
|
285
|
+
SHARDFILE_VERSION_NO_REQUIRES_SDK,
|
|
250
286
|
SHARDFILE_FLOOR,
|
|
251
287
|
type FormatVersion,
|
|
252
288
|
type FormatVersionParts,
|
|
@@ -369,10 +369,6 @@
|
|
|
369
369
|
"page": ["enterClientPlayer", "installClientPlayerEnter"],
|
|
370
370
|
"reads": []
|
|
371
371
|
},
|
|
372
|
-
"population.homes": {
|
|
373
|
-
"page": ["installClientPopulation"],
|
|
374
|
-
"reads": ["sim/runtime-plan", "sim/scripts"]
|
|
375
|
-
},
|
|
376
372
|
"population.hull-book": {
|
|
377
373
|
"page": ["prepareDeclaredHullBookKit"],
|
|
378
374
|
"reads": ["actors/species-programs", "explore/catalogue"]
|