@wildshard/shard-format 0.26.0 → 0.28.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 (50) hide show
  1. package/package.json +3 -1
  2. package/src/format/actorMoves.ts +32 -0
  3. package/src/format/audio-mp4.ts +1 -1
  4. package/src/format/audioProfiles.ts +1 -1
  5. package/src/format/brains.ts +3 -3
  6. package/src/format/builtIndexes.ts +2 -2
  7. package/src/format/clientChannels.ts +3 -3
  8. package/src/format/clientScripts.ts +1 -1
  9. package/src/format/contentBounds.ts +1 -1
  10. package/src/format/creature-layers.ts +44 -1
  11. package/src/format/creature-projectile.ts +32 -0
  12. package/src/format/creature-ranks.ts +37 -0
  13. package/src/format/creature-sizes.ts +45 -4
  14. package/src/format/creature-volumes.ts +5 -4
  15. package/src/format/creatures.ts +20 -3
  16. package/src/format/crowds.ts +1 -1
  17. package/src/format/deviceMemoryCost.ts +2 -2
  18. package/src/format/directorStages.ts +3 -3
  19. package/src/format/flyers.ts +2 -2
  20. package/src/format/grazers.ts +2 -2
  21. package/src/format/items.ts +1 -1
  22. package/src/format/materialGraph.ts +7 -7
  23. package/src/format/materials.ts +10 -10
  24. package/src/format/memoryAdmission.ts +1 -1
  25. package/src/format/namedJsonContracts.ts +1 -1
  26. package/src/format/nativeGround.ts +3 -3
  27. package/src/format/navigation.ts +2 -2
  28. package/src/format/parsed-json.ts +91 -0
  29. package/src/format/placement-page-text.ts +281 -0
  30. package/src/format/questHost.ts +1 -1
  31. package/src/format/rows.ts +18 -5
  32. package/src/format/runtime-tier.ts +56 -0
  33. package/src/format/runtimeBinds.ts +6 -6
  34. package/src/format/runtimeCost.ts +1 -1
  35. package/src/format/runtimeSpawns.ts +2 -2
  36. package/src/format/scaledPostContract.ts +2 -2
  37. package/src/format/scriptAbi.ts +1 -1
  38. package/src/format/scriptWireV2.ts +1 -1
  39. package/src/format/shardSchema.ts +2 -2
  40. package/src/format/shardfile-assets.ts +1 -1
  41. package/src/format/shardfileValidation.ts +2 -1
  42. package/src/format/skin-file.ts +3 -0
  43. package/src/format/skinData.ts +39 -19
  44. package/src/format/skins.ts +21 -2
  45. package/src/format/sourceResidency.ts +1 -1
  46. package/src/format/spawnCombat.ts +10 -5
  47. package/src/format/standalone-catalogue.ts +1 -1
  48. package/src/format/terrain.ts +1 -1
  49. package/src/format/validationReceipt.ts +2 -2
  50. package/src/format/weaponProfiles.ts +2 -2
@@ -8,8 +8,10 @@ import { isJsonData } from './json.ts';
8
8
  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
- import type { CreatureLayers } from './creature-layers.ts';
11
+ import type { CreatureAbilityInput, CreatureLayers } from './creature-layers.ts';
12
12
  import { creatureSizeRules } from './creature-sizes.ts';
13
+ import { SKIN_CLIPS_RECIPE, SkinClipMapSchema } from './skins.ts';
14
+ import type { SkinClipMap } from './skins.ts';
13
15
 
14
16
  const id = v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9.:-]*$/u), v.maxLength(128));
15
17
  const text = v.pipe(v.string(), v.maxLength(4096));
@@ -52,8 +54,12 @@ const species = v.strictObject({ id, kind: id, label: text, capExempt: v.exactOp
52
54
  temperament: v.exactOptional(CreatureTemperamentSchema), senses: v.exactOptional(CreatureSensesSchema),
53
55
  abilities: v.exactOptional(abilities), presentation: v.exactOptional(CreaturePresentationSchema) });
54
56
  const parameter = v.union([finite, v.boolean(), text, v.pipe(v.array(finite), v.maxLength(16))]);
57
+ const animationParameters = v.record(id, parameter);
58
+ const lookAnimation = v.strictObject({
59
+ recipe: id, parameters: animationParameters, clipMap: v.exactOptional(SkinClipMapSchema),
60
+ });
55
61
  const look = v.strictObject({ id, species: id, recipe: id, material: v.optional(v.nullable(id), null), parameters: v.record(id, parameter),
56
- animation: v.strictObject({ recipe: id, parameters: v.record(id, parameter) }) });
62
+ animation: lookAnimation });
57
63
  const basicCompendium = v.strictObject({ id, className: id, title: text, tabs: v.pipe(v.array(v.strictObject({ id, label: text })), v.maxLength(16)), stamp: text,
58
64
  stats: v.pipe(v.array(v.strictObject({ label: text, value: text })), v.maxLength(8)),
59
65
  entries: v.pipe(v.array(v.strictObject({ id, kind: v.literal('species'), tab: id, name: text, notes: text, sketch: v.pipe(text, v.check(sketchReference, 'bounded inert SVG data or admitted sketch hash')), species: id })), v.maxLength(256)) });
