@wildshard/shard-format 0.70.0 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -3
- package/src/cli/corpus-candidate.ts +228 -0
- package/src/cli/corpus-command.ts +32 -3
- 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 +24 -3
- package/src/cli/corpus.ts +50 -68
- package/src/cli/format-diff-range.ts +112 -0
- package/src/cli/main.ts +39 -9
- 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 +19 -1
- package/src/format/cook-deprecations.ts +53 -0
- package/src/format/cook-preparation.ts +2 -1
- package/src/format/creature-rest-rig.ts +248 -0
- package/src/format/creature-skin-bounds.ts +146 -0
- package/src/format/deprecations.ts +18 -21
- package/src/format/edge-observations.ts +67 -0
- package/src/format/empty-shardfile.ts +5 -3
- package/src/format/entry-read-set.ts +147 -0
- package/src/format/format-migrate-rebuild.ts +4 -1
- package/src/format/format-migrate.ts +7 -1
- package/src/format/format-migration-envelope.ts +19 -0
- package/src/format/format-migration-prune.ts +42 -1
- package/src/format/format-migrations.ts +8 -1
- package/src/format/format-window.ts +71 -0
- package/src/format/immutable.ts +4 -1
- package/src/format/json-schema.ts +1474 -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 +25 -8
- 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 +12 -1
- package/src/format/preparation-spec.ts +24 -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-assets.ts +11 -2
- 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 +12 -6
- package/src/format/tread-boxes.ts +65 -0
- package/src/format/vehicle-hulls.ts +124 -0
- package/src/format/version.ts +74 -17
- package/src/format/whole-inputs.ts +51 -0
- package/src/tools/runtime-hosts.json +4 -0
|
@@ -8,6 +8,7 @@ import { HeldJianDocumentSchema } from './heldJianDocument.ts';
|
|
|
8
8
|
import { BladeDocumentSchema, PolearmDocumentSchema, HeldSlotsDocumentSchema } from './heldWeaponDocuments.ts';
|
|
9
9
|
import { HeldBowFileSchema, HeldFirearmPageSchema } from './weaponProfiles.ts';
|
|
10
10
|
import { WaterWorldSchema } from './waterWorld.ts';
|
|
11
|
+
import { currentSchemaSource } from './schema-source.ts';
|
|
11
12
|
import { ForestNativeInputsSchema } from './forestNativeInputs.ts';
|
|
12
13
|
import { CaveFileSchema, CaveInteriorSchema } from './caveInterior.ts';
|
|
13
14
|
import { ForestGroundLayoutSchema, ForestPageSchema, LivingPageSitesSchema } from './forestPage.ts';
|
|
@@ -224,9 +225,8 @@ export const PLATFORM_FILE_FAMILIES: readonly PlatformFileFamily[] = [
|
|
|
224
225
|
source: '@wildshard/format/questInteractions#QuestPageInteractionsSchema', reader: 'src/game/quest/pageComposition.ts' },
|
|
225
226
|
{ pattern: /^quests\/services\.json$/u, schema: QuestServiceActionsSchema,
|
|
226
227
|
source: '@wildshard/format/questSteps#QuestServiceActionsSchema', reader: 'src/game/quest/effects.ts' },
|
|
227
|
-
// SA23: the source string is shard file data (each file's `jsonSchema.$comment`), so it keeps the old module name.
|
|
228
228
|
{ pattern: /^directors\/main\.json$/u, schema: DirectorDocumentSchema,
|
|
229
|
-
source: '@wildshard/format/
|
|
229
|
+
source: '@wildshard/format/directorDocument#DirectorDocumentSchema', reader: 'src/game/plugin/director.ts' },
|
|
230
230
|
{ pattern: /^quests\/panels\.json$/u, schema: QuestPanelCatalogueSchema,
|
|
231
231
|
source: '@wildshard/format/panelTemplate#QuestPanelCatalogueSchema', reader: 'src/game/ui/dataPanels.ts' },
|
|
232
232
|
{ pattern: /^world\/forest-weather\.json$/u, schema: ForestWeatherSchema,
|
|
@@ -283,7 +283,7 @@ export const PLATFORM_FILE_FAMILIES: readonly PlatformFileFamily[] = [
|
|
|
283
283
|
/** Match both logical name and defining schema identity. An unregistered or
|
|
284
284
|
* differently typed named JSON remains custom, even under a shared prefix. */
|
|
285
285
|
export function platformFileFamily(name: string, schemaSource: string | undefined): PlatformFileFamily | undefined {
|
|
286
|
-
const matches = PLATFORM_FILE_FAMILIES.filter(family => family.source === schemaSource && family.pattern.test(name));
|
|
286
|
+
const matches = PLATFORM_FILE_FAMILIES.filter(family => family.source === currentSchemaSource(schemaSource) && family.pattern.test(name));
|
|
287
287
|
if (matches.length > 1) throw new Error(`Ambiguous platform file family: ${name}`);
|
|
288
288
|
return matches[0];
|
|
289
289
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* oxlint-disable id-length, import/exports-last, import/group-exports, max-params, max-statements, no-magic-numbers -- x0/z1/x/z are the format's own bound field names and outerFloor keeps engine's (rows, floor, x, z) shape (SHARD-COMPAT PR6c) */
|
|
2
|
+
// SHARD-COMPAT PR6c (J487): a shard's play area (its x/z box and the fall floor at each spot) from the manifest's bounds
|
|
3
|
+
// under the `client/plan` rows that override them, so the page, the room and the MMO server read one rule without engine
|
|
4
|
+
// code. Moved from engine `src/shared/game/shardfile/playArea.ts` (SERVER-PARITY SS6): `player.enter` replaces the
|
|
5
|
+
// authored bounds (Sky Reach: floor -8, 250 m each way), `world.runtime-hooks` keeps the authored floor near the middle
|
|
6
|
+
// and drops it past a radius (Nine Dragon: -20 past 200 m), and the hooks win when a shard has both.
|
|
7
|
+
|
|
8
|
+
/** A rectangle and its fall floor, as a manifest or `player.enter` declares it. */
|
|
9
|
+
export interface PlayBounds {
|
|
10
|
+
readonly x0: number
|
|
11
|
+
readonly x1: number
|
|
12
|
+
readonly z0: number
|
|
13
|
+
readonly z1: number
|
|
14
|
+
readonly floor: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A `world.runtime-hooks` play area: its x/z, and the floor past `maxAbsXZ` from the origin. */
|
|
18
|
+
export interface RuntimeBoundsRows {
|
|
19
|
+
readonly x: readonly [number, number]
|
|
20
|
+
readonly z: readonly [number, number]
|
|
21
|
+
readonly outer: { readonly maxAbsXZ: number; readonly floor: number }
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** One `client/plan` feature row, as far as the play area reads it. */
|
|
25
|
+
export interface PlayAreaFeature {
|
|
26
|
+
readonly kind: string
|
|
27
|
+
readonly bounds?: PlayBounds | RuntimeBoundsRows
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Where a player may stand in a shard: an x/z box, and the fall floor at each spot in it. */
|
|
31
|
+
export interface PlayArea {
|
|
32
|
+
readonly x0: number
|
|
33
|
+
readonly x1: number
|
|
34
|
+
readonly z0: number
|
|
35
|
+
readonly z1: number
|
|
36
|
+
readonly floorAt: (x: number, z: number) => number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The floor at (x, z) under a runtime-hooks area: the authored floor inside `maxAbsXZ`, the outer floor past it. */
|
|
40
|
+
export function outerFloor(
|
|
41
|
+
rows: RuntimeBoundsRows,
|
|
42
|
+
authored: number,
|
|
43
|
+
x: number,
|
|
44
|
+
z: number,
|
|
45
|
+
): number {
|
|
46
|
+
return Math.max(Math.abs(x), Math.abs(z)) > rows.outer.maxAbsXZ
|
|
47
|
+
? rows.outer.floor
|
|
48
|
+
: authored
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isRuntime = (
|
|
52
|
+
bounds: PlayBounds | RuntimeBoundsRows,
|
|
53
|
+
): bounds is RuntimeBoundsRows => 'outer' in bounds
|
|
54
|
+
|
|
55
|
+
/** The play area the page selects for `authored` (the manifest's bounds) under the shard's `client/plan` features, or
|
|
56
|
+
* none. The runtime hooks install after `player.enter`, so theirs wins when a shard has both. */
|
|
57
|
+
export function declaredPlayArea(
|
|
58
|
+
authored: PlayBounds | undefined,
|
|
59
|
+
features: readonly PlayAreaFeature[],
|
|
60
|
+
): PlayArea | undefined {
|
|
61
|
+
let enter: PlayBounds | undefined = undefined
|
|
62
|
+
let hooks: RuntimeBoundsRows | undefined = undefined
|
|
63
|
+
for (const { kind, bounds } of features) {
|
|
64
|
+
if (bounds !== undefined && kind === 'player.enter' && !isRuntime(bounds)) {
|
|
65
|
+
enter = bounds
|
|
66
|
+
} else if (
|
|
67
|
+
bounds !== undefined &&
|
|
68
|
+
kind === 'world.runtime-hooks' &&
|
|
69
|
+
isRuntime(bounds)
|
|
70
|
+
) {
|
|
71
|
+
hooks = bounds
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (hooks !== undefined) {
|
|
75
|
+
// The page's hook keeps no area for a level that authors none (`runtimeLevelBounds`).
|
|
76
|
+
if (authored === undefined) {
|
|
77
|
+
return undefined
|
|
78
|
+
}
|
|
79
|
+
const rows = hooks
|
|
80
|
+
const { floor } = authored
|
|
81
|
+
return {
|
|
82
|
+
x0: rows.x[0],
|
|
83
|
+
x1: rows.x[1],
|
|
84
|
+
z0: rows.z[0],
|
|
85
|
+
z1: rows.z[1],
|
|
86
|
+
floorAt: (x: number, z: number): number => outerFloor(rows, floor, x, z),
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const bounds = enter ?? authored
|
|
90
|
+
if (bounds === undefined) {
|
|
91
|
+
return undefined
|
|
92
|
+
}
|
|
93
|
+
const { x0, x1, z0, z1, floor } = bounds
|
|
94
|
+
return { x0, x1, z0, z1, floorAt: (): number => floor }
|
|
95
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { zoneArmed } from './memory-armed.ts'
|
|
2
2
|
import { MEMORY_EPOCH } from './memory-epoch.ts'
|
|
3
3
|
|
|
4
|
+
import type { ZoneRef } from './memory-armed.ts'
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* SHARD-COMPAT CP10 (J486 D1.1, Jake 2026-11-21): memory lines, budgets and runtime targets judge a shard file once,
|
|
6
8
|
* at upload. The API stores this verdict and its rule version (the memory epoch) beside the original; a stored
|
|
@@ -10,6 +12,13 @@ import { MEMORY_EPOCH } from './memory-epoch.ts'
|
|
|
10
12
|
*/
|
|
11
13
|
type Judged = 'upload' | 'stored'
|
|
12
14
|
|
|
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). */
|
|
17
|
+
interface JudgedPorts {
|
|
18
|
+
readonly judged?: Judged | undefined
|
|
19
|
+
readonly armed?: boolean | ReadonlySet<string> | undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
interface PolicyIssue {
|
|
14
23
|
readonly code: string
|
|
15
24
|
readonly metric: string
|
|
@@ -29,14 +38,14 @@ interface PolicyVerdict {
|
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
function policyVerdict(
|
|
32
|
-
|
|
41
|
+
zone: ZoneRef,
|
|
33
42
|
judged: Judged,
|
|
34
43
|
issues: readonly PolicyIssue[],
|
|
35
44
|
): PolicyVerdict {
|
|
36
45
|
return {
|
|
37
46
|
judged,
|
|
38
47
|
epoch: MEMORY_EPOCH,
|
|
39
|
-
armed: zoneArmed(
|
|
48
|
+
armed: zoneArmed(zone),
|
|
40
49
|
issues: issues.map(
|
|
41
50
|
({ code, metric, actual, limit, severity }): PolicyIssue => ({
|
|
42
51
|
code,
|
|
@@ -85,6 +94,7 @@ function admittedVerdict(shard: Readonly<object>): PolicyVerdict {
|
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
export {
|
|
97
|
+
type JudgedPorts,
|
|
88
98
|
type Judged,
|
|
89
99
|
type PolicyIssue,
|
|
90
100
|
type PolicyVerdict,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/** The checks `requireCookPreparation` runs on a prepared file (SHARD-COMPAT PR4 and PR5, J487): the preparation
|
|
2
2
|
* marker against `cook.json`'s spec, the fence and the programs mount. */
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
isPreparationSpec,
|
|
5
|
+
preparationSpecOf,
|
|
6
|
+
unreadPreparationLine,
|
|
7
|
+
unreadPreparationSpec,
|
|
8
|
+
} from './preparation-spec.ts'
|
|
4
9
|
import { validationSourceBytes } from './validationReceipt.ts'
|
|
5
10
|
|
|
6
11
|
import type { AnyPrograms } from './cook-preparation.ts'
|
|
@@ -81,6 +86,12 @@ function preparationMarked(
|
|
|
81
86
|
version: number | undefined,
|
|
82
87
|
fix: string,
|
|
83
88
|
): boolean {
|
|
89
|
+
const unread = unreadPreparationSpec(index)
|
|
90
|
+
if (unread !== undefined) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
`shard.json names a newer preparation (${unreadPreparationLine(unread)}): update this reader or run ${fix}`,
|
|
93
|
+
)
|
|
94
|
+
}
|
|
84
95
|
const spec = preparationSpecOf(index)
|
|
85
96
|
const prepared = isPreparationSpec(version)
|
|
86
97
|
const refusal =
|
|
@@ -13,6 +13,9 @@ const PREPARATION_SPECS: readonly [
|
|
|
13
13
|
typeof PREPARATION_SPEC,
|
|
14
14
|
] = [LEGACY_PREPARATION_SPEC, PREPARATION_SPEC] as const
|
|
15
15
|
type PreparationSpec = (typeof PREPARATION_SPECS)[number]
|
|
16
|
+
/** SHARD-COMPAT SP1b1a: the highest spec a `shard.json` may name. A spec above `PREPARATION_SPEC` is a newer package's:
|
|
17
|
+
* this reader keeps its number and reads none of its lists (`unreadPreparationSpec`). */
|
|
18
|
+
const MAX_PREPARATION_SPEC = 255
|
|
16
19
|
/** The legacy `sdk` marker's prepared value, which always meant spec 3. */
|
|
17
20
|
const PREPARED_SDK = '0.3'
|
|
18
21
|
|
|
@@ -34,8 +37,29 @@ function preparationSpecOf(
|
|
|
34
37
|
return index.sdk === PREPARED_SDK ? LEGACY_PREPARATION_SPEC : undefined
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
/** SP1b1a: the spec a `shard.json` names above every spec this package reads, or `undefined`. A cook names such a file
|
|
41
|
+
* `stale preparation` with both numbers (`unreadPreparationLine`) instead of refusing its index. */
|
|
42
|
+
function unreadPreparationSpec(
|
|
43
|
+
index: Readonly<{ preparation?: unknown }>,
|
|
44
|
+
): number | undefined {
|
|
45
|
+
const spec = index.preparation
|
|
46
|
+
return typeof spec === 'number' &&
|
|
47
|
+
Number.isInteger(spec) &&
|
|
48
|
+
spec > PREPARATION_SPEC &&
|
|
49
|
+
spec <= MAX_PREPARATION_SPEC
|
|
50
|
+
? spec
|
|
51
|
+
: undefined
|
|
52
|
+
}
|
|
53
|
+
/** SP1b1a: `spec 5, reads 3 and 4`: what a file names beside what this package reads. */
|
|
54
|
+
function unreadPreparationLine(spec: number): string {
|
|
55
|
+
return `spec ${String(spec)}, reads ${PREPARATION_SPECS.join(' and ')}`
|
|
56
|
+
}
|
|
57
|
+
|
|
37
58
|
export {
|
|
38
59
|
LEGACY_PREPARATION_SPEC,
|
|
60
|
+
MAX_PREPARATION_SPEC,
|
|
61
|
+
unreadPreparationLine,
|
|
62
|
+
unreadPreparationSpec,
|
|
39
63
|
PREPARATION_SPEC,
|
|
40
64
|
PREPARATION_SPECS,
|
|
41
65
|
PREPARED_SDK,
|
|
@@ -128,7 +128,7 @@ export interface RegisteredJsonContracts {
|
|
|
128
128
|
readonly 'world/dressing-phone.json':{readonly schema:typeof SceneDressingSchema;readonly source:'@wildshard/format/sceneDressing#SceneDressingSchema'};
|
|
129
129
|
readonly 'world/building-sites.json':{readonly schema:typeof LivingPageSitesSchema;readonly source:'@wildshard/format/forestPage#LivingPageSitesSchema'};
|
|
130
130
|
readonly 'models/shape-book.json':{readonly schema:typeof FixedDrawRowsSchema;readonly source:'@wildshard/format/fixedDraws#FixedDrawRowsSchema'};
|
|
131
|
-
readonly 'directors/main.json':{readonly schema:typeof DirectorDocumentSchema;readonly source:'@wildshard/format/
|
|
131
|
+
readonly 'directors/main.json':{readonly schema:typeof DirectorDocumentSchema;readonly source:'@wildshard/format/directorDocument#DirectorDocumentSchema'};
|
|
132
132
|
readonly 'scenes/cascade.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
|
|
133
133
|
readonly 'scenes/cove.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
|
|
134
134
|
readonly 'scenes/hibiscus.json':{readonly schema:typeof WorldSceneSchema;readonly source:'@wildshard/format/clientChannels#WorldSceneSchema'};
|
|
@@ -250,7 +250,7 @@ export const REGISTERED_JSON:RegisteredJsonContracts = {
|
|
|
250
250
|
'world/dressing-phone.json':{schema:SceneDressingSchema,source:'@wildshard/format/sceneDressing#SceneDressingSchema'},
|
|
251
251
|
'world/building-sites.json':{schema:LivingPageSitesSchema,source:'@wildshard/format/forestPage#LivingPageSitesSchema'},
|
|
252
252
|
'models/shape-book.json':{schema:FixedDrawRowsSchema,source:'@wildshard/format/fixedDraws#FixedDrawRowsSchema'},
|
|
253
|
-
'directors/main.json':{schema:DirectorDocumentSchema,source:'@wildshard/format/
|
|
253
|
+
'directors/main.json':{schema:DirectorDocumentSchema,source:'@wildshard/format/directorDocument#DirectorDocumentSchema'},
|
|
254
254
|
'scenes/cascade.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
|
|
255
255
|
'scenes/cove.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
|
|
256
256
|
'scenes/hibiscus.json':{schema:WorldSceneSchema,source:'@wildshard/format/clientChannels#WorldSceneSchema'},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UNNAMED_TIER, budgetTierLimits } from './budget-tiers.ts'
|
|
2
|
-
import { ratchetNote, ratchetSeverity } from './memory-armed.ts'
|
|
2
|
+
import { armedZone, ratchetNote, ratchetSeverity } from './memory-armed.ts'
|
|
3
3
|
import { runtimeAccountedBytes } from './runtimeCost.ts'
|
|
4
4
|
|
|
5
5
|
import type { BudgetTier } from './budget-tiers.ts'
|
|
@@ -24,7 +24,10 @@ interface RuntimeTierIssue {
|
|
|
24
24
|
* ONE-FORMAT OF10c1a and J445: report a runtime's accounted bytes above its
|
|
25
25
|
* named memory tier. A runtime with no named tier uses the large target.
|
|
26
26
|
*/
|
|
27
|
-
function runtimeTierIssues(
|
|
27
|
+
function runtimeTierIssues(
|
|
28
|
+
source: RuntimeTierSource,
|
|
29
|
+
armed?: boolean | ReadonlySet<string>,
|
|
30
|
+
): RuntimeTierIssue[] {
|
|
28
31
|
const cost = source.runtime?.cost ?? source.budgets.client
|
|
29
32
|
if (source.runtime === null || cost === undefined) {
|
|
30
33
|
return []
|
|
@@ -35,14 +38,18 @@ function runtimeTierIssues(source: RuntimeTierSource): RuntimeTierIssue[] {
|
|
|
35
38
|
if (actual <= limit) {
|
|
36
39
|
return []
|
|
37
40
|
}
|
|
38
|
-
const severity = ratchetSeverity(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const severity = ratchetSeverity(
|
|
42
|
+
armedZone(source.identity?.slug, armed),
|
|
43
|
+
'runtime',
|
|
44
|
+
{
|
|
45
|
+
line: limit,
|
|
46
|
+
actual,
|
|
47
|
+
},
|
|
48
|
+
)
|
|
42
49
|
return [
|
|
43
50
|
{
|
|
44
51
|
code: 'runtime-tier-memory',
|
|
45
|
-
metric: `runtime accounted bytes over the ${tier} tier's memory (OF10c1a: name a larger tier or shrink the runtime)${severity === 'warning' ? ratchetNote(source.identity?.slug) : ''}`,
|
|
52
|
+
metric: `runtime accounted bytes over the ${tier} tier's memory (OF10c1a: name a larger tier or shrink the runtime)${severity === 'warning' ? ratchetNote(armedZone(source.identity?.slug, armed)) : ''}`,
|
|
46
53
|
actual,
|
|
47
54
|
limit,
|
|
48
55
|
severity,
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { validationSourceBytes } from './validationReceipt.ts'
|
|
2
|
+
import { writesSaveRevision } from './version.ts'
|
|
3
|
+
|
|
4
|
+
/** FORMAT-PRUNE FP26 (J493): from format 0.1.0.4 the save lineage `identity.revision` is spelled `identity.saveRevision`. */
|
|
5
|
+
const SAVE_REVISION = '0.1.0.4'
|
|
6
|
+
|
|
7
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** A copy of `row` with its key `from` named `to`, every other key as it is. */
|
|
12
|
+
function renamedKey(
|
|
13
|
+
row: Readonly<Record<string, unknown>>,
|
|
14
|
+
from: string,
|
|
15
|
+
to: string,
|
|
16
|
+
): Record<string, unknown> {
|
|
17
|
+
const entries = Object.entries(row)
|
|
18
|
+
const renamed = entries.map(
|
|
19
|
+
([key, item]: readonly [string, unknown]): readonly [string, unknown] => [
|
|
20
|
+
key === from ? to : key,
|
|
21
|
+
item,
|
|
22
|
+
],
|
|
23
|
+
)
|
|
24
|
+
return Object.fromEntries(renamed)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** FP26: what a file's hashes cover keeps the identity as its format wrote it. Below 0.1.0.4 that is `revision`: the
|
|
28
|
+
* source hash and the cook preparation's inputs were taken over those bytes, so an older file still matches its own.
|
|
29
|
+
* `formatVersion` is the index's (`2` for the legacy envelope). */
|
|
30
|
+
function asWrittenIdentity(value: object, formatVersion: unknown): unknown {
|
|
31
|
+
if (typeof formatVersion === 'string' && writesSaveRevision(formatVersion)) {
|
|
32
|
+
return value
|
|
33
|
+
}
|
|
34
|
+
const identity: unknown = Reflect.get(value, 'identity')
|
|
35
|
+
if (!isRecord(identity) || !Object.hasOwn(identity, 'saveRevision')) {
|
|
36
|
+
return value
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
...value,
|
|
40
|
+
identity: renamedKey(identity, 'saveRevision', 'revision'),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface SaveRevisionSpellings<Revision> {
|
|
45
|
+
readonly saveRevision?: Revision
|
|
46
|
+
readonly revision?: Revision
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** FP26: a row gives exactly one spelling of the save lineage. */
|
|
50
|
+
function oneSaveRevisionSpelling<Revision>(
|
|
51
|
+
row: Readonly<SaveRevisionSpellings<Revision>>,
|
|
52
|
+
): boolean {
|
|
53
|
+
return (row.saveRevision === undefined) !== (row.revision === undefined)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** FP26: the save lineage, under whichever spelling the row gave it. */
|
|
57
|
+
function saveRevisionOf<Revision>(
|
|
58
|
+
row: Readonly<SaveRevisionSpellings<Revision>>,
|
|
59
|
+
): Revision {
|
|
60
|
+
const value = row.saveRevision ?? row.revision
|
|
61
|
+
if (value === undefined) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
'The identity needs exactly one of saveRevision or revision',
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
return value
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The deprecation row for the old spelling (`deprecations.ts` lists it). */
|
|
70
|
+
interface SaveRevisionDeprecation {
|
|
71
|
+
readonly id: string
|
|
72
|
+
readonly path: string
|
|
73
|
+
readonly since: string
|
|
74
|
+
readonly replacement: string
|
|
75
|
+
readonly migration: string
|
|
76
|
+
readonly uses: (shard: Readonly<{ index: unknown }>) => boolean
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** FP26: the canonical bytes a source hash covers, the identity spelled as `formatVersion` wrote it. */
|
|
80
|
+
function writtenSourceBytes(value: object, formatVersion: unknown): Uint8Array {
|
|
81
|
+
return validationSourceBytes(asWrittenIdentity(value, formatVersion))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const SAVE_REVISION_DEPRECATION: SaveRevisionDeprecation = {
|
|
85
|
+
id: 'identity.revision',
|
|
86
|
+
path: 'shard.json identity.revision, the save lineage (FORMAT-PRUNE FP26, J493)',
|
|
87
|
+
since: SAVE_REVISION,
|
|
88
|
+
replacement:
|
|
89
|
+
'identity.saveRevision: the same number under its own name, so it is never read as the API shard revision',
|
|
90
|
+
migration: 'fp26-save-revision',
|
|
91
|
+
uses: (shard: Readonly<{ index: unknown }>): boolean => {
|
|
92
|
+
const identity: unknown = isRecord(shard.index)
|
|
93
|
+
? shard.index['identity']
|
|
94
|
+
: undefined
|
|
95
|
+
return isRecord(identity) && identity['revision'] !== undefined
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
SAVE_REVISION_DEPRECATION,
|
|
101
|
+
asWrittenIdentity,
|
|
102
|
+
oneSaveRevisionSpelling,
|
|
103
|
+
saveRevisionOf,
|
|
104
|
+
writtenSourceBytes,
|
|
105
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** FORMAT-PRUNE FP10: each named JSON file's `jsonSchema.$comment` names the format module that defines it. A module
|
|
2
|
+
* renamed after files shipped leaves a stale id in shard data; the chain step `fp10-schema-source` rewrites it, and
|
|
3
|
+
* until every kept file is mended (FE7 counts `schema-source.retired`), readers take the old id as the new one. The
|
|
4
|
+
* map empties, and this file goes, at FP22. */
|
|
5
|
+
|
|
6
|
+
/** Retired id to current id. */
|
|
7
|
+
const RETIRED_SCHEMA_SOURCES: Readonly<Record<string, string>> = {
|
|
8
|
+
// SA23 kept the old id because it was shard data; the module is directorDocument.
|
|
9
|
+
'@wildshard/format/directorProduct#DirectorProductSchema':
|
|
10
|
+
'@wildshard/format/directorDocument#DirectorDocumentSchema',
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The current id for `source`, retired or not. */
|
|
14
|
+
function currentSchemaSource(source: unknown): unknown {
|
|
15
|
+
if (
|
|
16
|
+
typeof source === 'string' &&
|
|
17
|
+
Object.hasOwn(RETIRED_SCHEMA_SOURCES, source)
|
|
18
|
+
) {
|
|
19
|
+
return RETIRED_SCHEMA_SOURCES[source]
|
|
20
|
+
}
|
|
21
|
+
return source
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Whether `source` is a retired id. */
|
|
25
|
+
function retiredSchemaSource(source: unknown): boolean {
|
|
26
|
+
return (
|
|
27
|
+
typeof source === 'string' && Object.hasOwn(RETIRED_SCHEMA_SOURCES, source)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** FE7's row for FP10, in the registry's shape (`deprecations.ts`). */
|
|
32
|
+
interface SchemaSourceDeprecation {
|
|
33
|
+
readonly id: string
|
|
34
|
+
readonly path: string
|
|
35
|
+
readonly since: string
|
|
36
|
+
readonly replacement: string
|
|
37
|
+
readonly migration: string
|
|
38
|
+
readonly uses: (shard: Readonly<{ index: unknown }>) => boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function field(value: unknown, key: string): unknown {
|
|
42
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
43
|
+
? Reflect.get(value, key)
|
|
44
|
+
: undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const SCHEMA_SOURCE_DEPRECATION: SchemaSourceDeprecation = {
|
|
48
|
+
id: 'schema-source.retired',
|
|
49
|
+
path: 'shard.json files[].jsonSchema.$comment naming a retired module (FORMAT-PRUNE FP10)',
|
|
50
|
+
since: '0.1.0.4',
|
|
51
|
+
replacement:
|
|
52
|
+
'the current defining module, e.g. @wildshard/format/directorDocument#DirectorDocumentSchema',
|
|
53
|
+
migration: 'fp10-schema-source',
|
|
54
|
+
uses: (shard: Readonly<{ index: unknown }>): boolean => {
|
|
55
|
+
const files = field(shard.index, 'files')
|
|
56
|
+
return (
|
|
57
|
+
Array.isArray(files) &&
|
|
58
|
+
files.some((file: unknown): boolean =>
|
|
59
|
+
retiredSchemaSource(field(field(file, 'jsonSchema'), '$comment')),
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
RETIRED_SCHEMA_SOURCES,
|
|
67
|
+
SCHEMA_SOURCE_DEPRECATION,
|
|
68
|
+
currentSchemaSource,
|
|
69
|
+
retiredSchemaSource,
|
|
70
|
+
}
|
package/src/format/sections.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type { ToonLookRow } from './toonLook.ts';
|
|
|
10
10
|
import type { KeyedSkyStyle } from './keyedSky.ts';
|
|
11
11
|
import type { SpawnScriptRows } from './spawnScripts.ts';
|
|
12
12
|
import type { ClientPlan } from './clientPlan.ts';
|
|
13
|
+
import type { ServerPlan } from './server-plan.ts';
|
|
13
14
|
import type { NativeSweptPolicyRows } from './items.ts';
|
|
14
15
|
import type { ReturnModuleRow, ViewModuleRow } from './scriptContract.ts';
|
|
15
16
|
import type { WorldScenesSection } from './worldScenes.ts';
|
|
@@ -63,6 +64,8 @@ export interface PlatformSections {
|
|
|
63
64
|
'look/keyed-sky': KeyedSkyStyle;
|
|
64
65
|
/** Client-only compiled feature declarations; ignored by the authoritative simulation. */
|
|
65
66
|
'client/plan': ClientPlan;
|
|
67
|
+
/** SHARD-COMPAT HS6b: the feature rows the server reads, written beside `client/plan` so the page's plan is the page's. */
|
|
68
|
+
'server/plan': ServerPlan;
|
|
66
69
|
'held/arms': HeldArmsRows;
|
|
67
70
|
'held/gear': HeldGearRows;
|
|
68
71
|
'held/finishes': HeldFinishesRows;
|
|
@@ -75,7 +78,7 @@ export interface PlatformSections {
|
|
|
75
78
|
'sim/runtime-plan': NativeRuntimePlanData;
|
|
76
79
|
'world/tiles': Pick<Shardfile, 'tiles' | 'far' | 'near' | 'ring'>;
|
|
77
80
|
'world/terrain': Pick<Shardfile, 'terrain' | 'nativeGround'>;
|
|
78
|
-
'world/edge': Pick<Shardfile, 'edge' | 'entryways'>;
|
|
81
|
+
'world/edge': Pick<Shardfile, 'edge' | 'entryways' | 'edgeObservations'>;
|
|
79
82
|
'world/collision': Pick<Shardfile, 'meshCollision'>;
|
|
80
83
|
'world/navigation': Pick<Shardfile, 'navigation'>;
|
|
81
84
|
'world/props': Pick<Shardfile, 'props'>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** SHARD-COMPAT HS6b (meta): `server/plan`, the server's own copy of the feature rows, so `client/plan` stays the page's.
|
|
2
|
+
* The SDK writes it from the parsed `client/plan` (HS6d) and the engine's server parses each row with the client plan's
|
|
3
|
+
* own schema at its seam (HS6c); here it is held to the shape that projects to JSON Schema (FP9): a version and up to 64
|
|
4
|
+
* rows, each naming its kind. */
|
|
5
|
+
import {
|
|
6
|
+
array,
|
|
7
|
+
literal,
|
|
8
|
+
looseObject,
|
|
9
|
+
maxLength,
|
|
10
|
+
pipe,
|
|
11
|
+
strictObject,
|
|
12
|
+
string,
|
|
13
|
+
} from 'valibot'
|
|
14
|
+
|
|
15
|
+
import type { GenericSchema } from 'valibot'
|
|
16
|
+
|
|
17
|
+
/** The section's only version. */
|
|
18
|
+
const VERSION = 1
|
|
19
|
+
/** The most feature rows a plan holds, as `client/plan`'s schema caps them. */
|
|
20
|
+
const MAX_FEATURES = 64
|
|
21
|
+
|
|
22
|
+
/** One feature row as the section holds it: its kind and its settings. */
|
|
23
|
+
interface ServerPlanRow {
|
|
24
|
+
readonly kind: string
|
|
25
|
+
readonly [key: string]: unknown
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The section's value. */
|
|
29
|
+
interface ServerPlan {
|
|
30
|
+
readonly version: typeof VERSION
|
|
31
|
+
readonly features: readonly ServerPlanRow[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const RowSchema = looseObject({ kind: string() })
|
|
35
|
+
const RowsSchema = pipe(array(RowSchema), maxLength(MAX_FEATURES))
|
|
36
|
+
|
|
37
|
+
const ServerPlanSchema: GenericSchema<unknown, ServerPlan> = strictObject({
|
|
38
|
+
version: literal(VERSION),
|
|
39
|
+
features: RowsSchema,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
export { type ServerPlan, type ServerPlanRow, ServerPlanSchema }
|
|
@@ -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>;
|