@wildshard/shard-format 0.69.2 → 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.
- package/package.json +21 -3
- package/src/cli/corpus-candidate.ts +228 -0
- package/src/cli/corpus-command.ts +67 -0
- package/src/cli/corpus-pins.ts +73 -0
- package/src/cli/corpus-report.ts +36 -0
- package/src/cli/corpus-tar.ts +28 -0
- package/src/cli/corpus-usage.ts +106 -0
- package/src/cli/corpus.ts +50 -68
- package/src/cli/format-diff-data.ts +89 -0
- package/src/cli/format-diff-lock.ts +122 -0
- package/src/cli/format-diff-normal.ts +300 -0
- package/src/cli/format-diff-paths.ts +103 -0
- package/src/cli/format-diff-range.ts +112 -0
- package/src/cli/format-diff-report.ts +30 -0
- package/src/cli/format-diff-rules.ts +232 -0
- package/src/cli/format-diff.ts +226 -0
- package/src/cli/main.ts +81 -32
- package/src/cli/pack.ts +20 -3
- package/src/cli/validate.ts +1 -1
- package/src/format/clientOwnership.ts +1 -1
- package/src/format/clientTrails.ts +121 -46
- package/src/format/cook-data.ts +22 -3
- package/src/format/cook-deprecations.ts +53 -0
- package/src/format/cook-preparation.ts +105 -70
- package/src/format/creature-rest-rig.ts +248 -0
- package/src/format/creature-skin-bounds.ts +146 -0
- package/src/format/deprecations.ts +30 -21
- package/src/format/edge-observations.ts +67 -0
- package/src/format/empty-shardfile.ts +4 -2
- package/src/format/entry-read-set.ts +147 -0
- package/src/format/format-migrate-rebuild.ts +4 -1
- package/src/format/format-migrate.ts +10 -5
- package/src/format/format-migration-envelope.ts +40 -0
- package/src/format/format-migration-prune.ts +42 -1
- package/src/format/format-migrations.ts +10 -1
- package/src/format/format-window.ts +71 -0
- package/src/format/immutable.ts +4 -1
- package/src/format/json-schema.ts +1468 -0
- package/src/format/lootEconomy.ts +4 -1
- package/src/format/mat4.ts +225 -0
- package/src/format/memory-armed.json +1 -9
- package/src/format/memory-armed.ts +46 -17
- package/src/format/memory-epoch.ts +10 -3
- package/src/format/memory-line.ts +17 -6
- package/src/format/outputFields.ts +3 -2
- package/src/format/outputIndex.ts +41 -6
- package/src/format/platformDataSections.ts +5 -0
- package/src/format/platformFileFamilies.ts +3 -3
- package/src/format/play-area.ts +95 -0
- package/src/format/policy-verdict.ts +12 -2
- package/src/format/preparation-checks.ts +100 -0
- package/src/format/preparation-spec.ts +45 -0
- package/src/format/registeredJson.ts +2 -2
- package/src/format/runtime-tier.ts +14 -7
- package/src/format/save-revision.ts +105 -0
- package/src/format/schema-source.ts +70 -0
- package/src/format/sections.ts +4 -1
- package/src/format/server-plan.ts +42 -0
- package/src/format/server-reads.ts +23 -0
- package/src/format/shardSchema.ts +9 -4
- package/src/format/shardSections.ts +17 -7
- package/src/format/shardfile-assets.ts +5 -5
- package/src/format/shardfile-stream-admit.ts +19 -10
- package/src/format/shardfile-stream-facts.ts +2 -1
- package/src/format/shardfile-stream.ts +2 -3
- package/src/format/shardfileValidation.ts +16 -9
- package/src/format/species-deprecations.ts +79 -0
- package/src/format/stateLineage.ts +15 -7
- package/src/format/tread-boxes.ts +65 -0
- package/src/format/vehicle-hulls.ts +124 -0
- package/src/format/version.ts +96 -10
- package/src/format/whole-inputs.ts +51 -0
- package/src/tools/runtime-hosts.json +4 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SHARD-COMPAT PR6d (J487): which files of a shard the MMO server reads, a rule over the index alone, so the cook packs
|
|
2
|
+
// the server's files and the server opens them without engine code. Moved from engine
|
|
3
|
+
// `src/shared/game/shardfile/outputDescriptor.ts` `serverReadsFile`: every bin, json and wasm file, and the one tile
|
|
4
|
+
// file the terrain section names by hash.
|
|
5
|
+
|
|
6
|
+
/** A file row as the index lists it: its kind and content hash. */
|
|
7
|
+
export interface ServerReadRow {
|
|
8
|
+
readonly kind: string
|
|
9
|
+
readonly hash: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Whether the MMO server reads this file; `terrain` is the terrain section's file reference, if the shard has one. */
|
|
13
|
+
export function serverReadsFile(
|
|
14
|
+
file: ServerReadRow,
|
|
15
|
+
terrain?: string,
|
|
16
|
+
): boolean {
|
|
17
|
+
return (
|
|
18
|
+
file.kind === 'bin' ||
|
|
19
|
+
file.kind === 'json' ||
|
|
20
|
+
file.kind === 'wasm' ||
|
|
21
|
+
(file.kind === 'tile' && terrain?.endsWith(file.hash) === true)
|
|
22
|
+
)
|
|
23
|
+
}
|
|
@@ -16,7 +16,7 @@ import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
|
|
|
16
16
|
import { preflightShardfile } from './preflight.ts';
|
|
17
17
|
import { preflightAssetGraph } from './shardfile-assets.ts';
|
|
18
18
|
import { SHARDFILE_VERSIONS } from './version.ts';
|
|
19
|
-
import type {
|
|
19
|
+
import type { FormatVersion } from './version.ts';
|
|
20
20
|
import { UiSchema, uiRules } from './ui.ts';
|
|
21
21
|
import { scriptBindingRules } from './scripts.ts';
|
|
22
22
|
import { RowsSchema } from './rows.ts';
|
|
@@ -47,6 +47,7 @@ import { RuntimeSchema } from './runtime.ts';
|
|
|
47
47
|
import { ClientScriptsSchema, clientScriptRules } from './clientScripts.ts';
|
|
48
48
|
import { lampPanelErrors } from './look-swing.ts';
|
|
49
49
|
import { ClientChannelsSchema } from './clientChannels.ts';
|
|
50
|
+
import { EdgeObservationsSchema } from './edge-observations.ts';
|
|
50
51
|
import { EdgeProfilesSchema } from './edgeProfiles.ts';
|
|
51
52
|
import { EntrywaysSchema, entrywayRules } from './entryways.ts';
|
|
52
53
|
import { ModesSchema } from './modes.ts';
|
|
@@ -101,6 +102,7 @@ const rawSchema: v.GenericSchema<ShardfileRowsInput, ShardfileRows> & { readonly
|
|
|
101
102
|
serverBudget: ServerBudgetSchema,
|
|
102
103
|
edge: EdgeProfilesSchema,
|
|
103
104
|
entryways: EntrywaysSchema,
|
|
105
|
+
edgeObservations: v.exactOptional(EdgeObservationsSchema),
|
|
104
106
|
movers: v.optional(MoversSchema, []),
|
|
105
107
|
modes: v.exactOptional(ModesSchema),
|
|
106
108
|
files: FilesSchema, tiles: TilesSchema, library: LibrarySchema, critical: CriticalSchema, late: v.exactOptional(AdmissionLateSchema),
|
|
@@ -142,7 +144,7 @@ export const ShardfileFieldSchemas: { readonly [Key in keyof Shardfile]-?: v.Gen
|
|
|
142
144
|
/** Public parsed output, independently named by section. The unchanged schema
|
|
143
145
|
* is checked against this interface, so consumers need not expand its input tree. */
|
|
144
146
|
export interface Shardfile {
|
|
145
|
-
version:
|
|
147
|
+
version: FormatVersion;
|
|
146
148
|
accent: v.InferOutput<typeof AccentSchema>;
|
|
147
149
|
identity: v.InferOutput<typeof IdentitySchema>;
|
|
148
150
|
presentation?: v.InferOutput<typeof PresentationSchema>;
|
|
@@ -157,6 +159,7 @@ export interface Shardfile {
|
|
|
157
159
|
serverBudget: v.InferOutput<typeof ServerBudgetSchema>;
|
|
158
160
|
edge: v.InferOutput<typeof EdgeProfilesSchema>;
|
|
159
161
|
entryways: v.InferOutput<typeof EntrywaysSchema>;
|
|
162
|
+
edgeObservations?: v.InferOutput<typeof EdgeObservationsSchema>;
|
|
160
163
|
movers: v.InferOutput<typeof MoversSchema>;
|
|
161
164
|
modes?: v.InferOutput<typeof ModesSchema>;
|
|
162
165
|
files: v.InferOutput<typeof FilesSchema>;
|
|
@@ -476,7 +479,7 @@ export { parseShardfile, parseShardfileField };
|
|
|
476
479
|
|
|
477
480
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
478
481
|
interface ShardfileRowsInputFields {
|
|
479
|
-
version:
|
|
482
|
+
version: FormatVersion;
|
|
480
483
|
accent: v.InferInput<typeof AccentSchema>;
|
|
481
484
|
identity: v.InferInput<typeof IdentitySchema>;
|
|
482
485
|
presentation?: v.InferInput<typeof PresentationSchema>;
|
|
@@ -516,6 +519,7 @@ interface ShardfileRowsInputFields {
|
|
|
516
519
|
serverBudget: v.InferInput<typeof ServerBudgetSchema>;
|
|
517
520
|
edge: v.InferInput<typeof EdgeProfilesSchema>;
|
|
518
521
|
entryways: v.InferInput<typeof EntrywaysSchema>;
|
|
522
|
+
edgeObservations?: v.InferInput<typeof EdgeObservationsSchema>;
|
|
519
523
|
movers?: v.InferInput<typeof MoversSchema> | undefined;
|
|
520
524
|
modes?: v.InferInput<typeof ModesSchema>;
|
|
521
525
|
files: v.InferInput<typeof FilesSchema>;
|
|
@@ -555,7 +559,7 @@ interface ShardfileRowsInputFields {
|
|
|
555
559
|
}
|
|
556
560
|
export type ShardfileRowsInput = { [Key in keyof ShardfileRowsInputFields]: ShardfileRowsInputFields[Key] };
|
|
557
561
|
interface ShardfileRowsFields {
|
|
558
|
-
version:
|
|
562
|
+
version: FormatVersion;
|
|
559
563
|
accent: v.InferOutput<typeof AccentSchema>;
|
|
560
564
|
identity: v.InferOutput<typeof IdentitySchema>;
|
|
561
565
|
presentation?: v.InferOutput<typeof PresentationSchema>;
|
|
@@ -595,6 +599,7 @@ interface ShardfileRowsFields {
|
|
|
595
599
|
serverBudget: v.InferOutput<typeof ServerBudgetSchema>;
|
|
596
600
|
edge: v.InferOutput<typeof EdgeProfilesSchema>;
|
|
597
601
|
entryways: v.InferOutput<typeof EntrywaysSchema>;
|
|
602
|
+
edgeObservations?: v.InferOutput<typeof EdgeObservationsSchema>;
|
|
598
603
|
movers: v.InferOutput<typeof MoversSchema>;
|
|
599
604
|
modes?: v.InferOutput<typeof ModesSchema>;
|
|
600
605
|
files: v.InferOutput<typeof FilesSchema>;
|
|
@@ -6,7 +6,8 @@ import * as v from 'valibot';
|
|
|
6
6
|
import { WIRE_CELL, WIRE_TILE_SIZES } from './wireLimits.ts';
|
|
7
7
|
import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
|
|
8
8
|
import { SHARDFILE_VERSIONS } from './version.ts';
|
|
9
|
-
import
|
|
9
|
+
import { oneSaveRevisionSpelling, saveRevisionOf } from './save-revision.ts';
|
|
10
|
+
import type { FormatVersion } from './version.ts';
|
|
10
11
|
import { RuntimeCostSchema } from './runtimeCost.ts';
|
|
11
12
|
import { CommonsCostsSchema } from './commonsCosts.ts';
|
|
12
13
|
import { ScriptBindingsSchema } from './scripts.ts';
|
|
@@ -38,9 +39,13 @@ const file: v.StrictObjectSchema<{ readonly hash: v.GenericSchema<ShardFileRowsI
|
|
|
38
39
|
const tileCount = (2 * CHUNK_HALF / WIRE_TILE_SIZES.l0) ** 2 + (2 * CHUNK_HALF / WIRE_TILE_SIZES.l1) ** 2;
|
|
39
40
|
|
|
40
41
|
/** Stable authored shard identity and deterministic seed. */
|
|
41
|
-
|
|
42
|
+
/** FORMAT-PRUNE FP26 (J493): the save lineage is `saveRevision`. Format 0.1.0.3 and older spell it `revision`; either
|
|
43
|
+
* spelling reads (the index checks which one its format version writes) and both come out as `saveRevision`. */
|
|
44
|
+
const IdentityRowSchema = v.strictObject({ slug: name, name: v.pipe(v.string(), v.minLength(1), v.maxLength(limits.idCharacters)), author: v.pipe(v.string(), v.minLength(1), v.maxLength(limits.idCharacters)), saveRevision: v.exactOptional(positive), revision: v.exactOptional(positive), seed: ShardNaturalSchema });
|
|
45
|
+
function identityWithSaveRevision(row: Readonly<v.InferOutput<typeof IdentityRowSchema>>): ShardIdentity { const { revision: _old, saveRevision: _new, ...rest } = row; return { ...rest, saveRevision: saveRevisionOf(row) }; }
|
|
46
|
+
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));
|
|
42
47
|
/** Wire revision, capabilities and exact commons declarations. */
|
|
43
|
-
export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.picklist(SHARDFILE_VERSIONS), capabilities: ShardNamesSchema, commons: v.pipe(v.array(ShardHashSchema), v.maxLength(limits.commons)), commonsWire: v.optional(v.record(ShardHashSchema, ShardNaturalSchema), {}), commonsCosts: v.optional(CommonsCostsSchema, {}) });
|
|
48
|
+
export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.exactOptional(v.picklist(SHARDFILE_VERSIONS)), capabilities: ShardNamesSchema, commons: v.pipe(v.array(ShardHashSchema), v.maxLength(limits.commons)), commonsWire: v.optional(v.record(ShardHashSchema, ShardNaturalSchema), {}), commonsCosts: v.optional(CommonsCostsSchema, {}) });
|
|
44
49
|
/** Authored compressed and resident ceilings. */
|
|
45
50
|
export const BudgetsSchema: v.GenericSchema<ShardBudgetsInput, ShardBudgets> = v.strictObject({
|
|
46
51
|
/** Reviewed whole-client floor retained when an opaque runtime becomes declared data. */
|
|
@@ -210,7 +215,10 @@ interface ShardIdentityInputFields {
|
|
|
210
215
|
slug: string;
|
|
211
216
|
name: string;
|
|
212
217
|
author: string;
|
|
213
|
-
|
|
218
|
+
/** FP26: the save lineage. */
|
|
219
|
+
saveRevision?: ShardNaturalInput;
|
|
220
|
+
/** FP26: the save lineage's spelling up to format 0.1.0.3; give exactly one of the two. */
|
|
221
|
+
revision?: ShardNaturalInput;
|
|
214
222
|
seed: ShardNaturalInput;
|
|
215
223
|
}
|
|
216
224
|
export type ShardIdentityInput = { [Key in keyof ShardIdentityInputFields]: ShardIdentityInputFields[Key] };
|
|
@@ -218,12 +226,14 @@ interface ShardIdentityFields {
|
|
|
218
226
|
slug: string;
|
|
219
227
|
name: string;
|
|
220
228
|
author: string;
|
|
221
|
-
|
|
229
|
+
/** FP26: the save lineage. It keys saves and never goes backwards; it is not the API's shard revision. */
|
|
230
|
+
saveRevision: ShardNatural;
|
|
222
231
|
seed: ShardNatural;
|
|
223
232
|
}
|
|
224
233
|
export type ShardIdentity = { [Key in keyof ShardIdentityFields]: ShardIdentityFields[Key] };
|
|
225
234
|
interface ShardRequiresInputFields {
|
|
226
|
-
|
|
235
|
+
/** SHARD-COMPAT CP8: deprecated (a copy of the format version, never read); writers stop sourcing it. */
|
|
236
|
+
sdk?: FormatVersion;
|
|
227
237
|
capabilities: ShardNamesInput;
|
|
228
238
|
commons: (ShardHashInput)[];
|
|
229
239
|
commonsWire?: Record<string, ShardNaturalInput> | undefined;
|
|
@@ -231,7 +241,7 @@ interface ShardRequiresInputFields {
|
|
|
231
241
|
}
|
|
232
242
|
export type ShardRequiresInput = { [Key in keyof ShardRequiresInputFields]: ShardRequiresInputFields[Key] };
|
|
233
243
|
interface ShardRequiresFields {
|
|
234
|
-
sdk
|
|
244
|
+
sdk?: FormatVersion;
|
|
235
245
|
capabilities: ShardNames;
|
|
236
246
|
commons: (ShardHash)[];
|
|
237
247
|
commonsWire: Record<string, ShardNatural>;
|
|
@@ -13,7 +13,7 @@ import type { Shardfile } from "./shardSchema.ts";
|
|
|
13
13
|
import type { ShardTerrain } from "./terrain.ts";
|
|
14
14
|
import { worstContentCost, memoryTargetWarnings, nearbyContentCost } from "./budget.ts";
|
|
15
15
|
import { CONTENT_CAPS as C } from './contentBounds.ts';
|
|
16
|
-
import { ARMED_LINES, ratchetLimit } from './memory-armed.ts';
|
|
16
|
+
import { ARMED_LINES, armedZone, ratchetLimit } from './memory-armed.ts';
|
|
17
17
|
import { asJudged } from './policy-verdict.ts';
|
|
18
18
|
import type { Judged } from './policy-verdict.ts';
|
|
19
19
|
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
@@ -29,7 +29,7 @@ import type { IssueCodeOf } from './issue-codes.ts';
|
|
|
29
29
|
import { isNavigationData, navigationCost } from './navigationBytes.ts';
|
|
30
30
|
|
|
31
31
|
type PerformancePolicy = 'refuse' | 'warn';
|
|
32
|
-
interface PerformanceOptions { readonly policy: PerformancePolicy; readonly sections: ReadonlyMap<string, unknown>; readonly mountedImages?: number; readonly index?: TierIndex; readonly judged?: Judged }
|
|
32
|
+
interface PerformanceOptions { readonly policy: PerformancePolicy; readonly sections: ReadonlyMap<string, unknown>; readonly mountedImages?: number; readonly index?: TierIndex; readonly judged?: Judged; readonly armed?: boolean | ReadonlySet<string> | undefined }
|
|
33
33
|
|
|
34
34
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's shard row, only read
|
|
35
35
|
function reportMemory(source: Shardfile, nativeBytes: number, options: Readonly<{ sections: ReadonlyMap<string, unknown>; mountedImages?: number; index?: TierIndex }>): PerformanceReport['memory'] {
|
|
@@ -321,7 +321,7 @@ export function performanceReport(source: Shardfile, observations: PerformanceOb
|
|
|
321
321
|
};
|
|
322
322
|
if (native.unmeasuredViewAndDownload) check(['perf-native-view-unmeasured', 'native view/download measurement required'], 1, 0);
|
|
323
323
|
if (source.runtime !== null && source.runtime.cost === undefined) check(['perf-native-resident-unmeasured', 'native resident measurement required'], 1, 0);
|
|
324
|
-
issues.push(...staleRuntimeIssues(source.runtime, undefined, source.identity), ...memoryLineIssues(worst, source.identity.slug));
|
|
324
|
+
issues.push(...staleRuntimeIssues(source.runtime, undefined, { ...source.identity, armed: resolved.armed }), ...memoryLineIssues(worst, armedZone(source.identity.slug, resolved.armed)));
|
|
325
325
|
const library = reportCardClosure(source, source.library), critical = reportCardClosure(source, source.critical);
|
|
326
326
|
const tileRoots = source.tiles.flatMap(tile => tile.files), farRoots = source.far?.files ?? [], nearRoots = nearPlaceholderRoots(source.near);
|
|
327
327
|
const playable = reportCardClosure(source, [...source.critical, ...source.library, ...farRoots, ...source.tiles.filter(tile => tile.lod === 1 || near(tile, spawn.x, spawn.z)).flatMap(tile => tile.files)]);
|
|
@@ -370,9 +370,9 @@ export function performanceReportLines(report: PerformanceReport): string[] {
|
|
|
370
370
|
|
|
371
371
|
/** Offline soft-cap policy and the hard loading ceiling (J445). A stored shard file was judged at its upload (CP10):
|
|
372
372
|
* no memory line refuses it again. */
|
|
373
|
-
export function offlineMemoryAdmission(_policy: 'warn' | 'refuse', judged: 'upload' | 'stored' = 'upload'): MemoryAdmission {
|
|
373
|
+
export function offlineMemoryAdmission(_policy: 'warn' | 'refuse', judged: 'upload' | 'stored' = 'upload', armed?: boolean | ReadonlySet<string>): MemoryAdmission {
|
|
374
374
|
// The hard loading ceiling applies to the armed list.
|
|
375
375
|
return new MemoryAdmission((): boolean => true, judged === 'stored'
|
|
376
376
|
? (): number => Number.POSITIVE_INFINITY
|
|
377
|
-
: (owner, kind): number => ratchetLimit(owner, kind, MEMORY_HARD_BYTES));
|
|
377
|
+
: (owner, kind): number => ratchetLimit(armedZone(owner, armed), kind, MEMORY_HARD_BYTES));
|
|
378
378
|
}
|
|
@@ -11,17 +11,17 @@ import {
|
|
|
11
11
|
import { issueError, withIssueCode } from './issue-codes.ts'
|
|
12
12
|
import { assembleOutputShardfile } from './outputIndex.ts'
|
|
13
13
|
import { admittedVerdict, recordVerdict } from './policy-verdict.ts'
|
|
14
|
+
import { writtenSourceBytes } from './save-revision.ts'
|
|
14
15
|
import { offlineMemoryAdmission } from './shardfile-assets.ts'
|
|
15
16
|
import {
|
|
16
17
|
assertShardfileTargets,
|
|
17
18
|
checkWorldTargets,
|
|
18
19
|
} from './shardfileValidation.ts'
|
|
19
20
|
import { parseShardfile } from './shardSchema.ts'
|
|
20
|
-
import { validationSourceBytes } from './validationReceipt.ts'
|
|
21
21
|
|
|
22
22
|
import type { AssetAdmission } from './assetAdmission.ts'
|
|
23
23
|
import type { OutputIndex } from './outputIndex.ts'
|
|
24
|
-
import type { Judged, PolicyVerdict } from './policy-verdict.ts'
|
|
24
|
+
import type { Judged, JudgedPorts, PolicyVerdict } from './policy-verdict.ts'
|
|
25
25
|
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
26
26
|
import type { AssetPasses } from './shardfile-stream-assets.ts'
|
|
27
27
|
import type { Shardfile } from './shardSchema.ts'
|
|
@@ -31,13 +31,14 @@ function admitHead(
|
|
|
31
31
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
|
|
32
32
|
index: OutputIndex,
|
|
33
33
|
payloads: ReadonlyMap<string, unknown>,
|
|
34
|
-
|
|
34
|
+
policy: Readonly<JudgedPorts>,
|
|
35
35
|
): Shardfile {
|
|
36
|
+
const { judged = 'upload', armed } = policy
|
|
36
37
|
const shard = withIssueCode('shard-schema', (): Shardfile =>
|
|
37
38
|
parseShardfile(assembleOutputShardfile(index, payloads), payloads),
|
|
38
39
|
)
|
|
39
40
|
withIssueCode('declared-costs', (): void => {
|
|
40
|
-
preflightDeclaredCosts(shard, offlineMemoryAdmission('warn', judged))
|
|
41
|
+
preflightDeclaredCosts(shard, offlineMemoryAdmission('warn', judged, armed))
|
|
41
42
|
})
|
|
42
43
|
const verdict = withIssueCode('performance-targets', (): PolicyVerdict =>
|
|
43
44
|
// MG6 epoch 5: the index lets the estimate count only the files a phone fetches (no mount bytes in the stream).
|
|
@@ -46,6 +47,7 @@ function admitHead(
|
|
|
46
47
|
mountedImages: 0,
|
|
47
48
|
index,
|
|
48
49
|
judged,
|
|
50
|
+
armed,
|
|
49
51
|
}),
|
|
50
52
|
)
|
|
51
53
|
return recordVerdict(shard, verdict)
|
|
@@ -58,21 +60,26 @@ function admitBeforeAssets(
|
|
|
58
60
|
index: OutputIndex,
|
|
59
61
|
payloads: ReadonlyMap<string, unknown>,
|
|
60
62
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's row type, only read
|
|
61
|
-
rows: Readonly<{
|
|
63
|
+
rows: Readonly<{
|
|
64
|
+
scripts: ScriptAdmissionRows
|
|
65
|
+
judged?: Judged | undefined
|
|
66
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
67
|
+
}>,
|
|
62
68
|
): Readonly<{
|
|
63
69
|
admission: AssetAdmission | undefined
|
|
64
70
|
refusal: unknown
|
|
65
71
|
head?: Shardfile | undefined
|
|
66
72
|
judged?: Judged | undefined
|
|
73
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
67
74
|
}> {
|
|
68
|
-
const { scripts, judged } = rows
|
|
75
|
+
const { scripts, judged, armed } = rows
|
|
69
76
|
try {
|
|
70
|
-
const head = admitHead(index, payloads, judged)
|
|
77
|
+
const head = admitHead(index, payloads, { judged, armed })
|
|
71
78
|
return {
|
|
72
79
|
admission: withIssueCode('asset-admission', (): AssetAdmission =>
|
|
73
80
|
assetAdmission(
|
|
74
81
|
head,
|
|
75
|
-
offlineMemoryAdmission('warn', judged),
|
|
82
|
+
offlineMemoryAdmission('warn', judged, armed),
|
|
76
83
|
scripts,
|
|
77
84
|
payloads,
|
|
78
85
|
),
|
|
@@ -80,6 +87,7 @@ function admitBeforeAssets(
|
|
|
80
87
|
refusal: undefined,
|
|
81
88
|
head,
|
|
82
89
|
judged,
|
|
90
|
+
armed,
|
|
83
91
|
}
|
|
84
92
|
} catch (error) {
|
|
85
93
|
return { admission: undefined, refusal: error }
|
|
@@ -94,6 +102,7 @@ function admitAssets(
|
|
|
94
102
|
refusal: unknown
|
|
95
103
|
head?: Shardfile | undefined
|
|
96
104
|
judged?: Judged | undefined
|
|
105
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
97
106
|
}>,
|
|
98
107
|
later: Readonly<AssetPasses>,
|
|
99
108
|
hash: (bytes: Readonly<Uint8Array>) => string,
|
|
@@ -114,7 +123,7 @@ function admitAssets(
|
|
|
114
123
|
admitAfterFiles(
|
|
115
124
|
admission,
|
|
116
125
|
later.assets,
|
|
117
|
-
offlineMemoryAdmission('warn', before.judged),
|
|
126
|
+
offlineMemoryAdmission('warn', before.judged, before.armed),
|
|
118
127
|
),
|
|
119
128
|
admittedVerdict(head),
|
|
120
129
|
)
|
|
@@ -134,7 +143,7 @@ function admitTail(
|
|
|
134
143
|
): void {
|
|
135
144
|
checkWorldTargets(shard, product.payloads.get('world/targets'))
|
|
136
145
|
if (
|
|
137
|
-
product.hash(
|
|
146
|
+
product.hash(writtenSourceBytes(shard, product.index.formatVersion)) !==
|
|
138
147
|
product.index.build.sourceHash
|
|
139
148
|
) {
|
|
140
149
|
throw issueError(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
registeredJsonContract,
|
|
13
13
|
validateRegisteredJson,
|
|
14
14
|
} from './registeredJson.ts'
|
|
15
|
+
import { currentSchemaSource } from './schema-source.ts'
|
|
15
16
|
import { assetCost } from './shardfile-assets.ts'
|
|
16
17
|
import { outputBlobExtension, outputBlobKind } from './shardfileValidation.ts'
|
|
17
18
|
import { validationSourceBytes } from './validationReceipt.ts'
|
|
@@ -140,7 +141,7 @@ function inspectRegistered(file: OutputFile, member: FactsMember): void {
|
|
|
140
141
|
'Unregistered named JSON with a schema needs a JSON Schema checker',
|
|
141
142
|
)
|
|
142
143
|
}
|
|
143
|
-
if (file.jsonSchema['$comment'] !== contract.source) {
|
|
144
|
+
if (currentSchemaSource(file.jsonSchema['$comment']) !== contract.source) {
|
|
144
145
|
throw new Error(
|
|
145
146
|
'Registered JSON requires its exact defining format contract',
|
|
146
147
|
)
|
|
@@ -39,7 +39,7 @@ import { readCanonicalJson } from './shardfileValidation.ts'
|
|
|
39
39
|
|
|
40
40
|
import type { DeprecationReport } from './deprecations.ts'
|
|
41
41
|
import type { OutputIndex } from './outputIndex.ts'
|
|
42
|
-
import type {
|
|
42
|
+
import type { JudgedPorts, PolicyVerdict } from './policy-verdict.ts'
|
|
43
43
|
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
44
44
|
import type { StoredSource } from './shardfile-stream-assets.ts'
|
|
45
45
|
import type { KeptMember, Replay } from './shardfile-stream-rows.ts'
|
|
@@ -51,7 +51,7 @@ import type {
|
|
|
51
51
|
import type { Shardfile } from './shardSchema.ts'
|
|
52
52
|
|
|
53
53
|
/** The host services a streaming validation needs. */
|
|
54
|
-
interface StreamValidationPorts {
|
|
54
|
+
interface StreamValidationPorts extends JudgedPorts {
|
|
55
55
|
/** Lowercase hex SHA-256 of exact bytes. */
|
|
56
56
|
readonly hash: (bytes: Readonly<Uint8Array>) => string
|
|
57
57
|
/** A fresh incremental SHA-256. */
|
|
@@ -60,7 +60,6 @@ interface StreamValidationPorts {
|
|
|
60
60
|
readonly decode?: (
|
|
61
61
|
stored: AsyncIterable<Uint8Array>,
|
|
62
62
|
) => AsyncIterable<Uint8Array>
|
|
63
|
-
readonly judged?: Judged
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/** What one streaming validation found. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cookMountPath, readCookData } from './cook-data.ts';
|
|
2
2
|
import { requireCookPreparation } from './cook-preparation.ts';
|
|
3
3
|
import { parseOutputIndex, validateOutputSection, assembleOutputShardfile, type OutputFile, type OutputIndex } from './outputIndex.ts';
|
|
4
|
+
import { asWrittenIdentity } from './save-revision.ts';
|
|
4
5
|
import { decisionModuleContracts, scriptAdmissionRows, type ScriptAdmissionRows, type ScriptContract } from './scriptContract.ts';
|
|
5
6
|
import { registeredJsonContract, validateRegisteredJson } from './registeredJson.ts';
|
|
6
7
|
import { validatePlatformFile } from './platformFileFamilies.ts';
|
|
@@ -22,12 +23,14 @@ import type { RecordingMeasure } from './audio-measure.ts';
|
|
|
22
23
|
import { issueError, withIssueCode as coded } from './issue-codes.ts';
|
|
23
24
|
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
24
25
|
import { memoryContext, offlineMemoryIssues } from './memory-line.ts';
|
|
26
|
+
import { armedZone } from './memory-armed.ts';
|
|
25
27
|
import { runtimeTierIssues } from './runtime-tier.ts';
|
|
26
28
|
import type { MemoryContext } from './memory-line.ts';
|
|
27
29
|
import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
|
|
28
30
|
import { admittedVerdict, policyVerdict, recordVerdict } from './policy-verdict.ts';
|
|
29
31
|
import type { Judged, PolicyVerdict } from './policy-verdict.ts';
|
|
30
32
|
import { deprecationReport } from './deprecations.ts';
|
|
33
|
+
import { currentSchemaSource } from './schema-source.ts';
|
|
31
34
|
import type { DeprecationReport } from './deprecations.ts';
|
|
32
35
|
|
|
33
36
|
/**
|
|
@@ -61,6 +64,9 @@ export interface ShardfileValidationPorts {
|
|
|
61
64
|
/** SHARD-COMPAT CP10: `'stored'` for a shard file already admitted (a stored original, an engine pin, a cook): memory
|
|
62
65
|
* and budget policy only reports, since it was judged at upload. Default `'upload'`: the policy refuses. */
|
|
63
66
|
readonly judged?: Judged;
|
|
67
|
+
/** 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
|
+
readonly armed?: boolean | ReadonlySet<string> | undefined;
|
|
64
70
|
/** D31: hold no file's bytes between checks. `assets`, here and in the result, reads each file again from `files`, so a
|
|
65
71
|
* host's peak is its largest file rather than the shard, at the cost of those repeat reads. */
|
|
66
72
|
readonly readThrough?: boolean;
|
|
@@ -124,20 +130,21 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
|
|
|
124
130
|
* A stored shard file (CP10, the context's `judged`) is never refused here: it was judged at its upload. */
|
|
125
131
|
export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse', context: MemoryContext = new Map()): PolicyVerdict {
|
|
126
132
|
// J412: the memory gates are ratchets; an issue in a zone not armed reports (`memory-armed.ts`) and is not thrown here.
|
|
127
|
-
const
|
|
133
|
+
const { armed } = memoryContext(context);
|
|
134
|
+
const found = [...staleRuntimeIssues(source.runtime, undefined, { ...source.identity, armed }), ...offlineMemoryIssues(source, context), ...runtimeTierIssues(source, armed), ...performanceTargetIssues(source, policy)];
|
|
128
135
|
const issues = found.filter(issue => issue.severity === 'refusal'), judged = memoryContext(context).judged ?? 'upload';
|
|
129
136
|
if (issues.length > 0 && judged === 'upload') throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
|
|
130
|
-
return policyVerdict(source.identity.slug, judged, found);
|
|
137
|
+
return policyVerdict(armedZone(source.identity.slug, armed), judged, found);
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/** Admit a whole shardfile's declared costs and its actual immutable bytes through the defining contracts. */
|
|
134
141
|
export function admitShardfileFolder(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
|
|
135
142
|
policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = [], context?: MemoryContext): Shardfile {
|
|
136
|
-
const { sections, judged } = context === undefined ? { sections: undefined, judged: undefined } : memoryContext(context);
|
|
143
|
+
const { sections, judged, armed } = context === undefined ? { sections: undefined, judged: undefined, armed: undefined } : memoryContext(context);
|
|
137
144
|
const source = coded('shard-schema', (): Shardfile => parseShardfile(input, sections));
|
|
138
|
-
coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy, judged)); });
|
|
145
|
+
coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy, judged, armed)); });
|
|
139
146
|
const verdict = coded('performance-targets', (): PolicyVerdict => assertShardfileTargets(source, policy, context));
|
|
140
|
-
return recordVerdict(coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy, judged), undefined, scripts, sections)), verdict);
|
|
147
|
+
return recordVerdict(coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy, judged, armed), undefined, scripts, sections)), verdict);
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
/** Refuse world target rows that name items or quests the shardfile does not declare. */
|
|
@@ -154,7 +161,7 @@ function inspectBlob(file: OutputFile, bytes: Uint8Array, ports: ShardfileValida
|
|
|
154
161
|
if (ports.definedJson !== undefined) ports.definedJson(validationSourceBytes(file.jsonSchema), bytes, file.name);
|
|
155
162
|
else if (contract === undefined || file.name === undefined) throw new Error('Unregistered named JSON with a schema needs a JSON Schema checker');
|
|
156
163
|
else {
|
|
157
|
-
if (file.jsonSchema['$comment'] !== contract.source) throw new Error('Registered JSON requires its exact defining format contract');
|
|
164
|
+
if (currentSchemaSource(file.jsonSchema['$comment']) !== contract.source) throw new Error('Registered JSON requires its exact defining format contract');
|
|
158
165
|
validateRegisteredJson(file.name, parseNamedJson(bytes));
|
|
159
166
|
}
|
|
160
167
|
}
|
|
@@ -250,8 +257,8 @@ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileV
|
|
|
250
257
|
coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
|
|
251
258
|
}
|
|
252
259
|
for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
|
|
253
|
-
const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages, index, judged: ports.judged ?? 'upload' });
|
|
260
|
+
const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages, index, judged: ports.judged ?? 'upload', armed: ports.armed });
|
|
254
261
|
checkWorldTargets(shard, payloads.get('world/targets'));
|
|
255
|
-
if (ports.hash(validationSourceBytes(shard)) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
|
|
256
|
-
return { index, shard, assets, sections: payloads, scripts, ...deprecationReport({ index, sections: payloads }, warnings), policy: admittedVerdict(shard), audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
|
|
262
|
+
if (ports.hash(validationSourceBytes(asWrittenIdentity(shard, index.formatVersion))) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
|
|
263
|
+
return { index, shard, assets, sections: payloads, scripts, ...deprecationReport({ index, sections: payloads, cook }, warnings), policy: admittedVerdict(shard), audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
|
|
257
264
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** FORMAT-PRUNE FP15: the species-program family's page features. OF30's cut B leaves the `species.program` client row
|
|
2
|
+
* and the `population.product-creatures` and `population.hull-book` plan features reading only what the family's
|
|
3
|
+
* sections held; each creature is a declared row now (ONE-FORMAT OF5b2b). The sections themselves are FE7 rows in
|
|
4
|
+
* `deprecations.ts`. No data migration exists: a shard drops the feature when it re-uploads (Track F), and FP20 deletes
|
|
5
|
+
* it at zero users. `legacyKinds` sits inside `actors/species-programs`, so that section's row counts it. */
|
|
6
|
+
|
|
7
|
+
/** The registry's row shape (`deprecations.ts`). */
|
|
8
|
+
interface SpeciesFeatureDeprecation {
|
|
9
|
+
readonly id: string
|
|
10
|
+
readonly path: string
|
|
11
|
+
readonly since: string
|
|
12
|
+
readonly replacement: string
|
|
13
|
+
readonly migration: undefined
|
|
14
|
+
readonly uses: (
|
|
15
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
16
|
+
) => boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The sections a page feature row can sit in. */
|
|
20
|
+
const FEATURE_SECTIONS: readonly string[] = ['client/plan', 'sim/runtime-plan']
|
|
21
|
+
const NONE = 0
|
|
22
|
+
|
|
23
|
+
/** Whether any object under `value` is a row of `kind`. */
|
|
24
|
+
function hasKind(value: unknown, kind: string): boolean {
|
|
25
|
+
const pending: unknown[] = [value]
|
|
26
|
+
while (pending.length > NONE) {
|
|
27
|
+
const next = pending.pop()
|
|
28
|
+
if (typeof next === 'object' && next !== null) {
|
|
29
|
+
if (!Array.isArray(next) && Reflect.get(next, 'kind') === kind) {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
const children: readonly unknown[] = Object.values(next)
|
|
33
|
+
pending.push(...children)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function featureRow(kind: string): SpeciesFeatureDeprecation {
|
|
40
|
+
return {
|
|
41
|
+
id: `feature.${kind}`,
|
|
42
|
+
path: `client/plan or sim/runtime-plan rows of kind ${kind} (the species-program family, FORMAT-PRUNE FP15)`,
|
|
43
|
+
since: '0.1.0.4',
|
|
44
|
+
replacement:
|
|
45
|
+
'declared creature rows (actors/creatures and their looks); the engine draws each from its row',
|
|
46
|
+
migration: undefined,
|
|
47
|
+
uses: (
|
|
48
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
49
|
+
): boolean =>
|
|
50
|
+
FEATURE_SECTIONS.some((name: string): boolean =>
|
|
51
|
+
hasKind(shard.sections.get(name), kind),
|
|
52
|
+
),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** OF30 cut B leaves these sections as plain JSON nothing reads. Deprecated at 0.1.0.1 (format `cda6f63`). */
|
|
57
|
+
const SPECIES_SECTION_DEPRECATIONS: readonly SpeciesFeatureDeprecation[] = [
|
|
58
|
+
'actors/species-programs',
|
|
59
|
+
'look/hull-book',
|
|
60
|
+
'look/rigged-hulls',
|
|
61
|
+
].map((name: string): SpeciesFeatureDeprecation => ({
|
|
62
|
+
id: `section.${name}`,
|
|
63
|
+
path: `sections/${name} (the species-program family, FORMAT-PRUNE FP15)`,
|
|
64
|
+
since: '0.1.0.1',
|
|
65
|
+
replacement:
|
|
66
|
+
'species rows and authored looks (actors/species); nothing reads it once OF30 lands',
|
|
67
|
+
migration: undefined,
|
|
68
|
+
uses: (
|
|
69
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
70
|
+
): boolean => shard.sections.has(name),
|
|
71
|
+
}))
|
|
72
|
+
|
|
73
|
+
const SPECIES_FEATURE_DEPRECATIONS: readonly SpeciesFeatureDeprecation[] = [
|
|
74
|
+
featureRow('species.program'),
|
|
75
|
+
featureRow('population.product-creatures'),
|
|
76
|
+
featureRow('population.hull-book'),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
export { SPECIES_FEATURE_DEPRECATIONS, SPECIES_SECTION_DEPRECATIONS }
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { assertMigrationCompatibility } from './migrations.ts';
|
|
3
3
|
import { StateSchema } from './state.ts';
|
|
4
|
+
import { oneSaveRevisionSpelling, saveRevisionOf } from './save-revision.ts';
|
|
4
5
|
import type { Shardfile } from './shardSchema.ts';
|
|
5
6
|
import { isJsonDataWithFileSchemas } from './json.ts';
|
|
6
7
|
import { IndexFormatVersionSchema, LegacyIndexVersionSchema } from './index-format-version.ts';
|
|
7
8
|
import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const lineageRevision = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(Number.MAX_SAFE_INTEGER));
|
|
11
|
+
// FORMAT-PRUNE FP26: a cached product of format 0.1.0.3 or older spells the save lineage `revision`; both read as `saveRevision`.
|
|
12
|
+
const identityRow = v.object({ slug: v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u)),
|
|
13
|
+
saveRevision: v.exactOptional(lineageRevision), revision: v.exactOptional(lineageRevision) });
|
|
14
|
+
function lineageIdentity(row: Readonly<v.InferOutput<typeof identityRow>>): StateLineage['identity'] { return { slug: row.slug, saveRevision: saveRevisionOf(row) }; }
|
|
15
|
+
const identity = v.pipe(identityRow, v.check(oneSaveRevisionSpelling, 'State lineage needs exactly one of saveRevision or revision'), v.transform(lineageIdentity));
|
|
11
16
|
const lineage: v.GenericSchema<StateLineageInput, StateLineage> = v.object({ identity, state: StateSchema });
|
|
12
17
|
|
|
13
18
|
/** Read only strict portable state and identity from a previously visited product. Its legacy geometry and scripts remain unadmitted. */
|
|
@@ -18,13 +23,15 @@ const measured = { path, hash: v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/u)),
|
|
|
18
23
|
bytes: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)) };
|
|
19
24
|
const lineageSchemas = v.exactOptional(v.pipe(v.array(v.strictObject(measured)), v.maxLength(128)));
|
|
20
25
|
// SHARD-COMPAT CP14: either envelope; 0.1.0.2 names its format in formatVersion and drops version and schemas.
|
|
21
|
-
const inventory = v.object({ format: v.literal('wildshard.shardfile'), formatVersion: IndexFormatVersionSchema,
|
|
26
|
+
const inventory = v.object({ format: v.literal('wildshard.shardfile'), formatVersion: IndexFormatVersionSchema,
|
|
27
|
+
// SHARD-COMPAT PR4: 0.1.0.3 drops `sdk` for `preparation`; the lineage reader needs neither.
|
|
28
|
+
sdk: v.exactOptional(v.picklist(['0.2', '0.3'])), preparation: v.exactOptional(v.unknown()),
|
|
22
29
|
version: LegacyIndexVersionSchema, identity,
|
|
23
30
|
sections: v.pipe(v.array(v.strictObject({ ...measured, name: v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9-]*\/[a-zA-Z][a-zA-Z0-9_-]*$/u)),
|
|
24
31
|
schema: v.pipe(v.string(), v.maxLength(240)) })), v.maxLength(256)),
|
|
25
32
|
schemas: lineageSchemas });
|
|
26
33
|
export interface OutputLineageIndex {
|
|
27
|
-
readonly identity: { readonly slug: string; readonly
|
|
34
|
+
readonly identity: { readonly slug: string; readonly saveRevision: number };
|
|
28
35
|
readonly sections: readonly { readonly path: string; readonly hash: string; readonly bytes: number; readonly name: string; readonly schema: string }[];
|
|
29
36
|
readonly schemas: readonly { readonly path: string; readonly hash: string; readonly bytes: number }[];
|
|
30
37
|
}
|
|
@@ -50,7 +57,7 @@ export function parseOutputLineageIndex(input: unknown): OutputLineageIndex {
|
|
|
50
57
|
/** Preserve saved field identities across validated author revisions; declaration ordering is immaterial. */
|
|
51
58
|
export function assertStateCompatibility(previous: StateLineage, next: Shardfile): void {
|
|
52
59
|
v.parse(v.literal(previous.identity.slug, 'State revisions must name the same shard'), next.identity.slug);
|
|
53
|
-
if (next.identity.
|
|
60
|
+
if (next.identity.saveRevision < previous.identity.saveRevision) throw new Error('State revisions cannot move backwards');
|
|
54
61
|
assertMigrationCompatibility(previous.state, next.state, next.migrations);
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -59,7 +66,8 @@ export function assertStateCompatibility(previous: StateLineage, next: Shardfile
|
|
|
59
66
|
interface StateLineageInputFields {
|
|
60
67
|
identity: {
|
|
61
68
|
slug: string;
|
|
62
|
-
|
|
69
|
+
saveRevision?: number;
|
|
70
|
+
revision?: number;
|
|
63
71
|
};
|
|
64
72
|
state: v.InferInput<typeof StateSchema>;
|
|
65
73
|
}
|
|
@@ -67,7 +75,7 @@ export type StateLineageInput = { [Key in keyof StateLineageInputFields]: StateL
|
|
|
67
75
|
interface StateLineageFields {
|
|
68
76
|
identity: {
|
|
69
77
|
slug: string;
|
|
70
|
-
|
|
78
|
+
saveRevision: number;
|
|
71
79
|
};
|
|
72
80
|
state: v.InferOutput<typeof StateSchema>;
|
|
73
81
|
}
|