Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
JavaScript 3d3d-assets3d-modelingagent-skillsagent-toolsai-agentsasset-pipelinecligame-assetsglbgltfmcpmcp-servermodel-context-protocolprocedural-generationprocedural-modelingtext-to-3dthreejstypescript
fix(evaluator): name procedural texture usage errors and add kiln validate (#215) (#229)
Matthew Kissingerf23adb7121d4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e47d5389..e4b1c2d2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -61,6 +61,14 @@ does not publish a package.`schemaVersion:2` record; `createMaterialPresetDraftAny` returns any preset's draft, andpreset summaries report `recordSchemaVersion`. The docs list the presets as a table that atest keeps in step with the catalog (#210).+- Name procedural texture usage errors and add `kiln validate` ([#215](https://github.com/instruktlabs/kiln/issues/215)).+ An unknown `proceduralTexture` usage (such as `data`) or a usage that does not match its+ portable material slot, in V2 or V3, now crosses the evaluator boundary as the closed+ `PROCEDURAL_TEXTURE_USAGE` diagnostic; its advice lists the seven usages and the slots+ that take them, instead of the bare rejection sentence. Discovery's `proceduralTexture`+ contract lists them too. The new `kiln validate <program.js|ref> [--json]` serves the same+ `kiln_validate` check from the CLI, prints the `programRef` and exits 1 when the source is+ invalid; the generic rejection advice names both forms.## 1.3.1 (2026-10-17)diff --git a/dist/agent-run.mjs b/dist/agent-run.mjsindex cc482e9d..981821b3 100644--- a/dist/agent-run.mjs+++ b/dist/agent-run.mjs@@ -3316,6 +3316,8 @@ function authoringDiagnosticAdvice(diagnostic) {return GEAR_RADII_ORDER_ADVICE;if (diagnostic === "PROCEDURAL_TEXTURE_UNKNOWN_KEY")return PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE;+ if (diagnostic === "PROCEDURAL_TEXTURE_USAGE")+ return PROCEDURAL_TEXTURE_USAGE_ADVICE;if (diagnostic === "MATERIAL_FRACTION_RANGE")return MATERIAL_FRACTION_RANGE_ADVICE;if (diagnostic === "PROFILE_HOLES_UNSUPPORTED")@@ -3330,7 +3332,7 @@ function rethrowAuthoringError(error) {}throw error;}-var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;+var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', PROCEDURAL_TEXTURE_USAGE_ADVICE = 'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;var init_authoring_diagnostic = __esm(() => {AuthoringDiagnosticError = class AuthoringDiagnosticError extends Error {diagnostic;@@ -3438,7 +3440,7 @@ function usage(value, path, fallback) {if (value === undefined)return fallback;if (!TEXTURE_USAGES.includes(value)) {- throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`);+ throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`, "PROCEDURAL_TEXTURE_USAGE");}return value;}@@ -3646,7 +3648,7 @@ function canonicalTextureRef(value, slot) {const spec = canonicalizeProceduralTextureSpecV2(record["spec"]);const expected = MATERIAL_TEXTURE_USAGE[slot];if (spec.usage !== expected) {- throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`);+ throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`, "PROCEDURAL_TEXTURE_USAGE");}return { kind: "procedural", spec };}@@ -3819,8 +3821,8 @@ var init_procedural_material_v2 = __esm(() => {});// src/procedural-texture-v3-contract.ts-function fail(message) {- throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, "PROCEDURAL_TEXTURE_V3_CONTRACT");+function fail(message, diagnostic = "PROCEDURAL_TEXTURE_V3_CONTRACT") {+ throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, diagnostic);}function assertProceduralJsonV3(input) {let nodes = 0;@@ -3973,7 +3975,7 @@ function admitProceduralTextureSpecV3(input) {fail("output texel budget exceeded.");const usage = r["usage"] === undefined ? "albedo" : r["usage"];if (!TEXTURE_USAGES.includes(usage))- fail("usage must be a known texture usage.");+ fail("usage must be a known texture usage.", "PROCEDURAL_TEXTURE_USAGE");const colorUsage = usage === "albedo" || usage === "emissive";const name = r["name"];if (name !== undefined && (typeof name !== "string" || !name.length || name.length > 80 || [...name].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)))@@ -11645,7 +11647,7 @@ function admitMaterial(input) {fail2("procedural references cannot carry a resource ID.");const admitted = admitProceduralTextureSpecV3(ref["spec"]);if (admitted.spec.usage !== PORTABLE_MATERIAL_SLOT_USAGE[slot])- fail2(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`);+ throw new PortableMaterialV3Error(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`, "PROCEDURAL_TEXTURE_USAGE");texels += admitted.spec.width * admitted.spec.height;work += admitted.estimatedWorkUnits;bytes += admitted.conservativePixelAllocationBytes;@@ -11702,8 +11704,8 @@ var init_procedural_material_v3 = __esm(() => {occlusion: "occlusion"};PortableMaterialV3Error = class PortableMaterialV3Error extends ProceduralTextureError {- constructor(message) {- super(`portableMaterial V3: ${message}`, "PORTABLE_MATERIAL_V3_CONTRACT");+ constructor(message, diagnostic = "PORTABLE_MATERIAL_V3_CONTRACT") {+ super(`portableMaterial V3: ${message}`, diagnostic);this.name = "PortableMaterialV3Error";}};@@ -42694,6 +42696,7 @@ define2("proceduralTexture", {...textureFacts,ownership: "Creates a new DataTexture with generated bytes and portable metadata.",parameters: [+ "usage is albedo (default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match the slot: portable baseColor takes albedo and occlusion takes occlusion; normal, metallicRoughness and emissive take their own name; pbrMaterial albedo, roughness, metalness and aoMap take albedo, roughness, metalness and occlusion.","V1/V2 preserve opaque patterns: size power-of-two 4..1024 and at most 8 layers. Explicit schemaVersion 3 uses width/height integers 4..1024, byte RGBA, at most 64 ordered operations and 64 polygon vertices.","V3 paint/mask use integer pixel-edge shapes with binary center coverage and fixed integer source-over rounding. A mask clears outside its shape; invert keeps outside. Zero-alpha pixels are transparent black.","V3 color-only palette colors are 1..32 RGB integers, optional fixed Bayer4 dither. Stamps (any usage) use bounded Xorshift32 seed/area placement; periodic wrapping is explicit and at most 256 expanded copies. Legacy-v2 layers delegate unchanged square V2 patterns with matching usage.",diff --git a/dist/build.json b/dist/build.jsonindex 6d3af712..d338f6c1 100644--- a/dist/build.json+++ b/dist/build.json@@ -2,10 +2,10 @@"schemaVersion": 1,"entries": {"worker": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -37,13 +37,13 @@},"target": "node","file": "evaluator-worker.mjs",- "bundleHash": "sha256:520d921c096ae6886598aea30c98378cba2dd2ccf01984c0d4623bc16a661adb"+ "bundleHash": "sha256:21ee8409de7902ed7c93f4e9f30ecd774c82811a7a456f1ff5a995fef2c265b2"},"agent-run": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -75,13 +75,13 @@},"target": "node","file": "agent-run.mjs",- "bundleHash": "sha256:33e567d79b6818228b247d767db3fecb3918b15986d6fcd346be7f23929130cc"+ "bundleHash": "sha256:a21ac1b7169718520bfd9f7cf9b0ea2001cdd14d69167166da2fca09c0a59c3d"},"agent-providers": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -116,10 +116,10 @@"bundleHash": "sha256:9d6faf03d307321bc2e3bd5ce5bdee0bbbf61e0ebed8bfebfa1fb072287b83fa"},"mcp": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -154,10 +154,10 @@"bundleHash": "sha256:a246b2c79d629a332cef4430dbe742b0c4a0d2f04f0281e673c3c60ff22706da"},"cli": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -189,13 +189,13 @@},"target": "node","file": "cli.mjs",- "bundleHash": "sha256:32b7c89ba7f18992d04f438b02a3091e0caeedfd68959a0ab1a6e439a58cf7a5"+ "bundleHash": "sha256:110504876178fa48e5f88a1b7b477de457c8a11140fd9fcc0a17283435e4dff1"},"engine": {- "identity": "sha256:4de3ab1a7f91fd2fa7f6da968cc033148dd1f92928ee3fb35f81d4bbe093019b",+ "identity": "sha256:975ae61072c000ce3395c036d57f3c6f41d1ded3fed4ce91249a17769f9354e4","engineVersion": "1.3.1","toolchain": "[email protected]",- "sourceHash": "3345bf309f0d9c99601553cc1b322c39af698f45122c98a04344740f98729229",+ "sourceHash": "50cbb3fa726a380b6da9ba91b4afb78b10f8a84ee6bcd90250591cbaac0b0958","rendererSourceHash": "27927c48b377f7694251a76c0cecd05216fcbbb8a7d03e8bf2bd681dabb5573a","dependencyHash": "20b5b45a138ab83d340e78729d1a427bdc9b8aeadc47c5f7acf907eab43377f3","dependencies": {@@ -227,7 +227,7 @@},"target": "node","file": "mcp-engine.mjs",- "bundleHash": "sha256:accf4fbac8de3b66f279ab590024f4bbe9a267b95fc427228e9fd3b239a78b33"+ "bundleHash": "sha256:fefb37ae96bde71ed5b9b273de4c03ec2c6bed46ec5ba1db445e79acb797ba92"}}}diff --git a/dist/cli.mjs b/dist/cli.mjsindex d8106586..8870e015 100644--- a/dist/cli.mjs+++ b/dist/cli.mjs@@ -194,6 +194,8 @@ function authoringDiagnosticAdvice(diagnostic) {return GEAR_RADII_ORDER_ADVICE;if (diagnostic === "PROCEDURAL_TEXTURE_UNKNOWN_KEY")return PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE;+ if (diagnostic === "PROCEDURAL_TEXTURE_USAGE")+ return PROCEDURAL_TEXTURE_USAGE_ADVICE;if (diagnostic === "MATERIAL_FRACTION_RANGE")return MATERIAL_FRACTION_RANGE_ADVICE;if (diagnostic === "PROFILE_HOLES_UNSUPPORTED")@@ -208,7 +210,7 @@ function rethrowAuthoringError(error) {}throw error;}-var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;+var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', PROCEDURAL_TEXTURE_USAGE_ADVICE = 'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;var init_authoring_diagnostic = __esm(() => {AuthoringDiagnosticError = class AuthoringDiagnosticError extends Error {diagnostic;@@ -773,7 +775,7 @@ function usage(value, path, fallback) {if (value === undefined)return fallback;if (!TEXTURE_USAGES.includes(value)) {- throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`);+ throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`, "PROCEDURAL_TEXTURE_USAGE");}return value;}@@ -981,7 +983,7 @@ function canonicalTextureRef(value, slot) {const spec = canonicalizeProceduralTextureSpecV2(record["spec"]);const expected = MATERIAL_TEXTURE_USAGE[slot];if (spec.usage !== expected) {- throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`);+ throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`, "PROCEDURAL_TEXTURE_USAGE");}return { kind: "procedural", spec };}@@ -1200,8 +1202,8 @@ var init_portable_sampler = __esm(() => {});// src/procedural-texture-v3-contract.ts-function fail(message) {- throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, "PROCEDURAL_TEXTURE_V3_CONTRACT");+function fail(message, diagnostic = "PROCEDURAL_TEXTURE_V3_CONTRACT") {+ throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, diagnostic);}function assertProceduralJsonV3(input) {let nodes = 0;@@ -1354,7 +1356,7 @@ function admitProceduralTextureSpecV3(input) {fail("output texel budget exceeded.");const usage = r["usage"] === undefined ? "albedo" : r["usage"];if (!TEXTURE_USAGES.includes(usage))- fail("usage must be a known texture usage.");+ fail("usage must be a known texture usage.", "PROCEDURAL_TEXTURE_USAGE");const colorUsage = usage === "albedo" || usage === "emissive";const name = r["name"];if (name !== undefined && (typeof name !== "string" || !name.length || name.length > 80 || [...name].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)))@@ -18685,7 +18687,7 @@ function admitMaterial(input) {fail6("procedural references cannot carry a resource ID.");const admitted = admitProceduralTextureSpecV3(ref["spec"]);if (admitted.spec.usage !== PORTABLE_MATERIAL_SLOT_USAGE[slot])- fail6(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`);+ throw new PortableMaterialV3Error(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`, "PROCEDURAL_TEXTURE_USAGE");texels += admitted.spec.width * admitted.spec.height;work += admitted.estimatedWorkUnits;bytes += admitted.conservativePixelAllocationBytes;@@ -18742,8 +18744,8 @@ var init_procedural_material_v3 = __esm(() => {occlusion: "occlusion"};PortableMaterialV3Error = class PortableMaterialV3Error extends ProceduralTextureError {- constructor(message) {- super(`portableMaterial V3: ${message}`, "PORTABLE_MATERIAL_V3_CONTRACT");+ constructor(message, diagnostic = "PORTABLE_MATERIAL_V3_CONTRACT") {+ super(`portableMaterial V3: ${message}`, diagnostic);this.name = "PortableMaterialV3Error";}};@@ -38829,7 +38831,7 @@ function decodeEvaluatorResultV2(json, maxGlbBytes, expectedRequestId) {if (!codes.includes(value.error.code) || typeof value.error.message !== "string" || value.error.message !== evaluatorOutcomeMessage(value.error.code)) {return fail9("result");}- if (value.error.diagnostic !== undefined && (value.error.code !== "EXECUTION_REJECTED" || value.error.diagnostic !== "UNBOUND_VARIABLE" && value.error.diagnostic !== "GEAR_RADII_ORDER" && value.error.diagnostic !== "ROUNDED_BOX_RADIUS" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_UNKNOWN_KEY" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_BLEND" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_V3_CONTRACT" && value.error.diagnostic !== "PORTABLE_MATERIAL_V3_CONTRACT" && value.error.diagnostic !== "TEXTURE_ATLAS_CONTRACT" && value.error.diagnostic !== "MATERIAL_FRACTION_RANGE" && value.error.diagnostic !== "MATERIAL_RECIPE_TEXTURE_BINDING" && value.error.diagnostic !== "PORTABLE_TEXTURE_REFERENCE" && value.error.diagnostic !== "PORTABLE_COLOR_ARGUMENT" && value.error.diagnostic !== "PARAMETRIC_PERIODIC_ENDPOINT" && value.error.diagnostic !== "PROFILE_HOLES_UNSUPPORTED" && value.error.diagnostic !== "PROFILE_BEVEL_COLLAPSE" && value.error.diagnostic !== "PROFILE_CORRESPONDENCE_COLLAPSE" && value.error.diagnostic !== "REMOVED_HELPER" && value.error.diagnostic !== "TUBE_RADIUS" && value.error.diagnostic !== "TAPER_CONE_AXIS" && value.error.diagnostic !== "SOLID_FLOAT32_COLLAPSE" && value.error.diagnostic !== "MESH_DATA_NONFINITE" && value.error.diagnostic !== "MATERIAL_ALPHA_MODE" && value.error.diagnostic !== "MATERIAL_COLOR_ARGUMENT" && value.error.diagnostic !== "PART_NAME_ARGUMENT" && value.error.diagnostic !== "PART_GEOMETRY_ARGUMENT" && value.error.diagnostic !== "PART_MATERIAL_ARGUMENT" && value.error.diagnostic !== "MATERIAL_PACKED_CHANNELS" && value.error.diagnostic !== "UNINITIALIZED_BINDING" && value.error.diagnostic !== "BUILD_RESULT" && value.error.diagnostic !== "MATERIAL_RECIPE_OVERRIDE" && value.error.diagnostic !== "PROGRAM_TYPE_ERROR" && value.error.diagnostic !== "PROGRAM_RANGE_ERROR" && value.error.diagnostic !== "LOD_SET" && value.error.diagnostic !== "OPEN_SHELL" && value.error.diagnostic !== "DELIVERY_CONTRACT" && value.error.diagnostic !== "REQUIRE_SOLID" && value.error.diagnostic !== "EXPORT_MATERIAL_SIDE_UNSUPPORTED" && value.error.diagnostic !== "BONE_CHAIN_ARGUMENT" && value.error.diagnostic !== "SKIN_BINDING_ARGUMENT"))+ if (value.error.diagnostic !== undefined && (value.error.code !== "EXECUTION_REJECTED" || value.error.diagnostic !== "UNBOUND_VARIABLE" && value.error.diagnostic !== "GEAR_RADII_ORDER" && value.error.diagnostic !== "ROUNDED_BOX_RADIUS" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_UNKNOWN_KEY" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_BLEND" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_USAGE" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_V3_CONTRACT" && value.error.diagnostic !== "PORTABLE_MATERIAL_V3_CONTRACT" && value.error.diagnostic !== "TEXTURE_ATLAS_CONTRACT" && value.error.diagnostic !== "MATERIAL_FRACTION_RANGE" && value.error.diagnostic !== "MATERIAL_RECIPE_TEXTURE_BINDING" && value.error.diagnostic !== "PORTABLE_TEXTURE_REFERENCE" && value.error.diagnostic !== "PORTABLE_COLOR_ARGUMENT" && value.error.diagnostic !== "PARAMETRIC_PERIODIC_ENDPOINT" && value.error.diagnostic !== "PROFILE_HOLES_UNSUPPORTED" && value.error.diagnostic !== "PROFILE_BEVEL_COLLAPSE" && value.error.diagnostic !== "PROFILE_CORRESPONDENCE_COLLAPSE" && value.error.diagnostic !== "REMOVED_HELPER" && value.error.diagnostic !== "TUBE_RADIUS" && value.error.diagnostic !== "TAPER_CONE_AXIS" && value.error.diagnostic !== "SOLID_FLOAT32_COLLAPSE" && value.error.diagnostic !== "MESH_DATA_NONFINITE" && value.error.diagnostic !== "MATERIAL_ALPHA_MODE" && value.error.diagnostic !== "MATERIAL_COLOR_ARGUMENT" && value.error.diagnostic !== "PART_NAME_ARGUMENT" && value.error.diagnostic !== "PART_GEOMETRY_ARGUMENT" && value.error.diagnostic !== "PART_MATERIAL_ARGUMENT" && value.error.diagnostic !== "MATERIAL_PACKED_CHANNELS" && value.error.diagnostic !== "UNINITIALIZED_BINDING" && value.error.diagnostic !== "BUILD_RESULT" && value.error.diagnostic !== "MATERIAL_RECIPE_OVERRIDE" && value.error.diagnostic !== "PROGRAM_TYPE_ERROR" && value.error.diagnostic !== "PROGRAM_RANGE_ERROR" && value.error.diagnostic !== "LOD_SET" && value.error.diagnostic !== "OPEN_SHELL" && value.error.diagnostic !== "DELIVERY_CONTRACT" && value.error.diagnostic !== "REQUIRE_SOLID" && value.error.diagnostic !== "EXPORT_MATERIAL_SIDE_UNSUPPORTED" && value.error.diagnostic !== "BONE_CHAIN_ARGUMENT" && value.error.diagnostic !== "SKIN_BINDING_ARGUMENT"))return fail9("result");if (value.error.solid !== undefined && (value.error.diagnostic !== "REQUIRE_SOLID" || !validSolidFailureDetails(value.error.solid)))return fail9("result");@@ -46023,6 +46025,7 @@ var init_helper_contracts = __esm(() => {...textureFacts,ownership: "Creates a new DataTexture with generated bytes and portable metadata.",parameters: [+ "usage is albedo (default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match the slot: portable baseColor takes albedo and occlusion takes occlusion; normal, metallicRoughness and emissive take their own name; pbrMaterial albedo, roughness, metalness and aoMap take albedo, roughness, metalness and occlusion.","V1/V2 preserve opaque patterns: size power-of-two 4..1024 and at most 8 layers. Explicit schemaVersion 3 uses width/height integers 4..1024, byte RGBA, at most 64 ordered operations and 64 polygon vertices.","V3 paint/mask use integer pixel-edge shapes with binary center coverage and fixed integer source-over rounding. A mask clears outside its shape; invert keeps outside. Zero-alpha pixels are transparent black.","V3 color-only palette colors are 1..32 RGB integers, optional fixed Bayer4 dither. Stamps (any usage) use bounded Xorshift32 seed/area placement; periodic wrapping is explicit and at most 256 expanded copies. Legacy-v2 layers delegate unchanged square V2 patterns with matching usage.",@@ -55928,6 +55931,7 @@ var USAGE3 = `kiln — vision-in-the-loop 3D asset generationUSAGEkiln render <program.js|ref> [options] execute a Kiln program (offline, no key)+ kiln validate <program.js|ref> [--json] kiln_validate: syntax and sandbox check, no buildkiln generate "<prompt>" [options] author a program with a model, then renderkiln source <file.js> save a source snapshot and print its programRefkiln source <programRef> --out file.js export a revision without model transcription@@ -56133,7 +56137,7 @@ function applyBackdrop(args) {return { ...recipe, backdrop: args.backdrop };}function jsonCommand(command) {- return command === "render" || command === "source";+ return command === "render" || command === "source" || command === "validate";}function jsonRenderFailure(error, receipt = { files: [] }) {console.log(JSON.stringify({@@ -56316,6 +56320,43 @@ async function cmdRender(args) {} catch {}}}+async function cmdValidate(args) {+ const input = args.positional[0];+ if (!input || args.positional.length !== 1) {+ const message = "validate requires a program path or reference";+ if (args.json)+ jsonRenderFailure(message);+ else+ console.error(`${message}++${USAGE3}`);+ return 2;+ }+ const store = localProgramStore();+ const isRef = input.startsWith("sha256:") || programRefPattern.test(input);+ const def = createKilnProgramToolRegistry({ programStore: store }).find((d) => d.name === "kiln_validate");+ if (!def)+ throw new Error("kiln_validate is missing from the MCP tool surface");+ const result = await def.run(isRef ? { programRef: input } : { code: await readFile13(resolvePath(input), "utf8") });+ if (args.json)+ console.log(JSON.stringify(result));+ else {+ console.log(`${result.valid ? "valid" : "invalid"} ${result.programRef ?? input}`);+ const described = new Set;+ for (const issue of result.issues) {+ described.add(issue.message);+ const where = issue.line === undefined ? "" : ` (line ${issue.line})`;+ const hint = issue.fixHint ? ` ${issue.fixHint}` : "";+ console.log(` error: ${issue.code}${where}: ${issue.message}${hint}`);+ }+ for (const error of result.errors)+ if (!described.has(error))+ console.log(` error: ${error}`);+ for (const warning of result.warnings)+ console.log(` warning: ${warning}`);+ }+ return result.valid ? 0 : 1;+}async function cmdGenerate(args) {assertNodeRuntime("agent");const prompt = args.positional.join(" ").trim();@@ -56535,6 +56576,8 @@ async function runMain(argv) {return await cmdSource(args);case "render":return await cmdRender(args);+ case "validate":+ return await cmdValidate(args);case "generate":return await cmdGenerate(args);default:diff --git a/dist/evaluator-worker.mjs b/dist/evaluator-worker.mjsindex 739a3ce5..de19a330 100644--- a/dist/evaluator-worker.mjs+++ b/dist/evaluator-worker.mjs@@ -96,6 +96,8 @@ function authoringDiagnosticAdvice(diagnostic) {return GEAR_RADII_ORDER_ADVICE;if (diagnostic === "PROCEDURAL_TEXTURE_UNKNOWN_KEY")return PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE;+ if (diagnostic === "PROCEDURAL_TEXTURE_USAGE")+ return PROCEDURAL_TEXTURE_USAGE_ADVICE;if (diagnostic === "MATERIAL_FRACTION_RANGE")return MATERIAL_FRACTION_RANGE_ADVICE;if (diagnostic === "PROFILE_HOLES_UNSUPPORTED")@@ -121,7 +123,7 @@ function rethrowAuthoringError(error) {}throw error;}-var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;+var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', PROCEDURAL_TEXTURE_USAGE_ADVICE = 'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;var init_authoring_diagnostic = __esm(() => {AuthoringDiagnosticError = class AuthoringDiagnosticError extends Error {diagnostic;@@ -3619,7 +3621,7 @@ function usage(value, path, fallback) {if (value === undefined)return fallback;if (!TEXTURE_USAGES.includes(value)) {- throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`);+ throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`, "PROCEDURAL_TEXTURE_USAGE");}return value;}@@ -3827,7 +3829,7 @@ function canonicalTextureRef(value, slot) {const spec = canonicalizeProceduralTextureSpecV2(record["spec"]);const expected = MATERIAL_TEXTURE_USAGE[slot];if (spec.usage !== expected) {- throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`);+ throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`, "PROCEDURAL_TEXTURE_USAGE");}return { kind: "procedural", spec };}@@ -4046,8 +4048,8 @@ var init_portable_sampler = __esm(() => {});// src/procedural-texture-v3-contract.ts-function fail(message) {- throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, "PROCEDURAL_TEXTURE_V3_CONTRACT");+function fail(message, diagnostic = "PROCEDURAL_TEXTURE_V3_CONTRACT") {+ throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, diagnostic);}function assertProceduralJsonV3(input) {let nodes = 0;@@ -4200,7 +4202,7 @@ function admitProceduralTextureSpecV3(input) {fail("output texel budget exceeded.");const usage = r["usage"] === undefined ? "albedo" : r["usage"];if (!TEXTURE_USAGES.includes(usage))- fail("usage must be a known texture usage.");+ fail("usage must be a known texture usage.", "PROCEDURAL_TEXTURE_USAGE");const colorUsage = usage === "albedo" || usage === "emissive";const name = r["name"];if (name !== undefined && (typeof name !== "string" || !name.length || name.length > 80 || [...name].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)))@@ -23784,7 +23786,7 @@ function admitMaterial(input) {fail8("procedural references cannot carry a resource ID.");const admitted = admitProceduralTextureSpecV3(ref["spec"]);if (admitted.spec.usage !== PORTABLE_MATERIAL_SLOT_USAGE[slot])- fail8(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`);+ throw new PortableMaterialV3Error(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`, "PROCEDURAL_TEXTURE_USAGE");texels += admitted.spec.width * admitted.spec.height;work += admitted.estimatedWorkUnits;bytes += admitted.conservativePixelAllocationBytes;@@ -23841,8 +23843,8 @@ var init_procedural_material_v3 = __esm(() => {occlusion: "occlusion"};PortableMaterialV3Error = class PortableMaterialV3Error extends ProceduralTextureError {- constructor(message) {- super(`portableMaterial V3: ${message}`, "PORTABLE_MATERIAL_V3_CONTRACT");+ constructor(message, diagnostic = "PORTABLE_MATERIAL_V3_CONTRACT") {+ super(`portableMaterial V3: ${message}`, diagnostic);this.name = "PortableMaterialV3Error";}};diff --git a/dist/mcp-engine.mjs b/dist/mcp-engine.mjsindex 195f79dd..863abb6a 100644--- a/dist/mcp-engine.mjs+++ b/dist/mcp-engine.mjs@@ -137,6 +137,8 @@ function authoringDiagnosticAdvice(diagnostic) {return GEAR_RADII_ORDER_ADVICE;if (diagnostic === "PROCEDURAL_TEXTURE_UNKNOWN_KEY")return PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE;+ if (diagnostic === "PROCEDURAL_TEXTURE_USAGE")+ return PROCEDURAL_TEXTURE_USAGE_ADVICE;if (diagnostic === "MATERIAL_FRACTION_RANGE")return MATERIAL_FRACTION_RANGE_ADVICE;if (diagnostic === "PROFILE_HOLES_UNSUPPORTED")@@ -151,7 +153,7 @@ function rethrowAuthoringError(error) {}throw error;}-var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;+var UNBOUND_VARIABLE_ADVICE = "Check variable spelling and scope: generated code used an undeclared variable. Read the current source and check declarations before retrying. If it was meant to be a Kiln helper, call kiln_discover to confirm the exact name and signature; the sandbox exposes only those globals.", GEAR_RADII_ORDER_ADVICE = "gearGeo requires boreRadius < rootRadius < tipRadius; specify rootRadius when changing tipRadius. Omitted radii keep their absolute defaults.", ROUNDED_BOX_RADIUS_ADVICE = "roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.", PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE = 'Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.', PROCEDURAL_TEXTURE_USAGE_ADVICE = 'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].', MATERIAL_FRACTION_RANGE_ADVICE = "Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.", PARAMETRIC_PERIODIC_ENDPOINT_ADVICE = "Periodic parametricSurface endpoints must return matching positions. For periodicU, sample(uMin, v) and sample(uMax, v) must match; for periodicV, sample(u, vMin) and sample(u, vMax) must match.", PROFILE_HOLES_UNSUPPORTED_ADVICE = "loftProfiles and sweepProfile: holes are unsupported in options or sections. Use extrudeProfile for a holed cross-section with optional twist/taper; independently varying contours need explicit geometry or solid subtraction. cap:false does not create inner walls or thickness.", PROFILE_CORRESPONDENCE_COLLAPSE_ADVICE = "loftProfiles or sweepProfile: corresponding profile edges collapse between stations. Check matching start vertices and vertex order; for an intended twist, add intermediate sections or path stations. No automatic correspondence repair is applied. Other self-intersections remain unchecked.", UNINITIALIZED_BINDING_ADVICE = "A const, let or class binding was read before its declaration ran (temporal dead zone). Move the declaration above the first code that reads it; top-level constants must be declared before other top-level code uses them. kiln_validate names the binding and line when the read runs immediately.", BUILD_RESULT_ADVICE = 'Define a top-level function build() (it may be async) that returns the root Object3D, for example const root = createRoot("Name"); ...; return root;. A build() that returns nothing, or returns a geometry or material, is rejected.', MATERIAL_RECIPE_OVERRIDE_ADVICE = 'materialRecipe takes a listed kiln.material.*.v1 ID and only the overrides that recipe allows; the allowed overrides differ by recipe (the emissive recipe has no metalness). Call kiln_discover with ids ["materialRecipe"] to see what each recipe allows; kiln_validate names the recipe and key when both are literals.', PROGRAM_TYPE_ERROR_ADVICE = "The program or a helper it called threw a TypeError: a value had the wrong type. Usually something is undefined (a function without a return, an un-awaited async helper such as roundedBoxGeo, extrudeProfile or materialRecipe, or a misspelt property) or a non-function was called. Run kiln_validate, then check the helper contract with kiln_discover.", PROGRAM_RANGE_ERROR_ADVICE = "The program or a helper it called threw a RangeError: a number was outside its allowed range, for example a non-positive size, an invalid array length or segment count, or unbounded recursion. Check the helper arguments against kiln_discover.", LOD_SET_ADVICE = 'Levels of detail: sibling nodes whose names share a stem and carry LOD0, LOD1, ... tokens (Body_LOD0, Body_LOD1) form one set. A set needs LOD0 and consecutive levels under one parent, outside any other tier, and one defineLod([lod0, lod1, ...], { screenCoverage: [...] }) call listing its tiers in level order with one value per level, each from 0 to 1 and strictly decreasing; the last may be 0, which never culls. Build one tier without LOD tokens unless the brief asks for levels. Call kiln_discover with ids ["defineLod"].', OPEN_SHELL_ADVICE = 'markOpenShell(part, reason) marks a part as intentionally open: part is the mesh createPart returned or a group whose meshes it covers, and reason is a non-empty string of at most 200 characters saying why, for example markOpenShell(rail, "C-channel closed by the end plates"). The engine owns the kilnOpenShell userData key; set it only through markOpenShell. Call kiln_discover with ids ["markOpenShell"].', DELIVERY_CONTRACT_ADVICE = 'Delivery helpers: colliderBox(size, { id }), colliderCapsule(radius, height, { id }) with height the total height of at least 2 * radius, colliderHull(mesh, { id }), anchor(kind, id), port(id) and defineModule(root, { footprint: [w, d], height, snapAxis: "x"|"y"|"z", origin: "corner"|"center" }). Ids and kinds are one segment of letters, digits, "_" or "-" with no dots; sizes are positive metres. The engine owns the kilnKit userData key; set it only through defineModule. defineBudget({ triangles: n | { LOD0, LOD1, ... }, draws? }) takes positive integers; definePalette(colors, { threshold? }) takes 1..64 hex colours. Call kiln_discover with ids ["colliderBox", "anchor", "defineModule", "defineBudget"].', REQUIRE_SOLID_ADVICE = 'REQUIRE_SOLID: a part marked with requireSolid(part) is not a closed, manifold, outward solid. Close every boundary (caps, end plates, a hull or a solid helper such as boxGeo or extrudeProfile), remove faces shared by three or more triangles, and keep one consistent outward winding; do not flip normals alone. Check the part with geometryDiagnostics(geometry).solid, or remove the requireSolid mark if the part is open on purpose. Call kiln_discover with ids ["requireSolid", "geometryDiagnostics"].', EXECUTION_REJECTED_ADVICE = "No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.", AuthoringDiagnosticError;var init_authoring_diagnostic = __esm(() => {AuthoringDiagnosticError = class AuthoringDiagnosticError extends Error {diagnostic;@@ -259,7 +261,7 @@ function usage(value, path, fallback) {if (value === undefined)return fallback;if (!TEXTURE_USAGES.includes(value)) {- throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`);+ throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(", ")}, got ${JSON.stringify(value)}.`, "PROCEDURAL_TEXTURE_USAGE");}return value;}@@ -467,7 +469,7 @@ function canonicalTextureRef(value, slot) {const spec = canonicalizeProceduralTextureSpecV2(record["spec"]);const expected = MATERIAL_TEXTURE_USAGE[slot];if (spec.usage !== expected) {- throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`);+ throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`, "PROCEDURAL_TEXTURE_USAGE");}return { kind: "procedural", spec };}@@ -640,8 +642,8 @@ var init_procedural_material_v2 = __esm(() => {});// src/procedural-texture-v3-contract.ts-function fail(message) {- throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, "PROCEDURAL_TEXTURE_V3_CONTRACT");+function fail(message, diagnostic = "PROCEDURAL_TEXTURE_V3_CONTRACT") {+ throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, diagnostic);}function assertProceduralJsonV3(input) {let nodes = 0;@@ -794,7 +796,7 @@ function admitProceduralTextureSpecV3(input) {fail("output texel budget exceeded.");const usage = r["usage"] === undefined ? "albedo" : r["usage"];if (!TEXTURE_USAGES.includes(usage))- fail("usage must be a known texture usage.");+ fail("usage must be a known texture usage.", "PROCEDURAL_TEXTURE_USAGE");const colorUsage = usage === "albedo" || usage === "emissive";const name = r["name"];if (name !== undefined && (typeof name !== "string" || !name.length || name.length > 80 || [...name].some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)))@@ -5731,7 +5733,7 @@ function admitMaterial(input) {fail2("procedural references cannot carry a resource ID.");const admitted = admitProceduralTextureSpecV3(ref["spec"]);if (admitted.spec.usage !== PORTABLE_MATERIAL_SLOT_USAGE[slot])- fail2(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`);+ throw new PortableMaterialV3Error(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`, "PROCEDURAL_TEXTURE_USAGE");texels += admitted.spec.width * admitted.spec.height;work += admitted.estimatedWorkUnits;bytes += admitted.conservativePixelAllocationBytes;@@ -5788,8 +5790,8 @@ var init_procedural_material_v3 = __esm(() => {occlusion: "occlusion"};PortableMaterialV3Error = class PortableMaterialV3Error extends ProceduralTextureError {- constructor(message) {- super(`portableMaterial V3: ${message}`, "PORTABLE_MATERIAL_V3_CONTRACT");+ constructor(message, diagnostic = "PORTABLE_MATERIAL_V3_CONTRACT") {+ super(`portableMaterial V3: ${message}`, diagnostic);this.name = "PortableMaterialV3Error";}};@@ -38366,7 +38368,7 @@ function decodeEvaluatorResultV2(json, maxGlbBytes, expectedRequestId) {if (!codes.includes(value.error.code) || typeof value.error.message !== "string" || value.error.message !== evaluatorOutcomeMessage(value.error.code)) {return fail9("result");}- if (value.error.diagnostic !== undefined && (value.error.code !== "EXECUTION_REJECTED" || value.error.diagnostic !== "UNBOUND_VARIABLE" && value.error.diagnostic !== "GEAR_RADII_ORDER" && value.error.diagnostic !== "ROUNDED_BOX_RADIUS" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_UNKNOWN_KEY" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_BLEND" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_V3_CONTRACT" && value.error.diagnostic !== "PORTABLE_MATERIAL_V3_CONTRACT" && value.error.diagnostic !== "TEXTURE_ATLAS_CONTRACT" && value.error.diagnostic !== "MATERIAL_FRACTION_RANGE" && value.error.diagnostic !== "MATERIAL_RECIPE_TEXTURE_BINDING" && value.error.diagnostic !== "PORTABLE_TEXTURE_REFERENCE" && value.error.diagnostic !== "PORTABLE_COLOR_ARGUMENT" && value.error.diagnostic !== "PARAMETRIC_PERIODIC_ENDPOINT" && value.error.diagnostic !== "PROFILE_HOLES_UNSUPPORTED" && value.error.diagnostic !== "PROFILE_BEVEL_COLLAPSE" && value.error.diagnostic !== "PROFILE_CORRESPONDENCE_COLLAPSE" && value.error.diagnostic !== "REMOVED_HELPER" && value.error.diagnostic !== "TUBE_RADIUS" && value.error.diagnostic !== "TAPER_CONE_AXIS" && value.error.diagnostic !== "SOLID_FLOAT32_COLLAPSE" && value.error.diagnostic !== "MESH_DATA_NONFINITE" && value.error.diagnostic !== "MATERIAL_ALPHA_MODE" && value.error.diagnostic !== "MATERIAL_COLOR_ARGUMENT" && value.error.diagnostic !== "PART_NAME_ARGUMENT" && value.error.diagnostic !== "PART_GEOMETRY_ARGUMENT" && value.error.diagnostic !== "PART_MATERIAL_ARGUMENT" && value.error.diagnostic !== "MATERIAL_PACKED_CHANNELS" && value.error.diagnostic !== "UNINITIALIZED_BINDING" && value.error.diagnostic !== "BUILD_RESULT" && value.error.diagnostic !== "MATERIAL_RECIPE_OVERRIDE" && value.error.diagnostic !== "PROGRAM_TYPE_ERROR" && value.error.diagnostic !== "PROGRAM_RANGE_ERROR" && value.error.diagnostic !== "LOD_SET" && value.error.diagnostic !== "OPEN_SHELL" && value.error.diagnostic !== "DELIVERY_CONTRACT" && value.error.diagnostic !== "REQUIRE_SOLID" && value.error.diagnostic !== "EXPORT_MATERIAL_SIDE_UNSUPPORTED" && value.error.diagnostic !== "BONE_CHAIN_ARGUMENT" && value.error.diagnostic !== "SKIN_BINDING_ARGUMENT"))+ if (value.error.diagnostic !== undefined && (value.error.code !== "EXECUTION_REJECTED" || value.error.diagnostic !== "UNBOUND_VARIABLE" && value.error.diagnostic !== "GEAR_RADII_ORDER" && value.error.diagnostic !== "ROUNDED_BOX_RADIUS" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_UNKNOWN_KEY" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_BLEND" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_USAGE" && value.error.diagnostic !== "PROCEDURAL_TEXTURE_V3_CONTRACT" && value.error.diagnostic !== "PORTABLE_MATERIAL_V3_CONTRACT" && value.error.diagnostic !== "TEXTURE_ATLAS_CONTRACT" && value.error.diagnostic !== "MATERIAL_FRACTION_RANGE" && value.error.diagnostic !== "MATERIAL_RECIPE_TEXTURE_BINDING" && value.error.diagnostic !== "PORTABLE_TEXTURE_REFERENCE" && value.error.diagnostic !== "PORTABLE_COLOR_ARGUMENT" && value.error.diagnostic !== "PARAMETRIC_PERIODIC_ENDPOINT" && value.error.diagnostic !== "PROFILE_HOLES_UNSUPPORTED" && value.error.diagnostic !== "PROFILE_BEVEL_COLLAPSE" && value.error.diagnostic !== "PROFILE_CORRESPONDENCE_COLLAPSE" && value.error.diagnostic !== "REMOVED_HELPER" && value.error.diagnostic !== "TUBE_RADIUS" && value.error.diagnostic !== "TAPER_CONE_AXIS" && value.error.diagnostic !== "SOLID_FLOAT32_COLLAPSE" && value.error.diagnostic !== "MESH_DATA_NONFINITE" && value.error.diagnostic !== "MATERIAL_ALPHA_MODE" && value.error.diagnostic !== "MATERIAL_COLOR_ARGUMENT" && value.error.diagnostic !== "PART_NAME_ARGUMENT" && value.error.diagnostic !== "PART_GEOMETRY_ARGUMENT" && value.error.diagnostic !== "PART_MATERIAL_ARGUMENT" && value.error.diagnostic !== "MATERIAL_PACKED_CHANNELS" && value.error.diagnostic !== "UNINITIALIZED_BINDING" && value.error.diagnostic !== "BUILD_RESULT" && value.error.diagnostic !== "MATERIAL_RECIPE_OVERRIDE" && value.error.diagnostic !== "PROGRAM_TYPE_ERROR" && value.error.diagnostic !== "PROGRAM_RANGE_ERROR" && value.error.diagnostic !== "LOD_SET" && value.error.diagnostic !== "OPEN_SHELL" && value.error.diagnostic !== "DELIVERY_CONTRACT" && value.error.diagnostic !== "REQUIRE_SOLID" && value.error.diagnostic !== "EXPORT_MATERIAL_SIDE_UNSUPPORTED" && value.error.diagnostic !== "BONE_CHAIN_ARGUMENT" && value.error.diagnostic !== "SKIN_BINDING_ARGUMENT"))return fail9("result");if (value.error.solid !== undefined && (value.error.diagnostic !== "REQUIRE_SOLID" || !validSolidFailureDetails(value.error.solid)))return fail9("result");@@ -46809,6 +46811,7 @@ define2("proceduralTexture", {...textureFacts,ownership: "Creates a new DataTexture with generated bytes and portable metadata.",parameters: [+ "usage is albedo (default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match the slot: portable baseColor takes albedo and occlusion takes occlusion; normal, metallicRoughness and emissive take their own name; pbrMaterial albedo, roughness, metalness and aoMap take albedo, roughness, metalness and occlusion.","V1/V2 preserve opaque patterns: size power-of-two 4..1024 and at most 8 layers. Explicit schemaVersion 3 uses width/height integers 4..1024, byte RGBA, at most 64 ordered operations and 64 polygon vertices.","V3 paint/mask use integer pixel-edge shapes with binary center coverage and fixed integer source-over rounding. A mask clears outside its shape; invert keeps outside. Zero-alpha pixels are transparent black.","V3 color-only palette colors are 1..32 RGB integers, optional fixed Bayer4 dither. Stamps (any usage) use bounded Xorshift32 seed/area placement; periodic wrapping is explicit and at most 256 expanded copies. Legacy-v2 layers delegate unchanged square V2 patterns with matching usage.",diff --git a/docs/programs.md b/docs/programs.mdindex 768d2f50..42ce1c30 100644--- a/docs/programs.md+++ b/docs/programs.md@@ -5,7 +5,9 @@ This is independent of the conversation or MCP connection.Pass `code` once to `kiln_validate` or `kiln_render`. Both return a `programRef`, evenwhen the draft fails. Use it for later rendering, validation, inspection, animation-and interior views. `kiln_source` reads the source; `kiln_edit` changes it.+and interior views. `kiln_source` reads the source; `kiln_edit` changes it. From a+shell, `kiln validate <program.js|ref>` runs the same `kiln_validate` check, prints the+`programRef` and exits 1 when the source is invalid; `--json` prints the tool result.Copy the returned reference exactly. Built-in stores return compact handles such as`p_7c94a132b8e0`, so the model need not repeat a full hash. A handle always identifiesdiff --git a/docs/runtime.md b/docs/runtime.mdindex 4d562fa7..2db53749 100644--- a/docs/runtime.md+++ b/docs/runtime.md@@ -87,7 +87,8 @@ A program that throws in the subprocess or isolated evaluator is reported asprogram crosses the worker boundary. The worker may add one closed cause, and the hostturns it into engine-written advice. Causes include a binding read before itsdeclaration ran, a `build()` that is missing or returns no Object3D, a `materialRecipe`-override the recipe does not allow, and a TypeError or RangeError. The host still has+override the recipe does not allow, a procedural texture usage that is unknown or does not+match its slot, and a TypeError or RangeError. The host still hasthe source it sent. `kiln_render`, `kiln_inspect`, `kiln_view_interior`,`kiln_screenshot_animation` and the CLI parse that source and append `Source check:`with up to three codes and lines that `kiln_validate` reports for it. Examples are@@ -95,7 +96,7 @@ with up to three codes and lines that `kiln_validate` reports for it. Examples a`SYNTAX_ERROR`. An unrecognised exception stays generic: the sentence continues with afixed engine-owned paragraph that says no message crosses the sandbox, that values areread with `kiln_inspect` on a rendered program rather than a thrown `Error`, and that-`kiln_validate` names the line (`EXECUTION_REJECTED_ADVICE` in+`kiln_validate` (`kiln validate` from the CLI) names the line (`EXECUTION_REJECTED_ADVICE` in`src/evaluator/authoring-diagnostic.ts`).## Animation measurementsdiff --git a/src/__tests__/cli-validate.test.ts b/src/__tests__/cli-validate.test.tsnew file mode 100644index 00000000..e883d826--- /dev/null+++ b/src/__tests__/cli-validate.test.ts@@ -0,0 +1,54 @@+import { expect, test } from 'bun:test';+import { spawnSync } from 'node:child_process';+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { join, resolve } from 'node:path';+import { tmpdir } from 'node:os';++const entry = resolve(import.meta.dir, '../cli.ts');++function workspace() {+ const cwd = mkdtempSync(join(tmpdir(), 'kiln-validate-cli-'));+ const run = (args: string[]) =>+ spawnSync(process.execPath, [entry, ...args], {+ cwd,+ encoding: 'utf8',+ windowsHide: true,+ env: { ...process.env, KILN_RENDER: 'cpu', KILN_PROGRAM_STORE: join(cwd, 'programs') },+ timeout: 20_000,+ });+ return { cwd, run, done: () => rmSync(cwd, { recursive: true, force: true }) };+}++const VALID = `const meta = { name: 'Crate' };\nfunction build() { return createRoot('Crate'); }\n`;+const INVALID = `const meta = { name: 'Crate' };\nfunction build() { return createRoot('Crate'); \n`;++test('kiln validate reports the kiln_validate result for a file and a ref', () => {+ const { cwd, run, done } = workspace();+ try {+ writeFileSync(join(cwd, 'good.js'), VALID);+ writeFileSync(join(cwd, 'bad.js'), INVALID);+ const good = run(['validate', 'good.js']);+ expect(good.status).toBe(0);+ expect(good.stdout).toMatch(/^valid p_/);+ const bad = run(['validate', 'bad.js']);+ expect(bad.status).toBe(1);+ expect(bad.stdout).toMatch(/^invalid p_/);+ expect(bad.stdout).toContain('error:');+ const json = run(['validate', 'bad.js', '--json']);+ expect(json.status).toBe(1);+ const result = JSON.parse(json.stdout);+ expect(result).toMatchObject({ valid: false, validationScope: 'syntax-and-sandbox' });+ expect(result.errors.length).toBeGreaterThan(0);+ const ref = /^valid (p_\S+)/.exec(good.stdout)![1]!;+ const byRef = run(['validate', ref, '--json']);+ expect(byRef.status).toBe(0);+ expect(JSON.parse(byRef.stdout)).toMatchObject({ valid: true, programRef: ref });+ const missing = run(['validate']);+ expect(missing.status).toBe(2);+ expect(missing.stderr).toContain('validate requires a program path or reference');+ } finally {+ done();+ }+ // Five CLI processes: 2.0 s on an idle host (2026-10-22); CLI-spawning tests have needed+ // up to 60 s on a loaded Windows host.+}, 60_000);diff --git a/src/cli.ts b/src/cli.tsindex 02d7a757..e304dc75 100644--- a/src/cli.ts+++ b/src/cli.ts@@ -40,6 +40,7 @@ const USAGE = `kiln — vision-in-the-loop 3D asset generationUSAGEkiln render <program.js|ref> [options] execute a Kiln program (offline, no key)+ kiln validate <program.js|ref> [--json] kiln_validate: syntax and sandbox check, no buildkiln generate "<prompt>" [options] author a program with a model, then renderkiln source <file.js> save a source snapshot and print its programRefkiln source <programRef> --out file.js export a revision without model transcription@@ -290,7 +291,7 @@ interface RenderCliReceipt extends Record<string, unknown> {/** Commands of this parser whose --json output includes failures, as `{ ok: false, error, files }`. */function jsonCommand(command: string | undefined): boolean {- return command === 'render' || command === 'source';+ return command === 'render' || command === 'source' || command === 'validate';}function jsonRenderFailure(error: unknown, receipt: RenderCliReceipt = { files: [] }): void {@@ -529,6 +530,46 @@ async function cmdRender(args: Args): Promise<number> {}}+/** The same kiln_validate definition MCP serves; the source is retained so its ref prints. */+async function cmdValidate(args: Args): Promise<number> {+ const input = args.positional[0];+ if (!input || args.positional.length !== 1) {+ const message = 'validate requires a program path or reference';+ if (args.json) jsonRenderFailure(message);+ else console.error(`${message}\n\n${USAGE}`);+ return 2;+ }+ const store = localProgramStore();+ const isRef = input.startsWith('sha256:') || programRefPattern.test(input);+ const def = createKilnProgramToolRegistry({ programStore: store }).find(+ (d) => d.name === 'kiln_validate',+ );+ if (!def) throw new Error('kiln_validate is missing from the MCP tool surface');+ const result = (await def.run(+ isRef ? { programRef: input } : { code: await readFile(resolvePath(input), 'utf8') },+ )) as {+ valid: boolean;+ programRef?: string;+ errors: string[];+ warnings: string[];+ issues: { code: string; message: string; fixHint?: string; line?: number }[];+ };+ if (args.json) console.log(JSON.stringify(result));+ else {+ console.log(`${result.valid ? 'valid' : 'invalid'} ${result.programRef ?? input}`);+ const described = new Set<string>();+ for (const issue of result.issues) {+ described.add(issue.message);+ const where = issue.line === undefined ? '' : ` (line ${issue.line})`;+ const hint = issue.fixHint ? ` ${issue.fixHint}` : '';+ console.log(` error: ${issue.code}${where}: ${issue.message}${hint}`);+ }+ for (const error of result.errors) if (!described.has(error)) console.log(` error: ${error}`);+ for (const warning of result.warnings) console.log(` warning: ${warning}`);+ }+ return result.valid ? 0 : 1;+}+async function cmdGenerate(args: Args): Promise<number> {assertNodeRuntime('agent');const prompt = args.positional.join(' ').trim();@@ -810,6 +851,8 @@ async function runMain(argv: readonly string[]): Promise<number> {return await cmdSource(args);case 'render':return await cmdRender(args);+ case 'validate':+ return await cmdValidate(args);case 'generate':return await cmdGenerate(args);default:diff --git a/src/discovery/catalog.test.ts b/src/discovery/catalog.test.tsindex 0dd7a01d..a109dca8 100644--- a/src/discovery/catalog.test.ts+++ b/src/discovery/catalog.test.ts@@ -14,6 +14,7 @@ import { sweepProfile } from '../sweep';import { listHelperSpecs } from './helper-specs';import { parseCatalog, type DiscoveryEntry } from './catalog-schema';import { listDiscoveryEntries, DISCOVERY_HELPER_RETIREMENTS } from './catalog';+import { TEXTURE_USAGES } from '../texture-contract';import { helperContracts } from './helper-contracts';const byName = () => new Map(listDiscoveryEntries().map((entry) => [entry.name, entry]));@@ -199,3 +200,12 @@ describe('executable Discovery catalog', () => {expect(roomContract.contract.axes).toContain('Width spans Z');});});++test('the proceduralTexture contract lists every accepted usage and its slots', () => {+ const entry = byName().get('proceduralTexture');+ if (!entry || !executable(entry)) throw new Error('Missing helper proceduralTexture');+ const usage = entry.contract.parameters.find((line) => line.startsWith('usage '));+ expect(usage).toBeDefined();+ for (const name of TEXTURE_USAGES) expect(usage).toContain(name);+ for (const slot of ['baseColor', 'aoMap', 'occlusion']) expect(usage).toContain(slot);+});diff --git a/src/discovery/helper-contracts.ts b/src/discovery/helper-contracts.tsindex 9910ed95..dce70fc7 100644--- a/src/discovery/helper-contracts.ts+++ b/src/discovery/helper-contracts.ts@@ -2696,6 +2696,7 @@ define(...textureFacts,ownership: 'Creates a new DataTexture with generated bytes and portable metadata.',parameters: [+ 'usage is albedo (default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match the slot: portable baseColor takes albedo and occlusion takes occlusion; normal, metallicRoughness and emissive take their own name; pbrMaterial albedo, roughness, metalness and aoMap take albedo, roughness, metalness and occlusion.','V1/V2 preserve opaque patterns: size power-of-two 4..1024 and at most 8 layers. Explicit schemaVersion 3 uses width/height integers 4..1024, byte RGBA, at most 64 ordered operations and 64 polygon vertices.','V3 paint/mask use integer pixel-edge shapes with binary center coverage and fixed integer source-over rounding. A mask clears outside its shape; invert keeps outside. Zero-alpha pixels are transparent black.','V3 color-only palette colors are 1..32 RGB integers, optional fixed Bayer4 dither. Stamps (any usage) use bounded Xorshift32 seed/area placement; periodic wrapping is explicit and at most 256 expanded copies. Legacy-v2 layers delegate unchanged square V2 patterns with matching usage.',diff --git a/src/evaluator/authoring-diagnostic.test.ts b/src/evaluator/authoring-diagnostic.test.tsindex 190a58dd..135b28e9 100644--- a/src/evaluator/authoring-diagnostic.test.ts+++ b/src/evaluator/authoring-diagnostic.test.ts@@ -7,6 +7,8 @@ import {createEvaluatorPortV2,} from './protocol';import { renderGLBViaSubprocess } from './subprocess';+import { authoringDiagnosticAdvice } from './authoring-diagnostic';+import { TEXTURE_USAGES } from '../texture-contract';import {canonicalizeProceduralTextureSpecV2,canonicalizePortableMaterialSpecV2,@@ -488,6 +490,7 @@ test('arbitrary exceptions and safety denials retain generic rejection', async (`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'ROUNDED_BOX_RADIUS'});}`,`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'PROCEDURAL_TEXTURE_UNKNOWN_KEY'});}`,`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'PROCEDURAL_TEXTURE_BLEND'});}`,+ `function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'PROCEDURAL_TEXTURE_USAGE'});}`,`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'MATERIAL_FRACTION_RANGE'});}`,`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'MATERIAL_COLOR_ARGUMENT'});}`,`function build(){throw Object.assign(new Error('SECRET_HOST_PATH'),{name:'AuthoringDiagnosticError',diagnostic:'MATERIAL_PACKED_CHANNELS'});}`,@@ -528,3 +531,33 @@ test('shipping registry exposes repair advice from its isolated evaluator', asynexpect(out.error).toContain('Check variable spelling and scope');expect(out.error).not.toContain('uv');}, 15000);++test('procedural texture usage errors list the accepted usages without crossing the message', async () => {+ const sources = [+ `function build(){proceduralTexture({schemaVersion:2,usage:'data',name:'PRIVATE_SOURCE_MARKER',layers:[{op:'solid',color:0}]});return createRoot('Cove');}`,+ `function build(){proceduralTexture({schemaVersion:3,width:4,height:4,usage:'height',operations:[]});return createRoot('Cove');}`,+ `async function build(){await compilePortableMaterialSpecV2({schemaVersion:2,model:'pbrMetallicRoughness',textures:{normal:{kind:'procedural',spec:{schemaVersion:2,usage:'albedo',layers:[{op:'solid',color:0}]}}}});return createRoot('Cove');}`,+ `async function build(){await compilePortableMaterialSpecV3({schemaVersion:3,model:'pbrMetallicRoughness',textures:{normal:{kind:'procedural',sampler:{minFilter:'linear',magFilter:'linear',wrapS:'repeat',wrapT:'repeat'},spec:{schemaVersion:3,width:4,height:4,usage:'albedo',operations:[]}}}});return createRoot('Cove');}`,+ ];+ for (const source of sources) {+ const wire = await evaluateEvaluatorRequestV2(+ createEvaluatorRequestV2({ requestId: 'procedural-usage', code: source }).json,+ );+ expect(JSON.parse(wire).error).toEqual({+ code: 'EXECUTION_REJECTED',+ message: 'Generated asset execution was rejected.',+ diagnostic: 'PROCEDURAL_TEXTURE_USAGE',+ });+ for (const secret of ['PRIVATE_SOURCE_MARKER', 'data', 'height'])+ expect(wire).not.toContain(secret);+ }+ await expect(renderGLBViaSubprocess(sources[0]!)).rejects.toMatchObject({+ code: 'EXECUTION_REJECTED',+ diagnostic: 'PROCEDURAL_TEXTURE_USAGE',+ });+ const advice = authoringDiagnosticAdvice('PROCEDURAL_TEXTURE_USAGE');+ for (const usage of TEXTURE_USAGES) expect(advice).toContain(usage);+ for (const slot of ['baseColor', 'normal', 'metallicRoughness', 'emissive', 'occlusion'])+ expect(advice).toContain(slot);+ await expect(renderGLBViaSubprocess(sources[0]!)).rejects.toThrow(advice);+}, 20000);diff --git a/src/evaluator/authoring-diagnostic.ts b/src/evaluator/authoring-diagnostic.tsindex 5d6684c1..d4a6deec 100644--- a/src/evaluator/authoring-diagnostic.ts+++ b/src/evaluator/authoring-diagnostic.ts@@ -19,6 +19,7 @@ export type AuthoringDiagnostic =| 'ROUNDED_BOX_RADIUS'| 'PROCEDURAL_TEXTURE_UNKNOWN_KEY'| 'PROCEDURAL_TEXTURE_BLEND'+ | 'PROCEDURAL_TEXTURE_USAGE'| 'PROCEDURAL_TEXTURE_V3_CONTRACT'| 'PORTABLE_MATERIAL_V3_CONTRACT'| 'TEXTURE_ATLAS_CONTRACT'@@ -53,6 +54,8 @@ export const ROUNDED_BOX_RADIUS_ADVICE ='roundedBoxGeo: radius must be less than half the smallest dimension. Reduce radius or increase the smallest dimension; equality is invalid.';export const PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE ='Remove unsupported proceduralTexture fields. Call kiln_discover with ids ["proceduralTexture"] and use only the documented fields for the selected layer op.';+export const PROCEDURAL_TEXTURE_USAGE_ADVICE =+ 'proceduralTexture usage is one of albedo (the default), emissive, normal, roughness, metalness, metallicRoughness or occlusion; there is no data or height usage. Match it to the slot it fills: portable material baseColor takes albedo, normal takes normal, metallicRoughness takes metallicRoughness (G roughness, B metalness), emissive takes emissive and occlusion takes occlusion; pbrMaterial albedo, normal, roughness, metalness, metallicRoughness, emissive and aoMap take the matching usage. Call kiln_discover with ids ["proceduralTexture"].';export const MATERIAL_FRACTION_RANGE_ADVICE ='Material fractions must be finite numbers between 0 and 1, inclusive. In proceduralTexture, mortarWidth and stagger are fractions, not pixels; opacity uses the same range. materialRecipe roughness, metalness, opacity, alphaCutoff and emissiveIntensity use 0..1. portableMaterial roughness, metalness and alphaCutoff also use 0..1; its emissiveIntensity has a separate 0..64 range. Call kiln_discover for the exact field contracts.';export const PARAMETRIC_PERIODIC_ENDPOINT_ADVICE =@@ -86,7 +89,7 @@ export const REQUIRE_SOLID_ADVICE =* bounding boxes and got the bare sentence, H30; decision 24).*/export const EXECUTION_REJECTED_ADVICE =- 'No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.';+ 'No message, stack or identifier crosses the sandbox: a thrown Error, a source-policy denial and any other failure are each reported only as this sentence. Run kiln_validate (CLI: kiln validate <program.js|ref>) on the same source for the failing line and code; to read values, render the program and call kiln_inspect (listParts, measurements) instead of throwing. A TypeError, RangeError, unbound variable or build() mistake is named when it is the cause.';export function authoringDiagnosticAdvice(diagnostic: AuthoringDiagnostic | undefined): string {if (diagnostic === 'PORTABLE_MATERIAL_V3_CONTRACT')return 'compilePortableMaterialSpecV3 requires schemaVersion 3, model pbrMetallicRoughness, typed V3 procedural or injected resource references, and complete minFilter/magFilter/wrapS/wrapT samplers. Match texture usage to its slot and split work exceeding the material budget. Resource bindings need a host with verified-byte admission. V2 remains available unchanged. Shader code, paths, raw textures and V3 height derivation are unsupported. Read kiln_discover ids ["compilePortableMaterialSpecV3"] for the exact contract.';@@ -145,6 +148,7 @@ export function authoringDiagnosticAdvice(diagnostic: AuthoringDiagnostic | undeif (diagnostic === 'ROUNDED_BOX_RADIUS') return ROUNDED_BOX_RADIUS_ADVICE;if (diagnostic === 'GEAR_RADII_ORDER') return GEAR_RADII_ORDER_ADVICE;if (diagnostic === 'PROCEDURAL_TEXTURE_UNKNOWN_KEY') return PROCEDURAL_TEXTURE_UNKNOWN_KEY_ADVICE;+ if (diagnostic === 'PROCEDURAL_TEXTURE_USAGE') return PROCEDURAL_TEXTURE_USAGE_ADVICE;if (diagnostic === 'MATERIAL_FRACTION_RANGE') return MATERIAL_FRACTION_RANGE_ADVICE;if (diagnostic === 'PROFILE_HOLES_UNSUPPORTED') return PROFILE_HOLES_UNSUPPORTED_ADVICE;if (diagnostic === 'PROFILE_CORRESPONDENCE_COLLAPSE')diff --git a/src/evaluator/protocol.ts b/src/evaluator/protocol.tsindex e1503b68..e6250308 100644--- a/src/evaluator/protocol.ts+++ b/src/evaluator/protocol.ts@@ -444,6 +444,7 @@ export function decodeEvaluatorResultV2(value.error.diagnostic !== 'ROUNDED_BOX_RADIUS' &&value.error.diagnostic !== 'PROCEDURAL_TEXTURE_UNKNOWN_KEY' &&value.error.diagnostic !== 'PROCEDURAL_TEXTURE_BLEND' &&+ value.error.diagnostic !== 'PROCEDURAL_TEXTURE_USAGE' &&value.error.diagnostic !== 'PROCEDURAL_TEXTURE_V3_CONTRACT' &&value.error.diagnostic !== 'PORTABLE_MATERIAL_V3_CONTRACT' &&value.error.diagnostic !== 'TEXTURE_ATLAS_CONTRACT' &&diff --git a/src/procedural-material-v2.ts b/src/procedural-material-v2.tsindex 4d96f11c..573f1654 100644--- a/src/procedural-material-v2.ts+++ b/src/procedural-material-v2.ts@@ -316,6 +316,7 @@ function usage(value: unknown, path: string, fallback: TextureUsage): TextureUsaif (!(TEXTURE_USAGES as readonly unknown[]).includes(value)) {throw new ProceduralTextureError(`${path} must be one of ${TEXTURE_USAGES.join(', ')}, got ${JSON.stringify(value)}.`,+ 'PROCEDURAL_TEXTURE_USAGE',);}return value as TextureUsage;@@ -597,6 +598,7 @@ function canonicalTextureRef(if (spec.usage !== expected) {throw new ProceduralTextureError(`${path} requires procedural usage ${JSON.stringify(expected)}, got ${JSON.stringify(spec.usage)}.`,+ 'PROCEDURAL_TEXTURE_USAGE',);}return { kind: 'procedural', spec };diff --git a/src/procedural-material-v3.ts b/src/procedural-material-v3.tsindex b7f6cd46..04439520 100644--- a/src/procedural-material-v3.ts+++ b/src/procedural-material-v3.ts@@ -13,6 +13,7 @@ import {type CanonicalPortableSamplerV1,type PortableSamplerV1,} from './portable-sampler';+import type { AuthoringDiagnostic } from './evaluator/authoring-diagnostic';import type { MaterialMapSlotV1 } from './pinned-material-map';export const PORTABLE_MATERIAL_V3_LIMITS = Object.freeze({@@ -74,8 +75,8 @@ export interface CanonicalPortableMaterialSpecV3textures: Partial<Record<MaterialMapSlotV1, CanonicalPortableTextureRefV3>>;}export class PortableMaterialV3Error extends ProceduralTextureError {- constructor(message: string) {- super(`portableMaterial V3: ${message}`, 'PORTABLE_MATERIAL_V3_CONTRACT');+ constructor(message: string, diagnostic: AuthoringDiagnostic = 'PORTABLE_MATERIAL_V3_CONTRACT') {+ super(`portableMaterial V3: ${message}`, diagnostic);this.name = 'PortableMaterialV3Error';}}@@ -172,7 +173,10 @@ function admitMaterial(input: unknown): PortableMaterialAdmissionV3 {fail('procedural references cannot carry a resource ID.');const admitted = admitProceduralTextureSpecV3(ref['spec']);if (admitted.spec.usage !== PORTABLE_MATERIAL_SLOT_USAGE[slot])- fail(`${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`);+ throw new PortableMaterialV3Error(+ `${slot} requires ${PORTABLE_MATERIAL_SLOT_USAGE[slot]} data.`,+ 'PROCEDURAL_TEXTURE_USAGE',+ );texels += admitted.spec.width * admitted.spec.height;work += admitted.estimatedWorkUnits;bytes += admitted.conservativePixelAllocationBytes;diff --git a/src/procedural-texture-v3-contract.ts b/src/procedural-texture-v3-contract.tsindex 21d9f855..54ca0663 100644--- a/src/procedural-texture-v3-contract.ts+++ b/src/procedural-texture-v3-contract.ts@@ -6,6 +6,7 @@ import {ProceduralTextureError,sha256Hex,} from './procedural-material-v2';+import type { AuthoringDiagnostic } from './evaluator/authoring-diagnostic';import { TEXTURE_USAGES, type TextureUsage } from './texture-contract';export const PROCEDURAL_TEXTURE_V3_COMPILER_ID = 'kiln.procedural-rgba.v3.1' as const;@@ -81,11 +82,11 @@ export interface CanonicalProceduralTextureSpecV3 {palette?: { colors: number[]; dither: 'none' | 'bayer4' };}-function fail(message: string): never {- throw new ProceduralTextureError(- `proceduralTexture V3: ${message}`,- 'PROCEDURAL_TEXTURE_V3_CONTRACT',- );+function fail(+ message: string,+ diagnostic: AuthoringDiagnostic = 'PROCEDURAL_TEXTURE_V3_CONTRACT',+): never {+ throw new ProceduralTextureError(`proceduralTexture V3: ${message}`, diagnostic);}const forbidden = new Set(['__proto__', 'prototype', 'constructor']);@@ -265,7 +266,7 @@ export function admitProceduralTextureSpecV3(input: unknown): ProceduralTextureAif (texels > MAX_PROCEDURAL_V3_TEXELS) fail('output texel budget exceeded.');const usage = r['usage'] === undefined ? 'albedo' : r['usage'];if (!(TEXTURE_USAGES as readonly unknown[]).includes(usage))- fail('usage must be a known texture usage.');+ fail('usage must be a known texture usage.', 'PROCEDURAL_TEXTURE_USAGE');const colorUsage = usage === 'albedo' || usage === 'emissive';const name = r['name'];if (