@wildshard/shard-format 0.70.0 → 0.71.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/package.json +15 -3
  2. package/src/cli/corpus-candidate.ts +228 -0
  3. package/src/cli/corpus-command.ts +32 -3
  4. package/src/cli/corpus-pins.ts +73 -0
  5. package/src/cli/corpus-report.ts +36 -0
  6. package/src/cli/corpus-tar.ts +28 -0
  7. package/src/cli/corpus-usage.ts +24 -3
  8. package/src/cli/corpus.ts +50 -68
  9. package/src/cli/format-diff-range.ts +112 -0
  10. package/src/cli/main.ts +39 -9
  11. package/src/cli/pack.ts +20 -3
  12. package/src/cli/validate.ts +1 -1
  13. package/src/format/clientOwnership.ts +1 -1
  14. package/src/format/clientTrails.ts +121 -46
  15. package/src/format/cook-deprecations.ts +53 -0
  16. package/src/format/cook-preparation.ts +2 -1
  17. package/src/format/creature-rest-rig.ts +248 -0
  18. package/src/format/creature-skin-bounds.ts +146 -0
  19. package/src/format/deprecations.ts +18 -21
  20. package/src/format/edge-observations.ts +67 -0
  21. package/src/format/empty-shardfile.ts +4 -2
  22. package/src/format/entry-read-set.ts +147 -0
  23. package/src/format/format-migrate-rebuild.ts +4 -1
  24. package/src/format/format-migrate.ts +7 -1
  25. package/src/format/format-migration-envelope.ts +19 -0
  26. package/src/format/format-migration-prune.ts +42 -1
  27. package/src/format/format-migrations.ts +8 -1
  28. package/src/format/format-window.ts +71 -0
  29. package/src/format/immutable.ts +4 -1
  30. package/src/format/json-schema.ts +1468 -0
  31. package/src/format/lootEconomy.ts +4 -1
  32. package/src/format/mat4.ts +225 -0
  33. package/src/format/memory-armed.json +1 -9
  34. package/src/format/memory-armed.ts +46 -17
  35. package/src/format/memory-epoch.ts +10 -3
  36. package/src/format/memory-line.ts +17 -6
  37. package/src/format/outputFields.ts +3 -2
  38. package/src/format/outputIndex.ts +14 -1
  39. package/src/format/platformDataSections.ts +5 -0
  40. package/src/format/platformFileFamilies.ts +3 -3
  41. package/src/format/play-area.ts +95 -0
  42. package/src/format/policy-verdict.ts +12 -2
  43. package/src/format/registeredJson.ts +2 -2
  44. package/src/format/runtime-tier.ts +14 -7
  45. package/src/format/save-revision.ts +105 -0
  46. package/src/format/schema-source.ts +70 -0
  47. package/src/format/sections.ts +4 -1
  48. package/src/format/server-plan.ts +42 -0
  49. package/src/format/server-reads.ts +23 -0
  50. package/src/format/shardSchema.ts +9 -4
  51. package/src/format/shardSections.ts +17 -7
  52. package/src/format/shardfile-assets.ts +5 -5
  53. package/src/format/shardfile-stream-admit.ts +19 -10
  54. package/src/format/shardfile-stream-facts.ts +2 -1
  55. package/src/format/shardfile-stream.ts +2 -3
  56. package/src/format/shardfileValidation.ts +16 -9
  57. package/src/format/species-deprecations.ts +79 -0
  58. package/src/format/stateLineage.ts +12 -6
  59. package/src/format/tread-boxes.ts +65 -0
  60. package/src/format/vehicle-hulls.ts +124 -0
  61. package/src/format/version.ts +74 -17
  62. package/src/format/whole-inputs.ts +51 -0
  63. package/src/tools/runtime-hosts.json +4 -0
@@ -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
- slug: string | undefined,
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(slug),
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,
@@ -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/directorProduct#DirectorProductSchema'};
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/directorProduct#DirectorProductSchema'},
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(source: RuntimeTierSource): RuntimeTierIssue[] {
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(source.identity?.slug, 'runtime', {
39
- line: limit,
40
- actual,
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
+ }
@@ -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 { ShardfileVersion } from './version.ts';
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: ShardfileVersion;
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: ShardfileVersion;
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: ShardfileVersion;
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 type { ShardfileVersion } from './version.ts';
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
- export const IdentitySchema: v.GenericSchema<ShardIdentityInput, ShardIdentity> = 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)), revision: positive, seed: ShardNaturalSchema });
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
- revision: ShardNaturalInput;
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
- revision: ShardNatural;
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
- sdk: ShardfileVersion;
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: ShardfileVersion;
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
  }