@wildshard/shard-format 0.46.0 → 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 +1 -1
- package/src/format/creature-body.ts +30 -5
- package/src/format/creature-skeletons.ts +57 -1
- package/src/format/memory-armed.ts +5 -26
- package/src/format/memory-line.ts +23 -20
- package/src/format/memory-ratchet.ts +7 -5
- package/src/format/runtime-tier.ts +2 -4
- package/src/format/shardSchema.ts +10 -0
- package/src/format/shardfile-assets.ts +9 -16
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": {
|
|
@@ -39,7 +39,7 @@ import type {
|
|
|
39
39
|
CreatureLookSwap,
|
|
40
40
|
} from './creature-channels.ts'
|
|
41
41
|
import type { CreatureSkeleton, CreatureSize } from './creature-layers.ts'
|
|
42
|
-
import type { CreatureTrail } from './creature-skeletons.ts'
|
|
42
|
+
import type { BipedStance, CreatureTrail } from './creature-skeletons.ts'
|
|
43
43
|
import type { CreatureVolume } from './creature-volumes.ts'
|
|
44
44
|
import type { GenericSchema } from 'valibot'
|
|
45
45
|
|
|
@@ -55,7 +55,9 @@ const scalar = pipe(number(), finite())
|
|
|
55
55
|
interface CreatureBody {
|
|
56
56
|
/** Omit for a GLB with its own rig; a kit poser names its contract explicitly. */
|
|
57
57
|
skeleton?: CreatureSkeleton
|
|
58
|
-
/** A
|
|
58
|
+
/** A biped's stance (ONE-FORMAT CC58); `horizontal` pitches the spine forward and needs a tail `trail`. */
|
|
59
|
+
stance?: BipedStance
|
|
60
|
+
/** A serpent's trail bones (ONE-FORMAT CC23), or a horizontal biped's tail (CC58); no other body has one. */
|
|
59
61
|
trail?: CreatureTrail
|
|
60
62
|
size: CreatureSize
|
|
61
63
|
scale: number
|
|
@@ -88,6 +90,9 @@ const bodyObject = strictObject({
|
|
|
88
90
|
skeleton: exactOptional(
|
|
89
91
|
picklist(['quadruped', 'biped', 'serpent'], 'Unknown creature skeleton'),
|
|
90
92
|
),
|
|
93
|
+
stance: exactOptional(
|
|
94
|
+
picklist(['upright', 'horizontal'], 'Unknown biped stance'),
|
|
95
|
+
),
|
|
91
96
|
trail: exactOptional(trailObject),
|
|
92
97
|
size: picklist(
|
|
93
98
|
['tiny', 'small', 'medium', 'large', 'giant'],
|
|
@@ -115,26 +120,46 @@ const CreatureBodySchema: GenericSchema<CreatureBody> = pipe(
|
|
|
115
120
|
((body.lock?.length ?? ONE) <= ONE && body.hits !== 'clip'),
|
|
116
121
|
'Only giants have multiple lock points or clip hits',
|
|
117
122
|
),
|
|
123
|
+
check<CreatureBody, 'Only a biped has a stance'>(
|
|
124
|
+
(body: {
|
|
125
|
+
readonly skeleton?: CreatureSkeleton
|
|
126
|
+
readonly stance?: BipedStance
|
|
127
|
+
}): boolean => body.stance === undefined || body.skeleton === 'biped',
|
|
128
|
+
'Only a biped has a stance',
|
|
129
|
+
),
|
|
130
|
+
check<CreatureBody, 'A horizontal biped has a tail trail row'>(
|
|
131
|
+
(body: {
|
|
132
|
+
readonly stance?: BipedStance
|
|
133
|
+
readonly trail?: CreatureTrail
|
|
134
|
+
}): boolean => body.stance !== 'horizontal' || body.trail !== undefined,
|
|
135
|
+
'A horizontal biped has a tail trail row',
|
|
136
|
+
),
|
|
118
137
|
check<CreatureBody, 'A serpent has a trail row and only a serpent has one'>(
|
|
119
138
|
(body: {
|
|
120
139
|
readonly skeleton?: CreatureSkeleton
|
|
140
|
+
readonly stance?: BipedStance
|
|
121
141
|
readonly trail?: CreatureTrail
|
|
122
|
-
}): boolean =>
|
|
142
|
+
}): boolean =>
|
|
143
|
+
(body.skeleton === 'biped' && body.stance === 'horizontal') ||
|
|
144
|
+
(body.skeleton === 'serpent') === (body.trail !== undefined),
|
|
123
145
|
'A serpent has a trail row and only a serpent has one',
|
|
124
146
|
),
|
|
125
147
|
check<CreatureBody, 'Too many resolved creature volumes'>(
|
|
126
148
|
(body: {
|
|
127
149
|
readonly skeleton?: CreatureSkeleton
|
|
150
|
+
readonly stance?: BipedStance
|
|
128
151
|
readonly trail?: CreatureTrail
|
|
129
152
|
readonly volumes?: readonly { readonly part: string }[]
|
|
130
153
|
}): boolean => {
|
|
131
|
-
// A serpent without its trail is
|
|
154
|
+
// A serpent or horizontal biped without its trail is a check above's refusal
|
|
132
155
|
const defaults =
|
|
133
156
|
body.skeleton === undefined ||
|
|
134
|
-
(body.skeleton === 'serpent'
|
|
157
|
+
((body.skeleton === 'serpent' || body.stance === 'horizontal') &&
|
|
158
|
+
body.trail === undefined)
|
|
135
159
|
? []
|
|
136
160
|
: creatureContract({
|
|
137
161
|
skeleton: body.skeleton,
|
|
162
|
+
...(body.stance === undefined ? {} : { stance: body.stance }),
|
|
138
163
|
...(body.trail === undefined ? {} : { trail: body.trail }),
|
|
139
164
|
}).volumes
|
|
140
165
|
return (
|
|
@@ -28,6 +28,10 @@ interface SkeletonContract {
|
|
|
28
28
|
readonly lock: string
|
|
29
29
|
readonly volumes: readonly SkeletonVolume[]
|
|
30
30
|
readonly clips: readonly string[]
|
|
31
|
+
/** Bones that follow the root's path, nearest first (CC23's serpent: every bone; CC58's horizontal biped: its tail). */
|
|
32
|
+
readonly trail?: readonly string[]
|
|
33
|
+
/** A forward pitch (radians about the bone's x axis) the poser gives one bone (CC58: a horizontal biped's spine). */
|
|
34
|
+
readonly pitch?: { readonly bone: string; readonly angle: number }
|
|
31
35
|
}
|
|
32
36
|
const ZERO = 0
|
|
33
37
|
const ONE = 1
|
|
@@ -173,13 +177,61 @@ function serpentContract(trail: CreatureTrail): SkeletonContract {
|
|
|
173
177
|
lock: 'head',
|
|
174
178
|
volumes: [HEAD, ...segments],
|
|
175
179
|
clips: CLIPS,
|
|
180
|
+
trail: bones,
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
|
-
/**
|
|
183
|
+
/** A biped's stance (ONE-FORMAT CC58): `upright` is the plain biped; `horizontal` pitches the spine forward. */
|
|
184
|
+
type BipedStance = 'upright' | 'horizontal'
|
|
185
|
+
/** The horizontal biped's forward spine pitch: about 74 degrees, so the body leans out over the legs (Q-CC38). */
|
|
186
|
+
const HORIZONTAL_SPINE_PITCH = 1.3
|
|
187
|
+
const TAIL_MULTIPLIER = 0.5
|
|
188
|
+
/** A horizontal biped's tail bones, hips outward: `tail1` … `tail<count>`. */
|
|
189
|
+
function tailBoneNames(count: number): readonly string[] {
|
|
190
|
+
return Array.from(
|
|
191
|
+
{ length: count },
|
|
192
|
+
(_unused: unknown, index: number): string => `tail${String(index + ONE)}`,
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The horizontal biped (ONE-FORMAT CC58, Q-CC38: the T-Rex): the biped contract with its spine pitched forward and a
|
|
197
|
+
* `tail` chain off the hips whose `count` bones are trail bones, `spacing` metres apart along the path behind the hips.
|
|
198
|
+
* One capsule a tail bone at x0.5; the tail tip is the `tail` socket (a sweep's origin).
|
|
199
|
+
*/
|
|
200
|
+
function horizontalBipedContract(trail: CreatureTrail): SkeletonContract {
|
|
201
|
+
const tail = tailBoneNames(trail.count)
|
|
202
|
+
const tip = tail.at(-ONE) ?? 'hips'
|
|
203
|
+
return {
|
|
204
|
+
...BIPED,
|
|
205
|
+
chains: { ...BIPED.chains, tail: { parent: 'hips', bones: tail } },
|
|
206
|
+
sockets: { ...BIPED.sockets, tail: socket(tip) },
|
|
207
|
+
volumes: [
|
|
208
|
+
...BIPED.volumes,
|
|
209
|
+
...tail.map((bone: string): SkeletonVolume => ({
|
|
210
|
+
part: bone,
|
|
211
|
+
bone,
|
|
212
|
+
shape: 'capsule',
|
|
213
|
+
radius: BODY_RADIUS,
|
|
214
|
+
halfLength: trail.spacing / HALF,
|
|
215
|
+
axis: 'z',
|
|
216
|
+
multiplier: TAIL_MULTIPLIER,
|
|
217
|
+
})),
|
|
218
|
+
],
|
|
219
|
+
trail: tail,
|
|
220
|
+
pitch: { bone: 'spine', angle: HORIZONTAL_SPINE_PITCH },
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
/** The one contract a body declares: a fixed skeleton's, a serpent's built from its trail row, or a horizontal biped's. */
|
|
179
224
|
function creatureContract(body: {
|
|
180
225
|
readonly skeleton: CreatureSkeleton
|
|
226
|
+
readonly stance?: BipedStance
|
|
181
227
|
readonly trail?: CreatureTrail
|
|
182
228
|
}): SkeletonContract {
|
|
229
|
+
if (body.skeleton === 'biped' && body.stance === 'horizontal') {
|
|
230
|
+
if (body.trail === undefined) {
|
|
231
|
+
throw new Error('A horizontal biped needs its tail trail row')
|
|
232
|
+
}
|
|
233
|
+
return horizontalBipedContract(body.trail)
|
|
234
|
+
}
|
|
183
235
|
if (body.skeleton !== 'serpent') {
|
|
184
236
|
return CREATURE_SKELETONS[body.skeleton]
|
|
185
237
|
}
|
|
@@ -203,13 +255,17 @@ function skeletonBones(
|
|
|
203
255
|
|
|
204
256
|
export {
|
|
205
257
|
CREATURE_SKELETONS,
|
|
258
|
+
HORIZONTAL_SPINE_PITCH,
|
|
206
259
|
MIN_VOLUME_RADIUS,
|
|
207
260
|
creatureContract,
|
|
261
|
+
horizontalBipedContract,
|
|
208
262
|
serpentContract,
|
|
209
263
|
skeletonBones,
|
|
264
|
+
tailBoneNames,
|
|
210
265
|
trailBoneNames,
|
|
211
266
|
}
|
|
212
267
|
export type {
|
|
268
|
+
BipedStance,
|
|
213
269
|
CreatureTrail,
|
|
214
270
|
FixedSkeleton,
|
|
215
271
|
SkeletonChain,
|
|
@@ -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
|
}
|