@@ -81,7 +87,12 @@ function rowRules(rows: ShardRows): string[] {
81
87
  const strikeIds = new Set<string>();
82
88
  for (const strikeRow of rows.strikes) { strikeIds.add(strikeRow.id); }
83
89
  const lookIds = new Set<string>();
84
- for (const lookRow of rows.looks) { lookIds.add(lookRow.id); }
90
+ for (const lookRow of rows.looks) {
91
+ lookIds.add(lookRow.id);
92
+ if (lookRow.animation.clipMap !== undefined && lookRow.animation.recipe !== SKIN_CLIPS_RECIPE) {
93
+ errors.push('Clip maps require platform.clips');
94
+ }
95
+ }
85
96
  for (const speciesRow of rows.species) {
86
97
  for (const ability of speciesRow.abilities ?? []) {
87
98
  if (!strikeIds.has(ability.use)) { errors.push(`Unknown creature ability: ${ability.use}`); }
@@ -109,9 +120,11 @@ function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input
109
120
  /** Admitted author data independent of validator implementation metadata. */
110
121
  type StrikeRowsInput = StrikeRows;
111
122
  interface StrikeRows { debris?: StrikeDebrisPolicy; id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; }
112
- interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
123
+ interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRowInput[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap<string>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
113
124
  // oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
114
- type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
125
+ type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; clipMap?: SkinClipMap; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
126
+
127
+ type SpeciesRowInput = Omit<SpeciesRow, "abilities"> & { abilities?: CreatureAbilityInput[] };
115
128
 
116
129
  /** A species keeps its old fields, with optional explicit creature layers. */
117
130
  interface SpeciesRow extends CreatureLayers { capExempt?: boolean; harvest?: HarvestDrop[]; id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
@@ -0,0 +1,56 @@
1
+ import { budgetTierLimits } from './budget-tiers.ts'
2
+ import { runtimeAccountedBytes } from './runtimeCost.ts'
3
+
4
+ import type { BudgetTier } from './budget-tiers.ts'
5
+
6
+ /** The tier an unnamed runtime is held to until OF10c1b names every runtime shard's tier. */
7
+ const UNNAMED_TIER: BudgetTier = 'large'
8
+
9
+ /** What the check reads of a shard: its runtime's reviewed cost and its budgets. */
10
+ type RuntimeTierSource = Readonly<{
11
+ runtime: Readonly<{ cost?: unknown }> | null
12
+ budgets: Readonly<{ client?: unknown; tier?: BudgetTier }>
13
+ }>
14
+
15
+ interface RuntimeTierIssue {
16
+ readonly code: 'runtime-tier-memory'
17
+ readonly metric: string
18
+ readonly actual: number
19
+ readonly limit: number
20
+ readonly severity: 'refusal'
21
+ }
22
+
23
+ /**
24
+ * ONE-FORMAT OF10c1a: a runtime fits its tier. A shard with a runtime and a reviewed cost (`runtime.cost`, else
25
+ * `budgets.client`) refuses at build and at upload when the runtime's accounted bytes (`runtimeAccountedBytes`: what
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.
28
+ */
29
+ function runtimeTierIssues(source: RuntimeTierSource): RuntimeTierIssue[] {
30
+ const cost = source.runtime?.cost ?? source.budgets.client
31
+ if (source.runtime === null || cost === undefined) {
32
+ return []
33
+ }
34
+ const tier = source.budgets.tier ?? UNNAMED_TIER
35
+ const limit = budgetTierLimits({ tier }).memoryBytes
36
+ const actual = runtimeAccountedBytes(cost)
37
+ if (actual <= limit) {
38
+ return []
39
+ }
40
+ return [
41
+ {
42
+ code: 'runtime-tier-memory',
43
+ metric: `runtime accounted bytes over the ${tier} tier's memory (OF10c1a: name a larger tier or shrink the runtime)`,
44
+ actual,
45
+ limit,
46
+ severity: 'refusal',
47
+ },
48
+ ]
49
+ }
50
+
51
+ export {
52
+ UNNAMED_TIER,
53
+ type RuntimeTierIssue,
54
+ type RuntimeTierSource,
55
+ runtimeTierIssues,
56
+ }
@@ -2,11 +2,11 @@ import type { Shardfile } from './shardSchema.ts';
2
2
  import * as v from 'valibot';
3
3
 
4
4
  /**
5
- * The behaviour sections a trusted hybrid runtime may bind (SHARD-PLATFORM M3, the runtime-owner binding, E435). A hybrid
5
+ * The behaviour sections a native runtime may bind (SHARD-PLATFORM M3, the runtime-owner binding, E435). A runtime shard
6
6
  * shard's runtime owns its world and its play scope; a section named here stays declared data in the shardfile, validated
7
7
  * like every row, and the platform installs it into that runtime's play scope through the same installers the template
8
- * uses (`@wildshard/game/shardfile/hybridRows`). The data client never installs a bound section a second time, and a bound
9
- * section's rows do not make a hybrid shardfile "non-empty": only an unbound behaviour row sends a hybrid shard down the
8
+ * uses (`@wildshard/game/shardfile/runtimeBoundRows`). The data client never installs a bound section a second time, and a bound
9
+ * section's rows do not make a runtime shardfile "non-empty": only an unbound behaviour row sends a runtime shard down the
10
10
  * full shardfile loader.
11
11
  *
12
12
  * - `quests`: quest graphs, flags and dialogue; the runtime supplies its flags and places world-piece markers.
@@ -25,14 +25,14 @@ import * as v from 'valibot';
25
25
  * Its Wasm roots remain verified product files and never create a data-client host.
26
26
  * - `clientChannels`: copied clock/state observations and bounded straight-line numeric expressions; the runtime
27
27
  * binds private visual targets, never authoritative state or player objects.
28
- * - `terrain`: a trusted runtime owns the terrain queries and draw construction. The data client omits those rows;
28
+ * - `terrain`: a native runtime owns the terrain queries and draw construction. The data client omits those rows;
29
29
  * unbound drawn tiles use the page's shared tile streamer. Edge rows remain platform data.
30
- * - `loot`: the trusted runtime consumes the original economy rows; only the secondary data client omits them.
30
+ * - `loot`: the native runtime consumes the original economy rows; only the secondary data client omits them.
31
31
  * - `props` (G227): the compiled props section (tiles, library models, panels, far proxy), bound the same way; the
32
32
  * runtime keeps the behaviour of the pieces it dresses.
33
33
  */
34
34
  export const RUNTIME_BOUND_SECTIONS = ['quests', 'ledger', 'items', 'spawns', 'state', 'terrain', 'props', 'modes', 'clientChannels', 'movers', 'loot'] as const;
35
- /** One section a trusted runtime binds rather than the data client. */
35
+ /** One section a native runtime binds rather than the data client. */
36
36
  export type RuntimeBoundSection = (typeof RUNTIME_BOUND_SECTIONS)[number];
37
37
  /** `runtime.binds`: the declared capability that replaces the implicit "empty apart from audio, edges and colliders" rule. */
38
38
  export const RuntimeBindsSchema: v.GenericSchema<RuntimeBindsRowsInput, RuntimeBindsRows> = v.pipe(v.array(v.picklist(RUNTIME_BOUND_SECTIONS)), v.maxLength(RUNTIME_BOUND_SECTIONS.length),
@@ -4,7 +4,7 @@ import { RUNTIME_RESIDENT_FACTOR } from './wireLimits.ts';
4
4
  const mb = v.pipe(v.number(), v.finite(), v.minValue(0));
5
5
  const FIRST_EPOCH = 1;
6
6
  const epochNumber = v.pipe(v.number(), v.integer(), v.minValue(FIRST_EPOCH));
7
- /** Reviewed trusted-runtime measurements, kept with their shard rather than presenting an empty data budget as its cost. */
7
+ /** Reviewed native-runtime measurements, kept with their shard rather than presenting an empty data budget as its cost. */
8
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({
9
9
  webContentMB: mb, glMB: mb, engineBaseMB: mb,
10
10
  /** Matched settled pre-entry resident set. When present, subtract it instead of the dated engine-only calibration. */
@@ -11,12 +11,12 @@ const home = v.strictObject({ id, kind, look: id, at, yaw: finite, respawn: v.pi
11
11
  const boss = v.strictObject({ id, kind, look: id, at, yaw: finite });
12
12
 
13
13
  /**
14
- * A trusted hybrid runtime's creatures as declared rows (SHARD-PLATFORM M3 / SF50-p, E435), the `spawns` section of
14
+ * A native runtime's creatures as declared rows (SHARD-PLATFORM M3 / SF50-p, E435), the `spawns` section of
15
15
  * `runtime.binds`. The runtime keeps its own species (rigs, brains, the hard 20 %); the rows declare WHERE they live and
16
16
  * WHO they are: each row's `id` is its stable declared key (a retained home uses it across respawn and cold restore).
17
17
  * One-shot actors keep their runtime-allocated identities and spawn order; `kind` / `look` name the runtime's registered
18
18
  * species and variant, and a home's `respawn` its refill delay.
19
- * The platform keeps the homes (`bindRuntimeHomes`, `bindRuntimeBoss` in ./hybridRows.ts); this is not the local sim's
19
+ * The platform keeps the homes (`bindRuntimeHomes`, `bindRuntimeBoss` in engine runtimeBoundRows); this is not the local sim's
20
20
  * `creatures` section (no brain, strike or species-catalogue rows: those stay the runtime's).
21
21
  */
22
22
  export const RuntimeSpawnsSchema: v.GenericSchema<RuntimeSpawnsInput, RuntimeSpawns> = v.pipe(v.strictObject({ homes: v.pipe(v.array(home), v.maxLength(256)), bosses: v.pipe(v.array(boss), v.maxLength(16)),
@@ -6,7 +6,7 @@ const number = v.pipe(v.number(), v.finite());
6
6
  const name = v.pipe(v.string(), v.minLength(1), v.maxLength(256));
7
7
  const storageSchema = v.picklist(['float16', 'unorm8']);
8
8
  const graph = v.custom<GraphIr>(input => {
9
- const checked = validateGraph(input, { trustedBudget: true });
9
+ const checked = validateGraph(input, { declaredBudget: true });
10
10
  return checked.ok && checked.graph.kind === 'post';
11
11
  }, 'Invalid scaled post graph');
12
12
  const term = v.union([number, name, v.null(), v.strictObject({ param: name }),
@@ -22,7 +22,7 @@ const schema: v.GenericSchema<unknown, ScaledPostRow> = v.strictObject({
22
22
  settings: v.record(name, number), when: v.exactOptional(name), outputs: v.record(name, name), drawnOnly: v.exactOptional(v.boolean()),
23
23
  });
24
24
 
25
- /** Complete native post preflight. Graphs keep the executor's trusted budget;
25
+ /** Complete native post preflight. Graphs keep the executor's host-owned budget;
26
26
  * target order, storage variants and draw/output references retain its rules.
27
27
  * The executor still checks these contracts before allocating and compiling. */
28
28
  export function parseScaledPostRow(input: unknown): ScaledPostRow {
@@ -10,5 +10,5 @@ export const SCRIPT_IMPORTS: Readonly<Record<string, readonly number[]>> = Objec
10
10
  finite32: [0x7d, 0x7d], finite64: [0x7c, 0x7c],
11
11
  });
12
12
 
13
- /** Read-only declared numeric parameters; the host supplies the trusted calling entity to the query adapter. */
13
+ /** Read-only declared numeric parameters; the host supplies the host-owned calling entity to the query adapter. */
14
14
  export const SCRIPT_PARAMETER_QUERY = 410;
@@ -36,7 +36,7 @@ export function writeV2Frame(view: DataView,layout: V2Layout,frame: V2Frame,coun
36
36
  }
37
37
  /** Reuse the last immutable count shape within one existing owner. Every call
38
38
  * validates current counts and captures a fresh detached header; no caller
39
- * authority or mutable input is retained as a trusted template. */
39
+ * authority or mutable input is retained as a host-owned template. */
40
40
  export function createV2FrameWriter(layout: V2Layout): (view: DataView,frame: V2Frame,counts: ReadonlyMap<number,number>) => V2FrameAuthority {
41
41
  let previous: readonly number[] | undefined;
42
42
  let available: number[] | undefined;
@@ -1,4 +1,4 @@
1
- import { creatureSizeRules } from './creature-sizes.ts';
1
+ import { creatureSizeRules, spawnCapacity } from './creature-sizes.ts';
2
2
  import { readSpeciesPrograms } from './speciesPrograms.ts';
3
3
  import type { StrikeDebrisPolicy } from './strike-debris.ts';
4
4
  import { strikeDebrisCatalogueRules } from './strike-debris.ts';
@@ -367,7 +367,7 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
367
367
  const crowdMembers = s.crowds.reduce((sum, row) => sum + row.count, 0);
368
368
  if (crowdMembers > 4096) errors.push('declared crowd member capacity');
369
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');
370
- if (s.creatures.spawns.length + crowdMembers > s.serverBudget.entities) errors.push('declared entity capacity');
370
+ if (spawnCapacity(s.creatures.spawns) + crowdMembers > s.serverBudget.entities) errors.push('declared entity capacity');
371
371
  errors.push(...creatureSizeRules(s.rows.species, s.creatures.spawns));
372
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');
373
373
  errors.push(...encounterRules(s.encounters, s.creatures.spawns.map((spawn) => spawn.id), s.ui.filter((row) => row.kind === 'bossPanel')));
@@ -305,7 +305,7 @@ export function validatePropDrawBounds(source: Shardfile, assets: ReadonlyMap<st
305
305
  for (const ref of [...props.panels.map(row => row.file), ...props.wholeLibrary ?? [], ...props.far === null ? [] : [props.far]]) validate(ref);
306
306
  }
307
307
 
308
- /** Report deterministic declared bounds and measured native execution; the caller supplies trusted provenance policy. */
308
+ /** Report deterministic declared bounds and measured native execution; the caller supplies host-owned provenance policy. */
309
309
  export function performanceReport(source: Shardfile, observations: PerformanceObservations, options: PerformancePolicy | PerformanceOptions = 'refuse'): PerformanceReport {
310
310
  const resolved: PerformanceOptions = typeof options === 'string' ? { policy: options, sections: new Map<string, unknown>() } : options, { policy } = resolved;
311
311
  const native = { resident: source.runtime?.cost === undefined ? 0 : runtimeOfflineBytes(source.runtime.cost), evidence: source.runtime?.cost?.evidence ?? null, unmeasuredViewAndDownload: source.runtime !== null };
@@ -22,6 +22,7 @@ import type { RecordingMeasure } from './audio-measure.ts';
22
22
  import { issueError, withIssueCode as coded } from './issue-codes.ts';
23
23
  import { staleRuntimeIssues } from './memory-epoch.ts';
24
24
  import { memoryContext, offlineMemoryIssues } from './memory-line.ts';
25
+ import { runtimeTierIssues } from './runtime-tier.ts';
25
26
  import type { MemoryContext } from './memory-line.ts';
26
27
  import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
27
28
 
@@ -111,7 +112,7 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
111
112
 
112
113
  /** Refuse the declared targets a policy treats as refusals, before any byte is read or executed. */
113
114
  export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse', context: MemoryContext = new Map()): void {
114
- const issues = [...staleRuntimeIssues(source.runtime), ...offlineMemoryIssues(source, context), ...performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal')];
115
+ const issues = [...staleRuntimeIssues(source.runtime), ...offlineMemoryIssues(source, context), ...runtimeTierIssues(source), ...performanceTargetIssues(source, policy).filter(issue => issue.severity === 'refusal')];
115
116
  if (issues.length === 0) return;
116
117
  throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
117
118
  }
@@ -35,6 +35,9 @@ function skinLookParameters(
35
35
  return {
36
36
  skin: look.output.skin,
37
37
  attackSpan: clips.output.attackSpan,
38
+ ...(row.animation.clipMap === undefined
39
+ ? {}
40
+ : { clipMap: row.animation.clipMap }),
38
41
  ...(look.output.variants === undefined
39
42
  ? {}
40
43
  : { variants: look.output.variants }),
@@ -2,52 +2,69 @@ import * as v from 'valibot';
2
2
  import { SkinPoseLayerSchema, validateSkinLayers } from './skinLayers.ts';
3
3
  import { SkinMaterialsSchema } from './skin-materials.ts';
4
4
  /** Animation clip identity; the native rig uses the same bounded family namespace. */
5
- export type SkinClipName = `${'idle' | 'walk' | 'run' | 'attack' | 'hit' | 'die' | 'turn' | 'swim' | 'fly'}${'' | `.${string}`}`;
5
+ type SkinClipName = `${'idle' | 'walk' | 'run' | 'attack' | 'hit' | 'die' | 'turn' | 'swim' | 'fly'}${'' | `.${string}`}`;
6
6
 
7
7
  const id = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u), v.maxLength(128));
8
8
  const hash = v.pipe(v.string(), v.regex(/^[0-9a-f]{64}$/u));
9
9
  /** Admitted clip family and optional lowercase action suffix; its transform is an identity type narrowing. */
10
- export const SkinClipNameSchema: v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows> & { readonly pipe: readonly [unknown, unknown, v.TransformAction<string, SkinClipName>] } = v.pipe(v.string(), v.regex(/^(idle|walk|run|attack|hit|die|turn|swim|fly)(\.[a-z][a-z0-9-]*)?$/u), v.transform((name) => name as SkinClipName));
10
+ const SkinClipNameSchema: v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows> & { readonly pipe: readonly [unknown, unknown, v.TransformAction<string, SkinClipName>] } = v.pipe(v.string(), v.regex(/^(idle|walk|run|attack|hit|die|turn|swim|fly)(\.[a-z][a-z0-9-]*)?$/u), v.transform((name) => name as SkinClipName));
11
+
12
+ declare const creatureClipName: unique symbol;
13
+ /** Exported skins can also use a validated name supplied by a creature author. */
14
+ type CreatureSkinClipName = SkinClipName | (string & { readonly [creatureClipName]: true });
15
+ const MAX_NAMED_CLIP_LENGTH = 64;
16
+ const namedClip = v.pipe(
17
+ v.string(),
18
+ v.maxLength(MAX_NAMED_CLIP_LENGTH),
19
+ v.regex(/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)?$/u),
20
+ v.transform((name): CreatureSkinClipName => name as CreatureSkinClipName),
21
+ );
22
+ const CreatureSkinClipNameSchema: v.GenericSchema<string, CreatureSkinClipName> =
23
+ v.union([SkinClipNameSchema, namedClip]);
11
24
  const joint = v.pipe(v.string(), v.regex(/^[A-Za-z][A-Za-z0-9_.-]*$/u), v.maxLength(64));
12
25
  const bytes = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(25_000_000));
13
26
 
14
27
  /** One exported skin: the GLB hash and rig. Clips may be empty for a poser-driven
15
28
  * rig; loop bindings must still name a declared clip. */
16
- export const SkinRowSchema: v.GenericSchema<SkinRowInput, SkinRow> = v.object({
29
+ const SkinRowSchema: v.GenericSchema<SkinRowInput, SkinRow> = v.object({
17
30
  id, file: hash, family: v.picklist(['toon', 'pbr']),
18
- rig: v.strictObject({ skeleton: v.pipe(v.string(), v.regex(/^[a-z][A-Za-z0-9.]*$/u), v.maxLength(128)), joints: v.pipe(v.array(v.pipe(v.array(joint), v.minLength(1), v.maxLength(128))), v.length(1)), clips: v.pipe(v.array(SkinClipNameSchema), v.maxLength(32)), sockets: v.pipe(v.array(joint), v.maxLength(32)) }),
31
+ rig: v.strictObject({ skeleton: v.pipe(v.string(), v.regex(/^[a-z][A-Za-z0-9.]*$/u), v.maxLength(128)), joints: v.pipe(v.array(v.pipe(v.array(joint), v.minLength(1), v.maxLength(128))), v.length(1)), clips: v.pipe(v.array(CreatureSkinClipNameSchema), v.maxLength(32)), sockets: v.pipe(v.array(joint), v.maxLength(32)) }),
19
32
  cost: v.strictObject({ decoded: bytes, gpu: bytes, triangles: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(400_000)), draws: v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(512)) }),
20
33
  });
21
34
  /** A validated exported skin row. */
22
35
 
23
36
  /** How a skin plays and draws: the family material entry (SF10a, validated by the family registry) the clips that loop and independent numeric pose clocks; `materials` (TE-ENG10) maps GLB material names to look materials (`./skin-materials`). */
24
- export const SkinBindingSchema: v.GenericSchema<SkinBindingInput, SkinBinding> = v.strictObject({ skin: id, material: v.record(v.string(), v.unknown()), materials: v.exactOptional(SkinMaterialsSchema), loops: v.pipe(v.array(SkinClipNameSchema), v.maxLength(32)), poseLayers: v.exactOptional(v.record(SkinClipNameSchema, v.pipe(v.array(SkinPoseLayerSchema), v.maxLength(32)))) });
37
+ const SkinBindingSchema: v.GenericSchema<SkinBindingInput, SkinBinding> = v.strictObject({ skin: id, material: v.record(v.string(), v.unknown()), materials: v.exactOptional(SkinMaterialsSchema), loops: v.pipe(v.array(CreatureSkinClipNameSchema), v.maxLength(32)), poseLayers: v.exactOptional(v.record(CreatureSkinClipNameSchema, v.pipe(v.array(SkinPoseLayerSchema), v.maxLength(32)))) });
25
38
  /** A validated skin binding. */
26
39
 
27
40
 
28
41
  /** Every creature kind, including flying/custom rigs, exposes body and head for collision and view binding. */
29
- export function validateCreatureBones(species: string, names: readonly string[]): void {
42
+ function validateCreatureBones(species: string, names: readonly string[]): void {
30
43
  for (const bone of ['body', 'head']) {
31
44
  if (!names.includes(bone)) throw new Error(`species '${species}': rig missing required bone '${bone}'`);
32
45
  }
33
46
  }
34
47
 
35
48
  /** Validate the export half's rows; unknown fields (its notes and motion receipt) are ignored. */
36
- export function parseSkinRows(input: unknown): SkinRow[] {
49
+ function parseSkinRows(input: unknown): SkinRow[] {
37
50
  const r = v.safeParse(v.pipe(v.array(SkinRowSchema), v.maxLength(256)), input);
38
51
  if (!r.success) throw new Error(`skins: ${r.issues.map((i) => `${v.getDotPath(i) ?? '(root)'}: ${i.message}`).join('; ')}`);
39
52
  if (new Set(r.output.map((row) => row.id)).size !== r.output.length) throw new Error('skins: unique ids');
40
53
  return r.output;
41
54
  }
42
55
  /** Validate skin bindings against their rows: one per skin, loops only over the row's clips, with bounded periodic layer tables. */
43
- export function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): SkinBinding[] {
56
+ function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): SkinBinding[] {
44
57
  const r = v.safeParse(v.pipe(v.array(SkinBindingSchema), v.maxLength(256)), input);
45
58
  if (!r.success) throw new Error(`skin bindings: ${r.issues.map((i) => `${v.getDotPath(i) ?? '(root)'}: ${i.message}`).join('; ')}`);
46
59
  for (const binding of r.output) {
47
60
  const row = rows.find((candidate) => candidate.id === binding.skin);
48
61
  if (row === undefined) throw new Error(`skin bindings: no skin ${binding.skin}`);
49
62
  if (binding.loops.some((name) => !row.rig.clips.includes(name))) throw new Error(`skin bindings: ${binding.skin} loops an unknown clip`);
50
- for (const [name, layers] of Object.entries(binding.poseLayers ?? {})) { if (layers === undefined) continue; if (!binding.loops.includes(name as SkinClipName)) throw new Error('skin layers require a looping base'); validateSkinLayers(layers, row.rig.joints[0] ?? []); }
63
+ for (const [name, layers] of Object.entries(binding.poseLayers ?? {})) {
64
+ if (layers === undefined) continue;
65
+ if (!binding.loops.some((loop): boolean => loop === name)) throw new Error('skin layers require a looping base');
66
+ validateSkinLayers(layers, row.rig.joints[0] ?? []);
67
+ }
51
68
  }
52
69
  if (new Set(r.output.map((binding) => binding.skin)).size !== r.output.length) throw new Error('skin bindings: one per skin');
53
70
  return r.output;
@@ -55,8 +72,8 @@ export function parseSkinBindings(input: unknown, rows: readonly SkinRow[]): Ski
55
72
 
56
73
 
57
74
  /** Admitted data contracts, independent of validator implementation metadata. */
58
- export type SkinClipNameRowsInput = string;
59
- export type SkinClipNameRows = SkinClipName;
75
+ type SkinClipNameRowsInput = string;
76
+ type SkinClipNameRows = SkinClipName;
60
77
  interface SkinRowInputFields {
61
78
  id: string;
62
79
  file: string;
@@ -74,7 +91,7 @@ interface SkinRowInputFields {
74
91
  draws: number;
75
92
  };
76
93
  }
77
- export type SkinRowInput = { [Key in keyof SkinRowInputFields]: SkinRowInputFields[Key] };
94
+ type SkinRowInput = { [Key in keyof SkinRowInputFields]: SkinRowInputFields[Key] };
78
95
  interface SkinRowFields {
79
96
  id: string;
80
97
  file: string;
@@ -82,7 +99,7 @@ interface SkinRowFields {
82
99
  rig: {
83
100
  skeleton: string;
84
101
  joints: ((string)[])[];
85
- clips: (SkinClipNameRows)[];
102
+ clips: CreatureSkinClipName[];
86
103
  sockets: (string)[];
87
104
  };
88
105
  cost: {
@@ -92,20 +109,23 @@ interface SkinRowFields {
92
109
  draws: number;
93
110
  };
94
111
  }
95
- export type SkinRow = { [Key in keyof SkinRowFields]: SkinRowFields[Key] };
112
+ type SkinRow = { [Key in keyof SkinRowFields]: SkinRowFields[Key] };
96
113
  interface SkinBindingInputFields {
97
114
  skin: string;
98
115
  material: Record<string, unknown>;
99
116
  materials?: Record<string, string>;
100
117
  loops: (SkinClipNameRowsInput)[];
101
- poseLayers?: v.InferInput<v.RecordSchema<v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
118
+ poseLayers?: v.InferInput<v.RecordSchema<v.GenericSchema<string, CreatureSkinClipName>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
102
119
  }
103
- export type SkinBindingInput = { [Key in keyof SkinBindingInputFields]: SkinBindingInputFields[Key] };
120
+ type SkinBindingInput = { [Key in keyof SkinBindingInputFields]: SkinBindingInputFields[Key] };
104
121
  interface SkinBindingFields {
105
122
  skin: string;
106
123
  material: Record<string, unknown>;
107
124
  materials?: Record<string, string>;
108
- loops: (SkinClipNameRows)[];
109
- poseLayers?: v.InferOutput<v.RecordSchema<v.GenericSchema<SkinClipNameRowsInput, SkinClipNameRows>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
125
+ loops: CreatureSkinClipName[];
126
+ poseLayers?: v.InferOutput<v.RecordSchema<v.GenericSchema<string, CreatureSkinClipName>, v.GenericSchema<(v.InferInput<typeof SkinPoseLayerSchema>)[], (v.InferOutput<typeof SkinPoseLayerSchema>)[]>, undefined>>;
110
127
  }
111
- export type SkinBinding = { [Key in keyof SkinBindingFields]: SkinBindingFields[Key] };
128
+ type SkinBinding = { [Key in keyof SkinBindingFields]: SkinBindingFields[Key] };
129
+
130
+ export { SkinClipNameSchema, CreatureSkinClipNameSchema, SkinRowSchema, SkinBindingSchema, validateCreatureBones, parseSkinRows, parseSkinBindings };
131
+ export type { SkinClipName, CreatureSkinClipName, SkinClipNameRowsInput, SkinClipNameRows, SkinRowInput, SkinRow, SkinBindingInput, SkinBinding };
@@ -1,4 +1,6 @@
1
1
  import * as v from 'valibot';
2
+ import { CreatureSkinClipNameSchema } from './skinData.ts';
3
+ import type { CreatureSkinClipName } from './skinData.ts';
2
4
 
3
5
  /** The look recipe for an exported skin, and its animation recipe. */
4
6
  const SKIN_LOOK_RECIPE = 'platform.skin';
@@ -18,13 +20,30 @@ interface SkinVariantsFields { version: typeof VARIANTS_VERSION; skins: Record<s
18
20
  type SkinVariants = { [Key in keyof SkinVariantsFields]: SkinVariantsFields[Key] };
19
21
  const SkinVariantsSchema: v.GenericSchema<SkinVariants> = v.strictObject({ version: v.literal(VARIANTS_VERSION),
20
22
  skins: variantSkins });
23
+ type SkinClipState = 'idle' | 'idle.graze' | 'walk' | 'attack' | 'hit' | 'die';
24
+ interface SkinClipMap<Name extends string = CreatureSkinClipName> {
25
+ states?: Partial<Record<SkinClipState, Name>>;
26
+ abilities?: Record<string, Name>;
27
+ }
28
+ const MAX_ABILITY_ID = 128;
29
+ const MAX_ABILITY_CLIPS = 32;
30
+ const clipSlot = v.exactOptional(CreatureSkinClipNameSchema);
31
+ const abilityName = v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9.:-]*$/u), v.maxLength(MAX_ABILITY_ID));
32
+ const stateClips = v.strictObject({
33
+ idle: clipSlot, 'idle.graze': clipSlot, walk: clipSlot, attack: clipSlot, hit: clipSlot, die: clipSlot,
34
+ });
35
+ const abilityClips = v.pipe(v.record(abilityName, CreatureSkinClipNameSchema), v.maxEntries(MAX_ABILITY_CLIPS));
36
+ const SkinClipMapSchema: v.GenericSchema<SkinClipMap<string>, SkinClipMap> = v.strictObject({
37
+ states: v.exactOptional(stateClips),
38
+ abilities: v.exactOptional(abilityClips),
39
+ });
21
40
  /** The animation recipe's parameters. */
22
41
  const SkinClipParametersSchema: v.GenericSchema<SkinClipParametersRowsInput, SkinClipParametersRows> = v.strictObject({ attackSpan: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0.05), v.maxValue(10)), 1) });
23
42
  /** The content-addressed skin file: one export row and its binding (validated together by the SF9c parsers). */
24
43
  const ShardSkinFileSchema: v.GenericSchema<ShardSkinFileRowsInput, ShardSkinFileRows> = v.strictObject({ row: v.unknown(), binding: v.unknown() });
25
44
 
26
45
  /** A parsed skin look: the file it names and the attack span its clip was sampled with. */
27
- interface SkinLookParameters { skin: string; variants?: string; attackSpan: number }
46
+ interface SkinLookParameters { skin: string; variants?: string; attackSpan: number; clipMap?: SkinClipMap }
28
47
 
29
48
  /** Admitted data contracts, independent of validator implementation metadata. */
30
49
  type SkinLookParametersRowsInput = SkinLookParametersRows;
@@ -48,4 +67,4 @@ interface ShardSkinFileRowsFields {
48
67
  }
49
68
  type ShardSkinFileRows = { [Key in keyof ShardSkinFileRowsFields]: ShardSkinFileRowsFields[Key] };
50
69
 
51
- export { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE, SkinLookParametersSchema, type SkinVariants, SkinVariantsSchema, SkinClipParametersSchema, ShardSkinFileSchema, type SkinLookParameters, type SkinLookParametersRowsInput, type SkinLookParametersRows, type SkinClipParametersRowsInput, type SkinClipParametersRows, type ShardSkinFileRowsInput, type ShardSkinFileRows };
70
+ export { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE, SkinLookParametersSchema, type SkinVariants, SkinVariantsSchema, SkinClipParametersSchema, SkinClipMapSchema, ShardSkinFileSchema, type SkinClipMap, type SkinClipState, type SkinLookParameters, type SkinLookParametersRowsInput, type SkinLookParametersRows, type SkinClipParametersRowsInput, type SkinClipParametersRows, type ShardSkinFileRowsInput, type ShardSkinFileRows };
@@ -8,7 +8,7 @@ function shardfileWireBytes(source:Wire):number{
8
8
  return source.files.reduce((sum,file)=>sum+file.compressed,0)
9
9
  +source.requires.commons.reduce((sum,hash)=>sum+(source.requires.commonsWire[hash]??0),0);
10
10
  }
11
- /** Exact existing source/wire claim, computed once by the publisher for first-party clients. */
11
+ /** Exact existing source/wire claim, computed once by the publisher for built-in clients. */
12
12
  function publishedSourceResidency(source:Shardfile):number{
13
13
  const accounting={heapBytes:0};preflightShardfile(source,accounting);
14
14
  return shardfileWireBytes(source)+accounting.heapBytes*2+(source.files.length+source.requires.commons.length)*128+1024;
@@ -4,23 +4,28 @@ import { CreatureStrikeSchema } from './creatures.ts';
4
4
 
5
5
  const id = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
6
6
  const amount = v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(60));
7
+ type StrikeTellKind = 'lane' | 'ring';
8
+ const StrikeTellKindSchema: v.GenericSchema<StrikeTellKind> = v.picklist(['lane', 'ring']);
7
9
  /** V1 strike capabilities use the existing contact kernel. Effects and presentation edges are rows, never hooks. */
8
- export const SpawnCombatSchema: v.GenericSchema<SpawnCombatInput, SpawnCombat> = v.pipe(v.unknown(), v.check(isJsonData, 'plain JSON scripted strikes'), v.array(v.strictObject({ id, row: CreatureStrikeSchema,
10
+ const SpawnCombatSchema: v.GenericSchema<SpawnCombatInput, SpawnCombat> = v.pipe(v.unknown(), v.check(isJsonData, 'plain JSON scripted strikes'), v.array(v.strictObject({ id, row: CreatureStrikeSchema,
9
11
  trauma: v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(1)), stun: amount,
10
- tell: v.exactOptional(v.picklist(['lane', 'ring'])), startCue: v.exactOptional(id), activeCue: v.exactOptional(id), doneCue: v.exactOptional(id),
12
+ tell: v.exactOptional(StrikeTellKindSchema), startCue: v.exactOptional(id), activeCue: v.exactOptional(id), doneCue: v.exactOptional(id),
11
13
  })), v.maxLength(32), v.check(rows => new Set(rows.map(row => row.id)).size === rows.length
12
14
  && new Set(rows.map(row => row.row.id)).size === rows.length, 'unique scripted strikes'));
13
15
 
14
16
 
15
17
  /** Admitted data contracts, independent of validator implementation metadata. */
16
- export type SpawnCombatInput = unknown;
17
- export type SpawnCombat = ({
18
+ type SpawnCombatInput = unknown;
19
+ type SpawnCombat = ({
18
20
  id: string;
19
21
  row: v.InferOutput<typeof CreatureStrikeSchema>;
20
22
  trauma: number;
21
23
  stun: number;
22
- tell?: 'lane' | 'ring';
24
+ tell?: StrikeTellKind;
23
25
  startCue?: string;
24
26
  activeCue?: string;
25
27
  doneCue?: string;
26
28
  })[];
29
+
30
+ export { SpawnCombatSchema, StrikeTellKindSchema };
31
+ export type { SpawnCombat, SpawnCombatInput, StrikeTellKind };
@@ -33,7 +33,7 @@ import type { GenericSchema } from 'valibot'
33
33
  // `placements` are `src/game/shared/grid/singleplayer.json` today, field for
34
34
  // field. A cell's `slug` keeps the authored spelling, so `_template` stays
35
35
  // `_template` although its product's `identity.slug` cannot start with an
36
- // underscore: `shardSlugOf` is the one mapping, as `firstPartyInstance` does.
36
+ // underscore: `shardSlugOf` is the one mapping, as `catalogueInstance` does.
37
37
 
38
38
  const FORMAT_VERSION = 0
39
39
  const MIN_SIZE = 1
@@ -43,7 +43,7 @@ const metre = v.pipe(v.number(), v.finite(), v.minValue(-1000), v.maxValue(1000)
43
43
  const groundPoint = v.tuple([metre, metre]);
44
44
  const seed = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(0xffffffff));
45
45
  /**
46
- * A hybrid shard's declared ground (G4): its baked terrain by key and seed, the trails, pads and pond its terrain metadata
46
+ * A runtime shard's declared ground (G4): its baked terrain by key and seed, the trails, pads and pond its terrain metadata
47
47
  * reads (grading masks, grass and forest clearings), its rest water level and render datum. Ordinary bodies use the
48
48
  * shardfile's water grammar; a ground-only basin borrows this field's mask and live water level. The game builds the
49
49
  * manifest ground from these rows (`declaredGround`); no shard code. Generated from the shard's own layout.
@@ -119,7 +119,7 @@ export async function validationSourceBytesPaced(source: unknown, pause: () => P
119
119
  }
120
120
  /** The build hashes the engine/game validator sources; unbundled clients always validate in full. */
121
121
  export function validationRevision(): string | null { return typeof __SHARDFILE_VALIDATOR__ === 'string' ? __SHARDFILE_VALIDATOR__ : null; }
122
- /** Cache metadata is trusted local storage, but stale or malformed verdicts are never accepted. */
122
+ /** Cache metadata is host-owned local storage, but stale or malformed verdicts are never accepted. */
123
123
  export function readValidationReceipt(input: unknown, sourceHash: string): ValidationReceipt | null {
124
124
  if (typeof input !== 'object' || input === null || !('revision' in input) || typeof input.revision !== 'string' || input.revision !== validationRevision() || !('sourceHash' in input) || input.sourceHash !== sourceHash || !('worst' in input)) return null;
125
125
  const indexHash: unknown = 'indexHash' in input ? input.indexHash : undefined;
@@ -133,7 +133,7 @@ export function readValidationReceipt(input: unknown, sourceHash: string): Valid
133
133
  if (typeof cost.playing !== 'number' || typeof cost.loading !== 'number' || typeof cost.accounted !== 'number' || typeof cost.location[0] !== 'number' || typeof cost.location[1] !== 'number') return null;
134
134
  return { revision: input.revision, sourceHash, ...(typeof indexHash === 'string' ? { indexHash } : {}),...(typeof residentBytes==='number'?{residentBytes}:{}), worst: { playing: cost.playing, loading: cost.loading, accounted: cost.accounted, location: [cost.location[0], cost.location[1]] } };
135
135
  }
136
- /** Only the client build's own validated first-party catalogue can skip a first asset-header validation. */
136
+ /** Only the client build's own validated built-in catalogue can skip a first asset-header validation. */
137
137
  export function builtValidationReceipt(sourceHash: string, indexHash?: string): ValidationReceipt | null {
138
138
  const rows: unknown = typeof __SHARDFILE_VERDICTS__ === 'object' ? __SHARDFILE_VERDICTS__ : null;
139
139
  if (!Array.isArray(rows)) return null;
@@ -75,7 +75,7 @@ export const ThrownWeaponProfileSchema: v.SchemaWithPipe<readonly [v.StrictObjec
75
75
  }), v.check(row => row.carried <= row.pool, 'Carried thrown weapons fit the native pool'));
76
76
 
77
77
  /** Native timed lash contacts: bounded unroll/double-crack clocks, pull/stagger reactions and named pipeline moves.
78
- * The profile supplies values only; the trusted family retains its contact ordering and continuation. */
78
+ * The profile supplies values only; the native family retains its contact ordering and continuation. */
79
79
  export const LashWeaponProfileSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly family: v.GenericSchema<LashWeaponProfileRowsInput['family'], LashWeaponProfileRows['family']>; readonly contact: v.ExactOptionalSchema<v.GenericSchema<Exclude<LashWeaponProfileRowsInput['contact'], undefined>, Exclude<LashWeaponProfileRows['contact'], undefined>>, undefined>; readonly timing: v.GenericSchema<LashWeaponProfileRowsInput['timing'], LashWeaponProfileRows['timing']>; readonly moves: v.GenericSchema<LashWeaponProfileRowsInput['moves'], LashWeaponProfileRows['moves']>; }, undefined>, v.CheckAction<{ [K in keyof LashWeaponProfileRows]: LashWeaponProfileRows[K] }, 'Ordered native lash contacts'>]> = v.pipe(v.strictObject({
80
80
  family: v.literal('lash'),
81
81
  contact: v.exactOptional(v.strictObject({ chestHeight: scalar, bodyAllowance: scalar })),
@@ -93,7 +93,7 @@ const reaction = v.variant('kind', [
93
93
  v.strictObject({ when: v.picklist(['before', 'survived']), kind: v.literal('stagger'),
94
94
  strength: scalar, aboveHealth: v.exactOptional(scalar) }),
95
95
  ]);
96
- /** Ordered cone/lane contacts, with authority supplied by the trusted owner rather than JSON. */
96
+ /** Ordered cone/lane contacts, with authority supplied by the native owner rather than JSON. */
97
97
  export const MeleeContactRowSchema: v.GenericSchema<MeleeContactDataInput, MeleeContactData> = v.pipe(v.strictObject({
98
98
  lane: v.picklist(['primary', 'secondary']), heavy: v.boolean(), cooldown: seconds,
99
99
  shape: v.picklist(['cone', 'lane']), reach: v.pipe(positive, v.maxValue(20)),