@wildshard/shard-format 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/format/assetAdmission.ts +3 -2
- package/src/format/creature-sizes.ts +106 -0
- package/src/format/deviceMemoryCost.ts +2 -1
- package/src/format/memory-epoch.ts +57 -0
- package/src/format/memory-line.ts +68 -0
- package/src/format/memoryAdmission.ts +4 -1
- package/src/format/rows.ts +2 -1
- package/src/format/runtimeCost.ts +6 -1
- package/src/format/shardSchema.ts +2 -0
- package/src/format/shardfile-assets.ts +12 -7
- package/src/format/shardfileValidation.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"./creaturePerch": "./src/format/creature-perch.ts",
|
|
108
108
|
"./creatureLayers": "./src/format/creature-layers.ts",
|
|
109
109
|
"./creatureVolumes": "./src/format/creature-volumes.ts",
|
|
110
|
+
"./creatureSizes": "./src/format/creature-sizes.ts",
|
|
110
111
|
"./creatureSkeletons": "./src/format/creature-skeletons.ts",
|
|
111
112
|
"./crowdPresentation": "./src/format/crowdPresentation.ts",
|
|
112
113
|
"./crowds": "./src/format/crowds.ts",
|
|
@@ -2,6 +2,7 @@ import { acceptsShardfileCost, textureLibrarySource } from './deviceMemoryCost.t
|
|
|
2
2
|
import { creaturePerchAdmissionRows } from './creature-perch.ts';
|
|
3
3
|
import { admitScriptContract, decisionModuleContracts, type ScriptAdmissionRows } from './scriptContract.ts';
|
|
4
4
|
import type { TextureTranscodeSupport } from './contentBounds.ts';
|
|
5
|
+
import { overHardLine } from './memory-line.ts';
|
|
5
6
|
import { admitScript } from './scriptAdmission.ts';
|
|
6
7
|
import { SCRIPT_LIMITS } from './scriptLimits.ts';
|
|
7
8
|
import { worstContentCost } from './budget.ts';
|
|
@@ -64,7 +65,7 @@ function preflightDeclaredCosts(source: Shardfile, memory?: MemoryAdmission): {
|
|
|
64
65
|
}
|
|
65
66
|
const resident = Object.values(commons).reduce((total, cost) => total + cost.decoded + cost.gpu, 0);
|
|
66
67
|
const worst = worstContentCost(source, resident);
|
|
67
|
-
if (!acceptsShardfileCost(memory, source, 'declared', worst)) throw new Error(`declared worst-location total exceeds envelope: ${worst.playing}`);
|
|
68
|
+
if (!acceptsShardfileCost(memory, source, 'declared', worst)) throw new Error(`declared worst-location total exceeds envelope: play ${worst.playing}, load ${worst.loading}${overHardLine(Math.max(worst.playing, worst.loading))}`);
|
|
68
69
|
return { commons, worst };
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -251,7 +252,7 @@ function admitAfterFiles(state: AssetAdmission, assets: ReadonlyMap<string, Uint
|
|
|
251
252
|
if (clientModules.size + new Set(scripts.filter(row => row.side === 'view').map(row => row.module)).size > SCRIPT_LIMITS.instances || clientMemory > SCRIPT_LIMITS.memoryBytes || libraryResident > s.budgets.library.resident) throw new Error('client script memory or view budget understated or above host cap');
|
|
252
253
|
if (libraryResident + sketchResident > s.budgets.library.resident) throw new Error('compendium sketch raster budget understated');
|
|
253
254
|
const cost = worstContentCost(textureLibrarySource(s, assets, textures), commons);
|
|
254
|
-
if (!acceptsShardfileCost(memory, s, 'actual', cost)) throw new Error(`worst-location total exceeds envelope: ${cost.playing}`);
|
|
255
|
+
if (!acceptsShardfileCost(memory, s, 'actual', cost)) throw new Error(`worst-location total exceeds envelope: play ${cost.playing}, load ${cost.loading}${overHardLine(Math.max(cost.playing, cost.loading))}`);
|
|
255
256
|
validateNavigationAssets(s, assets);
|
|
256
257
|
validateNativeGround(s, assets);
|
|
257
258
|
validateEntrywayTerrain(s, assets);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { CreatureBody, CreatureSize } from './creature-layers.ts'
|
|
2
|
+
|
|
3
|
+
interface CreatureSizePolicy {
|
|
4
|
+
readonly scale: number
|
|
5
|
+
readonly stride: number
|
|
6
|
+
readonly aggro: number
|
|
7
|
+
readonly cellWeight: number
|
|
8
|
+
readonly maxHeight?: number
|
|
9
|
+
}
|
|
10
|
+
const GIANT_HEIGHT = 15
|
|
11
|
+
const DEFAULT_SCALE = 1
|
|
12
|
+
const BODY_HEIGHT_FACTOR = 2
|
|
13
|
+
const MAX_VARIANT_SCALE = 1
|
|
14
|
+
/** Medium preserves the authored model units. Free body and spawn scales apply
|
|
15
|
+
* after the class; stride/aggro are independent multipliers, not extra geometry. */
|
|
16
|
+
const CREATURE_SIZES: Readonly<Record<CreatureSize, CreatureSizePolicy>> = {
|
|
17
|
+
tiny: { scale: 0.25, stride: 0.5, aggro: 0.5, cellWeight: 0.25 },
|
|
18
|
+
small: { scale: 0.5, stride: 0.75, aggro: 0.75, cellWeight: 0.5 },
|
|
19
|
+
medium: { scale: 1, stride: 1, aggro: 1, cellWeight: 1 },
|
|
20
|
+
large: { scale: 2, stride: 1.5, aggro: 1.5, cellWeight: 4 },
|
|
21
|
+
giant: {
|
|
22
|
+
scale: 4,
|
|
23
|
+
stride: 2,
|
|
24
|
+
aggro: 2,
|
|
25
|
+
cellWeight: 16,
|
|
26
|
+
maxHeight: GIANT_HEIGHT,
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
type SizeBody = Pick<CreatureBody, 'size' | 'scale'>
|
|
30
|
+
interface CreatureDimensions {
|
|
31
|
+
readonly bodyY: number
|
|
32
|
+
readonly bodyRadius: number
|
|
33
|
+
readonly headRadius: number
|
|
34
|
+
}
|
|
35
|
+
interface SizedSpecies {
|
|
36
|
+
readonly id: string
|
|
37
|
+
readonly body?: SizeBody
|
|
38
|
+
readonly dims: CreatureDimensions
|
|
39
|
+
readonly variants: readonly { readonly scale: readonly [number, number] }[]
|
|
40
|
+
}
|
|
41
|
+
interface SizedSpawn {
|
|
42
|
+
readonly id: string
|
|
43
|
+
readonly species: string
|
|
44
|
+
readonly scale: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function creatureScale(
|
|
48
|
+
body: SizeBody | undefined,
|
|
49
|
+
spawnScale: number = DEFAULT_SCALE,
|
|
50
|
+
): number {
|
|
51
|
+
return (
|
|
52
|
+
spawnScale *
|
|
53
|
+
(body === undefined
|
|
54
|
+
? DEFAULT_SCALE
|
|
55
|
+
: CREATURE_SIZES[body.size].scale * body.scale)
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
/** The declared dimensions' conservative upright envelope. Rig/mesh admission
|
|
59
|
+
* checks its actual transformed bounds separately; dimensions cannot waive it. */
|
|
60
|
+
function creatureHeight(
|
|
61
|
+
body: SizeBody,
|
|
62
|
+
dims: CreatureDimensions,
|
|
63
|
+
spawnScale: number,
|
|
64
|
+
): number {
|
|
65
|
+
const modelHeight = Math.max(
|
|
66
|
+
dims.bodyY * BODY_HEIGHT_FACTOR + dims.headRadius,
|
|
67
|
+
dims.bodyY + dims.bodyRadius,
|
|
68
|
+
)
|
|
69
|
+
return modelHeight * creatureScale(body, spawnScale)
|
|
70
|
+
}
|
|
71
|
+
function speciesSizeRules(
|
|
72
|
+
row: SizedSpecies,
|
|
73
|
+
spawns: readonly SizedSpawn[],
|
|
74
|
+
): string[] {
|
|
75
|
+
const { body } = row
|
|
76
|
+
if (body === undefined) {
|
|
77
|
+
return []
|
|
78
|
+
}
|
|
79
|
+
const cap = CREATURE_SIZES[body.size].maxHeight
|
|
80
|
+
if (cap === undefined) {
|
|
81
|
+
return []
|
|
82
|
+
}
|
|
83
|
+
const oversized = row.variants.some(
|
|
84
|
+
(variant): boolean =>
|
|
85
|
+
creatureHeight(body, row.dims, variant.scale[MAX_VARIANT_SCALE]) > cap,
|
|
86
|
+
)
|
|
87
|
+
const errors = oversized ? [`species ${row.id}: giant exceeds ${cap} m`] : []
|
|
88
|
+
return [
|
|
89
|
+
...errors,
|
|
90
|
+
...spawns.flatMap((spawn): string[] =>
|
|
91
|
+
spawn.species === row.id &&
|
|
92
|
+
creatureHeight(body, row.dims, spawn.scale) > cap
|
|
93
|
+
? [`spawn ${spawn.id}: giant exceeds ${cap} m`]
|
|
94
|
+
: [],
|
|
95
|
+
),
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
function creatureSizeRules(
|
|
99
|
+
species: readonly SizedSpecies[],
|
|
100
|
+
spawns: readonly SizedSpawn[] = [],
|
|
101
|
+
): string[] {
|
|
102
|
+
return species.flatMap((row): string[] => speciesSizeRules(row, spawns))
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { CREATURE_SIZES, creatureScale, creatureHeight, creatureSizeRules }
|
|
106
|
+
export type { CreatureSizePolicy }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CONTENT_CAPS as C, type TextureTranscodeSupport } from './contentBounds.ts';
|
|
2
|
+
import { overHardLine } from './memory-line.ts';
|
|
2
3
|
import { worstContentCostSteps, type worstContentCost } from './budget.ts';
|
|
3
4
|
import type { Shardfile } from './shardSchema.ts';
|
|
4
5
|
import type { MemoryAdmission } from './memoryAdmission.ts';
|
|
@@ -13,7 +14,7 @@ export function acceptsShardfileCost(memory: MemoryAdmission | undefined, source
|
|
|
13
14
|
|
|
14
15
|
/** Reapply the current trusted memory policy to a previously validated exact declaration. */
|
|
15
16
|
export function acceptValidatedCost(source: Shardfile, cost: ReturnType<typeof worstContentCost>, memory?: MemoryAdmission): void {
|
|
16
|
-
if (!acceptsShardfileCost(memory, source, 'declared', cost)) throw new Error(`declared worst-location total exceeds envelope: ${cost.playing}`);
|
|
17
|
+
if (!acceptsShardfileCost(memory, source, 'declared', cost)) throw new Error(`declared worst-location total exceeds envelope: play ${cost.playing}, load ${cost.loading}${overHardLine(Math.max(cost.playing, cost.loading))}`);
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/** Device cost projection after byte admission; source ceilings retain their full RGBA fallback. A KTX2 file's declared
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** MEMORY-GATES MG5 (J408, Jake 2026-11-17: "a stale runtimeCost is refused"): the memory model a runtime home's
|
|
2
|
+
* `runtimeCost` reading must have been taken against. It rises when the model changes what it charges (MG6 adds shader
|
|
3
|
+
* compile, load transients, far slabs and paint arrays); from then a reading from an older epoch is refused until the
|
|
4
|
+
* shard re-measures. A reading with no `epoch` is epoch 1, the model before MG6. */
|
|
5
|
+
const MEMORY_EPOCH = 1
|
|
6
|
+
const LEGACY_EPOCH = 1
|
|
7
|
+
|
|
8
|
+
interface EpochRow {
|
|
9
|
+
readonly epoch?: number | undefined
|
|
10
|
+
readonly imagesFirst?: EpochRow | undefined
|
|
11
|
+
}
|
|
12
|
+
interface StaleRuntimeIssue {
|
|
13
|
+
readonly code: 'perf-native-resident-unmeasured'
|
|
14
|
+
readonly metric: string
|
|
15
|
+
readonly actual: number
|
|
16
|
+
readonly limit: number
|
|
17
|
+
readonly severity: 'refusal'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Why a runtime reading is stale against `current`, or empty when it is current. */
|
|
21
|
+
function staleRuntimeCost(
|
|
22
|
+
row: EpochRow,
|
|
23
|
+
current: number = MEMORY_EPOCH,
|
|
24
|
+
): string {
|
|
25
|
+
const epoch = row.epoch ?? LEGACY_EPOCH
|
|
26
|
+
if (epoch >= current) {
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
29
|
+
return `native resident measurement is stale: memory epoch ${String(epoch)}, current ${String(current)} (J408): re-measure the runtime home`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A refusal, whatever the policy, for a runtime home's reading and for its images-first reading, each stale against
|
|
33
|
+
* `current`. Takes the shard's `runtime` (null for a data-only shard). */
|
|
34
|
+
function staleRuntimeIssues(
|
|
35
|
+
runtime: Readonly<{ cost?: EpochRow | undefined }> | null,
|
|
36
|
+
current: number = MEMORY_EPOCH,
|
|
37
|
+
): StaleRuntimeIssue[] {
|
|
38
|
+
const rows: EpochRow[] = []
|
|
39
|
+
const cost = runtime === null ? undefined : runtime.cost
|
|
40
|
+
if (cost !== undefined) {
|
|
41
|
+
rows.push(cost)
|
|
42
|
+
if (cost.imagesFirst !== undefined) {
|
|
43
|
+
rows.push(cost.imagesFirst)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return rows
|
|
47
|
+
.filter((row: EpochRow): boolean => staleRuntimeCost(row, current) !== '')
|
|
48
|
+
.map((row: EpochRow): StaleRuntimeIssue => ({
|
|
49
|
+
code: 'perf-native-resident-unmeasured',
|
|
50
|
+
metric: staleRuntimeCost(row, current),
|
|
51
|
+
actual: row.epoch ?? LEGACY_EPOCH,
|
|
52
|
+
limit: current,
|
|
53
|
+
severity: 'refusal',
|
|
54
|
+
}))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { MEMORY_EPOCH, staleRuntimeCost, staleRuntimeIssues }
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { worstContentCost } from './budget.ts'
|
|
2
|
+
import { runtimeAccountedBytes } from './runtimeCost.ts'
|
|
3
|
+
|
|
4
|
+
import type { Shardfile } from './shardSchema.ts'
|
|
5
|
+
|
|
6
|
+
/** J408 (Jake, 2026-11-17, after Nine crashed his iPhone 17 Pro at boot): the hard line. An estimate over it
|
|
7
|
+
* refuses in every offline gate (check, shard CI, api-server, the cook) whatever the policy or the report-only switch.
|
|
8
|
+
* Engine's MEMORY_AMBER (src/client/game/grid/budgetOverlay.ts). Decimal bytes. MEMORY-GATES MG4. */
|
|
9
|
+
const MEMORY_HARD_BYTES = 1.5e9
|
|
10
|
+
const GB = 1e9
|
|
11
|
+
const DIGITS = 1
|
|
12
|
+
const EMPTY_BYTES = 0
|
|
13
|
+
|
|
14
|
+
/** The refusal's words for an estimate over the hard line; empty under it. */
|
|
15
|
+
function overHardLine(bytes: number): string {
|
|
16
|
+
if (bytes <= MEMORY_HARD_BYTES) {
|
|
17
|
+
return ''
|
|
18
|
+
}
|
|
19
|
+
return ` (over the ${(MEMORY_HARD_BYTES / GB).toFixed(DIGITS)} GB phone line, J408: a phone would close the page)`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** J408 (MG4): the refusal for a worst-playing or loading estimate over the hard line. */
|
|
23
|
+
function hardLineIssue(
|
|
24
|
+
kind: 'playing' | 'loading',
|
|
25
|
+
bytes: number,
|
|
26
|
+
): {
|
|
27
|
+
readonly code: 'perf-playing-memory' | 'perf-loading-memory'
|
|
28
|
+
readonly metric: string
|
|
29
|
+
readonly actual: number
|
|
30
|
+
readonly limit: number
|
|
31
|
+
readonly severity: 'refusal'
|
|
32
|
+
} {
|
|
33
|
+
return {
|
|
34
|
+
code: `perf-${kind}-memory`,
|
|
35
|
+
metric: `worst ${kind} total bytes${overHardLine(bytes)}`,
|
|
36
|
+
actual: bytes,
|
|
37
|
+
limit: MEMORY_HARD_BYTES,
|
|
38
|
+
severity: 'refusal',
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** File admission cannot infer the opaque runtime's resident bytes. */
|
|
43
|
+
function offlineRuntimeMemoryIssues(
|
|
44
|
+
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's shard type, read only
|
|
45
|
+
source: Shardfile,
|
|
46
|
+
): ReturnType<typeof hardLineIssue>[] {
|
|
47
|
+
if (source.runtime?.cost === undefined) {
|
|
48
|
+
return []
|
|
49
|
+
}
|
|
50
|
+
const runtime = runtimeAccountedBytes(source.runtime.cost)
|
|
51
|
+
const commons = Object.values(source.requires.commonsCosts).reduce(
|
|
52
|
+
(sum, row): number => sum + row.decoded + row.gpu,
|
|
53
|
+
EMPTY_BYTES,
|
|
54
|
+
)
|
|
55
|
+
const cost = worstContentCost(source, runtime + commons)
|
|
56
|
+
return (['playing', 'loading'] as const)
|
|
57
|
+
.filter((kind): boolean => cost[kind] > MEMORY_HARD_BYTES)
|
|
58
|
+
.map((kind): ReturnType<typeof hardLineIssue> =>
|
|
59
|
+
hardLineIssue(kind, cost[kind]),
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
MEMORY_HARD_BYTES,
|
|
65
|
+
hardLineIssue,
|
|
66
|
+
offlineRuntimeMemoryIssues,
|
|
67
|
+
overHardLine,
|
|
68
|
+
}
|
|
@@ -33,7 +33,9 @@ export class MemoryAdmission {
|
|
|
33
33
|
private readonly warnings = new Map<string, MemoryAdmissionWarning>();
|
|
34
34
|
private readonly listeners = new Set<() => void>();
|
|
35
35
|
private readonly developer: () => boolean;
|
|
36
|
-
|
|
36
|
+
private readonly hardBytes: number;
|
|
37
|
+
/** `hardBytes` (J408): applies to playing and loading even with an override. */
|
|
38
|
+
constructor(developer: () => boolean = () => false, hardBytes: number = Number.POSITIVE_INFINITY) { this.developer = developer; this.hardBytes = hardBytes; }
|
|
37
39
|
|
|
38
40
|
/** True for an in-envelope request or a Developer override. False means the caller retains its original refusal path. */
|
|
39
41
|
accept(request: MemoryAdmissionRequest): boolean {
|
|
@@ -42,6 +44,7 @@ export class MemoryAdmission {
|
|
|
42
44
|
|| ![playingCap, loadingCap].every(value => Number.isFinite(value) && value > 0)) throw new RangeError('Invalid memory admission report');
|
|
43
45
|
const key = `${request.stage}:${request.owner}`;
|
|
44
46
|
const playingOverBytes = Math.max(0, request.playingBytes - playingCap), loadingOverBytes = Math.max(0, request.loadingBytes - loadingCap);
|
|
47
|
+
if (Math.max(request.playingBytes, request.loadingBytes) > this.hardBytes) { return false; }
|
|
45
48
|
if (playingOverBytes === 0 && loadingOverBytes === 0) { if (this.warnings.delete(key)) this.notify(); return true; }
|
|
46
49
|
if (!this.developer()) return false;
|
|
47
50
|
const warning = Object.freeze({ ...request, playingCap, loadingCap, playingOverBytes, loadingOverBytes,
|
package/src/format/rows.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { sketchReference } from './sketch.ts';
|
|
|
9
9
|
import { JournalRowSchema, journalRowRules } from './compendiumRows.ts';
|
|
10
10
|
import { CreatureTypeSchema, CreatureBodySchema, CreatureTemperamentSchema, CreatureSensesSchema, CreatureAbilitySchema, CreaturePresentationSchema } from './creature-layers.ts';
|
|
11
11
|
import type { CreatureLayers } from './creature-layers.ts';
|
|
12
|
+
import { creatureSizeRules } from './creature-sizes.ts';
|
|
12
13
|
|
|
13
14
|
const id = v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9.:-]*$/u), v.maxLength(128));
|
|
14
15
|
const text = v.pipe(v.string(), v.maxLength(4096));
|
|
@@ -75,7 +76,7 @@ function rowRules(rows: ShardRows): string[] {
|
|
|
75
76
|
}
|
|
76
77
|
for (const d of rows.days) if (d.schedule[0]?.from !== 0 || d.schedule.at(-1)?.to !== 24 || d.schedule.some((s, i) => s.from >= s.to || (i > 0 && d.schedule[i - 1]?.to !== s.from))) errors.push('complete ordered day schedule');
|
|
77
78
|
const speciesIds = new Set(rows.species.map((s) => s.id));
|
|
78
|
-
errors.push(...strikeDebrisCatalogueRules(rows));
|
|
79
|
+
errors.push(...strikeDebrisCatalogueRules(rows), ...creatureSizeRules(rows.species));
|
|
79
80
|
for (const s of rows.species) if (new Set(s.variants.map((r) => r.id)).size !== s.variants.length || s.variants.some((r) => r.scale[1] > 10)) errors.push('species variants');
|
|
80
81
|
const strikeIds = new Set<string>();
|
|
81
82
|
for (const strikeRow of rows.strikes) { strikeIds.add(strikeRow.id); }
|
|
@@ -2,14 +2,18 @@ import * as v from 'valibot';
|
|
|
2
2
|
import { RUNTIME_RESIDENT_FACTOR } from './wireLimits.ts';
|
|
3
3
|
|
|
4
4
|
const mb = v.pipe(v.number(), v.finite(), v.minValue(0));
|
|
5
|
+
const FIRST_EPOCH = 1;
|
|
6
|
+
const epochNumber = v.pipe(v.number(), v.integer(), v.minValue(FIRST_EPOCH));
|
|
5
7
|
/** Reviewed trusted-runtime measurements, kept with their shard rather than presenting an empty data budget as its cost. */
|
|
6
|
-
export const MemoryMeasurementSchema: v.StrictObjectSchema<{ readonly webContentMB: v.GenericSchema<MemoryMeasurementRowsInput['webContentMB'], MemoryMeasurementRows['webContentMB']>; readonly glMB: v.GenericSchema<MemoryMeasurementRowsInput['glMB'], MemoryMeasurementRows['glMB']>; readonly engineBaseMB: v.GenericSchema<MemoryMeasurementRowsInput['engineBaseMB'], MemoryMeasurementRows['engineBaseMB']>; readonly residentBaseMB: v.ExactOptionalSchema<v.GenericSchema<Exclude<MemoryMeasurementRowsInput['residentBaseMB'], undefined>, Exclude<MemoryMeasurementRows['residentBaseMB'], undefined>>, undefined>; readonly rev: v.GenericSchema<MemoryMeasurementRowsInput['rev'], MemoryMeasurementRows['rev']>; readonly device: v.GenericSchema<MemoryMeasurementRowsInput['device'], MemoryMeasurementRows['device']>; readonly evidence: v.GenericSchema<MemoryMeasurementRowsInput['evidence'], MemoryMeasurementRows['evidence']>; }, undefined> = v.strictObject({
|
|
8
|
+
export const MemoryMeasurementSchema: v.StrictObjectSchema<{ readonly webContentMB: v.GenericSchema<MemoryMeasurementRowsInput['webContentMB'], MemoryMeasurementRows['webContentMB']>; readonly glMB: v.GenericSchema<MemoryMeasurementRowsInput['glMB'], MemoryMeasurementRows['glMB']>; readonly engineBaseMB: v.GenericSchema<MemoryMeasurementRowsInput['engineBaseMB'], MemoryMeasurementRows['engineBaseMB']>; readonly residentBaseMB: v.ExactOptionalSchema<v.GenericSchema<Exclude<MemoryMeasurementRowsInput['residentBaseMB'], undefined>, Exclude<MemoryMeasurementRows['residentBaseMB'], undefined>>, undefined>; readonly rev: v.GenericSchema<MemoryMeasurementRowsInput['rev'], MemoryMeasurementRows['rev']>; readonly device: v.GenericSchema<MemoryMeasurementRowsInput['device'], MemoryMeasurementRows['device']>; readonly evidence: v.GenericSchema<MemoryMeasurementRowsInput['evidence'], MemoryMeasurementRows['evidence']>; readonly epoch: v.ExactOptionalSchema<v.GenericSchema<Exclude<MemoryMeasurementRowsInput['epoch'], undefined>, Exclude<MemoryMeasurementRows['epoch'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
7
9
|
webContentMB: mb, glMB: mb, engineBaseMB: mb,
|
|
8
10
|
/** Matched settled pre-entry resident set. When present, subtract it instead of the dated engine-only calibration. */
|
|
9
11
|
residentBaseMB: v.exactOptional(mb),
|
|
10
12
|
rev: v.pipe(v.string(), v.regex(/^[a-f0-9]{9,40}$/u)),
|
|
11
13
|
device: v.pipe(v.string(), v.minLength(1), v.maxLength(200)),
|
|
12
14
|
evidence: v.pipe(v.string(), v.regex(/^progress\/memory\/[a-zA-Z0-9/_-]+\.json$/u)),
|
|
15
|
+
/** MEMORY-GATES MG5 (J408): the memory model the reading was taken against (memory-epoch.ts); absent reads as epoch 1. */
|
|
16
|
+
epoch: v.exactOptional(epochNumber),
|
|
13
17
|
});
|
|
14
18
|
/** The current runtime measurement may retain its separate images-first reading for cold phone texture selection. */
|
|
15
19
|
export const RuntimeCostSchema: v.GenericSchema<RuntimeCostInput, RuntimeCost> = v.strictObject({ ...MemoryMeasurementSchema.entries, imagesFirst: v.optional(MemoryMeasurementSchema) });
|
|
@@ -58,6 +62,7 @@ interface MemoryMeasurementRowsFields {
|
|
|
58
62
|
rev: string;
|
|
59
63
|
device: string;
|
|
60
64
|
evidence: string;
|
|
65
|
+
epoch?: number;
|
|
61
66
|
}
|
|
62
67
|
export type MemoryMeasurementRows = { [Key in keyof MemoryMeasurementRowsFields]: MemoryMeasurementRowsFields[Key] };
|
|
63
68
|
export type RuntimeCostInput = Omit<MemoryMeasurementRowsInput, keyof ({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { creatureSizeRules } from './creature-sizes.ts';
|
|
1
2
|
import { readSpeciesPrograms } from './speciesPrograms.ts';
|
|
2
3
|
import type { StrikeDebrisPolicy } from './strike-debris.ts';
|
|
3
4
|
import { strikeDebrisCatalogueRules } from './strike-debris.ts';
|
|
@@ -367,6 +368,7 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
367
368
|
if (crowdMembers > 4096) errors.push('declared crowd member capacity');
|
|
368
369
|
if (s.crowds.some(row => Math.abs(row.x) > CHUNK_HALF || Math.abs(row.z) > CHUNK_HALF)) errors.push('declared crowd home in cell');
|
|
369
370
|
if (s.creatures.spawns.length + crowdMembers > s.serverBudget.entities) errors.push('declared entity capacity');
|
|
371
|
+
errors.push(...creatureSizeRules(s.rows.species, s.creatures.spawns));
|
|
370
372
|
for (const spawn of s.creatures.spawns) if (!species.get(spawn.species)?.variants.some((row) => row.id === spawn.variant) || (spawn.strike !== null && !strikes.has(spawn.strike))) errors.push('declared spawn species/variant/strike');
|
|
371
373
|
errors.push(...encounterRules(s.encounters, s.creatures.spawns.map((spawn) => spawn.id), s.ui.filter((row) => row.kind === 'bossPanel')));
|
|
372
374
|
const controlled = new Set(s.encounters.map((row) => row.entity));
|
|
@@ -13,6 +13,8 @@ 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, MEMORY_GATES } from './contentBounds.ts';
|
|
16
|
+
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
17
|
+
import { MEMORY_HARD_BYTES, hardLineIssue } from './memory-line.ts';
|
|
16
18
|
import { VIEW_DRAWS, viewDraws } from './view-draws.ts';
|
|
17
19
|
import { DEFAULT_GRAPH_BUDGET } from "./materialGraph.ts";
|
|
18
20
|
import { SCRIPT_LIMITS } from './scriptLimits.ts';
|
|
@@ -310,11 +312,15 @@ export function performanceReport(source: Shardfile, observations: PerformanceOb
|
|
|
310
312
|
};
|
|
311
313
|
if (native.unmeasuredViewAndDownload) check(['perf-native-view-unmeasured', 'native view/download measurement required'], 1, 0);
|
|
312
314
|
if (source.runtime !== null && source.runtime.cost === undefined) check(['perf-native-resident-unmeasured', 'native resident measurement required'], 1, 0);
|
|
313
|
-
|
|
314
|
-
|
|
315
|
+
issues.push(...staleRuntimeIssues(source.runtime));
|
|
316
|
+
// G433 keeps the soft caps report-only. J408 applies to both estimates ahead of the soft caps.
|
|
317
|
+
const total = (kind: 'playing' | 'loading', actual: number, limit: number): void => {
|
|
318
|
+
if (actual > MEMORY_HARD_BYTES) { issues.push(hardLineIssue(kind, actual)); return; }
|
|
319
|
+
const code = `perf-${kind}-memory` as const, metric = `worst ${kind} total bytes`;
|
|
315
320
|
if (MEMORY_GATES.reportOnly && actual > limit) issues.push({ code, metric: `${metric} (report-only, G433)`, actual, limit, severity: 'warning' }); else check([code, metric], actual, limit);
|
|
316
321
|
};
|
|
317
|
-
total(
|
|
322
|
+
total('playing', worst.playing, C.playing);
|
|
323
|
+
total('loading', worst.loading, C.loading);
|
|
318
324
|
const library = reportCardClosure(source, source.library), critical = reportCardClosure(source, source.critical);
|
|
319
325
|
const tileRoots = source.tiles.flatMap(tile => tile.files), farRoots = source.far?.files ?? [], nearRoots = nearPlaceholderRoots(source.near);
|
|
320
326
|
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)]);
|
|
@@ -361,8 +367,7 @@ export function performanceReportLines(report: PerformanceReport): string[] {
|
|
|
361
367
|
...report.issues.map(issue => `${issue.severity.toUpperCase()}: ${issue.metric}: ${issue.actual} > ${issue.limit}`)];
|
|
362
368
|
}
|
|
363
369
|
|
|
364
|
-
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return policy === 'warn' || MEMORY_GATES.reportOnly ? new MemoryAdmission(() => true) : undefined;
|
|
370
|
+
/** Offline soft-cap policy and the fixed J408 line for playing and loading. */
|
|
371
|
+
export function offlineMemoryAdmission(policy: 'warn' | 'refuse'): MemoryAdmission {
|
|
372
|
+
return new MemoryAdmission(() => policy === 'warn' || MEMORY_GATES.reportOnly, MEMORY_HARD_BYTES);
|
|
368
373
|
}
|
|
@@ -20,6 +20,8 @@ import { assertScriptSides } from './script-sides.ts';
|
|
|
20
20
|
import { shardfileRecordings } from './shardfile-audio.ts';
|
|
21
21
|
import type { RecordingMeasure } from './audio-measure.ts';
|
|
22
22
|
import { issueError, withIssueCode as coded } from './issue-codes.ts';
|
|
23
|
+
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
24
|
+
import { offlineRuntimeMemoryIssues } from './memory-line.ts';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* P1-F3 format validation of a built shardfile product (format 2: `shard.json`, sections, blobs, packs): the schema,
|
|
@@ -107,7 +109,7 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
|
|
|
107
109
|
|
|
108
110
|
/** Refuse the declared targets a policy treats as refusals, before any byte is read or executed. */
|
|
109
111
|
export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse'): void {
|
|
110
|
-
const issues = performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal');
|
|
112
|
+
const issues = [...staleRuntimeIssues(source.runtime), ...offlineRuntimeMemoryIssues(source), ...performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal')];
|
|
111
113
|
if (issues.length === 0) return;
|
|
112
114
|
throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
|
|
113
115
|
}
|