3D engine that AI agents drive
Merge scene-core and nature error messages and trim capabilities index (issue #653)
Nguyen Xuan An3e6ff0a4838d
diff --cc changes/653-nature.mdindex 00000000,00000000..e7531953new file mode 100644--- /dev/null+++ b/changes/653-nature.md@@@ -1,0 -1,0 +1,1 @@@++- The same readable errors now cover vegetation (`nodes[3].vegetation.scatter.density: got 9; expected a number from 0.0001 to 4, such as 1.`), `environment.wind`, particles and hair, cloth sheets and colliders, and image sequence maps: each names the full field path, the value received and an accepted example or range (#653)diff --cc changes/653-nature.size.mdindex 00000000,00000000..ac70da3bnew file mode 100644--- /dev/null+++ b/changes/653-nature.size.md@@@ -1,0 -1,0 +1,1 @@@++- scene:agent-scene+lazy: about 700 bytes gzip of message text in the vegetation, particle, hair, cloth and image sequence validators; nothing new runs unless a recipe is rejected, and an agent fixes the input in one retry.diff --cc scripts/capabilities-topics.mjsindex a52adea2,a52adea2..acc751a5--- a/scripts/capabilities-topics.mjs+++ b/scripts/capabilities-topics.mjs@@@ -72,7 -72,7 +72,7 @@@ export function answerCapabilities(capareturn {format: capabilities.scene.format, schemaVersion: capabilities.scene.schemaVersion,phase: capabilities.phase, availableIn: capabilities.availableIn,-- how: 'Call scene_capabilities again with topic set to one name below. Tools list common fields; schemas names the full field list of a recipe part (meshEdit and meshStack also take <name>.<op>, geometries takes geometries.<type>).',++ how: 'Call scene_capabilities with topic set to a name below. Tools list common fields; schemas names the full field list of a recipe part (meshEdit and meshStack also take <name>.<op>, geometries takes geometries.<type>).',topics: names,};}diff --cc scripts/smoke-agent-post-pass.mjsindex cffabaa9,cd9288db..f82b09cf--- a/scripts/smoke-agent-post-pass.mjs+++ b/scripts/smoke-agent-post-pass.mjs@@@ -93,7 -93,7 +93,7 @@@ async function waitForJob(jobId)try {await client.connect(transport);-- assert.equal((await client.listTools()).tools.length, 22);++ assert.equal((await client.listTools()).tools.length, 23);const capabilities = (await call('scene_capabilities', { topic: 'postPasses' })).structuredContent;assert.equal(capabilities.value.limits.maxPasses, 4);assert.ok((await call('scene_capabilities', { topic: 'operations' })).structuredContent.value.includes('set-post-passes'));diff --cc scripts/smoke-mcp.mjsindex 868dab35,99f5f6b4..d8f6e17f--- a/scripts/smoke-mcp.mjs+++ b/scripts/smoke-mcp.mjs@@@ -116,14 -113,14 +116,14 @@@ try{ type: 'add-node', node: { id: 'ornament', geometry: 'ornament', material: 'ruby', translation: [-1.2, 0.8, 0], scale: [0.28, 0.28, 0.28] } },] })).structuredContent;assert.equal(enlarged.renderSucceeded, true);- assert.equal(enlarged.inspection.counts.parts, 20);- assert.equal(enlarged.render.geometryBuffers, 8);+ assert.equal((await call('scene_inspect', { sessionId })).structuredContent.counts.parts, 20);- assert.equal(enlarged.render.geometryBuffers, 8);++ assert.equal(enlarged.render.geometryBuffers, before.metadata.geometryBuffers + 1);const topology = await look(sessionId, 'topology');assert.notDeepEqual(topology.bytes, before.bytes);await call('scene_restore', { sessionId, checkpointId: checkpoint.checkpointId, expectedRevision: 4 });const topologyRestored = await look(sessionId, 'topology-restored');assert.deepEqual(topologyRestored.bytes, before.bytes);-- assert.equal(topologyRestored.metadata.geometryBuffers, 7);++ assert.equal(topologyRestored.metadata.geometryBuffers, before.metadata.geometryBuffers);const removed = (await call('scene_apply', { sessionId, expectedRevision: 5, operations: [{ type: 'remove-node', id: 'lamp', recursive: true },...fixture.geometries.map(geometry => ({ type: 'remove-geometry', id: geometry.id })),diff --cc src/agent-bake.jsindex b809fc3c,b809fc3c..8d9136a8--- a/src/agent-bake.js+++ b/src/agent-bake.js@@@ -31,7 -31,7 +31,7 @@@ export function normalizeAgentBake(inpuif (input[field] === undefined) {continue;}-- resolved[field] = finiteNumber(input[field], `Bake ${field}`, minimum, maximum);++ resolved[field] = finiteNumber(input[field], `bake.${field}`, minimum, maximum);}// Absent means 'room', one probe in the middle of an enclosed room (an open scene gets none). false opts out; a list places them.// Measured against Cycles, a probe lowered the FLIP score of every baked room, so a bake brings one along.diff --cc src/agent-cloth.jsindex cb40cf8e,cb40cf8e..089064a8--- a/src/agent-cloth.js+++ b/src/agent-cloth.js@@@ -4,6 -4,6 +4,7 @@@ import { bakeClothWithFields } from './import { normalizeForceFields } from './force-fields.js';import { bakeCloth, sampleClothFrames, weldVertices, CLOTH_LIMITS } from './cloth.js';import { recomputeNormals } from './geometry-normals.js';++import { invalidField } from './field-error.js';import { bakingContext, boundedArray, finiteNumber, knownKeys, rootNodeWithGeometry, vectorOfThree } from './agent-recipe-checks.js';import { boneNodeId, boneTails, restWorldMatrix } from './rig.js';// Matches the ragdoll's bone capsule radius (src/ragdoll.js), without loading the ragdoll for one number.@@@ -36,103 -36,103 +37,106 @@@ const PIN_GROUP_THRESHOLD = 0.5const GROUP_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,47}$/;const NO_PATCHES = new Map();--function normalizeSheet(input, context) {-- knownKeys(input, SHEET_FIELDS, 'cloth sheet');-- rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, 'Cloth sheet');++function normalizeSheet(input, context, path) {++ knownKeys(input, SHEET_FIELDS, path);++ rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, `${path}.node`);const sheet = { node: input.node };if (input.pin !== undefined) {-- const edges = boundedArray(input.pin, PIN_EDGES.length, 'Cloth pin');-- for (const edge of edges) {++ const edges = boundedArray(input.pin, PIN_EDGES.length, `${path}.pin`);++ edges.forEach((edge, index) => {if (!PIN_EDGES.includes(edge)) {-- throw new RangeError(`Cloth pin must be one of ${PIN_EDGES.join(', ')}.`);++ throw invalidField(`${path}.pin[${index}]`, edge, `one of ${PIN_EDGES.join(', ')}`);}-- }++ });sheet.pin = [...new Set(edges)];}if (input.pinGroup !== undefined) {if (typeof input.pinGroup !== 'string' || !GROUP_NAME_PATTERN.test(input.pinGroup)) {-- throw new RangeError('Cloth pinGroup must be the name of a vertex group on the sheet mesh.');++ throw invalidField(`${path}.pinGroup`, input.pinGroup, 'the name of a vertex group on the sheet mesh, such as "hem"');}sheet.pinGroup = input.pinGroup;}if (input.pinTo !== undefined) {-- knownKeys(input.pinTo, PIN_TO_FIELDS, 'cloth pinTo');++ knownKeys(input.pinTo, PIN_TO_FIELDS, `${path}.pinTo`);if (!sheet.pin?.length && !sheet.pinGroup) {-- throw new RangeError('Cloth pinTo moves the pinned vertices, so the sheet needs pin too (or pinGroup).');++ throw invalidField(`${path}.pinTo`, input.pinTo, 'a sheet that also sets pin (such as ["top"]) or pinGroup, because pinTo moves the pinned vertices');}-- const target = existingNode(input.pinTo.node, context, 'Cloth pinTo');++ const target = existingNode(input.pinTo.node, context, `${path}.pinTo.node`);if (target === input.node) {-- throw new RangeError('Cloth pinTo cannot name the sheet itself.');++ throw invalidField(`${path}.pinTo.node`, target, 'a node other than the sheet itself, such as a pole or a hand');}-- sheet.pinTo = { node: target, weight: input.pinTo.weight === undefined ? 1 : finiteNumber(input.pinTo.weight, 'Cloth pinTo weight', 0.01, 1) };++ sheet.pinTo = { node: target, weight: input.pinTo.weight === undefined ? 1 : finiteNumber(input.pinTo.weight, `${path}.pinTo.weight`, 0.01, 1) };}const ranges = { stiffness: [0.01, 1], bend: [0, 1], density: [0.01, 10], damping: [0, 100], friction: [0, 1], thickness: [0, 0.5] };for (const [field, [minimum, maximum]] of Object.entries(ranges)) {-- if (input[field] !== undefined) sheet[field] = finiteNumber(input[field], `Cloth ${field}`, minimum, maximum);++ if (input[field] !== undefined) sheet[field] = finiteNumber(input[field], `${path}.${field}`, minimum, maximum);}return sheet;}--function existingNode(nodeId, context, label) {++function existingNode(nodeId, context, path) {if (typeof nodeId !== 'string' || !context.recipeNodes.has(nodeId)) {-- throw new RangeError(`${label} node was not found: ${String(nodeId).slice(0, 64)}.`);++ throw invalidField(path, nodeId, 'the ID of a node in the recipe, such as "pole"');}return nodeId;}--function normalizeMovingCollider(input, context) {-- knownKeys(input, MOVING_COLLIDER_FIELDS, 'cloth moving collider');++function normalizeMovingCollider(input, context, path) {++ knownKeys(input, MOVING_COLLIDER_FIELDS, path);const shape = input.shape ?? 'ball';if (!MOVING_SHAPES.includes(shape)) {-- throw new RangeError(`Cloth moving collider shape must be one of ${MOVING_SHAPES.join(', ')}.`);++ throw invalidField(`${path}.shape`, shape, `one of ${MOVING_SHAPES.join(', ')}`);++ }++ if (shape === 'capsule' && input.to === undefined) {++ throw invalidField(`${path}.to`, input.to, 'the ID of the node the capsule other end rides on, such as "hand"');}-- if ((shape === 'capsule') !== (input.to !== undefined)) {-- throw new RangeError('A capsule collider needs to (the node its other end rides on); a ball takes no to.');++ if (shape === 'ball' && input.to !== undefined) {++ throw invalidField(`${path}.to`, input.to, 'nothing for a ball; drop it or set shape to "capsule"');}const collider = {-- attach: existingNode(input.attach, context, 'Cloth collider attach'), shape,-- radius: finiteNumber(input.radius, 'Cloth collider radius', MIN_MOVING_RADIUS, MAX_MOVING_RADIUS),++ attach: existingNode(input.attach, context, `${path}.attach`), shape,++ radius: finiteNumber(input.radius, `${path}.radius`, MIN_MOVING_RADIUS, MAX_MOVING_RADIUS),};-- if (input.offset !== undefined) collider.offset = vectorOfThree(input.offset, 'Cloth collider offset', OFFSET_LIMIT);++ if (input.offset !== undefined) collider.offset = vectorOfThree(input.offset, `${path}.offset`, OFFSET_LIMIT);if (shape === 'capsule') {-- collider.to = existingNode(input.to, context, 'Cloth collider to');-- if (input.toOffset !== undefined) collider.toOffset = vectorOfThree(input.toOffset, 'Cloth collider toOffset', OFFSET_LIMIT);++ collider.to = existingNode(input.to, context, `${path}.to`);++ if (input.toOffset !== undefined) collider.toOffset = vectorOfThree(input.toOffset, `${path}.toOffset`, OFFSET_LIMIT);} else if (input.toOffset !== undefined) {-- throw new RangeError('A ball collider takes no toOffset.');++ throw invalidField(`${path}.toOffset`, input.toOffset, 'nothing for a ball; drop it or set shape to "capsule"');}return collider;}--function normalizeFittedCollider(input, recipe) {-- knownKeys(input, FITTED_COLLIDER_FIELDS, 'cloth fitted collider');++function normalizeFittedCollider(input, recipe, path) {++ knownKeys(input, FITTED_COLLIDER_FIELDS, path);const armature = (recipe.armatures ?? []).find(candidate => candidate.id === input.armature);if (!armature) {-- throw new RangeError(`Cloth collider armature was not found: ${JSON.stringify(String(input.armature).slice(0, 48))}. Add it to the recipe armatures.`);++ throw invalidField(`${path}.armature`, input.armature, 'the ID of an armature in the recipe armatures, such as "rig"');}const collider = { armature: armature.id };-- if (input.radiusFraction !== undefined) collider.radiusFraction = finiteNumber(input.radiusFraction, 'Cloth collider radiusFraction', 0.02, 0.5);++ if (input.radiusFraction !== undefined) collider.radiusFraction = finiteNumber(input.radiusFraction, `${path}.radiusFraction`, 0.02, 0.5);if (input.exclude !== undefined) {const names = new Set(armature.bones.map(bone => bone.name));-- collider.exclude = [...new Set(boundedArray(input.exclude, MAX_MOVING_COLLIDERS, 'Cloth collider exclude'))];++ collider.exclude = [...new Set(boundedArray(input.exclude, MAX_MOVING_COLLIDERS, `${path}.exclude`))];for (const name of collider.exclude) {-- if (!names.has(name)) throw new RangeError(`Cloth collider exclude names a bone that ${armature.id} does not have: ${JSON.stringify(String(name).slice(0, 48))}.`);++ if (!names.has(name)) throw invalidField(`${path}.exclude`, name, `a bone name of ${armature.id}, such as "${armature.bones[0]?.name ?? 'spine'}"`);}}return collider;}--function normalizeCollider(input, context, recipe) {++function normalizeCollider(input, context, recipe, path) {if (input !== null && typeof input === 'object' && Object.hasOwn(input, 'attach')) {-- return normalizeMovingCollider(input, context);++ return normalizeMovingCollider(input, context, path);}if (input !== null && typeof input === 'object' && Object.hasOwn(input, 'armature')) {-- return normalizeFittedCollider(input, recipe);++ return normalizeFittedCollider(input, recipe, path);}-- knownKeys(input, FIXED_COLLIDER_FIELDS, 'cloth collider');-- rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, 'Cloth collider');++ knownKeys(input, FIXED_COLLIDER_FIELDS, path);++ rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, `${path}.node`);const shape = input.shape ?? 'box';if (!COLLIDER_SHAPES.includes(shape)) {-- throw new RangeError(`Cloth collider shape must be one of ${COLLIDER_SHAPES.join(', ')}.`);++ throw invalidField(`${path}.shape`, shape, `one of ${COLLIDER_SHAPES.join(', ')}`);}return { node: input.node, shape };}@@@ -144,21 -144,21 +148,21 @@@ export function normalizeAgentCloth(inp}knownKeys(input, CLOTH_FIELDS, 'cloth');const context = bakingContext(recipe);-- const result = { duration: finiteNumber(input.duration, 'Cloth duration', 0.1, MAX_DURATION_SECONDS) };-- result.sheets = boundedArray(input.sheets, MAX_SHEETS, 'Cloth sheets').map(sheet => normalizeSheet(sheet, context));++ const result = { duration: finiteNumber(input.duration, 'cloth.duration', 0.1, MAX_DURATION_SECONDS) };++ result.sheets = boundedArray(input.sheets, MAX_SHEETS, 'cloth.sheets').map((sheet, index) => normalizeSheet(sheet, context, `cloth.sheets[${index}]`));if (!result.sheets.length) {-- throw new RangeError('Cloth needs at least one sheet. Use null to clear it.');++ throw invalidField('cloth.sheets', result.sheets, 'at least one sheet, such as [{ "node": "banner", "pin": ["top"] }]; use cloth: null to clear it');}-- if (input.gravity !== undefined) result.gravity = vectorOfThree(input.gravity, 'Cloth gravity', 1000);-- if (input.wind !== undefined) result.wind = vectorOfThree(input.wind, 'Cloth wind', 100);++ if (input.gravity !== undefined) result.gravity = vectorOfThree(input.gravity, 'cloth.gravity', 1000);++ if (input.wind !== undefined) result.wind = vectorOfThree(input.wind, 'cloth.wind', 100);if (input.fields !== undefined) result.fields = normalizeForceFields(input.fields, 'Cloth force field');if (input.colliders !== undefined) {-- const entries = boundedArray(input.colliders, MAX_COLLIDERS + MAX_MOVING_COLLIDERS, 'Cloth colliders');-- boundedArray(entries.filter(entry => !Object.hasOwn(entry ?? {}, 'attach') && !Object.hasOwn(entry ?? {}, 'armature')), MAX_COLLIDERS, 'Cloth colliders on fixed nodes');-- result.colliders = entries.map(collider => normalizeCollider(collider, context, recipe));++ const entries = boundedArray(input.colliders, MAX_COLLIDERS + MAX_MOVING_COLLIDERS, 'cloth.colliders');++ boundedArray(entries.filter(entry => !Object.hasOwn(entry ?? {}, 'attach') && !Object.hasOwn(entry ?? {}, 'armature')), MAX_COLLIDERS, 'cloth.colliders');++ result.colliders = entries.map((collider, index) => normalizeCollider(collider, context, recipe, `cloth.colliders[${index}]`));const movingCount = movingColliderSpecs(result, recipe).length;if (movingCount > MAX_MOVING_COLLIDERS) {-- throw new RangeError(`Cloth moving colliders are limited to ${MAX_MOVING_COLLIDERS} balls and capsules, counting one per armature bone; this has ${movingCount}.`);++ throw invalidField('cloth.colliders', `${movingCount} moving colliders`, `at most ${MAX_MOVING_COLLIDERS} balls and capsules, counting one per armature bone; exclude bones or drop colliders`);}}return result;@@@ -207,7 -207,7 +211,7 @@@ function pinGroupWeights(sheet, geometrconst weights = geometry.vertexGroups?.[sheet.pinGroup];if (!weights) {const known = Object.keys(geometry.vertexGroups ?? {});-- throw new RangeError(`Cloth pinGroup ${sheet.pinGroup} is not a vertex group of ${sheet.node}. Known groups: ${known.join(', ') || 'none'}. Make one with a vertex_group mesh edit.`);++ throw invalidField('cloth.sheets[].pinGroup', sheet.pinGroup, `a vertex group of node ${sheet.node} (known groups: ${known.join(', ') || 'none'}); make one with a vertex_group mesh edit`);}return weights;}diff --cc src/agent-particles.jsindex 0c709faa,0c709faa..82f4c336--- a/src/agent-particles.js+++ b/src/agent-particles.js@@@ -3,6 -3,6 +3,7 @@@ import { HAIR_LIMITS, buildHairMesh, crimport { normalizeForceFields } from './force-fields.js';import { PARTICLE_LIMITS, buildParticleMesh, createParticleLaunches } from './particles.js';import { createCollisionSurface } from './particle-collision.js';++import { invalidField } from './field-error.js';import { bakingContext, boundedArray, finiteNumber, knownKeys, rootNodeWithGeometry, vectorOfThree } from './agent-recipe-checks.js';const PARTICLES_FIELDS = ['gravity', 'wind', 'fields', 'systems'];@@@ -20,145 -20,145 +21,145 @@@ const POSITION_LIMIT = 10000const MAX_SEED = 0xffffffff;// A number stands for the range [value, value].--function rangeOf(value, label, minimum, maximum) {++function rangeOf(value, path, minimum, maximum) {if (typeof value === 'number') {-- return [finiteNumber(value, label, minimum, maximum), value];++ return [finiteNumber(value, path, minimum, maximum), value];}if (!Array.isArray(value) || value.length !== 2) {-- throw new TypeError(`${label} must be a number or [minimum, maximum].`);++ throw invalidField(path, value, `a number or [minimum, maximum] from ${minimum} to ${maximum}, such as [${Math.max(minimum, 0.5)}, ${Math.min(maximum, 1)}]`, TypeError);}-- const range = value.map(entry => finiteNumber(entry, label, minimum, maximum));++ const range = value.map((entry, index) => finiteNumber(entry, `${path}[${index}]`, minimum, maximum));if (range[0] > range[1]) {-- throw new RangeError(`${label} minimum must not exceed its maximum.`);++ throw invalidField(path, value, `[minimum, maximum] with the minimum not above the maximum, such as [${range[1]}, ${range[0]}]`);}return range;}--function normalizeEmitter(input) {-- knownKeys(input, EMITTER_FIELDS, 'particle emitter');++function normalizeEmitter(input, path) {++ knownKeys(input, EMITTER_FIELDS, path);const shape = input.shape ?? 'point';if (!EMITTER_SHAPES.includes(shape)) {-- throw new RangeError(`Particle emitter shape must be one of ${EMITTER_SHAPES.join(', ')}.`);++ throw invalidField(`${path}.shape`, shape, `one of ${EMITTER_SHAPES.join(', ')}`);}return {shape,-- position: input.position === undefined ? [0, 0, 0] : vectorOfThree(input.position, 'Particle emitter position', POSITION_LIMIT),-- halfExtents: input.halfExtents === undefined ? [0.5, 0.5, 0.5] : vectorOfThree(input.halfExtents, 'Particle emitter halfExtents', POSITION_LIMIT).map(Math.abs),-- radius: input.radius === undefined ? 0.5 : finiteNumber(input.radius, 'Particle emitter radius', 0, POSITION_LIMIT),++ position: input.position === undefined ? [0, 0, 0] : vectorOfThree(input.position, `${path}.position`, POSITION_LIMIT),++ halfExtents: input.halfExtents === undefined ? [0.5, 0.5, 0.5] : vectorOfThree(input.halfExtents, `${path}.halfExtents`, POSITION_LIMIT).map(Math.abs),++ radius: input.radius === undefined ? 0.5 : finiteNumber(input.radius, `${path}.radius`, 0, POSITION_LIMIT),};}--function normalizeCount(input) {++function normalizeCount(input, path) {const count = input.count ?? 100;if (!Number.isInteger(count) || count < 1 || count > PARTICLE_LIMITS.maxParticlesPerSystem) {-- throw new RangeError(`Particle count must be an integer from 1 to ${PARTICLE_LIMITS.maxParticlesPerSystem}.`);++ throw invalidField(`${path}.count`, count, `a whole number from 1 to ${PARTICLE_LIMITS.maxParticlesPerSystem}, such as 100`);}return count;}--function normalizeSeed(input) {++function normalizeSeed(input, path) {const seed = input.seed ?? 1;if (!Number.isInteger(seed) || seed < 0 || seed > MAX_SEED) {-- throw new RangeError(`Particle seed must be an integer from 0 to ${MAX_SEED}.`);++ throw invalidField(`${path}.seed`, seed, `a whole number from 0 to ${MAX_SEED}, such as 1`);}return seed;}--function normalizeColors(value) {++function normalizeColors(value, path) {if (!Array.isArray(value) || value.length !== 2) {-- throw new TypeError('Particle color must be [start, end], each [r, g, b] from 0 to 1.');++ throw invalidField(path, value, '[start, end], each [r, g, b] from 0 to 1, such as [[1, 0.6, 0.1], [0.3, 0, 0]]', TypeError);}-- return value.map(color => vectorOfThree(color, 'Particle color', 1000).map(channel => finiteNumber(channel, 'Particle color', 0, 1000)));++ return value.map((color, index) => vectorOfThree(color, `${path}[${index}]`, 1000).map((channel, channelIndex) => finiteNumber(channel, `${path}[${index}][${channelIndex}]`, 0, 1000)));}// [start, end] over the life, in either direction; a number holds one value.--function normalizeAlpha(value) {++function normalizeAlpha(value, path) {if (typeof value === 'number') {-- return [finiteNumber(value, 'Particle alpha', 0, 1), value];++ return [finiteNumber(value, path, 0, 1), value];}if (!Array.isArray(value) || value.length !== 2) {-- throw new TypeError('Particle alpha must be a number or [start, end] from 0 to 1.');++ throw invalidField(path, value, 'a number or [start, end] from 0 to 1, such as [1, 0]', TypeError);}-- return value.map(entry => finiteNumber(entry, 'Particle alpha', 0, 1));++ return value.map((entry, index) => finiteNumber(entry, `${path}[${index}]`, 0, 1));}--function normalizeColliders(value, context) {-- const nodeIds = boundedArray(value, PARTICLE_LIMITS.maxColliders, 'Particle colliders');++function normalizeColliders(value, context, path) {++ const nodeIds = boundedArray(value, PARTICLE_LIMITS.maxColliders, path);// Colliders are only read, so several systems may share one.-- for (const nodeId of nodeIds) {-- rootNodeWithGeometry(nodeId, context.recipeNodes, new Set(), context.motionNodeIds, context.physicsNodeIds, 'Particle collider', 'particles');-- }++ nodeIds.forEach((nodeId, index) => {++ rootNodeWithGeometry(nodeId, context.recipeNodes, new Set(), context.motionNodeIds, context.physicsNodeIds, `${path}[${index}]`, 'particles');++ });return nodeIds;}--function normalizeEmitterSystem(input, context) {-- knownKeys(input, EMITTER_SYSTEM_FIELDS, 'particle system');-- rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, 'Particle system', 'particles');++function normalizeEmitterSystem(input, context, path) {++ knownKeys(input, EMITTER_SYSTEM_FIELDS, path);++ rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, `${path}.node`, 'particles');const system = {-- type: 'emitter', node: input.node, seed: normalizeSeed(input), count: normalizeCount(input),-- lifetime: rangeOf(input.lifetime ?? 1, 'Particle lifetime', 0.01, PARTICLE_LIMITS.maxLifetime),-- speed: rangeOf(input.speed ?? 1, 'Particle speed', 0, 1000),-- size: rangeOf(input.size ?? 0.05, 'Particle size', 0.0001, 100),-- direction: input.direction === undefined ? [0, 1, 0] : vectorOfThree(input.direction, 'Particle direction', 1000),-- spread: input.spread === undefined ? 30 : finiteNumber(input.spread, 'Particle spread', 0, 180),-- emitter: normalizeEmitter(input.emitter ?? {}),++ type: 'emitter', node: input.node, seed: normalizeSeed(input, path), count: normalizeCount(input, path),++ lifetime: rangeOf(input.lifetime ?? 1, `${path}.lifetime`, 0.01, PARTICLE_LIMITS.maxLifetime),++ speed: rangeOf(input.speed ?? 1, `${path}.speed`, 0, 1000),++ size: rangeOf(input.size ?? 0.05, `${path}.size`, 0.0001, 100),++ direction: input.direction === undefined ? [0, 1, 0] : vectorOfThree(input.direction, `${path}.direction`, 1000),++ spread: input.spread === undefined ? 30 : finiteNumber(input.spread, `${path}.spread`, 0, 180),++ emitter: normalizeEmitter(input.emitter ?? {}, `${path}.emitter`),scale: input.scale ?? 'constant',-- drag: input.drag === undefined ? 0 : finiteNumber(input.drag, 'Particle drag', 0, 100),++ drag: input.drag === undefined ? 0 : finiteNumber(input.drag, `${path}.drag`, 0, 100),};if (Math.hypot(...system.direction) === 0) {-- throw new RangeError('Particle direction must not be the zero vector.');++ throw invalidField(`${path}.direction`, system.direction, 'a direction that is not the zero vector, such as [0, 1, 0]');}if (!SCALE_MODES.includes(system.scale)) {-- throw new RangeError(`Particle scale must be one of ${SCALE_MODES.join(', ')}.`);++ throw invalidField(`${path}.scale`, system.scale, `one of ${SCALE_MODES.join(', ')}`);}-- if (input.rate !== undefined) system.rate = finiteNumber(input.rate, 'Particle rate', 0.01, PARTICLE_LIMITS.maxParticlesPerSystem * 100);-- if (input.bounce !== undefined) system.bounce = finiteNumber(input.bounce, 'Particle bounce', 0, 1);-- if (input.friction !== undefined) system.friction = finiteNumber(input.friction, 'Particle friction', 0, 1);-- if (input.spin !== undefined) system.spin = rangeOf(input.spin, 'Particle spin', -100000, 100000);-- if (input.color !== undefined) system.color = normalizeColors(input.color);-- if (input.alpha !== undefined) system.alpha = normalizeAlpha(input.alpha);++ if (input.rate !== undefined) system.rate = finiteNumber(input.rate, `${path}.rate`, 0.01, PARTICLE_LIMITS.maxParticlesPerSystem * 100);++ if (input.bounce !== undefined) system.bounce = finiteNumber(input.bounce, `${path}.bounce`, 0, 1);++ if (input.friction !== undefined) system.friction = finiteNumber(input.friction, `${path}.friction`, 0, 1);++ if (input.spin !== undefined) system.spin = rangeOf(input.spin, `${path}.spin`, -100000, 100000);++ if (input.color !== undefined) system.color = normalizeColors(input.color, `${path}.color`);++ if (input.alpha !== undefined) system.alpha = normalizeAlpha(input.alpha, `${path}.alpha`);if (input.colliders !== undefined) {-- system.colliders = normalizeColliders(input.colliders, context);++ system.colliders = normalizeColliders(input.colliders, context, `${path}.colliders`);if (system.colliders.includes(system.node)) {-- throw new RangeError('A particle system node cannot be its own collider.');++ throw invalidField(`${path}.colliders`, system.colliders, `node IDs other than the system's own node "${system.node}"`);}}-- if (input.floor !== undefined) system.floor = finiteNumber(input.floor, 'Particle floor', -POSITION_LIMIT, POSITION_LIMIT);++ if (input.floor !== undefined) system.floor = finiteNumber(input.floor, `${path}.floor`, -POSITION_LIMIT, POSITION_LIMIT);return system;}--function normalizeHairSystem(input, context) {-- knownKeys(input, HAIR_FIELDS, 'hair system');-- rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, 'Hair system', 'particles');++function normalizeHairSystem(input, context, path) {++ knownKeys(input, HAIR_FIELDS, path);++ rootNodeWithGeometry(input.node, context.recipeNodes, context.claimedNodes, context.motionNodeIds, context.physicsNodeIds, `${path}.node`, 'particles');// The surface is only read, so several systems may grow from one node.-- rootNodeWithGeometry(input.surface, context.recipeNodes, new Set(), context.motionNodeIds, context.physicsNodeIds, 'Hair surface', 'particles');++ rootNodeWithGeometry(input.surface, context.recipeNodes, new Set(), context.motionNodeIds, context.physicsNodeIds, `${path}.surface`, 'particles');if (input.surface === input.node) {-- throw new RangeError('Hair surface and hair node must be different nodes.');++ throw invalidField(`${path}.surface`, input.surface, 'a node other than the hair node, such as the head mesh');}const segments = input.segments ?? 4;if (!Number.isInteger(segments) || segments < 1 || segments > HAIR_LIMITS.maxSegments) {-- throw new RangeError(`Hair segments must be an integer from 1 to ${HAIR_LIMITS.maxSegments}.`);++ throw invalidField(`${path}.segments`, segments, `a whole number from 1 to ${HAIR_LIMITS.maxSegments}, such as 4`);}const system = {-- type: 'hair', node: input.node, surface: input.surface, seed: normalizeSeed(input), count: normalizeCount(input), segments,-- length: rangeOf(input.length ?? 0.1, 'Hair length', 0.001, 100),-- width: finiteNumber(input.width ?? 0.004, 'Hair width', 0.0001, 10),-- droop: finiteNumber(input.droop ?? 0.5, 'Hair droop', 0, 10),-- lean: finiteNumber(input.lean ?? 0.2, 'Hair lean', 0, 2),++ type: 'hair', node: input.node, surface: input.surface, seed: normalizeSeed(input, path), count: normalizeCount(input, path), segments,++ length: rangeOf(input.length ?? 0.1, `${path}.length`, 0.001, 100),++ width: finiteNumber(input.width ?? 0.004, `${path}.width`, 0.0001, 10),++ droop: finiteNumber(input.droop ?? 0.5, `${path}.droop`, 0, 10),++ lean: finiteNumber(input.lean ?? 0.2, `${path}.lean`, 0, 2),};if (input.sway !== undefined) {-- system.sway = finiteNumber(input.sway, 'Hair sway', 0, 10);-- system.swayRate = finiteNumber(input.swayRate ?? 0.5, 'Hair swayRate', 0.01, 20);++ system.sway = finiteNumber(input.sway, `${path}.sway`, 0, 10);++ system.swayRate = finiteNumber(input.swayRate ?? 0.5, `${path}.swayRate`, 0.01, 20);}return system;}--function normalizeSystem(input, context) {++function normalizeSystem(input, context, path) {const type = input?.type ?? 'emitter';if (!SYSTEM_TYPES.includes(type)) {-- throw new RangeError(`Particle system type must be one of ${SYSTEM_TYPES.join(', ')}.`);++ throw invalidField(`${path}.type`, type, `one of ${SYSTEM_TYPES.join(', ')}`);}-- return type === 'hair' ? normalizeHairSystem(input, context) : normalizeEmitterSystem(input, context);++ return type === 'hair' ? normalizeHairSystem(input, context, path) : normalizeEmitterSystem(input, context, path);}/** Validate a recipe particles section against its nodes. Returns the plain, bounded form stored in the recipe. */@@@ -169,23 -169,23 +170,23 @@@ export function normalizeAgentParticlesknownKeys(input, PARTICLES_FIELDS, 'particles');const context = bakingContext(recipe, ['cloth']);const result = {};-- result.systems = boundedArray(input.systems, PARTICLE_LIMITS.maxSystems, 'Particle systems').map(system => normalizeSystem(system, context));++ result.systems = boundedArray(input.systems, PARTICLE_LIMITS.maxSystems, 'particles.systems').map((system, index) => normalizeSystem(system, context, `particles.systems[${index}]`));if (!result.systems.length) {-- throw new RangeError('Particles need at least one system. Use null to clear it.');++ throw invalidField('particles.systems', result.systems, 'at least one system, such as [{ "node": "sparks" }]; use particles: null to clear it');}const systemNodes = new Set(result.systems.map(system => system.node));for (const system of result.systems) {const clash = system.colliders?.find(nodeId => systemNodes.has(nodeId));if (clash) {-- throw new RangeError(`Particle collider ${clash} is a particle system node; its own geometry is replaced by particles.`);++ throw invalidField('particles.systems', clash, 'colliders that are not particle system nodes, because a system replaces its own geometry with particles');}}const total = result.systems.reduce((sum, system) => sum + system.count, 0);if (total > PARTICLE_LIMITS.maxParticles) {-- throw new RangeError(`Particle systems hold ${total} particles; the limit is ${PARTICLE_LIMITS.maxParticles} in total.`);++ throw invalidField('particles.systems', `${total} particles in total`, `counts that add up to at most ${PARTICLE_LIMITS.maxParticles}, such as a lower count in each system`);}-- if (input.gravity !== undefined) result.gravity = vectorOfThree(input.gravity, 'Particle gravity', 1000);-- if (input.wind !== undefined) result.wind = vectorOfThree(input.wind, 'Particle wind', 100);++ if (input.gravity !== undefined) result.gravity = vectorOfThree(input.gravity, 'particles.gravity', 1000);++ if (input.wind !== undefined) result.wind = vectorOfThree(input.wind, 'particles.wind', 100);if (input.fields !== undefined) result.fields = normalizeForceFields(input.fields, 'Particle force field');return result;}@@@ -244,7 -244,7 +245,7 @@@ function surfaceInWorld(geometry, matrifunction checkVertexBudget(vertices, totalVertices, nodeId) {if (vertices > PARTICLE_LIMITS.maxVertices || totalVertices > PARTICLE_LIMITS.maxVertices) {-- throw new RangeError(`Particle node ${nodeId} would draw ${totalVertices} vertices (shape vertices times count); the limit is ${PARTICLE_LIMITS.maxVertices}. Use a shape with fewer segments or a lower count.`);++ throw invalidField('particles.systems', `${totalVertices} vertices on node ${nodeId}`, `shape vertices times count of at most ${PARTICLE_LIMITS.maxVertices}; use a shape with fewer segments or a lower count`);}}@@@ -262,7 -262,7 +263,7 @@@ function collisionSurfaceOf(system, nod});const surface = createCollisionSurface(meshes);if (surface.triangleCount > PARTICLE_LIMITS.maxColliderTriangles) {-- throw new RangeError(`Particle colliders of ${system.node} hold ${surface.triangleCount} triangles; the limit is ${PARTICLE_LIMITS.maxColliderTriangles}.`);++ throw invalidField('particles.systems', `${surface.triangleCount} collider triangles for node ${system.node}`, `colliders with at most ${PARTICLE_LIMITS.maxColliderTriangles} triangles in total, such as a simpler collider mesh`);}return surface;}diff --cc src/agent-recipe-checks.jsindex 59a17758,b643af1d..ec369215--- a/src/agent-recipe-checks.js+++ b/src/agent-recipe-checks.js@@@ -1,53 -1,54 +1,56 @@@-// Checks shared by the recipe sections that bake geometry (cloth, particles, hair).+ import { invalidField } from './field-error.js';+-export function knownKeys(value, fields, label) {+// Checks shared by the recipe sections that bake geometry (cloth, particles, hair).+- export function knownKeys(value, fields, label) {++export function knownKeys(value, fields, path) {if (!value || Object.getPrototypeOf(value) !== Object.prototype) {- throw new TypeError(`${label} must be a plain object.`);- throw invalidField(label, value, 'an object, such as {}', TypeError);++ throw invalidField(path, value, 'a plain object, such as {}', TypeError);}for (const key of Object.keys(value)) {if (!fields.includes(key)) {- throw new TypeError(`Unknown or unsupported ${label} field: ${key}. Allowed fields: ${fields.join(', ')}.`);- throw invalidField(`${label}.${key}`, value[key], `one of the fields ${fields.join(', ')}; remove ${key}`, TypeError);++ throw invalidField(`${path}.${key}`, value[key], `no such field; use one of ${fields.join(', ')}`, TypeError);}}}--export function finiteNumber(value, label, minimum, maximum) {++export function finiteNumber(value, path, minimum, maximum) {if (typeof value !== 'number' || !Number.isFinite(value) || !Number.isFinite(Math.fround(value)) || value < minimum || value > maximum) {- throw new RangeError(`${label} must be a finite number within ${minimum} and ${maximum}.`);- throw invalidField(label, value, `a finite number from ${minimum} to ${maximum}, such as ${Math.min(Math.max(1, minimum), maximum)}`);++ throw invalidField(path, value, `a number from ${minimum} to ${maximum}, such as ${Math.min(Math.max(1, minimum), maximum)}`);}return value;}--export function vectorOfThree(value, label, limit) {++export function vectorOfThree(value, path, limit) {if (!Array.isArray(value) || value.length !== 3) {- throw new TypeError(`${label} needs 3 numbers.`);- throw invalidField(label, value, 'three numbers, such as [0, 1, 0]', TypeError);++ throw invalidField(path, value, 'an array of 3 numbers, such as [0, 1, 0]', TypeError);}-- return value.map(component => finiteNumber(component, label, -limit, limit));++ return value.map((component, index) => finiteNumber(component, `${path}[${index}]`, -limit, limit));}--export function boundedArray(value, maximum, label) {++export function boundedArray(value, maximum, path) {if (!Array.isArray(value) || value.length > maximum) {- throw new TypeError(`${label} must be an array of at most ${maximum} entries.`);- throw invalidField(label, value, `an array of at most ${maximum} entries, such as []`, TypeError);++ throw invalidField(path, Array.isArray(value) ? `${value.length} entries` : value, `an array of at most ${maximum} entries, such as []`, TypeError);}return value;}--export function rootNodeWithGeometry(nodeId, recipeNodes, claimedNodes, motionNodeIds, physicsNodeIds, label, system = 'cloth') {++// `path` names the field that holds the node ID, such as cloth.sheets[0].node.++export function rootNodeWithGeometry(nodeId, recipeNodes, claimedNodes, motionNodeIds, physicsNodeIds, path, system = 'cloth') {const node = typeof nodeId === 'string' ? recipeNodes.get(nodeId) : undefined;if (!node) {- throw new RangeError(`${label} node was not found: ${String(nodeId).slice(0, 64)}.`);- throw invalidField(`${label} node`, nodeId, 'the ID of a node in nodes, such as one scene_inspect lists');++ throw invalidField(path, nodeId, 'the ID of a node in the recipe, such as "banner"');}if (node.geometry === undefined) {- throw new RangeError(`${label} node ${nodeId} has no geometry.`);- throw invalidField(`${label} node`, nodeId, 'a node with a geometry; give it geometry and material');++ throw invalidField(path, nodeId, 'a node that draws a geometry; this one is a group');}if (node.parent !== null) {- throw new RangeError(`${label} node ${nodeId} must be a root node; reparent it first.`);- throw invalidField(`${label} node`, nodeId, 'a root node without a parent; reparent it first');++ throw invalidField(path, nodeId, 'a root node with no parent; reparent it first');}if (claimedNodes.has(nodeId)) {- throw new RangeError(`Node ${nodeId} is used twice in ${system}.`);- throw invalidField(`${label} node`, nodeId, `a node used once in ${system}; pick another node`);++ throw invalidField(path, nodeId, `a node that ${system} uses once; this one is used twice`);}if (motionNodeIds.has(nodeId) || physicsNodeIds.has(nodeId)) {- throw new RangeError(`Node ${nodeId} has a motion translation or rotation track or a physics body. ${label} needs a node that stays where it is.`);- throw invalidField(`${label} node`, nodeId, 'a node that stays where it is, with no motion translation or rotation track and no physics body');++ throw invalidField(path, nodeId, 'a node that stays where it is, with no translation or rotation track and no physics body');}claimedNodes.add(nodeId);}diff --cc src/agent-texture-sequence.jsindex 28f036f5,28f036f5..0154cf46--- a/src/agent-texture-sequence.js+++ b/src/agent-texture-sequence.js@@@ -1,5 -1,5 +1,6 @@@import { createImage } from './material-texture-kit.js';import { TEXTURE_SEQUENCE_LIMITS } from './texture-sequence-limits.js';++import { invalidField } from './field-error.js';// An image sequence as the colour map of a recipe material: `map: { sequence: { frames, fps, loop } }`. The frames are// catalog image assets that the host decodes before createAgentScene. The scene picks a frame from its motion time, so a@@@ -9,32 -9,32 +10,34 @@@ const ASSET_ID = /^[a-f0-9]{64}$/const MAP_FIELDS = ['sequence'];const SEQUENCE_FIELDS = ['frames', 'fps', 'loop'];--function knownKeys(value, allowed, label) {-- if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError(`${label} must be an object.`);++function knownKeys(value, allowed, path) {++ if (!value || typeof value !== 'object' || Array.isArray(value)) {++ throw invalidField(path, value, 'an object, such as {}', TypeError);++ }for (const key of Object.keys(value)) {-- if (!allowed.includes(key)) throw new TypeError(`Unknown ${label} field: ${key}. Allowed fields: ${allowed.join(', ')}.`);++ if (!allowed.includes(key)) throw invalidField(`${path}.${key}`, value[key], `no such field; use one of ${allowed.join(', ')}`, TypeError);}}/** Validate a material `map` field. Returns the canonical form kept in the recipe. */export function normalizeMapSequence(value) {-- knownKeys(value, MAP_FIELDS, 'material map');-- if (value.sequence === undefined) throw new TypeError('material map needs a sequence: { frames, fps }.');++ knownKeys(value, MAP_FIELDS, 'map');++ if (value.sequence === undefined) throw invalidField('map.sequence', value.sequence, 'a sequence, such as { "frames": [<asset id>, <asset id>], "fps": 12 }', TypeError);const sequence = value.sequence;-- knownKeys(sequence, SEQUENCE_FIELDS, 'map sequence');++ knownKeys(sequence, SEQUENCE_FIELDS, 'map.sequence');const { frames, fps, loop = true } = sequence;if (!Array.isArray(frames) || frames.length < 2 || frames.length > TEXTURE_SEQUENCE_LIMITS.maxFrames) {-- throw new RangeError(`map sequence frames must list 2 to ${TEXTURE_SEQUENCE_LIMITS.maxFrames} catalog image asset IDs.`);++ throw invalidField('map.sequence.frames', Array.isArray(frames) ? `${frames.length} frames` : frames, `a list of 2 to ${TEXTURE_SEQUENCE_LIMITS.maxFrames} catalog image asset IDs, such as [<asset id>, <asset id>]`);}-- for (const frame of frames) {++ frames.forEach((frame, index) => {if (typeof frame !== 'string' || !ASSET_ID.test(frame.toLowerCase())) {-- throw new TypeError('Each map sequence frame must be the 64 hexadecimal characters of a catalog image asset id; scene_asset_catalog lists them.');++ throw invalidField(`map.sequence.frames[${index}]`, frame, 'the 64 hexadecimal characters of a catalog image asset ID; scene_asset_catalog lists them', TypeError);}-- }++ });if (!Number.isFinite(fps) || fps <= 0 || fps > TEXTURE_SEQUENCE_LIMITS.maxFps) {-- throw new RangeError(`map sequence fps must be above 0 and at most ${TEXTURE_SEQUENCE_LIMITS.maxFps}.`);++ throw invalidField('map.sequence.fps', fps, `a number above 0 and at most ${TEXTURE_SEQUENCE_LIMITS.maxFps}, such as 12`);}-- if (typeof loop !== 'boolean') throw new TypeError('map sequence loop must be boolean.');++ if (typeof loop !== 'boolean') throw invalidField('map.sequence.loop', loop, 'true or false', TypeError);return { sequence: { frames: frames.map(frame => frame.toLowerCase()), fps, loop } };}@@@ -69,8 -69,8 +72,8 @@@ export function sequenceFrameIds(value/** The material `map` field of a recipe material: validates it against the rest of the material and stores it on `result`. */export function applyMapSequence(value, result) {-- if (result.tag !== 'surface') throw new RangeError('Material map needs the surface tag.');-- if (value.pattern !== undefined) throw new TypeError('A material takes a pattern or a map sequence, not both.');++ if (result.tag !== 'surface') throw invalidField('map', value.map, 'a material with the surface tag; remove map or use the surface tag');++ if (value.pattern !== undefined) throw invalidField('pattern', value.pattern, 'nothing, because a material takes a pattern or a map sequence, not both', TypeError);result.map = normalizeMapSequence(value.map);// Like a pattern, the frames bring their own colours, so color tints them and defaults to white.if (value.color === undefined) result.color = [1, 1, 1];@@@ -89,7 -89,7 +92,7 @@@ export function createTextureSequence(m});const { width, height } = images[0];if (images.some(frame => frame.width !== width || frame.height !== height)) {-- throw new RangeError(`Material ${materialId}: every sequence frame must have the same size, ${width}x${height} here. Resize the images in the catalog.`);++ throw invalidField('map.sequence.frames', `frames of different sizes in material ${materialId}`, `frames that all measure ${width}x${height}; resize the images in the catalog`);}const wrapped = images.map(frame => createImage(frame.data, frame.width, frame.height));const descriptor = { image: wrapped[0], colorSpace: 'srgb' };diff --cc src/agent-vegetation.jsindex 0c5418d7,0c5418d7..98791861--- a/src/agent-vegetation.js+++ b/src/agent-vegetation.js@@@ -2,6 -2,6 +2,7 @@@ import { mat4 } from 'gl-matrix'import { leafTextureDescriptor } from './vegetation-textures.js';import { SPECIES, createTree, scatterVegetation, levelForDistance } from './vegetation.js';import { createRecipeTerrain } from './agent-terrain.js';++import { invalidField } from './field-error.js';// Recipe vegetation: a group node with a `vegetation` field grows one tree, or scatters trees over a terrain node. The// result reuses the placed-asset channel of agent-scene.js: generated geometries (type "asset"), materials (assetSource)@@@ -21,81 -21,81 +22,83 @@@ const GRASS_CARD_COLOR = [80, 128, 40]const BARE_SEASON = 0.9;const DECIDUOUS_SPECIES = new Set(['broadleaf', 'birch', 'bush']);--function knownKeys(value, allowed, label) {-- if (!value || typeof value !== 'object' || Array.isArray(value)) throw new TypeError(`${label} must be an object.`);++function knownKeys(value, allowed, path) {++ if (!value || typeof value !== 'object' || Array.isArray(value)) {++ throw invalidField(path, value, 'an object, such as {}', TypeError);++ }for (const key of Object.keys(value)) {-- if (!allowed.includes(key)) throw new TypeError(`Unknown ${label} field: ${key}. Allowed fields: ${allowed.join(', ')}.`);++ if (!allowed.includes(key)) throw invalidField(`${path}.${key}`, value[key], `no such field; use one of ${allowed.join(', ')}`, TypeError);}}--function numberWithin(value, minimum, maximum, label) {++function numberWithin(value, minimum, maximum, path) {if (!Number.isFinite(value) || value < minimum || value > maximum) {-- throw new RangeError(`${label} must be a number from ${minimum} to ${maximum}.`);++ throw invalidField(path, value, `a number from ${minimum} to ${maximum}, such as ${Math.min(Math.max(1, minimum), maximum)}`);}return value;}--function planePoint(value, label) {++function planePoint(value, path) {if (!Array.isArray(value) || value.length !== 2 || value.some(component => !Number.isFinite(component))) {-- throw new TypeError(`${label} must be [x, z] in metres.`);++ throw invalidField(path, value, '[x, z] in metres, such as [0, 0]', TypeError);}return [...value];}--function normalizeExclusion(value) {-- knownKeys(value, EXCLUSION_FIELDS, 'vegetation exclusion');++function normalizeExclusion(value, path) {++ knownKeys(value, EXCLUSION_FIELDS, path);if (value.min !== undefined || value.max !== undefined) {-- const min = planePoint(value.min, 'exclusion min');-- const max = planePoint(value.max, 'exclusion max');-- if (max[0] <= min[0] || max[1] <= min[1]) throw new RangeError('exclusion max must be above min on both axes.');++ const min = planePoint(value.min, `${path}.min`);++ const max = planePoint(value.max, `${path}.max`);++ if (max[0] <= min[0] || max[1] <= min[1]) throw invalidField(`${path}.max`, max, `[x, z] above min ${JSON.stringify(min)} on both axes`);return { min, max };}-- const radius = numberWithin(value.radius, 0.01, 2000, 'exclusion radius');++ const radius = numberWithin(value.radius, 0.01, 2000, `${path}.radius`);if (value.node !== undefined) {-- if (typeof value.node !== 'string' || !value.node) throw new TypeError('exclusion node must be a node ID.');++ if (typeof value.node !== 'string' || !value.node) throw invalidField(`${path}.node`, value.node, 'a node ID, such as "pond"', TypeError);return { node: value.node, radius };}-- return { center: planePoint(value.center, 'exclusion center'), radius };++ return { center: planePoint(value.center, `${path}.center`), radius };}--function normalizeScatter(value) {-- knownKeys(value, SCATTER_FIELDS, 'vegetation scatter');-- if (typeof value.ground !== 'string' || !value.ground) throw new TypeError('vegetation scatter needs ground: the ID of a terrain node.');++function normalizeScatter(value, path) {++ knownKeys(value, SCATTER_FIELDS, path);++ if (typeof value.ground !== 'string' || !value.ground) throw invalidField(`${path}.ground`, value.ground, 'the ID of a terrain node, such as "ground"', TypeError);const result = {ground: value.ground,-- density: numberWithin(value.density ?? 0.012, 0.0001, 4, 'scatter density'),-- slopeLimit: numberWithin(value.slopeLimit ?? 32, 0, 90, 'scatter slopeLimit'),-- variants: numberWithin(value.variants ?? 3, 1, VEGETATION_LIMITS.maxVariants, 'scatter variants'),++ density: numberWithin(value.density ?? 0.012, 0.0001, 4, `${path}.density`),++ slopeLimit: numberWithin(value.slopeLimit ?? 32, 0, 90, `${path}.slopeLimit`),++ variants: numberWithin(value.variants ?? 3, 1, VEGETATION_LIMITS.maxVariants, `${path}.variants`),exclude: [],};-- if (!Number.isInteger(result.variants)) throw new RangeError('scatter variants must be a whole number.');++ if (!Number.isInteger(result.variants)) throw invalidField(`${path}.variants`, result.variants, `a whole number from 1 to ${VEGETATION_LIMITS.maxVariants}, such as 3`);if (value.exclude !== undefined) {if (!Array.isArray(value.exclude) || value.exclude.length > VEGETATION_LIMITS.maxExclusions) {-- throw new RangeError(`scatter exclude lists at most ${VEGETATION_LIMITS.maxExclusions} areas.`);++ throw invalidField(`${path}.exclude`, Array.isArray(value.exclude) ? `${value.exclude.length} areas` : value.exclude, `a list of at most ${VEGETATION_LIMITS.maxExclusions} areas, such as [{ "center": [0, 0], "radius": 5 }]`);}-- result.exclude = value.exclude.map(normalizeExclusion);++ result.exclude = value.exclude.map((entry, index) => normalizeExclusion(entry, `${path}.exclude[${index}]`));}if (value.area !== undefined) {-- knownKeys(value.area, ['min', 'max'], 'scatter area');-- result.area = { min: planePoint(value.area.min, 'area min'), max: planePoint(value.area.max, 'area max') };++ knownKeys(value.area, ['min', 'max'], `${path}.area`);++ result.area = { min: planePoint(value.area.min, `${path}.area.min`), max: planePoint(value.area.max, `${path}.area.max`) };if (result.area.max[0] <= result.area.min[0] || result.area.max[1] <= result.area.min[1]) {-- throw new RangeError('scatter area max must be above min on both axes.');++ throw invalidField(`${path}.area.max`, result.area.max, `[x, z] above min ${JSON.stringify(result.area.min)} on both axes`);}}if (value.scale !== undefined) {-- if (!Array.isArray(value.scale) || value.scale.length !== 2) throw new TypeError('scatter scale must be [min, max].');-- result.scale = [numberWithin(value.scale[0], 0.1, 10, 'scatter scale min'), numberWithin(value.scale[1], 0.1, 10, 'scatter scale max')];-- if (result.scale[1] < result.scale[0]) throw new RangeError('scatter scale max must not be below min.');++ if (!Array.isArray(value.scale) || value.scale.length !== 2) throw invalidField(`${path}.scale`, value.scale, '[min, max], such as [0.8, 1.2]', TypeError);++ result.scale = [numberWithin(value.scale[0], 0.1, 10, `${path}.scale[0]`), numberWithin(value.scale[1], 0.1, 10, `${path}.scale[1]`)];++ if (result.scale[1] < result.scale[0]) throw invalidField(`${path}.scale`, value.scale, '[min, max] with max not below min, such as [0.8, 1.2]');}return result;}/** Validate environment.wind: strength 0 to 4 (0.3) and direction in degrees (0 toward +x, 90 toward +z). */export function normalizeWind(value) {-- knownKeys(value, ['strength', 'direction'], 'wind');++ knownKeys(value, ['strength', 'direction'], 'environment.wind');return {-- strength: numberWithin(value.strength ?? 0.3, 0, 4, 'wind.strength'),-- direction: numberWithin(value.direction ?? 0, -360, 360, 'wind.direction'),++ strength: numberWithin(value.strength ?? 0.3, 0, 4, 'environment.wind.strength'),++ direction: numberWithin(value.direction ?? 0, -360, 360, 'environment.wind.direction'),};}@@@ -112,37 -112,37 +115,38 @@@ function mergedRuntime(placed, vegetati/** Validate the `vegetation` field of a node (`node` is the whole node, which must be a group). Returns the canonical form kept in the recipe. */export function normalizeVegetation(value, node) {-- if (node && (node.geometry !== undefined || node.skin !== undefined || node.asset !== undefined)) {-- throw new TypeError(`Node ${node.id}: a node that grows vegetation is a group; drop geometry, material, skin and asset.`);++ const conflict = node && ['geometry', 'skin', 'asset'].find(field => node[field] !== undefined);++ if (conflict) {++ throw invalidField(conflict, node[conflict], 'nothing, because a node that grows vegetation is a group; drop geometry, material, skin and asset', TypeError);}knownKeys(value, VEGETATION_FIELDS, 'vegetation');const result = {};if ((value.species === undefined) === (value.mix === undefined)) {-- throw new TypeError('vegetation needs exactly one of species (one tree) or mix (a scatter, species weights).');++ throw invalidField('vegetation.species', value.species, 'exactly one of species (one tree, such as "broadleaf") or mix (a scatter, such as { "broadleaf": 3, "bush": 1 })', TypeError);}if (value.species !== undefined) {if (!SCATTER_SPECIES.includes(value.species) || (!value.scatter && !SPECIES[value.species])) {-- throw new RangeError(`vegetation species must be one of ${(value.scatter ? SCATTER_SPECIES : Object.keys(SPECIES)).join(', ')}.`);++ throw invalidField('vegetation.species', value.species, `one of ${(value.scatter ? SCATTER_SPECIES : Object.keys(SPECIES)).join(', ')}`);}result.species = value.species;} else {-- if (!value.scatter) throw new TypeError('vegetation mix needs scatter. A single tree takes species.');-- if (!value.mix || typeof value.mix !== 'object' || Array.isArray(value.mix)) throw new TypeError('vegetation mix must map species to weights.');++ if (!value.scatter) throw invalidField('vegetation.scatter', value.scatter, 'a scatter, such as { "ground": "ground" }, because mix needs one; a single tree takes species', TypeError);++ if (!value.mix || typeof value.mix !== 'object' || Array.isArray(value.mix)) throw invalidField('vegetation.mix', value.mix, 'an object that maps species to weights, such as { "broadleaf": 3, "bush": 1 }', TypeError);result.mix = {};for (const [name, weight] of Object.entries(value.mix)) {-- if (!SCATTER_SPECIES.includes(name)) throw new RangeError(`vegetation mix species must be among ${SCATTER_SPECIES.join(', ')}; got ${name}.`);-- result.mix[name] = numberWithin(weight, 0, 100, `mix ${name}`);++ if (!SCATTER_SPECIES.includes(name)) throw invalidField('vegetation.mix', name, `species names among ${SCATTER_SPECIES.join(', ')}`);++ result.mix[name] = numberWithin(weight, 0, 100, `vegetation.mix.${name}`);}-- if (!Object.values(result.mix).some(weight => weight > 0)) throw new RangeError('vegetation mix needs one positive weight.');++ if (!Object.values(result.mix).some(weight => weight > 0)) throw invalidField('vegetation.mix', value.mix, 'at least one positive weight, such as { "broadleaf": 1 }');}-- result.seed = numberWithin(value.seed ?? 1, -2147483648, 2147483647, 'vegetation seed');-- if (value.height !== undefined) result.height = numberWithin(value.height, 0.2, 80, 'vegetation height');++ result.seed = numberWithin(value.seed ?? 1, -2147483648, 2147483647, 'vegetation.seed');++ if (value.height !== undefined) result.height = numberWithin(value.height, 0.2, 80, 'vegetation.height');result.leaves = value.leaves ?? 'cards';-- if (result.leaves !== 'cards' && result.leaves !== 'mesh') throw new RangeError('vegetation leaves must be cards or mesh.');-- result.season = numberWithin(value.season ?? 0, 0, 1, 'vegetation season');-- if (value.cullDistance !== undefined) result.cullDistance = numberWithin(value.cullDistance, 1, 100_000, 'vegetation cullDistance');-- result.distanceScale = numberWithin(value.distanceScale ?? 1, 0.1, 10, 'vegetation distanceScale');-- if (value.scatter !== undefined) result.scatter = normalizeScatter(value.scatter);++ if (result.leaves !== 'cards' && result.leaves !== 'mesh') throw invalidField('vegetation.leaves', result.leaves, '"cards" or "mesh"');++ result.season = numberWithin(value.season ?? 0, 0, 1, 'vegetation.season');++ if (value.cullDistance !== undefined) result.cullDistance = numberWithin(value.cullDistance, 1, 100_000, 'vegetation.cullDistance');++ result.distanceScale = numberWithin(value.distanceScale ?? 1, 0.1, 10, 'vegetation.distanceScale');++ if (value.scatter !== undefined) result.scatter = normalizeScatter(value.scatter, 'vegetation.scatter');return result;}@@@ -186,7 -186,7 +190,7 @@@ function groundTerrain(recipe, scatterconst ground = recipe.nodes.find(node => node.id === scatter.ground);const definition = ground && recipe.geometries.find(geometry => geometry.id === ground.geometry);if (definition?.type !== 'terrain') {-- throw new RangeError(`vegetation scatter ground ${JSON.stringify(scatter.ground.slice(0, 48))} must be a node drawing a terrain geometry. Give the group node the same transform as the ground.`);++ throw invalidField('vegetation.scatter.ground', scatter.ground, 'the ID of a node that draws a terrain geometry, such as "ground"; give the group node the same transform as the ground');}return { definition, terrain: createRecipeTerrain(definition) };}@@@ -206,7 -206,7 +210,7 @@@ function exclusionTest(recipe, scatterlet center = entry.center;if (entry.node) {const target = recipe.nodes.find(node => node.id === entry.node);-- if (!target) throw new RangeError(`vegetation exclusion names node ${JSON.stringify(entry.node.slice(0, 48))}, which is not in the recipe.`);++ if (!target) throw invalidField('vegetation.scatter.exclude[].node', entry.node, 'the ID of a node in the recipe, such as "pond"');center = [target.translation[0], target.translation[2]];}return (x, z) => Math.hypot(x - center[0], z - center[1]) <= entry.radius;@@@ -221,7 -221,7 +225,7 @@@ export function scatterOptionsFor(recipconst area = scatterArea(scatter, definition);const candidates = (area.maxX - area.minX) * (area.maxZ - area.minZ) * scatter.density;if (candidates > VEGETATION_LIMITS.maxCandidates) {-- throw new RangeError(`This scatter would try about ${Math.round(candidates)} trees. Lower density or give a smaller area; the limit is ${VEGETATION_LIMITS.maxInstances} placed instances.`);++ throw invalidField('vegetation.scatter.density', scatter.density, `a density that tries at most ${VEGETATION_LIMITS.maxCandidates} trees over the area (this tries about ${Math.round(candidates)}); lower it or give a smaller area`);}return {area, density: scatter.density, terrainHeight: terrain.heightAt, slopeLimit: scatter.slopeLimit,@@@ -237,7 -237,7 +241,7 @@@ function grow(recipe, vegetation)}const scattered = scatterVegetation(scatterOptionsFor(recipe, vegetation));if (scattered.instances.length > VEGETATION_LIMITS.maxInstances) {-- throw new RangeError(`This scatter placed ${scattered.instances.length} instances; the limit is ${VEGETATION_LIMITS.maxInstances}. Lower density or give a smaller area.`);++ throw invalidField('vegetation.scatter.density', vegetation.scatter.density, `a density that places at most ${VEGETATION_LIMITS.maxInstances} instances (this placed ${scattered.instances.length}); lower it or give a smaller area`);}return { variants: Object.values(scattered.variants).flat(), instances: scattered.instances };}@@@ -340,7 -340,7 +344,7 @@@ export function expandVegetation(recipe});}if (recipe.nodes.length + generatedNodes.length > limits.maxNodes) {-- throw new RangeError(`Vegetation expands to ${generatedNodes.length} part nodes, which with the ${recipe.nodes.length} authored nodes exceeds maxNodes ${limits.maxNodes}. Lower density or cull far trees with cullDistance.`);++ throw invalidField('vegetation.scatter.density', `${generatedNodes.length} generated part nodes`, `a density that keeps authored plus generated nodes (${recipe.nodes.length} authored) within maxNodes ${limits.maxNodes}; lower it or cull far trees with cullDistance`);}recipe.nodes.push(...generatedNodes);return mergedRuntime(placedRuntime, runtime);diff --cc tests/actionable-errors-nature.test.jsindex 00000000,00000000..b0ee7f28new file mode 100644--- /dev/null+++ b/tests/actionable-errors-nature.test.js@@@ -1,0 -1,0 +1,107 @@@++import test from 'node:test';++import assert from 'node:assert/strict';++import { readFileSync } from 'node:fs';++import { createAgentScene, loadAllAgentSceneModules } from '../src/agent-scene.js';++++await loadAllAgentSceneModules();++++const FRAME_IDS = ['a', 'b'].map(letter => letter.repeat(64));++const GROUND = { id: 'ground', type: 'terrain', size: 60, resolution: 32, seed: 3, amplitude: 2 };++++function natureRecipe() {++ return {++ format: '67js.scene', schemaVersion: 1,++ geometries: [GROUND, { id: 'speck', type: 'box', bevel: 0 }, { id: 'sheet', type: 'grid', segments: 4 }],++ materials: [{ id: 'grass', tag: 'grass', color: [0.2, 0.4, 0.1] }, { id: 'glow', color: [1, 0.5, 0.1], emission: 4 }, { id: 'fabric', color: [0.7, 0.2, 0.2], doubleSided: true }],++ nodes: [++ { id: 'hills', geometry: 'ground', material: 'grass' },++ { id: 'sparks', geometry: 'speck', material: 'glow' },++ { id: 'flag', geometry: 'sheet', material: 'fabric', translation: [0, 2, 0] },++ { id: 'forest' },++ ],++ };++}++++function bad(change) {++ return () => {++ const recipe = natureRecipe();++ change(recipe);++ return createAgentScene(recipe, {}, { sequenceFrames: new Map() });++ };++}++++function vegetation(value) {++ return bad(recipe => { recipe.nodes[3].vegetation = value; });++}++++function particles(value) {++ return bad(recipe => { recipe.particles = value; });++}++++function cloth(value) {++ return bad(recipe => { recipe.cloth = value; });++}++++function sequence(value) {++ return bad(recipe => { recipe.materials[1].map = { sequence: value }; });++}++++// Each case: how an agent reaches the error, the full field path it must name, the value it must echo, and the example or range.++const CASES = [++ ['vegetation species unknown', vegetation({ species: 'cactus' }), 'nodes[3].vegetation.species', '"cactus"', 'one of broadleaf'],++ ['vegetation season above one', vegetation({ species: 'broadleaf', season: 3 }), 'nodes[3].vegetation.season', '3', 'from 0 to 1'],++ ['vegetation scatter without a ground', vegetation({ species: 'broadleaf', scatter: {} }), 'nodes[3].vegetation.scatter.ground', 'undefined', 'such as "ground"'],++ ['vegetation scatter density too high', vegetation({ species: 'broadleaf', scatter: { ground: 'hills', density: 9 } }), 'nodes[3].vegetation.scatter.density', '9', 'from 0.0001 to 4'],++ ['vegetation exclusion corner as text', vegetation({ species: 'broadleaf', scatter: { ground: 'hills', exclude: [{ min: 'a', max: [1, 1] }] } }), 'nodes[3].vegetation.scatter.exclude[0].min', '"a"', '[x, z] in metres, such as [0, 0]'],++ ['vegetation scatter ground that is not terrain', vegetation({ species: 'broadleaf', scatter: { ground: 'sparks' } }), 'vegetation.scatter.ground', '"sparks"', 'terrain geometry'],++ ['wind strength above four', bad(recipe => { recipe.environment = { wind: { strength: 9 } }; }), 'environment.wind.strength', '9', 'from 0 to 4'],++ ['particle count above the limit', particles({ systems: [{ node: 'sparks', count: 2001 }] }), 'particles.systems[0].count', '2001', 'from 1 to 2000'],++ ['particle emitter shape unknown', particles({ systems: [{ node: 'sparks', emitter: { shape: 'cone' } }] }), 'particles.systems[0].emitter.shape', '"cone"', 'one of point, box'],++ ['particle node that does not exist', particles({ systems: [{ node: 'missing' }] }), 'particles.systems[0].node', '"missing"', 'the ID of a node in the recipe'],++ ['particle gravity with two numbers', particles({ systems: [{ node: 'sparks' }], gravity: [0, -9] }), 'particles.gravity', '[0,-9]', 'an array of 3 numbers'],++ ['particle lifetime range reversed', particles({ systems: [{ node: 'sparks', lifetime: [2, 1] }] }), 'particles.systems[0].lifetime', '[2,1]', '[minimum, maximum]'],++ ['particle field that does not exist', particles({ systems: [{ node: 'sparks', colour: 'red' }] }), 'particles.systems[0].colour', '"red"', 'no such field'],++ ['cloth duration above ten', cloth({ duration: 11, sheets: [{ node: 'flag' }] }), 'cloth.duration', '11', 'from 0.1 to 10'],++ ['cloth pin edge unknown', cloth({ duration: 2, sheets: [{ node: 'flag', pin: ['middle'] }] }), 'cloth.sheets[0].pin[0]', '"middle"', 'one of top, bottom'],++ ['cloth sheet node that is a group', cloth({ duration: 2, sheets: [{ node: 'forest' }] }), 'cloth.sheets[0].node', '"forest"', 'a node that draws a geometry'],++ ['cloth collider shape unknown', cloth({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'sparks', shape: 'cone' }] }), 'cloth.colliders[0].shape', '"cone"', 'one of ball, box'],++ ['cloth capsule collider without an end node', cloth({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ attach: 'sparks', shape: 'capsule', radius: 0.1 }] }), 'cloth.colliders[0].to', 'undefined', 'the ID of the node'],++ ['cloth pinTo without a pin', cloth({ duration: 2, sheets: [{ node: 'flag', pinTo: { node: 'sparks' } }] }), 'cloth.sheets[0].pinTo', '{"node":"sparks"}', 'also sets pin'],++ ['texture sequence fps above the limit', sequence({ frames: FRAME_IDS, fps: 600 }), 'materials[1].map.sequence.fps', '600', 'at most 60, such as 12'],++ ['texture sequence frame that is not an asset ID', sequence({ frames: [FRAME_IDS[0], 'not-an-id'] }), 'materials[1].map.sequence.frames[1]', '"not-an-id"', '64 hexadecimal characters'],++ ['texture sequence with one frame', sequence({ frames: [FRAME_IDS[0]], fps: 10 }), 'materials[1].map.sequence.frames', '"1 frames"', 'a list of 2 to 64'],++ ['texture sequence loop as text', sequence({ frames: FRAME_IDS, fps: 10, loop: 'yes' }), 'materials[1].map.sequence.loop', '"yes"', 'true or false'],++];++++for (const [name, trigger, path, received, expectation] of CASES) {++ test(`${name} names ${path}, the value and what is accepted`, () => {++ assert.throws(trigger, error => {++ assert.ok(error.message.includes(`${path}: got ${received}; expected `), `message was: ${error.message}`);++ assert.ok(error.message.includes(expectation), `message was: ${error.message}`);++ return true;++ });++ });++}++++// The guard: these files hold the nature validators an agent reaches through recipes (vegetation, particles and hair,++// cloth, image sequences). A throw in them reports through invalidField, which names the path, the value and what is++// accepted. A throw listed here stays raw on purpose: host wiring no recipe field can fix. A new raw throw fails this++// test until it uses invalidField or is listed.++const RAW_THROWS_LEFT = {++ 'src/agent-vegetation.js': [],++ 'src/agent-particles.js': [],++ 'src/agent-cloth.js': [],++ 'src/agent-texture-sequence.js': [++ "`Material ${materialId}: image ${id.slice(0, 12)} was not loaded. The host decodes catalog images before createAgentScene or apply.`",++ ],++ 'src/agent-recipe-checks.js': [],++};++const THROW_PATTERN = /throw new (?:Range|Type)?Error\((.{0,40})/;++++for (const [file, listed] of Object.entries(RAW_THROWS_LEFT)) {++ test(`${file} adds no raw throw that lacks a field path and an expectation`, () => {++ const lines = readFileSync(new URL(`../${file}`, import.meta.url), 'utf8').split(/\r?\n/);++ const found = lines.map(line => line.match(THROW_PATTERN)?.[1]).filter(Boolean);++ assert.deepEqual(found, listed.map(text => text.slice(0, 40)), `${file}: report agent input mistakes with invalidField(path, value, expected) from src/field-error.js; list a throw here only when no input field can cause it`);++ });++}diff --cc tests/actionable-errors-scene-core.test.jsindex 00000000,c5648381..00d428c5mode 000000,100644..100644--- a/tests/actionable-errors-scene-core.test.js+++ b/tests/actionable-errors-scene-core.test.js@@@ -1,0 -1,142 +1,136 @@@+ import './support/load-agent-scene-modules.mjs';+ import test from 'node:test';+ import assert from 'node:assert/strict';+ import { readFileSync } from 'node:fs';+ import { createAgentScene } from '../src/agent-scene.js';+ import { taggedFacePositions } from '../src/agent-mesh.js';+ import { generateTerrainGeometry } from '../src/agent-terrain.js';+ import { loadAgentSceneModules } from '../src/agent-scene-modules.js';++ function baseRecipe() {+ return {+ format: '67js.scene', schemaVersion: 1,+ geometries: [{ id: 'cube', type: 'box', bevel: 0 }, { id: 'sheet', type: 'grid', segments: 4 }],+ materials: [{ id: 'plain', color: [0.5, 0.5, 0.5] }],+ nodes: [{ id: 'body', geometry: 'cube', material: 'plain' }, { id: 'flag', geometry: 'sheet', material: 'plain' }],+ };+ }++ async function recipeError(change, limits) {+ const recipe = baseRecipe();+ change(recipe);+ await loadAgentSceneModules(recipe);+ try {+ createAgentScene(recipe, limits);+ } catch (error) {+ return error;+ }+ assert.fail('the recipe was accepted');+ }++ // Each case names the full path, the value received and what is accepted with an example or a range.+ const RECIPE_CASES = [+ // src/agent-scene.js+ ['a node flag names its full path', recipe => { recipe.nodes[0].decal = 'yes'; }, TypeError, /^nodes\[0\]\.decal: got "yes"; expected true or false\.$/],+ ['an unknown node field names the field to remove', recipe => { recipe.nodes[0].colour = 'red'; }, TypeError, /^nodes\[0\]\.node\.colour: got "red"; expected one of the fields id, geometry, material.*; remove colour\.$/],+ ['a camera takes fov or focalLength, never both', recipe => { recipe.camera = { fov: 40, focalLength: 50 }; }, RangeError, /^camera\.focalLength: got 50; expected only one of fov \(degrees\) or focalLength \(millimetres with sensorWidth\), such as fov 45; remove the other\.$/],+ ['a missing material names the choices', recipe => { recipe.nodes[0].material = 'ghost'; }, RangeError, /^nodes\.body\.material: got "ghost"; expected one of plain\.$/],+ ['a duplicate ID names the collection', recipe => { recipe.nodes[1].id = 'body'; }, RangeError, /^nodes\[1\]\.id: got "body"; expected an ID no other nodes entry uses; rename one, or remove the other\.$/],+ ['a geometry type outside the list names the list', recipe => { recipe.geometries[0].type = 'blob'; }, TypeError, /^geometries\[0\]\.type: got "blob"; expected one of box, cylinder.*terrain\.$/],+ ['a point list gives the range and an example', recipe => { recipe.geometries.push({ id: 'ring', type: 'lathe', profile: [[1, 0]] }); }, RangeError, /^geometries\[2\]\.profile: got "1 points"; expected a list of 2 to 4096 points of 2 numbers, such as \[\[0,0\],\[1,1\]\]\.$/],+ ['a wrong schema version gives the expected value', recipe => { recipe.schemaVersion = 2; }, RangeError, /^schemaVersion: got 2; expected 1\.$/],- // src/agent-recipe-checks.js (cloth sections use its shared checks)- ['a cloth node that does not exist', recipe => { recipe.cloth = { duration: 2, sheets: [{ node: 'ghost' }] }; }, RangeError, /^Cloth sheet node: got "ghost"; expected the ID of a node in nodes, such as one scene_inspect lists\.$/],- ['a cloth number outside its range', recipe => { recipe.cloth = { duration: 0, sheets: [{ node: 'flag' }] }; }, RangeError, /^Cloth duration: got 0; expected a finite number from 0\.1 to \d+, such as 1\.$/],- ['a cloth vector of the wrong length', recipe => { recipe.cloth = { duration: 2, gravity: [0, 1], sheets: [{ node: 'flag' }] }; }, TypeError, /^Cloth gravity: got \[0,1\]; expected three numbers, such as \[0, 1, 0\]\.$/],- ['a cloth list that is not a list', recipe => { recipe.cloth = { duration: 2, sheets: 'flag' }; }, TypeError, /^Cloth sheets: got "flag"; expected an array of at most \d+ entries, such as \[\]\.$/],- ['an unknown cloth field names the field to remove', recipe => { recipe.cloth = { duration: 2, surprise: 1, sheets: [{ node: 'flag' }] }; }, TypeError, /^cloth\.surprise: got 1; expected one of the fields duration.*; remove surprise\.$/],+ // src/agent-terrain.js+ ['a terrain size outside its range', recipe => { recipe.geometries.push({ id: 'ground', type: 'terrain', size: 0 }); }, RangeError, /^geometries\[2\]\.terrain\.size: got 0; expected a number from 1 to 2000, such as 40\.$/],+ ['a terrain resolution that is not whole', recipe => { recipe.geometries.push({ id: 'ground', type: 'terrain', resolution: 8.5 }); }, RangeError, /^geometries\[2\]\.terrain\.resolution: got 8\.5; expected a whole number, such as 64\.$/],+ ['terrain holes that are not a list', recipe => { recipe.geometries.push({ id: 'ground', type: 'terrain', holes: 'many' }); }, RangeError, /^geometries\[2\]\.terrain\.holes: got "many"; expected a list of at most 16 circles, such as \[\{ "center": \[0, 0\], "radius": 2 \}\]\.$/],+ ['a terrain amplitude outside its range', recipe => { recipe.geometries.push({ id: 'ground', type: 'terrain', amplitude: 500 }); }, RangeError, /^geometries\[2\]\.terrain\.amplitude: got 500; expected a number from 0 to 200, such as 1\.$/],+ // src/agent-mesh.js+ ];++ for (const [name, change, ErrorType, pattern, limits] of RECIPE_CASES) {+ test(`recipe error: ${name}`, async () => {+ const error = await recipeError(change, limits);+ assert.ok(error instanceof ErrorType, `${error.name}: ${error.message}`);+ assert.match(error.message, pattern);+ });+ }++ test('scene operations report the field, the value and what is accepted', () => {+ const scene = createAgentScene(baseRecipe(), { maxCheckpoints: 1 });+ const expectError = (run, ErrorType, pattern) => assert.throws(run, error => error instanceof ErrorType && pattern.test(error.message), `${pattern}`);+ expectError(() => scene.apply([{ type: 'remove-node', id: 'ghost' }], { expectedRevision: 0 }), RangeError, /^id: got "ghost"; expected the ID of a node in nodes; scene_inspect lists them\.$/);+ expectError(() => scene.apply([{ type: 'set-node', id: 'ghost' }], { expectedRevision: 0 }), RangeError, /^id: got "ghost"; expected the ID of an existing node;/);+ expectError(() => scene.apply([{ type: 'launch' }], { expectedRevision: 0 }), TypeError, /^type: got "launch"; expected one of set-node, set-material/);+ expectError(() => scene.apply([], { expectedRevision: 0 }), RangeError, /^operations: got "0 operations"; expected a list of 1 to \d+ operations, such as \[\{ "type": "set-camera", "fov": 50 \}\]\.$/);+ expectError(() => scene.apply([{ type: 'set-camera', fov: 50 }], { expectedRevision: 7 }), RangeError, /^expectedRevision: got 7; expected the current revision, 0; scene_inspect returns it\.$/);+ expectError(() => scene.apply([{ type: 'remove-node', id: 'body', recursive: 'yes' }], { expectedRevision: 0 }), TypeError, /^recursive: got "yes"; expected true or false\.$/);+ expectError(() => scene.inspect({ ids: ['ghost'] }), RangeError, /^ids: got "ghost"; expected IDs of existing nodes; call scene_inspect without ids to list them\.$/);+ expectError(() => scene.inspect({ includeBounds: 'yes' }), TypeError, /^includeBounds: got "yes"; expected true or false\.$/);+ expectError(() => scene.inspect({ path: { ground: 'ghost', from: [0, 0], to: [1, 1] } }), RangeError, /^path\.ground: got "ghost"; expected the ID of a node with a drawn geometry;/);+ expectError(() => scene.inspectMeshes({ geometries: ['ghost'] }), RangeError, /^geometries: got "ghost"; expected one of cube, sheet\.$/);+ expectError(() => scene.sampleMotion(1), RangeError, /^time: got 1; expected null, because this recipe has no motion/);+ expectError(() => scene.sampleMotion(4000), RangeError, /^time: got 4000; expected null or a number of seconds from 0 to 3600, such as 0\.5\.$/);+ const checkpoint = scene.checkpoint();+ expectError(() => scene.checkpoint(), RangeError, /^checkpoints: got "1 saved"; expected at most 1 saved checkpoints;/);+ scene.releaseCheckpoint(checkpoint);+ expectError(() => scene.releaseCheckpoint(checkpoint), RangeError, /^checkpointId: got \{\}; expected a checkpointId that scene_checkpoint returned and you have not released\.$/);+ });++ test('a mesh region on a plain shape names the tag and the next step', () => {+ const recipe = baseRecipe();+ recipe.nodes[1] = { id: 'lid', geometry: 'cube', material: 'plain', relations: [{ kind: 'gap', to: 'body', region: 'top', side: '+y' }] };+ assert.throws(() => createAgentScene(recipe), error => error instanceof RangeError+ && /region: got "top"; expected a tag on a mesh geometry; tag faces with a mesh_edit tag op, or drop region/.test(error.message));+ });++ test('direct mesh and terrain builders name the field and the next step', () => {+ const scene = createAgentScene(baseRecipe());+ assert.throws(() => taggedFacePositions(scene.parts[0].geometry, 'lid'), error => error instanceof RangeError+ && /^region: got "lid"; expected a tag on a mesh geometry; tag faces with a mesh_edit tag op, or drop region\.$/.test(error.message));+ assert.throws(() => generateTerrainGeometry({ resolution: 200 }, 5000), error => error instanceof RangeError+ && /^terrain\.resolution: got 200; expected a resolution whose 40401 vertices fit maxVertices 5000; lower it\.$/.test(error.message));+ assert.throws(() => generateTerrainGeometry({ resolution: 8.5 }, 5000), error => error instanceof RangeError+ && /^terrain\.resolution: got 8.5; expected a whole number, such as 64\.$/.test(error.message));+ });++ // The guard: these files hold the validators an agent reaches through recipes and operations. A throw in them reports+ // through invalidField, which names the path, the value and what is accepted. The throws listed here stay raw on+ // purpose: whole-input size limits, JSON copy checks that run before any field has a path, and engine invariants no+ // recipe field can fix. A new raw throw fails this test until it uses invalidField or is listed.+ const RAW_THROWS_LEFT = {+ 'src/agent-scene.js': [+ "'maxNodes cannot exceed 4096.');",+ "'JSON exceeds maxRecipeBytes. Reduce the",+ "'JSON nesting exceeds 64 levels.');",+ "'JSON exceeds maxRecipeBytes.');",+ "'Recipe must contain finite, acyclic JSO",+ "'JSON exceeds maxRecipeBytes.');",+ "'Recipe objects must be plain JSON objec",+ "'Invalid JSON key.');",+ "'JSON accessors and hidden fields are un",+ "'JSON arrays must be dense without extra",+ "'JSON arrays must be dense without trail",+ "'JSON exceeds maxRecipeBytes.');",+ "'Camera matrices must remain finite and ",+ "`Node ${node.name} normal transform exce",+ "`Node ${node.name} world geometry bounds",+ "'Retained render matrices must not be de",+ "'Motion camera matrices exceed the suppo",+ "'Motion scale must remain positive at Fl",+ "'Geometry preflight exceeds peak maxVert",+ "`Mesh ${plan.definition.id} has ${vertic",+ "'Generated geometry exceeds its conserva",+ ],+ 'src/agent-recipe-checks.js': [],+ 'src/agent-mesh.js': [],+ 'src/agent-terrain.js': [],+ };+ const THROW_PATTERN = /throw new (?:Range|Type)?Error\((.{0,40})/;++ for (const [file, listed] of Object.entries(RAW_THROWS_LEFT)) {+ test(`${file} adds no raw throw that lacks a field path and an expectation`, () => {+ const lines = readFileSync(new URL(`../${file}`, import.meta.url), 'utf8').split(/\r?\n/);+ const found = lines.map(line => line.match(THROW_PATTERN)?.[1]).filter(Boolean);+ assert.deepEqual(found, listed, `${file}: report agent input mistakes with invalidField(path, value, expected) from src/field-error.js; list a throw here only when no input field can cause it`);+ });+ }diff --cc tests/agent-scene-motion.test.jsindex 677a4277,05bdce36..ed4cda30--- a/tests/agent-scene-motion.test.js+++ b/tests/agent-scene-motion.test.js@@@ -96,10 -96,10 +96,10 @@@ test('final batch reference validationscene.sampleMotion(1);const before = pose(scene);const canonical = scene.exportRecipe();- assert.throws(() => scene.apply([{ type: 'remove-node', id: 'hinge', recursive: true }], { expectedRevision: 0 }), /target/);+ assert.throws(() => scene.apply([{ type: 'remove-node', id: 'hinge', recursive: true }], { expectedRevision: 0 }), /motion\.tracks\[0\]\.id: got "hinge"/);assert.deepEqual(pose(scene), before);assert.deepEqual(scene.exportRecipe(), canonical);- assert.throws(() => scene.apply([{ type: 'set-motion' }], { expectedRevision: 0 }), /requires motion/);+ assert.throws(() => scene.apply([{ type: 'set-motion' }], { expectedRevision: 0 }), /motion: got undefined; expected a motion value, or null to clear it/);scene.apply([{ type: 'remove-node', id: 'hinge', recursive: true },{ type: 'remove-material', id: 'finish' },diff --cc tests/agent-scene-vegetation.test.jsindex 528a29cc,528a29cc..18e6401b--- a/tests/agent-scene-vegetation.test.js+++ b/tests/agent-scene-vegetation.test.js@@@ -130,19 -130,19 +130,19 @@@ test('one tree grows at the node transfassert.equal(single.parts.length, 2);assert.equal(single.parts[0].matrix[12], 4);const bad = (vegetation, pattern) => assert.throws(() => createAgentScene({ ...stillRecipe(), nodes: [{ id: 'hills', geometry: 'ground', material: 'grass' }, { id: 'marker', geometry: 'marker', material: 'steel' }, { id: 'forest', vegetation }] }), pattern);-- bad({ mix: { broadleaf: 1 }, scatter: { ground: 'marker' } }, /terrain/);-- bad({ mix: { oak: 1 }, scatter: { ground: 'hills' } }, /species/);-- bad({ species: 'broadleaf', mix: { birch: 1 } }, /exactly one/);-- bad({ species: 'grass' }, /species must be/);-- bad({ mix: { grass: 1 }, scatter: { ground: 'hills', density: 4 } }, /try about/);++ bad({ mix: { broadleaf: 1 }, scatter: { ground: 'marker' } }, /vegetation\.scatter\.ground: got "marker"; expected the ID of a node that draws a terrain geometry/);++ bad({ mix: { oak: 1 }, scatter: { ground: 'hills' } }, /vegetation\.mix: got "oak"; expected species names among/);++ bad({ species: 'broadleaf', mix: { birch: 1 } }, /vegetation\.species: got "broadleaf"; expected exactly one of species/);++ bad({ species: 'grass' }, /vegetation\.species: got "grass"; expected one of broadleaf/);++ bad({ mix: { grass: 1 }, scatter: { ground: 'hills', density: 4 } }, /vegetation\.scatter\.density: got 4; expected a density that tries at most/);});test('environment.wind validates and survives export', () => {const scene = createAgentScene(forestRecipe());assert.deepEqual(scene.environment.wind, { strength: 0.8, direction: 30 });assert.deepEqual(scene.exportRecipe().environment.wind, { strength: 0.8, direction: 30 });-- assert.throws(() => createAgentScene({ ...forestRecipe(), environment: { wind: { strength: 9 } } }), /strength/);-- assert.throws(() => createAgentScene({ ...forestRecipe(), environment: { wind: { speed: 1 } } }), /Unknown wind field/);++ assert.throws(() => createAgentScene({ ...forestRecipe(), environment: { wind: { strength: 9 } } }), /environment\.wind\.strength: got 9; expected a number from 0 to 4/);++ assert.throws(() => createAgentScene({ ...forestRecipe(), environment: { wind: { speed: 1 } } }), /environment\.wind\.speed: got 1; expected no such field; use one of strength, direction/);});test('an imported tree with a foliage override gets the swaying tag and shares it between placements', async () => {diff --cc tests/agent-scene.test.jsindex e7c22bf3,680e9b89..eef05fe3--- a/tests/agent-scene.test.js+++ b/tests/agent-scene.test.js@@@ -302,16 -302,16 +302,16 @@@ test('recipe boundary rejects malforme});test('command and resource budgets, bounded inspection and missing IDs report failures', () => {- assert.throws(() => createAgentScene(recipe(), { maxNodes: 2 }), /resource limit/);+ assert.throws(() => createAgentScene(recipe(), { maxNodes: 2 }), /nodes: got "3 entries"; expected an array of at most 2 entries/);const extra = recipe();extra.geometries.push({ id: 'sphere', type: 'sphere', segments: 8, rings: 4 });- assert.throws(() => createAgentScene(extra, { maxGeometries: 1 }), /resource limit/);+ assert.throws(() => createAgentScene(extra, { maxGeometries: 1 }), /geometries: got "2 entries"; expected an array of at most 1 entries/);const duplicate = recipe();duplicate.nodes[2].id = 'root';- assert.throws(() => createAgentScene(duplicate), /Duplicate/);+ assert.throws(() => createAgentScene(duplicate), /nodes\[2\]\.id: got "root"; expected an ID no other nodes entry uses/);const session = createAgentScene(recipe(), { maxOperations: 1 });- assert.throws(() => session.apply([{ type: 'set-camera', fov: 60 }, { type: 'set-camera', fov: 70 }], { expectedRevision: 0 }), /maxOperations/);- assert.throws(() => session.apply([], { expectedRevision: 0 }), /commands/);+ assert.throws(() => session.apply([{ type: 'set-camera', fov: 60 }, { type: 'set-camera', fov: 70 }], { expectedRevision: 0 }), /operations: got "2 operations"; expected a list of 1 to 1 operations/);- assert.throws(() => session.apply([], { expectedRevision: 0 }), /operations: got \[\]; expected a list of 1 to 1 operations/);++ assert.throws(() => session.apply([], { expectedRevision: 0 }), /operations: got "0 operations"; expected a list of 1 to 1 operations/);const inspection = session.inspect({ limit: 1 });assert.equal(inspection.nodes.length, 1);assert.equal(inspection.truncated, true);diff --cc tests/agent-texture-sequence.test.jsindex b3f0cb84,b3f0cb84..1625b737--- a/tests/agent-texture-sequence.test.js+++ b/tests/agent-texture-sequence.test.js@@@ -48,14 -48,14 +48,14 @@@ test('frame index is floor(time * fps)test('a bad frame ID, frame count, fps or loop is rejected with a message that names the field', () => {const good = { frames: FRAME_IDS, fps: 12 };assert.deepEqual(normalizeMapSequence({ sequence: { ...good, frames: FRAME_IDS.map(id => id.toUpperCase()) } }).sequence.frames, FRAME_IDS);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, frames: [FRAME_IDS[0], 'not-an-id'] } }), /64 hexadecimal characters/);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, frames: [FRAME_IDS[0]] } }), /2 to 64/);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, fps: 0 } }), /fps must be above 0/);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, fps: 61 } }), /fps must be above 0 and at most 60/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, frames: [FRAME_IDS[0], 'not-an-id'] } }), /map\.sequence\.frames\[1\]: got "not-an-id"; expected the 64 hexadecimal characters/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, frames: [FRAME_IDS[0]] } }), /map\.sequence\.frames: got "1 frames"; expected a list of 2 to 64 catalog image asset IDs/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, fps: 0 } }), /map\.sequence\.fps: got 0; expected a number above 0 and at most 60/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, fps: 61 } }), /map\.sequence\.fps: got 61; expected a number above 0 and at most 60/);assert.throws(() => normalizeMapSequence({ sequence: { ...good, fps: Number.NaN } }), /fps/);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, loop: 'yes' } }), /loop must be boolean/);-- assert.throws(() => normalizeMapSequence({ sequence: { ...good, url: 'https://example.com/a.png' } }), /Unknown map sequence field: url/);-- assert.throws(() => normalizeMapSequence({ url: 'https://example.com/a.png' }), /Unknown material map field: url/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, loop: 'yes' } }), /map\.sequence\.loop: got "yes"; expected true or false/);++ assert.throws(() => normalizeMapSequence({ sequence: { ...good, url: 'https://example.com/a.png' } }), /map\.sequence\.url: got "https:\/\/example\.com\/a\.png"; expected no such field; use one of frames, fps, loop/);++ assert.throws(() => normalizeMapSequence({ url: 'https://example.com/a.png' }), /map\.url: got "https:\/\/example\.com\/a\.png"; expected no such field; use one of sequence/);});test('the scene shows the frame of its motion time, reports it and seeks deterministically', () => {@@@ -81,10 -81,10 +81,10 @@@ test('the scene rejects frames that arassert.throws(() => createAgentScene(quadRecipe({ frames: FRAME_IDS, fps: 10 }), {}, { sequenceFrames: new Map() }), /was not loaded/);const mixed = framePool();mixed.set(FRAME_IDS[1], { width: 4, height: 4, data: new Uint8ClampedArray(64) });-- assert.throws(() => createAgentScene(quadRecipe({ frames: FRAME_IDS, fps: 10 }), {}, { sequenceFrames: mixed }), /same size/);++ assert.throws(() => createAgentScene(quadRecipe({ frames: FRAME_IDS, fps: 10 }), {}, { sequenceFrames: mixed }), /map\.sequence\.frames: got "frames of different sizes in materia.*; expected frames that all measure 2x2/);const recipe = quadRecipe({ frames: FRAME_IDS, fps: 10 });recipe.materials[0].pattern = { type: 'bricks' };-- assert.throws(() => createAgentScene(recipe, {}, { sequenceFrames: framePool() }), /pattern or a map sequence/);++ assert.throws(() => createAgentScene(recipe, {}, { sequenceFrames: framePool() }), /pattern: got \{"type":"bricks"\}; expected nothing, because a material takes a pattern or a map sequence/);});test('an edit can set a sequence and the frame IDs of a recipe are collected for the host', () => {diff --cc tests/cloth-moving.test.jsindex 945fb7a7,945fb7a7..ed7e7e36--- a/tests/cloth-moving.test.js+++ b/tests/cloth-moving.test.js@@@ -170,10 -170,10 +170,10 @@@ test('a soft pin pulls the particle lestest('recipe checks refuse bad moving colliders and pins', () => {const bad = cloth => () => createAgentScene(walkingCapeRecipe({ ...CAPE, ...cloth }));-- assert.throws(bad({ colliders: [{ attach: 'chest', shape: 'capsule', radius: 0.1 }] }), /capsule collider needs to/);-- assert.throws(bad({ colliders: [{ attach: 'nowhere', radius: 0.1 }] }), /not found/);-- assert.throws(bad({ colliders: [{ armature: 'rig', exclude: ['tail'] }] }), /does not have/);-- assert.throws(bad({ colliders: [{ armature: 'ghost' }] }), /armature was not found/);-- assert.throws(bad({ sheets: [{ node: 'cape', pinTo: { node: 'chest' } }] }), /needs pin too/);-- assert.throws(bad({ sheets: [{ node: 'cape', pin: ['top'], pinTo: { node: 'chest', weight: 0 } }] }), /weight/);++ assert.throws(bad({ colliders: [{ attach: 'chest', shape: 'capsule', radius: 0.1 }] }), /cloth\.colliders\[0\]\.to: got undefined; expected the ID of the node the capsule other end rides on/);++ assert.throws(bad({ colliders: [{ attach: 'nowhere', radius: 0.1 }] }), /cloth\.colliders\[0\]\.attach: got "nowhere"; expected the ID of a node in the recipe/);++ assert.throws(bad({ colliders: [{ armature: 'rig', exclude: ['tail'] }] }), /cloth\.colliders\[0\]\.exclude: got "tail"; expected a bone name of rig/);++ assert.throws(bad({ colliders: [{ armature: 'ghost' }] }), /cloth\.colliders\[0\]\.armature: got "ghost"; expected the ID of an armature/);++ assert.throws(bad({ sheets: [{ node: 'cape', pinTo: { node: 'chest' } }] }), /cloth\.sheets\[0\]\.pinTo: got .*; expected a sheet that also sets pin/);++ assert.throws(bad({ sheets: [{ node: 'cape', pin: ['top'], pinTo: { node: 'chest', weight: 0 } }] }), /cloth\.sheets\[0\]\.pinTo\.weight: got 0; expected a number from 0\.01 to 1/);});diff --cc tests/cloth.test.jsindex e8d8ccb1,6122e8e0..45d9d635--- a/tests/cloth.test.js+++ b/tests/cloth.test.js@@@ -174,7 -174,7 +174,7 @@@ test('cloth recipes need the cloth modutest('set-cloth edits the section, null clears it and the recipe round trips', () => {const scene = createAgentScene(flagRecipe(null));- assert.throws(() => scene.sampleMotion(1), /no motion, physics, cloth or particles/);- assert.throws(() => scene.sampleMotion(1), /time: got 1; expected null, because this recipe has no motion, physics, cloth, particles or placed asset clip/);++ assert.throws(() => scene.sampleMotion(1), /no motion, physics, cloth, particles/);scene.apply([{ type: 'set-cloth', cloth: hangingFlag }], { expectedRevision: scene.revision });scene.sampleMotion(1);const exported = scene.exportRecipe();@@@ -198,26 -198,26 +198,26 @@@ test('editing a scene while the cloth itest('hostile cloth sections are rejected before any solver runs', () => {const bad = (cloth, pattern, nodes) => assert.throws(() => createAgentScene(flagRecipe(cloth, nodes)), pattern);-- bad({ duration: 2, sheets: [] }, /at least one sheet/);-- bad({ duration: 0, sheets: [{ node: 'flag' }] }, /duration/);-- bad({ duration: 11, sheets: [{ node: 'flag' }] }, /duration/);- bad({ duration: 2, sheets: [{ node: 'missing' }] }, /not found/);- bad({ duration: 2, sheets: [{ node: 'flag' }, { node: 'flag' }] }, /twice/);- bad({ duration: 2, sheets: [{ node: 'missing' }] }, /Cloth sheet node: got "missing"; expected the ID of a node in nodes/);- bad({ duration: 2, sheets: [{ node: 'flag' }, { node: 'flag' }] }, /Cloth sheet node: got "flag"; expected a node used once in cloth/);-- bad({ duration: 2, sheets: [{ node: 'flag', stiffness: 2 }] }, /stiffness/);-- bad({ duration: 2, sheets: [{ node: 'flag', density: 0 }] }, /density/);-- bad({ duration: 2, sheets: [{ node: 'flag', pin: ['middle'] }] }, /pin/);- bad({ duration: 2, sheets: [{ node: 'flag', surprise: 1 }] }, /Unknown/);- bad({ duration: 2, surprise: 1, sheets: [{ node: 'flag' }] }, /Unknown/);- bad({ duration: 2, sheets: [{ node: 'flag', surprise: 1 }] }, /cloth sheet\.surprise: got 1; expected one of the fields/);- bad({ duration: 2, surprise: 1, sheets: [{ node: 'flag' }] }, /cloth\.surprise: got 1; expected one of the fields/);++ bad({ duration: 2, sheets: [] }, /cloth\.sheets: got \[\]; expected at least one sheet/);++ bad({ duration: 0, sheets: [{ node: 'flag' }] }, /cloth\.duration: got 0; expected a number from 0\.1 to 10/);++ bad({ duration: 11, sheets: [{ node: 'flag' }] }, /cloth\.duration: got 11; expected a number from 0\.1 to 10/);++ bad({ duration: 2, sheets: [{ node: 'missing' }] }, /cloth\.sheets\[0\]\.node: got "missing"; expected the ID of a node in the recipe/);++ bad({ duration: 2, sheets: [{ node: 'flag' }, { node: 'flag' }] }, /cloth\.sheets\[1\]\.node: got "flag"; expected a node that cloth uses once/);++ bad({ duration: 2, sheets: [{ node: 'flag', stiffness: 2 }] }, /cloth\.sheets\[0\]\.stiffness: got 2; expected a number from 0\.01 to 1/);++ bad({ duration: 2, sheets: [{ node: 'flag', density: 0 }] }, /cloth\.sheets\[0\]\.density: got 0; expected a number from 0\.01 to 10/);++ bad({ duration: 2, sheets: [{ node: 'flag', pin: ['middle'] }] }, /cloth\.sheets\[0\]\.pin\[0\]: got "middle"; expected one of top, bottom/);++ bad({ duration: 2, sheets: [{ node: 'flag', surprise: 1 }] }, /cloth\.sheets\[0\]\.surprise: got 1; expected no such field/);++ bad({ duration: 2, surprise: 1, sheets: [{ node: 'flag' }] }, /cloth\.surprise: got 1; expected no such field/);bad({ duration: 2, wind: [0, 0, NaN], sheets: [{ node: 'flag' }] }, /finite/);-- bad({ duration: 2, wind: [0, 0, 1e9], sheets: [{ node: 'flag' }] }, /wind/);++ bad({ duration: 2, wind: [0, 0, 1e9], sheets: [{ node: 'flag' }] }, /cloth\.wind\[2\]: got 1000000000; expected a number from -100 to 100/);bad({ duration: 2, gravity: [0, -Infinity, 0], sheets: [{ node: 'flag' }] }, /finite/);-- bad({ duration: 2, sheets: Array.from({ length: 9 }, () => ({ node: 'flag' })) }, /at most 8/);-- bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: Array.from({ length: 17 }, () => ({ node: 'flag' })) }, /at most 16/);- bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'flag' }] }, /twice/);- bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'flag' }] }, /Cloth collider node: got "flag"; expected a node used once in cloth/);-- bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'stone', shape: 'cone' }] }, /shape/, [{ id: 'stone', geometry: 'ball', material: 'stone' }]);-- bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'child' }] }, /root node/, [{ id: 'child', parent: 'flag', geometry: 'ball', material: 'stone' }]);- bad('cloth', /plain object/);- bad('cloth', /expected an object/);-- bad({ duration: 2, sheets: 'flag' }, /array/);++ bad({ duration: 2, sheets: Array.from({ length: 9 }, () => ({ node: 'flag' })) }, /cloth\.sheets: got "9 entries"; expected an array of at most 8 entries/);++ bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: Array.from({ length: 17 }, () => ({ node: 'flag' })) }, /cloth\.colliders: got "17 entries"; expected an array of at most 16 entries/);++ bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'flag' }] }, /cloth\.colliders\[0\]\.node: got "flag"; expected a node that cloth uses once/);++ bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'stone', shape: 'cone' }] }, /cloth\.colliders\[0\]\.shape: got "cone"; expected one of ball, box/, [{ id: 'stone', geometry: 'ball', material: 'stone' }]);++ bad({ duration: 2, sheets: [{ node: 'flag' }], colliders: [{ node: 'child' }] }, /cloth\.colliders\[0\]\.node: got "child"; expected a root node with no parent/, [{ id: 'child', parent: 'flag', geometry: 'ball', material: 'stone' }]);++ bad('cloth', /cloth: got "cloth"; expected a plain object/);++ bad({ duration: 2, sheets: 'flag' }, /cloth\.sheets: got "flag"; expected an array/);});test('particle and frame limits reject oversized bakes with a clear error', () => {@@@ -230,8 -230,8 +230,8 @@@test('a cloth node cannot also carry motion or a physics body', () => {const withMotion = flagRecipe(hangingFlag);-- withMotion.motion = { duration: 1, loop: false, tracks: [{ kind: 'node', id: 'flag', property: 'translation', interpolation: 'linear', keys: [{ time: 0, value: [0, 2, 0] }, { time: 1, value: [1, 2, 0] }] }] };-- assert.throws(() => createAgentScene(withMotion), /motion/);++ withMotion.motion = { duration: 1, loop: false, tracks: [{ kind: 'node', id: 'flag', property: 'translation', interpolation: 'LINEAR', keyframes: [{ time: 0, value: [0, 2, 0] }, { time: 1, value: [1, 2, 0] }] }] };++ assert.throws(() => createAgentScene(withMotion), /cloth\.sheets\[0\]\.node: got "flag"; expected a node that stays where it is/);});test('welding joins vertices at one position so a seam cannot tear', () => {diff --cc tests/navmesh.test.jsindex fa6557e2,741c56b8..2047d64f--- a/tests/navmesh.test.js+++ b/tests/navmesh.test.js@@@ -81,6 -81,6 +81,6 @@@ test('scene_inspect path returns translassert.ok(!(value[0] > -8.8 && value[0] < -5.2 && value[2] > -8.8 && value[2] < -5.2), `${value} is inside the rock`);}assert.throws(() => scene.inspect({ path: { ground: 'ground', from: [0, 0], to: [15, 15] } }), /a hole/);- assert.throws(() => scene.inspect({ path: { ground: 'nowhere', from: [0, 0], to: [15, 15] } }), /not a node/);+ assert.throws(() => scene.inspect({ path: { ground: 'nowhere', from: [0, 0], to: [15, 15] } }), /path\.ground: got "nowhere"; expected the ID of a node with a drawn geometry/);- assert.throws(() => scene.inspect({ path: { ground: 'ground', from: [-15, -15], to: [15, 15], seconds: 2, speed: 1 } }), /seconds or speed/);+ assert.throws(() => scene.inspect({ path: { ground: 'ground', from: [-15, -15], to: [15, 15], seconds: 2, speed: 1 } }), /path\.speed: got 1; expected speed or seconds, not both/);});diff --cc tests/part-relations.test.jsindex 25ce8c6e,70568d98..2929fbf3--- a/tests/part-relations.test.js+++ b/tests/part-relations.test.js@@@ -97,9 -97,9 +97,9 @@@ test('a tagged region of the target is{ id: 'tank', geometry: 'tank' },{ id: 'cap', relations: [{ kind: 'gap', to: 'tank', region: 'lid', side: '+y' }] },], [body]);- assert.throws(() => createAgentScene(bad), /cannot be satisfied.*Unknown tag lid.*Known tags: .*top/s);+ assert.throws(() => createAgentScene(bad), /nodes\[1\]\.relations\[0\]\.region: got "lid"; expected a target that can be measured \(Unknown tag lid.*Known tags: .*top/s);const plain = recipeWith([{ id: 'a' }, { id: 'b', relations: [{ kind: 'gap', to: 'a', region: 'top', side: '+y' }] }]);- assert.throws(() => createAgentScene(plain), /plain shape.*tag faces with a mesh_edit tag op/s);+ assert.throws(() => createAgentScene(plain), /region: got "top"; expected a tag on a mesh geometry.*tag faces with a mesh_edit tag op/s);});test('relations solve the same every time and again after an edit moves a referenced region', () => {diff --cc tests/particle-collision.test.jsindex 456428e1,5f10a2e4..9d83fa92--- a/tests/particle-collision.test.js+++ b/tests/particle-collision.test.js@@@ -142,7 -142,7 +142,7 @@@ test('collision input is validated andconst rejects = (system, pattern) => assert.throws(() => createAgentScene(dropRecipe(system)), pattern);rejects({ bounce: 1.5 }, /bounce/);rejects({ friction: -1 }, /friction/);- rejects({ colliders: ['ghost'] }, /not found/);- rejects({ colliders: ['ghost'] }, /Particle collider node: got "ghost"; expected the ID of a node in nodes/);++ rejects({ colliders: ['ghost'] }, /particles\.systems\[0\]\.colliders\[0\]: got "ghost"; expected the ID of a node in the recipe/);rejects({ colliders: ['sparks'] }, /own collider/);rejects({ colliders: 'slab' }, /colliders/);rejects({ alpha: [0, 2] }, /alpha/);diff --cc tests/particles.test.jsindex cc53186c,6108e684..4aa9cf88--- a/tests/particles.test.js+++ b/tests/particles.test.js@@@ -145,7 -145,7 +145,7 @@@ test('set-particles adds, changes and cassert.equal(scene.inspect().particles.systems[0].particles, 5);scene.apply([{ type: 'set-particles', particles: null }], { expectedRevision: scene.revision });assert.equal(scene.inspect().particles, undefined);- assert.throws(() => scene.apply([{ type: 'set-particles' }], { expectedRevision: scene.revision }), /requires particles/);- assert.throws(() => scene.apply([{ type: 'set-particles' }], { expectedRevision: scene.revision }), /particles: got undefined; expected a particles value, or null to clear it/);++ assert.throws(() => scene.apply([{ type: 'set-particles' }], { expectedRevision: scene.revision }), /particles: got undefined; expected a particles value/);});test('the capabilities describe the limits that the validator enforces', () => {@@@ -157,68 -157,68 +157,68 @@@test('hostile input is rejected with the limit in the message', () => {const system = overrides => ({ systems: [{ node: 'sparks', ...overrides }] });const bad = (particles, pattern, nodes) => assert.throws(() => createAgentScene(sparkRecipe(particles, nodes)), pattern);-- bad(system({ count: 2001 }), /count must be an integer from 1 to 2000/);-- bad(system({ count: 1e9 }), /count must be an integer/);-- bad(system({ count: 0 }), /count must be an integer/);-- bad(system({ count: 1.5 }), /count must be an integer/);++ bad(system({ count: 2001 }), /systems\[0\]\.count: got 2001; expected a whole number from 1 to 2000/);++ bad(system({ count: 1e9 }), /\.count: got .*; expected a whole number from 1 to 2000/);++ bad(system({ count: 0 }), /\.count: got .*; expected a whole number from 1 to 2000/);++ bad(system({ count: 1.5 }), /\.count: got .*; expected a whole number from 1 to 2000/);bad(system({ count: Infinity }), /finite|count|speed|direction|rate/);-- bad(system({ count: '10' }), /count must be an integer/);-- bad(system({ seed: -1 }), /seed must be an integer/);-- bad(system({ seed: 2 ** 32 }), /seed must be an integer/);-- bad(system({ seed: 1.5 }), /seed must be an integer/);- bad(system({ lifetime: 0 }), /lifetime must be a finite number/);- bad(system({ lifetime: 1e9 }), /lifetime must be a finite number/);- bad(system({ lifetime: 0 }), /Particle lifetime: got (0|1e\+9); expected a finite number from 0\.01 to 60/);- bad(system({ lifetime: 1e9 }), /lifetime: got .*expected a finite number/);-- bad(system({ lifetime: [2, 1] }), /minimum must not exceed/);-- bad(system({ lifetime: [1, 2, 3] }), /lifetime must be a number or/);++ bad(system({ count: '10' }), /\.count: got .*; expected a whole number from 1 to 2000/);++ bad(system({ seed: -1 }), /\.seed: got .*; expected a whole number from 0 to 4294967295/);++ bad(system({ seed: 2 ** 32 }), /\.seed: got .*; expected a whole number from 0 to 4294967295/);++ bad(system({ seed: 1.5 }), /\.seed: got .*; expected a whole number from 0 to 4294967295/);++ bad(system({ lifetime: 0 }), /\.lifetime: got .*; expected a number from 0\.01 to 60/);++ bad(system({ lifetime: 1e9 }), /\.lifetime: got .*; expected a number from 0\.01 to 60/);++ bad(system({ lifetime: [2, 1] }), /\.(lifetime|length): got \[.*; expected \[minimum, maximum\] with the minimum not above the maximum/);++ bad(system({ lifetime: [1, 2, 3] }), /\.lifetime: got \[1,2,3\]; expected a number or \[minimum, maximum\]/);bad(system({ speed: NaN }), /finite|count|speed|direction|rate/);- bad(system({ speed: -1 }), /speed must be a finite number/);- bad(system({ size: 0 }), /size must be a finite number/);- bad(system({ size: 1e30 }), /size must be a finite number/);- bad(system({ rate: 0 }), /rate must be a finite number/);- bad(system({ speed: -1 }), /speed: got .*expected a finite number/);- bad(system({ size: 0 }), /size: got .*expected a finite number/);- bad(system({ size: 1e30 }), /size: got .*expected a finite number/);- bad(system({ rate: 0 }), /rate: got .*expected a finite number/);++ bad(system({ speed: -1 }), /\.speed: got -1; expected a number from 0 to 1000/);++ bad(system({ size: 0 }), /\.size: got .*; expected a number from 0\.0001 to 100/);++ bad(system({ size: 1e30 }), /\.size: got .*; expected a number from 0\.0001 to 100/);++ bad(system({ rate: 0 }), /\.rate: got 0; expected a number from 0\.01 to 200000/);bad(system({ rate: Infinity }), /finite|count|speed|direction|rate/);- bad(system({ spread: 181 }), /spread must be a finite number/);- bad(system({ drag: -1 }), /drag must be a finite number/);- bad(system({ drag: 1e9 }), /drag must be a finite number/);- bad(system({ floor: 1e9 }), /floor must be a finite number/);- bad(system({ spread: 181 }), /spread: got .*expected a finite number/);- bad(system({ drag: -1 }), /drag: got .*expected a finite number/);- bad(system({ drag: 1e9 }), /drag: got .*expected a finite number/);- bad(system({ floor: 1e9 }), /floor: got .*expected a finite number/);-- bad(system({ direction: [0, 0, 0] }), /zero vector/);- bad(system({ direction: [1, 2] }), /needs 3 numbers/);- bad(system({ direction: [1, 2] }), /expected three numbers/);++ bad(system({ spread: 181 }), /\.spread: got 181; expected a number from 0 to 180/);++ bad(system({ drag: -1 }), /\.drag: got .*; expected a number from 0 to 100/);++ bad(system({ drag: 1e9 }), /\.drag: got .*; expected a number from 0 to 100/);++ bad(system({ floor: 1e9 }), /\.floor: got 1000000000; expected a number from -10000 to 10000/);++ bad(system({ direction: [0, 0, 0] }), /\.direction: got \[0,0,0\]; expected a direction that is not the zero vector/);++ bad(system({ direction: [1, 2] }), /\.direction: got \[1,2\]; expected an array of 3 numbers/);bad(system({ direction: [1, 2, NaN] }), /finite|count|speed|direction|rate/);-- bad(system({ scale: 'huge' }), /scale must be one of/);-- bad(system({ emitter: { shape: 'cone' } }), /emitter shape must be one of/);- bad(system({ emitter: { radius: -1 } }), /radius must be a finite number/);- bad(system({ emitter: { position: [1e9, 0, 0] } }), /position must be a finite number/);- bad(system({ emitter: { jet: true } }), /Unknown or unsupported particle emitter field/);- bad(system({ colour: 'red' }), /Unknown or unsupported particle system field/);- bad({ systems: [{ node: 'sparks' }], extra: 1 }, /Unknown or unsupported particles field/);- bad(system({ emitter: { radius: -1 } }), /radius: got .*expected a finite number/);- bad(system({ emitter: { position: [1e9, 0, 0] } }), /position: got .*expected a finite number/);- bad(system({ emitter: { jet: true } }), /particle emitter\.\w+: got .*expected one of the fields/);- bad(system({ colour: 'red' }), /particle system\.\w+: got .*expected one of the fields/);- bad({ systems: [{ node: 'sparks' }], extra: 1 }, /particles\.\w+: got .*expected one of the fields/);-- bad({ systems: [] }, /at least one system/);- bad({ systems: 'many' }, /must be an array/);- bad({ systems: 'many' }, /expected an array/);-- bad({ systems: Array.from({ length: 5 }, () => ({ node: 'sparks' })) }, /at most 4/);- bad({ systems: [{ node: 'sparks' }, { node: 'sparks' }] }, /used twice in particles/);- bad({ gravity: [0, -1e9, 0], systems: [{ node: 'sparks' }] }, /gravity must be a finite number/);- bad({ wind: [1000, 0, 0], systems: [{ node: 'sparks' }] }, /wind must be a finite number/);- bad(system({ node: 'missing' }), /node was not found/);- bad(system({ node: '__proto__' }), /node was not found/);- bad({ systems: [{ node: 'sparks' }, { node: 'sparks' }] }, /expected a node used once in particles/);- bad({ gravity: [0, -1e9, 0], systems: [{ node: 'sparks' }] }, /gravity: got .*expected a finite number/);- bad({ wind: [1000, 0, 0], systems: [{ node: 'sparks' }] }, /wind: got .*expected a finite number/);- bad(system({ node: 'missing' }), /node: got .*expected the ID of a node in nodes/);- bad(system({ node: '__proto__' }), /node: got .*expected the ID of a node in nodes/);++ bad(system({ scale: 'huge' }), /\.scale: got "huge"; expected one of constant, shrink, grow/);++ bad(system({ emitter: { shape: 'cone' } }), /\.emitter\.shape: got "cone"; expected one of point, box, sphere, disc/);++ bad(system({ emitter: { radius: -1 } }), /\.emitter\.radius: got -1; expected a number from 0 to 10000/);++ bad(system({ emitter: { position: [1e9, 0, 0] } }), /\.emitter\.position\[0\]: got 1000000000; expected a number from -10000 to 10000/);++ bad(system({ emitter: { jet: true } }), /\.emitter\.jet: got true; expected no such field/);++ bad(system({ colour: 'red' }), /\.colour: got "red"; expected no such field/);++ bad({ systems: [{ node: 'sparks' }], extra: 1 }, /particles\.extra: got 1; expected no such field/);++ bad({ systems: [] }, /particles\.systems: got \[\]; expected at least one system/);++ bad({ systems: 'many' }, /particles\.systems: got "many"; expected an array of at most 4 entries/);++ bad({ systems: Array.from({ length: 5 }, () => ({ node: 'sparks' })) }, /particles\.systems: got "5 entries"; expected an array of at most 4 entries/);++ bad({ systems: [{ node: 'sparks' }, { node: 'sparks' }] }, /particles\.systems\[1\]\.node: got "sparks"; expected a node that particles uses once/);++ bad({ gravity: [0, -1e9, 0], systems: [{ node: 'sparks' }] }, /particles\.gravity\[1\]: got -1000000000; expected a number from -1000 to 1000/);++ bad({ wind: [1000, 0, 0], systems: [{ node: 'sparks' }] }, /particles\.wind\[0\]: got 1000; expected a number from -100 to 100/);++ bad(system({ node: 'missing' }), /\.node: got .*; expected the ID of a node in the recipe/);++ bad(system({ node: '__proto__' }), /\.node: got .*; expected the ID of a node in the recipe/);bad(null === 0 ? null : JSON.parse('{"systems":[{"node":"sparks","__proto__":{"count":5}}]}'), /Invalid JSON key|Unknown or unsupported/);- bad('systems', /must be a plain object/);- bad('systems', /expected an object/);++ bad('systems', /particles: got "systems"; expected a plain object/);});test('total particles and total vertices are bounded across systems', () => {const nodes = ['b', 'c', 'd'].map(id => ({ id, geometry: 'speck', material: 'glow' }));const systems = ['sparks', 'b', 'c'].map(node => ({ node, count: 1500 }));-- assert.throws(() => createAgentScene(sparkRecipe({ systems }, nodes)), /4000 in total/);++ assert.throws(() => createAgentScene(sparkRecipe({ systems }, nodes)), /particles\.systems: got "4500 particles in total"; expected counts that add up to at most 4000/);const heavy = sparkRecipe({ systems: [{ node: 'sparks', count: 10 }] });heavy.nodes[0].geometry = 'ball';heavy.particles.systems[0].count = 40;-- assert.throws(() => createAgentScene(heavy), /would draw \d+ vertices.*limit is 100000/);++ assert.throws(() => createAgentScene(heavy), /particles\.systems: got "\d+ vertices on node sparks"; expected shape vertices times count of at most 100000/);});test('a particle node cannot carry motion or physics, or be a cloth sheet', () => {const withMotion = sparkRecipe(burst);withMotion.motion = { duration: 1, loop: false, tracks: [{ id: 'sparks', kind: 'node', property: 'translation', keyframes: [{ time: 0, value: [0, 0, 0] }, { time: 1, value: [1, 0, 0] }] }] };-- assert.throws(() => createAgentScene(withMotion), /motion/);++ assert.throws(() => createAgentScene(withMotion), /particles\.systems\[0\]\.node: got "sparks"; expected a node that stays where it is/);const withCloth = sparkRecipe(burst);withCloth.cloth = { duration: 1, sheets: [{ node: 'sparks' }] };- assert.throws(() => createAgentScene(withCloth), /Particle system node: got "sparks"; expected a node used once in particles/);+ assert.throws(() => createAgentScene(withCloth), /used twice|cloth/i);const child = sparkRecipe(burst, [{ id: 'kid', geometry: 'speck', material: 'glow', parent: 'sparks' }]);child.particles.systems[0].node = 'kid';assert.throws(() => createAgentScene(child), /root node/);@@@ -245,7 -245,7 +245,7 @@@ test('a large burst seeks statelessly iassert.equal(bufferSizes.size, 1, 'the particle buffers keep one size across seeks');scene.sampleMotion(3600);assert.ok(particlePositions(scene).every(Number.isFinite));- assert.throws(() => scene.sampleMotion(3601), /Motion time/);- assert.throws(() => scene.sampleMotion(3601), /time: got 3601; expected null or a number of seconds from 0 to 3600/);++ assert.throws(() => scene.sampleMotion(3601), /time: got 3601; expected null or a number of seconds/);});test('the particle code stays unloaded for a scene without particles', async () => {@@@ -343,23 -343,23 +343,23 @@@ test('hair triangles face outward and ttest('hostile hair input is rejected', () => {const bad = (system, pattern) => assert.throws(() => createAgentScene(hairRecipe(system)), pattern);- bad({ surface: 'missing' }, /Hair surface node was not found/);- bad({ surface: 'missing' }, /Hair surface node: got "missing"; expected the ID of a node in nodes/);-- bad({ surface: 'fur' }, /different nodes/);-- bad({ segments: 9 }, /segments must be an integer from 1 to 8/);-- bad({ segments: 0 }, /segments must be an integer/);-- bad({ count: 2001 }, /count must be an integer/);- bad({ length: 0 }, /length must be a finite number/);- bad({ length: 0 }, /length: got .*expected a finite number/);-- bad({ length: [3, 1] }, /minimum must not exceed/);- bad({ width: 100 }, /width must be a finite number/);- bad({ droop: -1 }, /droop must be a finite number/);- bad({ sway: 11 }, /sway must be a finite number/);- bad({ width: 100 }, /width: got .*expected a finite number/);- bad({ droop: -1 }, /droop: got .*expected a finite number/);- bad({ sway: 11 }, /sway: got .*expected a finite number/);++ bad({ surface: 'missing' }, /particles\.systems\[0\]\.surface: got "missing"; expected the ID of a node in the recipe/);++ bad({ surface: 'fur' }, /\.surface: got "fur"; expected a node other than the hair node/);++ bad({ segments: 9 }, /\.segments: got 9; expected a whole number from 1 to 8/);++ bad({ segments: 0 }, /\.segments: got 0; expected a whole number from 1 to 8/);++ bad({ count: 2001 }, /\.count: got .*; expected a whole number from 1 to 2000/);++ bad({ length: 0 }, /\.length: got 0; expected a number from 0\.001 to 100/);++ bad({ length: [3, 1] }, /\.(lifetime|length): got \[.*; expected \[minimum, maximum\] with the minimum not above the maximum/);++ bad({ width: 100 }, /\.width: got 100; expected a number from 0\.0001 to 10/);++ bad({ droop: -1 }, /\.droop: got -1; expected a number from 0 to 10/);++ bad({ sway: 11 }, /\.sway: got 11; expected a number from 0 to 10/);});test('hair limits the vertices it draws, and an empty surface is refused', () => {const crowded = hairRecipe({ count: 2000, segments: 8 });crowded.particles.systems.push({ type: 'hair', node: 'extra', surface: 'head', count: 2000, segments: 8 });crowded.nodes.push({ id: 'extra', geometry: 'strands', material: 'fur' });-- assert.throws(() => createAgentScene(crowded), /vertices.*limit is 100000/);++ assert.throws(() => createAgentScene(crowded), /particles\.systems: got "\d+ vertices on node extra"; expected shape vertices times count of at most 100000/);const flat = hairRecipe({});flat.nodes[0].scale = [0, 0, 0];assert.throws(() => createAgentScene(flat), /no triangle with area|scale/);