@wildshard/shard-format 0.46.1 → 0.46.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.2",
|
|
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": {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import armed from './memory-armed.json' with { type: 'json' }
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* mandatory") on J424 ("the gates should only block once an agent has done the work to get it under the gate"): the
|
|
6
|
-
* one armed-zone list, `memory-armed.json`. Every memory gate refuses an armed zone over its line, whatever the policy
|
|
7
|
-
* or the report-only switch; it reports every other zone. Engine's guards read the same JSON.
|
|
8
|
-
*/
|
|
3
|
+
/** The armed-zone readings are shared with the engine. J445 uses the common
|
|
4
|
+
* loading ceiling for offline refusal and the playing line for reporting. */
|
|
9
5
|
interface ArmedZone {
|
|
10
6
|
readonly armed: string
|
|
11
7
|
readonly by: string
|
|
@@ -39,32 +35,16 @@ function zoneArmed(slug?: string): boolean {
|
|
|
39
35
|
return slug !== undefined && Object.hasOwn(ARMED_ZONES, slug)
|
|
40
36
|
}
|
|
41
37
|
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/** The line a zone's entry locks at: the J410 line, or its reading at arming plus the allowance when that is higher. */
|
|
46
|
-
function zoneLine(zone: ArmedZone, kind: ArmedKind): number {
|
|
47
|
-
const armedBytes = kind === 'playing' ? zone.playingBytes : zone.loadingBytes
|
|
48
|
-
return Math.max(
|
|
49
|
-
ARMED_LINES[kind],
|
|
50
|
-
armedBytes + Math.floor(armedBytes * ARMED_ALLOWANCE),
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** What an armed zone's offline estimate refuses over: the J410 line, or, when the conservative estimate of a source
|
|
55
|
-
* that EM11 measured under the line already reads over it (Nine's playing), that reading at arming plus the
|
|
56
|
-
* allowance, so the gate locks in the measured state and refuses any growth. Undefined for a zone that only reports. */
|
|
38
|
+
/** The common lines for an armed zone. A revision's own reading is evidence,
|
|
39
|
+
* while the offline decision uses the shared target or ceiling (J445). */
|
|
57
40
|
function armedLine(
|
|
58
41
|
slug: string | undefined,
|
|
59
42
|
kind: ArmedKind,
|
|
60
43
|
): number | undefined {
|
|
61
|
-
|
|
62
|
-
slug === undefined || !zoneArmed(slug) ? undefined : ARMED_ZONES[slug]
|
|
63
|
-
return zone === undefined ? undefined : zoneLine(zone, kind)
|
|
44
|
+
return zoneArmed(slug) ? ARMED_LINES[kind] : undefined
|
|
64
45
|
}
|
|
65
46
|
|
|
66
47
|
export {
|
|
67
|
-
ARMED_ALLOWANCE,
|
|
68
48
|
ARMED_LINES,
|
|
69
49
|
ARMED_ZONES,
|
|
70
50
|
type ArmedKind,
|
|
@@ -73,5 +53,4 @@ export {
|
|
|
73
53
|
HELD_ZONES,
|
|
74
54
|
type HeldZone,
|
|
75
55
|
zoneArmed,
|
|
76
|
-
zoneLine,
|
|
77
56
|
}
|
|
@@ -2,17 +2,15 @@ import { parse } from 'valibot'
|
|
|
2
2
|
|
|
3
3
|
import { bootMemoryCosts } from './boot-memory-cost.ts'
|
|
4
4
|
import { worstContentCost } from './budget.ts'
|
|
5
|
-
import {
|
|
5
|
+
import { ARMED_LINES } from './memory-armed.ts'
|
|
6
6
|
import { ratchetNote, ratchetSeverity } from './memory-ratchet.ts'
|
|
7
7
|
import { runtimeAccountedBytes, RuntimeCostSchema } from './runtimeCost.ts'
|
|
8
8
|
|
|
9
9
|
import type { TierIndex } from './phone-files.ts'
|
|
10
10
|
import type { Shardfile } from './shardSchema.ts'
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
* Engine's MEMORY_AMBER (src/client/game/grid/budgetOverlay.ts). Decimal bytes. MEMORY-GATES MG4. */
|
|
15
|
-
const MEMORY_HARD_BYTES = 1.5e9
|
|
12
|
+
/** The hard loading ceiling in decimal bytes (J445). */
|
|
13
|
+
const MEMORY_HARD_BYTES: number = ARMED_LINES.loading
|
|
16
14
|
const GB = 1e9
|
|
17
15
|
const DIGITS = 1
|
|
18
16
|
const EMPTY_BYTES = 0
|
|
@@ -25,8 +23,8 @@ function overHardLine(bytes: number): string {
|
|
|
25
23
|
return ` (over the ${(MEMORY_HARD_BYTES / GB).toFixed(DIGITS)} GB phone line, J408: a phone would close the page)`
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
26
|
+
/** J445: the playing target reports. Only an armed zone over the loading
|
|
27
|
+
* ceiling refuses. */
|
|
30
28
|
function hardLineIssue(
|
|
31
29
|
kind: 'playing' | 'loading',
|
|
32
30
|
bytes: number,
|
|
@@ -39,12 +37,12 @@ function hardLineIssue(
|
|
|
39
37
|
readonly severity: 'refusal' | 'warning'
|
|
40
38
|
} {
|
|
41
39
|
const { slug, line } =
|
|
42
|
-
typeof zone === 'object' ? zone : { slug: zone, line:
|
|
40
|
+
typeof zone === 'object' ? zone : { slug: zone, line: ARMED_LINES[kind] }
|
|
43
41
|
const severity = ratchetSeverity(slug, kind, { line, actual: bytes })
|
|
44
42
|
const over =
|
|
45
|
-
|
|
46
|
-
?
|
|
47
|
-
:
|
|
43
|
+
kind === 'playing'
|
|
44
|
+
? ` (over the ${(line / GB).toFixed(DIGITS)} GB playing target, J445)`
|
|
45
|
+
: overHardLine(bytes)
|
|
48
46
|
return {
|
|
49
47
|
code: `perf-${kind}-memory`,
|
|
50
48
|
metric: `worst ${kind} total bytes${over}${severity === 'warning' ? ratchetNote(slug, kind) : ''}`,
|
|
@@ -54,6 +52,18 @@ function hardLineIssue(
|
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
|
|
55
|
+
/** The offline memory thresholds apply equally to a build and its report. */
|
|
56
|
+
function memoryLineIssues(
|
|
57
|
+
cost: Readonly<Record<'playing' | 'loading', number>>,
|
|
58
|
+
slug: string,
|
|
59
|
+
): ReturnType<typeof hardLineIssue>[] {
|
|
60
|
+
return (['playing', 'loading'] as const)
|
|
61
|
+
.filter((kind): boolean => cost[kind] > ARMED_LINES[kind])
|
|
62
|
+
.map((kind): ReturnType<typeof hardLineIssue> =>
|
|
63
|
+
hardLineIssue(kind, cost[kind], slug),
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
/**
|
|
58
68
|
* MG6 epoch 3 (mini-estcal, 2026-11-17): the offline gates charge a runtime home from the engine base, never less a
|
|
59
69
|
* matched pre-entry resident set. The phone-tier probe found that set live at the boot peak: the renderer's
|
|
@@ -112,21 +122,14 @@ function offlineMemoryIssues(
|
|
|
112
122
|
commons: runtime + commons,
|
|
113
123
|
boot: bootMemoryCosts(source, sections, { mountedImages, index }),
|
|
114
124
|
})
|
|
115
|
-
|
|
116
|
-
const { slug } = source.identity
|
|
117
|
-
const line = (kind: 'playing' | 'loading'): number =>
|
|
118
|
-
armedLine(slug, kind) ?? MEMORY_HARD_BYTES
|
|
119
|
-
return (['playing', 'loading'] as const)
|
|
120
|
-
.filter((kind): boolean => cost[kind] > line(kind))
|
|
121
|
-
.map((kind): ReturnType<typeof hardLineIssue> =>
|
|
122
|
-
hardLineIssue(kind, cost[kind], { slug, line: line(kind) }),
|
|
123
|
-
)
|
|
125
|
+
return memoryLineIssues(cost, source.identity.slug)
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
export {
|
|
127
129
|
MEMORY_HARD_BYTES,
|
|
128
130
|
type MemoryContext,
|
|
129
131
|
hardLineIssue,
|
|
132
|
+
memoryLineIssues,
|
|
130
133
|
memoryContext,
|
|
131
134
|
offlineMemoryIssues,
|
|
132
135
|
overHardLine,
|
|
@@ -51,17 +51,19 @@ const RATCHET_ALLOWANCE = 0.005
|
|
|
51
51
|
|
|
52
52
|
type RatchetMetric = 'playing' | 'loading' | 'runtime'
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
*
|
|
54
|
+
/** J445: only the common loading ceiling can refuse an armed shard.
|
|
55
|
+
* Playing and runtime tier overages are reported. */
|
|
56
56
|
function ratchetLimit(
|
|
57
57
|
slug: string | undefined,
|
|
58
|
-
|
|
58
|
+
metric: RatchetMetric,
|
|
59
59
|
line: number,
|
|
60
60
|
): number {
|
|
61
|
-
return zoneArmed(slug)
|
|
61
|
+
return metric === 'loading' && zoneArmed(slug)
|
|
62
|
+
? line
|
|
63
|
+
: Number.POSITIVE_INFINITY
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
/**
|
|
66
|
+
/** Describe the offline decision for a measured overage. */
|
|
65
67
|
function ratchetSeverity(
|
|
66
68
|
slug: string | undefined,
|
|
67
69
|
metric: RatchetMetric,
|
|
@@ -21,10 +21,8 @@ interface RuntimeTierIssue {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* ONE-FORMAT OF10c1a
|
|
25
|
-
*
|
|
26
|
-
* it holds above the engine's resident base) exceed its tier's `memoryBytes`. A shard naming no tier is held to `large`
|
|
27
|
-
* until OF10c1b names a tier in each of our runtime shards' sources; then a runtime must name one.
|
|
24
|
+
* ONE-FORMAT OF10c1a and J445: report a runtime's accounted bytes above its
|
|
25
|
+
* named memory tier. A runtime with no named tier uses the large target.
|
|
28
26
|
*/
|
|
29
27
|
function runtimeTierIssues(source: RuntimeTierSource): RuntimeTierIssue[] {
|
|
30
28
|
const cost = source.runtime?.cost ?? source.budgets.client
|
|
@@ -385,6 +385,13 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
385
385
|
errors.push(...encounterRules(s.encounters, s.creatures.spawns.map((spawn) => spawn.id), s.ui.filter((row) => row.kind === 'bossPanel')));
|
|
386
386
|
const controlled = new Set(s.encounters.map((row) => row.entity));
|
|
387
387
|
errors.push(...groupBrainRules(s.creatures.groups, s.creatures.spawns, s.creatures.brains.map((row) => row.id), [...controlled]));
|
|
388
|
+
const packRows = sections?.has('sim/scripts') === true ? sections.get('sim/scripts') : undefined;
|
|
389
|
+
const packOwns = (spawn: string, group: string): boolean => packRows === undefined || (Array.isArray(packRows) && packRows.some((script: unknown): boolean => {
|
|
390
|
+
if (typeof script !== 'object' || script === null || !('binding' in script) || !('actors' in script)) { return false; }
|
|
391
|
+
const { binding, actors } = script;
|
|
392
|
+
return typeof binding === 'object' && binding !== null && 'spawnGroup' in binding && binding.spawnGroup === group
|
|
393
|
+
&& typeof actors === 'object' && actors !== null && Object.values(actors).includes(spawn);
|
|
394
|
+
}));
|
|
388
395
|
// Keep every previously admitted named/encounter controller. Only the formerly
|
|
389
396
|
// unowned null-brain case is extended to an actual engine policy or declaration.
|
|
390
397
|
const inlineBrains: Record<ShardCreatures['brains'][number]['kind'] | 'hunt', true> = {
|
|
@@ -396,6 +403,9 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
|
|
|
396
403
|
if (controlled.has(row.id)) { return row.brain !== null; }
|
|
397
404
|
if (row.brain !== null) { return false; }
|
|
398
405
|
const brain = species.get(row.species)?.temperament?.brain;
|
|
406
|
+
// OF19b: a decision pack. Temperament `none` and a spawn group: the group's `spawnGroup` decision row owns the body,
|
|
407
|
+
// and where `sim/scripts` is in hand that row must list it.
|
|
408
|
+
if (brain === 'none' && row.group !== undefined) { return !packOwns(row.id, row.group); }
|
|
399
409
|
return brain === undefined || !(Object.hasOwn(inlineBrains, brain)
|
|
400
410
|
|| s.creatures.brains.some((declaration: { readonly id: string }): boolean => declaration.id === brain));
|
|
401
411
|
})) errors.push('exactly one declared creature controller');
|
|
@@ -12,10 +12,11 @@ import { journalImageRefs } from './compendiumRows.ts';
|
|
|
12
12
|
import type { Shardfile } from "./shardSchema.ts";
|
|
13
13
|
import type { ShardTerrain } from "./terrain.ts";
|
|
14
14
|
import { worstContentCost, memoryTargetWarnings, nearbyContentCost } from "./budget.ts";
|
|
15
|
-
import { CONTENT_CAPS as C
|
|
15
|
+
import { CONTENT_CAPS as C } from './contentBounds.ts';
|
|
16
|
+
import { ARMED_LINES } from './memory-armed.ts';
|
|
16
17
|
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
17
18
|
import { ratchetLimit } from './memory-ratchet.ts';
|
|
18
|
-
import { MEMORY_HARD_BYTES,
|
|
19
|
+
import { MEMORY_HARD_BYTES, memoryLineIssues, runtimeOfflineBytes } from './memory-line.ts';
|
|
19
20
|
import { bootMemoryCosts } from './boot-memory-cost.ts';
|
|
20
21
|
import type { TierIndex } from './phone-files.ts';
|
|
21
22
|
import { VIEW_DRAWS, viewDraws } from './view-draws.ts';
|
|
@@ -33,7 +34,7 @@ interface PerformanceOptions { readonly policy: PerformancePolicy; readonly sect
|
|
|
33
34
|
function reportMemory(source: Shardfile, nativeBytes: number, options: Readonly<{ sections: ReadonlyMap<string, unknown>; mountedImages?: number; index?: TierIndex }>): PerformanceReport['memory'] {
|
|
34
35
|
const commons = nativeBytes + Object.values(source.requires.commonsCosts).reduce((sum, row) => sum + row.decoded + row.gpu, 0);
|
|
35
36
|
const budget = { commons, boot: bootMemoryCosts(source, options.sections, options) };
|
|
36
|
-
return { near: nearbyContentCost(source, source.spawn.x, source.spawn.z, budget), worst: worstContentCost(source, budget), playingLimit:
|
|
37
|
+
return { near: nearbyContentCost(source, source.spawn.x, source.spawn.z, budget), worst: worstContentCost(source, budget), playingLimit: ARMED_LINES.playing, loadingLimit: ARMED_LINES.loading };
|
|
37
38
|
}
|
|
38
39
|
/** A performance issue's code and its metric words. */
|
|
39
40
|
type Named = readonly [code: IssueCodeOf<'performance'>, metric: string];
|
|
@@ -319,15 +320,7 @@ export function performanceReport(source: Shardfile, observations: PerformanceOb
|
|
|
319
320
|
};
|
|
320
321
|
if (native.unmeasuredViewAndDownload) check(['perf-native-view-unmeasured', 'native view/download measurement required'], 1, 0);
|
|
321
322
|
if (source.runtime !== null && source.runtime.cost === undefined) check(['perf-native-resident-unmeasured', 'native resident measurement required'], 1, 0);
|
|
322
|
-
issues.push(...staleRuntimeIssues(source.runtime, undefined, source.identity));
|
|
323
|
-
// G433 keeps the soft caps report-only. J408 applies to both estimates ahead of the soft caps.
|
|
324
|
-
const total = (kind: 'playing' | 'loading', actual: number, limit: number): void => {
|
|
325
|
-
if (actual > MEMORY_HARD_BYTES) { issues.push(hardLineIssue(kind, actual, source.identity.slug)); return; }
|
|
326
|
-
const code = `perf-${kind}-memory` as const, metric = `worst ${kind} total bytes`;
|
|
327
|
-
if (MEMORY_GATES.reportOnly && actual > limit) issues.push({ code, metric: `${metric} (report-only, G433)`, actual, limit, severity: 'warning' }); else check([code, metric], actual, limit);
|
|
328
|
-
};
|
|
329
|
-
total('playing', worst.playing, C.playing);
|
|
330
|
-
total('loading', worst.loading, C.loading);
|
|
323
|
+
issues.push(...staleRuntimeIssues(source.runtime, undefined, source.identity), ...memoryLineIssues(worst, source.identity.slug));
|
|
331
324
|
const library = reportCardClosure(source, source.library), critical = reportCardClosure(source, source.critical);
|
|
332
325
|
const tileRoots = source.tiles.flatMap(tile => tile.files), farRoots = source.far?.files ?? [], nearRoots = nearPlaceholderRoots(source.near);
|
|
333
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)]);
|
|
@@ -374,8 +367,8 @@ export function performanceReportLines(report: PerformanceReport): string[] {
|
|
|
374
367
|
...report.issues.map(issue => `${issue.severity.toUpperCase()}: ${issue.metric}: ${issue.actual} > ${issue.limit}`)];
|
|
375
368
|
}
|
|
376
369
|
|
|
377
|
-
/** Offline soft-cap policy and the
|
|
378
|
-
export function offlineMemoryAdmission(
|
|
379
|
-
//
|
|
380
|
-
return new MemoryAdmission(() =>
|
|
370
|
+
/** Offline soft-cap policy and the hard loading ceiling (J445). */
|
|
371
|
+
export function offlineMemoryAdmission(_policy: 'warn' | 'refuse'): MemoryAdmission {
|
|
372
|
+
// The hard loading ceiling applies to the armed list.
|
|
373
|
+
return new MemoryAdmission((): boolean => true, (owner, kind): number => ratchetLimit(owner, kind, MEMORY_HARD_BYTES));
|
|
381
374
|
}
|