@plasius/gpu-model-core 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/model-document.ts","../src/index.ts"],"sourcesContent":["/** The only document version accepted by the v1 runtime validator. */\nexport const GPU_MODEL_DOCUMENT_SCHEMA_VERSION = \"plasius.gpu-model-document/1\" as const;\n\n/** Canonical basis shared by conversion, processing, and rendering packages. */\nexport const CANONICAL_GPU_MODEL_COORDINATE_SYSTEM = Object.freeze({\n unit: \"metre\",\n upAxis: \"y\",\n forwardAxis: \"-z\",\n handedness: \"right\",\n winding: \"counter-clockwise\",\n origin: \"floor-centred\",\n} as const);\n\n/** Fixed defensive ceilings for one canonical v1 document. */\nexport const GPU_MODEL_DOCUMENT_LIMITS = Object.freeze({\n roots: 4_096,\n nodes: 65_536,\n resources: 16_384,\n accessors: 262_144,\n accessorElements: 16_000_000,\n meshes: 65_536,\n primitives: 262_144,\n materials: 65_536,\n textures: 65_536,\n skeletons: 4_096,\n joints: 65_536,\n skins: 4_096,\n blendShapes: 65_536,\n blendShapeDeltas: 262_144,\n blendShapeAccessorReferences: 786_432,\n animations: 4_096,\n analyticGeometry: 4_096,\n diagnostics: 4_096,\n sceneEdges: 65_535,\n primitiveAttributes: 262_144,\n skinJoints: 65_536,\n weightVertices: 1_000_000,\n weightInfluences: 8_000_000,\n animationSamplers: 65_536,\n animationChannels: 262_144,\n animationValues: 8_000_000,\n geometryIndexElements: 16_000_000,\n geometryWorldAccessorInstances: 262_144,\n geometryWorldVertices: 16_000_000,\n identifierLength: 128,\n nameLength: 512,\n diagnosticMessageLength: 2_048,\n metadataDepth: 8,\n metadataValues: 4_096,\n metadataObjectKeys: 128,\n metadataArrayLength: 512,\n metadataKeyLength: 128,\n metadataStringLength: 2_048,\n} as const);\n\nexport interface GpuModelResourceVerificationLimits {\n readonly maxResourceBytes: number;\n readonly maxAggregateBytes: number;\n readonly maxImageBytes: number;\n readonly maxAggregateImageBytes: number;\n readonly maxImageDimension: number;\n readonly maxImagePixels: number;\n readonly chunkBytes: number;\n readonly timeoutMs: number;\n}\n\n/** Default verification budgets. Callers may tighten, but never raise, them. */\nexport const GPU_MODEL_RESOURCE_VERIFICATION_LIMITS: Readonly<GpuModelResourceVerificationLimits> = Object.freeze({\n maxResourceBytes: 100 * 1024 * 1024,\n maxAggregateBytes: 164 * 1024 * 1024,\n maxImageBytes: 64 * 1024 * 1024,\n maxAggregateImageBytes: 64 * 1024 * 1024,\n maxImageDimension: 4_096,\n maxImagePixels: 4_096 * 4_096,\n chunkBytes: 1024 * 1024,\n timeoutMs: 30_000,\n} as const);\n\n/** Stable machine-readable validation failure categories. */\nexport type GpuModelDocumentErrorCode =\n | \"invalid-type\"\n | \"invalid-value\"\n | \"unknown-key\"\n | \"limit-exceeded\"\n | \"feature-disabled\"\n | \"unsupported-feature\"\n | \"duplicate-id\"\n | \"missing-reference\"\n | \"invalid-reference\"\n | \"graph-cycle\"\n | \"payload-length-mismatch\"\n | \"resource-unverified\"\n | \"resource-verification-failed\"\n | \"resource-budget-exceeded\";\n\nfunction escapeDiagnosticText(value: string, maximum: number): string {\n let output = \"\";\n for (const character of value) {\n const point = character.codePointAt(0)!;\n const unsafe = point < 0x20\n || (point >= 0x7f && point <= 0x9f)\n || point === 0x2028\n || point === 0x2029\n || (point >= 0x202a && point <= 0x202e)\n || (point >= 0x2066 && point <= 0x2069)\n || (point >= 0xd800 && point <= 0xdfff);\n output += character === \"\\\\\"\n ? \"\\\\\\\\\"\n : unsafe\n ? `\\\\u${point.toString(16).padStart(point <= 0xffff ? 4 : 6, \"0\")}`\n : character;\n if (output.length >= maximum) break;\n }\n return output.slice(0, maximum);\n}\n\n/** Bounded validation error safe to return across worker boundaries. */\nexport class GpuModelDocumentError extends TypeError {\n public readonly code: GpuModelDocumentErrorCode;\n public readonly path: string;\n\n public constructor(code: GpuModelDocumentErrorCode, path: string, detail: string) {\n const safePath = escapeDiagnosticText(path, 256);\n const safeDetail = escapeDiagnosticText(detail, 512);\n super(`Invalid GPU model document at ${safePath}: ${safeDetail}`);\n this.name = \"GpuModelDocumentError\";\n this.code = code;\n this.path = safePath;\n }\n}\n\n/** JSON-compatible value accepted by bounded canonical metadata fields. */\nexport type GpuModelMetadataValue =\n | null\n | boolean\n | number\n | string\n | readonly GpuModelMetadataValue[]\n | { readonly [key: string]: GpuModelMetadataValue };\n\n/** Immutable, safe-keyed source/extension metadata. */\nexport type GpuModelMetadata = Readonly<Record<string, GpuModelMetadataValue>>;\nexport type GpuModelSourceMetadata = GpuModelMetadata;\nexport type GpuModelVec2 = readonly [number, number];\nexport type GpuModelVec3 = readonly [number, number, number];\nexport type GpuModelVec4 = readonly [number, number, number, number];\n/** Column-major 4 x 4 affine matrix. */\nexport type GpuModelMatrix4 = readonly [\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n];\n\nexport interface GpuModelTransformTrs {\n readonly translation: GpuModelVec3;\n readonly rotation: GpuModelVec4;\n readonly scale: GpuModelVec3;\n}\n\nexport interface GpuModelBounds {\n readonly min: GpuModelVec3;\n readonly max: GpuModelVec3;\n}\n\nexport interface GpuModelNode {\n readonly id: string;\n readonly name?: string;\n readonly children: readonly string[];\n readonly meshId?: string;\n readonly skinId?: string;\n readonly localMatrix: GpuModelMatrix4;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelResourceKind = \"buffer\" | \"image\";\n\n/** Privately attestable immutable payload. Verification status is never shape-based. */\nexport interface GpuModelResource {\n readonly id: string;\n readonly kind: GpuModelResourceKind;\n readonly contentHash: string;\n readonly byteLength: number;\n readonly mimeType: string;\n readonly payload: Blob;\n}\n\nexport interface GpuModelResourceVerificationContext {\n readonly resourceId: string;\n readonly kind: GpuModelResourceKind;\n readonly declaredMimeType: string;\n readonly byteLength: number;\n readonly signal?: AbortSignal;\n}\n\nexport interface GpuModelResourceInspection {\n readonly valid: boolean;\n readonly detectedMimeType: string;\n readonly width?: number;\n readonly height?: number;\n}\n\n/** Trusted, injected worker boundary for streaming digest and payload inspection. */\nexport interface GpuModelResourceVerificationPort {\n digestSha256(\n chunks: AsyncIterable<Uint8Array>,\n context: GpuModelResourceVerificationContext,\n ): Promise<string>;\n inspectResource(\n chunks: AsyncIterable<Uint8Array>,\n context: GpuModelResourceVerificationContext,\n ): Promise<GpuModelResourceInspection>;\n}\n\nexport interface GpuModelResourceVerificationOptions {\n readonly signal?: AbortSignal;\n readonly limits?: Partial<GpuModelResourceVerificationLimits>;\n}\n\nexport type GpuModelAccessorComponentType = \"i8\" | \"u8\" | \"i16\" | \"u16\" | \"u32\" | \"f32\";\nexport type GpuModelAccessorElementType = \"scalar\" | \"vec2\" | \"vec3\" | \"vec4\" | \"mat2\" | \"mat3\" | \"mat4\";\n\nexport interface GpuModelAccessor {\n readonly id: string;\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteStride?: number;\n readonly count: number;\n readonly componentType: GpuModelAccessorComponentType;\n readonly elementType: GpuModelAccessorElementType;\n readonly normalized?: boolean;\n readonly min?: readonly number[];\n readonly max?: readonly number[];\n}\n\nexport interface GpuModelPrimitiveAttribute {\n readonly semantic: string;\n readonly accessorId: string;\n}\n\nexport type GpuModelPrimitiveTopology = \"points\" | \"lines\" | \"line-strip\" | \"triangles\" | \"triangle-strip\";\n\nexport interface GpuModelPrimitive {\n readonly id: string;\n readonly topology: GpuModelPrimitiveTopology;\n readonly attributes: readonly GpuModelPrimitiveAttribute[];\n readonly indicesAccessorId?: string;\n readonly materialId?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport interface GpuModelMesh {\n readonly id: string;\n readonly name?: string;\n readonly primitives: readonly GpuModelPrimitive[];\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelTextureColorSpace = \"srgb\" | \"linear\" | \"normal-map\" | \"data\";\nexport type GpuModelTextureUsage =\n | \"base-color\"\n | \"metallic-roughness\"\n | \"normal\"\n | \"occlusion\"\n | \"emissive\"\n | \"transmission\"\n | \"clearcoat\"\n | \"clearcoat-roughness\"\n | \"clearcoat-normal\"\n | \"sheen-color\"\n | \"sheen-roughness\";\n\nexport interface GpuModelTextureTransform {\n readonly offset?: GpuModelVec2;\n readonly rotationRadians?: number;\n readonly scale?: GpuModelVec2;\n}\n\nexport interface GpuModelTextureBinding {\n readonly textureId: string;\n readonly samplerId?: string;\n readonly texCoordSet?: number;\n readonly transform?: GpuModelTextureTransform;\n readonly colorSpace: GpuModelTextureColorSpace;\n readonly intendedUsage: GpuModelTextureUsage;\n}\n\nexport type GpuModelAlphaMode = \"opaque\" | \"mask\" | \"blend\";\nexport type GpuModelMaterialWorkflow = \"metallic-roughness\" | \"specular-glossiness\" | \"unlit\" | \"custom\";\n\nexport interface GpuModelMaterialTextures {\n readonly baseColor?: GpuModelTextureBinding;\n readonly metallicRoughness?: GpuModelTextureBinding;\n readonly normal?: GpuModelTextureBinding;\n readonly occlusion?: GpuModelTextureBinding;\n readonly emissive?: GpuModelTextureBinding;\n readonly transmission?: GpuModelTextureBinding;\n readonly clearcoat?: GpuModelTextureBinding;\n readonly clearcoatRoughness?: GpuModelTextureBinding;\n readonly clearcoatNormal?: GpuModelTextureBinding;\n readonly sheenColor?: GpuModelTextureBinding;\n readonly sheenRoughness?: GpuModelTextureBinding;\n}\n\nexport interface GpuModelMaterial {\n readonly id: string;\n readonly name?: string;\n readonly workflow: GpuModelMaterialWorkflow;\n readonly alphaMode: GpuModelAlphaMode;\n readonly alphaCutoff?: number;\n readonly doubleSided?: boolean;\n readonly baseColorFactor: GpuModelVec4;\n readonly metallicFactor?: number;\n readonly roughnessFactor?: number;\n readonly emissiveFactor?: GpuModelVec3;\n readonly transmissionFactor?: number;\n readonly clearcoatFactor?: number;\n readonly clearcoatRoughnessFactor?: number;\n readonly sheenColorFactor?: GpuModelVec3;\n readonly sheenRoughnessFactor?: number;\n readonly normalScale?: number;\n readonly occlusionStrength?: number;\n readonly textures: GpuModelMaterialTextures;\n readonly extensions: GpuModelMetadata;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelTextureWrap = \"repeat\" | \"mirrored-repeat\" | \"clamp-to-edge\";\nexport interface GpuModelTextureSampler {\n readonly id: string;\n readonly wrapS?: GpuModelTextureWrap;\n readonly wrapT?: GpuModelTextureWrap;\n readonly minFilter?: string;\n readonly magFilter?: string;\n readonly mipFilter?: \"nearest\" | \"linear\";\n}\n\nexport type GpuModelTextureEmbeddingPolicy = \"inherit-source\" | \"prefer-embedded\" | \"prefer-external\" | \"forbid-embedding\";\n\n/** Texture fidelity node; embedded bytes are addressed through imageResourceId. */\nexport interface GpuModelTexture {\n readonly id: string;\n readonly fileName?: string;\n readonly relativePath?: string;\n readonly mimeType?: string;\n readonly contentHash: string;\n readonly imageResourceId: string;\n readonly byteLength?: number;\n readonly intendedUsage: readonly GpuModelTextureUsage[];\n readonly colorSpace: GpuModelTextureColorSpace;\n readonly sampler?: GpuModelTextureSampler;\n readonly exportEmbeddingPolicy: GpuModelTextureEmbeddingPolicy;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelSkeleton {\n readonly id: string;\n readonly name?: string;\n readonly jointIds: readonly string[];\n readonly rootJointIds: readonly string[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelJoint {\n readonly id: string;\n readonly name?: string;\n readonly nodeId: string;\n readonly parentJointId?: string;\n readonly restLocalTransform: GpuModelTransformTrs;\n readonly inverseBindMatrix?: GpuModelMatrix4;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelVertexWeightSet {\n readonly primitiveId: string;\n readonly influencesPerVertex: number;\n readonly joints: readonly (readonly number[])[];\n readonly weights: readonly (readonly number[])[];\n}\n\nexport interface GpuModelSkin {\n readonly id: string;\n readonly skeletonId: string;\n readonly jointIds: readonly string[];\n readonly inverseBindMatrices: readonly GpuModelMatrix4[];\n readonly weightSets: readonly GpuModelVertexWeightSet[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelBlendShapeDelta {\n readonly primitiveId: string;\n readonly positionAccessorId?: string;\n readonly normalAccessorId?: string;\n readonly tangentAccessorId?: string;\n}\n\nexport interface GpuModelBlendShape {\n readonly id: string;\n readonly meshId: string;\n readonly name?: string;\n readonly defaultWeight?: number;\n readonly deltas: readonly GpuModelBlendShapeDelta[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelAnimationInterpolation = \"step\" | \"linear\" | \"cubic-spline\";\nexport interface GpuModelAnimationSampler {\n readonly id: string;\n readonly inputAccessorId: string;\n readonly outputAccessorId: string;\n readonly inputTimesSeconds: readonly number[];\n readonly outputValues: readonly number[];\n readonly interpolation: GpuModelAnimationInterpolation;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelAnimationTargetType = \"node-translation\" | \"node-rotation\" | \"node-scale\" | \"weights\";\nexport interface GpuModelAnimationChannel {\n readonly id: string;\n readonly samplerId: string;\n readonly targetType: GpuModelAnimationTargetType;\n readonly targetId: string;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelAnimation {\n readonly id: string;\n readonly name?: string;\n readonly durationSeconds: number;\n readonly samplers: readonly GpuModelAnimationSampler[];\n readonly channels: readonly GpuModelAnimationChannel[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelSourceUnit = \"metre\" | \"millimetre\" | \"centimetre\" | \"inch\" | \"foot\" | \"unitless\";\nexport interface GpuModelAnalyticGeometry {\n readonly id: string;\n readonly kind: \"brep-placeholder\";\n readonly sourceResourceId: string;\n readonly sourceUnit: GpuModelSourceUnit;\n readonly tessellatedMeshId?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport interface GpuModelProvenance {\n readonly sourceFormat: string;\n readonly sourceContentHash: string;\n readonly converterId: string;\n readonly converterVersion: string;\n readonly provider?: string;\n readonly sourceIdentifier?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelDiagnosticSeverity = \"info\" | \"warning\" | \"error\";\nexport interface GpuModelDiagnostic {\n readonly severity: GpuModelDiagnosticSeverity;\n readonly code: string;\n readonly message: string;\n readonly path?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\n/** Complete immutable renderer-neutral canonical model document v1. */\nexport interface GpuModelDocument {\n readonly schemaVersion: typeof GPU_MODEL_DOCUMENT_SCHEMA_VERSION;\n readonly coordinateSystem: typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n readonly roots: readonly string[];\n readonly nodes: readonly GpuModelNode[];\n readonly resources: readonly GpuModelResource[];\n readonly accessors: readonly GpuModelAccessor[];\n readonly meshes: readonly GpuModelMesh[];\n readonly materials: readonly GpuModelMaterial[];\n readonly textures: readonly GpuModelTexture[];\n readonly skeletons: readonly GpuModelSkeleton[];\n readonly joints: readonly GpuModelJoint[];\n readonly skins: readonly GpuModelSkin[];\n readonly blendShapes: readonly GpuModelBlendShape[];\n readonly animations: readonly GpuModelAnimation[];\n readonly analyticGeometry: readonly GpuModelAnalyticGeometry[];\n readonly bounds: GpuModelBounds;\n readonly provenance: GpuModelProvenance;\n readonly diagnostics: readonly GpuModelDiagnostic[];\n readonly metadata: GpuModelMetadata;\n}\n\ntype UnknownRecord = Record<string, unknown>;\ntype VerificationLimits = Readonly<GpuModelResourceVerificationLimits>;\n\nconst PROHIBITED_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\nconst IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;\nconst METADATA_KEY = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/u;\nconst TOKEN = /^[A-Za-z0-9][A-Za-z0-9.+_-]{0,127}$/u;\nconst ATTRIBUTE_SEMANTIC = /^(?:POSITION|NORMAL|TANGENT|TEXCOORD_[0-7]|COLOR_[0-7]|JOINTS_[0-7]|WEIGHTS_[0-7]|_[A-Z][A-Z0-9_]{0,62})$/u;\nconst SHA_256 = /^[a-f0-9]{64}$/u;\nconst MIME_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,63}\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,63}$/u;\nconst RELATIVE_PATH = /^(?!\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))(?!.*\\\\)(?![a-z][a-z0-9+.-]*:).{1,2048}$/iu;\nconst FILE_NAME = /^(?!\\.{1,2}$)(?!.*[\\\\/]).{1,512}$/u;\nconst GPU_FLOAT_MAX = 3.402_823_466_385_288_6e38;\nconst EPSILON = 1e-5;\nconst BOUNDS_ABSOLUTE_EPSILON = 1e-5;\nconst COMPONENT_BYTES: Readonly<Record<GpuModelAccessorComponentType, number>> = Object.freeze({\n i8: 1, u8: 1, i16: 2, u16: 2, u32: 4, f32: 4,\n});\nconst ELEMENT_COMPONENTS: Readonly<Record<GpuModelAccessorElementType, number>> = Object.freeze({\n scalar: 1, vec2: 2, vec3: 3, vec4: 4, mat2: 4, mat3: 9, mat4: 16,\n});\nconst COMPONENT_RANGES: Readonly<Record<GpuModelAccessorComponentType, readonly [number, number, boolean]>> = Object.freeze({\n i8: [-128, 127, true],\n u8: [0, 255, true],\n i16: [-32_768, 32_767, true],\n u16: [0, 65_535, true],\n u32: [0, 4_294_967_295, true],\n f32: [-GPU_FLOAT_MAX, GPU_FLOAT_MAX, false],\n});\nconst IMAGE_MIME_TYPES = new Set([\"image/jpeg\", \"image/ktx2\", \"image/png\", \"image/webp\"]);\nconst BUFFER_MIME_TYPES = new Set([\"application/octet-stream\", \"application/vnd.plasius.gpu-buffer\"]);\nconst TEXTURE_USAGES: readonly GpuModelTextureUsage[] = Object.freeze([\n \"base-color\", \"metallic-roughness\", \"normal\", \"occlusion\", \"emissive\", \"transmission\",\n \"clearcoat\", \"clearcoat-roughness\", \"clearcoat-normal\", \"sheen-color\", \"sheen-roughness\",\n]);\nconst MATERIAL_TEXTURE_SLOTS = Object.freeze({\n baseColor: \"base-color\",\n metallicRoughness: \"metallic-roughness\",\n normal: \"normal\",\n occlusion: \"occlusion\",\n emissive: \"emissive\",\n transmission: \"transmission\",\n clearcoat: \"clearcoat\",\n clearcoatRoughness: \"clearcoat-roughness\",\n clearcoatNormal: \"clearcoat-normal\",\n sheenColor: \"sheen-color\",\n sheenRoughness: \"sheen-roughness\",\n} as const satisfies Readonly<Record<keyof GpuModelMaterialTextures, GpuModelTextureUsage>>);\n\nconst verifiedResources = new WeakSet<object>();\nconst verifiedResourceBytes = new WeakMap<object, Uint8Array>();\nconst verifiedResourceEvidence = new WeakMap<object, GpuModelResourceInspection>();\nconst validatedDocuments = new WeakSet<object>();\n\ninterface DocumentBudget {\n metadataValues: number;\n sceneEdges: number;\n primitiveAttributes: number;\n accessorElements: number;\n primitives: number;\n skinJoints: number;\n weightVertices: number;\n weightInfluences: number;\n animationSamplers: number;\n animationChannels: number;\n animationValues: number;\n blendShapeDeltas: number;\n blendShapeAccessorReferences: number;\n geometryIndexElements: number;\n geometryWorldAccessorInstances: number;\n geometryWorldVertices: number;\n}\n\nfunction fail(code: GpuModelDocumentErrorCode, path: string, detail: string): never {\n throw new GpuModelDocumentError(code, path, detail);\n}\n\nfunction readRecord(value: unknown, path: string, allowedKeys: readonly string[]): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return fail(\"invalid-type\", path, \"expected an object\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return fail(\"invalid-type\", path, \"expected a plain object\");\n }\n const allowed = new Set(allowedKeys);\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") return fail(\"unknown-key\", path, \"symbol keys are not permitted\");\n if (PROHIBITED_KEYS.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"prohibited object key\");\n if (!allowed.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"unknown key\");\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) {\n return fail(\"invalid-type\", `${path}.${key}`, \"properties must be enumerable data properties\");\n }\n }\n return value as UnknownRecord;\n}\n\nfunction requireKey(record: UnknownRecord, key: string, path: string): unknown {\n if (!Object.hasOwn(record, key)) return fail(\"invalid-value\", `${path}.${key}`, \"required key is missing\");\n return record[key];\n}\n\nfunction readArray(value: unknown, path: string, maximum: number, minimum = 0): readonly unknown[] {\n if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) {\n return fail(\"invalid-type\", path, \"expected an array\");\n }\n if (value.length < minimum || value.length > maximum) {\n return fail(\"limit-exceeded\", path, `array length must be between ${minimum} and ${maximum}`);\n }\n for (let index = 0; index < value.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) {\n return fail(\"invalid-type\", `${path}[${index}]`, \"array entries must be enumerable data properties\");\n }\n }\n for (const key of Reflect.ownKeys(value)) {\n if (key === \"length\") continue;\n if (typeof key === \"string\" && /^(?:0|[1-9][0-9]*)$/u.test(key) && Number(key) < value.length) continue;\n return fail(\"unknown-key\", path, \"array properties and symbol keys are not permitted\");\n }\n return value;\n}\n\nfunction hasInvalidText(value: string): boolean {\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index);\n if (code <= 0x1f || (code >= 0x7f && code <= 0x9f) || code === 0x2028 || code === 0x2029) return true;\n if (code >= 0xd800 && code <= 0xdbff) {\n const trailing = value.charCodeAt(index + 1);\n if (!Number.isInteger(trailing) || trailing < 0xdc00 || trailing > 0xdfff) return true;\n index += 1;\n } else if (code >= 0xdc00 && code <= 0xdfff) return true;\n }\n return false;\n}\n\nfunction readString(value: unknown, path: string, maximum: number, pattern?: RegExp): string {\n if (typeof value !== \"string\") return fail(\"invalid-type\", path, \"expected a string\");\n if (value.length === 0 || value.length > maximum) {\n return fail(\"limit-exceeded\", path, `string length must be between 1 and ${maximum}`);\n }\n if (hasInvalidText(value)) return fail(\"invalid-value\", path, \"string must contain well-formed text without control characters\");\n if (pattern && !pattern.test(value)) return fail(\"invalid-value\", path, \"string has an invalid format\");\n return value;\n}\n\nfunction readId(value: unknown, path: string): string {\n return readString(value, path, GPU_MODEL_DOCUMENT_LIMITS.identifierLength, IDENTIFIER);\n}\n\nfunction readSha256(value: unknown, path: string): string {\n if (typeof value !== \"string\" || !SHA_256.test(value)) {\n return fail(\"invalid-value\", path, \"expected a lowercase hexadecimal SHA-256 digest\");\n }\n return value;\n}\n\nfunction readBoolean(value: unknown, path: string): boolean {\n if (typeof value !== \"boolean\") return fail(\"invalid-type\", path, \"expected a boolean\");\n return value;\n}\n\nfunction readFinite(value: unknown, path: string, minimum?: number, maximum?: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return fail(\"invalid-value\", path, \"expected a finite number\");\n const lower = minimum ?? -GPU_FLOAT_MAX;\n const upper = maximum ?? GPU_FLOAT_MAX;\n if (value < lower || value > upper) return fail(\"invalid-value\", path, `number must be between ${String(lower)} and ${String(upper)}`);\n return Object.is(value, -0) ? 0 : value;\n}\n\nfunction readSafeInteger(value: unknown, path: string, minimum = 0, maximum = Number.MAX_SAFE_INTEGER): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < minimum || value > maximum) {\n return fail(\"invalid-value\", path, `expected a safe integer between ${minimum} and ${maximum}`);\n }\n return value;\n}\n\nfunction readEnum<T extends string>(value: unknown, path: string, allowed: readonly T[]): T {\n if (typeof value !== \"string\" || !(allowed as readonly string[]).includes(value)) {\n return fail(\"invalid-value\", path, `expected one of: ${allowed.join(\", \")}`);\n }\n return value as T;\n}\n\nfunction readNumberTuple(value: unknown, path: string, length: number, minimum?: number, maximum?: number): readonly number[] {\n const input = readArray(value, path, length, length);\n return Object.freeze(input.map((entry, index) => readFinite(entry, `${path}[${index}]`, minimum, maximum)));\n}\n\nfunction readOptional<T>(record: UnknownRecord, key: string, parser: (value: unknown, path: string) => T, path: string): T | undefined {\n if (!Object.hasOwn(record, key)) return undefined;\n return parser(record[key], `${path}.${key}`);\n}\n\nfunction assignOptional<T extends object, K extends PropertyKey, V>(target: T, key: K, value: V | undefined): void {\n if (value !== undefined) Object.assign(target, { [key]: value });\n}\n\nfunction consumeBudget(budget: DocumentBudget, key: keyof DocumentBudget, amount: number, maximum: number, path: string, label: string): void {\n budget[key] += amount;\n if (!Number.isSafeInteger(budget[key]) || budget[key] > maximum) {\n return fail(\"limit-exceeded\", path, `document ${label} count exceeds the limit`);\n }\n}\n\nfunction readMetadataValue(value: unknown, path: string, depth: number, budget: DocumentBudget): GpuModelMetadataValue {\n consumeBudget(budget, \"metadataValues\", 1, GPU_MODEL_DOCUMENT_LIMITS.metadataValues, path, \"metadata value\");\n if (value === null || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return readFinite(value, path);\n if (typeof value === \"string\") return readString(value, path, GPU_MODEL_DOCUMENT_LIMITS.metadataStringLength);\n if (depth >= GPU_MODEL_DOCUMENT_LIMITS.metadataDepth) return fail(\"limit-exceeded\", path, \"metadata nesting is too deep\");\n if (Array.isArray(value)) {\n const input = readArray(value, path, GPU_MODEL_DOCUMENT_LIMITS.metadataArrayLength);\n return Object.freeze(input.map((entry, index) => readMetadataValue(entry, `${path}[${index}]`, depth + 1, budget)));\n }\n if (typeof value !== \"object\" || value === null) return fail(\"invalid-type\", path, \"metadata value is not JSON-compatible\");\n const record = value as object;\n const prototype = Object.getPrototypeOf(record);\n if (prototype !== Object.prototype && prototype !== null) return fail(\"invalid-type\", path, \"metadata objects must be plain objects\");\n const keys = Reflect.ownKeys(record);\n if (keys.length > GPU_MODEL_DOCUMENT_LIMITS.metadataObjectKeys) return fail(\"limit-exceeded\", path, \"metadata object has too many keys\");\n const output: Record<string, GpuModelMetadataValue> = {};\n for (const key of keys) {\n if (typeof key !== \"string\") return fail(\"unknown-key\", path, \"metadata symbol keys are not permitted\");\n if (PROHIBITED_KEYS.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"prohibited metadata key\");\n readString(key, `${path}.[key]`, GPU_MODEL_DOCUMENT_LIMITS.metadataKeyLength, METADATA_KEY);\n const descriptor = Object.getOwnPropertyDescriptor(record, key);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) return fail(\"invalid-type\", `${path}.${key}`, \"metadata properties must be enumerable data properties\");\n output[key] = readMetadataValue(descriptor.value, `${path}.${key}`, depth + 1, budget);\n }\n return Object.freeze(output);\n}\n\nfunction readMetadata(value: unknown, path: string, budget: DocumentBudget): GpuModelMetadata {\n const parsed = readMetadataValue(value, path, 0, budget);\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return fail(\"invalid-type\", path, \"metadata must be an object\");\n return parsed as GpuModelMetadata;\n}\n\nfunction parseCoordinateSystem(value: unknown): typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM {\n const path = \"$.coordinateSystem\";\n const record = readRecord(value, path, [\"unit\", \"upAxis\", \"forwardAxis\", \"handedness\", \"winding\", \"origin\"]);\n for (const [key, expected] of Object.entries(CANONICAL_GPU_MODEL_COORDINATE_SYSTEM)) {\n if (requireKey(record, key, path) !== expected) return fail(\"invalid-value\", `${path}.${key}`, \"coordinate system is not canonical\");\n }\n return CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n}\n\nfunction parseMatrix(value: unknown, path: string, requireAffine = true): GpuModelMatrix4 {\n const matrix = readNumberTuple(value, path, 16) as GpuModelMatrix4;\n if (requireAffine && (matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1)) {\n return fail(\"invalid-value\", path, \"matrix must be affine, with a [0, 0, 0, 1] projective row\");\n }\n return matrix;\n}\n\nfunction parseBounds(value: unknown, path: string): GpuModelBounds {\n const record = readRecord(value, path, [\"min\", \"max\"]);\n const min = readNumberTuple(requireKey(record, \"min\", path), `${path}.min`, 3) as GpuModelVec3;\n const max = readNumberTuple(requireKey(record, \"max\", path), `${path}.max`, 3) as GpuModelVec3;\n for (let index = 0; index < 3; index += 1) {\n if (min[index]! > max[index]!) return fail(\"invalid-value\", path, \"bounds min cannot exceed max\");\n }\n return { min, max };\n}\n\nfunction parseTransformTrs(value: unknown, path: string): GpuModelTransformTrs {\n const record = readRecord(value, path, [\"translation\", \"rotation\", \"scale\"]);\n const translation = readNumberTuple(requireKey(record, \"translation\", path), `${path}.translation`, 3) as GpuModelVec3;\n const rotation = readNumberTuple(requireKey(record, \"rotation\", path), `${path}.rotation`, 4) as GpuModelVec4;\n const scale = readNumberTuple(requireKey(record, \"scale\", path), `${path}.scale`, 3) as GpuModelVec3;\n const magnitude = Math.hypot(...rotation);\n if (!almostEqual(magnitude, 1, 1e-4)) return fail(\"invalid-value\", `${path}.rotation`, \"rotation quaternion must be normalized\");\n return { translation, rotation, scale };\n}\n\nconst blobSizeGetter = Object.getOwnPropertyDescriptor(Blob.prototype, \"size\")!.get!;\nconst blobTypeGetter = Object.getOwnPropertyDescriptor(Blob.prototype, \"type\")!.get!;\nconst blobSlice = Blob.prototype.slice;\nconst blobArrayBuffer = Blob.prototype.arrayBuffer;\n\nfunction intrinsicBlobSize(blob: Blob): number {\n return Reflect.apply(blobSizeGetter, blob, []) as number;\n}\n\nfunction intrinsicBlobType(blob: Blob): string {\n return Reflect.apply(blobTypeGetter, blob, []) as string;\n}\n\nfunction intrinsicBlobSlice(blob: Blob, start: number, end: number, contentType?: string): Blob {\n return Reflect.apply(blobSlice, blob, contentType === undefined ? [start, end] : [start, end, contentType]) as Blob;\n}\n\nfunction intrinsicBlobArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\n return Reflect.apply(blobArrayBuffer, blob, []) as Promise<ArrayBuffer>;\n}\n\nfunction parseResourceHeader(value: unknown, path: string): GpuModelResource {\n const record = readRecord(value, path, [\"id\", \"kind\", \"contentHash\", \"byteLength\", \"mimeType\", \"payload\"]);\n const kind = readEnum(requireKey(record, \"kind\", path), `${path}.kind`, [\"buffer\", \"image\"] as const);\n const mimeType = readString(requireKey(record, \"mimeType\", path), `${path}.mimeType`, 128, MIME_TYPE).toLowerCase();\n if (kind === \"image\" ? !IMAGE_MIME_TYPES.has(mimeType) : !BUFFER_MIME_TYPES.has(mimeType)) {\n return fail(\"invalid-value\", `${path}.mimeType`, `unsupported ${kind} MIME type`);\n }\n const payload = requireKey(record, \"payload\", path);\n if (!(payload instanceof Blob)) return fail(\"invalid-type\", `${path}.payload`, \"expected an immutable Blob payload\");\n if (Object.getPrototypeOf(payload) !== Blob.prototype || Reflect.ownKeys(payload).some((key) => typeof key === \"string\")) {\n return fail(\"invalid-type\", `${path}.payload`, \"expected a native Blob without caller-defined properties\");\n }\n const byteLength = readSafeInteger(requireKey(record, \"byteLength\", path), `${path}.byteLength`, 1);\n if (intrinsicBlobSize(payload) !== byteLength) return fail(\"payload-length-mismatch\", `${path}.payload`, \"payload byte length does not match byteLength\");\n const payloadType = intrinsicBlobType(payload);\n if (payloadType && payloadType.toLowerCase() !== mimeType) return fail(\"invalid-value\", `${path}.payload`, \"payload MIME type does not match mimeType\");\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n kind,\n contentHash: readSha256(requireKey(record, \"contentHash\", path), `${path}.contentHash`),\n byteLength,\n mimeType,\n payload,\n };\n}\n\nfunction resolveVerificationLimits(options?: GpuModelResourceVerificationOptions): VerificationLimits {\n const overrides = options?.limits;\n if (overrides === undefined) return GPU_MODEL_RESOURCE_VERIFICATION_LIMITS;\n const record = readRecord(overrides, \"$.verification.limits\", Object.keys(GPU_MODEL_RESOURCE_VERIFICATION_LIMITS));\n const output = { ...GPU_MODEL_RESOURCE_VERIFICATION_LIMITS };\n for (const [key, ceiling] of Object.entries(GPU_MODEL_RESOURCE_VERIFICATION_LIMITS) as Array<[keyof VerificationLimits, number]>) {\n if (!Object.hasOwn(record, key)) continue;\n const value = readSafeInteger(record[key], `$.verification.limits.${key}`, 1, ceiling);\n Object.assign(output, { [key]: value });\n }\n if (output.maxImageBytes > output.maxResourceBytes) output.maxImageBytes = output.maxResourceBytes;\n if (output.maxAggregateImageBytes > output.maxAggregateBytes) output.maxAggregateImageBytes = output.maxAggregateBytes;\n return Object.freeze(output);\n}\n\nfunction preflightResourceBudget(resources: readonly GpuModelResource[], limits: VerificationLimits): void {\n let aggregate = 0;\n let aggregateImages = 0;\n for (let index = 0; index < resources.length; index += 1) {\n const resource = resources[index]!;\n const path = `$.resources[${index}]`;\n if (resource.byteLength > limits.maxResourceBytes) return fail(\"resource-budget-exceeded\", `${path}.byteLength`, \"resource byte budget exceeded\");\n if (resource.kind === \"image\" && resource.byteLength > limits.maxImageBytes) {\n return fail(\"resource-budget-exceeded\", `${path}.byteLength`, \"image resource byte budget exceeded\");\n }\n aggregate += resource.byteLength;\n if (!Number.isSafeInteger(aggregate) || aggregate > limits.maxAggregateBytes) {\n return fail(\"resource-budget-exceeded\", \"$.resources\", \"aggregate resource byte budget exceeded\");\n }\n if (resource.kind === \"image\") {\n aggregateImages += resource.byteLength;\n if (!Number.isSafeInteger(aggregateImages) || aggregateImages > limits.maxAggregateImageBytes) {\n return fail(\"resource-budget-exceeded\", \"$.resources\", \"aggregate image byte budget exceeded\");\n }\n }\n }\n}\n\nfunction assertVerifiedResourceEvidence(\n resource: GpuModelResource,\n limits: VerificationLimits,\n path: string,\n): void {\n const evidence = verifiedResourceEvidence.get(resource);\n if (!evidence) return fail(\"resource-unverified\", path, \"verified resource inspection evidence is unavailable\");\n if (resource.kind !== \"image\") return;\n const width = evidence.width;\n const height = evidence.height;\n if (width === undefined || height === undefined) {\n return fail(\"resource-verification-failed\", path, \"verified image inspection evidence is incomplete\");\n }\n if (width > limits.maxImageDimension || height > limits.maxImageDimension || width * height > limits.maxImagePixels) {\n return fail(\"resource-budget-exceeded\", path, \"image dimension budget exceeded\");\n }\n}\n\nfunction cachedResourceWithinLimits(\n resource: GpuModelResource,\n limits: VerificationLimits,\n path: string,\n): GpuModelResource {\n preflightResourceBudget([resource], limits);\n assertVerifiedResourceEvidence(resource, limits, path);\n return resource;\n}\n\nfunction verificationAbortError(signal: AbortSignal, path: string): GpuModelDocumentError {\n return signal.reason instanceof GpuModelDocumentError\n ? signal.reason\n : new GpuModelDocumentError(\"resource-verification-failed\", path, \"resource verification was aborted\");\n}\n\nfunction throwIfVerificationAborted(signal: AbortSignal, path: string): void {\n if (signal.aborted) throw verificationAbortError(signal, path);\n}\n\nfunction createBlobChunks(\n blob: Blob,\n chunkBytes: number,\n observed: { bytes: number },\n signal: AbortSignal,\n path: string,\n snapshot?: Uint8Array,\n): AsyncIterable<Uint8Array> {\n return {\n async *[Symbol.asyncIterator]() {\n const size = intrinsicBlobSize(blob);\n for (let offset = 0; offset < size; offset += chunkBytes) {\n throwIfVerificationAborted(signal, path);\n const end = Math.min(size, offset + chunkBytes);\n const chunk = new Uint8Array(await intrinsicBlobArrayBuffer(intrinsicBlobSlice(blob, offset, end)));\n throwIfVerificationAborted(signal, path);\n observed.bytes += chunk.byteLength;\n if (snapshot) snapshot.set(chunk, offset);\n yield chunk;\n }\n throwIfVerificationAborted(signal, path);\n },\n };\n}\n\ninterface VerificationDeadline {\n readonly signal: AbortSignal;\n race<T>(operation: () => Promise<T> | T): Promise<T>;\n throwIfAborted(): void;\n dispose(): void;\n}\n\nfunction createVerificationDeadline(timeoutMs: number, callerSignal: AbortSignal | undefined, path: string): VerificationDeadline {\n const controller = new AbortController();\n const abort = (detail: string): void => {\n if (!controller.signal.aborted) {\n controller.abort(new GpuModelDocumentError(\"resource-verification-failed\", path, detail));\n }\n };\n const callerAbort = (): void => abort(\"resource verification was aborted\");\n if (callerSignal?.aborted) callerAbort();\n else callerSignal?.addEventListener(\"abort\", callerAbort, { once: true });\n const timeout = setTimeout(() => abort(\"resource verification deadline exceeded\"), timeoutMs);\n timeout.unref?.();\n return {\n signal: controller.signal,\n async race<T>(operation: () => Promise<T> | T): Promise<T> {\n throwIfVerificationAborted(controller.signal, path);\n let abortListener: (() => void) | undefined;\n const aborted = new Promise<never>((_resolve, reject) => {\n abortListener = () => reject(verificationAbortError(controller.signal, path));\n controller.signal.addEventListener(\"abort\", abortListener, { once: true });\n if (controller.signal.aborted) abortListener();\n });\n try {\n const running = Promise.resolve().then(() => {\n throwIfVerificationAborted(controller.signal, path);\n return operation();\n });\n return await Promise.race([running, aborted]);\n } finally {\n if (abortListener) controller.signal.removeEventListener(\"abort\", abortListener);\n }\n },\n throwIfAborted(): void {\n throwIfVerificationAborted(controller.signal, path);\n },\n dispose(): void {\n clearTimeout(timeout);\n callerSignal?.removeEventListener(\"abort\", callerAbort);\n },\n };\n}\n\nfunction parseInspection(value: unknown, path: string): GpuModelResourceInspection {\n const record = readRecord(value, path, [\"valid\", \"detectedMimeType\", \"width\", \"height\"]);\n const output: Record<string, unknown> = {\n valid: readBoolean(requireKey(record, \"valid\", path), `${path}.valid`),\n detectedMimeType: readString(requireKey(record, \"detectedMimeType\", path), `${path}.detectedMimeType`, 128, MIME_TYPE).toLowerCase(),\n };\n assignOptional(output, \"width\", readOptional(record, \"width\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n assignOptional(output, \"height\", readOptional(record, \"height\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n return output as unknown as GpuModelResourceInspection;\n}\n\nfunction bytesStartWith(bytes: Uint8Array, signature: readonly number[]): boolean {\n return bytes.byteLength >= signature.length && signature.every((value, index) => bytes[index] === value);\n}\n\nfunction validateImageMagic(resource: GpuModelResource, bytes: Uint8Array, inspection: GpuModelResourceInspection, path: string): void {\n if (inspection.width === undefined || inspection.height === undefined) {\n return fail(\"resource-verification-failed\", path, \"image inspection must report dimensions\");\n }\n let signatureValid = false;\n if (resource.mimeType === \"image/png\") {\n signatureValid = bytes.byteLength >= 24 && bytesStartWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);\n if (signatureValid) {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (view.getUint32(16) !== inspection.width || view.getUint32(20) !== inspection.height) {\n return fail(\"resource-verification-failed\", path, \"image dimensions disagree with the PNG header\");\n }\n }\n } else if (resource.mimeType === \"image/jpeg\") {\n signatureValid = bytes.byteLength >= 4 && bytesStartWith(bytes, [0xff, 0xd8, 0xff]) && bytes.at(-2) === 0xff && bytes.at(-1) === 0xd9;\n } else if (resource.mimeType === \"image/webp\") {\n signatureValid = bytes.byteLength >= 16\n && bytesStartWith(bytes, [0x52, 0x49, 0x46, 0x46])\n && String.fromCharCode(...bytes.subarray(8, 12)) === \"WEBP\";\n } else if (resource.mimeType === \"image/ktx2\") {\n signatureValid = bytesStartWith(bytes, [0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a]);\n }\n if (!signatureValid) return fail(\"resource-verification-failed\", path, \"image signature is invalid for the declared MIME type\");\n}\n\nasync function verifyParsedResource(\n resource: GpuModelResource,\n port: GpuModelResourceVerificationPort,\n limits: VerificationLimits,\n options?: GpuModelResourceVerificationOptions,\n path = \"$.resource\",\n): Promise<GpuModelResource> {\n if (options?.signal?.aborted) return fail(\"resource-verification-failed\", path, \"resource verification was aborted\");\n if (verifiedResources.has(resource) && verifiedResourceBytes.has(resource)) {\n return cachedResourceWithinLimits(resource, limits, path);\n }\n preflightResourceBudget([resource], limits);\n if (typeof port !== \"object\" || port === null || typeof port.inspectResource !== \"function\" || typeof port.digestSha256 !== \"function\") {\n return fail(\"invalid-type\", \"$.verificationPort\", \"expected digest and inspection functions\");\n }\n const deadline = createVerificationDeadline(limits.timeoutMs, options?.signal, path);\n try {\n const context: GpuModelResourceVerificationContext = Object.freeze({\n resourceId: resource.id,\n kind: resource.kind,\n declaredMimeType: resource.mimeType,\n byteLength: resource.byteLength,\n signal: deadline.signal,\n });\n const inspectionObserved = { bytes: 0 };\n let inspectionValue: unknown;\n try {\n inspectionValue = await deadline.race(() => port.inspectResource(\n createBlobChunks(resource.payload, limits.chunkBytes, inspectionObserved, deadline.signal, path),\n context,\n ));\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n deadline.throwIfAborted();\n return fail(\"resource-verification-failed\", path, \"resource inspection failed\");\n }\n deadline.throwIfAborted();\n if (inspectionObserved.bytes !== resource.byteLength) return fail(\"resource-verification-failed\", path, \"resource inspection did not consume the complete payload\");\n const inspection = parseInspection(inspectionValue, `${path}.inspection`);\n if (!inspection.valid) return fail(\"resource-verification-failed\", path, \"resource inspection rejected the payload\");\n if (inspection.detectedMimeType !== resource.mimeType) return fail(\"resource-verification-failed\", path, \"detected MIME type does not match the declaration\");\n if (resource.kind === \"image\") {\n const width = inspection.width;\n const height = inspection.height;\n if (width === undefined || height === undefined) return fail(\"resource-verification-failed\", path, \"image inspection did not report dimensions\");\n if (width > limits.maxImageDimension || height > limits.maxImageDimension || width * height > limits.maxImagePixels) {\n return fail(\"resource-budget-exceeded\", path, \"image dimension budget exceeded\");\n }\n } else if (inspection.width !== undefined || inspection.height !== undefined) {\n return fail(\"resource-verification-failed\", path, \"buffer inspection must not report image dimensions\");\n }\n const snapshot = new Uint8Array(resource.byteLength);\n const digestObserved = { bytes: 0 };\n let digest: unknown;\n try {\n digest = await deadline.race(() => port.digestSha256(\n createBlobChunks(resource.payload, limits.chunkBytes, digestObserved, deadline.signal, path, snapshot),\n context,\n ));\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n deadline.throwIfAborted();\n return fail(\"resource-verification-failed\", path, \"resource digest verification failed\");\n }\n deadline.throwIfAborted();\n if (digestObserved.bytes !== resource.byteLength) return fail(\"resource-verification-failed\", path, \"resource digest did not consume the complete payload\");\n if (typeof digest !== \"string\" || !SHA_256.test(digest) || digest !== resource.contentHash) {\n return fail(\"resource-verification-failed\", path, \"resource digest does not match contentHash\");\n }\n if (resource.kind === \"image\") validateImageMagic(resource, snapshot, inspection, path);\n const verified = Object.freeze({\n ...resource,\n payload: new Blob([snapshot], { type: resource.mimeType }),\n });\n verifiedResources.add(verified);\n verifiedResourceBytes.set(verified, snapshot);\n verifiedResourceEvidence.set(verified, Object.freeze({ ...inspection }));\n return verified;\n } finally {\n deadline.dispose();\n }\n}\n\n/** Verifies one bounded resource and returns a privately branded immutable value. */\nexport async function verifyGpuModelResource(\n value: unknown,\n port: GpuModelResourceVerificationPort,\n options?: GpuModelResourceVerificationOptions,\n): Promise<GpuModelResource> {\n try {\n const limits = resolveVerificationLimits(options);\n const resource = typeof value === \"object\"\n && value !== null\n && verifiedResources.has(value)\n && verifiedResourceBytes.has(value)\n ? value as GpuModelResource\n : parseResourceHeader(value, \"$.resource\");\n return await verifyParsedResource(resource, port, limits, options);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$.resource\", \"resource could not be safely inspected\");\n }\n}\n\nfunction parseNode(value: unknown, path: string, budget: DocumentBudget): GpuModelNode {\n const record = readRecord(value, path, [\"id\", \"name\", \"children\", \"meshId\", \"skinId\", \"localMatrix\", \"metadata\"]);\n const children = Object.freeze(readArray(requireKey(record, \"children\", path), `${path}.children`, GPU_MODEL_DOCUMENT_LIMITS.nodes)\n .map((entry, index) => readId(entry, `${path}.children[${index}]`)));\n consumeBudget(budget, \"sceneEdges\", children.length, GPU_MODEL_DOCUMENT_LIMITS.sceneEdges, path, \"scene edge\");\n ensureUnique(children, `${path}.children`, \"duplicate child node\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n children,\n localMatrix: parseMatrix(requireKey(record, \"localMatrix\", path), `${path}.localMatrix`),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"meshId\", readOptional(record, \"meshId\", readId, path));\n assignOptional(output, \"skinId\", readOptional(record, \"skinId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelNode;\n}\n\nfunction parseAccessor(value: unknown, path: string, budget: DocumentBudget): GpuModelAccessor {\n const record = readRecord(value, path, [\"id\", \"resourceId\", \"byteOffset\", \"byteStride\", \"count\", \"componentType\", \"elementType\", \"normalized\", \"min\", \"max\"]);\n const componentType = readEnum(requireKey(record, \"componentType\", path), `${path}.componentType`, [\"i8\", \"u8\", \"i16\", \"u16\", \"u32\", \"f32\"] as const);\n const elementType = readEnum(requireKey(record, \"elementType\", path), `${path}.elementType`, [\"scalar\", \"vec2\", \"vec3\", \"vec4\", \"mat2\", \"mat3\", \"mat4\"] as const);\n const normalized = readOptional(record, \"normalized\", readBoolean, path);\n if (normalized === true && componentType === \"f32\") return fail(\"invalid-value\", `${path}.normalized`, \"floating-point accessors cannot be normalized\");\n if (elementType.startsWith(\"mat\") && componentType !== \"f32\") return fail(\"invalid-value\", `${path}.componentType`, \"matrix accessors must use f32 components\");\n const expectedComponents = ELEMENT_COMPONENTS[elementType];\n const min = readOptional(record, \"min\", (entry, entryPath) => readNumberTuple(entry, entryPath, expectedComponents), path);\n const max = readOptional(record, \"max\", (entry, entryPath) => readNumberTuple(entry, entryPath, expectedComponents), path);\n if ((min === undefined) !== (max === undefined)) return fail(\"invalid-value\", path, \"accessor min and max must be supplied together\");\n if (min && max) {\n const [componentMinimum, componentMaximum, integer] = COMPONENT_RANGES[componentType];\n for (let index = 0; index < expectedComponents; index += 1) {\n const minimum = min[index]!;\n const maximum = max[index]!;\n if (minimum > maximum) return fail(\"invalid-value\", path, \"accessor min cannot exceed max\");\n if (minimum < componentMinimum || maximum > componentMaximum || (integer && (!Number.isInteger(minimum) || !Number.isInteger(maximum)))) {\n return fail(\"invalid-value\", path, \"accessor bounds are outside the component representation\");\n }\n }\n }\n const count = readSafeInteger(requireKey(record, \"count\", path), `${path}.count`, 1, GPU_MODEL_DOCUMENT_LIMITS.weightVertices);\n consumeBudget(budget, \"accessorElements\", count * expectedComponents, GPU_MODEL_DOCUMENT_LIMITS.accessorElements, path, \"accessor element component\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n resourceId: readId(requireKey(record, \"resourceId\", path), `${path}.resourceId`),\n byteOffset: readSafeInteger(requireKey(record, \"byteOffset\", path), `${path}.byteOffset`),\n count,\n componentType,\n elementType,\n };\n assignOptional(output, \"byteStride\", readOptional(record, \"byteStride\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1, 2_048), path));\n assignOptional(output, \"normalized\", normalized);\n assignOptional(output, \"min\", min);\n assignOptional(output, \"max\", max);\n return output as unknown as GpuModelAccessor;\n}\n\nfunction parsePrimitive(value: unknown, path: string, budget: DocumentBudget): GpuModelPrimitive {\n const record = readRecord(value, path, [\"id\", \"topology\", \"attributes\", \"indicesAccessorId\", \"materialId\", \"metadata\"]);\n const attributesInput = readArray(requireKey(record, \"attributes\", path), `${path}.attributes`, 64, 1);\n consumeBudget(budget, \"primitiveAttributes\", attributesInput.length, GPU_MODEL_DOCUMENT_LIMITS.primitiveAttributes, path, \"primitive attribute\");\n const attributes = Object.freeze(attributesInput.map((entry, index) => {\n const entryPath = `${path}.attributes[${index}]`;\n const attribute = readRecord(entry, entryPath, [\"semantic\", \"accessorId\"]);\n return {\n semantic: readString(requireKey(attribute, \"semantic\", entryPath), `${entryPath}.semantic`, 64, ATTRIBUTE_SEMANTIC),\n accessorId: readId(requireKey(attribute, \"accessorId\", entryPath), `${entryPath}.accessorId`),\n };\n }));\n ensureUnique(attributes.map(({ semantic }) => semantic), `${path}.attributes`, \"duplicate attribute semantic\");\n if (!attributes.some(({ semantic }) => semantic === \"POSITION\")) return fail(\"invalid-value\", `${path}.attributes`, \"primitive requires POSITION\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n topology: readEnum(requireKey(record, \"topology\", path), `${path}.topology`, [\"points\", \"lines\", \"line-strip\", \"triangles\", \"triangle-strip\"] as const),\n attributes,\n };\n assignOptional(output, \"indicesAccessorId\", readOptional(record, \"indicesAccessorId\", readId, path));\n assignOptional(output, \"materialId\", readOptional(record, \"materialId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelPrimitive;\n}\n\nfunction parseMesh(value: unknown, path: string, budget: DocumentBudget): GpuModelMesh {\n const record = readRecord(value, path, [\"id\", \"name\", \"primitives\", \"metadata\"]);\n const input = readArray(requireKey(record, \"primitives\", path), `${path}.primitives`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n consumeBudget(budget, \"primitives\", input.length, GPU_MODEL_DOCUMENT_LIMITS.primitives, path, \"primitive\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n primitives: Object.freeze(input.map((entry, index) => parsePrimitive(entry, `${path}.primitives[${index}]`, budget))),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelMesh;\n}\n\nfunction parseTextureTransform(value: unknown, path: string): GpuModelTextureTransform {\n const record = readRecord(value, path, [\"offset\", \"rotationRadians\", \"scale\"]);\n if (Reflect.ownKeys(record).length === 0) return fail(\"invalid-value\", path, \"texture transform cannot be empty\");\n const output: Record<string, unknown> = {};\n assignOptional(output, \"offset\", readOptional(record, \"offset\", (entry, entryPath) => readNumberTuple(entry, entryPath, 2) as GpuModelVec2, path));\n assignOptional(output, \"rotationRadians\", readOptional(record, \"rotationRadians\", readFinite, path));\n assignOptional(output, \"scale\", readOptional(record, \"scale\", (entry, entryPath) => readNumberTuple(entry, entryPath, 2) as GpuModelVec2, path));\n return output as GpuModelTextureTransform;\n}\n\nfunction parseTextureBinding(value: unknown, path: string): GpuModelTextureBinding {\n const record = readRecord(value, path, [\"textureId\", \"samplerId\", \"texCoordSet\", \"transform\", \"colorSpace\", \"intendedUsage\"]);\n const output: Record<string, unknown> = {\n textureId: readId(requireKey(record, \"textureId\", path), `${path}.textureId`),\n colorSpace: readEnum(requireKey(record, \"colorSpace\", path), `${path}.colorSpace`, [\"srgb\", \"linear\", \"normal-map\", \"data\"] as const),\n intendedUsage: readEnum(requireKey(record, \"intendedUsage\", path), `${path}.intendedUsage`, TEXTURE_USAGES),\n };\n assignOptional(output, \"samplerId\", readOptional(record, \"samplerId\", readId, path));\n assignOptional(output, \"texCoordSet\", readOptional(record, \"texCoordSet\", (entry, entryPath) => readSafeInteger(entry, entryPath, 0, 7), path));\n assignOptional(output, \"transform\", readOptional(record, \"transform\", parseTextureTransform, path));\n return output as unknown as GpuModelTextureBinding;\n}\n\nfunction parseMaterialTextures(value: unknown, path: string): GpuModelMaterialTextures {\n const slots = Object.keys(MATERIAL_TEXTURE_SLOTS);\n const record = readRecord(value, path, slots);\n const output: Record<string, unknown> = {};\n for (const slot of slots) assignOptional(output, slot, readOptional(record, slot, parseTextureBinding, path));\n return output as GpuModelMaterialTextures;\n}\n\nfunction parseMaterial(value: unknown, path: string, budget: DocumentBudget): GpuModelMaterial {\n const keys = [\n \"id\", \"name\", \"workflow\", \"alphaMode\", \"alphaCutoff\", \"doubleSided\", \"baseColorFactor\",\n \"metallicFactor\", \"roughnessFactor\", \"emissiveFactor\", \"transmissionFactor\", \"clearcoatFactor\",\n \"clearcoatRoughnessFactor\", \"sheenColorFactor\", \"sheenRoughnessFactor\", \"normalScale\",\n \"occlusionStrength\", \"textures\", \"extensions\", \"sourceMetadata\",\n ];\n const record = readRecord(value, path, keys);\n const alphaMode = readEnum(requireKey(record, \"alphaMode\", path), `${path}.alphaMode`, [\"opaque\", \"mask\", \"blend\"] as const);\n const alphaCutoff = readOptional(record, \"alphaCutoff\", (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path);\n if (alphaMode === \"mask\" && alphaCutoff === undefined) return fail(\"invalid-value\", `${path}.alphaCutoff`, \"mask materials require alphaCutoff\");\n if (alphaMode !== \"mask\" && alphaCutoff !== undefined) return fail(\"invalid-value\", `${path}.alphaCutoff`, \"alphaCutoff is only valid for mask materials\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n workflow: readEnum(requireKey(record, \"workflow\", path), `${path}.workflow`, [\"metallic-roughness\", \"specular-glossiness\", \"unlit\", \"custom\"] as const),\n alphaMode,\n baseColorFactor: readNumberTuple(requireKey(record, \"baseColorFactor\", path), `${path}.baseColorFactor`, 4, 0, 1) as GpuModelVec4,\n textures: parseMaterialTextures(requireKey(record, \"textures\", path), `${path}.textures`),\n extensions: readMetadata(requireKey(record, \"extensions\", path), `${path}.extensions`, budget),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"alphaCutoff\", alphaCutoff);\n assignOptional(output, \"doubleSided\", readOptional(record, \"doubleSided\", readBoolean, path));\n for (const key of [\"metallicFactor\", \"roughnessFactor\", \"transmissionFactor\", \"clearcoatFactor\", \"clearcoatRoughnessFactor\", \"sheenRoughnessFactor\", \"occlusionStrength\"] as const) {\n assignOptional(output, key, readOptional(record, key, (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path));\n }\n assignOptional(output, \"normalScale\", readOptional(record, \"normalScale\", readFinite, path));\n assignOptional(output, \"emissiveFactor\", readOptional(record, \"emissiveFactor\", (entry, entryPath) => readNumberTuple(entry, entryPath, 3, 0) as GpuModelVec3, path));\n assignOptional(output, \"sheenColorFactor\", readOptional(record, \"sheenColorFactor\", (entry, entryPath) => readNumberTuple(entry, entryPath, 3, 0, 1) as GpuModelVec3, path));\n return output as unknown as GpuModelMaterial;\n}\n\nfunction parseTextureSampler(value: unknown, path: string): GpuModelTextureSampler {\n const record = readRecord(value, path, [\"id\", \"wrapS\", \"wrapT\", \"minFilter\", \"magFilter\", \"mipFilter\"]);\n const output: Record<string, unknown> = { id: readId(requireKey(record, \"id\", path), `${path}.id`) };\n assignOptional(output, \"wrapS\", readOptional(record, \"wrapS\", (entry, entryPath) => readEnum(entry, entryPath, [\"repeat\", \"mirrored-repeat\", \"clamp-to-edge\"] as const), path));\n assignOptional(output, \"wrapT\", readOptional(record, \"wrapT\", (entry, entryPath) => readEnum(entry, entryPath, [\"repeat\", \"mirrored-repeat\", \"clamp-to-edge\"] as const), path));\n assignOptional(output, \"minFilter\", readOptional(record, \"minFilter\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"magFilter\", readOptional(record, \"magFilter\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"mipFilter\", readOptional(record, \"mipFilter\", (entry, entryPath) => readEnum(entry, entryPath, [\"nearest\", \"linear\"] as const), path));\n return output as unknown as GpuModelTextureSampler;\n}\n\nfunction parseTexture(value: unknown, path: string, budget: DocumentBudget): GpuModelTexture {\n const record = readRecord(value, path, [\"id\", \"fileName\", \"relativePath\", \"mimeType\", \"contentHash\", \"imageResourceId\", \"byteLength\", \"intendedUsage\", \"colorSpace\", \"sampler\", \"exportEmbeddingPolicy\", \"sourceMetadata\"]);\n const usages = Object.freeze(readArray(requireKey(record, \"intendedUsage\", path), `${path}.intendedUsage`, TEXTURE_USAGES.length, 1)\n .map((entry, index) => readEnum(entry, `${path}.intendedUsage[${index}]`, TEXTURE_USAGES)));\n ensureUnique(usages, `${path}.intendedUsage`, \"duplicate intended texture usage\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n contentHash: readSha256(requireKey(record, \"contentHash\", path), `${path}.contentHash`),\n imageResourceId: readId(requireKey(record, \"imageResourceId\", path), `${path}.imageResourceId`),\n intendedUsage: usages,\n colorSpace: readEnum(requireKey(record, \"colorSpace\", path), `${path}.colorSpace`, [\"srgb\", \"linear\", \"normal-map\", \"data\"] as const),\n exportEmbeddingPolicy: readEnum(requireKey(record, \"exportEmbeddingPolicy\", path), `${path}.exportEmbeddingPolicy`, [\"inherit-source\", \"prefer-embedded\", \"prefer-external\", \"forbid-embedding\"] as const),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"fileName\", readOptional(record, \"fileName\", (entry, entryPath) => readString(entry, entryPath, 512, FILE_NAME), path));\n assignOptional(output, \"relativePath\", readOptional(record, \"relativePath\", (entry, entryPath) => readString(entry, entryPath, 2_048, RELATIVE_PATH), path));\n assignOptional(output, \"mimeType\", readOptional(record, \"mimeType\", (entry, entryPath) => readString(entry, entryPath, 128, MIME_TYPE).toLowerCase(), path));\n assignOptional(output, \"byteLength\", readOptional(record, \"byteLength\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n assignOptional(output, \"sampler\", readOptional(record, \"sampler\", parseTextureSampler, path));\n return output as unknown as GpuModelTexture;\n}\n\nfunction parseSkeleton(value: unknown, path: string, budget: DocumentBudget): GpuModelSkeleton {\n const record = readRecord(value, path, [\"id\", \"name\", \"jointIds\", \"rootJointIds\", \"sourceMetadata\"]);\n const jointIds = Object.freeze(readArray(requireKey(record, \"jointIds\", path), `${path}.jointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.jointIds[${index}]`)));\n const rootJointIds = Object.freeze(readArray(requireKey(record, \"rootJointIds\", path), `${path}.rootJointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.rootJointIds[${index}]`)));\n consumeBudget(budget, \"skinJoints\", jointIds.length + rootJointIds.length, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, path, \"rig joint\");\n ensureUnique(jointIds, `${path}.jointIds`, \"duplicate skeleton joint\");\n ensureUnique(rootJointIds, `${path}.rootJointIds`, \"duplicate root joint\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n jointIds,\n rootJointIds,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n return output as unknown as GpuModelSkeleton;\n}\n\nfunction parseJoint(value: unknown, path: string, budget: DocumentBudget): GpuModelJoint {\n const record = readRecord(value, path, [\"id\", \"name\", \"nodeId\", \"parentJointId\", \"restLocalTransform\", \"inverseBindMatrix\", \"sourceMetadata\"]);\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n nodeId: readId(requireKey(record, \"nodeId\", path), `${path}.nodeId`),\n restLocalTransform: parseTransformTrs(requireKey(record, \"restLocalTransform\", path), `${path}.restLocalTransform`),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"parentJointId\", readOptional(record, \"parentJointId\", readId, path));\n assignOptional(output, \"inverseBindMatrix\", readOptional(record, \"inverseBindMatrix\", parseMatrix, path));\n return output as unknown as GpuModelJoint;\n}\n\nfunction parseWeightRows(value: unknown, path: string, rows: number, columns: number, integer: boolean, budget: DocumentBudget): readonly (readonly number[])[] {\n const input = readArray(value, path, rows, rows);\n consumeBudget(budget, \"weightVertices\", input.length, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, path, \"weight vertex\");\n consumeBudget(budget, \"weightInfluences\", input.length * columns, GPU_MODEL_DOCUMENT_LIMITS.weightInfluences, path, \"weight influence\");\n return Object.freeze(input.map((row, rowIndex) => {\n const parsed = readNumberTuple(row, `${path}[${rowIndex}]`, columns, 0, integer ? Number.MAX_SAFE_INTEGER : 1);\n if (integer && parsed.some((entry) => !Number.isSafeInteger(entry))) return fail(\"invalid-value\", `${path}[${rowIndex}]`, \"joint indices must be safe integers\");\n return parsed;\n }));\n}\n\nfunction parseVertexWeightSet(value: unknown, path: string, budget: DocumentBudget): GpuModelVertexWeightSet {\n const record = readRecord(value, path, [\"primitiveId\", \"influencesPerVertex\", \"joints\", \"weights\"]);\n const influences = readSafeInteger(requireKey(record, \"influencesPerVertex\", path), `${path}.influencesPerVertex`, 1, 32);\n if (influences % 4 !== 0) return fail(\"invalid-value\", `${path}.influencesPerVertex`, \"influencesPerVertex must be a multiple of four\");\n const jointRows = readArray(requireKey(record, \"joints\", path), `${path}.joints`, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, 1);\n const weightRows = readArray(requireKey(record, \"weights\", path), `${path}.weights`, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, 1);\n if (jointRows.length !== weightRows.length) return fail(\"invalid-value\", path, \"joint and weight row counts must match\");\n return {\n primitiveId: readId(requireKey(record, \"primitiveId\", path), `${path}.primitiveId`),\n influencesPerVertex: influences,\n joints: parseWeightRows(jointRows, `${path}.joints`, jointRows.length, influences, true, budget),\n weights: parseWeightRows(weightRows, `${path}.weights`, weightRows.length, influences, false, budget),\n };\n}\n\nfunction parseSkin(value: unknown, path: string, budget: DocumentBudget): GpuModelSkin {\n const record = readRecord(value, path, [\"id\", \"skeletonId\", \"jointIds\", \"inverseBindMatrices\", \"weightSets\", \"sourceMetadata\"]);\n const jointIds = Object.freeze(readArray(requireKey(record, \"jointIds\", path), `${path}.jointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.jointIds[${index}]`)));\n consumeBudget(budget, \"skinJoints\", jointIds.length, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, path, \"skin joint\");\n ensureUnique(jointIds, `${path}.jointIds`, \"duplicate skin joint\");\n const inverseInput = readArray(requireKey(record, \"inverseBindMatrices\", path), `${path}.inverseBindMatrices`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, jointIds.length);\n if (inverseInput.length !== jointIds.length) return fail(\"invalid-value\", `${path}.inverseBindMatrices`, \"one inverse bind matrix is required per skin joint\");\n const weightInput = readArray(requireKey(record, \"weightSets\", path), `${path}.weightSets`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n const weightSets = Object.freeze(weightInput.map((entry, index) => parseVertexWeightSet(entry, `${path}.weightSets[${index}]`, budget)));\n ensureUnique(weightSets.map(({ primitiveId }) => primitiveId), `${path}.weightSets`, \"duplicate primitive weight set\");\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n skeletonId: readId(requireKey(record, \"skeletonId\", path), `${path}.skeletonId`),\n jointIds,\n inverseBindMatrices: Object.freeze(inverseInput.map((entry, index) => parseMatrix(entry, `${path}.inverseBindMatrices[${index}]`))),\n weightSets,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseBlendShapeDelta(value: unknown, path: string): GpuModelBlendShapeDelta {\n const record = readRecord(value, path, [\"primitiveId\", \"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"]);\n const output: Record<string, unknown> = { primitiveId: readId(requireKey(record, \"primitiveId\", path), `${path}.primitiveId`) };\n for (const key of [\"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"] as const) {\n assignOptional(output, key, readOptional(record, key, readId, path));\n }\n if (!output.positionAccessorId && !output.normalAccessorId && !output.tangentAccessorId) {\n return fail(\"invalid-value\", path, \"blend-shape delta requires at least one accessor\");\n }\n return output as unknown as GpuModelBlendShapeDelta;\n}\n\nfunction parseBlendShape(value: unknown, path: string, budget: DocumentBudget): GpuModelBlendShape {\n const record = readRecord(value, path, [\"id\", \"meshId\", \"name\", \"defaultWeight\", \"deltas\", \"sourceMetadata\"]);\n const deltaInput = readArray(requireKey(record, \"deltas\", path), `${path}.deltas`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n consumeBudget(\n budget,\n \"blendShapeDeltas\",\n deltaInput.length,\n GPU_MODEL_DOCUMENT_LIMITS.blendShapeDeltas,\n `${path}.deltas`,\n \"blend-shape delta\",\n );\n const deltas = Object.freeze(deltaInput.map((entry, index) => parseBlendShapeDelta(entry, `${path}.deltas[${index}]`)));\n ensureUnique(deltas.map(({ primitiveId }) => primitiveId), `${path}.deltas`, \"duplicate blend-shape primitive delta\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n meshId: readId(requireKey(record, \"meshId\", path), `${path}.meshId`),\n deltas,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"defaultWeight\", readOptional(record, \"defaultWeight\", (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path));\n return output as unknown as GpuModelBlendShape;\n}\n\nfunction parseAnimationSampler(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimationSampler {\n const record = readRecord(value, path, [\"id\", \"inputAccessorId\", \"outputAccessorId\", \"inputTimesSeconds\", \"outputValues\", \"interpolation\", \"sourceMetadata\"]);\n const timesInput = readArray(requireKey(record, \"inputTimesSeconds\", path), `${path}.inputTimesSeconds`, GPU_MODEL_DOCUMENT_LIMITS.animationValues, 1);\n const valuesInput = readArray(requireKey(record, \"outputValues\", path), `${path}.outputValues`, GPU_MODEL_DOCUMENT_LIMITS.animationValues, 1);\n consumeBudget(budget, \"animationValues\", timesInput.length + valuesInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationValues, path, \"animation value\");\n const times = Object.freeze(timesInput.map((entry, index) => readFinite(entry, `${path}.inputTimesSeconds[${index}]`, 0)));\n for (let index = 1; index < times.length; index += 1) {\n if (times[index]! <= times[index - 1]!) return fail(\"invalid-value\", `${path}.inputTimesSeconds`, \"animation input times must be strictly increasing\");\n }\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n inputAccessorId: readId(requireKey(record, \"inputAccessorId\", path), `${path}.inputAccessorId`),\n outputAccessorId: readId(requireKey(record, \"outputAccessorId\", path), `${path}.outputAccessorId`),\n inputTimesSeconds: times,\n outputValues: Object.freeze(valuesInput.map((entry, index) => readFinite(entry, `${path}.outputValues[${index}]`))),\n interpolation: readEnum(requireKey(record, \"interpolation\", path), `${path}.interpolation`, [\"step\", \"linear\", \"cubic-spline\"] as const),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseAnimationChannel(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimationChannel {\n const record = readRecord(value, path, [\"id\", \"samplerId\", \"targetType\", \"targetId\", \"sourceMetadata\"]);\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n samplerId: readId(requireKey(record, \"samplerId\", path), `${path}.samplerId`),\n targetType: readEnum(requireKey(record, \"targetType\", path), `${path}.targetType`, [\"node-translation\", \"node-rotation\", \"node-scale\", \"weights\"] as const),\n targetId: readId(requireKey(record, \"targetId\", path), `${path}.targetId`),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseAnimation(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimation {\n const record = readRecord(value, path, [\"id\", \"name\", \"durationSeconds\", \"samplers\", \"channels\", \"sourceMetadata\"]);\n const samplerInput = readArray(requireKey(record, \"samplers\", path), `${path}.samplers`, GPU_MODEL_DOCUMENT_LIMITS.animationSamplers, 1);\n const channelInput = readArray(requireKey(record, \"channels\", path), `${path}.channels`, GPU_MODEL_DOCUMENT_LIMITS.animationChannels, 1);\n consumeBudget(budget, \"animationSamplers\", samplerInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationSamplers, path, \"animation sampler\");\n consumeBudget(budget, \"animationChannels\", channelInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationChannels, path, \"animation channel\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n durationSeconds: readFinite(requireKey(record, \"durationSeconds\", path), `${path}.durationSeconds`, 0),\n samplers: Object.freeze(samplerInput.map((entry, index) => parseAnimationSampler(entry, `${path}.samplers[${index}]`, budget))),\n channels: Object.freeze(channelInput.map((entry, index) => parseAnimationChannel(entry, `${path}.channels[${index}]`, budget))),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n return output as unknown as GpuModelAnimation;\n}\n\nfunction parseAnalyticGeometry(value: unknown, path: string, budget: DocumentBudget): GpuModelAnalyticGeometry {\n const record = readRecord(value, path, [\"id\", \"kind\", \"sourceResourceId\", \"sourceUnit\", \"tessellatedMeshId\", \"metadata\"]);\n if (requireKey(record, \"kind\", path) !== \"brep-placeholder\") return fail(\"invalid-value\", `${path}.kind`, \"unsupported analytic geometry kind\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n kind: \"brep-placeholder\",\n sourceResourceId: readId(requireKey(record, \"sourceResourceId\", path), `${path}.sourceResourceId`),\n sourceUnit: readEnum(requireKey(record, \"sourceUnit\", path), `${path}.sourceUnit`, [\"metre\", \"millimetre\", \"centimetre\", \"inch\", \"foot\", \"unitless\"] as const),\n };\n assignOptional(output, \"tessellatedMeshId\", readOptional(record, \"tessellatedMeshId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelAnalyticGeometry;\n}\n\nfunction parseProvenance(value: unknown, budget: DocumentBudget): GpuModelProvenance {\n const path = \"$.provenance\";\n const record = readRecord(value, path, [\"sourceFormat\", \"sourceContentHash\", \"converterId\", \"converterVersion\", \"provider\", \"sourceIdentifier\", \"metadata\"]);\n const output: Record<string, unknown> = {\n sourceFormat: readString(requireKey(record, \"sourceFormat\", path), `${path}.sourceFormat`, 128, TOKEN),\n sourceContentHash: readSha256(requireKey(record, \"sourceContentHash\", path), `${path}.sourceContentHash`),\n converterId: readString(requireKey(record, \"converterId\", path), `${path}.converterId`, 128, TOKEN),\n converterVersion: readString(requireKey(record, \"converterVersion\", path), `${path}.converterVersion`, 128, TOKEN),\n };\n assignOptional(output, \"provider\", readOptional(record, \"provider\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"sourceIdentifier\", readOptional(record, \"sourceIdentifier\", (entry, entryPath) => readString(entry, entryPath, 2_048), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelProvenance;\n}\n\nfunction parseDiagnostic(value: unknown, path: string, budget: DocumentBudget): GpuModelDiagnostic {\n const record = readRecord(value, path, [\"severity\", \"code\", \"message\", \"path\", \"metadata\"]);\n const output: Record<string, unknown> = {\n severity: readEnum(requireKey(record, \"severity\", path), `${path}.severity`, [\"info\", \"warning\", \"error\"] as const),\n code: readString(requireKey(record, \"code\", path), `${path}.code`, 128, TOKEN),\n message: readString(requireKey(record, \"message\", path), `${path}.message`, GPU_MODEL_DOCUMENT_LIMITS.diagnosticMessageLength),\n };\n assignOptional(output, \"path\", readOptional(record, \"path\", (entry, entryPath) => readString(entry, entryPath, 512), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelDiagnostic;\n}\n\nfunction ensureUnique(values: readonly string[], path: string, detail = \"duplicate identity\"): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) return fail(\"duplicate-id\", path, `${detail}: ${value}`);\n seen.add(value);\n }\n}\n\nfunction indexById<T extends { readonly id: string }>(values: readonly T[], path: string): ReadonlyMap<string, T> {\n ensureUnique(values.map(({ id }) => id), path);\n return new Map(values.map((value) => [value.id, value]));\n}\n\nfunction requireReference<T>(index: ReadonlyMap<string, T>, id: string, path: string, kind: string): T {\n const value = index.get(id);\n if (!value) return fail(\"missing-reference\", path, `missing ${kind}: ${id}`);\n return value;\n}\n\nfunction almostEqual(left: number, right: number, epsilon = EPSILON): boolean {\n return Math.abs(left - right) <= epsilon * Math.max(1, Math.abs(left), Math.abs(right));\n}\n\nfunction matrixAlmostEqual(left: GpuModelMatrix4, right: GpuModelMatrix4): boolean {\n return left.every((value, index) => almostEqual(value, right[index]!));\n}\n\nfunction multiplyMatrices(left: GpuModelMatrix4, right: GpuModelMatrix4): GpuModelMatrix4 {\n const output = new Array<number>(16).fill(0);\n for (let column = 0; column < 4; column += 1) {\n for (let row = 0; row < 4; row += 1) {\n let value = 0;\n for (let inner = 0; inner < 4; inner += 1) value += left[inner * 4 + row]! * right[column * 4 + inner]!;\n output[column * 4 + row] = value;\n }\n }\n return Object.freeze(output) as unknown as GpuModelMatrix4;\n}\n\nfunction transformPosition(matrix: GpuModelMatrix4, position: readonly number[]): GpuModelVec3 {\n const [x, y, z] = position;\n return [\n matrix[0] * x! + matrix[4] * y! + matrix[8] * z! + matrix[12],\n matrix[1] * x! + matrix[5] * y! + matrix[9] * z! + matrix[13],\n matrix[2] * x! + matrix[6] * y! + matrix[10] * z! + matrix[14],\n ];\n}\n\ninterface SceneValidation {\n readonly worldByNode: ReadonlyMap<string, GpuModelMatrix4>;\n readonly ancestryEntryByNode: ReadonlyMap<string, number>;\n readonly ancestryExitByNode: ReadonlyMap<string, number>;\n}\n\nfunction validateScene(roots: readonly string[], nodes: readonly GpuModelNode[], nodeIndex: ReadonlyMap<string, GpuModelNode>): SceneValidation {\n ensureUnique(roots, \"$.roots\", \"duplicate root node\");\n const parentCounts = new Map(nodes.map(({ id }) => [id, 0]));\n for (let nodeIndexValue = 0; nodeIndexValue < nodes.length; nodeIndexValue += 1) {\n const node = nodes[nodeIndexValue]!;\n for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {\n const childId = node.children[childIndex]!;\n requireReference(nodeIndex, childId, `$.nodes[${nodeIndexValue}].children[${childIndex}]`, \"node\");\n const parentCount = parentCounts.get(childId)! + 1;\n if (parentCount > 1) return fail(\"invalid-reference\", `$.nodes[${nodeIndexValue}].children[${childIndex}]`, \"node cannot have more than one parent\");\n parentCounts.set(childId, parentCount);\n }\n }\n const rootSet = new Set(roots);\n for (let index = 0; index < roots.length; index += 1) {\n const root = roots[index]!;\n requireReference(nodeIndex, root, `$.roots[${index}]`, \"node\");\n if (parentCounts.get(root) !== 0) return fail(\"invalid-reference\", `$.roots[${index}]`, \"root node cannot have a parent\");\n }\n for (const [nodeId, count] of parentCounts) {\n if (count === 0 && !rootSet.has(nodeId)) return fail(\"invalid-reference\", \"$.roots\", `parentless node is missing from roots: ${nodeId}`);\n }\n const worldByNode = new Map<string, GpuModelMatrix4>();\n const queue = roots.map((root) => ({ id: root, world: requireReference(nodeIndex, root, \"$.roots\", \"node\").localMatrix }));\n for (let cursor = 0; cursor < queue.length; cursor += 1) {\n const { id, world } = queue[cursor]!;\n if (worldByNode.has(id)) return fail(\"graph-cycle\", \"$.nodes\", \"scene graph contains a cycle\");\n worldByNode.set(id, world);\n const node = requireReference(nodeIndex, id, \"$.nodes\", \"node\");\n for (const childId of node.children) {\n const child = requireReference(nodeIndex, childId, \"$.nodes\", \"node\");\n queue.push({ id: childId, world: multiplyMatrices(world, child.localMatrix) });\n }\n }\n if (worldByNode.size !== nodes.length) return fail(\"graph-cycle\", \"$.nodes\", \"scene graph contains a cycle or unreachable node\");\n const ancestryEntryByNode = new Map<string, number>();\n const ancestryExitByNode = new Map<string, number>();\n const traversal = roots.slice().reverse().map((id) => ({ id, exiting: false }));\n let timestamp = 0;\n while (traversal.length > 0) {\n const current = traversal.pop()!;\n if (current.exiting) {\n ancestryExitByNode.set(current.id, timestamp);\n timestamp += 1;\n continue;\n }\n ancestryEntryByNode.set(current.id, timestamp);\n timestamp += 1;\n traversal.push({ id: current.id, exiting: true });\n const node = requireReference(nodeIndex, current.id, \"$.nodes\", \"node\");\n for (let index = node.children.length - 1; index >= 0; index -= 1) {\n traversal.push({ id: node.children[index]!, exiting: false });\n }\n }\n if (ancestryExitByNode.size !== nodes.length) return fail(\"graph-cycle\", \"$.nodes\", \"scene ancestry traversal is incomplete\");\n return { worldByNode, ancestryEntryByNode, ancestryExitByNode };\n}\n\nfunction isAncestor(scene: SceneValidation, possibleAncestor: string, nodeId: string): boolean {\n const ancestorEntry = scene.ancestryEntryByNode.get(possibleAncestor);\n const ancestorExit = scene.ancestryExitByNode.get(possibleAncestor);\n const nodeEntry = scene.ancestryEntryByNode.get(nodeId);\n const nodeExit = scene.ancestryExitByNode.get(nodeId);\n return ancestorEntry !== undefined\n && ancestorExit !== undefined\n && nodeEntry !== undefined\n && nodeExit !== undefined\n && ancestorEntry < nodeEntry\n && nodeExit < ancestorExit;\n}\n\nfunction validateAttributeAccessor(semantic: string, accessor: GpuModelAccessor, path: string): void {\n const unsigned = accessor.componentType === \"u8\" || accessor.componentType === \"u16\";\n if (semantic === \"POSITION\") {\n if (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.normalized === true) {\n return fail(\"invalid-reference\", path, \"POSITION accessor must be a non-normalized f32 vec3\");\n }\n if (!accessor.min || !accessor.max) return fail(\"invalid-reference\", path, \"POSITION accessor requires min and max bounds\");\n } else if (semantic === \"NORMAL\" && (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"NORMAL accessor must be a non-normalized f32 vec3\");\n } else if (semantic === \"TANGENT\" && (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec4\" || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"TANGENT accessor must be a non-normalized f32 vec4\");\n } else if (semantic.startsWith(\"TEXCOORD_\") && (accessor.elementType !== \"vec2\" || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"texture-coordinate accessor must be f32 or normalized unsigned vec2\");\n } else if (semantic.startsWith(\"COLOR_\") && (!(accessor.elementType === \"vec3\" || accessor.elementType === \"vec4\") || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"colour accessor must be f32 or normalized unsigned vec3/vec4\");\n } else if (semantic.startsWith(\"JOINTS_\") && (accessor.elementType !== \"vec4\" || !unsigned || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"joint accessor must be a non-normalized unsigned vec4\");\n } else if (semantic.startsWith(\"WEIGHTS_\") && (accessor.elementType !== \"vec4\" || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"weight accessor must be f32 or normalized unsigned vec4\");\n }\n}\n\ninterface AccessorReader {\n readonly accessor: GpuModelAccessor;\n readonly components: number;\n readRaw(index: number): readonly number[];\n read(index: number): readonly number[];\n}\n\nfunction createAccessorReader(accessor: GpuModelAccessor, resource: GpuModelResource, path: string): AccessorReader {\n const bytes = verifiedResourceBytes.get(resource);\n if (!bytes) return fail(\"resource-unverified\", path, \"accessor requires a privately verified resource\");\n const componentBytes = COMPONENT_BYTES[accessor.componentType];\n const components = ELEMENT_COMPONENTS[accessor.elementType];\n const elementBytes = componentBytes * components;\n const stride = accessor.byteStride ?? elementBytes;\n if (stride < elementBytes) return fail(\"invalid-value\", `${path}.byteStride`, \"byteStride cannot be smaller than one element\");\n if ((accessor.byteOffset % componentBytes) !== 0 || (stride % componentBytes) !== 0) {\n return fail(\"invalid-value\", path, \"accessor offset and stride must align to the component size\");\n }\n const extent = accessor.byteOffset + stride * (accessor.count - 1) + elementBytes;\n if (!Number.isSafeInteger(extent) || extent > bytes.byteLength) return fail(\"invalid-reference\", path, \"accessor range exceeds its verified buffer resource\");\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const rawComponent = (offset: number): number => {\n switch (accessor.componentType) {\n case \"i8\": return view.getInt8(offset);\n case \"u8\": return view.getUint8(offset);\n case \"i16\": return view.getInt16(offset, true);\n case \"u16\": return view.getUint16(offset, true);\n case \"u32\": return view.getUint32(offset, true);\n case \"f32\": return view.getFloat32(offset, true);\n }\n };\n const normalize = (value: number): number => {\n if (accessor.normalized !== true) return value;\n switch (accessor.componentType) {\n case \"i8\": return Math.max(value / 127, -1);\n case \"u8\": return value / 255;\n case \"i16\": return Math.max(value / 32_767, -1);\n case \"u16\": return value / 65_535;\n case \"u32\": return value / 4_294_967_295;\n case \"f32\": return value;\n }\n };\n const readRaw = (index: number): readonly number[] => {\n if (!Number.isSafeInteger(index) || index < 0 || index >= accessor.count) return fail(\"invalid-reference\", path, \"accessor index is out of range\");\n const offset = accessor.byteOffset + stride * index;\n return Object.freeze(Array.from({ length: components }, (_, component) => rawComponent(offset + component * componentBytes)));\n };\n return {\n accessor,\n components,\n readRaw,\n read(index: number) {\n return Object.freeze(readRaw(index).map(normalize));\n },\n };\n}\n\ninterface AccessorPayloadEvidence {\n readonly min: readonly number[];\n readonly max: readonly number[];\n}\n\nfunction validateAccessorPayload(reader: AccessorReader, path: string): AccessorPayloadEvidence {\n const actualMin = new Array<number>(reader.components).fill(Number.POSITIVE_INFINITY);\n const actualMax = new Array<number>(reader.components).fill(Number.NEGATIVE_INFINITY);\n for (let item = 0; item < reader.accessor.count; item += 1) {\n const values = reader.readRaw(item);\n for (let component = 0; component < reader.components; component += 1) {\n const value = values[component]!;\n if (!Number.isFinite(value)) return fail(\"invalid-value\", path, \"accessor payload contains a non-finite value\");\n actualMin[component] = Math.min(actualMin[component]!, value);\n actualMax[component] = Math.max(actualMax[component]!, value);\n }\n }\n if (reader.accessor.min && reader.accessor.max) {\n for (let component = 0; component < reader.components; component += 1) {\n const minimumMatches = reader.accessor.componentType === \"f32\"\n ? almostEqual(actualMin[component]!, reader.accessor.min[component]!)\n : actualMin[component] === reader.accessor.min[component];\n const maximumMatches = reader.accessor.componentType === \"f32\"\n ? almostEqual(actualMax[component]!, reader.accessor.max[component]!)\n : actualMax[component] === reader.accessor.max[component];\n if (!minimumMatches || !maximumMatches) {\n return fail(\"invalid-reference\", path, \"declared accessor min/max do not match verified payload bytes\");\n }\n }\n }\n return Object.freeze({\n min: Object.freeze(actualMin),\n max: Object.freeze(actualMax),\n });\n}\n\nfunction actualAccessorBounds(reader: AccessorReader, evidence: AccessorPayloadEvidence, path: string): GpuModelBounds {\n if (reader.components !== 3) return fail(\"invalid-reference\", path, \"position reader must have three components\");\n return {\n min: evidence.min as GpuModelVec3,\n max: evidence.max as GpuModelVec3,\n };\n}\n\nfunction assertBoundsEqual(actual: GpuModelBounds, declared: GpuModelBounds, path: string): void {\n for (let component = 0; component < 3; component += 1) {\n if (Math.abs(actual.min[component]! - declared.min[component]!) > BOUNDS_ABSOLUTE_EPSILON\n || Math.abs(actual.max[component]! - declared.max[component]!) > BOUNDS_ABSOLUTE_EPSILON) {\n return fail(\"invalid-reference\", path, \"declared bounds do not match byte-verified POSITION data\");\n }\n }\n}\n\nfunction validateReferences(document: GpuModelDocument, budget: DocumentBudget): void {\n const nodes = indexById(document.nodes, \"$.nodes\");\n const resources = indexById(document.resources, \"$.resources\");\n const accessors = indexById(document.accessors, \"$.accessors\");\n const meshes = indexById(document.meshes, \"$.meshes\");\n const materials = indexById(document.materials, \"$.materials\");\n const textures = indexById(document.textures, \"$.textures\");\n const skeletons = indexById(document.skeletons, \"$.skeletons\");\n const joints = indexById(document.joints, \"$.joints\");\n const skins = indexById(document.skins, \"$.skins\");\n const blendShapes = indexById(document.blendShapes, \"$.blendShapes\");\n indexById(document.animations, \"$.animations\");\n indexById(document.analyticGeometry, \"$.analyticGeometry\");\n const scene = validateScene(document.roots, document.nodes, nodes);\n\n const readers = new Map<string, AccessorReader>();\n const payloadEvidence = new Map<string, AccessorPayloadEvidence>();\n for (let index = 0; index < document.accessors.length; index += 1) {\n const accessor = document.accessors[index]!;\n const resource = requireReference(resources, accessor.resourceId, `$.accessors[${index}].resourceId`, \"resource\");\n if (resource.kind !== \"buffer\") return fail(\"invalid-reference\", `$.accessors[${index}].resourceId`, \"accessor resource must be a buffer\");\n const reader = createAccessorReader(accessor, resource, `$.accessors[${index}]`);\n payloadEvidence.set(accessor.id, validateAccessorPayload(reader, `$.accessors[${index}]`));\n readers.set(accessor.id, reader);\n }\n\n const primitiveById = new Map<string, { primitive: GpuModelPrimitive; mesh: GpuModelMesh; path: string; position: GpuModelAccessor }>();\n const weightedPrimitiveIds = new Set<string>();\n const maximumIndexByAccessor = new Map<string, number>();\n for (let meshIndex = 0; meshIndex < document.meshes.length; meshIndex += 1) {\n const mesh = document.meshes[meshIndex]!;\n for (let primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex += 1) {\n const primitive = mesh.primitives[primitiveIndex]!;\n const path = `$.meshes[${meshIndex}].primitives[${primitiveIndex}]`;\n if (primitiveById.has(primitive.id)) return fail(\"duplicate-id\", path, `duplicate primitive ID: ${primitive.id}`);\n const positionAttribute = primitive.attributes.find(({ semantic }) => semantic === \"POSITION\")!;\n const position = requireReference(accessors, positionAttribute.accessorId, `${path}.attributes`, \"accessor\");\n for (let attributeIndex = 0; attributeIndex < primitive.attributes.length; attributeIndex += 1) {\n const attribute = primitive.attributes[attributeIndex]!;\n const accessor = requireReference(accessors, attribute.accessorId, `${path}.attributes[${attributeIndex}].accessorId`, \"accessor\");\n validateAttributeAccessor(attribute.semantic, accessor, `${path}.attributes[${attributeIndex}]`);\n if (accessor.count !== position.count) return fail(\"invalid-reference\", `${path}.attributes[${attributeIndex}]`, \"vertex attribute count must match POSITION\");\n }\n const jointSets = primitive.attributes.filter(({ semantic }) => semantic.startsWith(\"JOINTS_\")).map(({ semantic }) => semantic.slice(\"JOINTS_\".length)).sort();\n const weightSets = primitive.attributes.filter(({ semantic }) => semantic.startsWith(\"WEIGHTS_\")).map(({ semantic }) => semantic.slice(\"WEIGHTS_\".length)).sort();\n if (jointSets.length > 0 || weightSets.length > 0) {\n if (jointSets.length !== weightSets.length || jointSets.some((suffix, index) => suffix !== weightSets[index] || Number(suffix) !== index)) {\n return fail(\"invalid-reference\", `${path}.attributes`, \"JOINTS_n and WEIGHTS_n attributes must be paired and contiguous from zero\");\n }\n weightedPrimitiveIds.add(primitive.id);\n }\n const positionReader = requireReference(readers, position.id, `${path}.attributes`, \"accessor reader\");\n const actual = actualAccessorBounds(\n positionReader,\n requireReference(payloadEvidence, position.id, `${path}.attributes`, \"accessor payload evidence\"),\n `${path}.attributes.POSITION`,\n );\n assertBoundsEqual(actual, { min: position.min as GpuModelVec3, max: position.max as GpuModelVec3 }, `${path}.attributes.POSITION`);\n if (primitive.indicesAccessorId) {\n const indices = requireReference(accessors, primitive.indicesAccessorId, `${path}.indicesAccessorId`, \"accessor\");\n if (indices.elementType !== \"scalar\" || !(indices.componentType === \"u8\" || indices.componentType === \"u16\" || indices.componentType === \"u32\") || indices.normalized === true) {\n return fail(\"invalid-reference\", `${path}.indicesAccessorId`, \"index accessor must be an unsigned non-normalized scalar\");\n }\n const indexReader = requireReference(readers, indices.id, `${path}.indicesAccessorId`, \"accessor reader\");\n let maximumIndex = maximumIndexByAccessor.get(indices.id);\n if (maximumIndex === undefined) {\n consumeBudget(\n budget,\n \"geometryIndexElements\",\n indices.count,\n GPU_MODEL_DOCUMENT_LIMITS.geometryIndexElements,\n `${path}.indicesAccessorId`,\n \"geometry index element\",\n );\n maximumIndex = 0;\n for (let item = 0; item < indices.count; item += 1) {\n maximumIndex = Math.max(maximumIndex, indexReader.read(item)[0]!);\n }\n maximumIndexByAccessor.set(indices.id, maximumIndex);\n }\n if (maximumIndex >= position.count) return fail(\"invalid-reference\", `${path}.indicesAccessorId`, \"index payload references a vertex outside POSITION\");\n }\n if (primitive.materialId) {\n const material = requireReference(materials, primitive.materialId, `${path}.materialId`, \"material\");\n const semantics = new Set(primitive.attributes.map(({ semantic }) => semantic));\n for (const [slot, binding] of Object.entries(material.textures)) {\n if (!binding) continue;\n const requiredSemantic = `TEXCOORD_${String(binding.texCoordSet ?? 0)}`;\n if (!semantics.has(requiredSemantic)) {\n return fail(\n \"invalid-reference\",\n `${path}.materialId`,\n `material texture binding ${slot} requires primitive attribute ${requiredSemantic}`,\n );\n }\n }\n }\n primitiveById.set(primitive.id, { primitive, mesh, path, position });\n }\n }\n\n interface MeshValidationEvidence {\n readonly primitiveIds: ReadonlySet<string>;\n readonly positionReaders: readonly AccessorReader[];\n }\n const meshEvidenceById = new Map<string, MeshValidationEvidence>();\n for (const mesh of document.meshes) {\n const primitiveIds = new Set<string>();\n const positionIds = new Set<string>();\n for (const primitive of mesh.primitives) {\n primitiveIds.add(primitive.id);\n positionIds.add(requireReference(primitiveById, primitive.id, `$.meshes.${mesh.id}`, \"primitive\").position.id);\n }\n const positionReaders = Object.freeze([...positionIds].map((positionId) =>\n requireReference(readers, positionId, `$.meshes.${mesh.id}`, \"POSITION reader\")));\n meshEvidenceById.set(mesh.id, Object.freeze({ primitiveIds, positionReaders }));\n }\n\n const worldGeometry: Array<{\n readonly nodeIndex: number;\n readonly world: GpuModelMatrix4;\n readonly positionReaders: readonly AccessorReader[];\n }> = [];\n for (let nodeIndex = 0; nodeIndex < document.nodes.length; nodeIndex += 1) {\n const node = document.nodes[nodeIndex]!;\n if (node.skinId && !node.meshId) return fail(\"invalid-reference\", `$.nodes[${nodeIndex}].skinId`, \"a skinned node must also reference a mesh\");\n if (node.skinId) requireReference(skins, node.skinId, `$.nodes[${nodeIndex}].skinId`, \"skin\");\n if (!node.meshId) continue;\n requireReference(meshes, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh validation evidence\");\n const world = requireReference(scene.worldByNode, node.id, `$.nodes[${nodeIndex}]`, \"world transform\");\n const positionReaders = Object.freeze(meshEvidence.positionReaders.map((reader) => {\n consumeBudget(\n budget,\n \"geometryWorldAccessorInstances\",\n 1,\n GPU_MODEL_DOCUMENT_LIMITS.geometryWorldAccessorInstances,\n `$.nodes[${nodeIndex}].meshId`,\n \"world-geometry accessor instance\",\n );\n consumeBudget(\n budget,\n \"geometryWorldVertices\",\n reader.accessor.count,\n GPU_MODEL_DOCUMENT_LIMITS.geometryWorldVertices,\n `$.nodes[${nodeIndex}].meshId`,\n \"world-geometry vertex\",\n );\n return reader;\n }));\n worldGeometry.push({ nodeIndex, world, positionReaders });\n }\n if (worldGeometry.length === 0) return fail(\"invalid-reference\", \"$.bounds\", \"document bounds require scene-referenced byte-verified POSITION geometry\");\n\n const worldMin = [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY];\n const worldMax = [Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY];\n for (const { nodeIndex, world, positionReaders } of worldGeometry) {\n for (const reader of positionReaders) {\n for (let vertex = 0; vertex < reader.accessor.count; vertex += 1) {\n const transformed = transformPosition(world, reader.read(vertex));\n for (let component = 0; component < 3; component += 1) {\n const value = transformed[component]!;\n if (!Number.isFinite(value)) return fail(\"invalid-value\", `$.nodes[${nodeIndex}].localMatrix`, \"world transform produced non-finite bounds\");\n worldMin[component] = Math.min(worldMin[component]!, value);\n worldMax[component] = Math.max(worldMax[component]!, value);\n }\n }\n }\n }\n assertBoundsEqual(\n { min: worldMin as unknown as GpuModelVec3, max: worldMax as unknown as GpuModelVec3 },\n document.bounds,\n \"$.bounds\",\n );\n\n for (let index = 0; index < document.textures.length; index += 1) {\n const texture = document.textures[index]!;\n const resource = requireReference(resources, texture.imageResourceId, `$.textures[${index}].imageResourceId`, \"resource\");\n if (resource.kind !== \"image\") return fail(\"invalid-reference\", `$.textures[${index}].imageResourceId`, \"texture resource must be an image\");\n if (texture.contentHash !== resource.contentHash) return fail(\"invalid-reference\", `$.textures[${index}].contentHash`, \"texture hash must match its verified image resource\");\n if (texture.mimeType !== undefined && texture.mimeType !== resource.mimeType) return fail(\"invalid-reference\", `$.textures[${index}].mimeType`, \"texture MIME type must match its image resource\");\n if (texture.byteLength !== undefined && texture.byteLength !== resource.byteLength) return fail(\"invalid-reference\", `$.textures[${index}].byteLength`, \"texture byteLength must match its image resource\");\n }\n for (let materialIndex = 0; materialIndex < document.materials.length; materialIndex += 1) {\n const material = document.materials[materialIndex]!;\n for (const [slot, expectedUsage] of Object.entries(MATERIAL_TEXTURE_SLOTS) as Array<[keyof GpuModelMaterialTextures, GpuModelTextureUsage]>) {\n const binding = material.textures[slot];\n if (!binding) continue;\n const texture = requireReference(textures, binding.textureId, `$.materials[${materialIndex}].textures.${slot}.textureId`, \"texture\");\n if (binding.intendedUsage !== expectedUsage) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.intendedUsage`, \"texture usage does not match its material slot\");\n if (!texture.intendedUsage.includes(binding.intendedUsage)) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}`, \"texture does not declare the binding usage\");\n if (texture.colorSpace !== binding.colorSpace) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.colorSpace`, \"binding and texture color spaces must match\");\n if (binding.samplerId !== undefined && binding.samplerId !== texture.sampler?.id) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.samplerId`, \"binding sampler does not match the texture sampler\");\n }\n }\n\n const skeletonForJoint = new Map<string, string>();\n const jointIdsBySkeleton = new Map<string, ReadonlySet<string>>();\n for (let skeletonIndex = 0; skeletonIndex < document.skeletons.length; skeletonIndex += 1) {\n const skeleton = document.skeletons[skeletonIndex]!;\n const skeletonJointIds = new Set(skeleton.jointIds);\n const skeletonJointNodes = new Set<string>();\n const expectedRoots = new Set<string>();\n jointIdsBySkeleton.set(skeleton.id, skeletonJointIds);\n for (let jointIndex = 0; jointIndex < skeleton.jointIds.length; jointIndex += 1) {\n const jointId = skeleton.jointIds[jointIndex]!;\n const joint = requireReference(joints, jointId, `$.skeletons[${skeletonIndex}].jointIds[${jointIndex}]`, \"joint\");\n if (skeletonForJoint.has(jointId)) return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].jointIds[${jointIndex}]`, \"joint cannot belong to more than one skeleton\");\n skeletonForJoint.set(jointId, skeleton.id);\n requireReference(nodes, joint.nodeId, `$.joints.${joint.id}.nodeId`, \"node\");\n if (skeletonJointNodes.has(joint.nodeId)) return fail(\"duplicate-id\", `$.skeletons[${skeletonIndex}].jointIds`, `duplicate joint node: ${joint.nodeId}`);\n skeletonJointNodes.add(joint.nodeId);\n if (joint.parentJointId === undefined) expectedRoots.add(joint.id);\n }\n const declaredRoots = new Set(skeleton.rootJointIds);\n if (expectedRoots.size !== declaredRoots.size || [...expectedRoots].some((id) => !declaredRoots.has(id))) {\n return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].rootJointIds`, \"rootJointIds must exactly identify parentless skeleton joints\");\n }\n for (let rootIndex = 0; rootIndex < skeleton.rootJointIds.length; rootIndex += 1) {\n const rootJoint = requireReference(joints, skeleton.rootJointIds[rootIndex]!, `$.skeletons[${skeletonIndex}].rootJointIds[${rootIndex}]`, \"joint\");\n if (!skeletonJointIds.has(rootJoint.id)) return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].rootJointIds[${rootIndex}]`, \"root joint is not a member of the skeleton\");\n requireReference(scene.worldByNode, rootJoint.nodeId, `$.joints.${rootJoint.id}.nodeId`, \"scene node\");\n }\n }\n if (skeletonForJoint.size !== document.joints.length) return fail(\"invalid-reference\", \"$.joints\", \"every joint must belong to exactly one skeleton\");\n for (let jointIndex = 0; jointIndex < document.joints.length; jointIndex += 1) {\n const joint = document.joints[jointIndex]!;\n const node = requireReference(nodes, joint.nodeId, `$.joints[${jointIndex}].nodeId`, \"node\");\n if (joint.parentJointId) {\n const parent = requireReference(joints, joint.parentJointId, `$.joints[${jointIndex}].parentJointId`, \"joint\");\n if (skeletonForJoint.get(parent.id) !== skeletonForJoint.get(joint.id)) return fail(\"invalid-reference\", `$.joints[${jointIndex}].parentJointId`, \"parent joint must belong to the same skeleton\");\n if (!isAncestor(scene, parent.nodeId, node.id)) return fail(\"invalid-reference\", `$.joints[${jointIndex}].parentJointId`, \"parent joint node must be an ancestor of the child joint node\");\n }\n }\n\n const skinUse = new Map<string, Set<string>>();\n for (const node of document.nodes) {\n if (!node.skinId || !node.meshId) continue;\n const set = skinUse.get(node.skinId) ?? new Set<string>();\n set.add(node.meshId);\n skinUse.set(node.skinId, set);\n }\n const skinValidatedPrimitiveIds = new Set<string>();\n for (let skinIndex = 0; skinIndex < document.skins.length; skinIndex += 1) {\n const skin = document.skins[skinIndex]!;\n const skeleton = requireReference(skeletons, skin.skeletonId, `$.skins[${skinIndex}].skeletonId`, \"skeleton\");\n const skeletonJointIds = requireReference(jointIdsBySkeleton, skeleton.id, `$.skins[${skinIndex}].skeletonId`, \"skeleton joint set\");\n for (let jointIndex = 0; jointIndex < skin.jointIds.length; jointIndex += 1) {\n const joint = requireReference(joints, skin.jointIds[jointIndex]!, `$.skins[${skinIndex}].jointIds[${jointIndex}]`, \"joint\");\n if (!skeletonJointIds.has(joint.id)) return fail(\"invalid-reference\", `$.skins[${skinIndex}].jointIds[${jointIndex}]`, \"skin joint is not a member of its skeleton\");\n if (joint.inverseBindMatrix && !matrixAlmostEqual(joint.inverseBindMatrix, skin.inverseBindMatrices[jointIndex]!)) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].inverseBindMatrices[${jointIndex}]`, \"skin matrix does not match authored joint inverse bind matrix\");\n }\n }\n const usedMeshes = skinUse.get(skin.id);\n if (!usedMeshes || usedMeshes.size === 0) return fail(\"invalid-reference\", `$.skins[${skinIndex}]`, \"skin must be linked from a node that also references a mesh\");\n const expectedPrimitiveIds = new Set<string>();\n for (const meshId of usedMeshes) {\n requireReference(meshes, meshId, `$.skins[${skinIndex}]`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, meshId, `$.skins[${skinIndex}]`, \"mesh validation evidence\");\n for (const primitiveId of meshEvidence.primitiveIds) expectedPrimitiveIds.add(primitiveId);\n }\n const weightSetByPrimitive = new Map(skin.weightSets.map((weightSet) => [weightSet.primitiveId, weightSet]));\n if (weightSetByPrimitive.size !== expectedPrimitiveIds.size || [...expectedPrimitiveIds].some((id) => !weightSetByPrimitive.has(id))) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"skin weight sets must exactly cover linked mesh primitives\");\n }\n for (const primitiveId of expectedPrimitiveIds) {\n skinValidatedPrimitiveIds.add(primitiveId);\n const primitiveEntry = requireReference(primitiveById, primitiveId, `$.skins[${skinIndex}].weightSets`, \"primitive\");\n const weightSet = requireReference(weightSetByPrimitive, primitiveId, `$.skins[${skinIndex}].weightSets`, \"weight set\");\n const jointsBySet = new Map<number, GpuModelAccessor>();\n const weightsBySet = new Map<number, GpuModelAccessor>();\n for (const attribute of primitiveEntry.primitive.attributes) {\n const jointMatch = /^JOINTS_([0-7])$/u.exec(attribute.semantic);\n const weightMatch = /^WEIGHTS_([0-7])$/u.exec(attribute.semantic);\n if (jointMatch) jointsBySet.set(Number(jointMatch[1]), requireReference(accessors, attribute.accessorId, primitiveEntry.path, \"joint accessor\"));\n if (weightMatch) weightsBySet.set(Number(weightMatch[1]), requireReference(accessors, attribute.accessorId, primitiveEntry.path, \"weight accessor\"));\n }\n if (jointsBySet.size === 0 || jointsBySet.size !== weightsBySet.size) return fail(\"invalid-reference\", primitiveEntry.path, \"JOINTS_n and WEIGHTS_n attributes must be paired\");\n for (let setIndex = 0; setIndex < jointsBySet.size; setIndex += 1) {\n if (!jointsBySet.has(setIndex) || !weightsBySet.has(setIndex)) return fail(\"invalid-reference\", primitiveEntry.path, \"joint and weight attribute sets must be contiguous from zero\");\n }\n if (weightSet.influencesPerVertex !== jointsBySet.size * 4) return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"influencesPerVertex does not match joint/weight attribute sets\");\n if (weightSet.joints.length !== primitiveEntry.position.count || weightSet.weights.length !== primitiveEntry.position.count) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"weight row count must match POSITION\");\n }\n for (let vertex = 0; vertex < primitiveEntry.position.count; vertex += 1) {\n const decodedJoints: number[] = [];\n const decodedWeights: number[] = [];\n for (let setIndex = 0; setIndex < jointsBySet.size; setIndex += 1) {\n decodedJoints.push(...requireReference(readers, jointsBySet.get(setIndex)!.id, primitiveEntry.path, \"joint reader\").read(vertex));\n decodedWeights.push(...requireReference(readers, weightsBySet.get(setIndex)!.id, primitiveEntry.path, \"weight reader\").read(vertex));\n }\n let total = 0;\n for (let influence = 0; influence < decodedJoints.length; influence += 1) {\n const jointIndexValue = decodedJoints[influence]!;\n const weight = decodedWeights[influence]!;\n if (!Number.isSafeInteger(jointIndexValue) || jointIndexValue < 0 || jointIndexValue >= skin.jointIds.length) return fail(\"invalid-reference\", primitiveEntry.path, \"joint payload index exceeds the skin joint list\");\n if (!Number.isFinite(weight) || weight < 0 || weight > 1) return fail(\"invalid-value\", primitiveEntry.path, \"weight payload contains an invalid value\");\n if (weightSet.joints[vertex]![influence] !== jointIndexValue || !almostEqual(weightSet.weights[vertex]![influence]!, weight)) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"authored weight rows do not match verified accessor bytes\");\n }\n total += weight;\n }\n if (!almostEqual(total, 1, 1e-4)) return fail(\"invalid-value\", primitiveEntry.path, \"vertex weights must sum to one without repair\");\n }\n }\n }\n for (const primitiveId of weightedPrimitiveIds) {\n if (!skinValidatedPrimitiveIds.has(primitiveId)) return fail(\"invalid-reference\", `$.meshes[].primitives.${primitiveId}`, \"joint/weight attributes require a linked skin and mesh node\");\n }\n\n for (let shapeIndex = 0; shapeIndex < document.blendShapes.length; shapeIndex += 1) {\n const shape = document.blendShapes[shapeIndex]!;\n const mesh = requireReference(meshes, shape.meshId, `$.blendShapes[${shapeIndex}].meshId`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, mesh.id, `$.blendShapes[${shapeIndex}].meshId`, \"mesh validation evidence\");\n for (let deltaIndex = 0; deltaIndex < shape.deltas.length; deltaIndex += 1) {\n const delta = shape.deltas[deltaIndex]!;\n const path = `$.blendShapes[${shapeIndex}].deltas[${deltaIndex}]`;\n if (!meshEvidence.primitiveIds.has(delta.primitiveId)) return fail(\"invalid-reference\", `${path}.primitiveId`, \"blend-shape primitive is not part of its mesh\");\n const base = requireReference(primitiveById, delta.primitiveId, path, \"primitive\").position;\n for (const key of [\"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"] as const) {\n const accessorId = delta[key];\n if (!accessorId) continue;\n consumeBudget(\n budget,\n \"blendShapeAccessorReferences\",\n 1,\n GPU_MODEL_DOCUMENT_LIMITS.blendShapeAccessorReferences,\n `${path}.${key}`,\n \"blend-shape accessor reference\",\n );\n const accessor = requireReference(accessors, accessorId, `${path}.${key}`, \"accessor\");\n if (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.count !== base.count || accessor.normalized === true) {\n return fail(\"invalid-reference\", `${path}.${key}`, \"blend-shape accessor has an invalid representation\");\n }\n requireReference(payloadEvidence, accessor.id, `${path}.${key}`, \"verified accessor payload evidence\");\n }\n }\n }\n\n for (let animationIndex = 0; animationIndex < document.animations.length; animationIndex += 1) {\n const animation = document.animations[animationIndex]!;\n const samplers = indexById(animation.samplers, `$.animations[${animationIndex}].samplers`);\n indexById(animation.channels, `$.animations[${animationIndex}].channels`);\n const usedSamplerIds = new Set<string>();\n const targetTypesBySampler = new Map<string, GpuModelAnimationTargetType>();\n for (let channelIndex = 0; channelIndex < animation.channels.length; channelIndex += 1) {\n const channel = animation.channels[channelIndex]!;\n const path = `$.animations[${animationIndex}].channels[${channelIndex}]`;\n const sampler = requireReference(samplers, channel.samplerId, `${path}.samplerId`, \"animation sampler\");\n usedSamplerIds.add(sampler.id);\n const previousTarget = targetTypesBySampler.get(sampler.id);\n if (previousTarget && previousTarget !== channel.targetType) return fail(\"invalid-reference\", `${path}.samplerId`, \"one animation sampler cannot drive incompatible target types\");\n targetTypesBySampler.set(sampler.id, channel.targetType);\n if (channel.targetType === \"weights\") requireReference(blendShapes, channel.targetId, `${path}.targetId`, \"blend shape\");\n else requireReference(nodes, channel.targetId, `${path}.targetId`, \"node\");\n }\n if (usedSamplerIds.size !== animation.samplers.length) return fail(\"invalid-reference\", `$.animations[${animationIndex}].samplers`, \"animation contains an unused sampler\");\n for (let samplerIndex = 0; samplerIndex < animation.samplers.length; samplerIndex += 1) {\n const sampler = animation.samplers[samplerIndex]!;\n const path = `$.animations[${animationIndex}].samplers[${samplerIndex}]`;\n const input = requireReference(accessors, sampler.inputAccessorId, `${path}.inputAccessorId`, \"accessor\");\n const output = requireReference(accessors, sampler.outputAccessorId, `${path}.outputAccessorId`, \"accessor\");\n if (input.componentType !== \"f32\" || input.elementType !== \"scalar\" || input.normalized === true) return fail(\"invalid-reference\", `${path}.inputAccessorId`, \"animation input must be a non-normalized f32 scalar accessor\");\n if (input.count !== sampler.inputTimesSeconds.length) return fail(\"invalid-reference\", `${path}.inputTimesSeconds`, \"authored input time count does not match its accessor\");\n const inputReader = requireReference(readers, input.id, `${path}.inputAccessorId`, \"accessor reader\");\n for (let key = 0; key < input.count; key += 1) {\n const decoded = inputReader.read(key)[0]!;\n if (!Number.isFinite(decoded) || !almostEqual(decoded, sampler.inputTimesSeconds[key]!)) return fail(\"invalid-reference\", `${path}.inputTimesSeconds`, \"authored input times do not match verified accessor bytes\");\n }\n if (sampler.inputTimesSeconds.at(-1)! > animation.durationSeconds + EPSILON) return fail(\"invalid-value\", `${path}.inputTimesSeconds`, \"animation key time exceeds clip duration\");\n const targetType = requireReference(targetTypesBySampler, sampler.id, path, \"sampler target type\");\n const expectedElementType: GpuModelAccessorElementType = targetType === \"node-rotation\" ? \"vec4\" : targetType === \"weights\" ? \"scalar\" : \"vec3\";\n if (output.componentType !== \"f32\" || output.elementType !== expectedElementType || output.normalized === true) return fail(\"invalid-reference\", `${path}.outputAccessorId`, \"animation output has an invalid accessor representation\");\n const multiplier = sampler.interpolation === \"cubic-spline\" ? 3 : 1;\n if (output.count !== input.count * multiplier) return fail(\"invalid-reference\", `${path}.outputAccessorId`, \"animation input and output element counts are inconsistent\");\n const expectedValues = output.count * ELEMENT_COMPONENTS[output.elementType];\n if (sampler.outputValues.length !== expectedValues) return fail(\"invalid-reference\", `${path}.outputValues`, \"authored output value count does not match its accessor\");\n const outputReader = requireReference(readers, output.id, `${path}.outputAccessorId`, \"accessor reader\");\n let flatIndex = 0;\n for (let element = 0; element < output.count; element += 1) {\n for (const decoded of outputReader.read(element)) {\n if (!Number.isFinite(decoded) || !almostEqual(decoded, sampler.outputValues[flatIndex]!)) return fail(\"invalid-reference\", `${path}.outputValues`, \"authored output values do not match verified accessor bytes\");\n flatIndex += 1;\n }\n }\n }\n }\n\n for (let index = 0; index < document.analyticGeometry.length; index += 1) {\n const analytic = document.analyticGeometry[index]!;\n const source = requireReference(resources, analytic.sourceResourceId, `$.analyticGeometry[${index}].sourceResourceId`, \"resource\");\n if (source.kind !== \"buffer\") return fail(\"invalid-reference\", `$.analyticGeometry[${index}].sourceResourceId`, \"analytic source must be a buffer resource\");\n if (analytic.tessellatedMeshId) requireReference(meshes, analytic.tessellatedMeshId, `$.analyticGeometry[${index}].tessellatedMeshId`, \"mesh\");\n }\n}\n\nfunction parseVerifiedResource(value: unknown, path: string): GpuModelResource {\n if (typeof value !== \"object\" || value === null || !verifiedResources.has(value) || !verifiedResourceBytes.has(value)) {\n return fail(\"resource-unverified\", path, \"expected a privately verified resource; use createAndVerifyGpuModelDocument\");\n }\n return value as GpuModelResource;\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || value instanceof Blob) return value;\n for (const child of Object.values(value)) deepFreeze(child);\n return Object.freeze(value);\n}\n\nconst DOCUMENT_KEYS = Object.freeze([\n \"schemaVersion\", \"coordinateSystem\", \"roots\", \"nodes\", \"resources\", \"accessors\", \"meshes\", \"materials\", \"textures\",\n \"skeletons\", \"joints\", \"skins\", \"blendShapes\", \"animations\", \"analyticGeometry\", \"bounds\", \"provenance\", \"diagnostics\", \"metadata\",\n] as const);\n\nfunction parseGpuModelDocument(value: unknown): GpuModelDocument {\n const path = \"$\";\n const record = readRecord(value, path, DOCUMENT_KEYS);\n const schemaVersion = requireKey(record, \"schemaVersion\", path);\n if (schemaVersion !== GPU_MODEL_DOCUMENT_SCHEMA_VERSION) return fail(\"invalid-value\", \"$.schemaVersion\", \"unsupported schema version\");\n const parseCollection = <T>(key: string, maximum: number, parser: (entry: unknown, entryPath: string) => T, minimum = 0): readonly T[] => {\n const input = readArray(requireKey(record, key, path), `$.${key}`, maximum, minimum);\n return Object.freeze(input.map((entry, index) => parser(entry, `$.${key}[${index}]`)));\n };\n const budget: DocumentBudget = {\n metadataValues: 0,\n sceneEdges: 0,\n primitiveAttributes: 0,\n accessorElements: 0,\n primitives: 0,\n skinJoints: 0,\n weightVertices: 0,\n weightInfluences: 0,\n animationSamplers: 0,\n animationChannels: 0,\n animationValues: 0,\n blendShapeDeltas: 0,\n blendShapeAccessorReferences: 0,\n geometryIndexElements: 0,\n geometryWorldAccessorInstances: 0,\n geometryWorldVertices: 0,\n };\n const roots = Object.freeze(readArray(requireKey(record, \"roots\", path), \"$.roots\", GPU_MODEL_DOCUMENT_LIMITS.roots, 1)\n .map((entry, index) => readId(entry, `$.roots[${index}]`)));\n const document: GpuModelDocument = {\n schemaVersion,\n coordinateSystem: parseCoordinateSystem(requireKey(record, \"coordinateSystem\", path)),\n roots,\n nodes: parseCollection(\"nodes\", GPU_MODEL_DOCUMENT_LIMITS.nodes, (entry, entryPath) => parseNode(entry, entryPath, budget), 1),\n resources: parseCollection(\"resources\", GPU_MODEL_DOCUMENT_LIMITS.resources, parseVerifiedResource, 1),\n accessors: parseCollection(\"accessors\", GPU_MODEL_DOCUMENT_LIMITS.accessors, (entry, entryPath) => parseAccessor(entry, entryPath, budget)),\n meshes: parseCollection(\"meshes\", GPU_MODEL_DOCUMENT_LIMITS.meshes, (entry, entryPath) => parseMesh(entry, entryPath, budget)),\n materials: parseCollection(\"materials\", GPU_MODEL_DOCUMENT_LIMITS.materials, (entry, entryPath) => parseMaterial(entry, entryPath, budget)),\n textures: parseCollection(\"textures\", GPU_MODEL_DOCUMENT_LIMITS.textures, (entry, entryPath) => parseTexture(entry, entryPath, budget)),\n skeletons: parseCollection(\"skeletons\", GPU_MODEL_DOCUMENT_LIMITS.skeletons, (entry, entryPath) => parseSkeleton(entry, entryPath, budget)),\n joints: parseCollection(\"joints\", GPU_MODEL_DOCUMENT_LIMITS.joints, (entry, entryPath) => parseJoint(entry, entryPath, budget)),\n skins: parseCollection(\"skins\", GPU_MODEL_DOCUMENT_LIMITS.skins, (entry, entryPath) => parseSkin(entry, entryPath, budget)),\n blendShapes: parseCollection(\"blendShapes\", GPU_MODEL_DOCUMENT_LIMITS.blendShapes, (entry, entryPath) => parseBlendShape(entry, entryPath, budget)),\n animations: parseCollection(\"animations\", GPU_MODEL_DOCUMENT_LIMITS.animations, (entry, entryPath) => parseAnimation(entry, entryPath, budget)),\n analyticGeometry: parseCollection(\"analyticGeometry\", GPU_MODEL_DOCUMENT_LIMITS.analyticGeometry, (entry, entryPath) => parseAnalyticGeometry(entry, entryPath, budget)),\n bounds: parseBounds(requireKey(record, \"bounds\", path), \"$.bounds\"),\n provenance: parseProvenance(requireKey(record, \"provenance\", path), budget),\n diagnostics: parseCollection(\"diagnostics\", GPU_MODEL_DOCUMENT_LIMITS.diagnostics, (entry, entryPath) => parseDiagnostic(entry, entryPath, budget)),\n metadata: readMetadata(requireKey(record, \"metadata\", path), \"$.metadata\", budget),\n };\n if (document.meshes.length === 0) return fail(\"invalid-value\", \"$.meshes\", \"v1 document bounds require at least one canonical mesh\");\n validateReferences(document, budget);\n const frozen = deepFreeze(document);\n validatedDocuments.add(frozen);\n return frozen;\n}\n\n/**\n * Creates a document only from privately verified resource values. This\n * synchronous factory never hashes or inspects caller-controlled bytes.\n */\nexport function createGpuModelDocument(value: unknown): GpuModelDocument {\n if (typeof value === \"object\" && value !== null && validatedDocuments.has(value)) return value as GpuModelDocument;\n try {\n return parseGpuModelDocument(value);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$\", \"input could not be safely inspected\");\n }\n}\n\n/** Non-narrowing probe for the synchronous, privately verified factory. */\nexport function canCreateGpuModelDocument(value: unknown): boolean {\n try {\n createGpuModelDocument(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Only privately branded factory output narrows to GpuModelDocument. */\nexport function isGpuModelDocument(value: unknown): value is GpuModelDocument {\n return typeof value === \"object\" && value !== null && validatedDocuments.has(value);\n}\n\n/**\n * Preflights all resource budgets, verifies every raw resource through the\n * injected streaming port, then performs the complete synchronous contract\n * validation. Structured clones intentionally re-enter verification.\n */\nexport async function createAndVerifyGpuModelDocument(\n value: unknown,\n port: GpuModelResourceVerificationPort,\n options?: GpuModelResourceVerificationOptions,\n): Promise<GpuModelDocument> {\n try {\n const limits = resolveVerificationLimits(options);\n if (options?.signal?.aborted) return fail(\"resource-verification-failed\", \"$.resources\", \"resource verification was aborted\");\n if (isGpuModelDocument(value)) {\n preflightResourceBudget(value.resources, limits);\n value.resources.forEach((resource, index) => assertVerifiedResourceEvidence(resource, limits, `$.resources[${index}]`));\n return value;\n }\n const record = readRecord(value, \"$\", DOCUMENT_KEYS);\n const resourceInput = readArray(requireKey(record, \"resources\", \"$\"), \"$.resources\", GPU_MODEL_DOCUMENT_LIMITS.resources, 1);\n const parsed = resourceInput.map((entry, index) => {\n if (typeof entry === \"object\" && entry !== null && verifiedResources.has(entry) && verifiedResourceBytes.has(entry)) return entry as GpuModelResource;\n return parseResourceHeader(entry, `$.resources[${index}]`);\n });\n ensureUnique(parsed.map(({ id }) => id), \"$.resources\");\n preflightResourceBudget(parsed, limits);\n const verified: GpuModelResource[] = [];\n for (let index = 0; index < parsed.length; index += 1) {\n verified.push(await verifyParsedResource(parsed[index]!, port, limits, options, `$.resources[${index}]`));\n }\n const candidate: Record<string, unknown> = {};\n for (const key of DOCUMENT_KEYS) {\n if (Object.hasOwn(record, key)) candidate[key] = record[key];\n }\n candidate.resources = verified;\n return createGpuModelDocument(candidate);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$\", \"input could not be safely inspected or verified\");\n }\n}\n\n/** Version of the bounded compiler projection used by the ChatGPT PVOX demo. */\nexport const GPU_MODEL_STATIC_DEMO_PROFILE_VERSION = \"plasius.gpu-model-static-demo/1\" as const;\n\n/** Remotely evaluated parent gate required before the demo projection may run. */\nexport const GPU_MODEL_STATIC_DEMO_FEATURE_FLAG = \"asset.pipeline.pvox-models.enabled\" as const;\n\n/** Fixed-point PVOX coordinate ceiling; callers cannot override or raise it. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES = 1_048_576 as const;\n\n/** Largest axis extent representable between the fixed coordinate endpoints. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES = GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES * 2;\n\n/** Largest three-axis diagonal representable inside the fixed coordinate cube. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_DIAGONAL_METRES = Math.hypot(\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n);\n\n/** Non-raiseable ceilings for the bounded static PVOX demonstration profile. */\nexport const GPU_MODEL_STATIC_DEMO_LIMITS = Object.freeze({\n maxTriangles: 200_000,\n maxNodes: 4_096,\n maxPrimitives: 16_384,\n maxMaterials: 4_096,\n maxResourceBytes: 16 * 1024 * 1024,\n maxAggregateResourceBytes: 16 * 1024 * 1024,\n} as const);\n\n/** Exact spatial promise required from source adapters before demo compilation. */\nexport const GPU_MODEL_STATIC_DEMO_NORMALIZATION_CONTRACT = Object.freeze({\n ...CANONICAL_GPU_MODEL_COORDINATE_SYSTEM,\n floorPlane: \"y=0\",\n horizontalCenter: \"bounds-centre-xz-at-origin\",\n} as const);\n\nexport interface GpuModelStaticDemoLimits {\n readonly maxTriangles: number;\n readonly maxNodes: number;\n readonly maxPrimitives: number;\n readonly maxMaterials: number;\n readonly maxResourceBytes: number;\n readonly maxAggregateResourceBytes: number;\n}\n\n/** Callers pass the remotely evaluated parent gate; local defaults fail closed. */\nexport interface GpuModelStaticDemoCompilerOptions {\n readonly pvoxModelsEnabled: boolean;\n readonly limits?: Partial<GpuModelStaticDemoLimits>;\n}\n\n/** URI-free evidence retained by a compiler projection. */\nexport interface GpuModelStaticDemoSourceEvidence {\n readonly sourceFormat: string;\n readonly sourceContentHash: string;\n readonly converterId: string;\n readonly converterVersion: string;\n readonly provider?: string;\n}\n\n/** Fixed, texture-free surface properties for one material region. */\nexport interface GpuModelStaticDemoMaterial {\n readonly sourceMaterialId: string | null;\n readonly sourceMaterialName?: string;\n readonly sourceWorkflow: \"metallic-roughness\" | \"unlit\";\n readonly baseColorFactor: GpuModelVec4;\n readonly metallicFactor: number;\n readonly roughnessFactor: number;\n readonly emissiveFactor: GpuModelVec3;\n readonly doubleSided: boolean;\n}\n\nexport type GpuModelTriangleVec3 = readonly [GpuModelVec3, GpuModelVec3, GpuModelVec3];\n\n/** One byte-verified source triangle transformed into canonical world space. */\nexport interface GpuModelStaticDemoWorldTriangle {\n readonly sourceNodeId: string;\n readonly sourceMeshId: string;\n readonly sourcePrimitiveId: string;\n readonly sourceTriangleIndex: number;\n readonly materialIndex: number;\n readonly positions: GpuModelTriangleVec3;\n readonly normals: GpuModelTriangleVec3;\n readonly bounds: GpuModelBounds;\n}\n\n/** Immutable, compiler-safe hand-off from model core to the PVOX compiler. */\nexport interface GpuModelStaticDemoCompilerInput {\n readonly profileVersion: typeof GPU_MODEL_STATIC_DEMO_PROFILE_VERSION;\n readonly canonicalDocumentHash: string;\n readonly coordinateSystem: typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n readonly bounds: GpuModelBounds;\n readonly sourceEvidence: GpuModelStaticDemoSourceEvidence;\n readonly materials: readonly GpuModelStaticDemoMaterial[];\n readonly worldTriangles: readonly GpuModelStaticDemoWorldTriangle[];\n}\n\nconst CANONICAL_DOCUMENT_ENCODING_VERSION = \"plasius.gpu-model-document-canonical-json/1\" as const;\n\nfunction canonicalJson(value: unknown): string {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"boolean\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) return fail(\"invalid-value\", \"$\", \"canonical encoding encountered a non-finite number\");\n return JSON.stringify(Object.is(value, -0) ? 0 : value);\n }\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(\",\")}]`;\n if (typeof value !== \"object\" || value === null || value instanceof Blob) {\n return fail(\"invalid-type\", \"$\", \"canonical encoding encountered an unsupported value\");\n }\n const entries = Object.entries(value)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);\n return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(\",\")}}`;\n}\n\nfunction canonicalDocumentRecord(document: GpuModelDocument): Readonly<Record<string, unknown>> {\n const resources = document.resources.map(({ payload: _payload, ...resource }) => resource);\n return {\n encodingVersion: CANONICAL_DOCUMENT_ENCODING_VERSION,\n document: { ...document, resources },\n };\n}\n\n/**\n * Encodes the complete verified document deterministically. Resource payloads\n * are represented by their privately verified SHA-256 identities, not copied\n * into the encoding a second time. Object keys are sorted; semantic array order\n * is preserved.\n */\nexport function encodeGpuModelDocumentCanonical(document: GpuModelDocument): Uint8Array {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"canonical encoding requires a verified GPU model document\");\n return new TextEncoder().encode(canonicalJson(canonicalDocumentRecord(document)));\n}\n\n/** Computes the lowercase SHA-256 identity of the canonical whole document. */\nexport async function hashGpuModelDocumentCanonical(document: GpuModelDocument): Promise<string> {\n const bytes = encodeGpuModelDocumentCanonical(document);\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return fail(\"unsupported-feature\", \"$\", \"SHA-256 Web Crypto is unavailable\");\n const digest = await subtle.digest(\"SHA-256\", Uint8Array.from(bytes).buffer);\n return Array.from(new Uint8Array(digest), (value) => value.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction resolveStaticDemoLimits(options: GpuModelStaticDemoCompilerOptions): Readonly<GpuModelStaticDemoLimits> {\n const record = readRecord(options, \"$.options\", [\"pvoxModelsEnabled\", \"limits\"]);\n const enabled = readBoolean(requireKey(record, \"pvoxModelsEnabled\", \"$.options\"), \"$.options.pvoxModelsEnabled\");\n if (!enabled) return fail(\"feature-disabled\", \"$.options.pvoxModelsEnabled\", `${GPU_MODEL_STATIC_DEMO_FEATURE_FLAG} is disabled`);\n if (!Object.hasOwn(record, \"limits\")) return GPU_MODEL_STATIC_DEMO_LIMITS;\n const overrides = readRecord(record.limits, \"$.options.limits\", Object.keys(GPU_MODEL_STATIC_DEMO_LIMITS));\n const limits: Record<string, number> = { ...GPU_MODEL_STATIC_DEMO_LIMITS };\n for (const [key, ceiling] of Object.entries(GPU_MODEL_STATIC_DEMO_LIMITS)) {\n if (Object.hasOwn(overrides, key)) limits[key] = readSafeInteger(overrides[key], `$.options.limits.${key}`, 1, ceiling);\n }\n return Object.freeze(limits) as unknown as Readonly<GpuModelStaticDemoLimits>;\n}\n\n/** Proves metre/Y-up/-Z/floor-centred normalization against verified bounds. */\nexport function assertGpuModelStaticDemoNormalization(document: GpuModelDocument): void {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"normalization requires a verified GPU model document\");\n const extents = document.bounds.max.map((value, index) => value - document.bounds.min[index]!);\n const diagonal = Math.hypot(...extents);\n if (!Number.isFinite(diagonal) || diagonal <= 0) return fail(\"invalid-value\", \"$.bounds\", \"static demo bounds must have a finite non-zero diagonal\");\n if ([...document.bounds.min, ...document.bounds.max].some((value) => Math.abs(value) > GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES)) {\n return fail(\"limit-exceeded\", \"$.bounds\", \"static demo coordinate magnitude exceeds the fixed PVOX ceiling\");\n }\n if (extents.some((extent) => extent > GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES)\n || diagonal > GPU_MODEL_STATIC_DEMO_MAX_DIAGONAL_METRES) {\n return fail(\"limit-exceeded\", \"$.bounds\", \"static demo extent exceeds the fixed PVOX ceiling\");\n }\n const tolerance = Math.min(1e-3, Math.max(1, diagonal) * EPSILON);\n const floorAligned = Math.abs(document.bounds.min[1]) <= tolerance;\n const centeredX = Math.abs(document.bounds.min[0] + document.bounds.max[0]) <= tolerance * 2;\n const centeredZ = Math.abs(document.bounds.min[2] + document.bounds.max[2]) <= tolerance * 2;\n if (!floorAligned || !centeredX || !centeredZ) {\n return fail(\"invalid-value\", \"$.bounds\", \"static demo geometry must be floor-centred at the canonical origin\");\n }\n}\n\nfunction determinant3(matrix: GpuModelMatrix4): number {\n const a00 = matrix[0], a01 = matrix[4], a02 = matrix[8];\n const a10 = matrix[1], a11 = matrix[5], a12 = matrix[9];\n const a20 = matrix[2], a21 = matrix[6], a22 = matrix[10];\n return a00 * (a11 * a22 - a12 * a21)\n - a01 * (a10 * a22 - a12 * a20)\n + a02 * (a10 * a21 - a11 * a20);\n}\n\nfunction normalizedVector(value: readonly number[], path: string): GpuModelVec3 {\n const length = Math.hypot(value[0]!, value[1]!, value[2]!);\n if (!Number.isFinite(length) || length <= 1e-12) return fail(\"invalid-value\", path, \"triangle or normal vector is degenerate\");\n return Object.freeze([value[0]! / length, value[1]! / length, value[2]! / length]) as GpuModelVec3;\n}\n\nfunction faceNormal(positions: GpuModelTriangleVec3, path: string): GpuModelVec3 {\n const ab = positions[1].map((value, index) => value - positions[0][index]!) as number[];\n const ac = positions[2].map((value, index) => value - positions[0][index]!) as number[];\n return normalizedVector([\n ab[1]! * ac[2]! - ab[2]! * ac[1]!,\n ab[2]! * ac[0]! - ab[0]! * ac[2]!,\n ab[0]! * ac[1]! - ab[1]! * ac[0]!,\n ], path);\n}\n\nfunction transformNormal(matrix: GpuModelMatrix4, normal: readonly number[], determinant: number, fallback: GpuModelVec3): GpuModelVec3 {\n const a00 = matrix[0], a01 = matrix[4], a02 = matrix[8];\n const a10 = matrix[1], a11 = matrix[5], a12 = matrix[9];\n const a20 = matrix[2], a21 = matrix[6], a22 = matrix[10];\n const transformed = [\n ((a11 * a22 - a12 * a21) * normal[0]! + (a12 * a20 - a10 * a22) * normal[1]! + (a10 * a21 - a11 * a20) * normal[2]!) / determinant,\n ((a02 * a21 - a01 * a22) * normal[0]! + (a00 * a22 - a02 * a20) * normal[1]! + (a01 * a20 - a00 * a21) * normal[2]!) / determinant,\n ((a01 * a12 - a02 * a11) * normal[0]! + (a02 * a10 - a00 * a12) * normal[1]! + (a00 * a11 - a01 * a10) * normal[2]!) / determinant,\n ];\n const length = Math.hypot(...transformed);\n return !Number.isFinite(length) || length <= 1e-12\n ? fallback\n : Object.freeze(transformed.map((value) => value / length)) as unknown as GpuModelVec3;\n}\n\nfunction triangleBounds(positions: GpuModelTriangleVec3): GpuModelBounds {\n const min = [0, 1, 2].map((component) => Math.min(...positions.map((position) => position[component]!))) as unknown as GpuModelVec3;\n const max = [0, 1, 2].map((component) => Math.max(...positions.map((position) => position[component]!))) as unknown as GpuModelVec3;\n return { min, max };\n}\n\nfunction assertStaticDemoTriangleCoordinates(positions: GpuModelTriangleVec3, path: string): void {\n for (let corner = 0; corner < positions.length; corner += 1) {\n for (let component = 0; component < positions[corner]!.length; component += 1) {\n if (Math.abs(positions[corner]![component]!) > GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES) {\n return fail(\"limit-exceeded\", path, \"static demo triangle coordinate exceeds the fixed PVOX ceiling\");\n }\n }\n }\n}\n\nfunction staticDemoMaterial(material: GpuModelMaterial): GpuModelStaticDemoMaterial {\n if (material.workflow !== \"metallic-roughness\" && material.workflow !== \"unlit\") {\n return fail(\"unsupported-feature\", `$.materials.${material.id}.workflow`, \"static demo supports metallic-roughness and unlit materials only\");\n }\n const unsupportedSurfaceExtension = (material.transmissionFactor ?? 0) > 0\n || (material.clearcoatFactor ?? 0) > 0\n || (material.sheenColorFactor?.some((value) => value > 0) ?? false)\n || Object.keys(material.extensions).length > 0;\n if (material.alphaMode !== \"opaque\" || material.baseColorFactor[3] !== 1 || unsupportedSurfaceExtension) {\n return fail(\"unsupported-feature\", `$.materials.${material.id}`, \"static demo supports opaque fixed-factor materials without unsupported surface extensions\");\n }\n if (Object.keys(material.textures).length > 0) {\n return fail(\"unsupported-feature\", `$.materials.${material.id}.textures`, \"static demo accepts fixed surface factors, not texture bindings\");\n }\n const output: Record<string, unknown> = {\n sourceMaterialId: material.id,\n sourceWorkflow: material.workflow,\n baseColorFactor: material.baseColorFactor,\n metallicFactor: material.metallicFactor ?? 0,\n roughnessFactor: material.roughnessFactor ?? 1,\n emissiveFactor: material.emissiveFactor ?? [0, 0, 0],\n doubleSided: material.doubleSided ?? false,\n };\n if (material.name !== undefined) output.sourceMaterialName = material.name;\n return output as unknown as GpuModelStaticDemoMaterial;\n}\n\nfunction defaultStaticDemoMaterial(): GpuModelStaticDemoMaterial {\n return {\n sourceMaterialId: null,\n sourceWorkflow: \"metallic-roughness\",\n baseColorFactor: [1, 1, 1, 1],\n metallicFactor: 0,\n roughnessFactor: 1,\n emissiveFactor: [0, 0, 0],\n doubleSided: false,\n };\n}\n\n/**\n * Produces the only compiler input accepted by the bounded ChatGPT-to-PVOX\n * demonstration. This is a strict projection, not a tolerant repair step.\n */\nexport async function createGpuModelStaticDemoCompilerInput(\n document: GpuModelDocument,\n options: GpuModelStaticDemoCompilerOptions,\n): Promise<GpuModelStaticDemoCompilerInput> {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"static demo compilation requires a verified GPU model document\");\n const limits = resolveStaticDemoLimits(options);\n assertGpuModelStaticDemoNormalization(document);\n\n if (document.nodes.length > limits.maxNodes) return fail(\"limit-exceeded\", \"$.nodes\", \"static demo node limit exceeded\");\n const primitiveCount = document.meshes.reduce((total, mesh) => total + mesh.primitives.length, 0);\n if (primitiveCount > limits.maxPrimitives) return fail(\"limit-exceeded\", \"$.meshes\", \"static demo primitive limit exceeded\");\n if (document.materials.length > limits.maxMaterials) return fail(\"limit-exceeded\", \"$.materials\", \"static demo material limit exceeded\");\n if (document.textures.length > 0) return fail(\"unsupported-feature\", \"$.textures\", \"static demo does not retain texture resources\");\n for (const [key, values] of [\n [\"skeletons\", document.skeletons], [\"joints\", document.joints], [\"skins\", document.skins],\n [\"blendShapes\", document.blendShapes], [\"animations\", document.animations], [\"analyticGeometry\", document.analyticGeometry],\n ] as const) {\n if (values.length > 0) return fail(\"unsupported-feature\", `$.${key}`, \"static demo supports rigid triangle geometry only\");\n }\n let aggregateResourceBytes = 0;\n for (let index = 0; index < document.resources.length; index += 1) {\n const resource = document.resources[index]!;\n if (resource.kind !== \"buffer\") return fail(\"unsupported-feature\", `$.resources[${index}]`, \"static demo permits buffer resources only\");\n if (resource.byteLength > limits.maxResourceBytes) return fail(\"limit-exceeded\", `$.resources[${index}].byteLength`, \"static demo resource limit exceeded\");\n aggregateResourceBytes += resource.byteLength;\n if (!Number.isSafeInteger(aggregateResourceBytes) || aggregateResourceBytes > limits.maxAggregateResourceBytes) {\n return fail(\"limit-exceeded\", \"$.resources\", \"static demo aggregate resource limit exceeded\");\n }\n }\n\n const nodes = indexById(document.nodes, \"$.nodes\");\n const meshes = indexById(document.meshes, \"$.meshes\");\n const accessors = indexById(document.accessors, \"$.accessors\");\n const resources = indexById(document.resources, \"$.resources\");\n const scene = validateScene(document.roots, document.nodes, nodes);\n const readers = new Map<string, AccessorReader>();\n const readerFor = (accessor: GpuModelAccessor, path: string): AccessorReader => {\n const existing = readers.get(accessor.id);\n if (existing) return existing;\n const resource = requireReference(resources, accessor.resourceId, path, \"resource\");\n const reader = createAccessorReader(accessor, resource, path);\n readers.set(accessor.id, reader);\n return reader;\n };\n\n const materials: GpuModelStaticDemoMaterial[] = document.materials.map(staticDemoMaterial);\n const materialIndices = new Map(document.materials.map((material, index) => [material.id, index]));\n let defaultMaterialIndex: number | undefined;\n const worldTriangles: GpuModelStaticDemoWorldTriangle[] = [];\n\n for (let nodeIndex = 0; nodeIndex < document.nodes.length; nodeIndex += 1) {\n const node = document.nodes[nodeIndex]!;\n if (node.skinId !== undefined) return fail(\"unsupported-feature\", `$.nodes[${nodeIndex}].skinId`, \"static demo nodes cannot reference skins\");\n if (!node.meshId) continue;\n const mesh = requireReference(meshes, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh\");\n const world = requireReference(scene.worldByNode, node.id, `$.nodes[${nodeIndex}]`, \"world transform\");\n const determinant = determinant3(world);\n if (!Number.isFinite(determinant) || Math.abs(determinant) <= 1e-12) {\n return fail(\"invalid-value\", `$.nodes[${nodeIndex}].localMatrix`, \"static demo world transform must be invertible\");\n }\n for (let primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex += 1) {\n const primitive = mesh.primitives[primitiveIndex]!;\n const path = `$.meshes.${mesh.id}.primitives[${primitiveIndex}]`;\n if (primitive.topology !== \"triangles\") return fail(\"unsupported-feature\", `${path}.topology`, \"static demo requires explicit triangle topology\");\n const unsupportedAttribute = primitive.attributes.find(({ semantic }) => semantic !== \"POSITION\" && semantic !== \"NORMAL\");\n if (unsupportedAttribute) return fail(\"unsupported-feature\", `${path}.attributes`, `static demo does not consume ${unsupportedAttribute.semantic}`);\n const positionAttribute = primitive.attributes.find(({ semantic }) => semantic === \"POSITION\");\n if (!positionAttribute) return fail(\"invalid-reference\", `${path}.attributes`, \"static demo requires POSITION\");\n const positionAccessor = requireReference(accessors, positionAttribute.accessorId, `${path}.attributes.POSITION`, \"accessor\");\n const positionReader = readerFor(positionAccessor, `${path}.attributes.POSITION`);\n const normalAttribute = primitive.attributes.find(({ semantic }) => semantic === \"NORMAL\");\n const normalReader = normalAttribute\n ? readerFor(requireReference(accessors, normalAttribute.accessorId, `${path}.attributes.NORMAL`, \"accessor\"), `${path}.attributes.NORMAL`)\n : undefined;\n const indexReader = primitive.indicesAccessorId\n ? readerFor(requireReference(accessors, primitive.indicesAccessorId, `${path}.indicesAccessorId`, \"accessor\"), `${path}.indicesAccessorId`)\n : undefined;\n const elementCount = indexReader?.accessor.count ?? positionAccessor.count;\n if (elementCount % 3 !== 0) return fail(\"invalid-value\", path, \"triangle element count must be divisible by three\");\n const triangleCount = elementCount / 3;\n if (worldTriangles.length + triangleCount > limits.maxTriangles) return fail(\"limit-exceeded\", path, \"static demo triangle limit exceeded\");\n let materialIndex: number;\n if (primitive.materialId !== undefined) {\n const resolvedMaterialIndex = materialIndices.get(primitive.materialId);\n if (resolvedMaterialIndex === undefined) return fail(\"missing-reference\", `${path}.materialId`, `missing material index: ${primitive.materialId}`);\n materialIndex = resolvedMaterialIndex;\n } else {\n if (defaultMaterialIndex === undefined) {\n if (materials.length >= limits.maxMaterials) return fail(\"limit-exceeded\", \"$.materials\", \"static demo material limit exceeded\");\n defaultMaterialIndex = materials.length;\n materials.push(defaultStaticDemoMaterial());\n }\n materialIndex = defaultMaterialIndex;\n }\n for (let triangleIndex = 0; triangleIndex < triangleCount; triangleIndex += 1) {\n const sourceIndices = [0, 1, 2].map((corner) => {\n const element = triangleIndex * 3 + corner;\n return indexReader ? indexReader.read(element)[0]! : element;\n });\n if (determinant < 0) [sourceIndices[1], sourceIndices[2]] = [sourceIndices[2]!, sourceIndices[1]!];\n const positions = Object.freeze(sourceIndices.map((index) => Object.freeze(transformPosition(world, positionReader.read(index))))) as unknown as GpuModelTriangleVec3;\n assertStaticDemoTriangleCoordinates(positions, `${path}.triangles[${triangleIndex}]`);\n const fallback = faceNormal(positions, `${path}.triangles[${triangleIndex}]`);\n const normals = Object.freeze(sourceIndices.map((index) => normalReader\n ? transformNormal(world, normalReader.read(index), determinant, fallback)\n : fallback)) as unknown as GpuModelTriangleVec3;\n worldTriangles.push({\n sourceNodeId: node.id,\n sourceMeshId: mesh.id,\n sourcePrimitiveId: primitive.id,\n sourceTriangleIndex: triangleIndex,\n materialIndex,\n positions,\n normals,\n bounds: triangleBounds(positions),\n });\n }\n }\n }\n if (worldTriangles.length === 0) return fail(\"invalid-value\", \"$.meshes\", \"static demo requires at least one world triangle\");\n\n const sourceEvidence: GpuModelStaticDemoSourceEvidence = {\n sourceFormat: document.provenance.sourceFormat,\n sourceContentHash: document.provenance.sourceContentHash,\n converterId: document.provenance.converterId,\n converterVersion: document.provenance.converterVersion,\n ...(document.provenance.provider !== undefined ? { provider: document.provenance.provider } : {}),\n };\n return deepFreeze({\n profileVersion: GPU_MODEL_STATIC_DEMO_PROFILE_VERSION,\n canonicalDocumentHash: await hashGpuModelDocumentCanonical(document),\n coordinateSystem: CANONICAL_GPU_MODEL_COORDINATE_SYSTEM,\n bounds: document.bounds,\n sourceEvidence,\n materials,\n worldTriangles,\n }) as unknown as GpuModelStaticDemoCompilerInput;\n}\n","/** Package identity and rollout metadata for the initial repository baseline. */\nexport const packageName = \"@plasius/gpu-model-core\" as const;\n\nexport const packageBootstrap = Object.freeze({\n packageName,\n featureFlag: \"gpu.model.conversion.enabled\",\n status: \"bootstrap\",\n} as const);\n\nexport * from \"./model-document.js\";\n"],"mappings":";AACO,IAAM,oCAAoC;AAG1C,IAAM,wCAAwC,OAAO,OAAO;AAAA,EACjE,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AACV,CAAU;AAGH,IAAM,4BAA4B,OAAO,OAAO;AAAA,EACrD,OAAO;AAAA,EACP,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,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AG,IAAI,cAAc,aAAa,GAAG;AACpF,cAAM,WAAW,WAAW,WAAW,GAAG,IAAI,cAAc,aAAa,GAAG;AAC5E,cAAM,UAAU,OAAO,OAAO,cAAc,IAAI,CAAC,UAAU,eACvD,gBAAgB,OAAO,aAAa,KAAK,KAAK,GAAG,aAAa,QAAQ,IACtE,QAAQ,CAAC;AACb,uBAAe,KAAK;AAAA,UAClB,cAAc,KAAK;AAAA,UACnB,cAAc,KAAK;AAAA,UACnB,mBAAmB,UAAU;AAAA,UAC7B,qBAAqB;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,UACA,QAAQ,eAAe,SAAS;AAAA,QAClC,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACA,MAAI,eAAe,WAAW,EAAG,QAAO,KAAK,iBAAiB,YAAY,kDAAkD;AAE5H,QAAM,iBAAmD;AAAA,IACvD,cAAc,SAAS,WAAW;AAAA,IAClC,mBAAmB,SAAS,WAAW;AAAA,IACvC,aAAa,SAAS,WAAW;AAAA,IACjC,kBAAkB,SAAS,WAAW;AAAA,IACtC,GAAI,SAAS,WAAW,aAAa,SAAY,EAAE,UAAU,SAAS,WAAW,SAAS,IAAI,CAAC;AAAA,EACjG;AACA,SAAO,WAAW;AAAA,IAChB,gBAAgB;AAAA,IAChB,uBAAuB,MAAM,8BAA8B,QAAQ;AAAA,IACnE,kBAAkB;AAAA,IAClB,QAAQ,SAAS;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;;;AC5pFO,IAAM,cAAc;AAEpB,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C;AAAA,EACA,aAAa;AAAA,EACb,QAAQ;AACV,CAAU;","names":[]}
1
+ {"version":3,"sources":["../src/model-document.ts","../src/diagnostics.ts","../src/index.ts"],"sourcesContent":["/** The only document version accepted by the v1 runtime validator. */\nexport const GPU_MODEL_DOCUMENT_SCHEMA_VERSION = \"plasius.gpu-model-document/1\" as const;\n\n/** Canonical basis shared by conversion, processing, and rendering packages. */\nexport const CANONICAL_GPU_MODEL_COORDINATE_SYSTEM = Object.freeze({\n unit: \"metre\",\n upAxis: \"y\",\n forwardAxis: \"-z\",\n handedness: \"right\",\n winding: \"counter-clockwise\",\n origin: \"floor-centred\",\n} as const);\n\n/** Fixed defensive ceilings for one canonical v1 document. */\nexport const GPU_MODEL_DOCUMENT_LIMITS = Object.freeze({\n roots: 4_096,\n nodes: 65_536,\n resources: 16_384,\n accessors: 262_144,\n accessorElements: 16_000_000,\n meshes: 65_536,\n primitives: 262_144,\n materials: 65_536,\n textures: 65_536,\n skeletons: 4_096,\n joints: 65_536,\n skins: 4_096,\n blendShapes: 65_536,\n blendShapeDeltas: 262_144,\n blendShapeAccessorReferences: 786_432,\n animations: 4_096,\n analyticGeometry: 4_096,\n diagnostics: 4_096,\n sceneEdges: 65_535,\n primitiveAttributes: 262_144,\n skinJoints: 65_536,\n weightVertices: 1_000_000,\n weightInfluences: 8_000_000,\n animationSamplers: 65_536,\n animationChannels: 262_144,\n animationValues: 8_000_000,\n geometryIndexElements: 16_000_000,\n geometryWorldAccessorInstances: 262_144,\n geometryWorldVertices: 16_000_000,\n identifierLength: 128,\n nameLength: 512,\n diagnosticMessageLength: 2_048,\n metadataDepth: 8,\n metadataValues: 4_096,\n metadataObjectKeys: 128,\n metadataArrayLength: 512,\n metadataKeyLength: 128,\n metadataStringLength: 2_048,\n} as const);\n\nexport interface GpuModelResourceVerificationLimits {\n readonly maxResourceBytes: number;\n readonly maxAggregateBytes: number;\n readonly maxImageBytes: number;\n readonly maxAggregateImageBytes: number;\n readonly maxImageDimension: number;\n readonly maxImagePixels: number;\n readonly chunkBytes: number;\n readonly timeoutMs: number;\n}\n\n/** Default verification budgets. Callers may tighten, but never raise, them. */\nexport const GPU_MODEL_RESOURCE_VERIFICATION_LIMITS: Readonly<GpuModelResourceVerificationLimits> = Object.freeze({\n maxResourceBytes: 100 * 1024 * 1024,\n maxAggregateBytes: 164 * 1024 * 1024,\n maxImageBytes: 64 * 1024 * 1024,\n maxAggregateImageBytes: 64 * 1024 * 1024,\n maxImageDimension: 4_096,\n maxImagePixels: 4_096 * 4_096,\n chunkBytes: 1024 * 1024,\n timeoutMs: 30_000,\n} as const);\n\n/** Stable machine-readable validation failure categories. */\nexport type GpuModelDocumentErrorCode =\n | \"invalid-type\"\n | \"invalid-value\"\n | \"unknown-key\"\n | \"limit-exceeded\"\n | \"feature-disabled\"\n | \"unsupported-feature\"\n | \"duplicate-id\"\n | \"missing-reference\"\n | \"invalid-reference\"\n | \"graph-cycle\"\n | \"payload-length-mismatch\"\n | \"resource-unverified\"\n | \"resource-verification-failed\"\n | \"resource-budget-exceeded\";\n\nfunction escapeDiagnosticText(value: string, maximum: number): string {\n let output = \"\";\n for (const character of value) {\n const point = character.codePointAt(0)!;\n const unsafe = point < 0x20\n || (point >= 0x7f && point <= 0x9f)\n || point === 0x2028\n || point === 0x2029\n || (point >= 0x202a && point <= 0x202e)\n || (point >= 0x2066 && point <= 0x2069)\n || (point >= 0xd800 && point <= 0xdfff);\n output += character === \"\\\\\"\n ? \"\\\\\\\\\"\n : unsafe\n ? `\\\\u${point.toString(16).padStart(point <= 0xffff ? 4 : 6, \"0\")}`\n : character;\n if (output.length >= maximum) break;\n }\n return output.slice(0, maximum);\n}\n\n/** Bounded validation error safe to return across worker boundaries. */\nexport class GpuModelDocumentError extends TypeError {\n public readonly code: GpuModelDocumentErrorCode;\n public readonly path: string;\n\n public constructor(code: GpuModelDocumentErrorCode, path: string, detail: string) {\n const safePath = escapeDiagnosticText(path, 256);\n const safeDetail = escapeDiagnosticText(detail, 512);\n super(`Invalid GPU model document at ${safePath}: ${safeDetail}`);\n this.name = \"GpuModelDocumentError\";\n this.code = code;\n this.path = safePath;\n }\n}\n\n/** JSON-compatible value accepted by bounded canonical metadata fields. */\nexport type GpuModelMetadataValue =\n | null\n | boolean\n | number\n | string\n | readonly GpuModelMetadataValue[]\n | { readonly [key: string]: GpuModelMetadataValue };\n\n/** Immutable, safe-keyed source/extension metadata. */\nexport type GpuModelMetadata = Readonly<Record<string, GpuModelMetadataValue>>;\nexport type GpuModelSourceMetadata = GpuModelMetadata;\nexport type GpuModelVec2 = readonly [number, number];\nexport type GpuModelVec3 = readonly [number, number, number];\nexport type GpuModelVec4 = readonly [number, number, number, number];\n/** Column-major 4 x 4 affine matrix. */\nexport type GpuModelMatrix4 = readonly [\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n number, number, number, number,\n];\n\nexport interface GpuModelTransformTrs {\n readonly translation: GpuModelVec3;\n readonly rotation: GpuModelVec4;\n readonly scale: GpuModelVec3;\n}\n\nexport interface GpuModelBounds {\n readonly min: GpuModelVec3;\n readonly max: GpuModelVec3;\n}\n\nexport interface GpuModelNode {\n readonly id: string;\n readonly name?: string;\n readonly children: readonly string[];\n readonly meshId?: string;\n readonly skinId?: string;\n readonly localMatrix: GpuModelMatrix4;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelResourceKind = \"buffer\" | \"image\";\n\n/** Privately attestable immutable payload. Verification status is never shape-based. */\nexport interface GpuModelResource {\n readonly id: string;\n readonly kind: GpuModelResourceKind;\n readonly contentHash: string;\n readonly byteLength: number;\n readonly mimeType: string;\n readonly payload: Blob;\n}\n\nexport interface GpuModelResourceVerificationContext {\n readonly resourceId: string;\n readonly kind: GpuModelResourceKind;\n readonly declaredMimeType: string;\n readonly byteLength: number;\n readonly signal?: AbortSignal;\n}\n\nexport interface GpuModelResourceInspection {\n readonly valid: boolean;\n readonly detectedMimeType: string;\n readonly width?: number;\n readonly height?: number;\n}\n\n/** Trusted, injected worker boundary for streaming digest and payload inspection. */\nexport interface GpuModelResourceVerificationPort {\n digestSha256(\n chunks: AsyncIterable<Uint8Array>,\n context: GpuModelResourceVerificationContext,\n ): Promise<string>;\n inspectResource(\n chunks: AsyncIterable<Uint8Array>,\n context: GpuModelResourceVerificationContext,\n ): Promise<GpuModelResourceInspection>;\n}\n\nexport interface GpuModelResourceVerificationOptions {\n readonly signal?: AbortSignal;\n readonly limits?: Partial<GpuModelResourceVerificationLimits>;\n}\n\nexport type GpuModelAccessorComponentType = \"i8\" | \"u8\" | \"i16\" | \"u16\" | \"u32\" | \"f32\";\nexport type GpuModelAccessorElementType = \"scalar\" | \"vec2\" | \"vec3\" | \"vec4\" | \"mat2\" | \"mat3\" | \"mat4\";\n\nexport interface GpuModelAccessor {\n readonly id: string;\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteStride?: number;\n readonly count: number;\n readonly componentType: GpuModelAccessorComponentType;\n readonly elementType: GpuModelAccessorElementType;\n readonly normalized?: boolean;\n readonly min?: readonly number[];\n readonly max?: readonly number[];\n}\n\nexport interface GpuModelPrimitiveAttribute {\n readonly semantic: string;\n readonly accessorId: string;\n}\n\nexport type GpuModelPrimitiveTopology = \"points\" | \"lines\" | \"line-strip\" | \"triangles\" | \"triangle-strip\";\n\nexport interface GpuModelPrimitive {\n readonly id: string;\n readonly topology: GpuModelPrimitiveTopology;\n readonly attributes: readonly GpuModelPrimitiveAttribute[];\n readonly indicesAccessorId?: string;\n readonly materialId?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport interface GpuModelMesh {\n readonly id: string;\n readonly name?: string;\n readonly primitives: readonly GpuModelPrimitive[];\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelTextureColorSpace = \"srgb\" | \"linear\" | \"normal-map\" | \"data\";\nexport type GpuModelTextureUsage =\n | \"base-color\"\n | \"metallic-roughness\"\n | \"normal\"\n | \"occlusion\"\n | \"emissive\"\n | \"transmission\"\n | \"clearcoat\"\n | \"clearcoat-roughness\"\n | \"clearcoat-normal\"\n | \"sheen-color\"\n | \"sheen-roughness\";\n\nexport interface GpuModelTextureTransform {\n readonly offset?: GpuModelVec2;\n readonly rotationRadians?: number;\n readonly scale?: GpuModelVec2;\n}\n\nexport interface GpuModelTextureBinding {\n readonly textureId: string;\n readonly samplerId?: string;\n readonly texCoordSet?: number;\n readonly transform?: GpuModelTextureTransform;\n readonly colorSpace: GpuModelTextureColorSpace;\n readonly intendedUsage: GpuModelTextureUsage;\n}\n\nexport type GpuModelAlphaMode = \"opaque\" | \"mask\" | \"blend\";\nexport type GpuModelMaterialWorkflow = \"metallic-roughness\" | \"specular-glossiness\" | \"unlit\" | \"custom\";\n\nexport interface GpuModelMaterialTextures {\n readonly baseColor?: GpuModelTextureBinding;\n readonly metallicRoughness?: GpuModelTextureBinding;\n readonly normal?: GpuModelTextureBinding;\n readonly occlusion?: GpuModelTextureBinding;\n readonly emissive?: GpuModelTextureBinding;\n readonly transmission?: GpuModelTextureBinding;\n readonly clearcoat?: GpuModelTextureBinding;\n readonly clearcoatRoughness?: GpuModelTextureBinding;\n readonly clearcoatNormal?: GpuModelTextureBinding;\n readonly sheenColor?: GpuModelTextureBinding;\n readonly sheenRoughness?: GpuModelTextureBinding;\n}\n\nexport interface GpuModelMaterial {\n readonly id: string;\n readonly name?: string;\n readonly workflow: GpuModelMaterialWorkflow;\n readonly alphaMode: GpuModelAlphaMode;\n readonly alphaCutoff?: number;\n readonly doubleSided?: boolean;\n readonly baseColorFactor: GpuModelVec4;\n readonly metallicFactor?: number;\n readonly roughnessFactor?: number;\n readonly emissiveFactor?: GpuModelVec3;\n readonly transmissionFactor?: number;\n readonly clearcoatFactor?: number;\n readonly clearcoatRoughnessFactor?: number;\n readonly sheenColorFactor?: GpuModelVec3;\n readonly sheenRoughnessFactor?: number;\n readonly normalScale?: number;\n readonly occlusionStrength?: number;\n readonly textures: GpuModelMaterialTextures;\n readonly extensions: GpuModelMetadata;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelTextureWrap = \"repeat\" | \"mirrored-repeat\" | \"clamp-to-edge\";\nexport interface GpuModelTextureSampler {\n readonly id: string;\n readonly wrapS?: GpuModelTextureWrap;\n readonly wrapT?: GpuModelTextureWrap;\n readonly minFilter?: string;\n readonly magFilter?: string;\n readonly mipFilter?: \"nearest\" | \"linear\";\n}\n\nexport type GpuModelTextureEmbeddingPolicy = \"inherit-source\" | \"prefer-embedded\" | \"prefer-external\" | \"forbid-embedding\";\n\n/** Texture fidelity node; embedded bytes are addressed through imageResourceId. */\nexport interface GpuModelTexture {\n readonly id: string;\n readonly fileName?: string;\n readonly relativePath?: string;\n readonly mimeType?: string;\n readonly contentHash: string;\n readonly imageResourceId: string;\n readonly byteLength?: number;\n readonly intendedUsage: readonly GpuModelTextureUsage[];\n readonly colorSpace: GpuModelTextureColorSpace;\n readonly sampler?: GpuModelTextureSampler;\n readonly exportEmbeddingPolicy: GpuModelTextureEmbeddingPolicy;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelSkeleton {\n readonly id: string;\n readonly name?: string;\n readonly jointIds: readonly string[];\n readonly rootJointIds: readonly string[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelJoint {\n readonly id: string;\n readonly name?: string;\n readonly nodeId: string;\n readonly parentJointId?: string;\n readonly restLocalTransform: GpuModelTransformTrs;\n readonly inverseBindMatrix?: GpuModelMatrix4;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelVertexWeightSet {\n readonly primitiveId: string;\n readonly influencesPerVertex: number;\n readonly joints: readonly (readonly number[])[];\n readonly weights: readonly (readonly number[])[];\n}\n\nexport interface GpuModelSkin {\n readonly id: string;\n readonly skeletonId: string;\n readonly jointIds: readonly string[];\n readonly inverseBindMatrices: readonly GpuModelMatrix4[];\n readonly weightSets: readonly GpuModelVertexWeightSet[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelBlendShapeDelta {\n readonly primitiveId: string;\n readonly positionAccessorId?: string;\n readonly normalAccessorId?: string;\n readonly tangentAccessorId?: string;\n}\n\nexport interface GpuModelBlendShape {\n readonly id: string;\n readonly meshId: string;\n readonly name?: string;\n readonly defaultWeight?: number;\n readonly deltas: readonly GpuModelBlendShapeDelta[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelAnimationInterpolation = \"step\" | \"linear\" | \"cubic-spline\";\nexport interface GpuModelAnimationSampler {\n readonly id: string;\n readonly inputAccessorId: string;\n readonly outputAccessorId: string;\n readonly inputTimesSeconds: readonly number[];\n readonly outputValues: readonly number[];\n readonly interpolation: GpuModelAnimationInterpolation;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelAnimationTargetType = \"node-translation\" | \"node-rotation\" | \"node-scale\" | \"weights\";\nexport interface GpuModelAnimationChannel {\n readonly id: string;\n readonly samplerId: string;\n readonly targetType: GpuModelAnimationTargetType;\n readonly targetId: string;\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport interface GpuModelAnimation {\n readonly id: string;\n readonly name?: string;\n readonly durationSeconds: number;\n readonly samplers: readonly GpuModelAnimationSampler[];\n readonly channels: readonly GpuModelAnimationChannel[];\n readonly sourceMetadata: GpuModelSourceMetadata;\n}\n\nexport type GpuModelSourceUnit = \"metre\" | \"millimetre\" | \"centimetre\" | \"inch\" | \"foot\" | \"unitless\";\nexport interface GpuModelAnalyticGeometry {\n readonly id: string;\n readonly kind: \"brep-placeholder\";\n readonly sourceResourceId: string;\n readonly sourceUnit: GpuModelSourceUnit;\n readonly tessellatedMeshId?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport interface GpuModelProvenance {\n readonly sourceFormat: string;\n readonly sourceContentHash: string;\n readonly converterId: string;\n readonly converterVersion: string;\n readonly provider?: string;\n readonly sourceIdentifier?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\nexport type GpuModelDiagnosticSeverity = \"info\" | \"warning\" | \"error\";\nexport interface GpuModelDiagnostic {\n readonly severity: GpuModelDiagnosticSeverity;\n readonly code: string;\n readonly message: string;\n readonly path?: string;\n readonly metadata?: GpuModelMetadata;\n}\n\n/** Complete immutable renderer-neutral canonical model document v1. */\nexport interface GpuModelDocument {\n readonly schemaVersion: typeof GPU_MODEL_DOCUMENT_SCHEMA_VERSION;\n readonly coordinateSystem: typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n readonly roots: readonly string[];\n readonly nodes: readonly GpuModelNode[];\n readonly resources: readonly GpuModelResource[];\n readonly accessors: readonly GpuModelAccessor[];\n readonly meshes: readonly GpuModelMesh[];\n readonly materials: readonly GpuModelMaterial[];\n readonly textures: readonly GpuModelTexture[];\n readonly skeletons: readonly GpuModelSkeleton[];\n readonly joints: readonly GpuModelJoint[];\n readonly skins: readonly GpuModelSkin[];\n readonly blendShapes: readonly GpuModelBlendShape[];\n readonly animations: readonly GpuModelAnimation[];\n readonly analyticGeometry: readonly GpuModelAnalyticGeometry[];\n readonly bounds: GpuModelBounds;\n readonly provenance: GpuModelProvenance;\n readonly diagnostics: readonly GpuModelDiagnostic[];\n readonly metadata: GpuModelMetadata;\n}\n\ntype UnknownRecord = Record<string, unknown>;\ntype VerificationLimits = Readonly<GpuModelResourceVerificationLimits>;\n\nconst PROHIBITED_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\nconst IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;\nconst METADATA_KEY = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/u;\nconst TOKEN = /^[A-Za-z0-9][A-Za-z0-9.+_-]{0,127}$/u;\nconst ATTRIBUTE_SEMANTIC = /^(?:POSITION|NORMAL|TANGENT|TEXCOORD_[0-7]|COLOR_[0-7]|JOINTS_[0-7]|WEIGHTS_[0-7]|_[A-Z][A-Z0-9_]{0,62})$/u;\nconst SHA_256 = /^[a-f0-9]{64}$/u;\nconst MIME_TYPE = /^[a-z0-9][a-z0-9!#$&^_.+-]{0,63}\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,63}$/u;\nconst RELATIVE_PATH = /^(?!\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))(?!.*\\\\)(?![a-z][a-z0-9+.-]*:).{1,2048}$/iu;\nconst FILE_NAME = /^(?!\\.{1,2}$)(?!.*[\\\\/]).{1,512}$/u;\nconst GPU_FLOAT_MAX = 3.402_823_466_385_288_6e38;\nconst EPSILON = 1e-5;\nconst BOUNDS_ABSOLUTE_EPSILON = 1e-5;\nconst COMPONENT_BYTES: Readonly<Record<GpuModelAccessorComponentType, number>> = Object.freeze({\n i8: 1, u8: 1, i16: 2, u16: 2, u32: 4, f32: 4,\n});\nconst ELEMENT_COMPONENTS: Readonly<Record<GpuModelAccessorElementType, number>> = Object.freeze({\n scalar: 1, vec2: 2, vec3: 3, vec4: 4, mat2: 4, mat3: 9, mat4: 16,\n});\nconst COMPONENT_RANGES: Readonly<Record<GpuModelAccessorComponentType, readonly [number, number, boolean]>> = Object.freeze({\n i8: [-128, 127, true],\n u8: [0, 255, true],\n i16: [-32_768, 32_767, true],\n u16: [0, 65_535, true],\n u32: [0, 4_294_967_295, true],\n f32: [-GPU_FLOAT_MAX, GPU_FLOAT_MAX, false],\n});\nconst IMAGE_MIME_TYPES = new Set([\"image/jpeg\", \"image/ktx2\", \"image/png\", \"image/webp\"]);\nconst BUFFER_MIME_TYPES = new Set([\"application/octet-stream\", \"application/vnd.plasius.gpu-buffer\"]);\nconst TEXTURE_USAGES: readonly GpuModelTextureUsage[] = Object.freeze([\n \"base-color\", \"metallic-roughness\", \"normal\", \"occlusion\", \"emissive\", \"transmission\",\n \"clearcoat\", \"clearcoat-roughness\", \"clearcoat-normal\", \"sheen-color\", \"sheen-roughness\",\n]);\nconst MATERIAL_TEXTURE_SLOTS = Object.freeze({\n baseColor: \"base-color\",\n metallicRoughness: \"metallic-roughness\",\n normal: \"normal\",\n occlusion: \"occlusion\",\n emissive: \"emissive\",\n transmission: \"transmission\",\n clearcoat: \"clearcoat\",\n clearcoatRoughness: \"clearcoat-roughness\",\n clearcoatNormal: \"clearcoat-normal\",\n sheenColor: \"sheen-color\",\n sheenRoughness: \"sheen-roughness\",\n} as const satisfies Readonly<Record<keyof GpuModelMaterialTextures, GpuModelTextureUsage>>);\n\nconst verifiedResources = new WeakSet<object>();\nconst verifiedResourceBytes = new WeakMap<object, Uint8Array>();\nconst verifiedResourceEvidence = new WeakMap<object, GpuModelResourceInspection>();\nconst validatedDocuments = new WeakSet<object>();\n\ninterface DocumentBudget {\n metadataValues: number;\n sceneEdges: number;\n primitiveAttributes: number;\n accessorElements: number;\n primitives: number;\n skinJoints: number;\n weightVertices: number;\n weightInfluences: number;\n animationSamplers: number;\n animationChannels: number;\n animationValues: number;\n blendShapeDeltas: number;\n blendShapeAccessorReferences: number;\n geometryIndexElements: number;\n geometryWorldAccessorInstances: number;\n geometryWorldVertices: number;\n}\n\nfunction fail(code: GpuModelDocumentErrorCode, path: string, detail: string): never {\n throw new GpuModelDocumentError(code, path, detail);\n}\n\nfunction readRecord(value: unknown, path: string, allowedKeys: readonly string[]): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return fail(\"invalid-type\", path, \"expected an object\");\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return fail(\"invalid-type\", path, \"expected a plain object\");\n }\n const allowed = new Set(allowedKeys);\n for (const key of Reflect.ownKeys(value)) {\n if (typeof key !== \"string\") return fail(\"unknown-key\", path, \"symbol keys are not permitted\");\n if (PROHIBITED_KEYS.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"prohibited object key\");\n if (!allowed.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"unknown key\");\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) {\n return fail(\"invalid-type\", `${path}.${key}`, \"properties must be enumerable data properties\");\n }\n }\n return value as UnknownRecord;\n}\n\nfunction requireKey(record: UnknownRecord, key: string, path: string): unknown {\n if (!Object.hasOwn(record, key)) return fail(\"invalid-value\", `${path}.${key}`, \"required key is missing\");\n return record[key];\n}\n\nfunction readArray(value: unknown, path: string, maximum: number, minimum = 0): readonly unknown[] {\n if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) {\n return fail(\"invalid-type\", path, \"expected an array\");\n }\n if (value.length < minimum || value.length > maximum) {\n return fail(\"limit-exceeded\", path, `array length must be between ${minimum} and ${maximum}`);\n }\n for (let index = 0; index < value.length; index += 1) {\n const descriptor = Object.getOwnPropertyDescriptor(value, String(index));\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) {\n return fail(\"invalid-type\", `${path}[${index}]`, \"array entries must be enumerable data properties\");\n }\n }\n for (const key of Reflect.ownKeys(value)) {\n if (key === \"length\") continue;\n if (typeof key === \"string\" && /^(?:0|[1-9][0-9]*)$/u.test(key) && Number(key) < value.length) continue;\n return fail(\"unknown-key\", path, \"array properties and symbol keys are not permitted\");\n }\n return value;\n}\n\nfunction hasInvalidText(value: string): boolean {\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index);\n if (code <= 0x1f || (code >= 0x7f && code <= 0x9f) || code === 0x2028 || code === 0x2029) return true;\n if (code >= 0xd800 && code <= 0xdbff) {\n const trailing = value.charCodeAt(index + 1);\n if (!Number.isInteger(trailing) || trailing < 0xdc00 || trailing > 0xdfff) return true;\n index += 1;\n } else if (code >= 0xdc00 && code <= 0xdfff) return true;\n }\n return false;\n}\n\nfunction readString(value: unknown, path: string, maximum: number, pattern?: RegExp): string {\n if (typeof value !== \"string\") return fail(\"invalid-type\", path, \"expected a string\");\n if (value.length === 0 || value.length > maximum) {\n return fail(\"limit-exceeded\", path, `string length must be between 1 and ${maximum}`);\n }\n if (hasInvalidText(value)) return fail(\"invalid-value\", path, \"string must contain well-formed text without control characters\");\n if (pattern && !pattern.test(value)) return fail(\"invalid-value\", path, \"string has an invalid format\");\n return value;\n}\n\nfunction readId(value: unknown, path: string): string {\n return readString(value, path, GPU_MODEL_DOCUMENT_LIMITS.identifierLength, IDENTIFIER);\n}\n\nfunction readSha256(value: unknown, path: string): string {\n if (typeof value !== \"string\" || !SHA_256.test(value)) {\n return fail(\"invalid-value\", path, \"expected a lowercase hexadecimal SHA-256 digest\");\n }\n return value;\n}\n\nfunction readBoolean(value: unknown, path: string): boolean {\n if (typeof value !== \"boolean\") return fail(\"invalid-type\", path, \"expected a boolean\");\n return value;\n}\n\nfunction readFinite(value: unknown, path: string, minimum?: number, maximum?: number): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return fail(\"invalid-value\", path, \"expected a finite number\");\n const lower = minimum ?? -GPU_FLOAT_MAX;\n const upper = maximum ?? GPU_FLOAT_MAX;\n if (value < lower || value > upper) return fail(\"invalid-value\", path, `number must be between ${String(lower)} and ${String(upper)}`);\n return Object.is(value, -0) ? 0 : value;\n}\n\nfunction readSafeInteger(value: unknown, path: string, minimum = 0, maximum = Number.MAX_SAFE_INTEGER): number {\n if (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < minimum || value > maximum) {\n return fail(\"invalid-value\", path, `expected a safe integer between ${minimum} and ${maximum}`);\n }\n return value;\n}\n\nfunction readEnum<T extends string>(value: unknown, path: string, allowed: readonly T[]): T {\n if (typeof value !== \"string\" || !(allowed as readonly string[]).includes(value)) {\n return fail(\"invalid-value\", path, `expected one of: ${allowed.join(\", \")}`);\n }\n return value as T;\n}\n\nfunction readNumberTuple(value: unknown, path: string, length: number, minimum?: number, maximum?: number): readonly number[] {\n const input = readArray(value, path, length, length);\n return Object.freeze(input.map((entry, index) => readFinite(entry, `${path}[${index}]`, minimum, maximum)));\n}\n\nfunction readOptional<T>(record: UnknownRecord, key: string, parser: (value: unknown, path: string) => T, path: string): T | undefined {\n if (!Object.hasOwn(record, key)) return undefined;\n return parser(record[key], `${path}.${key}`);\n}\n\nfunction assignOptional<T extends object, K extends PropertyKey, V>(target: T, key: K, value: V | undefined): void {\n if (value !== undefined) Object.assign(target, { [key]: value });\n}\n\nfunction consumeBudget(budget: DocumentBudget, key: keyof DocumentBudget, amount: number, maximum: number, path: string, label: string): void {\n budget[key] += amount;\n if (!Number.isSafeInteger(budget[key]) || budget[key] > maximum) {\n return fail(\"limit-exceeded\", path, `document ${label} count exceeds the limit`);\n }\n}\n\nfunction readMetadataValue(value: unknown, path: string, depth: number, budget: DocumentBudget): GpuModelMetadataValue {\n consumeBudget(budget, \"metadataValues\", 1, GPU_MODEL_DOCUMENT_LIMITS.metadataValues, path, \"metadata value\");\n if (value === null || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") return readFinite(value, path);\n if (typeof value === \"string\") return readString(value, path, GPU_MODEL_DOCUMENT_LIMITS.metadataStringLength);\n if (depth >= GPU_MODEL_DOCUMENT_LIMITS.metadataDepth) return fail(\"limit-exceeded\", path, \"metadata nesting is too deep\");\n if (Array.isArray(value)) {\n const input = readArray(value, path, GPU_MODEL_DOCUMENT_LIMITS.metadataArrayLength);\n return Object.freeze(input.map((entry, index) => readMetadataValue(entry, `${path}[${index}]`, depth + 1, budget)));\n }\n if (typeof value !== \"object\" || value === null) return fail(\"invalid-type\", path, \"metadata value is not JSON-compatible\");\n const record = value as object;\n const prototype = Object.getPrototypeOf(record);\n if (prototype !== Object.prototype && prototype !== null) return fail(\"invalid-type\", path, \"metadata objects must be plain objects\");\n const keys = Reflect.ownKeys(record);\n if (keys.length > GPU_MODEL_DOCUMENT_LIMITS.metadataObjectKeys) return fail(\"limit-exceeded\", path, \"metadata object has too many keys\");\n const output: Record<string, GpuModelMetadataValue> = {};\n for (const key of keys) {\n if (typeof key !== \"string\") return fail(\"unknown-key\", path, \"metadata symbol keys are not permitted\");\n if (PROHIBITED_KEYS.has(key)) return fail(\"unknown-key\", `${path}.${key}`, \"prohibited metadata key\");\n readString(key, `${path}.[key]`, GPU_MODEL_DOCUMENT_LIMITS.metadataKeyLength, METADATA_KEY);\n const descriptor = Object.getOwnPropertyDescriptor(record, key);\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) return fail(\"invalid-type\", `${path}.${key}`, \"metadata properties must be enumerable data properties\");\n output[key] = readMetadataValue(descriptor.value, `${path}.${key}`, depth + 1, budget);\n }\n return Object.freeze(output);\n}\n\nfunction readMetadata(value: unknown, path: string, budget: DocumentBudget): GpuModelMetadata {\n const parsed = readMetadataValue(value, path, 0, budget);\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return fail(\"invalid-type\", path, \"metadata must be an object\");\n return parsed as GpuModelMetadata;\n}\n\nfunction parseCoordinateSystem(value: unknown): typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM {\n const path = \"$.coordinateSystem\";\n const record = readRecord(value, path, [\"unit\", \"upAxis\", \"forwardAxis\", \"handedness\", \"winding\", \"origin\"]);\n for (const [key, expected] of Object.entries(CANONICAL_GPU_MODEL_COORDINATE_SYSTEM)) {\n if (requireKey(record, key, path) !== expected) return fail(\"invalid-value\", `${path}.${key}`, \"coordinate system is not canonical\");\n }\n return CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n}\n\nfunction parseMatrix(value: unknown, path: string, requireAffine = true): GpuModelMatrix4 {\n const matrix = readNumberTuple(value, path, 16) as GpuModelMatrix4;\n if (requireAffine && (matrix[3] !== 0 || matrix[7] !== 0 || matrix[11] !== 0 || matrix[15] !== 1)) {\n return fail(\"invalid-value\", path, \"matrix must be affine, with a [0, 0, 0, 1] projective row\");\n }\n return matrix;\n}\n\nfunction parseBounds(value: unknown, path: string): GpuModelBounds {\n const record = readRecord(value, path, [\"min\", \"max\"]);\n const min = readNumberTuple(requireKey(record, \"min\", path), `${path}.min`, 3) as GpuModelVec3;\n const max = readNumberTuple(requireKey(record, \"max\", path), `${path}.max`, 3) as GpuModelVec3;\n for (let index = 0; index < 3; index += 1) {\n if (min[index]! > max[index]!) return fail(\"invalid-value\", path, \"bounds min cannot exceed max\");\n }\n return { min, max };\n}\n\nfunction parseTransformTrs(value: unknown, path: string): GpuModelTransformTrs {\n const record = readRecord(value, path, [\"translation\", \"rotation\", \"scale\"]);\n const translation = readNumberTuple(requireKey(record, \"translation\", path), `${path}.translation`, 3) as GpuModelVec3;\n const rotation = readNumberTuple(requireKey(record, \"rotation\", path), `${path}.rotation`, 4) as GpuModelVec4;\n const scale = readNumberTuple(requireKey(record, \"scale\", path), `${path}.scale`, 3) as GpuModelVec3;\n const magnitude = Math.hypot(...rotation);\n if (!almostEqual(magnitude, 1, 1e-4)) return fail(\"invalid-value\", `${path}.rotation`, \"rotation quaternion must be normalized\");\n return { translation, rotation, scale };\n}\n\nconst blobSizeGetter = Object.getOwnPropertyDescriptor(Blob.prototype, \"size\")!.get!;\nconst blobTypeGetter = Object.getOwnPropertyDescriptor(Blob.prototype, \"type\")!.get!;\nconst blobSlice = Blob.prototype.slice;\nconst blobArrayBuffer = Blob.prototype.arrayBuffer;\n\nfunction intrinsicBlobSize(blob: Blob): number {\n return Reflect.apply(blobSizeGetter, blob, []) as number;\n}\n\nfunction intrinsicBlobType(blob: Blob): string {\n return Reflect.apply(blobTypeGetter, blob, []) as string;\n}\n\nfunction intrinsicBlobSlice(blob: Blob, start: number, end: number, contentType?: string): Blob {\n return Reflect.apply(blobSlice, blob, contentType === undefined ? [start, end] : [start, end, contentType]) as Blob;\n}\n\nfunction intrinsicBlobArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\n return Reflect.apply(blobArrayBuffer, blob, []) as Promise<ArrayBuffer>;\n}\n\nfunction parseResourceHeader(value: unknown, path: string): GpuModelResource {\n const record = readRecord(value, path, [\"id\", \"kind\", \"contentHash\", \"byteLength\", \"mimeType\", \"payload\"]);\n const kind = readEnum(requireKey(record, \"kind\", path), `${path}.kind`, [\"buffer\", \"image\"] as const);\n const mimeType = readString(requireKey(record, \"mimeType\", path), `${path}.mimeType`, 128, MIME_TYPE).toLowerCase();\n if (kind === \"image\" ? !IMAGE_MIME_TYPES.has(mimeType) : !BUFFER_MIME_TYPES.has(mimeType)) {\n return fail(\"invalid-value\", `${path}.mimeType`, `unsupported ${kind} MIME type`);\n }\n const payload = requireKey(record, \"payload\", path);\n if (!(payload instanceof Blob)) return fail(\"invalid-type\", `${path}.payload`, \"expected an immutable Blob payload\");\n if (Object.getPrototypeOf(payload) !== Blob.prototype || Reflect.ownKeys(payload).some((key) => typeof key === \"string\")) {\n return fail(\"invalid-type\", `${path}.payload`, \"expected a native Blob without caller-defined properties\");\n }\n const byteLength = readSafeInteger(requireKey(record, \"byteLength\", path), `${path}.byteLength`, 1);\n if (intrinsicBlobSize(payload) !== byteLength) return fail(\"payload-length-mismatch\", `${path}.payload`, \"payload byte length does not match byteLength\");\n const payloadType = intrinsicBlobType(payload);\n if (payloadType && payloadType.toLowerCase() !== mimeType) return fail(\"invalid-value\", `${path}.payload`, \"payload MIME type does not match mimeType\");\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n kind,\n contentHash: readSha256(requireKey(record, \"contentHash\", path), `${path}.contentHash`),\n byteLength,\n mimeType,\n payload,\n };\n}\n\nfunction resolveVerificationLimits(options?: GpuModelResourceVerificationOptions): VerificationLimits {\n const overrides = options?.limits;\n if (overrides === undefined) return GPU_MODEL_RESOURCE_VERIFICATION_LIMITS;\n const record = readRecord(overrides, \"$.verification.limits\", Object.keys(GPU_MODEL_RESOURCE_VERIFICATION_LIMITS));\n const output = { ...GPU_MODEL_RESOURCE_VERIFICATION_LIMITS };\n for (const [key, ceiling] of Object.entries(GPU_MODEL_RESOURCE_VERIFICATION_LIMITS) as Array<[keyof VerificationLimits, number]>) {\n if (!Object.hasOwn(record, key)) continue;\n const value = readSafeInteger(record[key], `$.verification.limits.${key}`, 1, ceiling);\n Object.assign(output, { [key]: value });\n }\n if (output.maxImageBytes > output.maxResourceBytes) output.maxImageBytes = output.maxResourceBytes;\n if (output.maxAggregateImageBytes > output.maxAggregateBytes) output.maxAggregateImageBytes = output.maxAggregateBytes;\n return Object.freeze(output);\n}\n\nfunction preflightResourceBudget(resources: readonly GpuModelResource[], limits: VerificationLimits): void {\n let aggregate = 0;\n let aggregateImages = 0;\n for (let index = 0; index < resources.length; index += 1) {\n const resource = resources[index]!;\n const path = `$.resources[${index}]`;\n if (resource.byteLength > limits.maxResourceBytes) return fail(\"resource-budget-exceeded\", `${path}.byteLength`, \"resource byte budget exceeded\");\n if (resource.kind === \"image\" && resource.byteLength > limits.maxImageBytes) {\n return fail(\"resource-budget-exceeded\", `${path}.byteLength`, \"image resource byte budget exceeded\");\n }\n aggregate += resource.byteLength;\n if (!Number.isSafeInteger(aggregate) || aggregate > limits.maxAggregateBytes) {\n return fail(\"resource-budget-exceeded\", \"$.resources\", \"aggregate resource byte budget exceeded\");\n }\n if (resource.kind === \"image\") {\n aggregateImages += resource.byteLength;\n if (!Number.isSafeInteger(aggregateImages) || aggregateImages > limits.maxAggregateImageBytes) {\n return fail(\"resource-budget-exceeded\", \"$.resources\", \"aggregate image byte budget exceeded\");\n }\n }\n }\n}\n\nfunction assertVerifiedResourceEvidence(\n resource: GpuModelResource,\n limits: VerificationLimits,\n path: string,\n): void {\n const evidence = verifiedResourceEvidence.get(resource);\n if (!evidence) return fail(\"resource-unverified\", path, \"verified resource inspection evidence is unavailable\");\n if (resource.kind !== \"image\") return;\n const width = evidence.width;\n const height = evidence.height;\n if (width === undefined || height === undefined) {\n return fail(\"resource-verification-failed\", path, \"verified image inspection evidence is incomplete\");\n }\n if (width > limits.maxImageDimension || height > limits.maxImageDimension || width * height > limits.maxImagePixels) {\n return fail(\"resource-budget-exceeded\", path, \"image dimension budget exceeded\");\n }\n}\n\nfunction cachedResourceWithinLimits(\n resource: GpuModelResource,\n limits: VerificationLimits,\n path: string,\n): GpuModelResource {\n preflightResourceBudget([resource], limits);\n assertVerifiedResourceEvidence(resource, limits, path);\n return resource;\n}\n\nfunction verificationAbortError(signal: AbortSignal, path: string): GpuModelDocumentError {\n return signal.reason instanceof GpuModelDocumentError\n ? signal.reason\n : new GpuModelDocumentError(\"resource-verification-failed\", path, \"resource verification was aborted\");\n}\n\nfunction throwIfVerificationAborted(signal: AbortSignal, path: string): void {\n if (signal.aborted) throw verificationAbortError(signal, path);\n}\n\nfunction createBlobChunks(\n blob: Blob,\n chunkBytes: number,\n observed: { bytes: number },\n signal: AbortSignal,\n path: string,\n snapshot?: Uint8Array,\n): AsyncIterable<Uint8Array> {\n return {\n async *[Symbol.asyncIterator]() {\n const size = intrinsicBlobSize(blob);\n for (let offset = 0; offset < size; offset += chunkBytes) {\n throwIfVerificationAborted(signal, path);\n const end = Math.min(size, offset + chunkBytes);\n const chunk = new Uint8Array(await intrinsicBlobArrayBuffer(intrinsicBlobSlice(blob, offset, end)));\n throwIfVerificationAborted(signal, path);\n observed.bytes += chunk.byteLength;\n if (snapshot) snapshot.set(chunk, offset);\n yield chunk;\n }\n throwIfVerificationAborted(signal, path);\n },\n };\n}\n\ninterface VerificationDeadline {\n readonly signal: AbortSignal;\n race<T>(operation: () => Promise<T> | T): Promise<T>;\n throwIfAborted(): void;\n dispose(): void;\n}\n\nfunction createVerificationDeadline(timeoutMs: number, callerSignal: AbortSignal | undefined, path: string): VerificationDeadline {\n const controller = new AbortController();\n const abort = (detail: string): void => {\n if (!controller.signal.aborted) {\n controller.abort(new GpuModelDocumentError(\"resource-verification-failed\", path, detail));\n }\n };\n const callerAbort = (): void => abort(\"resource verification was aborted\");\n if (callerSignal?.aborted) callerAbort();\n else callerSignal?.addEventListener(\"abort\", callerAbort, { once: true });\n const timeout = setTimeout(() => abort(\"resource verification deadline exceeded\"), timeoutMs);\n timeout.unref?.();\n return {\n signal: controller.signal,\n async race<T>(operation: () => Promise<T> | T): Promise<T> {\n throwIfVerificationAborted(controller.signal, path);\n let abortListener: (() => void) | undefined;\n const aborted = new Promise<never>((_resolve, reject) => {\n abortListener = () => reject(verificationAbortError(controller.signal, path));\n controller.signal.addEventListener(\"abort\", abortListener, { once: true });\n if (controller.signal.aborted) abortListener();\n });\n try {\n const running = Promise.resolve().then(() => {\n throwIfVerificationAborted(controller.signal, path);\n return operation();\n });\n return await Promise.race([running, aborted]);\n } finally {\n if (abortListener) controller.signal.removeEventListener(\"abort\", abortListener);\n }\n },\n throwIfAborted(): void {\n throwIfVerificationAborted(controller.signal, path);\n },\n dispose(): void {\n clearTimeout(timeout);\n callerSignal?.removeEventListener(\"abort\", callerAbort);\n },\n };\n}\n\nfunction parseInspection(value: unknown, path: string): GpuModelResourceInspection {\n const record = readRecord(value, path, [\"valid\", \"detectedMimeType\", \"width\", \"height\"]);\n const output: Record<string, unknown> = {\n valid: readBoolean(requireKey(record, \"valid\", path), `${path}.valid`),\n detectedMimeType: readString(requireKey(record, \"detectedMimeType\", path), `${path}.detectedMimeType`, 128, MIME_TYPE).toLowerCase(),\n };\n assignOptional(output, \"width\", readOptional(record, \"width\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n assignOptional(output, \"height\", readOptional(record, \"height\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n return output as unknown as GpuModelResourceInspection;\n}\n\nfunction bytesStartWith(bytes: Uint8Array, signature: readonly number[]): boolean {\n return bytes.byteLength >= signature.length && signature.every((value, index) => bytes[index] === value);\n}\n\nfunction validateImageMagic(resource: GpuModelResource, bytes: Uint8Array, inspection: GpuModelResourceInspection, path: string): void {\n if (inspection.width === undefined || inspection.height === undefined) {\n return fail(\"resource-verification-failed\", path, \"image inspection must report dimensions\");\n }\n let signatureValid = false;\n if (resource.mimeType === \"image/png\") {\n signatureValid = bytes.byteLength >= 24 && bytesStartWith(bytes, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);\n if (signatureValid) {\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n if (view.getUint32(16) !== inspection.width || view.getUint32(20) !== inspection.height) {\n return fail(\"resource-verification-failed\", path, \"image dimensions disagree with the PNG header\");\n }\n }\n } else if (resource.mimeType === \"image/jpeg\") {\n signatureValid = bytes.byteLength >= 4 && bytesStartWith(bytes, [0xff, 0xd8, 0xff]) && bytes.at(-2) === 0xff && bytes.at(-1) === 0xd9;\n } else if (resource.mimeType === \"image/webp\") {\n signatureValid = bytes.byteLength >= 16\n && bytesStartWith(bytes, [0x52, 0x49, 0x46, 0x46])\n && String.fromCharCode(...bytes.subarray(8, 12)) === \"WEBP\";\n } else if (resource.mimeType === \"image/ktx2\") {\n signatureValid = bytesStartWith(bytes, [0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a]);\n }\n if (!signatureValid) return fail(\"resource-verification-failed\", path, \"image signature is invalid for the declared MIME type\");\n}\n\nasync function verifyParsedResource(\n resource: GpuModelResource,\n port: GpuModelResourceVerificationPort,\n limits: VerificationLimits,\n options?: GpuModelResourceVerificationOptions,\n path = \"$.resource\",\n): Promise<GpuModelResource> {\n if (options?.signal?.aborted) return fail(\"resource-verification-failed\", path, \"resource verification was aborted\");\n if (verifiedResources.has(resource) && verifiedResourceBytes.has(resource)) {\n return cachedResourceWithinLimits(resource, limits, path);\n }\n preflightResourceBudget([resource], limits);\n if (typeof port !== \"object\" || port === null || typeof port.inspectResource !== \"function\" || typeof port.digestSha256 !== \"function\") {\n return fail(\"invalid-type\", \"$.verificationPort\", \"expected digest and inspection functions\");\n }\n const deadline = createVerificationDeadline(limits.timeoutMs, options?.signal, path);\n try {\n const context: GpuModelResourceVerificationContext = Object.freeze({\n resourceId: resource.id,\n kind: resource.kind,\n declaredMimeType: resource.mimeType,\n byteLength: resource.byteLength,\n signal: deadline.signal,\n });\n const inspectionObserved = { bytes: 0 };\n let inspectionValue: unknown;\n try {\n inspectionValue = await deadline.race(() => port.inspectResource(\n createBlobChunks(resource.payload, limits.chunkBytes, inspectionObserved, deadline.signal, path),\n context,\n ));\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n deadline.throwIfAborted();\n return fail(\"resource-verification-failed\", path, \"resource inspection failed\");\n }\n deadline.throwIfAborted();\n if (inspectionObserved.bytes !== resource.byteLength) return fail(\"resource-verification-failed\", path, \"resource inspection did not consume the complete payload\");\n const inspection = parseInspection(inspectionValue, `${path}.inspection`);\n if (!inspection.valid) return fail(\"resource-verification-failed\", path, \"resource inspection rejected the payload\");\n if (inspection.detectedMimeType !== resource.mimeType) return fail(\"resource-verification-failed\", path, \"detected MIME type does not match the declaration\");\n if (resource.kind === \"image\") {\n const width = inspection.width;\n const height = inspection.height;\n if (width === undefined || height === undefined) return fail(\"resource-verification-failed\", path, \"image inspection did not report dimensions\");\n if (width > limits.maxImageDimension || height > limits.maxImageDimension || width * height > limits.maxImagePixels) {\n return fail(\"resource-budget-exceeded\", path, \"image dimension budget exceeded\");\n }\n } else if (inspection.width !== undefined || inspection.height !== undefined) {\n return fail(\"resource-verification-failed\", path, \"buffer inspection must not report image dimensions\");\n }\n const snapshot = new Uint8Array(resource.byteLength);\n const digestObserved = { bytes: 0 };\n let digest: unknown;\n try {\n digest = await deadline.race(() => port.digestSha256(\n createBlobChunks(resource.payload, limits.chunkBytes, digestObserved, deadline.signal, path, snapshot),\n context,\n ));\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n deadline.throwIfAborted();\n return fail(\"resource-verification-failed\", path, \"resource digest verification failed\");\n }\n deadline.throwIfAborted();\n if (digestObserved.bytes !== resource.byteLength) return fail(\"resource-verification-failed\", path, \"resource digest did not consume the complete payload\");\n if (typeof digest !== \"string\" || !SHA_256.test(digest) || digest !== resource.contentHash) {\n return fail(\"resource-verification-failed\", path, \"resource digest does not match contentHash\");\n }\n if (resource.kind === \"image\") validateImageMagic(resource, snapshot, inspection, path);\n const verified = Object.freeze({\n ...resource,\n payload: new Blob([snapshot], { type: resource.mimeType }),\n });\n verifiedResources.add(verified);\n verifiedResourceBytes.set(verified, snapshot);\n verifiedResourceEvidence.set(verified, Object.freeze({ ...inspection }));\n return verified;\n } finally {\n deadline.dispose();\n }\n}\n\n/** Verifies one bounded resource and returns a privately branded immutable value. */\nexport async function verifyGpuModelResource(\n value: unknown,\n port: GpuModelResourceVerificationPort,\n options?: GpuModelResourceVerificationOptions,\n): Promise<GpuModelResource> {\n try {\n const limits = resolveVerificationLimits(options);\n const resource = typeof value === \"object\"\n && value !== null\n && verifiedResources.has(value)\n && verifiedResourceBytes.has(value)\n ? value as GpuModelResource\n : parseResourceHeader(value, \"$.resource\");\n return await verifyParsedResource(resource, port, limits, options);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$.resource\", \"resource could not be safely inspected\");\n }\n}\n\nfunction parseNode(value: unknown, path: string, budget: DocumentBudget): GpuModelNode {\n const record = readRecord(value, path, [\"id\", \"name\", \"children\", \"meshId\", \"skinId\", \"localMatrix\", \"metadata\"]);\n const children = Object.freeze(readArray(requireKey(record, \"children\", path), `${path}.children`, GPU_MODEL_DOCUMENT_LIMITS.nodes)\n .map((entry, index) => readId(entry, `${path}.children[${index}]`)));\n consumeBudget(budget, \"sceneEdges\", children.length, GPU_MODEL_DOCUMENT_LIMITS.sceneEdges, path, \"scene edge\");\n ensureUnique(children, `${path}.children`, \"duplicate child node\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n children,\n localMatrix: parseMatrix(requireKey(record, \"localMatrix\", path), `${path}.localMatrix`),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"meshId\", readOptional(record, \"meshId\", readId, path));\n assignOptional(output, \"skinId\", readOptional(record, \"skinId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelNode;\n}\n\nfunction parseAccessor(value: unknown, path: string, budget: DocumentBudget): GpuModelAccessor {\n const record = readRecord(value, path, [\"id\", \"resourceId\", \"byteOffset\", \"byteStride\", \"count\", \"componentType\", \"elementType\", \"normalized\", \"min\", \"max\"]);\n const componentType = readEnum(requireKey(record, \"componentType\", path), `${path}.componentType`, [\"i8\", \"u8\", \"i16\", \"u16\", \"u32\", \"f32\"] as const);\n const elementType = readEnum(requireKey(record, \"elementType\", path), `${path}.elementType`, [\"scalar\", \"vec2\", \"vec3\", \"vec4\", \"mat2\", \"mat3\", \"mat4\"] as const);\n const normalized = readOptional(record, \"normalized\", readBoolean, path);\n if (normalized === true && componentType === \"f32\") return fail(\"invalid-value\", `${path}.normalized`, \"floating-point accessors cannot be normalized\");\n if (elementType.startsWith(\"mat\") && componentType !== \"f32\") return fail(\"invalid-value\", `${path}.componentType`, \"matrix accessors must use f32 components\");\n const expectedComponents = ELEMENT_COMPONENTS[elementType];\n const min = readOptional(record, \"min\", (entry, entryPath) => readNumberTuple(entry, entryPath, expectedComponents), path);\n const max = readOptional(record, \"max\", (entry, entryPath) => readNumberTuple(entry, entryPath, expectedComponents), path);\n if ((min === undefined) !== (max === undefined)) return fail(\"invalid-value\", path, \"accessor min and max must be supplied together\");\n if (min && max) {\n const [componentMinimum, componentMaximum, integer] = COMPONENT_RANGES[componentType];\n for (let index = 0; index < expectedComponents; index += 1) {\n const minimum = min[index]!;\n const maximum = max[index]!;\n if (minimum > maximum) return fail(\"invalid-value\", path, \"accessor min cannot exceed max\");\n if (minimum < componentMinimum || maximum > componentMaximum || (integer && (!Number.isInteger(minimum) || !Number.isInteger(maximum)))) {\n return fail(\"invalid-value\", path, \"accessor bounds are outside the component representation\");\n }\n }\n }\n const count = readSafeInteger(requireKey(record, \"count\", path), `${path}.count`, 1, GPU_MODEL_DOCUMENT_LIMITS.weightVertices);\n consumeBudget(budget, \"accessorElements\", count * expectedComponents, GPU_MODEL_DOCUMENT_LIMITS.accessorElements, path, \"accessor element component\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n resourceId: readId(requireKey(record, \"resourceId\", path), `${path}.resourceId`),\n byteOffset: readSafeInteger(requireKey(record, \"byteOffset\", path), `${path}.byteOffset`),\n count,\n componentType,\n elementType,\n };\n assignOptional(output, \"byteStride\", readOptional(record, \"byteStride\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1, 2_048), path));\n assignOptional(output, \"normalized\", normalized);\n assignOptional(output, \"min\", min);\n assignOptional(output, \"max\", max);\n return output as unknown as GpuModelAccessor;\n}\n\nfunction parsePrimitive(value: unknown, path: string, budget: DocumentBudget): GpuModelPrimitive {\n const record = readRecord(value, path, [\"id\", \"topology\", \"attributes\", \"indicesAccessorId\", \"materialId\", \"metadata\"]);\n const attributesInput = readArray(requireKey(record, \"attributes\", path), `${path}.attributes`, 64, 1);\n consumeBudget(budget, \"primitiveAttributes\", attributesInput.length, GPU_MODEL_DOCUMENT_LIMITS.primitiveAttributes, path, \"primitive attribute\");\n const attributes = Object.freeze(attributesInput.map((entry, index) => {\n const entryPath = `${path}.attributes[${index}]`;\n const attribute = readRecord(entry, entryPath, [\"semantic\", \"accessorId\"]);\n return {\n semantic: readString(requireKey(attribute, \"semantic\", entryPath), `${entryPath}.semantic`, 64, ATTRIBUTE_SEMANTIC),\n accessorId: readId(requireKey(attribute, \"accessorId\", entryPath), `${entryPath}.accessorId`),\n };\n }));\n ensureUnique(attributes.map(({ semantic }) => semantic), `${path}.attributes`, \"duplicate attribute semantic\");\n if (!attributes.some(({ semantic }) => semantic === \"POSITION\")) return fail(\"invalid-value\", `${path}.attributes`, \"primitive requires POSITION\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n topology: readEnum(requireKey(record, \"topology\", path), `${path}.topology`, [\"points\", \"lines\", \"line-strip\", \"triangles\", \"triangle-strip\"] as const),\n attributes,\n };\n assignOptional(output, \"indicesAccessorId\", readOptional(record, \"indicesAccessorId\", readId, path));\n assignOptional(output, \"materialId\", readOptional(record, \"materialId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelPrimitive;\n}\n\nfunction parseMesh(value: unknown, path: string, budget: DocumentBudget): GpuModelMesh {\n const record = readRecord(value, path, [\"id\", \"name\", \"primitives\", \"metadata\"]);\n const input = readArray(requireKey(record, \"primitives\", path), `${path}.primitives`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n consumeBudget(budget, \"primitives\", input.length, GPU_MODEL_DOCUMENT_LIMITS.primitives, path, \"primitive\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n primitives: Object.freeze(input.map((entry, index) => parsePrimitive(entry, `${path}.primitives[${index}]`, budget))),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelMesh;\n}\n\nfunction parseTextureTransform(value: unknown, path: string): GpuModelTextureTransform {\n const record = readRecord(value, path, [\"offset\", \"rotationRadians\", \"scale\"]);\n if (Reflect.ownKeys(record).length === 0) return fail(\"invalid-value\", path, \"texture transform cannot be empty\");\n const output: Record<string, unknown> = {};\n assignOptional(output, \"offset\", readOptional(record, \"offset\", (entry, entryPath) => readNumberTuple(entry, entryPath, 2) as GpuModelVec2, path));\n assignOptional(output, \"rotationRadians\", readOptional(record, \"rotationRadians\", readFinite, path));\n assignOptional(output, \"scale\", readOptional(record, \"scale\", (entry, entryPath) => readNumberTuple(entry, entryPath, 2) as GpuModelVec2, path));\n return output as GpuModelTextureTransform;\n}\n\nfunction parseTextureBinding(value: unknown, path: string): GpuModelTextureBinding {\n const record = readRecord(value, path, [\"textureId\", \"samplerId\", \"texCoordSet\", \"transform\", \"colorSpace\", \"intendedUsage\"]);\n const output: Record<string, unknown> = {\n textureId: readId(requireKey(record, \"textureId\", path), `${path}.textureId`),\n colorSpace: readEnum(requireKey(record, \"colorSpace\", path), `${path}.colorSpace`, [\"srgb\", \"linear\", \"normal-map\", \"data\"] as const),\n intendedUsage: readEnum(requireKey(record, \"intendedUsage\", path), `${path}.intendedUsage`, TEXTURE_USAGES),\n };\n assignOptional(output, \"samplerId\", readOptional(record, \"samplerId\", readId, path));\n assignOptional(output, \"texCoordSet\", readOptional(record, \"texCoordSet\", (entry, entryPath) => readSafeInteger(entry, entryPath, 0, 7), path));\n assignOptional(output, \"transform\", readOptional(record, \"transform\", parseTextureTransform, path));\n return output as unknown as GpuModelTextureBinding;\n}\n\nfunction parseMaterialTextures(value: unknown, path: string): GpuModelMaterialTextures {\n const slots = Object.keys(MATERIAL_TEXTURE_SLOTS);\n const record = readRecord(value, path, slots);\n const output: Record<string, unknown> = {};\n for (const slot of slots) assignOptional(output, slot, readOptional(record, slot, parseTextureBinding, path));\n return output as GpuModelMaterialTextures;\n}\n\nfunction parseMaterial(value: unknown, path: string, budget: DocumentBudget): GpuModelMaterial {\n const keys = [\n \"id\", \"name\", \"workflow\", \"alphaMode\", \"alphaCutoff\", \"doubleSided\", \"baseColorFactor\",\n \"metallicFactor\", \"roughnessFactor\", \"emissiveFactor\", \"transmissionFactor\", \"clearcoatFactor\",\n \"clearcoatRoughnessFactor\", \"sheenColorFactor\", \"sheenRoughnessFactor\", \"normalScale\",\n \"occlusionStrength\", \"textures\", \"extensions\", \"sourceMetadata\",\n ];\n const record = readRecord(value, path, keys);\n const alphaMode = readEnum(requireKey(record, \"alphaMode\", path), `${path}.alphaMode`, [\"opaque\", \"mask\", \"blend\"] as const);\n const alphaCutoff = readOptional(record, \"alphaCutoff\", (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path);\n if (alphaMode === \"mask\" && alphaCutoff === undefined) return fail(\"invalid-value\", `${path}.alphaCutoff`, \"mask materials require alphaCutoff\");\n if (alphaMode !== \"mask\" && alphaCutoff !== undefined) return fail(\"invalid-value\", `${path}.alphaCutoff`, \"alphaCutoff is only valid for mask materials\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n workflow: readEnum(requireKey(record, \"workflow\", path), `${path}.workflow`, [\"metallic-roughness\", \"specular-glossiness\", \"unlit\", \"custom\"] as const),\n alphaMode,\n baseColorFactor: readNumberTuple(requireKey(record, \"baseColorFactor\", path), `${path}.baseColorFactor`, 4, 0, 1) as GpuModelVec4,\n textures: parseMaterialTextures(requireKey(record, \"textures\", path), `${path}.textures`),\n extensions: readMetadata(requireKey(record, \"extensions\", path), `${path}.extensions`, budget),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"alphaCutoff\", alphaCutoff);\n assignOptional(output, \"doubleSided\", readOptional(record, \"doubleSided\", readBoolean, path));\n for (const key of [\"metallicFactor\", \"roughnessFactor\", \"transmissionFactor\", \"clearcoatFactor\", \"clearcoatRoughnessFactor\", \"sheenRoughnessFactor\", \"occlusionStrength\"] as const) {\n assignOptional(output, key, readOptional(record, key, (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path));\n }\n assignOptional(output, \"normalScale\", readOptional(record, \"normalScale\", readFinite, path));\n assignOptional(output, \"emissiveFactor\", readOptional(record, \"emissiveFactor\", (entry, entryPath) => readNumberTuple(entry, entryPath, 3, 0) as GpuModelVec3, path));\n assignOptional(output, \"sheenColorFactor\", readOptional(record, \"sheenColorFactor\", (entry, entryPath) => readNumberTuple(entry, entryPath, 3, 0, 1) as GpuModelVec3, path));\n return output as unknown as GpuModelMaterial;\n}\n\nfunction parseTextureSampler(value: unknown, path: string): GpuModelTextureSampler {\n const record = readRecord(value, path, [\"id\", \"wrapS\", \"wrapT\", \"minFilter\", \"magFilter\", \"mipFilter\"]);\n const output: Record<string, unknown> = { id: readId(requireKey(record, \"id\", path), `${path}.id`) };\n assignOptional(output, \"wrapS\", readOptional(record, \"wrapS\", (entry, entryPath) => readEnum(entry, entryPath, [\"repeat\", \"mirrored-repeat\", \"clamp-to-edge\"] as const), path));\n assignOptional(output, \"wrapT\", readOptional(record, \"wrapT\", (entry, entryPath) => readEnum(entry, entryPath, [\"repeat\", \"mirrored-repeat\", \"clamp-to-edge\"] as const), path));\n assignOptional(output, \"minFilter\", readOptional(record, \"minFilter\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"magFilter\", readOptional(record, \"magFilter\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"mipFilter\", readOptional(record, \"mipFilter\", (entry, entryPath) => readEnum(entry, entryPath, [\"nearest\", \"linear\"] as const), path));\n return output as unknown as GpuModelTextureSampler;\n}\n\nfunction parseTexture(value: unknown, path: string, budget: DocumentBudget): GpuModelTexture {\n const record = readRecord(value, path, [\"id\", \"fileName\", \"relativePath\", \"mimeType\", \"contentHash\", \"imageResourceId\", \"byteLength\", \"intendedUsage\", \"colorSpace\", \"sampler\", \"exportEmbeddingPolicy\", \"sourceMetadata\"]);\n const usages = Object.freeze(readArray(requireKey(record, \"intendedUsage\", path), `${path}.intendedUsage`, TEXTURE_USAGES.length, 1)\n .map((entry, index) => readEnum(entry, `${path}.intendedUsage[${index}]`, TEXTURE_USAGES)));\n ensureUnique(usages, `${path}.intendedUsage`, \"duplicate intended texture usage\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n contentHash: readSha256(requireKey(record, \"contentHash\", path), `${path}.contentHash`),\n imageResourceId: readId(requireKey(record, \"imageResourceId\", path), `${path}.imageResourceId`),\n intendedUsage: usages,\n colorSpace: readEnum(requireKey(record, \"colorSpace\", path), `${path}.colorSpace`, [\"srgb\", \"linear\", \"normal-map\", \"data\"] as const),\n exportEmbeddingPolicy: readEnum(requireKey(record, \"exportEmbeddingPolicy\", path), `${path}.exportEmbeddingPolicy`, [\"inherit-source\", \"prefer-embedded\", \"prefer-external\", \"forbid-embedding\"] as const),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"fileName\", readOptional(record, \"fileName\", (entry, entryPath) => readString(entry, entryPath, 512, FILE_NAME), path));\n assignOptional(output, \"relativePath\", readOptional(record, \"relativePath\", (entry, entryPath) => readString(entry, entryPath, 2_048, RELATIVE_PATH), path));\n assignOptional(output, \"mimeType\", readOptional(record, \"mimeType\", (entry, entryPath) => readString(entry, entryPath, 128, MIME_TYPE).toLowerCase(), path));\n assignOptional(output, \"byteLength\", readOptional(record, \"byteLength\", (entry, entryPath) => readSafeInteger(entry, entryPath, 1), path));\n assignOptional(output, \"sampler\", readOptional(record, \"sampler\", parseTextureSampler, path));\n return output as unknown as GpuModelTexture;\n}\n\nfunction parseSkeleton(value: unknown, path: string, budget: DocumentBudget): GpuModelSkeleton {\n const record = readRecord(value, path, [\"id\", \"name\", \"jointIds\", \"rootJointIds\", \"sourceMetadata\"]);\n const jointIds = Object.freeze(readArray(requireKey(record, \"jointIds\", path), `${path}.jointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.jointIds[${index}]`)));\n const rootJointIds = Object.freeze(readArray(requireKey(record, \"rootJointIds\", path), `${path}.rootJointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.rootJointIds[${index}]`)));\n consumeBudget(budget, \"skinJoints\", jointIds.length + rootJointIds.length, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, path, \"rig joint\");\n ensureUnique(jointIds, `${path}.jointIds`, \"duplicate skeleton joint\");\n ensureUnique(rootJointIds, `${path}.rootJointIds`, \"duplicate root joint\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n jointIds,\n rootJointIds,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n return output as unknown as GpuModelSkeleton;\n}\n\nfunction parseJoint(value: unknown, path: string, budget: DocumentBudget): GpuModelJoint {\n const record = readRecord(value, path, [\"id\", \"name\", \"nodeId\", \"parentJointId\", \"restLocalTransform\", \"inverseBindMatrix\", \"sourceMetadata\"]);\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n nodeId: readId(requireKey(record, \"nodeId\", path), `${path}.nodeId`),\n restLocalTransform: parseTransformTrs(requireKey(record, \"restLocalTransform\", path), `${path}.restLocalTransform`),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"parentJointId\", readOptional(record, \"parentJointId\", readId, path));\n assignOptional(output, \"inverseBindMatrix\", readOptional(record, \"inverseBindMatrix\", parseMatrix, path));\n return output as unknown as GpuModelJoint;\n}\n\nfunction parseWeightRows(value: unknown, path: string, rows: number, columns: number, integer: boolean, budget: DocumentBudget): readonly (readonly number[])[] {\n const input = readArray(value, path, rows, rows);\n consumeBudget(budget, \"weightVertices\", input.length, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, path, \"weight vertex\");\n consumeBudget(budget, \"weightInfluences\", input.length * columns, GPU_MODEL_DOCUMENT_LIMITS.weightInfluences, path, \"weight influence\");\n return Object.freeze(input.map((row, rowIndex) => {\n const parsed = readNumberTuple(row, `${path}[${rowIndex}]`, columns, 0, integer ? Number.MAX_SAFE_INTEGER : 1);\n if (integer && parsed.some((entry) => !Number.isSafeInteger(entry))) return fail(\"invalid-value\", `${path}[${rowIndex}]`, \"joint indices must be safe integers\");\n return parsed;\n }));\n}\n\nfunction parseVertexWeightSet(value: unknown, path: string, budget: DocumentBudget): GpuModelVertexWeightSet {\n const record = readRecord(value, path, [\"primitiveId\", \"influencesPerVertex\", \"joints\", \"weights\"]);\n const influences = readSafeInteger(requireKey(record, \"influencesPerVertex\", path), `${path}.influencesPerVertex`, 1, 32);\n if (influences % 4 !== 0) return fail(\"invalid-value\", `${path}.influencesPerVertex`, \"influencesPerVertex must be a multiple of four\");\n const jointRows = readArray(requireKey(record, \"joints\", path), `${path}.joints`, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, 1);\n const weightRows = readArray(requireKey(record, \"weights\", path), `${path}.weights`, GPU_MODEL_DOCUMENT_LIMITS.weightVertices, 1);\n if (jointRows.length !== weightRows.length) return fail(\"invalid-value\", path, \"joint and weight row counts must match\");\n return {\n primitiveId: readId(requireKey(record, \"primitiveId\", path), `${path}.primitiveId`),\n influencesPerVertex: influences,\n joints: parseWeightRows(jointRows, `${path}.joints`, jointRows.length, influences, true, budget),\n weights: parseWeightRows(weightRows, `${path}.weights`, weightRows.length, influences, false, budget),\n };\n}\n\nfunction parseSkin(value: unknown, path: string, budget: DocumentBudget): GpuModelSkin {\n const record = readRecord(value, path, [\"id\", \"skeletonId\", \"jointIds\", \"inverseBindMatrices\", \"weightSets\", \"sourceMetadata\"]);\n const jointIds = Object.freeze(readArray(requireKey(record, \"jointIds\", path), `${path}.jointIds`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, 1)\n .map((entry, index) => readId(entry, `${path}.jointIds[${index}]`)));\n consumeBudget(budget, \"skinJoints\", jointIds.length, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, path, \"skin joint\");\n ensureUnique(jointIds, `${path}.jointIds`, \"duplicate skin joint\");\n const inverseInput = readArray(requireKey(record, \"inverseBindMatrices\", path), `${path}.inverseBindMatrices`, GPU_MODEL_DOCUMENT_LIMITS.skinJoints, jointIds.length);\n if (inverseInput.length !== jointIds.length) return fail(\"invalid-value\", `${path}.inverseBindMatrices`, \"one inverse bind matrix is required per skin joint\");\n const weightInput = readArray(requireKey(record, \"weightSets\", path), `${path}.weightSets`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n const weightSets = Object.freeze(weightInput.map((entry, index) => parseVertexWeightSet(entry, `${path}.weightSets[${index}]`, budget)));\n ensureUnique(weightSets.map(({ primitiveId }) => primitiveId), `${path}.weightSets`, \"duplicate primitive weight set\");\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n skeletonId: readId(requireKey(record, \"skeletonId\", path), `${path}.skeletonId`),\n jointIds,\n inverseBindMatrices: Object.freeze(inverseInput.map((entry, index) => parseMatrix(entry, `${path}.inverseBindMatrices[${index}]`))),\n weightSets,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseBlendShapeDelta(value: unknown, path: string): GpuModelBlendShapeDelta {\n const record = readRecord(value, path, [\"primitiveId\", \"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"]);\n const output: Record<string, unknown> = { primitiveId: readId(requireKey(record, \"primitiveId\", path), `${path}.primitiveId`) };\n for (const key of [\"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"] as const) {\n assignOptional(output, key, readOptional(record, key, readId, path));\n }\n if (!output.positionAccessorId && !output.normalAccessorId && !output.tangentAccessorId) {\n return fail(\"invalid-value\", path, \"blend-shape delta requires at least one accessor\");\n }\n return output as unknown as GpuModelBlendShapeDelta;\n}\n\nfunction parseBlendShape(value: unknown, path: string, budget: DocumentBudget): GpuModelBlendShape {\n const record = readRecord(value, path, [\"id\", \"meshId\", \"name\", \"defaultWeight\", \"deltas\", \"sourceMetadata\"]);\n const deltaInput = readArray(requireKey(record, \"deltas\", path), `${path}.deltas`, GPU_MODEL_DOCUMENT_LIMITS.primitives, 1);\n consumeBudget(\n budget,\n \"blendShapeDeltas\",\n deltaInput.length,\n GPU_MODEL_DOCUMENT_LIMITS.blendShapeDeltas,\n `${path}.deltas`,\n \"blend-shape delta\",\n );\n const deltas = Object.freeze(deltaInput.map((entry, index) => parseBlendShapeDelta(entry, `${path}.deltas[${index}]`)));\n ensureUnique(deltas.map(({ primitiveId }) => primitiveId), `${path}.deltas`, \"duplicate blend-shape primitive delta\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n meshId: readId(requireKey(record, \"meshId\", path), `${path}.meshId`),\n deltas,\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n assignOptional(output, \"defaultWeight\", readOptional(record, \"defaultWeight\", (entry, entryPath) => readFinite(entry, entryPath, 0, 1), path));\n return output as unknown as GpuModelBlendShape;\n}\n\nfunction parseAnimationSampler(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimationSampler {\n const record = readRecord(value, path, [\"id\", \"inputAccessorId\", \"outputAccessorId\", \"inputTimesSeconds\", \"outputValues\", \"interpolation\", \"sourceMetadata\"]);\n const timesInput = readArray(requireKey(record, \"inputTimesSeconds\", path), `${path}.inputTimesSeconds`, GPU_MODEL_DOCUMENT_LIMITS.animationValues, 1);\n const valuesInput = readArray(requireKey(record, \"outputValues\", path), `${path}.outputValues`, GPU_MODEL_DOCUMENT_LIMITS.animationValues, 1);\n consumeBudget(budget, \"animationValues\", timesInput.length + valuesInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationValues, path, \"animation value\");\n const times = Object.freeze(timesInput.map((entry, index) => readFinite(entry, `${path}.inputTimesSeconds[${index}]`, 0)));\n for (let index = 1; index < times.length; index += 1) {\n if (times[index]! <= times[index - 1]!) return fail(\"invalid-value\", `${path}.inputTimesSeconds`, \"animation input times must be strictly increasing\");\n }\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n inputAccessorId: readId(requireKey(record, \"inputAccessorId\", path), `${path}.inputAccessorId`),\n outputAccessorId: readId(requireKey(record, \"outputAccessorId\", path), `${path}.outputAccessorId`),\n inputTimesSeconds: times,\n outputValues: Object.freeze(valuesInput.map((entry, index) => readFinite(entry, `${path}.outputValues[${index}]`))),\n interpolation: readEnum(requireKey(record, \"interpolation\", path), `${path}.interpolation`, [\"step\", \"linear\", \"cubic-spline\"] as const),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseAnimationChannel(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimationChannel {\n const record = readRecord(value, path, [\"id\", \"samplerId\", \"targetType\", \"targetId\", \"sourceMetadata\"]);\n return {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n samplerId: readId(requireKey(record, \"samplerId\", path), `${path}.samplerId`),\n targetType: readEnum(requireKey(record, \"targetType\", path), `${path}.targetType`, [\"node-translation\", \"node-rotation\", \"node-scale\", \"weights\"] as const),\n targetId: readId(requireKey(record, \"targetId\", path), `${path}.targetId`),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n}\n\nfunction parseAnimation(value: unknown, path: string, budget: DocumentBudget): GpuModelAnimation {\n const record = readRecord(value, path, [\"id\", \"name\", \"durationSeconds\", \"samplers\", \"channels\", \"sourceMetadata\"]);\n const samplerInput = readArray(requireKey(record, \"samplers\", path), `${path}.samplers`, GPU_MODEL_DOCUMENT_LIMITS.animationSamplers, 1);\n const channelInput = readArray(requireKey(record, \"channels\", path), `${path}.channels`, GPU_MODEL_DOCUMENT_LIMITS.animationChannels, 1);\n consumeBudget(budget, \"animationSamplers\", samplerInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationSamplers, path, \"animation sampler\");\n consumeBudget(budget, \"animationChannels\", channelInput.length, GPU_MODEL_DOCUMENT_LIMITS.animationChannels, path, \"animation channel\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n durationSeconds: readFinite(requireKey(record, \"durationSeconds\", path), `${path}.durationSeconds`, 0),\n samplers: Object.freeze(samplerInput.map((entry, index) => parseAnimationSampler(entry, `${path}.samplers[${index}]`, budget))),\n channels: Object.freeze(channelInput.map((entry, index) => parseAnimationChannel(entry, `${path}.channels[${index}]`, budget))),\n sourceMetadata: readMetadata(requireKey(record, \"sourceMetadata\", path), `${path}.sourceMetadata`, budget),\n };\n assignOptional(output, \"name\", readOptional(record, \"name\", (entry, entryPath) => readString(entry, entryPath, GPU_MODEL_DOCUMENT_LIMITS.nameLength), path));\n return output as unknown as GpuModelAnimation;\n}\n\nfunction parseAnalyticGeometry(value: unknown, path: string, budget: DocumentBudget): GpuModelAnalyticGeometry {\n const record = readRecord(value, path, [\"id\", \"kind\", \"sourceResourceId\", \"sourceUnit\", \"tessellatedMeshId\", \"metadata\"]);\n if (requireKey(record, \"kind\", path) !== \"brep-placeholder\") return fail(\"invalid-value\", `${path}.kind`, \"unsupported analytic geometry kind\");\n const output: Record<string, unknown> = {\n id: readId(requireKey(record, \"id\", path), `${path}.id`),\n kind: \"brep-placeholder\",\n sourceResourceId: readId(requireKey(record, \"sourceResourceId\", path), `${path}.sourceResourceId`),\n sourceUnit: readEnum(requireKey(record, \"sourceUnit\", path), `${path}.sourceUnit`, [\"metre\", \"millimetre\", \"centimetre\", \"inch\", \"foot\", \"unitless\"] as const),\n };\n assignOptional(output, \"tessellatedMeshId\", readOptional(record, \"tessellatedMeshId\", readId, path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelAnalyticGeometry;\n}\n\nfunction parseProvenance(value: unknown, budget: DocumentBudget): GpuModelProvenance {\n const path = \"$.provenance\";\n const record = readRecord(value, path, [\"sourceFormat\", \"sourceContentHash\", \"converterId\", \"converterVersion\", \"provider\", \"sourceIdentifier\", \"metadata\"]);\n const output: Record<string, unknown> = {\n sourceFormat: readString(requireKey(record, \"sourceFormat\", path), `${path}.sourceFormat`, 128, TOKEN),\n sourceContentHash: readSha256(requireKey(record, \"sourceContentHash\", path), `${path}.sourceContentHash`),\n converterId: readString(requireKey(record, \"converterId\", path), `${path}.converterId`, 128, TOKEN),\n converterVersion: readString(requireKey(record, \"converterVersion\", path), `${path}.converterVersion`, 128, TOKEN),\n };\n assignOptional(output, \"provider\", readOptional(record, \"provider\", (entry, entryPath) => readString(entry, entryPath, 128, TOKEN), path));\n assignOptional(output, \"sourceIdentifier\", readOptional(record, \"sourceIdentifier\", (entry, entryPath) => readString(entry, entryPath, 2_048), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelProvenance;\n}\n\nfunction parseDiagnostic(value: unknown, path: string, budget: DocumentBudget): GpuModelDiagnostic {\n const record = readRecord(value, path, [\"severity\", \"code\", \"message\", \"path\", \"metadata\"]);\n const output: Record<string, unknown> = {\n severity: readEnum(requireKey(record, \"severity\", path), `${path}.severity`, [\"info\", \"warning\", \"error\"] as const),\n code: readString(requireKey(record, \"code\", path), `${path}.code`, 128, TOKEN),\n message: readString(requireKey(record, \"message\", path), `${path}.message`, GPU_MODEL_DOCUMENT_LIMITS.diagnosticMessageLength),\n };\n assignOptional(output, \"path\", readOptional(record, \"path\", (entry, entryPath) => readString(entry, entryPath, 512), path));\n assignOptional(output, \"metadata\", readOptional(record, \"metadata\", (entry, entryPath) => readMetadata(entry, entryPath, budget), path));\n return output as unknown as GpuModelDiagnostic;\n}\n\nfunction ensureUnique(values: readonly string[], path: string, detail = \"duplicate identity\"): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) return fail(\"duplicate-id\", path, `${detail}: ${value}`);\n seen.add(value);\n }\n}\n\nfunction indexById<T extends { readonly id: string }>(values: readonly T[], path: string): ReadonlyMap<string, T> {\n ensureUnique(values.map(({ id }) => id), path);\n return new Map(values.map((value) => [value.id, value]));\n}\n\nfunction requireReference<T>(index: ReadonlyMap<string, T>, id: string, path: string, kind: string): T {\n const value = index.get(id);\n if (!value) return fail(\"missing-reference\", path, `missing ${kind}: ${id}`);\n return value;\n}\n\nfunction almostEqual(left: number, right: number, epsilon = EPSILON): boolean {\n return Math.abs(left - right) <= epsilon * Math.max(1, Math.abs(left), Math.abs(right));\n}\n\nfunction matrixAlmostEqual(left: GpuModelMatrix4, right: GpuModelMatrix4): boolean {\n return left.every((value, index) => almostEqual(value, right[index]!));\n}\n\nfunction multiplyMatrices(left: GpuModelMatrix4, right: GpuModelMatrix4): GpuModelMatrix4 {\n const output = new Array<number>(16).fill(0);\n for (let column = 0; column < 4; column += 1) {\n for (let row = 0; row < 4; row += 1) {\n let value = 0;\n for (let inner = 0; inner < 4; inner += 1) value += left[inner * 4 + row]! * right[column * 4 + inner]!;\n output[column * 4 + row] = value;\n }\n }\n return Object.freeze(output) as unknown as GpuModelMatrix4;\n}\n\nfunction transformPosition(matrix: GpuModelMatrix4, position: readonly number[]): GpuModelVec3 {\n const [x, y, z] = position;\n return [\n matrix[0] * x! + matrix[4] * y! + matrix[8] * z! + matrix[12],\n matrix[1] * x! + matrix[5] * y! + matrix[9] * z! + matrix[13],\n matrix[2] * x! + matrix[6] * y! + matrix[10] * z! + matrix[14],\n ];\n}\n\ninterface SceneValidation {\n readonly worldByNode: ReadonlyMap<string, GpuModelMatrix4>;\n readonly ancestryEntryByNode: ReadonlyMap<string, number>;\n readonly ancestryExitByNode: ReadonlyMap<string, number>;\n}\n\nfunction validateScene(roots: readonly string[], nodes: readonly GpuModelNode[], nodeIndex: ReadonlyMap<string, GpuModelNode>): SceneValidation {\n ensureUnique(roots, \"$.roots\", \"duplicate root node\");\n const parentCounts = new Map(nodes.map(({ id }) => [id, 0]));\n for (let nodeIndexValue = 0; nodeIndexValue < nodes.length; nodeIndexValue += 1) {\n const node = nodes[nodeIndexValue]!;\n for (let childIndex = 0; childIndex < node.children.length; childIndex += 1) {\n const childId = node.children[childIndex]!;\n requireReference(nodeIndex, childId, `$.nodes[${nodeIndexValue}].children[${childIndex}]`, \"node\");\n const parentCount = parentCounts.get(childId)! + 1;\n if (parentCount > 1) return fail(\"invalid-reference\", `$.nodes[${nodeIndexValue}].children[${childIndex}]`, \"node cannot have more than one parent\");\n parentCounts.set(childId, parentCount);\n }\n }\n const rootSet = new Set(roots);\n for (let index = 0; index < roots.length; index += 1) {\n const root = roots[index]!;\n requireReference(nodeIndex, root, `$.roots[${index}]`, \"node\");\n if (parentCounts.get(root) !== 0) return fail(\"invalid-reference\", `$.roots[${index}]`, \"root node cannot have a parent\");\n }\n for (const [nodeId, count] of parentCounts) {\n if (count === 0 && !rootSet.has(nodeId)) return fail(\"invalid-reference\", \"$.roots\", `parentless node is missing from roots: ${nodeId}`);\n }\n const worldByNode = new Map<string, GpuModelMatrix4>();\n const queue = roots.map((root) => ({ id: root, world: requireReference(nodeIndex, root, \"$.roots\", \"node\").localMatrix }));\n for (let cursor = 0; cursor < queue.length; cursor += 1) {\n const { id, world } = queue[cursor]!;\n if (worldByNode.has(id)) return fail(\"graph-cycle\", \"$.nodes\", \"scene graph contains a cycle\");\n worldByNode.set(id, world);\n const node = requireReference(nodeIndex, id, \"$.nodes\", \"node\");\n for (const childId of node.children) {\n const child = requireReference(nodeIndex, childId, \"$.nodes\", \"node\");\n queue.push({ id: childId, world: multiplyMatrices(world, child.localMatrix) });\n }\n }\n if (worldByNode.size !== nodes.length) return fail(\"graph-cycle\", \"$.nodes\", \"scene graph contains a cycle or unreachable node\");\n const ancestryEntryByNode = new Map<string, number>();\n const ancestryExitByNode = new Map<string, number>();\n const traversal = roots.slice().reverse().map((id) => ({ id, exiting: false }));\n let timestamp = 0;\n while (traversal.length > 0) {\n const current = traversal.pop()!;\n if (current.exiting) {\n ancestryExitByNode.set(current.id, timestamp);\n timestamp += 1;\n continue;\n }\n ancestryEntryByNode.set(current.id, timestamp);\n timestamp += 1;\n traversal.push({ id: current.id, exiting: true });\n const node = requireReference(nodeIndex, current.id, \"$.nodes\", \"node\");\n for (let index = node.children.length - 1; index >= 0; index -= 1) {\n traversal.push({ id: node.children[index]!, exiting: false });\n }\n }\n if (ancestryExitByNode.size !== nodes.length) return fail(\"graph-cycle\", \"$.nodes\", \"scene ancestry traversal is incomplete\");\n return { worldByNode, ancestryEntryByNode, ancestryExitByNode };\n}\n\nfunction isAncestor(scene: SceneValidation, possibleAncestor: string, nodeId: string): boolean {\n const ancestorEntry = scene.ancestryEntryByNode.get(possibleAncestor);\n const ancestorExit = scene.ancestryExitByNode.get(possibleAncestor);\n const nodeEntry = scene.ancestryEntryByNode.get(nodeId);\n const nodeExit = scene.ancestryExitByNode.get(nodeId);\n return ancestorEntry !== undefined\n && ancestorExit !== undefined\n && nodeEntry !== undefined\n && nodeExit !== undefined\n && ancestorEntry < nodeEntry\n && nodeExit < ancestorExit;\n}\n\nfunction validateAttributeAccessor(semantic: string, accessor: GpuModelAccessor, path: string): void {\n const unsigned = accessor.componentType === \"u8\" || accessor.componentType === \"u16\";\n if (semantic === \"POSITION\") {\n if (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.normalized === true) {\n return fail(\"invalid-reference\", path, \"POSITION accessor must be a non-normalized f32 vec3\");\n }\n if (!accessor.min || !accessor.max) return fail(\"invalid-reference\", path, \"POSITION accessor requires min and max bounds\");\n } else if (semantic === \"NORMAL\" && (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"NORMAL accessor must be a non-normalized f32 vec3\");\n } else if (semantic === \"TANGENT\" && (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec4\" || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"TANGENT accessor must be a non-normalized f32 vec4\");\n } else if (semantic.startsWith(\"TEXCOORD_\") && (accessor.elementType !== \"vec2\" || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"texture-coordinate accessor must be f32 or normalized unsigned vec2\");\n } else if (semantic.startsWith(\"COLOR_\") && (!(accessor.elementType === \"vec3\" || accessor.elementType === \"vec4\") || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"colour accessor must be f32 or normalized unsigned vec3/vec4\");\n } else if (semantic.startsWith(\"JOINTS_\") && (accessor.elementType !== \"vec4\" || !unsigned || accessor.normalized === true)) {\n return fail(\"invalid-reference\", path, \"joint accessor must be a non-normalized unsigned vec4\");\n } else if (semantic.startsWith(\"WEIGHTS_\") && (accessor.elementType !== \"vec4\" || (accessor.componentType !== \"f32\" && !(unsigned && accessor.normalized === true)))) {\n return fail(\"invalid-reference\", path, \"weight accessor must be f32 or normalized unsigned vec4\");\n }\n}\n\ninterface AccessorReader {\n readonly accessor: GpuModelAccessor;\n readonly components: number;\n readRaw(index: number): readonly number[];\n read(index: number): readonly number[];\n}\n\nfunction createAccessorReader(accessor: GpuModelAccessor, resource: GpuModelResource, path: string): AccessorReader {\n const bytes = verifiedResourceBytes.get(resource);\n if (!bytes) return fail(\"resource-unverified\", path, \"accessor requires a privately verified resource\");\n const componentBytes = COMPONENT_BYTES[accessor.componentType];\n const components = ELEMENT_COMPONENTS[accessor.elementType];\n const elementBytes = componentBytes * components;\n const stride = accessor.byteStride ?? elementBytes;\n if (stride < elementBytes) return fail(\"invalid-value\", `${path}.byteStride`, \"byteStride cannot be smaller than one element\");\n if ((accessor.byteOffset % componentBytes) !== 0 || (stride % componentBytes) !== 0) {\n return fail(\"invalid-value\", path, \"accessor offset and stride must align to the component size\");\n }\n const extent = accessor.byteOffset + stride * (accessor.count - 1) + elementBytes;\n if (!Number.isSafeInteger(extent) || extent > bytes.byteLength) return fail(\"invalid-reference\", path, \"accessor range exceeds its verified buffer resource\");\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const rawComponent = (offset: number): number => {\n switch (accessor.componentType) {\n case \"i8\": return view.getInt8(offset);\n case \"u8\": return view.getUint8(offset);\n case \"i16\": return view.getInt16(offset, true);\n case \"u16\": return view.getUint16(offset, true);\n case \"u32\": return view.getUint32(offset, true);\n case \"f32\": return view.getFloat32(offset, true);\n }\n };\n const normalize = (value: number): number => {\n if (accessor.normalized !== true) return value;\n switch (accessor.componentType) {\n case \"i8\": return Math.max(value / 127, -1);\n case \"u8\": return value / 255;\n case \"i16\": return Math.max(value / 32_767, -1);\n case \"u16\": return value / 65_535;\n case \"u32\": return value / 4_294_967_295;\n case \"f32\": return value;\n }\n };\n const readRaw = (index: number): readonly number[] => {\n if (!Number.isSafeInteger(index) || index < 0 || index >= accessor.count) return fail(\"invalid-reference\", path, \"accessor index is out of range\");\n const offset = accessor.byteOffset + stride * index;\n return Object.freeze(Array.from({ length: components }, (_, component) => rawComponent(offset + component * componentBytes)));\n };\n return {\n accessor,\n components,\n readRaw,\n read(index: number) {\n return Object.freeze(readRaw(index).map(normalize));\n },\n };\n}\n\ninterface AccessorPayloadEvidence {\n readonly min: readonly number[];\n readonly max: readonly number[];\n}\n\nfunction validateAccessorPayload(reader: AccessorReader, path: string): AccessorPayloadEvidence {\n const actualMin = new Array<number>(reader.components).fill(Number.POSITIVE_INFINITY);\n const actualMax = new Array<number>(reader.components).fill(Number.NEGATIVE_INFINITY);\n for (let item = 0; item < reader.accessor.count; item += 1) {\n const values = reader.readRaw(item);\n for (let component = 0; component < reader.components; component += 1) {\n const value = values[component]!;\n if (!Number.isFinite(value)) return fail(\"invalid-value\", path, \"accessor payload contains a non-finite value\");\n actualMin[component] = Math.min(actualMin[component]!, value);\n actualMax[component] = Math.max(actualMax[component]!, value);\n }\n }\n if (reader.accessor.min && reader.accessor.max) {\n for (let component = 0; component < reader.components; component += 1) {\n const minimumMatches = reader.accessor.componentType === \"f32\"\n ? almostEqual(actualMin[component]!, reader.accessor.min[component]!)\n : actualMin[component] === reader.accessor.min[component];\n const maximumMatches = reader.accessor.componentType === \"f32\"\n ? almostEqual(actualMax[component]!, reader.accessor.max[component]!)\n : actualMax[component] === reader.accessor.max[component];\n if (!minimumMatches || !maximumMatches) {\n return fail(\"invalid-reference\", path, \"declared accessor min/max do not match verified payload bytes\");\n }\n }\n }\n return Object.freeze({\n min: Object.freeze(actualMin),\n max: Object.freeze(actualMax),\n });\n}\n\nfunction actualAccessorBounds(reader: AccessorReader, evidence: AccessorPayloadEvidence, path: string): GpuModelBounds {\n if (reader.components !== 3) return fail(\"invalid-reference\", path, \"position reader must have three components\");\n return {\n min: evidence.min as GpuModelVec3,\n max: evidence.max as GpuModelVec3,\n };\n}\n\nfunction assertBoundsEqual(actual: GpuModelBounds, declared: GpuModelBounds, path: string): void {\n for (let component = 0; component < 3; component += 1) {\n if (Math.abs(actual.min[component]! - declared.min[component]!) > BOUNDS_ABSOLUTE_EPSILON\n || Math.abs(actual.max[component]! - declared.max[component]!) > BOUNDS_ABSOLUTE_EPSILON) {\n return fail(\"invalid-reference\", path, \"declared bounds do not match byte-verified POSITION data\");\n }\n }\n}\n\nfunction validateReferences(document: GpuModelDocument, budget: DocumentBudget): void {\n const nodes = indexById(document.nodes, \"$.nodes\");\n const resources = indexById(document.resources, \"$.resources\");\n const accessors = indexById(document.accessors, \"$.accessors\");\n const meshes = indexById(document.meshes, \"$.meshes\");\n const materials = indexById(document.materials, \"$.materials\");\n const textures = indexById(document.textures, \"$.textures\");\n const skeletons = indexById(document.skeletons, \"$.skeletons\");\n const joints = indexById(document.joints, \"$.joints\");\n const skins = indexById(document.skins, \"$.skins\");\n const blendShapes = indexById(document.blendShapes, \"$.blendShapes\");\n indexById(document.animations, \"$.animations\");\n indexById(document.analyticGeometry, \"$.analyticGeometry\");\n const scene = validateScene(document.roots, document.nodes, nodes);\n\n const readers = new Map<string, AccessorReader>();\n const payloadEvidence = new Map<string, AccessorPayloadEvidence>();\n for (let index = 0; index < document.accessors.length; index += 1) {\n const accessor = document.accessors[index]!;\n const resource = requireReference(resources, accessor.resourceId, `$.accessors[${index}].resourceId`, \"resource\");\n if (resource.kind !== \"buffer\") return fail(\"invalid-reference\", `$.accessors[${index}].resourceId`, \"accessor resource must be a buffer\");\n const reader = createAccessorReader(accessor, resource, `$.accessors[${index}]`);\n payloadEvidence.set(accessor.id, validateAccessorPayload(reader, `$.accessors[${index}]`));\n readers.set(accessor.id, reader);\n }\n\n const primitiveById = new Map<string, { primitive: GpuModelPrimitive; mesh: GpuModelMesh; path: string; position: GpuModelAccessor }>();\n const weightedPrimitiveIds = new Set<string>();\n const maximumIndexByAccessor = new Map<string, number>();\n for (let meshIndex = 0; meshIndex < document.meshes.length; meshIndex += 1) {\n const mesh = document.meshes[meshIndex]!;\n for (let primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex += 1) {\n const primitive = mesh.primitives[primitiveIndex]!;\n const path = `$.meshes[${meshIndex}].primitives[${primitiveIndex}]`;\n if (primitiveById.has(primitive.id)) return fail(\"duplicate-id\", path, `duplicate primitive ID: ${primitive.id}`);\n const positionAttribute = primitive.attributes.find(({ semantic }) => semantic === \"POSITION\")!;\n const position = requireReference(accessors, positionAttribute.accessorId, `${path}.attributes`, \"accessor\");\n for (let attributeIndex = 0; attributeIndex < primitive.attributes.length; attributeIndex += 1) {\n const attribute = primitive.attributes[attributeIndex]!;\n const accessor = requireReference(accessors, attribute.accessorId, `${path}.attributes[${attributeIndex}].accessorId`, \"accessor\");\n validateAttributeAccessor(attribute.semantic, accessor, `${path}.attributes[${attributeIndex}]`);\n if (accessor.count !== position.count) return fail(\"invalid-reference\", `${path}.attributes[${attributeIndex}]`, \"vertex attribute count must match POSITION\");\n }\n const jointSets = primitive.attributes.filter(({ semantic }) => semantic.startsWith(\"JOINTS_\")).map(({ semantic }) => semantic.slice(\"JOINTS_\".length)).sort();\n const weightSets = primitive.attributes.filter(({ semantic }) => semantic.startsWith(\"WEIGHTS_\")).map(({ semantic }) => semantic.slice(\"WEIGHTS_\".length)).sort();\n if (jointSets.length > 0 || weightSets.length > 0) {\n if (jointSets.length !== weightSets.length || jointSets.some((suffix, index) => suffix !== weightSets[index] || Number(suffix) !== index)) {\n return fail(\"invalid-reference\", `${path}.attributes`, \"JOINTS_n and WEIGHTS_n attributes must be paired and contiguous from zero\");\n }\n weightedPrimitiveIds.add(primitive.id);\n }\n const positionReader = requireReference(readers, position.id, `${path}.attributes`, \"accessor reader\");\n const actual = actualAccessorBounds(\n positionReader,\n requireReference(payloadEvidence, position.id, `${path}.attributes`, \"accessor payload evidence\"),\n `${path}.attributes.POSITION`,\n );\n assertBoundsEqual(actual, { min: position.min as GpuModelVec3, max: position.max as GpuModelVec3 }, `${path}.attributes.POSITION`);\n if (primitive.indicesAccessorId) {\n const indices = requireReference(accessors, primitive.indicesAccessorId, `${path}.indicesAccessorId`, \"accessor\");\n if (indices.elementType !== \"scalar\" || !(indices.componentType === \"u8\" || indices.componentType === \"u16\" || indices.componentType === \"u32\") || indices.normalized === true) {\n return fail(\"invalid-reference\", `${path}.indicesAccessorId`, \"index accessor must be an unsigned non-normalized scalar\");\n }\n const indexReader = requireReference(readers, indices.id, `${path}.indicesAccessorId`, \"accessor reader\");\n let maximumIndex = maximumIndexByAccessor.get(indices.id);\n if (maximumIndex === undefined) {\n consumeBudget(\n budget,\n \"geometryIndexElements\",\n indices.count,\n GPU_MODEL_DOCUMENT_LIMITS.geometryIndexElements,\n `${path}.indicesAccessorId`,\n \"geometry index element\",\n );\n maximumIndex = 0;\n for (let item = 0; item < indices.count; item += 1) {\n maximumIndex = Math.max(maximumIndex, indexReader.read(item)[0]!);\n }\n maximumIndexByAccessor.set(indices.id, maximumIndex);\n }\n if (maximumIndex >= position.count) return fail(\"invalid-reference\", `${path}.indicesAccessorId`, \"index payload references a vertex outside POSITION\");\n }\n if (primitive.materialId) {\n const material = requireReference(materials, primitive.materialId, `${path}.materialId`, \"material\");\n const semantics = new Set(primitive.attributes.map(({ semantic }) => semantic));\n for (const [slot, binding] of Object.entries(material.textures)) {\n if (!binding) continue;\n const requiredSemantic = `TEXCOORD_${String(binding.texCoordSet ?? 0)}`;\n if (!semantics.has(requiredSemantic)) {\n return fail(\n \"invalid-reference\",\n `${path}.materialId`,\n `material texture binding ${slot} requires primitive attribute ${requiredSemantic}`,\n );\n }\n }\n }\n primitiveById.set(primitive.id, { primitive, mesh, path, position });\n }\n }\n\n interface MeshValidationEvidence {\n readonly primitiveIds: ReadonlySet<string>;\n readonly positionReaders: readonly AccessorReader[];\n }\n const meshEvidenceById = new Map<string, MeshValidationEvidence>();\n for (const mesh of document.meshes) {\n const primitiveIds = new Set<string>();\n const positionIds = new Set<string>();\n for (const primitive of mesh.primitives) {\n primitiveIds.add(primitive.id);\n positionIds.add(requireReference(primitiveById, primitive.id, `$.meshes.${mesh.id}`, \"primitive\").position.id);\n }\n const positionReaders = Object.freeze([...positionIds].map((positionId) =>\n requireReference(readers, positionId, `$.meshes.${mesh.id}`, \"POSITION reader\")));\n meshEvidenceById.set(mesh.id, Object.freeze({ primitiveIds, positionReaders }));\n }\n\n const worldGeometry: Array<{\n readonly nodeIndex: number;\n readonly world: GpuModelMatrix4;\n readonly positionReaders: readonly AccessorReader[];\n }> = [];\n for (let nodeIndex = 0; nodeIndex < document.nodes.length; nodeIndex += 1) {\n const node = document.nodes[nodeIndex]!;\n if (node.skinId && !node.meshId) return fail(\"invalid-reference\", `$.nodes[${nodeIndex}].skinId`, \"a skinned node must also reference a mesh\");\n if (node.skinId) requireReference(skins, node.skinId, `$.nodes[${nodeIndex}].skinId`, \"skin\");\n if (!node.meshId) continue;\n requireReference(meshes, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh validation evidence\");\n const world = requireReference(scene.worldByNode, node.id, `$.nodes[${nodeIndex}]`, \"world transform\");\n const positionReaders = Object.freeze(meshEvidence.positionReaders.map((reader) => {\n consumeBudget(\n budget,\n \"geometryWorldAccessorInstances\",\n 1,\n GPU_MODEL_DOCUMENT_LIMITS.geometryWorldAccessorInstances,\n `$.nodes[${nodeIndex}].meshId`,\n \"world-geometry accessor instance\",\n );\n consumeBudget(\n budget,\n \"geometryWorldVertices\",\n reader.accessor.count,\n GPU_MODEL_DOCUMENT_LIMITS.geometryWorldVertices,\n `$.nodes[${nodeIndex}].meshId`,\n \"world-geometry vertex\",\n );\n return reader;\n }));\n worldGeometry.push({ nodeIndex, world, positionReaders });\n }\n if (worldGeometry.length === 0) return fail(\"invalid-reference\", \"$.bounds\", \"document bounds require scene-referenced byte-verified POSITION geometry\");\n\n const worldMin = [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY];\n const worldMax = [Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY];\n for (const { nodeIndex, world, positionReaders } of worldGeometry) {\n for (const reader of positionReaders) {\n for (let vertex = 0; vertex < reader.accessor.count; vertex += 1) {\n const transformed = transformPosition(world, reader.read(vertex));\n for (let component = 0; component < 3; component += 1) {\n const value = transformed[component]!;\n if (!Number.isFinite(value)) return fail(\"invalid-value\", `$.nodes[${nodeIndex}].localMatrix`, \"world transform produced non-finite bounds\");\n worldMin[component] = Math.min(worldMin[component]!, value);\n worldMax[component] = Math.max(worldMax[component]!, value);\n }\n }\n }\n }\n assertBoundsEqual(\n { min: worldMin as unknown as GpuModelVec3, max: worldMax as unknown as GpuModelVec3 },\n document.bounds,\n \"$.bounds\",\n );\n\n for (let index = 0; index < document.textures.length; index += 1) {\n const texture = document.textures[index]!;\n const resource = requireReference(resources, texture.imageResourceId, `$.textures[${index}].imageResourceId`, \"resource\");\n if (resource.kind !== \"image\") return fail(\"invalid-reference\", `$.textures[${index}].imageResourceId`, \"texture resource must be an image\");\n if (texture.contentHash !== resource.contentHash) return fail(\"invalid-reference\", `$.textures[${index}].contentHash`, \"texture hash must match its verified image resource\");\n if (texture.mimeType !== undefined && texture.mimeType !== resource.mimeType) return fail(\"invalid-reference\", `$.textures[${index}].mimeType`, \"texture MIME type must match its image resource\");\n if (texture.byteLength !== undefined && texture.byteLength !== resource.byteLength) return fail(\"invalid-reference\", `$.textures[${index}].byteLength`, \"texture byteLength must match its image resource\");\n }\n for (let materialIndex = 0; materialIndex < document.materials.length; materialIndex += 1) {\n const material = document.materials[materialIndex]!;\n for (const [slot, expectedUsage] of Object.entries(MATERIAL_TEXTURE_SLOTS) as Array<[keyof GpuModelMaterialTextures, GpuModelTextureUsage]>) {\n const binding = material.textures[slot];\n if (!binding) continue;\n const texture = requireReference(textures, binding.textureId, `$.materials[${materialIndex}].textures.${slot}.textureId`, \"texture\");\n if (binding.intendedUsage !== expectedUsage) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.intendedUsage`, \"texture usage does not match its material slot\");\n if (!texture.intendedUsage.includes(binding.intendedUsage)) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}`, \"texture does not declare the binding usage\");\n if (texture.colorSpace !== binding.colorSpace) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.colorSpace`, \"binding and texture color spaces must match\");\n if (binding.samplerId !== undefined && binding.samplerId !== texture.sampler?.id) return fail(\"invalid-reference\", `$.materials[${materialIndex}].textures.${slot}.samplerId`, \"binding sampler does not match the texture sampler\");\n }\n }\n\n const skeletonForJoint = new Map<string, string>();\n const jointIdsBySkeleton = new Map<string, ReadonlySet<string>>();\n for (let skeletonIndex = 0; skeletonIndex < document.skeletons.length; skeletonIndex += 1) {\n const skeleton = document.skeletons[skeletonIndex]!;\n const skeletonJointIds = new Set(skeleton.jointIds);\n const skeletonJointNodes = new Set<string>();\n const expectedRoots = new Set<string>();\n jointIdsBySkeleton.set(skeleton.id, skeletonJointIds);\n for (let jointIndex = 0; jointIndex < skeleton.jointIds.length; jointIndex += 1) {\n const jointId = skeleton.jointIds[jointIndex]!;\n const joint = requireReference(joints, jointId, `$.skeletons[${skeletonIndex}].jointIds[${jointIndex}]`, \"joint\");\n if (skeletonForJoint.has(jointId)) return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].jointIds[${jointIndex}]`, \"joint cannot belong to more than one skeleton\");\n skeletonForJoint.set(jointId, skeleton.id);\n requireReference(nodes, joint.nodeId, `$.joints.${joint.id}.nodeId`, \"node\");\n if (skeletonJointNodes.has(joint.nodeId)) return fail(\"duplicate-id\", `$.skeletons[${skeletonIndex}].jointIds`, `duplicate joint node: ${joint.nodeId}`);\n skeletonJointNodes.add(joint.nodeId);\n if (joint.parentJointId === undefined) expectedRoots.add(joint.id);\n }\n const declaredRoots = new Set(skeleton.rootJointIds);\n if (expectedRoots.size !== declaredRoots.size || [...expectedRoots].some((id) => !declaredRoots.has(id))) {\n return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].rootJointIds`, \"rootJointIds must exactly identify parentless skeleton joints\");\n }\n for (let rootIndex = 0; rootIndex < skeleton.rootJointIds.length; rootIndex += 1) {\n const rootJoint = requireReference(joints, skeleton.rootJointIds[rootIndex]!, `$.skeletons[${skeletonIndex}].rootJointIds[${rootIndex}]`, \"joint\");\n if (!skeletonJointIds.has(rootJoint.id)) return fail(\"invalid-reference\", `$.skeletons[${skeletonIndex}].rootJointIds[${rootIndex}]`, \"root joint is not a member of the skeleton\");\n requireReference(scene.worldByNode, rootJoint.nodeId, `$.joints.${rootJoint.id}.nodeId`, \"scene node\");\n }\n }\n if (skeletonForJoint.size !== document.joints.length) return fail(\"invalid-reference\", \"$.joints\", \"every joint must belong to exactly one skeleton\");\n for (let jointIndex = 0; jointIndex < document.joints.length; jointIndex += 1) {\n const joint = document.joints[jointIndex]!;\n const node = requireReference(nodes, joint.nodeId, `$.joints[${jointIndex}].nodeId`, \"node\");\n if (joint.parentJointId) {\n const parent = requireReference(joints, joint.parentJointId, `$.joints[${jointIndex}].parentJointId`, \"joint\");\n if (skeletonForJoint.get(parent.id) !== skeletonForJoint.get(joint.id)) return fail(\"invalid-reference\", `$.joints[${jointIndex}].parentJointId`, \"parent joint must belong to the same skeleton\");\n if (!isAncestor(scene, parent.nodeId, node.id)) return fail(\"invalid-reference\", `$.joints[${jointIndex}].parentJointId`, \"parent joint node must be an ancestor of the child joint node\");\n }\n }\n\n const skinUse = new Map<string, Set<string>>();\n for (const node of document.nodes) {\n if (!node.skinId || !node.meshId) continue;\n const set = skinUse.get(node.skinId) ?? new Set<string>();\n set.add(node.meshId);\n skinUse.set(node.skinId, set);\n }\n const skinValidatedPrimitiveIds = new Set<string>();\n for (let skinIndex = 0; skinIndex < document.skins.length; skinIndex += 1) {\n const skin = document.skins[skinIndex]!;\n const skeleton = requireReference(skeletons, skin.skeletonId, `$.skins[${skinIndex}].skeletonId`, \"skeleton\");\n const skeletonJointIds = requireReference(jointIdsBySkeleton, skeleton.id, `$.skins[${skinIndex}].skeletonId`, \"skeleton joint set\");\n for (let jointIndex = 0; jointIndex < skin.jointIds.length; jointIndex += 1) {\n const joint = requireReference(joints, skin.jointIds[jointIndex]!, `$.skins[${skinIndex}].jointIds[${jointIndex}]`, \"joint\");\n if (!skeletonJointIds.has(joint.id)) return fail(\"invalid-reference\", `$.skins[${skinIndex}].jointIds[${jointIndex}]`, \"skin joint is not a member of its skeleton\");\n if (joint.inverseBindMatrix && !matrixAlmostEqual(joint.inverseBindMatrix, skin.inverseBindMatrices[jointIndex]!)) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].inverseBindMatrices[${jointIndex}]`, \"skin matrix does not match authored joint inverse bind matrix\");\n }\n }\n const usedMeshes = skinUse.get(skin.id);\n if (!usedMeshes || usedMeshes.size === 0) return fail(\"invalid-reference\", `$.skins[${skinIndex}]`, \"skin must be linked from a node that also references a mesh\");\n const expectedPrimitiveIds = new Set<string>();\n for (const meshId of usedMeshes) {\n requireReference(meshes, meshId, `$.skins[${skinIndex}]`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, meshId, `$.skins[${skinIndex}]`, \"mesh validation evidence\");\n for (const primitiveId of meshEvidence.primitiveIds) expectedPrimitiveIds.add(primitiveId);\n }\n const weightSetByPrimitive = new Map(skin.weightSets.map((weightSet) => [weightSet.primitiveId, weightSet]));\n if (weightSetByPrimitive.size !== expectedPrimitiveIds.size || [...expectedPrimitiveIds].some((id) => !weightSetByPrimitive.has(id))) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"skin weight sets must exactly cover linked mesh primitives\");\n }\n for (const primitiveId of expectedPrimitiveIds) {\n skinValidatedPrimitiveIds.add(primitiveId);\n const primitiveEntry = requireReference(primitiveById, primitiveId, `$.skins[${skinIndex}].weightSets`, \"primitive\");\n const weightSet = requireReference(weightSetByPrimitive, primitiveId, `$.skins[${skinIndex}].weightSets`, \"weight set\");\n const jointsBySet = new Map<number, GpuModelAccessor>();\n const weightsBySet = new Map<number, GpuModelAccessor>();\n for (const attribute of primitiveEntry.primitive.attributes) {\n const jointMatch = /^JOINTS_([0-7])$/u.exec(attribute.semantic);\n const weightMatch = /^WEIGHTS_([0-7])$/u.exec(attribute.semantic);\n if (jointMatch) jointsBySet.set(Number(jointMatch[1]), requireReference(accessors, attribute.accessorId, primitiveEntry.path, \"joint accessor\"));\n if (weightMatch) weightsBySet.set(Number(weightMatch[1]), requireReference(accessors, attribute.accessorId, primitiveEntry.path, \"weight accessor\"));\n }\n if (jointsBySet.size === 0 || jointsBySet.size !== weightsBySet.size) return fail(\"invalid-reference\", primitiveEntry.path, \"JOINTS_n and WEIGHTS_n attributes must be paired\");\n for (let setIndex = 0; setIndex < jointsBySet.size; setIndex += 1) {\n if (!jointsBySet.has(setIndex) || !weightsBySet.has(setIndex)) return fail(\"invalid-reference\", primitiveEntry.path, \"joint and weight attribute sets must be contiguous from zero\");\n }\n if (weightSet.influencesPerVertex !== jointsBySet.size * 4) return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"influencesPerVertex does not match joint/weight attribute sets\");\n if (weightSet.joints.length !== primitiveEntry.position.count || weightSet.weights.length !== primitiveEntry.position.count) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"weight row count must match POSITION\");\n }\n for (let vertex = 0; vertex < primitiveEntry.position.count; vertex += 1) {\n const decodedJoints: number[] = [];\n const decodedWeights: number[] = [];\n for (let setIndex = 0; setIndex < jointsBySet.size; setIndex += 1) {\n decodedJoints.push(...requireReference(readers, jointsBySet.get(setIndex)!.id, primitiveEntry.path, \"joint reader\").read(vertex));\n decodedWeights.push(...requireReference(readers, weightsBySet.get(setIndex)!.id, primitiveEntry.path, \"weight reader\").read(vertex));\n }\n let total = 0;\n for (let influence = 0; influence < decodedJoints.length; influence += 1) {\n const jointIndexValue = decodedJoints[influence]!;\n const weight = decodedWeights[influence]!;\n if (!Number.isSafeInteger(jointIndexValue) || jointIndexValue < 0 || jointIndexValue >= skin.jointIds.length) return fail(\"invalid-reference\", primitiveEntry.path, \"joint payload index exceeds the skin joint list\");\n if (!Number.isFinite(weight) || weight < 0 || weight > 1) return fail(\"invalid-value\", primitiveEntry.path, \"weight payload contains an invalid value\");\n if (weightSet.joints[vertex]![influence] !== jointIndexValue || !almostEqual(weightSet.weights[vertex]![influence]!, weight)) {\n return fail(\"invalid-reference\", `$.skins[${skinIndex}].weightSets`, \"authored weight rows do not match verified accessor bytes\");\n }\n total += weight;\n }\n if (!almostEqual(total, 1, 1e-4)) return fail(\"invalid-value\", primitiveEntry.path, \"vertex weights must sum to one without repair\");\n }\n }\n }\n for (const primitiveId of weightedPrimitiveIds) {\n if (!skinValidatedPrimitiveIds.has(primitiveId)) return fail(\"invalid-reference\", `$.meshes[].primitives.${primitiveId}`, \"joint/weight attributes require a linked skin and mesh node\");\n }\n\n for (let shapeIndex = 0; shapeIndex < document.blendShapes.length; shapeIndex += 1) {\n const shape = document.blendShapes[shapeIndex]!;\n const mesh = requireReference(meshes, shape.meshId, `$.blendShapes[${shapeIndex}].meshId`, \"mesh\");\n const meshEvidence = requireReference(meshEvidenceById, mesh.id, `$.blendShapes[${shapeIndex}].meshId`, \"mesh validation evidence\");\n for (let deltaIndex = 0; deltaIndex < shape.deltas.length; deltaIndex += 1) {\n const delta = shape.deltas[deltaIndex]!;\n const path = `$.blendShapes[${shapeIndex}].deltas[${deltaIndex}]`;\n if (!meshEvidence.primitiveIds.has(delta.primitiveId)) return fail(\"invalid-reference\", `${path}.primitiveId`, \"blend-shape primitive is not part of its mesh\");\n const base = requireReference(primitiveById, delta.primitiveId, path, \"primitive\").position;\n for (const key of [\"positionAccessorId\", \"normalAccessorId\", \"tangentAccessorId\"] as const) {\n const accessorId = delta[key];\n if (!accessorId) continue;\n consumeBudget(\n budget,\n \"blendShapeAccessorReferences\",\n 1,\n GPU_MODEL_DOCUMENT_LIMITS.blendShapeAccessorReferences,\n `${path}.${key}`,\n \"blend-shape accessor reference\",\n );\n const accessor = requireReference(accessors, accessorId, `${path}.${key}`, \"accessor\");\n if (accessor.componentType !== \"f32\" || accessor.elementType !== \"vec3\" || accessor.count !== base.count || accessor.normalized === true) {\n return fail(\"invalid-reference\", `${path}.${key}`, \"blend-shape accessor has an invalid representation\");\n }\n requireReference(payloadEvidence, accessor.id, `${path}.${key}`, \"verified accessor payload evidence\");\n }\n }\n }\n\n for (let animationIndex = 0; animationIndex < document.animations.length; animationIndex += 1) {\n const animation = document.animations[animationIndex]!;\n const samplers = indexById(animation.samplers, `$.animations[${animationIndex}].samplers`);\n indexById(animation.channels, `$.animations[${animationIndex}].channels`);\n const usedSamplerIds = new Set<string>();\n const targetTypesBySampler = new Map<string, GpuModelAnimationTargetType>();\n for (let channelIndex = 0; channelIndex < animation.channels.length; channelIndex += 1) {\n const channel = animation.channels[channelIndex]!;\n const path = `$.animations[${animationIndex}].channels[${channelIndex}]`;\n const sampler = requireReference(samplers, channel.samplerId, `${path}.samplerId`, \"animation sampler\");\n usedSamplerIds.add(sampler.id);\n const previousTarget = targetTypesBySampler.get(sampler.id);\n if (previousTarget && previousTarget !== channel.targetType) return fail(\"invalid-reference\", `${path}.samplerId`, \"one animation sampler cannot drive incompatible target types\");\n targetTypesBySampler.set(sampler.id, channel.targetType);\n if (channel.targetType === \"weights\") requireReference(blendShapes, channel.targetId, `${path}.targetId`, \"blend shape\");\n else requireReference(nodes, channel.targetId, `${path}.targetId`, \"node\");\n }\n if (usedSamplerIds.size !== animation.samplers.length) return fail(\"invalid-reference\", `$.animations[${animationIndex}].samplers`, \"animation contains an unused sampler\");\n for (let samplerIndex = 0; samplerIndex < animation.samplers.length; samplerIndex += 1) {\n const sampler = animation.samplers[samplerIndex]!;\n const path = `$.animations[${animationIndex}].samplers[${samplerIndex}]`;\n const input = requireReference(accessors, sampler.inputAccessorId, `${path}.inputAccessorId`, \"accessor\");\n const output = requireReference(accessors, sampler.outputAccessorId, `${path}.outputAccessorId`, \"accessor\");\n if (input.componentType !== \"f32\" || input.elementType !== \"scalar\" || input.normalized === true) return fail(\"invalid-reference\", `${path}.inputAccessorId`, \"animation input must be a non-normalized f32 scalar accessor\");\n if (input.count !== sampler.inputTimesSeconds.length) return fail(\"invalid-reference\", `${path}.inputTimesSeconds`, \"authored input time count does not match its accessor\");\n const inputReader = requireReference(readers, input.id, `${path}.inputAccessorId`, \"accessor reader\");\n for (let key = 0; key < input.count; key += 1) {\n const decoded = inputReader.read(key)[0]!;\n if (!Number.isFinite(decoded) || !almostEqual(decoded, sampler.inputTimesSeconds[key]!)) return fail(\"invalid-reference\", `${path}.inputTimesSeconds`, \"authored input times do not match verified accessor bytes\");\n }\n if (sampler.inputTimesSeconds.at(-1)! > animation.durationSeconds + EPSILON) return fail(\"invalid-value\", `${path}.inputTimesSeconds`, \"animation key time exceeds clip duration\");\n const targetType = requireReference(targetTypesBySampler, sampler.id, path, \"sampler target type\");\n const expectedElementType: GpuModelAccessorElementType = targetType === \"node-rotation\" ? \"vec4\" : targetType === \"weights\" ? \"scalar\" : \"vec3\";\n if (output.componentType !== \"f32\" || output.elementType !== expectedElementType || output.normalized === true) return fail(\"invalid-reference\", `${path}.outputAccessorId`, \"animation output has an invalid accessor representation\");\n const multiplier = sampler.interpolation === \"cubic-spline\" ? 3 : 1;\n if (output.count !== input.count * multiplier) return fail(\"invalid-reference\", `${path}.outputAccessorId`, \"animation input and output element counts are inconsistent\");\n const expectedValues = output.count * ELEMENT_COMPONENTS[output.elementType];\n if (sampler.outputValues.length !== expectedValues) return fail(\"invalid-reference\", `${path}.outputValues`, \"authored output value count does not match its accessor\");\n const outputReader = requireReference(readers, output.id, `${path}.outputAccessorId`, \"accessor reader\");\n let flatIndex = 0;\n for (let element = 0; element < output.count; element += 1) {\n for (const decoded of outputReader.read(element)) {\n if (!Number.isFinite(decoded) || !almostEqual(decoded, sampler.outputValues[flatIndex]!)) return fail(\"invalid-reference\", `${path}.outputValues`, \"authored output values do not match verified accessor bytes\");\n flatIndex += 1;\n }\n }\n }\n }\n\n for (let index = 0; index < document.analyticGeometry.length; index += 1) {\n const analytic = document.analyticGeometry[index]!;\n const source = requireReference(resources, analytic.sourceResourceId, `$.analyticGeometry[${index}].sourceResourceId`, \"resource\");\n if (source.kind !== \"buffer\") return fail(\"invalid-reference\", `$.analyticGeometry[${index}].sourceResourceId`, \"analytic source must be a buffer resource\");\n if (analytic.tessellatedMeshId) requireReference(meshes, analytic.tessellatedMeshId, `$.analyticGeometry[${index}].tessellatedMeshId`, \"mesh\");\n }\n}\n\nfunction parseVerifiedResource(value: unknown, path: string): GpuModelResource {\n if (typeof value !== \"object\" || value === null || !verifiedResources.has(value) || !verifiedResourceBytes.has(value)) {\n return fail(\"resource-unverified\", path, \"expected a privately verified resource; use createAndVerifyGpuModelDocument\");\n }\n return value as GpuModelResource;\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || value instanceof Blob) return value;\n for (const child of Object.values(value)) deepFreeze(child);\n return Object.freeze(value);\n}\n\nconst DOCUMENT_KEYS = Object.freeze([\n \"schemaVersion\", \"coordinateSystem\", \"roots\", \"nodes\", \"resources\", \"accessors\", \"meshes\", \"materials\", \"textures\",\n \"skeletons\", \"joints\", \"skins\", \"blendShapes\", \"animations\", \"analyticGeometry\", \"bounds\", \"provenance\", \"diagnostics\", \"metadata\",\n] as const);\n\nfunction parseGpuModelDocument(value: unknown): GpuModelDocument {\n const path = \"$\";\n const record = readRecord(value, path, DOCUMENT_KEYS);\n const schemaVersion = requireKey(record, \"schemaVersion\", path);\n if (schemaVersion !== GPU_MODEL_DOCUMENT_SCHEMA_VERSION) return fail(\"invalid-value\", \"$.schemaVersion\", \"unsupported schema version\");\n const parseCollection = <T>(key: string, maximum: number, parser: (entry: unknown, entryPath: string) => T, minimum = 0): readonly T[] => {\n const input = readArray(requireKey(record, key, path), `$.${key}`, maximum, minimum);\n return Object.freeze(input.map((entry, index) => parser(entry, `$.${key}[${index}]`)));\n };\n const budget: DocumentBudget = {\n metadataValues: 0,\n sceneEdges: 0,\n primitiveAttributes: 0,\n accessorElements: 0,\n primitives: 0,\n skinJoints: 0,\n weightVertices: 0,\n weightInfluences: 0,\n animationSamplers: 0,\n animationChannels: 0,\n animationValues: 0,\n blendShapeDeltas: 0,\n blendShapeAccessorReferences: 0,\n geometryIndexElements: 0,\n geometryWorldAccessorInstances: 0,\n geometryWorldVertices: 0,\n };\n const roots = Object.freeze(readArray(requireKey(record, \"roots\", path), \"$.roots\", GPU_MODEL_DOCUMENT_LIMITS.roots, 1)\n .map((entry, index) => readId(entry, `$.roots[${index}]`)));\n const document: GpuModelDocument = {\n schemaVersion,\n coordinateSystem: parseCoordinateSystem(requireKey(record, \"coordinateSystem\", path)),\n roots,\n nodes: parseCollection(\"nodes\", GPU_MODEL_DOCUMENT_LIMITS.nodes, (entry, entryPath) => parseNode(entry, entryPath, budget), 1),\n resources: parseCollection(\"resources\", GPU_MODEL_DOCUMENT_LIMITS.resources, parseVerifiedResource, 1),\n accessors: parseCollection(\"accessors\", GPU_MODEL_DOCUMENT_LIMITS.accessors, (entry, entryPath) => parseAccessor(entry, entryPath, budget)),\n meshes: parseCollection(\"meshes\", GPU_MODEL_DOCUMENT_LIMITS.meshes, (entry, entryPath) => parseMesh(entry, entryPath, budget)),\n materials: parseCollection(\"materials\", GPU_MODEL_DOCUMENT_LIMITS.materials, (entry, entryPath) => parseMaterial(entry, entryPath, budget)),\n textures: parseCollection(\"textures\", GPU_MODEL_DOCUMENT_LIMITS.textures, (entry, entryPath) => parseTexture(entry, entryPath, budget)),\n skeletons: parseCollection(\"skeletons\", GPU_MODEL_DOCUMENT_LIMITS.skeletons, (entry, entryPath) => parseSkeleton(entry, entryPath, budget)),\n joints: parseCollection(\"joints\", GPU_MODEL_DOCUMENT_LIMITS.joints, (entry, entryPath) => parseJoint(entry, entryPath, budget)),\n skins: parseCollection(\"skins\", GPU_MODEL_DOCUMENT_LIMITS.skins, (entry, entryPath) => parseSkin(entry, entryPath, budget)),\n blendShapes: parseCollection(\"blendShapes\", GPU_MODEL_DOCUMENT_LIMITS.blendShapes, (entry, entryPath) => parseBlendShape(entry, entryPath, budget)),\n animations: parseCollection(\"animations\", GPU_MODEL_DOCUMENT_LIMITS.animations, (entry, entryPath) => parseAnimation(entry, entryPath, budget)),\n analyticGeometry: parseCollection(\"analyticGeometry\", GPU_MODEL_DOCUMENT_LIMITS.analyticGeometry, (entry, entryPath) => parseAnalyticGeometry(entry, entryPath, budget)),\n bounds: parseBounds(requireKey(record, \"bounds\", path), \"$.bounds\"),\n provenance: parseProvenance(requireKey(record, \"provenance\", path), budget),\n diagnostics: parseCollection(\"diagnostics\", GPU_MODEL_DOCUMENT_LIMITS.diagnostics, (entry, entryPath) => parseDiagnostic(entry, entryPath, budget)),\n metadata: readMetadata(requireKey(record, \"metadata\", path), \"$.metadata\", budget),\n };\n if (document.meshes.length === 0) return fail(\"invalid-value\", \"$.meshes\", \"v1 document bounds require at least one canonical mesh\");\n validateReferences(document, budget);\n const frozen = deepFreeze(document);\n validatedDocuments.add(frozen);\n return frozen;\n}\n\n/**\n * Creates a document only from privately verified resource values. This\n * synchronous factory never hashes or inspects caller-controlled bytes.\n */\nexport function createGpuModelDocument(value: unknown): GpuModelDocument {\n if (typeof value === \"object\" && value !== null && validatedDocuments.has(value)) return value as GpuModelDocument;\n try {\n return parseGpuModelDocument(value);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$\", \"input could not be safely inspected\");\n }\n}\n\n/** Non-narrowing probe for the synchronous, privately verified factory. */\nexport function canCreateGpuModelDocument(value: unknown): boolean {\n try {\n createGpuModelDocument(value);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Only privately branded factory output narrows to GpuModelDocument. */\nexport function isGpuModelDocument(value: unknown): value is GpuModelDocument {\n return typeof value === \"object\" && value !== null && validatedDocuments.has(value);\n}\n\n/**\n * Preflights all resource budgets, verifies every raw resource through the\n * injected streaming port, then performs the complete synchronous contract\n * validation. Structured clones intentionally re-enter verification.\n */\nexport async function createAndVerifyGpuModelDocument(\n value: unknown,\n port: GpuModelResourceVerificationPort,\n options?: GpuModelResourceVerificationOptions,\n): Promise<GpuModelDocument> {\n try {\n const limits = resolveVerificationLimits(options);\n if (options?.signal?.aborted) return fail(\"resource-verification-failed\", \"$.resources\", \"resource verification was aborted\");\n if (isGpuModelDocument(value)) {\n preflightResourceBudget(value.resources, limits);\n value.resources.forEach((resource, index) => assertVerifiedResourceEvidence(resource, limits, `$.resources[${index}]`));\n return value;\n }\n const record = readRecord(value, \"$\", DOCUMENT_KEYS);\n const resourceInput = readArray(requireKey(record, \"resources\", \"$\"), \"$.resources\", GPU_MODEL_DOCUMENT_LIMITS.resources, 1);\n const parsed = resourceInput.map((entry, index) => {\n if (typeof entry === \"object\" && entry !== null && verifiedResources.has(entry) && verifiedResourceBytes.has(entry)) return entry as GpuModelResource;\n return parseResourceHeader(entry, `$.resources[${index}]`);\n });\n ensureUnique(parsed.map(({ id }) => id), \"$.resources\");\n preflightResourceBudget(parsed, limits);\n const verified: GpuModelResource[] = [];\n for (let index = 0; index < parsed.length; index += 1) {\n verified.push(await verifyParsedResource(parsed[index]!, port, limits, options, `$.resources[${index}]`));\n }\n const candidate: Record<string, unknown> = {};\n for (const key of DOCUMENT_KEYS) {\n if (Object.hasOwn(record, key)) candidate[key] = record[key];\n }\n candidate.resources = verified;\n return createGpuModelDocument(candidate);\n } catch (error) {\n if (error instanceof GpuModelDocumentError) throw error;\n throw new GpuModelDocumentError(\"invalid-type\", \"$\", \"input could not be safely inspected or verified\");\n }\n}\n\n/** Version of the bounded compiler projection used by the ChatGPT PVOX demo. */\nexport const GPU_MODEL_STATIC_DEMO_PROFILE_VERSION = \"plasius.gpu-model-static-demo/1\" as const;\n\n/** Remotely evaluated parent gate required before the demo projection may run. */\nexport const GPU_MODEL_STATIC_DEMO_FEATURE_FLAG = \"asset.pipeline.pvox-models.enabled\" as const;\n\n/** Fixed-point PVOX coordinate ceiling; callers cannot override or raise it. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES = 1_048_576 as const;\n\n/** Largest axis extent representable between the fixed coordinate endpoints. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES = GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES * 2;\n\n/** Largest three-axis diagonal representable inside the fixed coordinate cube. */\nexport const GPU_MODEL_STATIC_DEMO_MAX_DIAGONAL_METRES = Math.hypot(\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES,\n);\n\n/** Non-raiseable ceilings for the bounded static PVOX demonstration profile. */\nexport const GPU_MODEL_STATIC_DEMO_LIMITS = Object.freeze({\n maxTriangles: 200_000,\n maxNodes: 4_096,\n maxPrimitives: 16_384,\n maxMaterials: 4_096,\n maxResourceBytes: 16 * 1024 * 1024,\n maxAggregateResourceBytes: 16 * 1024 * 1024,\n} as const);\n\n/** Exact spatial promise required from source adapters before demo compilation. */\nexport const GPU_MODEL_STATIC_DEMO_NORMALIZATION_CONTRACT = Object.freeze({\n ...CANONICAL_GPU_MODEL_COORDINATE_SYSTEM,\n floorPlane: \"y=0\",\n horizontalCenter: \"bounds-centre-xz-at-origin\",\n} as const);\n\nexport interface GpuModelStaticDemoLimits {\n readonly maxTriangles: number;\n readonly maxNodes: number;\n readonly maxPrimitives: number;\n readonly maxMaterials: number;\n readonly maxResourceBytes: number;\n readonly maxAggregateResourceBytes: number;\n}\n\n/** Callers pass the remotely evaluated parent gate; local defaults fail closed. */\nexport interface GpuModelStaticDemoCompilerOptions {\n readonly pvoxModelsEnabled: boolean;\n readonly limits?: Partial<GpuModelStaticDemoLimits>;\n}\n\n/** URI-free evidence retained by a compiler projection. */\nexport interface GpuModelStaticDemoSourceEvidence {\n readonly sourceFormat: string;\n readonly sourceContentHash: string;\n readonly converterId: string;\n readonly converterVersion: string;\n readonly provider?: string;\n}\n\n/** Fixed, texture-free surface properties for one material region. */\nexport interface GpuModelStaticDemoMaterial {\n readonly sourceMaterialId: string | null;\n readonly sourceMaterialName?: string;\n readonly sourceWorkflow: \"metallic-roughness\" | \"unlit\";\n readonly baseColorFactor: GpuModelVec4;\n readonly metallicFactor: number;\n readonly roughnessFactor: number;\n readonly emissiveFactor: GpuModelVec3;\n readonly doubleSided: boolean;\n}\n\nexport type GpuModelTriangleVec3 = readonly [GpuModelVec3, GpuModelVec3, GpuModelVec3];\n\n/** One byte-verified source triangle transformed into canonical world space. */\nexport interface GpuModelStaticDemoWorldTriangle {\n readonly sourceNodeId: string;\n readonly sourceMeshId: string;\n readonly sourcePrimitiveId: string;\n readonly sourceTriangleIndex: number;\n readonly materialIndex: number;\n readonly positions: GpuModelTriangleVec3;\n readonly normals: GpuModelTriangleVec3;\n readonly bounds: GpuModelBounds;\n}\n\n/** Immutable, compiler-safe hand-off from model core to the PVOX compiler. */\nexport interface GpuModelStaticDemoCompilerInput {\n readonly profileVersion: typeof GPU_MODEL_STATIC_DEMO_PROFILE_VERSION;\n readonly canonicalDocumentHash: string;\n readonly coordinateSystem: typeof CANONICAL_GPU_MODEL_COORDINATE_SYSTEM;\n readonly bounds: GpuModelBounds;\n readonly sourceEvidence: GpuModelStaticDemoSourceEvidence;\n readonly materials: readonly GpuModelStaticDemoMaterial[];\n readonly worldTriangles: readonly GpuModelStaticDemoWorldTriangle[];\n}\n\nconst CANONICAL_DOCUMENT_ENCODING_VERSION = \"plasius.gpu-model-document-canonical-json/1\" as const;\n\nfunction canonicalJson(value: unknown): string {\n if (value === null) return \"null\";\n if (typeof value === \"string\" || typeof value === \"boolean\") return JSON.stringify(value);\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) return fail(\"invalid-value\", \"$\", \"canonical encoding encountered a non-finite number\");\n return JSON.stringify(Object.is(value, -0) ? 0 : value);\n }\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(\",\")}]`;\n if (typeof value !== \"object\" || value === null || value instanceof Blob) {\n return fail(\"invalid-type\", \"$\", \"canonical encoding encountered an unsupported value\");\n }\n const entries = Object.entries(value)\n .filter(([, entry]) => entry !== undefined)\n .sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);\n return `{${entries.map(([key, entry]) => `${JSON.stringify(key)}:${canonicalJson(entry)}`).join(\",\")}}`;\n}\n\nfunction canonicalDocumentRecord(document: GpuModelDocument): Readonly<Record<string, unknown>> {\n const resources = document.resources.map(({ payload: _payload, ...resource }) => resource);\n return {\n encodingVersion: CANONICAL_DOCUMENT_ENCODING_VERSION,\n document: { ...document, resources },\n };\n}\n\n/**\n * Encodes the complete verified document deterministically. Resource payloads\n * are represented by their privately verified SHA-256 identities, not copied\n * into the encoding a second time. Object keys are sorted; semantic array order\n * is preserved.\n */\nexport function encodeGpuModelDocumentCanonical(document: GpuModelDocument): Uint8Array {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"canonical encoding requires a verified GPU model document\");\n return new TextEncoder().encode(canonicalJson(canonicalDocumentRecord(document)));\n}\n\n/** Computes the lowercase SHA-256 identity of the canonical whole document. */\nexport async function hashGpuModelDocumentCanonical(document: GpuModelDocument): Promise<string> {\n const bytes = encodeGpuModelDocumentCanonical(document);\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) return fail(\"unsupported-feature\", \"$\", \"SHA-256 Web Crypto is unavailable\");\n const digest = await subtle.digest(\"SHA-256\", Uint8Array.from(bytes).buffer);\n return Array.from(new Uint8Array(digest), (value) => value.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nfunction resolveStaticDemoLimits(options: GpuModelStaticDemoCompilerOptions): Readonly<GpuModelStaticDemoLimits> {\n const record = readRecord(options, \"$.options\", [\"pvoxModelsEnabled\", \"limits\"]);\n const enabled = readBoolean(requireKey(record, \"pvoxModelsEnabled\", \"$.options\"), \"$.options.pvoxModelsEnabled\");\n if (!enabled) return fail(\"feature-disabled\", \"$.options.pvoxModelsEnabled\", `${GPU_MODEL_STATIC_DEMO_FEATURE_FLAG} is disabled`);\n if (!Object.hasOwn(record, \"limits\")) return GPU_MODEL_STATIC_DEMO_LIMITS;\n const overrides = readRecord(record.limits, \"$.options.limits\", Object.keys(GPU_MODEL_STATIC_DEMO_LIMITS));\n const limits: Record<string, number> = { ...GPU_MODEL_STATIC_DEMO_LIMITS };\n for (const [key, ceiling] of Object.entries(GPU_MODEL_STATIC_DEMO_LIMITS)) {\n if (Object.hasOwn(overrides, key)) limits[key] = readSafeInteger(overrides[key], `$.options.limits.${key}`, 1, ceiling);\n }\n return Object.freeze(limits) as unknown as Readonly<GpuModelStaticDemoLimits>;\n}\n\n/** Proves metre/Y-up/-Z/floor-centred normalization against verified bounds. */\nexport function assertGpuModelStaticDemoNormalization(document: GpuModelDocument): void {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"normalization requires a verified GPU model document\");\n const extents = document.bounds.max.map((value, index) => value - document.bounds.min[index]!);\n const diagonal = Math.hypot(...extents);\n if (!Number.isFinite(diagonal) || diagonal <= 0) return fail(\"invalid-value\", \"$.bounds\", \"static demo bounds must have a finite non-zero diagonal\");\n if ([...document.bounds.min, ...document.bounds.max].some((value) => Math.abs(value) > GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES)) {\n return fail(\"limit-exceeded\", \"$.bounds\", \"static demo coordinate magnitude exceeds the fixed PVOX ceiling\");\n }\n if (extents.some((extent) => extent > GPU_MODEL_STATIC_DEMO_MAX_EXTENT_METRES)\n || diagonal > GPU_MODEL_STATIC_DEMO_MAX_DIAGONAL_METRES) {\n return fail(\"limit-exceeded\", \"$.bounds\", \"static demo extent exceeds the fixed PVOX ceiling\");\n }\n const tolerance = Math.min(1e-3, Math.max(1, diagonal) * EPSILON);\n const floorAligned = Math.abs(document.bounds.min[1]) <= tolerance;\n const centeredX = Math.abs(document.bounds.min[0] + document.bounds.max[0]) <= tolerance * 2;\n const centeredZ = Math.abs(document.bounds.min[2] + document.bounds.max[2]) <= tolerance * 2;\n if (!floorAligned || !centeredX || !centeredZ) {\n return fail(\"invalid-value\", \"$.bounds\", \"static demo geometry must be floor-centred at the canonical origin\");\n }\n}\n\nfunction determinant3(matrix: GpuModelMatrix4): number {\n const a00 = matrix[0], a01 = matrix[4], a02 = matrix[8];\n const a10 = matrix[1], a11 = matrix[5], a12 = matrix[9];\n const a20 = matrix[2], a21 = matrix[6], a22 = matrix[10];\n return a00 * (a11 * a22 - a12 * a21)\n - a01 * (a10 * a22 - a12 * a20)\n + a02 * (a10 * a21 - a11 * a20);\n}\n\nfunction normalizedVector(value: readonly number[], path: string): GpuModelVec3 {\n const length = Math.hypot(value[0]!, value[1]!, value[2]!);\n if (!Number.isFinite(length) || length <= 1e-12) return fail(\"invalid-value\", path, \"triangle or normal vector is degenerate\");\n return Object.freeze([value[0]! / length, value[1]! / length, value[2]! / length]) as GpuModelVec3;\n}\n\nfunction faceNormal(positions: GpuModelTriangleVec3, path: string): GpuModelVec3 {\n const ab = positions[1].map((value, index) => value - positions[0][index]!) as number[];\n const ac = positions[2].map((value, index) => value - positions[0][index]!) as number[];\n return normalizedVector([\n ab[1]! * ac[2]! - ab[2]! * ac[1]!,\n ab[2]! * ac[0]! - ab[0]! * ac[2]!,\n ab[0]! * ac[1]! - ab[1]! * ac[0]!,\n ], path);\n}\n\nfunction transformNormal(matrix: GpuModelMatrix4, normal: readonly number[], determinant: number, fallback: GpuModelVec3): GpuModelVec3 {\n const a00 = matrix[0], a01 = matrix[4], a02 = matrix[8];\n const a10 = matrix[1], a11 = matrix[5], a12 = matrix[9];\n const a20 = matrix[2], a21 = matrix[6], a22 = matrix[10];\n const transformed = [\n ((a11 * a22 - a12 * a21) * normal[0]! + (a12 * a20 - a10 * a22) * normal[1]! + (a10 * a21 - a11 * a20) * normal[2]!) / determinant,\n ((a02 * a21 - a01 * a22) * normal[0]! + (a00 * a22 - a02 * a20) * normal[1]! + (a01 * a20 - a00 * a21) * normal[2]!) / determinant,\n ((a01 * a12 - a02 * a11) * normal[0]! + (a02 * a10 - a00 * a12) * normal[1]! + (a00 * a11 - a01 * a10) * normal[2]!) / determinant,\n ];\n const length = Math.hypot(...transformed);\n return !Number.isFinite(length) || length <= 1e-12\n ? fallback\n : Object.freeze(transformed.map((value) => value / length)) as unknown as GpuModelVec3;\n}\n\nfunction triangleBounds(positions: GpuModelTriangleVec3): GpuModelBounds {\n const min = [0, 1, 2].map((component) => Math.min(...positions.map((position) => position[component]!))) as unknown as GpuModelVec3;\n const max = [0, 1, 2].map((component) => Math.max(...positions.map((position) => position[component]!))) as unknown as GpuModelVec3;\n return { min, max };\n}\n\nfunction assertStaticDemoTriangleCoordinates(positions: GpuModelTriangleVec3, path: string): void {\n for (let corner = 0; corner < positions.length; corner += 1) {\n for (let component = 0; component < positions[corner]!.length; component += 1) {\n if (Math.abs(positions[corner]![component]!) > GPU_MODEL_STATIC_DEMO_MAX_ABSOLUTE_COORDINATE_METRES) {\n return fail(\"limit-exceeded\", path, \"static demo triangle coordinate exceeds the fixed PVOX ceiling\");\n }\n }\n }\n}\n\nfunction staticDemoMaterial(material: GpuModelMaterial): GpuModelStaticDemoMaterial {\n if (material.workflow !== \"metallic-roughness\" && material.workflow !== \"unlit\") {\n return fail(\"unsupported-feature\", `$.materials.${material.id}.workflow`, \"static demo supports metallic-roughness and unlit materials only\");\n }\n const unsupportedSurfaceExtension = (material.transmissionFactor ?? 0) > 0\n || (material.clearcoatFactor ?? 0) > 0\n || (material.sheenColorFactor?.some((value) => value > 0) ?? false)\n || Object.keys(material.extensions).length > 0;\n if (material.alphaMode !== \"opaque\" || material.baseColorFactor[3] !== 1 || unsupportedSurfaceExtension) {\n return fail(\"unsupported-feature\", `$.materials.${material.id}`, \"static demo supports opaque fixed-factor materials without unsupported surface extensions\");\n }\n if (Object.keys(material.textures).length > 0) {\n return fail(\"unsupported-feature\", `$.materials.${material.id}.textures`, \"static demo accepts fixed surface factors, not texture bindings\");\n }\n const output: Record<string, unknown> = {\n sourceMaterialId: material.id,\n sourceWorkflow: material.workflow,\n baseColorFactor: material.baseColorFactor,\n metallicFactor: material.metallicFactor ?? 0,\n roughnessFactor: material.roughnessFactor ?? 1,\n emissiveFactor: material.emissiveFactor ?? [0, 0, 0],\n doubleSided: material.doubleSided ?? false,\n };\n if (material.name !== undefined) output.sourceMaterialName = material.name;\n return output as unknown as GpuModelStaticDemoMaterial;\n}\n\nfunction defaultStaticDemoMaterial(): GpuModelStaticDemoMaterial {\n return {\n sourceMaterialId: null,\n sourceWorkflow: \"metallic-roughness\",\n baseColorFactor: [1, 1, 1, 1],\n metallicFactor: 0,\n roughnessFactor: 1,\n emissiveFactor: [0, 0, 0],\n doubleSided: false,\n };\n}\n\n/**\n * Produces the only compiler input accepted by the bounded ChatGPT-to-PVOX\n * demonstration. This is a strict projection, not a tolerant repair step.\n */\nexport async function createGpuModelStaticDemoCompilerInput(\n document: GpuModelDocument,\n options: GpuModelStaticDemoCompilerOptions,\n): Promise<GpuModelStaticDemoCompilerInput> {\n if (!isGpuModelDocument(document)) return fail(\"invalid-type\", \"$\", \"static demo compilation requires a verified GPU model document\");\n const limits = resolveStaticDemoLimits(options);\n assertGpuModelStaticDemoNormalization(document);\n\n if (document.nodes.length > limits.maxNodes) return fail(\"limit-exceeded\", \"$.nodes\", \"static demo node limit exceeded\");\n const primitiveCount = document.meshes.reduce((total, mesh) => total + mesh.primitives.length, 0);\n if (primitiveCount > limits.maxPrimitives) return fail(\"limit-exceeded\", \"$.meshes\", \"static demo primitive limit exceeded\");\n if (document.materials.length > limits.maxMaterials) return fail(\"limit-exceeded\", \"$.materials\", \"static demo material limit exceeded\");\n if (document.textures.length > 0) return fail(\"unsupported-feature\", \"$.textures\", \"static demo does not retain texture resources\");\n for (const [key, values] of [\n [\"skeletons\", document.skeletons], [\"joints\", document.joints], [\"skins\", document.skins],\n [\"blendShapes\", document.blendShapes], [\"animations\", document.animations], [\"analyticGeometry\", document.analyticGeometry],\n ] as const) {\n if (values.length > 0) return fail(\"unsupported-feature\", `$.${key}`, \"static demo supports rigid triangle geometry only\");\n }\n let aggregateResourceBytes = 0;\n for (let index = 0; index < document.resources.length; index += 1) {\n const resource = document.resources[index]!;\n if (resource.kind !== \"buffer\") return fail(\"unsupported-feature\", `$.resources[${index}]`, \"static demo permits buffer resources only\");\n if (resource.byteLength > limits.maxResourceBytes) return fail(\"limit-exceeded\", `$.resources[${index}].byteLength`, \"static demo resource limit exceeded\");\n aggregateResourceBytes += resource.byteLength;\n if (!Number.isSafeInteger(aggregateResourceBytes) || aggregateResourceBytes > limits.maxAggregateResourceBytes) {\n return fail(\"limit-exceeded\", \"$.resources\", \"static demo aggregate resource limit exceeded\");\n }\n }\n\n const nodes = indexById(document.nodes, \"$.nodes\");\n const meshes = indexById(document.meshes, \"$.meshes\");\n const accessors = indexById(document.accessors, \"$.accessors\");\n const resources = indexById(document.resources, \"$.resources\");\n const scene = validateScene(document.roots, document.nodes, nodes);\n const readers = new Map<string, AccessorReader>();\n const readerFor = (accessor: GpuModelAccessor, path: string): AccessorReader => {\n const existing = readers.get(accessor.id);\n if (existing) return existing;\n const resource = requireReference(resources, accessor.resourceId, path, \"resource\");\n const reader = createAccessorReader(accessor, resource, path);\n readers.set(accessor.id, reader);\n return reader;\n };\n\n const materials: GpuModelStaticDemoMaterial[] = document.materials.map(staticDemoMaterial);\n const materialIndices = new Map(document.materials.map((material, index) => [material.id, index]));\n let defaultMaterialIndex: number | undefined;\n const worldTriangles: GpuModelStaticDemoWorldTriangle[] = [];\n\n for (let nodeIndex = 0; nodeIndex < document.nodes.length; nodeIndex += 1) {\n const node = document.nodes[nodeIndex]!;\n if (node.skinId !== undefined) return fail(\"unsupported-feature\", `$.nodes[${nodeIndex}].skinId`, \"static demo nodes cannot reference skins\");\n if (!node.meshId) continue;\n const mesh = requireReference(meshes, node.meshId, `$.nodes[${nodeIndex}].meshId`, \"mesh\");\n const world = requireReference(scene.worldByNode, node.id, `$.nodes[${nodeIndex}]`, \"world transform\");\n const determinant = determinant3(world);\n if (!Number.isFinite(determinant) || Math.abs(determinant) <= 1e-12) {\n return fail(\"invalid-value\", `$.nodes[${nodeIndex}].localMatrix`, \"static demo world transform must be invertible\");\n }\n for (let primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex += 1) {\n const primitive = mesh.primitives[primitiveIndex]!;\n const path = `$.meshes.${mesh.id}.primitives[${primitiveIndex}]`;\n if (primitive.topology !== \"triangles\") return fail(\"unsupported-feature\", `${path}.topology`, \"static demo requires explicit triangle topology\");\n const unsupportedAttribute = primitive.attributes.find(({ semantic }) => semantic !== \"POSITION\" && semantic !== \"NORMAL\");\n if (unsupportedAttribute) return fail(\"unsupported-feature\", `${path}.attributes`, `static demo does not consume ${unsupportedAttribute.semantic}`);\n const positionAttribute = primitive.attributes.find(({ semantic }) => semantic === \"POSITION\");\n if (!positionAttribute) return fail(\"invalid-reference\", `${path}.attributes`, \"static demo requires POSITION\");\n const positionAccessor = requireReference(accessors, positionAttribute.accessorId, `${path}.attributes.POSITION`, \"accessor\");\n const positionReader = readerFor(positionAccessor, `${path}.attributes.POSITION`);\n const normalAttribute = primitive.attributes.find(({ semantic }) => semantic === \"NORMAL\");\n const normalReader = normalAttribute\n ? readerFor(requireReference(accessors, normalAttribute.accessorId, `${path}.attributes.NORMAL`, \"accessor\"), `${path}.attributes.NORMAL`)\n : undefined;\n const indexReader = primitive.indicesAccessorId\n ? readerFor(requireReference(accessors, primitive.indicesAccessorId, `${path}.indicesAccessorId`, \"accessor\"), `${path}.indicesAccessorId`)\n : undefined;\n const elementCount = indexReader?.accessor.count ?? positionAccessor.count;\n if (elementCount % 3 !== 0) return fail(\"invalid-value\", path, \"triangle element count must be divisible by three\");\n const triangleCount = elementCount / 3;\n if (worldTriangles.length + triangleCount > limits.maxTriangles) return fail(\"limit-exceeded\", path, \"static demo triangle limit exceeded\");\n let materialIndex: number;\n if (primitive.materialId !== undefined) {\n const resolvedMaterialIndex = materialIndices.get(primitive.materialId);\n if (resolvedMaterialIndex === undefined) return fail(\"missing-reference\", `${path}.materialId`, `missing material index: ${primitive.materialId}`);\n materialIndex = resolvedMaterialIndex;\n } else {\n if (defaultMaterialIndex === undefined) {\n if (materials.length >= limits.maxMaterials) return fail(\"limit-exceeded\", \"$.materials\", \"static demo material limit exceeded\");\n defaultMaterialIndex = materials.length;\n materials.push(defaultStaticDemoMaterial());\n }\n materialIndex = defaultMaterialIndex;\n }\n for (let triangleIndex = 0; triangleIndex < triangleCount; triangleIndex += 1) {\n const sourceIndices = [0, 1, 2].map((corner) => {\n const element = triangleIndex * 3 + corner;\n return indexReader ? indexReader.read(element)[0]! : element;\n });\n if (determinant < 0) [sourceIndices[1], sourceIndices[2]] = [sourceIndices[2]!, sourceIndices[1]!];\n const positions = Object.freeze(sourceIndices.map((index) => Object.freeze(transformPosition(world, positionReader.read(index))))) as unknown as GpuModelTriangleVec3;\n assertStaticDemoTriangleCoordinates(positions, `${path}.triangles[${triangleIndex}]`);\n const fallback = faceNormal(positions, `${path}.triangles[${triangleIndex}]`);\n const normals = Object.freeze(sourceIndices.map((index) => normalReader\n ? transformNormal(world, normalReader.read(index), determinant, fallback)\n : fallback)) as unknown as GpuModelTriangleVec3;\n worldTriangles.push({\n sourceNodeId: node.id,\n sourceMeshId: mesh.id,\n sourcePrimitiveId: primitive.id,\n sourceTriangleIndex: triangleIndex,\n materialIndex,\n positions,\n normals,\n bounds: triangleBounds(positions),\n });\n }\n }\n }\n if (worldTriangles.length === 0) return fail(\"invalid-value\", \"$.meshes\", \"static demo requires at least one world triangle\");\n\n const sourceEvidence: GpuModelStaticDemoSourceEvidence = {\n sourceFormat: document.provenance.sourceFormat,\n sourceContentHash: document.provenance.sourceContentHash,\n converterId: document.provenance.converterId,\n converterVersion: document.provenance.converterVersion,\n ...(document.provenance.provider !== undefined ? { provider: document.provenance.provider } : {}),\n };\n return deepFreeze({\n profileVersion: GPU_MODEL_STATIC_DEMO_PROFILE_VERSION,\n canonicalDocumentHash: await hashGpuModelDocumentCanonical(document),\n coordinateSystem: CANONICAL_GPU_MODEL_COORDINATE_SYSTEM,\n bounds: document.bounds,\n sourceEvidence,\n materials,\n worldTriangles,\n }) as unknown as GpuModelStaticDemoCompilerInput;\n}\n","import type { GpuModelDiagnosticSeverity, GpuModelMetadataValue } from \"./model-document.js\";\n\n/** Supported policy modes; strict is always the default. */\nexport type GpuModelDiagnosticMode = \"strict\" | \"tolerant\" | \"forensic\";\n/** Adapter compliance profiles inherited from the canonical conversion policy. */\nexport type GpuModelDiagnosticStandard = \"gltf-glb\" | \"obj-mtl\" | \"fbx\" | \"cad-bim\";\n/** Stable repair definitions; format adapters apply and verify these actions. */\nexport const GPU_MODEL_REPAIR_RULES = Object.freeze(([\n {\n \"id\": \"missing-normals\",\n \"action\": \"Generate deterministic vertex normals from validated triangle geometry.\",\n \"severity\": \"warning\",\n \"confidence\": \"high\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Generate deterministic vertex normals from validated triangle geometry and record the generation basis.\"\n },\n {\n \"id\": \"bad-winding\",\n \"action\": \"Normalize winding to the adapter coordinate convention.\",\n \"severity\": \"warning\",\n \"confidence\": \"medium\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Normalize winding to the adapter coordinate convention and record the inferred orientation.\"\n },\n {\n \"id\": \"invalid-indices\",\n \"action\": \"Drop the invalid primitive.\",\n \"severity\": \"error\",\n \"confidence\": \"medium\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Reject the invalid primitive or clamp only when the fixture and adapter policy explicitly prove a safe repair; retain the original index in the record.\"\n },\n {\n \"id\": \"nan-transforms\",\n \"action\": \"Replace non-finite transform components with identity components.\",\n \"severity\": \"error\",\n \"confidence\": \"high\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Replace the non-finite component with the identity transform component and record the source value and fallback.\"\n },\n {\n \"id\": \"non-normalized-weights\",\n \"action\": \"Normalize finite non-negative skin weights.\",\n \"severity\": \"warning\",\n \"confidence\": \"high\",\n \"standardIds\": [\n \"gltf-glb\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Normalize finite, non-negative influences and record the pre-normalization weights and discarded influence policy.\"\n },\n {\n \"id\": \"missing-texture-path\",\n \"action\": \"Leave the missing or unsafe texture slot unresolved.\",\n \"severity\": \"warning\",\n \"confidence\": \"low\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Resolve only an explicitly bounded package-relative fallback; otherwise keep the material slot unresolved and emit a visible warning.\"\n },\n {\n \"id\": \"malformed-material-reference\",\n \"action\": \"Attach the canonical default material.\",\n \"severity\": \"error\",\n \"confidence\": \"medium\",\n \"standardIds\": [\n \"gltf-glb\",\n \"obj-mtl\",\n \"fbx\",\n \"cad-bim\"\n ],\n \"policy\": \"Attach the canonical default material only when the target policy permits it and preserve the unresolved source reference.\"\n }\n] as const).map(rule => Object.freeze({ ...rule, standardIds: Object.freeze(rule.standardIds) })));\n\n/** Defensive ceilings for a complete report, including its source snapshots. */\nexport const GPU_MODEL_DIAGNOSTIC_LIMITS = Object.freeze({\n issues: 4096, values: 16384, depth: 12, members: 1024, string: 65536, bytes: 1048576,\n} as const);\n\n/** An inert, bounded report was malformed; errors never echo caller values. */\nexport class GpuModelDiagnosticsError extends TypeError {\n public constructor() {\n super(\"Invalid or over-budget GPU model diagnostics report\");\n this.name = \"GpuModelDiagnosticsError\";\n }\n}\n\n/** Common, path-addressable fields; callers must remove sensitive source text. */\nexport interface GpuModelConversionIssueBase {\n readonly code: string;\n readonly path: string;\n readonly message: string;\n}\n/** Adapter-reported standard violation, with explicit completed-repair evidence. */\nexport interface GpuModelConversionViolation extends GpuModelConversionIssueBase {\n readonly kind: \"violation\";\n readonly ruleId: string;\n readonly originalValue: GpuModelMetadataValue;\n readonly repairApplied: boolean;\n}\n/** Unsupported source/target semantics are always blocking. */\nexport interface GpuModelUnsupportedData extends GpuModelConversionIssueBase {\n readonly kind: \"unsupported\";\n}\n/** An advisory that does not represent a standard violation or lost data. */\nexport interface GpuModelConversionWarning extends GpuModelConversionIssueBase {\n readonly kind: \"warning\";\n}\n/** Explicit source-fidelity loss, requiring caller consent even after repair. */\nexport interface GpuModelConversionLoss extends GpuModelConversionIssueBase {\n readonly kind: \"loss\";\n readonly effect: \"dropped\" | \"approximated\";\n}\n/** Discriminated adapter input contract; unknown rule IDs remain blocking. */\nexport type GpuModelConversionIssue = GpuModelConversionViolation | GpuModelUnsupportedData | GpuModelConversionWarning | GpuModelConversionLoss;\n/** Typed construction contract; the evaluator also validates unknown input. */\nexport interface GpuModelDiagnosticInput {\n readonly standard: GpuModelDiagnosticStandard;\n readonly mode?: GpuModelDiagnosticMode;\n readonly allowLoss?: boolean;\n readonly issues: readonly GpuModelConversionIssue[];\n readonly rawSource?: GpuModelMetadataValue;\n readonly maxEvidenceBytes?: number;\n}\n/** One verified report of an adapter-applied repair; never a repair request. */\nexport interface GpuModelRepairRecord {\n readonly ruleId: typeof GPU_MODEL_REPAIR_RULES[number][\"id\"];\n readonly originalValue: GpuModelMetadataValue;\n readonly action: string;\n readonly severity: GpuModelDiagnosticSeverity;\n readonly affectedPath: string;\n readonly confidence: \"high\" | \"medium\" | \"low\";\n}\n/** Separate categories prevent warnings from disguising violations or loss. */\nexport type GpuModelConversionDiagnostic =\n | (GpuModelConversionIssueBase & { readonly kind: \"blocking-error\"; readonly severity: \"error\"; readonly ruleId: string })\n | (GpuModelConversionIssueBase & { readonly kind: \"repair\"; readonly severity: GpuModelDiagnosticSeverity; readonly ruleId: string })\n | (GpuModelUnsupportedData & { readonly severity: \"error\" })\n | (GpuModelConversionWarning & { readonly severity: \"warning\" })\n | (GpuModelConversionLoss & { readonly severity: \"warning\" });\n/** Immutable owned ledger. Acceptance validates reports, not repaired geometry. */\nexport interface GpuModelDiagnosticReport {\n readonly mode: GpuModelDiagnosticMode;\n readonly standard: GpuModelDiagnosticStandard;\n readonly accepted: boolean;\n readonly diagnostics: readonly GpuModelConversionDiagnostic[];\n readonly repairs: readonly GpuModelRepairRecord[];\n readonly losses: readonly (GpuModelConversionLoss & { readonly severity: \"warning\" })[];\n readonly rawSource?: GpuModelMetadataValue;\n}\n\nfunction fail(): never { throw new GpuModelDiagnosticsError(); }\ninterface Budget { values: number; bytes: number }\nfunction charge(budget: Budget, bytes: number): void {\n budget.bytes += bytes;\n if (budget.bytes > GPU_MODEL_DIAGNOSTIC_LIMITS.bytes) fail();\n}\nfunction textBytes(value: string): number {\n return new TextEncoder().encode(JSON.stringify(value)).byteLength;\n}\n\n// Read only own data properties. Serialized JSON is the boundary for hostile Proxies.\nfunction snapshot(value: unknown, depth: number, budget: Budget, ancestors: Set<object>, memberLimit: number = GPU_MODEL_DIAGNOSTIC_LIMITS.members): GpuModelMetadataValue {\n if (++budget.values > GPU_MODEL_DIAGNOSTIC_LIMITS.values || depth > GPU_MODEL_DIAGNOSTIC_LIMITS.depth) fail();\n if (value === null || typeof value === \"boolean\") { charge(budget, value === null ? 4 : value ? 4 : 5); return value; }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) fail();\n charge(budget, JSON.stringify(value).length);\n return Object.is(value, -0) ? 0 : value;\n }\n if (typeof value === \"string\") {\n if (value.length > GPU_MODEL_DIAGNOSTIC_LIMITS.string) fail();\n charge(budget, textBytes(value));\n return value;\n }\n if (typeof value !== \"object\" || ancestors.has(value)) fail();\n const array = Array.isArray(value);\n const prototype = Object.getPrototypeOf(value);\n if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail();\n const keys = Reflect.ownKeys(value);\n // Only the top-level issues list gets the higher issue ceiling.\n const maxMembers = memberLimit;\n if (keys.length > maxMembers + (array ? 1 : 0)) fail();\n ancestors.add(value);\n charge(budget, 2);\n if (array) {\n const length = Object.getOwnPropertyDescriptor(value, \"length\")!.value as number;\n if (length > maxMembers || keys.length !== length + 1) fail();\n const result: GpuModelMetadataValue[] = [];\n for (let i = 0; i < length; i++) {\n const descriptor = Object.getOwnPropertyDescriptor(value, String(i));\n if (!descriptor || !(\"value\" in descriptor) || !descriptor.enumerable) fail();\n if (i > 0) charge(budget, 1);\n result.push(snapshot(descriptor.value, depth + 1, budget, ancestors));\n }\n ancestors.delete(value);\n return Object.freeze(result);\n }\n const result: Record<string, GpuModelMetadataValue> = {};\n let count = 0;\n for (const key of keys) {\n if (typeof key !== \"string\" || key.length > 256 || [\"__proto__\", \"constructor\", \"prototype\"].includes(key)) fail();\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n if (!(\"value\" in descriptor) || !descriptor.enumerable) fail();\n if (count++ > 0) charge(budget, 1);\n charge(budget, textBytes(key) + 1);\n result[key] = snapshot(descriptor.value, depth + 1, budget, ancestors, depth === 0 && key === \"issues\" ? GPU_MODEL_DIAGNOSTIC_LIMITS.issues : GPU_MODEL_DIAGNOSTIC_LIMITS.members);\n }\n ancestors.delete(value);\n return Object.freeze(result);\n}\nfunction record(value: GpuModelMetadataValue | undefined): Record<string, GpuModelMetadataValue> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return fail();\n return value as Record<string, GpuModelMetadataValue>;\n}\nfunction keysOnly(value: Record<string, GpuModelMetadataValue>, allowed: readonly string[]): void {\n if (Object.keys(value).some(key => !allowed.includes(key))) fail();\n}\nfunction enumValue<T extends string>(value: GpuModelMetadataValue | undefined, allowed: readonly T[]): T {\n if (typeof value !== \"string\" || !(allowed as readonly string[]).includes(value)) return fail();\n return value as T;\n}\nfunction hasUnsafeText(value: string): boolean {\n for (const character of value) {\n const point = character.codePointAt(0)!;\n if (point < 0x20 || (point >= 0x7f && point <= 0x9f) || (point >= 0x2028 && point <= 0x202e) || (point >= 0x2066 && point <= 0x2069) || (point >= 0xd800 && point <= 0xdfff)) return true;\n }\n return false;\n}\nfunction text(value: GpuModelMetadataValue | undefined, max: number): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > max || hasUnsafeText(value)) return fail();\n return value;\n}\nfunction boolean(value: GpuModelMetadataValue | undefined): boolean {\n if (typeof value !== \"boolean\") return fail();\n return value;\n}\nfunction parseIssue(value: GpuModelMetadataValue): GpuModelConversionIssue {\n const issue = record(value);\n const kind = enumValue(issue.kind, [\"violation\", \"unsupported\", \"warning\", \"loss\"] as const);\n const base = { code: text(issue.code, 128), path: text(issue.path, 1024), message: text(issue.message, 2048) };\n if (!base.path.startsWith(\"/\")) fail();\n const common = [\"kind\", \"code\", \"path\", \"message\"];\n if (kind === \"violation\") {\n keysOnly(issue, [...common, \"ruleId\", \"originalValue\", \"repairApplied\"]);\n if (!Object.hasOwn(issue, \"originalValue\")) fail();\n return { ...base, kind, ruleId: text(issue.ruleId, 128), originalValue: issue.originalValue!, repairApplied: boolean(issue.repairApplied) };\n }\n if (kind === \"loss\") {\n keysOnly(issue, [...common, \"effect\"]);\n return { ...base, kind, effect: enumValue(issue.effect, [\"dropped\", \"approximated\"] as const) };\n }\n keysOnly(issue, common);\n return { ...base, kind };\n}\n\n/**\n * Validate a bounded inert adapter report and build an immutable conversion ledger.\n * Strict rejects violations. Tolerant/forensic require explicit applied repairs.\n * Callers must scrub source snapshots before supplying them and must not log them.\n * Throws GpuModelDiagnosticsError for malformed or over-budget reports.\n */\nexport function evaluateGpuModelDiagnostics(value: unknown): GpuModelDiagnosticReport {\n const budget: Budget = { values: 0, bytes: 0 };\n const args = record(snapshot(value, 0, budget, new Set()));\n keysOnly(args, [\"standard\", \"mode\", \"allowLoss\", \"issues\", \"rawSource\", \"maxEvidenceBytes\"]);\n const standard = enumValue(args.standard, [\"gltf-glb\", \"obj-mtl\", \"fbx\", \"cad-bim\"] as const);\n const mode = args.mode === undefined ? \"strict\" : enumValue(args.mode, [\"strict\", \"tolerant\", \"forensic\"] as const);\n const allowLoss = args.allowLoss === undefined ? false : boolean(args.allowLoss);\n if (args.maxEvidenceBytes !== undefined && (typeof args.maxEvidenceBytes !== \"number\" || !Number.isSafeInteger(args.maxEvidenceBytes) || args.maxEvidenceBytes < 1 || args.maxEvidenceBytes > GPU_MODEL_DIAGNOSTIC_LIMITS.bytes || budget.bytes > args.maxEvidenceBytes)) fail();\n if (mode === \"forensic\" ? !Object.hasOwn(args, \"rawSource\") : Object.hasOwn(args, \"rawSource\")) fail();\n if (!Array.isArray(args.issues) || args.issues.length > GPU_MODEL_DIAGNOSTIC_LIMITS.issues) fail();\n const issues = args.issues.map(parseIssue);\n const lossPaths = new Set(issues.filter(issue => issue.kind === \"loss\").map(issue => issue.path));\n const diagnostics: GpuModelConversionDiagnostic[] = [];\n const repairs: GpuModelRepairRecord[] = [];\n const losses: (GpuModelConversionLoss & { readonly severity: \"warning\" })[] = [];\n let accepted = true;\n for (const issue of issues) {\n const base = { code: issue.code, path: issue.path, message: issue.message };\n if (issue.kind === \"violation\") {\n const rule = GPU_MODEL_REPAIR_RULES.find(rule => rule.id === issue.ruleId);\n const requiresLoss = [\"invalid-indices\", \"missing-texture-path\", \"malformed-material-reference\"].includes(issue.ruleId);\n const repaired = mode !== \"strict\" && issue.repairApplied && rule && (rule.standardIds as readonly string[]).includes(standard) && (!requiresLoss || lossPaths.has(issue.path));\n if (repaired) {\n repairs.push(Object.freeze({ ruleId: rule.id, originalValue: issue.originalValue, action: rule.action, severity: rule.severity, affectedPath: issue.path, confidence: rule.confidence }));\n diagnostics.push(Object.freeze({ ...base, kind: \"repair\", severity: rule.severity, ruleId: rule.id }));\n } else {\n accepted = false;\n diagnostics.push(Object.freeze({ ...base, kind: \"blocking-error\", severity: \"error\", ruleId: issue.ruleId }));\n }\n } else if (issue.kind === \"unsupported\") {\n accepted = false;\n diagnostics.push(Object.freeze({ ...issue, severity: \"error\" }));\n } else if (issue.kind === \"loss\") {\n if (!allowLoss) accepted = false;\n const loss = Object.freeze({ ...issue, severity: \"warning\" as const });\n losses.push(loss);\n diagnostics.push(loss);\n } else diagnostics.push(Object.freeze({ ...issue, severity: \"warning\" }));\n }\n return Object.freeze({ mode, standard, accepted, diagnostics: Object.freeze(diagnostics), repairs: Object.freeze(repairs), losses: Object.freeze(losses), ...(mode === \"forensic\" ? { rawSource: args.rawSource! } : {}) });\n}\n","/** Package identity and rollout metadata for the initial repository baseline. */\nexport const packageName = \"@plasius/gpu-model-core\" as const;\n\nexport const packageBootstrap = Object.freeze({\n packageName,\n featureFlag: \"gpu.model.conversion.enabled\",\n status: \"bootstrap\",\n} as const);\n\nexport * from \"./model-document.js\";\n\nexport * from \"./diagnostics.js\";\n"],"mappings":";AACO,IAAM,oCAAoC;AAG1C,IAAM,wCAAwC,OAAO,OAAO;AAAA,EACjE,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,QAAQ;AACV,CAAU;AAGH,IAAM,4BAA4B,OAAO,OAAO;AAAA,EACrD,OAAO;AAAA,EACP,OAAO;AAAA,EACP,WAAW;AAAA,EACX,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,8BAA8B;AAAA,EAC9B,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,gBAAgB;A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