@plasius/gpu-shader 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -16
- package/dist/cli.cjs +235 -43
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +235 -43
- package/dist/cli.js.map +1 -1
- package/dist/{contracts-C4eel8MT.d.cts → contracts-B49AUejk.d.cts} +1 -1
- package/dist/{contracts-C4eel8MT.d.ts → contracts-B49AUejk.d.ts} +1 -1
- package/dist/index.cjs +238 -115
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +237 -115
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +116 -24
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +116 -24
- package/dist/node.js.map +1 -1
- package/dist/testing.cjs +117 -29
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +117 -29
- package/dist/testing.js.map +1 -1
- package/matrices/stable-webgpu-2026-07-13.json +1 -545
- package/package.json +1 -1
package/dist/testing.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts","../src/contracts.ts","../src/canonical-json.ts","../src/hash.ts","../src/manifest-validation.ts","../src/testing/inventory.ts","../src/testing/matrix.ts","../src/testing/qualification-bundle.ts","../src/testing/evidence.ts"],"sourcesContent":["export { defineShaderCompileUnit, validateCompileUnitInventory } from \"./testing/inventory.js\";\nexport { validateStableWebGpuMatrix } from \"./testing/matrix.js\";\nexport { validateQualificationBundleManifest, validateQualificationFixture } from \"./testing/qualification-bundle.js\";\nexport {\n aggregateShaderValidationEvidence,\n computeQualificationInventorySha256,\n computeQualificationSubjectBinding,\n createQualificationPreflight,\n parseShaderValidationEvidenceAttestationRef,\n parseTrustedWorkflowProvenance,\n validateShaderValidationEvidence,\n verifyShaderValidationEvidenceAttestation,\n} from \"./testing/evidence.js\";\nexport type { AggregateShaderValidationEvidenceInput, EvidenceArtifact } from \"./testing/evidence.js\";\n","/** Contract version shared by the first reflection-first manifest family. */\nexport const GPU_INTERFACE_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_VERSION_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_STYLE_PROFILE_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_COMPILE_UNIT_VERSION = \"1.0.0\" as const;\nexport const SHADER_VALIDATION_EVIDENCE_VERSION = \"1.0.0\" as const;\nexport const STABLE_WEBGPU_MATRIX_VERSION = \"1.0.0\" as const;\nexport const SHADER_QUALIFICATION_FIXTURE_VERSION = \"1.0.0\" as const;\nexport const SHADER_QUALIFICATION_BUNDLE_VERSION = \"1.0.0\" as const;\n/** Remotely controlled rollout gate owned by the asset service. */\nexport const GPU_SHADER_STORE_FEATURE_FLAG = \"asset.pipeline.shader-store.enabled\" as const;\n/** User-visible style discovery/selection entitlement owned by the capability service. */\nexport const GPU_SHADER_STYLE_SELECTION_CAPABILITY = \"gpu.shader.style.select\" as const;\n\n/** Lowercase hexadecimal SHA-256 value. Runtime parsers enforce its shape. */\nexport type Sha256Hex = string & { readonly __sha256Hex: unique symbol };\n\n/** Stable universal policies accepted by this contract implementation. */\nexport const SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [\n Object.freeze({\n matrixId: \"stable-webgpu\",\n matrixVersion: \"2026-07-13\",\n matrixSha256: \"9b47ff8162b055d49e38c4fe90b9074992ab8c9e1125926e936f8122e6119fd8\",\n }),\n] as const satisfies readonly {\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: string;\n}[];\nObject.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);\n\n/**\n * Exact additive policies accepted by this release. Empty means supplemental\n * qualification fails closed until reviewed policy bytes and lanes are added.\n */\nexport const SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES: readonly Readonly<{\n scope: string;\n matrixId: string;\n matrixVersion: string;\n matrixSha256: string;\n}>[] = Object.freeze([]);\n\nexport interface GitObjectId {\n readonly algorithm: \"sha1\" | \"sha256\";\n readonly hex: string;\n}\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue =\n | JsonPrimitive\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type ShaderDiagnosticSeverity = \"error\" | \"warning\" | \"info\";\nexport type ShaderDiagnosticCode =\n | \"invalid-contract\"\n | \"digest-mismatch\"\n | \"model-abi-mismatch\"\n | \"interface-abi-mismatch\"\n | \"shader-abi-mismatch\"\n | \"incompatible-model-interface\"\n | \"missing-semantic\"\n | \"missing-feature\"\n | \"limit-not-met\"\n | \"unsupported-format\"\n | \"unpromoted-asset\"\n | \"compilation-error\"\n | \"pipeline-error\"\n | \"device-lost\"\n | \"activation-error\"\n | \"stale-evidence\"\n | \"incomplete-matrix\"\n | \"uncovered-fragment\"\n | \"timeout\"\n | \"runner-unavailable\"\n | \"adapter-unavailable\";\n\nexport interface ShaderDiagnostic {\n readonly code: ShaderDiagnosticCode;\n readonly severity: ShaderDiagnosticSeverity;\n readonly message: string;\n readonly path?: string;\n readonly expected?: JsonValue;\n readonly actual?: JsonValue;\n}\n\nexport type ShaderResult<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly diagnostics: readonly ShaderDiagnostic[] };\n\nexport type GpuScalarKind = \"i32\" | \"u32\" | \"f32\" | \"f16\" | \"bool\";\nexport type GpuHostAddressSpace = \"uniform\" | \"storage\";\nexport type GpuAddressSpace =\n | GpuHostAddressSpace\n | \"function\"\n | \"private\"\n | \"workgroup\";\n\nexport interface GpuScalarLayout {\n readonly kind: \"scalar\";\n readonly scalar: GpuScalarKind;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuAtomicLayout {\n readonly kind: \"atomic\";\n readonly scalar: \"i32\" | \"u32\";\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuVectorLayout {\n readonly kind: \"vector\";\n readonly scalar: GpuScalarKind;\n readonly width: 2 | 3 | 4;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuMatrixLayout {\n readonly kind: \"matrix\";\n readonly scalar: \"f32\" | \"f16\";\n readonly columns: 2 | 3 | 4;\n readonly rows: 2 | 3 | 4;\n readonly columnStride: number;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuArrayLayout {\n readonly kind: \"array\";\n readonly element: GpuTypeLayout;\n /** Null represents a WGSL runtime-sized array. */\n readonly count: number | null;\n readonly stride: number;\n readonly alignment: number;\n readonly byteSize: number | null;\n}\n\nexport interface GpuRecordReferenceLayout {\n readonly kind: \"record\";\n readonly recordName: string;\n readonly alignment: number;\n readonly byteSize: number | null;\n}\n\nexport type GpuTypeLayout =\n | GpuScalarLayout\n | GpuAtomicLayout\n | GpuVectorLayout\n | GpuMatrixLayout\n | GpuArrayLayout\n | GpuRecordReferenceLayout;\n\nexport interface GpuRecordMemberLayout {\n readonly name: string;\n readonly offset: number;\n /** Effective alignment after applying an optional WGSL `@align`. */\n readonly alignment: number;\n /** Logical size of the value, excluding a member-level `@size`. */\n readonly valueByteSize: number | null;\n /** Occupied member span, including a member-level `@size`. */\n readonly occupiedByteSize: number | null;\n readonly explicitAlign: number | null;\n readonly explicitSize: number | null;\n readonly type: GpuTypeLayout;\n}\n\nexport interface GpuRecordLayout {\n readonly name: string;\n readonly alignment: number;\n /** Null for records ending in a runtime-sized array. */\n readonly byteSize: number | null;\n /** Fixed prefix before any runtime-sized array. */\n readonly minimumByteSize: number;\n readonly runtimeArrayMember: string | null;\n readonly addressSpaces: readonly GpuAddressSpace[];\n /** WGSL declaration order; constructor and codec order depend on it. */\n readonly members: readonly GpuRecordMemberLayout[];\n}\n\nexport type GpuShaderStage = \"vertex\" | \"fragment\" | \"compute\";\nexport type GpuBindingAccess = \"read\" | \"write\" | \"read_write\";\n\nexport type GpuBindingResourceLayout =\n | {\n readonly kind: \"buffer\";\n readonly addressSpace: GpuHostAddressSpace;\n readonly access: GpuBindingAccess;\n readonly recordName: string | null;\n readonly minimumBindingSize: number;\n }\n | {\n readonly kind: \"sampler\";\n readonly samplerType: \"filtering\" | \"non-filtering\" | \"comparison\";\n }\n | {\n readonly kind: \"texture\";\n readonly sampleType: \"float\" | \"unfilterable-float\" | \"depth\" | \"sint\" | \"uint\";\n readonly viewDimension: \"1d\" | \"2d\" | \"2d-array\" | \"cube\" | \"cube-array\" | \"3d\";\n readonly multisampled: boolean;\n }\n | {\n readonly kind: \"storage-texture\";\n readonly access: \"write-only\" | \"read-only\" | \"read-write\";\n readonly format: string;\n readonly viewDimension: \"1d\" | \"2d\" | \"2d-array\" | \"3d\";\n }\n | { readonly kind: \"external-texture\" };\n\nexport interface GpuBindingLayout {\n readonly moduleId: string;\n readonly variableName: string;\n readonly group: number;\n readonly binding: number;\n readonly resource: GpuBindingResourceLayout;\n readonly visibility: readonly GpuShaderStage[];\n}\n\nexport interface GpuEntryPointIo {\n readonly name: string;\n readonly locationKind: \"location\" | \"builtin\";\n readonly location: number | string;\n readonly interpolation: string | null;\n readonly type: GpuTypeLayout;\n}\n\nexport type GpuWorkgroupDimension =\n | { readonly kind: \"literal\"; readonly value: number }\n | { readonly kind: \"override\"; readonly name: string };\n\nexport interface GpuEntryPointInterface {\n readonly moduleId: string;\n readonly name: string;\n readonly stage: GpuShaderStage;\n readonly inputs: readonly GpuEntryPointIo[];\n readonly outputs: readonly GpuEntryPointIo[];\n readonly bindingKeys: readonly string[];\n readonly overrideNames: readonly string[];\n readonly workgroupSize: readonly [\n GpuWorkgroupDimension,\n GpuWorkgroupDimension,\n GpuWorkgroupDimension,\n ] | null;\n /**\n * WebGPU workgroup-storage bytes statically used by a compute entry point.\n * This is null for non-compute entry points.\n */\n readonly workgroupStorageSize: number | null;\n}\n\nexport interface GpuVertexInputLayout {\n readonly pipelineId: string;\n readonly moduleId: string;\n readonly entryPoint: string;\n readonly shaderLocation: number;\n readonly shaderType: GpuTypeLayout;\n readonly bufferSlot: number;\n readonly format: string;\n readonly offset: number;\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly semantic: string | null;\n}\n\n/** Shader-independent vertex bytes consumed from a model buffer. */\nexport interface GpuModelVertexInputLayout {\n readonly source: {\n readonly pipelineId: string;\n readonly shaderLocation: number;\n };\n readonly format: string;\n readonly offset: number;\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly semantic: string;\n}\n\n/** A reflected model-facing resource projection; shader coordinates and visibility are excluded. */\nexport interface GpuModelBindingLayout {\n readonly source: {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n };\n readonly resource: GpuBindingResourceLayout;\n readonly semantic: string | null;\n}\n\nexport interface GpuOverrideLayout {\n readonly moduleId: string;\n readonly name: string;\n readonly id: number | null;\n readonly type: \"bool\" | \"i32\" | \"u32\" | \"f32\" | \"f16\";\n readonly defaultValue: boolean | number | null;\n}\n\nexport type GpuSemanticSource =\n | {\n readonly kind: \"record-member\";\n readonly recordName: string;\n readonly memberPath: readonly string[];\n }\n | {\n readonly kind: \"vertex-attribute\";\n readonly pipelineId: string;\n readonly shaderLocation: number;\n }\n | {\n readonly kind: \"binding\";\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n };\n\nexport interface GpuSemanticProjection {\n readonly semantic: string;\n readonly source: GpuSemanticSource;\n}\n\nexport interface GpuModelAbiProjection {\n readonly recordNames: readonly string[];\n readonly bindings: readonly GpuModelBindingLayout[];\n readonly vertexInputs: readonly GpuModelVertexInputLayout[];\n readonly semantics: readonly GpuSemanticProjection[];\n}\n\nexport interface GpuInterfaceManifest {\n readonly contractVersion: typeof GPU_INTERFACE_MANIFEST_VERSION;\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly modules: readonly {\n readonly moduleId: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly records: readonly GpuRecordLayout[];\n readonly bindings: readonly GpuBindingLayout[];\n readonly entryPoints: readonly GpuEntryPointInterface[];\n readonly vertexInputs: readonly GpuVertexInputLayout[];\n readonly overrides: readonly GpuOverrideLayout[];\n readonly modelAbi: GpuModelAbiProjection;\n readonly modelAbiHash: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly generatedBy: {\n readonly packageVersion: string;\n readonly reflector: \"wgsl_reflect\";\n readonly reflectorVersion: \"1.5.0\";\n };\n}\n\nexport interface GpuInterfaceRef {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n}\n\nexport interface ShaderVersionRef {\n readonly shaderId: string;\n readonly version: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n}\n\nexport interface ShaderStyleProfileRef {\n readonly profileId: string;\n readonly version: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n}\n\nexport interface SerializableGpuProgrammableStage {\n readonly moduleId: string;\n readonly entryPoint: string;\n readonly constants: Readonly<Record<string, boolean | number>>;\n}\n\nexport interface SerializableGpuBindGroupLayout {\n readonly group: number;\n readonly entries: readonly Omit<GpuBindingLayout, \"moduleId\" | \"variableName\">[];\n}\n\nexport interface SerializableGpuPipelineLayout {\n readonly bindGroups: readonly SerializableGpuBindGroupLayout[];\n}\n\nexport interface SerializableGpuComputePipelineDescriptor {\n readonly kind: \"compute\";\n readonly pipelineId: string;\n readonly layout: SerializableGpuPipelineLayout;\n readonly compute: SerializableGpuProgrammableStage;\n}\n\nexport interface SerializableGpuRenderPipelineDescriptor {\n readonly kind: \"render\";\n readonly pipelineId: string;\n readonly layout: SerializableGpuPipelineLayout;\n readonly vertex: SerializableGpuProgrammableStage;\n readonly fragment: SerializableGpuProgrammableStage | null;\n readonly vertexBuffers: readonly {\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly attributes: readonly {\n readonly format: string;\n readonly offset: number;\n readonly shaderLocation: number;\n readonly semantic: string | null;\n }[];\n }[];\n readonly primitive: {\n readonly topology: \"point-list\" | \"line-list\" | \"line-strip\" | \"triangle-list\" | \"triangle-strip\";\n readonly stripIndexFormat: \"uint16\" | \"uint32\" | null;\n readonly frontFace: \"ccw\" | \"cw\";\n readonly cullMode: \"none\" | \"front\" | \"back\";\n readonly unclippedDepth: boolean;\n };\n readonly colorTargets: readonly {\n readonly format: string;\n readonly blend: {\n readonly color: SerializableGpuBlendComponent;\n readonly alpha: SerializableGpuBlendComponent;\n } | null;\n readonly writeMask: number;\n }[];\n readonly depthStencil: {\n readonly format: string;\n readonly depthWriteEnabled: boolean;\n readonly depthCompare: GpuCompareFunction;\n readonly stencilFront: SerializableGpuStencilFaceState;\n readonly stencilBack: SerializableGpuStencilFaceState;\n readonly stencilReadMask: number;\n readonly stencilWriteMask: number;\n readonly depthBias: number;\n readonly depthBiasSlopeScale: number;\n readonly depthBiasClamp: number;\n } | null;\n readonly multisample: {\n readonly count: 1 | 4;\n readonly mask: number;\n readonly alphaToCoverageEnabled: boolean;\n };\n}\n\nexport type GpuCompareFunction = \"never\" | \"less\" | \"equal\" | \"less-equal\" | \"greater\" | \"not-equal\" | \"greater-equal\" | \"always\";\n\nexport interface SerializableGpuBlendComponent {\n readonly operation: \"add\" | \"subtract\" | \"reverse-subtract\" | \"min\" | \"max\";\n readonly srcFactor: \"zero\" | \"one\" | \"src\" | \"one-minus-src\" | \"src-alpha\" | \"one-minus-src-alpha\" | \"dst\" | \"one-minus-dst\" | \"dst-alpha\" | \"one-minus-dst-alpha\" | \"src-alpha-saturated\" | \"constant\" | \"one-minus-constant\";\n readonly dstFactor: \"zero\" | \"one\" | \"src\" | \"one-minus-src\" | \"src-alpha\" | \"one-minus-src-alpha\" | \"dst\" | \"one-minus-dst\" | \"dst-alpha\" | \"one-minus-dst-alpha\" | \"src-alpha-saturated\" | \"constant\" | \"one-minus-constant\";\n}\n\nexport interface SerializableGpuStencilFaceState {\n readonly compare: GpuCompareFunction;\n readonly failOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n readonly depthFailOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n readonly passOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n}\n\nexport type SerializableGpuPipelineDescriptor =\n | SerializableGpuComputePipelineDescriptor\n | SerializableGpuRenderPipelineDescriptor;\n\nexport interface GpuLimitRequirement {\n readonly name: string;\n readonly comparator: \"at-least\" | \"at-most\";\n readonly value: number;\n}\n\nexport interface ShaderRequirements {\n readonly semantics: readonly string[];\n readonly features: readonly string[];\n readonly limits: readonly GpuLimitRequirement[];\n readonly formats: readonly string[];\n}\n\nexport type ShaderRenderRole =\n | \"material\"\n | \"lighting\"\n | \"outline\"\n | \"shadow\"\n | \"post-processing\";\n\nexport interface ShaderValidationEvidenceRef {\n readonly evidenceId: string;\n readonly uri: string;\n readonly sha256: Sha256Hex;\n readonly matrixId: string;\n readonly matrixVersion: string;\n /** Digest of the exact versioned matrix-policy bytes used to produce the evidence. */\n readonly matrixSha256: Sha256Hex;\n /** Exact external GitHub build-provenance reference artifact for the evidence bytes. */\n readonly attestationRef: {\n readonly uri: string;\n readonly sha256: Sha256Hex;\n };\n}\n\n/** Additional qualification required beyond the stable universal matrix. */\nexport interface ScopedShaderValidationEvidenceRef {\n /** Stable, profile-selectable scope such as `xr`; `universal` is reserved. */\n readonly scope: string;\n readonly evidence: ShaderValidationEvidenceRef;\n}\n\n/** Exact supplemental matrix policy a style profile requires for every role. */\nexport interface ShaderValidationScopeRequirement {\n /** Stable policy scope such as `xr`; `universal` is reserved. */\n readonly scope: string;\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: Sha256Hex;\n}\n\nexport interface ShaderVersionManifest {\n readonly contractVersion: typeof SHADER_VERSION_MANIFEST_VERSION;\n readonly shaderId: string;\n readonly version: string;\n readonly modules: readonly {\n readonly moduleId: string;\n readonly uri: string;\n readonly byteLength: number;\n readonly sha256: Sha256Hex;\n readonly contentType: \"text/wgsl; charset=utf-8\";\n }[];\n readonly gpuInterface: GpuInterfaceRef;\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly renderRoles: readonly {\n readonly role: ShaderRenderRole;\n readonly pipelineIds: readonly string[];\n }[];\n readonly compatibleModelInterfaces: readonly {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n }[];\n readonly requirements: ShaderRequirements;\n readonly shaderAbiHash: Sha256Hex;\n /** Passing evidence for the universal stable-WebGPU matrix. */\n readonly validationEvidence: ShaderValidationEvidenceRef;\n /** Passing evidence for additive matrices, for example XR device lanes. */\n readonly additionalValidationEvidence: readonly ScopedShaderValidationEvidenceRef[];\n}\n\n/** Immutable shader manifest fields qualified before external evidence is attached. */\nexport type ShaderVersionManifestCore = Omit<ShaderVersionManifest, \"validationEvidence\" | \"additionalValidationEvidence\">;\n\nexport interface ShaderStyleRoleBinding {\n readonly role: ShaderRenderRole;\n readonly shader: ShaderVersionRef;\n}\n\nexport interface ShaderStyleProfileManifest {\n readonly contractVersion: typeof SHADER_STYLE_PROFILE_MANIFEST_VERSION;\n readonly profileId: string;\n readonly version: string;\n readonly style: string;\n readonly roles: readonly ShaderStyleRoleBinding[];\n readonly compatibleModelInterfaces: readonly {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n }[];\n readonly requiredSemantics: readonly string[];\n /** Exact supplemental matrix policies every referenced shader must provide. */\n readonly requiredValidationScopes: readonly ShaderValidationScopeRequirement[];\n}\n\nexport interface ModelGpuCompatibilityDescriptor {\n readonly modelId: string;\n readonly version: string;\n readonly gpuInterface: GpuInterfaceRef;\n readonly modelAbiHash: Sha256Hex;\n readonly providedSemantics: readonly string[];\n readonly defaultStyleProfile: ShaderStyleProfileRef | null;\n}\n\nexport interface GpuCapabilitySnapshot {\n readonly features: readonly string[];\n readonly limits: Readonly<Record<string, number>>;\n readonly formats: readonly string[];\n}\n\nexport interface ModelShaderCompatibility {\n readonly modelAbiHash: Sha256Hex;\n readonly shaderAbiHash: Sha256Hex;\n readonly matchedInterfaceId: string;\n}\n\nexport type GpuScalarValue = number;\nexport type GpuVectorValue = readonly number[];\nexport type GpuMatrixValue = readonly (readonly number[])[];\nexport type GpuRecordValue = Readonly<Record<string, unknown>>;\n\nexport interface GpuRecordCodec<T = GpuRecordValue> {\n readonly record: GpuRecordLayout;\n readonly minimumByteLength: number;\n byteLength(value: T): number;\n encode(value: T): ArrayBuffer;\n encodeInto(\n value: T,\n destination: ArrayBuffer | ArrayBufferView,\n byteOffset?: number,\n ): number;\n decode(\n source: ArrayBuffer | ArrayBufferView,\n options?: { readonly byteOffset?: number; readonly byteLength?: number },\n ): T;\n}\n\nexport interface PromotedShaderCatalogResolver {\n /** Must prove the URI belongs to the configured promoted catalog root and exact immutable identity. */\n isCatalogAssetUri(uri: string): boolean;\n loadProfile(\n ref: ShaderStyleProfileRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadShader(\n ref: ShaderVersionRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadInterface(\n ref: GpuInterfaceRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadModule(\n shader: ShaderVersionRef,\n moduleId: string,\n uri: string,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n}\n\nexport interface LoadedShaderVersion {\n readonly ref: ShaderVersionRef;\n readonly manifest: ShaderVersionManifest;\n readonly gpuInterface: GpuInterfaceManifest;\n readonly modules: ReadonlyMap<string, Uint8Array>;\n}\n\nexport interface LoadedShaderStyleProfile {\n readonly ref: ShaderStyleProfileRef;\n readonly manifest: ShaderStyleProfileManifest;\n readonly shaders: ReadonlyMap<ShaderRenderRole, LoadedShaderVersion>;\n}\n\nexport interface GpuCompilationMessageLike {\n readonly type: \"error\" | \"warning\" | \"info\";\n readonly message: string;\n readonly lineNum?: number;\n readonly linePos?: number;\n}\n\nexport interface GpuShaderModuleLike {\n getCompilationInfo(): Promise<{ readonly messages: readonly GpuCompilationMessageLike[] }>;\n}\n\nexport interface GpuDeviceLike {\n readonly features: Iterable<string>;\n readonly limits: Readonly<Record<string, number>>;\n readonly lost?: Promise<{ readonly reason?: string; readonly message?: string }>;\n createShaderModule(descriptor: { readonly label?: string; readonly code: string }): GpuShaderModuleLike;\n createBindGroupLayout(descriptor: unknown): unknown;\n createPipelineLayout(descriptor: { readonly bindGroupLayouts: readonly unknown[] }): unknown;\n createComputePipelineAsync?(descriptor: unknown): Promise<unknown>;\n createRenderPipelineAsync?(descriptor: unknown): Promise<unknown>;\n createComputePipeline?(descriptor: unknown): unknown;\n createRenderPipeline?(descriptor: unknown): unknown;\n pushErrorScope?(filter: \"validation\"): void;\n popErrorScope?(): Promise<{ readonly message?: string } | null>;\n}\n\nexport interface PreparedShaderStyleProfile {\n readonly loaded: LoadedShaderStyleProfile;\n readonly pipelines: ReadonlyMap<string, unknown>;\n readonly preparedAt: number;\n dispose(): void;\n}\n\nexport interface ActiveShaderStyleProfile {\n readonly prepared: PreparedShaderStyleProfile;\n readonly activatedAt: number;\n}\n\nexport interface FrameBoundaryScheduler {\n schedule(operation: () => void): Promise<void>;\n}\n\nexport interface ShaderStyleController {\n readonly current: ActiveShaderStyleProfile | null;\n}\n\nexport interface AssembledWgslModule {\n readonly moduleId: string;\n readonly source: string;\n}\n\nexport type GpuSemanticSelector = GpuSemanticProjection;\n\n/** Selects a reflected binding. Callers cannot supply its resource layout. */\nexport interface GpuModelBindingSelector {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n readonly semantic?: string | null;\n}\n\nexport interface ReflectGpuInterfaceInput {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly modules: readonly AssembledWgslModule[];\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly modelFacingRecordNames: readonly string[];\n readonly modelFacingBindings: readonly GpuModelBindingSelector[];\n readonly semantics: readonly GpuSemanticSelector[];\n}\n\nexport interface GeneratedGpuInterfaceArtifacts {\n readonly manifestJson: string;\n readonly jsonSchemas: string;\n readonly typescriptTypes: string;\n readonly byteConstants: string;\n readonly codecs: string;\n}\n\nexport interface ShaderCompileUnitManifest {\n readonly contractVersion: typeof SHADER_COMPILE_UNIT_VERSION;\n readonly compileUnitId: string;\n readonly fragmentIds: readonly string[];\n readonly modules: readonly {\n readonly moduleId: string;\n readonly sha256: Sha256Hex;\n readonly assembly: {\n /** UTF-8 fragment bytes joined by one LF byte, with no executable transforms. */\n readonly kind: \"concat-v1\";\n readonly fragmentIds: readonly string[];\n };\n }[];\n readonly entryPoints: readonly {\n readonly moduleId: string;\n readonly name: string;\n readonly stage: GpuShaderStage;\n }[];\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly interfaceRef: GpuInterfaceRef;\n readonly overrideValues: Readonly<Record<string, boolean | number>>;\n readonly qualificationFixture: {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n };\n}\n\nexport interface ShaderCompileUnitInventory {\n readonly contractVersion: typeof SHADER_COMPILE_UNIT_VERSION;\n readonly fragments: readonly {\n readonly fragmentId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly compileUnits: readonly ShaderCompileUnitManifest[];\n}\n\nexport type ShaderMatrixBrowserName = \"chromium\" | \"chrome\" | \"edge\" | \"firefox\" | \"safari\";\nexport type ShaderMatrixOsName =\n | \"ubuntu\"\n | \"windows\"\n | \"macos\"\n | \"chromeos\"\n | \"android\"\n | \"ios\"\n | \"ipados\"\n | \"visionos\";\n\nexport interface StableWebGpuMatrixCell {\n readonly cellId: string;\n readonly runnerLabels: readonly string[];\n readonly browser: {\n readonly name: ShaderMatrixBrowserName;\n readonly channel: \"stable\" | \"playwright-bundled\";\n };\n readonly os: {\n readonly name: ShaderMatrixOsName;\n readonly versionRequirement:\n | { readonly kind: \"exact\"; readonly value: string }\n | { readonly kind: \"major\"; readonly value: number }\n | { readonly kind: \"minimum-major\"; readonly value: number }\n | { readonly kind: \"stable-channel\"; readonly channel: \"stable\" };\n readonly architecture: \"x64\" | \"arm64\";\n };\n readonly adapter: {\n readonly kind: \"software\" | \"physical\";\n readonly vendor: string;\n readonly family: string;\n readonly backend: \"swiftshader\" | \"d3d12\" | \"metal\" | \"vulkan\";\n };\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n };\n readonly timeoutMs: number;\n readonly blocking: boolean;\n readonly countsTowardStableCoverage: boolean;\n}\n\nexport interface StableWebGpuMatrixManifest {\n readonly contractVersion: typeof STABLE_WEBGPU_MATRIX_VERSION;\n readonly matrixId: string;\n readonly version: string;\n readonly policy: {\n readonly coverage: \"all-cells-required\";\n readonly unavailable: \"fail\";\n readonly skipped: \"fail\";\n readonly timeout: \"fail\";\n readonly deviceLoss: \"fail\";\n readonly requiredPhysicalCellCount: 15;\n readonly requiredBlockingCellCount: 16;\n };\n readonly cells: readonly StableWebGpuMatrixCell[];\n}\n\nexport type ShaderQualificationStatus =\n | \"passed\"\n | \"failed\"\n | \"skipped\"\n | \"timeout\"\n | \"device-lost\"\n | \"runner-unavailable\"\n | \"adapter-unavailable\";\n\nexport type ShaderQualificationPhaseName =\n | \"assembly\"\n | \"reflection-schema\"\n | \"shader-compilation\"\n | \"pipeline-layout\"\n | \"pipeline-creation\"\n | \"bind-group-creation\"\n | \"cpu-to-gpu-layout\"\n | \"gpu-to-cpu-layout\"\n | \"bounded-execution\"\n | \"semantic-readback\";\n\nexport type ShaderQualificationPhaseEvidence =\n | {\n readonly name: Exclude<ShaderQualificationPhaseName, \"shader-compilation\" | \"semantic-readback\">;\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly evidenceSha256: Sha256Hex;\n }\n | {\n readonly name: \"shader-compilation\";\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly compilationMessagesSha256: Sha256Hex;\n readonly errorCount: number;\n }\n | {\n readonly name: \"semantic-readback\";\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly expectedSha256: Sha256Hex;\n readonly actualSha256: Sha256Hex;\n };\n\nexport interface ShaderQualificationResult {\n readonly compileUnitId: string;\n readonly cellId: string;\n readonly status: ShaderQualificationStatus;\n readonly startedAt: string;\n readonly completedAt: string;\n readonly observed: {\n readonly runner: { readonly id: string; readonly labels: readonly string[] };\n readonly os: { readonly name: string; readonly version: string; readonly channel: string | null; readonly architecture: string };\n readonly browser: { readonly name: string; readonly version: string; readonly channel: string };\n readonly adapter: {\n readonly physical: boolean;\n readonly vendor: string;\n readonly family: string;\n readonly architecture: string;\n readonly device: string;\n readonly description: string;\n readonly backend: string;\n readonly driver: string;\n };\n readonly features: readonly string[];\n readonly limits: Readonly<Record<string, number>>;\n };\n readonly phases: readonly ShaderQualificationPhaseEvidence[];\n readonly diagnostics: readonly ShaderDiagnostic[];\n}\n\n/** Candidate claims that can be serialized inside the candidate archive without a self-digest. */\nexport interface ShaderQualificationCandidateSubject {\n /** Digest of the ShaderVersionManifest projection with validationEvidence omitted. */\n readonly shaderManifestCore: {\n readonly shaderId: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly shaderAbiHash: Sha256Hex;\n readonly interfaceManifestSha256: Sha256Hex;\n readonly modelAbiHashes: readonly Sha256Hex[];\n readonly modules: readonly { readonly moduleId: string; readonly sha256: Sha256Hex }[];\n readonly requiredCompileUnitIds: readonly string[];\n readonly requiredCellIds: readonly string[];\n}\n\nexport interface ShaderValidationEvidenceSubject extends ShaderQualificationCandidateSubject {\n /** Verified externally over the complete immutable archive; never embedded in that archive. */\n readonly dataBundleSha256: Sha256Hex;\n}\n\nexport interface ShaderTrustedWorkflowProvenance {\n readonly repository: string;\n readonly commit: GitObjectId;\n readonly ref: string;\n readonly workflowRef: string;\n readonly workflowSha: GitObjectId;\n readonly runId: string;\n readonly runAttempt: number;\n readonly job: string;\n readonly eventName: string;\n readonly oidcAttestation: {\n readonly issuer: \"https://token.actions.githubusercontent.com\";\n readonly subject: string;\n readonly audience: string;\n readonly verifiedClaimsSha256: Sha256Hex;\n readonly verifiedAt: string;\n readonly source: \"trusted-runner-preflight\";\n };\n}\n\n/** Identifies the workflow job and runner that produced a qualification-cell artifact. */\nexport interface ShaderQualificationExecutionProducer {\n readonly repository: string;\n readonly commit: GitObjectId;\n readonly ref: string;\n readonly runId: string;\n readonly runAttempt: number;\n readonly job: \"swiftshader\" | \"physical\" | \"physical-runner-preflight\";\n readonly trustedWorkflowRepository: \"Plasius-LTD/gpu-shader\";\n readonly trustedWorkflowRef: string;\n readonly trustedWorkflowSha: GitObjectId;\n readonly runner: {\n readonly name: string;\n readonly environment: \"github-hosted\" | \"self-hosted\" | \"device-farm\";\n readonly os: string;\n readonly architecture: string;\n };\n}\n\nexport interface ShaderValidationEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly evidenceId: string;\n readonly status: \"passed\" | \"failed\";\n readonly generatedAt: string;\n readonly subjectBindingSha256: Sha256Hex;\n readonly subject: ShaderValidationEvidenceSubject;\n readonly matrixRef: {\n readonly matrixId: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly toolchain: {\n readonly packageVersion: string;\n readonly reflectorVersion: \"1.5.0\";\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n };\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly counts: {\n readonly compileUnits: number;\n readonly cells: number;\n readonly expectedResults: number;\n readonly passedResults: number;\n };\n readonly cellRuns: readonly ShaderValidationCellRun[];\n readonly results: readonly ShaderQualificationResult[];\n}\n\nexport type ShaderQualificationResource =\n | {\n readonly kind: \"buffer\";\n readonly resourceId: string;\n readonly byteLength: number;\n readonly usage: readonly string[];\n readonly initialData: { readonly path: string; readonly sha256: Sha256Hex } | null;\n }\n | {\n readonly kind: \"texture\";\n readonly resourceId: string;\n readonly dimension: \"1d\" | \"2d\" | \"3d\";\n readonly size: readonly [number, number, number];\n readonly mipLevelCount: number;\n readonly sampleCount: 1 | 4;\n readonly format: string;\n readonly usage: readonly string[];\n readonly initialData: {\n readonly path: string;\n readonly sha256: Sha256Hex;\n readonly bytesPerRow: number;\n readonly rowsPerImage: number;\n readonly mipLevel: number;\n readonly origin: readonly [number, number, number];\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n } | null;\n }\n | {\n readonly kind: \"sampler\";\n readonly resourceId: string;\n readonly descriptor: Readonly<Record<string, JsonPrimitive>>;\n };\n\nexport type ShaderQualificationCommand =\n | {\n readonly kind: \"dispatch\";\n readonly pipelineId: string;\n readonly bindGroupIds: readonly string[];\n readonly workgroups: readonly [number, number, number];\n }\n | {\n readonly kind: \"draw\";\n readonly pipelineId: string;\n readonly bindGroupIds: readonly string[];\n readonly vertexBuffers: readonly {\n readonly slot: number;\n readonly resourceId: string;\n readonly offset: number;\n readonly size: number;\n }[];\n readonly colorAttachments: readonly {\n readonly resourceId: string;\n readonly view: ShaderQualificationTextureViewDescriptor;\n readonly clearValue: readonly [number, number, number, number];\n readonly loadOp: \"clear\" | \"load\";\n readonly storeOp: \"store\" | \"discard\";\n }[];\n readonly depthStencilAttachment: {\n readonly resourceId: string;\n readonly view: ShaderQualificationTextureViewDescriptor;\n readonly depthClearValue: number;\n readonly depthLoadOp: \"clear\" | \"load\";\n readonly depthStoreOp: \"store\" | \"discard\";\n readonly stencilClearValue: number;\n readonly stencilLoadOp: \"clear\" | \"load\" | null;\n readonly stencilStoreOp: \"store\" | \"discard\" | null;\n } | null;\n readonly vertexCount: number;\n readonly instanceCount: number;\n readonly firstVertex: number;\n readonly firstInstance: number;\n }\n | {\n readonly kind: \"copy-buffer\";\n readonly source: string;\n readonly destination: string;\n readonly byteLength: number;\n }\n | {\n readonly kind: \"copy-texture-to-buffer\";\n readonly source: {\n readonly resourceId: string;\n readonly mipLevel: number;\n readonly origin: readonly [number, number, number];\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n };\n readonly destination: {\n readonly resourceId: string;\n readonly offset: number;\n readonly bytesPerRow: number;\n readonly rowsPerImage: number;\n };\n readonly extent: readonly [number, number, number];\n };\n\nexport interface ShaderQualificationTextureViewDescriptor {\n readonly format: string | null;\n readonly dimension: \"1d\" | \"2d\" | \"2d-array\" | \"cube\" | \"cube-array\" | \"3d\" | null;\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n readonly baseMipLevel: number;\n readonly mipLevelCount: number | null;\n readonly baseArrayLayer: number;\n readonly arrayLayerCount: number | null;\n}\n\nexport type ShaderQualificationBindGroupResource =\n | { readonly kind: \"buffer\"; readonly resourceId: string; readonly offset: number; readonly size: number }\n | { readonly kind: \"texture-view\"; readonly resourceId: string; readonly view: ShaderQualificationTextureViewDescriptor }\n | { readonly kind: \"sampler\"; readonly resourceId: string };\n\n/** A declarative host-codec ↔ final-WGSL record-layout probe. */\nexport interface ShaderQualificationBufferRecordLayoutProbe {\n readonly kind: \"buffer-record\";\n readonly probeId: string;\n readonly source: {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n readonly recordName: string;\n };\n readonly pipelineId: string;\n readonly commandIndex: number;\n readonly input: {\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteLength: number;\n /** Encoded with createGpuRecordCodec and compared byte-for-byte with admitted initialData. */\n readonly value: JsonValue;\n };\n readonly output: {\n readonly readbackIndex: number;\n readonly recordName: string;\n /** GPU output is decoded with the reflected codec and compared to this value. */\n readonly expectedValue: JsonValue;\n };\n}\n\n/** A declarative host vertex-format encoder ↔ final-WGSL vertex-fetch probe. */\nexport interface ShaderQualificationVertexInputLayoutProbe {\n readonly kind: \"vertex-input\";\n readonly probeId: string;\n readonly source: {\n readonly pipelineId: string;\n readonly shaderLocation: number;\n readonly semantic: string;\n };\n readonly commandIndex: number;\n readonly input: {\n readonly resourceId: string;\n readonly vertexBufferSlot: number;\n /** Absolute vertex or instance element selected by the draw command. */\n readonly elementIndex: number;\n /** Encoded from the reflected GPUVertexFormat and compared with admitted bytes. */\n readonly value: JsonValue;\n };\n readonly output: {\n readonly readbackIndex: number;\n readonly recordName: string;\n /** GPU-observed vertex value encoded through this reflected output record. */\n readonly expectedValue: JsonValue;\n };\n}\n\nexport type ShaderQualificationLayoutProbe =\n | ShaderQualificationBufferRecordLayoutProbe\n | ShaderQualificationVertexInputLayoutProbe;\n\nexport interface ShaderQualificationFixtureManifest {\n readonly contractVersion: typeof SHADER_QUALIFICATION_FIXTURE_VERSION;\n readonly fixtureId: string;\n readonly resources: readonly ShaderQualificationResource[];\n readonly bindGroups: readonly {\n readonly bindGroupId: string;\n readonly group: number;\n readonly entries: readonly { readonly binding: number; readonly resource: ShaderQualificationBindGroupResource }[];\n }[];\n readonly commands: readonly ShaderQualificationCommand[];\n readonly layoutProbes: readonly ShaderQualificationLayoutProbe[];\n readonly readbacks: readonly {\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteLength: number;\n readonly expectedSha256: Sha256Hex;\n }[];\n readonly bounds: {\n readonly maxBufferBytes: number;\n readonly maxTextureTexels: number;\n readonly maxCommands: number;\n readonly timeoutMs: number;\n };\n}\n\nexport interface ShaderQualificationBundleManifest {\n readonly contractVersion: typeof SHADER_QUALIFICATION_BUNDLE_VERSION;\n readonly inventory: ShaderCompileUnitInventory;\n readonly subject: ShaderQualificationCandidateSubject;\n readonly shaderManifestCorePath: string;\n readonly gpuInterfaceManifest: { readonly path: string; readonly sha256: Sha256Hex };\n readonly modelCompatibilityFixtures: readonly {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly modules: readonly { readonly moduleId: string; readonly path: string; readonly sha256: Sha256Hex }[];\n readonly fixtures: readonly {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n readonly kind: \"qualification-fixture\";\n }[];\n}\n\nexport interface ShaderQualificationModelCompatibilityFixture {\n readonly contractVersion: typeof SHADER_QUALIFICATION_FIXTURE_VERSION;\n readonly fixtureId: string;\n readonly model: ModelGpuCompatibilityDescriptor;\n}\n\nexport interface ShaderCellEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly qualificationId: string;\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: Sha256Hex;\n readonly cellId: string;\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n readonly driver: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n /** `sha256(\"plasius.gpu.qualification-subject/v1\\n\" + canonical(subject,digests))`. */\n readonly subjectBindingSha256: Sha256Hex;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n readonly results: readonly ShaderQualificationResult[];\n}\n\nexport interface ShaderRunnerCellPreflightEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-runner-cell-preflight-evidence\";\n readonly qualificationId: string;\n readonly cellId: string;\n readonly status: \"available\" | \"runner-unavailable\";\n readonly matrixSha256: Sha256Hex;\n readonly runnerLabels: readonly string[];\n /** API-observed self-hosted/device labels, or hosted image labels derived from the actual OS/architecture environment. */\n readonly matchedRunners: readonly {\n readonly name: string;\n readonly labels: readonly string[];\n }[];\n /** Independently verified adapter package/code identity, or null when inventory cannot observe it. */\n readonly adapterHarness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n } | null;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n}\n\nexport interface ShaderValidationCellRun {\n readonly cellId: string;\n readonly source: \"cell-evidence\" | \"runner-preflight\" | \"workflow-diagnostic\";\n readonly sourceArtifactSha256: Sha256Hex;\n readonly resultsSha256: Sha256Hex;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n /** Null when no adapter actually executed (runner-unavailable/workflow diagnostic). */\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n readonly driver: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n } | null;\n readonly resultCount: number;\n readonly status: ShaderQualificationStatus;\n}\n\n/** Non-secret claims emitted by the trusted prepare job after Blob version and OIDC verification. */\nexport interface ShaderQualificationPreflightManifest {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-qualification-preflight\";\n readonly qualificationId: string;\n readonly sourceBlob: {\n readonly host: string;\n readonly versionId: string;\n readonly uri: string;\n };\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n readonly subjectBindingSha256: Sha256Hex;\n readonly provenance: ShaderTrustedWorkflowProvenance;\n}\n\nexport interface ShaderNonQualifyingWorkflowDiagnostic {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"non-qualifying-workflow-diagnostic\";\n readonly qualificationId: string;\n readonly cellId: string;\n readonly status: \"timeout\" | \"failed\";\n readonly matrixSha256: Sha256Hex;\n readonly message: string;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n}\n\n/** External GitHub build-provenance reference; verified outside the evidence JSON digest. */\nexport interface ShaderValidationEvidenceAttestationRef {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-validation-evidence-attestation-ref\";\n readonly evidence: { readonly name: string; readonly sha256: Sha256Hex };\n readonly attestation: {\n readonly id: string;\n readonly url: string;\n readonly bundle: { readonly name: string; readonly sha256: Sha256Hex };\n };\n readonly producer: {\n readonly repository: string;\n readonly runId: string;\n readonly runAttempt: number;\n readonly trustedWorkflowRepository: \"Plasius-LTD/gpu-shader\";\n readonly trustedWorkflowRef: string;\n readonly trustedWorkflowSha: GitObjectId;\n };\n}\n\nexport interface ShaderCompileFixture {\n /** Local/hosted testing only. Callback fixtures can never produce trusted physical evidence. */\n readonly qualificationEligible: false;\n readonly fixtureId: string;\n setup(context: ShaderCompileContext): Promise<void>;\n encode(context: ShaderCompileContext): Promise<void>;\n verify(context: ShaderCompileContext): Promise<void>;\n cleanup(context: ShaderCompileContext): Promise<void>;\n}\n\nexport interface ShaderCompileContext {\n readonly device: GpuDeviceLike;\n readonly unit: ShaderCompileUnitManifest;\n readonly modules: ReadonlyMap<string, GpuShaderModuleLike>;\n readonly state: Map<string, unknown>;\n}\n","import type { JsonValue } from \"./contracts.js\";\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction assertUnicodeScalarString(value: string, path: string): void {\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index);\n if (code >= 0xd800 && code <= 0xdbff) {\n const next = value.charCodeAt(index + 1);\n if (!(next >= 0xdc00 && next <= 0xdfff)) throw new TypeError(`${path} contains an unpaired UTF-16 surrogate.`);\n index += 1;\n } else if (code >= 0xdc00 && code <= 0xdfff) throw new TypeError(`${path} contains an unpaired UTF-16 surrogate.`);\n }\n}\n\n/**\n * Canonicalizes contract data using the JSON Canonicalization Scheme ordering\n * rules. Unsupported JavaScript values are rejected rather than silently lost.\n */\nexport function canonicalizeGpuContract(value: unknown): string {\n const ancestors = new Set<object>();\n\n const visit = (current: unknown, path: string): string => {\n if (current === null) return \"null\";\n if (typeof current === \"string\" || typeof current === \"boolean\") {\n if (typeof current === \"string\") assertUnicodeScalarString(current, path);\n return JSON.stringify(current);\n }\n if (typeof current === \"number\") {\n if (!Number.isFinite(current)) {\n throw new TypeError(`${path} contains a non-finite number.`);\n }\n return Object.is(current, -0) ? \"0\" : JSON.stringify(current);\n }\n if (typeof current !== \"object\") {\n throw new TypeError(`${path} contains a value that JSON cannot represent.`);\n }\n if (ancestors.has(current)) {\n throw new TypeError(`${path} contains a circular reference.`);\n }\n\n ancestors.add(current);\n try {\n if (Array.isArray(current)) {\n return `[${current.map((item, index) => visit(item, `${path}[${index}]`)).join(\",\")}]`;\n }\n if (!isPlainObject(current)) {\n throw new TypeError(`${path} must contain only plain JSON objects.`);\n }\n const keys = Object.keys(current).sort();\n const properties = keys.map((key) => {\n assertUnicodeScalarString(key, `${path} key`);\n const member = current[key];\n if (member === undefined) {\n throw new TypeError(`${path}.${key} is undefined.`);\n }\n return `${JSON.stringify(key)}:${visit(member, `${path}.${key}`)}`;\n });\n return `{${properties.join(\",\")}}`;\n } finally {\n ancestors.delete(current);\n }\n };\n\n return visit(value, \"$root\");\n}\n\n/** Parses and verifies exact JCS canonical JSON while preserving its JSON-only type. */\nexport function parseCanonicalJson(value: string): JsonValue {\n const parsed = JSON.parse(value) as JsonValue;\n if (canonicalizeGpuContract(parsed) !== value) throw new TypeError(\"JSON input is valid but not in canonical form.\");\n return parsed;\n}\n","import { canonicalizeGpuContract } from \"./canonical-json.js\";\nimport type {\n GpuInterfaceManifest,\n SerializableGpuPipelineDescriptor,\n Sha256Hex,\n ShaderRequirements,\n ShaderVersionManifest,\n} from \"./contracts.js\";\n\nconst SHA256_PATTERN = /^[a-f0-9]{64}$/u;\n\nexport function asSha256Hex(value: string): Sha256Hex {\n if (!SHA256_PATTERN.test(value)) {\n throw new TypeError(\"SHA-256 values must be lowercase 64-character hexadecimal strings.\");\n }\n return value as Sha256Hex;\n}\n\n/** Computes a SHA-256 digest using the browser-safe Web Crypto API. */\nexport async function computeSha256(value: Uint8Array | string): Promise<Sha256Hex> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) {\n throw new Error(\"Web Crypto SHA-256 support is required.\");\n }\n const bytes = typeof value === \"string\" ? new TextEncoder().encode(value) : value;\n const digest = await subtle.digest(\"SHA-256\", bytes as BufferSource);\n return asSha256Hex(\n Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\"),\n );\n}\n\nfunction sorted<T>(items: readonly T[], compare: (left: T, right: T) => number): T[] {\n return [...items].sort(compare);\n}\n\nfunction compareString(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction interfaceProjection(manifest: GpuInterfaceManifest): unknown {\n return {\n contractVersion: manifest.contractVersion,\n records: sorted(manifest.records, (left, right) => compareString(left.name, right.name)),\n bindings: sorted(manifest.bindings, (left, right) =>\n compareString(left.moduleId, right.moduleId) || left.group - right.group || left.binding - right.binding),\n entryPoints: sorted(manifest.entryPoints, (left, right) =>\n compareString(left.moduleId, right.moduleId)\n || compareString(left.stage, right.stage)\n || compareString(left.name, right.name)),\n vertexInputs: sorted(manifest.vertexInputs, (left, right) =>\n compareString(left.pipelineId, right.pipelineId) || left.shaderLocation - right.shaderLocation),\n overrides: sorted(manifest.overrides, (left, right) =>\n compareString(left.moduleId, right.moduleId) || compareString(left.name, right.name)),\n };\n}\n\nfunction modelProjection(manifest: GpuInterfaceManifest): unknown {\n const recordsByName = new Map(manifest.records.map((record) => [record.name, record]));\n const names = new Set<string>();\n const includeRecord = (name: string): void => {\n if (names.has(name)) return;\n const record = recordsByName.get(name);\n if (!record) throw new TypeError(`Model ABI references missing record ${name}.`);\n names.add(name);\n const visitType = (type: typeof record.members[number][\"type\"]): void => {\n if (type.kind === \"record\") includeRecord(type.recordName);\n if (type.kind === \"array\") visitType(type.element);\n };\n for (const member of record.members) visitType(member.type);\n };\n for (const name of manifest.modelAbi.recordNames) includeRecord(name);\n for (const binding of manifest.modelAbi.bindings) {\n if (binding.resource.kind === \"buffer\" && binding.resource.recordName) includeRecord(binding.resource.recordName);\n }\n for (const semantic of manifest.modelAbi.semantics) {\n if (semantic.source.kind === \"record-member\") includeRecord(semantic.source.recordName);\n }\n const semanticProjection = manifest.modelAbi.semantics.map((projection) => ({\n semantic: projection.semantic,\n source: projection.source.kind === \"record-member\"\n ? {\n kind: projection.source.kind,\n recordName: projection.source.recordName,\n memberPath: projection.source.memberPath,\n }\n : { kind: projection.source.kind },\n }));\n return {\n contractVersion: manifest.contractVersion,\n records: sorted(\n manifest.records.filter((record) => names.has(record.name)),\n (left, right) => compareString(left.name, right.name),\n ).map(({ addressSpaces: _shaderUsage, ...record }) => record),\n bindings: sorted(manifest.modelAbi.bindings, (left, right) =>\n compareString(left.semantic ?? \"\", right.semantic ?? \"\")\n || compareString(canonicalizeGpuContract(left.resource), canonicalizeGpuContract(right.resource)))\n .map(({ source: _selector, ...binding }) => binding),\n vertexInputs: sorted(manifest.modelAbi.vertexInputs, (left, right) =>\n compareString(left.semantic ?? \"\", right.semantic ?? \"\")\n || left.offset - right.offset)\n .map(({ source: _selector, ...vertex }) => vertex),\n semantics: sorted(semanticProjection, (left, right) =>\n compareString(left.semantic, right.semantic),\n ),\n };\n}\n\nexport type ComputeGpuAbiHashInput =\n | { readonly kind: \"model\"; readonly interface: GpuInterfaceManifest }\n | { readonly kind: \"interface\"; readonly interface: GpuInterfaceManifest }\n | {\n readonly kind: \"shader\";\n readonly interface: GpuInterfaceManifest;\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly requirements: ShaderRequirements;\n };\n\n/** Computes a domain-separated ABI digest over normalized structural data. */\nexport async function computeGpuAbiHash(input: ComputeGpuAbiHashInput): Promise<Sha256Hex> {\n if (input.kind === \"model\") {\n return computeSha256(\n `plasius.gpu.model-abi/v1\\n${canonicalizeGpuContract(modelProjection(input.interface))}`,\n );\n }\n if (input.kind === \"interface\") {\n return computeSha256(\n `plasius.gpu.interface-abi/v1\\n${canonicalizeGpuContract(interfaceProjection(input.interface))}`,\n );\n }\n const pipelines = sorted(input.pipelines, (left, right) =>\n compareString(left.pipelineId, right.pipelineId),\n );\n const requirements = {\n semantics: [...input.requirements.semantics].sort(),\n features: [...input.requirements.features].sort(),\n limits: sorted(input.requirements.limits, (left, right) => compareString(left.name, right.name)),\n formats: [...input.requirements.formats].sort(),\n };\n return computeSha256(\n `plasius.gpu.shader-abi/v1\\n${canonicalizeGpuContract({\n interface: interfaceProjection(input.interface),\n pipelines,\n requirements,\n })}`,\n );\n}\n\n/** Breaks the manifest/evidence digest cycle by omitting only the evidence reference. */\nexport async function computeShaderManifestCoreSha256(\n manifest: Omit<ShaderVersionManifest, \"validationEvidence\" | \"additionalValidationEvidence\"> | ShaderVersionManifest,\n): Promise<Sha256Hex> {\n const core = Object.fromEntries(Object.entries(manifest).filter(\n ([key]) => key !== \"validationEvidence\" && key !== \"additionalValidationEvidence\",\n ));\n return computeSha256(\n `plasius.gpu.shader-manifest-core/v1\\n${canonicalizeGpuContract(core)}`,\n );\n}\n","import {\n GPU_INTERFACE_MANIFEST_VERSION,\n SHADER_QUALIFICATION_FIXTURE_VERSION,\n SHADER_STYLE_PROFILE_MANIFEST_VERSION,\n SHADER_VERSION_MANIFEST_VERSION,\n SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES,\n SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES,\n type GpuBindingResourceLayout,\n type GpuInterfaceManifest,\n type ModelGpuCompatibilityDescriptor,\n type GpuRecordLayout,\n type GpuTypeLayout,\n type SerializableGpuPipelineDescriptor,\n type ShaderStyleProfileManifest,\n type ShaderQualificationModelCompatibilityFixture,\n type ShaderVersionManifest,\n type ShaderVersionManifestCore,\n} from \"./contracts.js\";\nimport { canonicalizeGpuContract as canonicalizeForValidation } from \"./canonical-json.js\";\nimport { asSha256Hex } from \"./hash.js\";\nimport { validatePipelineDerivedRequirements } from \"./requirements-validation.js\";\n\ntype UnknownRecord = Record<string, unknown>;\nconst stages = [\"vertex\", \"fragment\", \"compute\"] as const;\nconst roles = [\"material\", \"lighting\", \"outline\", \"shadow\", \"post-processing\"] as const;\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const allowed = new Set(keys);\n for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path}.${key} is not part of this contract version.`);\n for (const key of keys) if (!(key in value)) throw new TypeError(`${path}.${key} is required.`);\n}\n\nfunction text(value: unknown, path: string, maximum = 512): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 0x1f)) {\n throw new TypeError(`${path} must be a bounded non-empty string without control characters.`);\n }\n return value;\n}\n\nfunction token(value: unknown, path: string): string {\n const result = text(value, path, 160);\n if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u.test(result) || result.includes(\"..\")) throw new TypeError(`${path} must be a safe token.`);\n return result;\n}\n\nfunction enumeration<T extends string | number>(value: unknown, values: readonly T[], path: string): T {\n if (!values.includes(value as T)) throw new TypeError(`${path} is invalid.`);\n return value as T;\n}\n\nfunction integer(value: unknown, path: string, minimum = 0, maximum = 0xffff_ffff): number {\n if (!Number.isSafeInteger(value) || (value as number) < minimum || (value as number) > maximum) {\n throw new TypeError(`${path} must be an integer from ${minimum} through ${maximum}.`);\n }\n return value as number;\n}\n\nfunction finite(value: unknown, path: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) throw new TypeError(`${path} must be finite.`);\n return value;\n}\n\nfunction array(value: unknown, path: string, maximum = 4096): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${path} must be a bounded array.`);\n return value;\n}\n\nfunction nullableInteger(value: unknown, path: string): number | null {\n return value === null ? null : integer(value, path);\n}\n\nfunction nullableToken(value: unknown, path: string): string | null {\n return value === null ? null : token(value, path);\n}\n\nfunction digest(value: unknown, path: string): string {\n try { return asSha256Hex(text(value, path, 64)); }\n catch (cause) { throw new TypeError(`${path} must be a lowercase SHA-256 digest.`, { cause }); }\n}\n\nfunction uri(value: unknown, path: string): string {\n const result = text(value, path, 2048);\n let parsed: URL;\n try { parsed = new URL(result); }\n catch (cause) { throw new TypeError(`${path} must be an absolute immutable asset URI.`, { cause }); }\n if (parsed.protocol !== \"https:\" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path} must be credential-free HTTPS without a fragment.`);\n const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());\n const forbidden = new Set([\"sig\", \"se\", \"sp\", \"sv\", \"spr\", \"st\", \"skoid\", \"sktid\", \"skt\", \"ske\", \"sks\", \"skv\"]);\n if (keys.some((key) => forbidden.has(key)) || new Set(keys).size !== keys.length) throw new TypeError(`${path} must not contain SAS credentials or duplicate query parameters.`);\n if (parsed.href !== result) throw new TypeError(`${path} must use its canonical URL serialization.`);\n return result;\n}\n\nfunction unique<T>(values: readonly T[], key: (value: T) => string, path: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n const identity = key(value);\n if (seen.has(identity)) throw new TypeError(`${path} contains duplicate ${identity}.`);\n seen.add(identity);\n }\n}\n\nfunction tokenArray(value: unknown, path: string, maximum = 4096): string[] {\n const result = array(value, path, maximum).map((item, index) => token(item, `${path}[${index}]`));\n unique(result, String, path);\n return result;\n}\n\nfunction typeLayout(value: unknown, path: string, depth = 0): GpuTypeLayout {\n if (depth > 24) throw new TypeError(`${path} exceeds the type nesting limit.`);\n const input = object(value, path);\n const kind = enumeration(input.kind, [\"scalar\", \"atomic\", \"vector\", \"matrix\", \"array\", \"record\"] as const, `${path}.kind`);\n integer(input.alignment, `${path}.alignment`, 1);\n if (kind === \"array\") {\n exact(input, [\"kind\", \"element\", \"count\", \"stride\", \"alignment\", \"byteSize\"], path);\n const element = typeLayout(input.element, `${path}.element`, depth + 1);\n const count = nullableInteger(input.count, `${path}.count`);\n const stride = integer(input.stride, `${path}.stride`, 1);\n const byteSize = nullableInteger(input.byteSize, `${path}.byteSize`);\n if (input.alignment !== element.alignment || stride % element.alignment !== 0\n || element.byteSize === null || stride < element.byteSize\n || (count === null ? byteSize !== null : byteSize !== count * stride)) {\n throw new TypeError(`${path} has inconsistent array layout algebra.`);\n }\n } else if (kind === \"record\") {\n exact(input, [\"kind\", \"recordName\", \"alignment\", \"byteSize\"], path);\n token(input.recordName, `${path}.recordName`);\n nullableInteger(input.byteSize, `${path}.byteSize`);\n } else {\n integer(input.byteSize, `${path}.byteSize`, 1);\n if (kind === \"scalar\") {\n exact(input, [\"kind\", \"scalar\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\", \"f32\", \"f16\", \"bool\"] as const, `${path}.scalar`);\n const size = input.scalar === \"f16\" ? 2 : 4;\n if (input.alignment !== size || input.byteSize !== size) throw new TypeError(`${path} has inconsistent scalar layout.`);\n } else if (kind === \"atomic\") {\n exact(input, [\"kind\", \"scalar\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\"] as const, `${path}.scalar`);\n if (input.alignment !== 4 || input.byteSize !== 4) throw new TypeError(`${path} has inconsistent atomic layout.`);\n } else if (kind === \"vector\") {\n exact(input, [\"kind\", \"scalar\", \"width\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\", \"f32\", \"f16\", \"bool\"] as const, `${path}.scalar`);\n const width = enumeration(input.width, [2, 3, 4] as const, `${path}.width`);\n const scalarSize = input.scalar === \"f16\" ? 2 : 4;\n if (input.alignment !== (width === 2 ? 2 : 4) * scalarSize || input.byteSize !== width * scalarSize) throw new TypeError(`${path} has inconsistent vector layout.`);\n } else {\n exact(input, [\"kind\", \"scalar\", \"columns\", \"rows\", \"columnStride\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"f32\", \"f16\"] as const, `${path}.scalar`);\n const columns = enumeration(input.columns, [2, 3, 4] as const, `${path}.columns`);\n const rows = enumeration(input.rows, [2, 3, 4] as const, `${path}.rows`);\n const stride = integer(input.columnStride, `${path}.columnStride`, 1);\n const scalarSize = input.scalar === \"f16\" ? 2 : 4;\n const alignment = (rows === 2 ? 2 : 4) * scalarSize;\n if (input.alignment !== alignment || stride !== Math.ceil((rows * scalarSize) / alignment) * alignment || input.byteSize !== columns * stride) throw new TypeError(`${path} has inconsistent matrix layout.`);\n }\n }\n return input as unknown as GpuTypeLayout;\n}\n\nfunction recordLayout(value: unknown, path: string): GpuRecordLayout {\n const input = object(value, path);\n exact(input, [\"name\", \"alignment\", \"byteSize\", \"minimumByteSize\", \"runtimeArrayMember\", \"addressSpaces\", \"members\"], path);\n token(input.name, `${path}.name`);\n integer(input.alignment, `${path}.alignment`, 1);\n nullableInteger(input.byteSize, `${path}.byteSize`);\n integer(input.minimumByteSize, `${path}.minimumByteSize`);\n nullableToken(input.runtimeArrayMember, `${path}.runtimeArrayMember`);\n const spaces = array(input.addressSpaces, `${path}.addressSpaces`, 5).map((space, index) =>\n enumeration(space, [\"uniform\", \"storage\", \"function\", \"private\", \"workgroup\"] as const, `${path}.addressSpaces[${index}]`));\n unique(spaces, String, `${path}.addressSpaces`);\n const members = array(input.members, `${path}.members`);\n let priorEnd = 0;\n const names: string[] = [];\n members.forEach((value, index) => {\n const memberPath = `${path}.members[${index}]`;\n const member = object(value, memberPath);\n exact(member, [\"name\", \"offset\", \"alignment\", \"valueByteSize\", \"occupiedByteSize\", \"explicitAlign\", \"explicitSize\", \"type\"], memberPath);\n names.push(token(member.name, `${memberPath}.name`));\n const offset = integer(member.offset, `${memberPath}.offset`);\n const alignment = integer(member.alignment, `${memberPath}.alignment`, 1);\n const valueSize = nullableInteger(member.valueByteSize, `${memberPath}.valueByteSize`);\n const occupied = nullableInteger(member.occupiedByteSize, `${memberPath}.occupiedByteSize`);\n const explicitAlign = member.explicitAlign === null ? null : integer(member.explicitAlign, `${memberPath}.explicitAlign`, 1);\n const explicitSize = member.explicitSize === null ? null : integer(member.explicitSize, `${memberPath}.explicitSize`, 1);\n const type = typeLayout(member.type, `${memberPath}.type`);\n if (explicitAlign !== null && ((explicitAlign & (explicitAlign - 1)) !== 0 || explicitAlign < type.alignment)) {\n throw new TypeError(`${memberPath}.explicitAlign must be a power of two no smaller than the natural alignment.`);\n }\n if (explicitSize !== null && (type.byteSize === null || explicitSize < type.byteSize)) {\n throw new TypeError(`${memberPath}.explicitSize must not shrink a fixed-size WGSL type.`);\n }\n if (offset < priorEnd || offset % alignment !== 0 || alignment !== (explicitAlign ?? type.alignment)\n || valueSize !== type.byteSize || occupied !== (explicitSize ?? type.byteSize)\n || (occupied !== null && valueSize !== null && occupied < valueSize)) {\n throw new TypeError(`${memberPath} has inconsistent member layout algebra.`);\n }\n if (occupied === null && index !== members.length - 1) throw new TypeError(`${memberPath} is a non-final runtime array.`);\n if (occupied !== null) priorEnd = offset + occupied;\n });\n unique(names, String, `${path}.members`);\n if ((input.byteSize === null) !== (input.runtimeArrayMember !== null)) throw new TypeError(`${path} has inconsistent runtime array metadata.`);\n const maximumAlignment = Math.max(1, ...members.map((value) => Number((value as UnknownRecord).alignment)));\n if (input.alignment !== maximumAlignment) throw new TypeError(`${path}.alignment is inconsistent with its members.`);\n const tail = members.at(-1) as UnknownRecord | undefined;\n const expectedMinimum = input.runtimeArrayMember === null\n ? Math.ceil(priorEnd / Number(input.alignment)) * Number(input.alignment)\n : Number(tail?.offset ?? 0);\n if (input.minimumByteSize !== expectedMinimum || (input.byteSize !== null && input.byteSize !== expectedMinimum)\n || (input.runtimeArrayMember !== null && tail?.name !== input.runtimeArrayMember)) {\n throw new TypeError(`${path} has inconsistent fixed/runtime size metadata.`);\n }\n if (input.runtimeArrayMember !== null) {\n const tailType = tail?.type as GpuTypeLayout | undefined;\n if (!tailType || tailType.kind !== \"array\" || tailType.count !== null) throw new TypeError(`${path}.runtimeArrayMember must name a direct trailing runtime-sized array.`);\n }\n return input as unknown as GpuRecordLayout;\n}\n\nfunction bindingResource(value: unknown, path: string): GpuBindingResourceLayout {\n const input = object(value, path);\n const kind = enumeration(input.kind, [\"buffer\", \"sampler\", \"texture\", \"storage-texture\", \"external-texture\"] as const, `${path}.kind`);\n if (kind === \"buffer\") {\n exact(input, [\"kind\", \"addressSpace\", \"access\", \"recordName\", \"minimumBindingSize\"], path);\n enumeration(input.addressSpace, [\"uniform\", \"storage\"] as const, `${path}.addressSpace`);\n enumeration(input.access, [\"read\", \"write\", \"read_write\"] as const, `${path}.access`);\n if (input.addressSpace === \"uniform\" && input.access !== \"read\") throw new TypeError(`${path}.access must be read for uniform buffers.`);\n nullableToken(input.recordName, `${path}.recordName`);\n integer(input.minimumBindingSize, `${path}.minimumBindingSize`);\n } else if (kind === \"sampler\") {\n exact(input, [\"kind\", \"samplerType\"], path);\n enumeration(input.samplerType, [\"filtering\", \"non-filtering\", \"comparison\"] as const, `${path}.samplerType`);\n } else if (kind === \"texture\") {\n exact(input, [\"kind\", \"sampleType\", \"viewDimension\", \"multisampled\"], path);\n enumeration(input.sampleType, [\"float\", \"unfilterable-float\", \"depth\", \"sint\", \"uint\"] as const, `${path}.sampleType`);\n enumeration(input.viewDimension, [\"1d\", \"2d\", \"2d-array\", \"cube\", \"cube-array\", \"3d\"] as const, `${path}.viewDimension`);\n if (typeof input.multisampled !== \"boolean\") throw new TypeError(`${path}.multisampled must be boolean.`);\n } else if (kind === \"storage-texture\") {\n exact(input, [\"kind\", \"access\", \"format\", \"viewDimension\"], path);\n enumeration(input.access, [\"write-only\", \"read-only\", \"read-write\"] as const, `${path}.access`);\n token(input.format, `${path}.format`);\n enumeration(input.viewDimension, [\"1d\", \"2d\", \"2d-array\", \"3d\"] as const, `${path}.viewDimension`);\n } else exact(input, [\"kind\"], path);\n return input as unknown as GpuBindingResourceLayout;\n}\n\nfunction visibility(value: unknown, path: string): (typeof stages)[number][] {\n const result = array(value, path, 3).map((item, index) => enumeration(item, stages, `${path}[${index}]`));\n unique(result, String, path);\n if (result.length === 0) throw new TypeError(`${path} must include at least one shader stage.`);\n return result;\n}\n\nfunction binding(value: unknown, path: string, coordinates = true): UnknownRecord {\n const input = object(value, path);\n exact(input, coordinates\n ? [\"moduleId\", \"variableName\", \"group\", \"binding\", \"resource\", \"visibility\"]\n : [\"source\", \"resource\", \"semantic\"], path);\n if (coordinates) {\n token(input.moduleId, `${path}.moduleId`); token(input.variableName, `${path}.variableName`);\n integer(input.group, `${path}.group`); integer(input.binding, `${path}.binding`);\n visibility(input.visibility, `${path}.visibility`);\n } else {\n const source = object(input.source, `${path}.source`); exact(source, [\"moduleId\", \"group\", \"binding\"], `${path}.source`);\n token(source.moduleId, `${path}.source.moduleId`); integer(source.group, `${path}.source.group`); integer(source.binding, `${path}.source.binding`);\n nullableToken(input.semantic, `${path}.semantic`);\n }\n bindingResource(input.resource, `${path}.resource`);\n return input;\n}\n\nfunction entryIo(value: unknown, path: string): UnknownRecord {\n const input = object(value, path);\n exact(input, [\"name\", \"locationKind\", \"location\", \"interpolation\", \"type\"], path);\n token(input.name, `${path}.name`);\n const kind = enumeration(input.locationKind, [\"location\", \"builtin\"] as const, `${path}.locationKind`);\n if (kind === \"location\") integer(input.location, `${path}.location`); else token(input.location, `${path}.location`);\n if (input.interpolation !== null) token(input.interpolation, `${path}.interpolation`);\n typeLayout(input.type, `${path}.type`);\n return input;\n}\n\nfunction vertexInput(value: unknown, path: string, model = false): UnknownRecord {\n const input = object(value, path);\n if (model) {\n exact(input, [\"source\", \"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"], path);\n const source = object(input.source, `${path}.source`); exact(source, [\"pipelineId\", \"shaderLocation\"], `${path}.source`);\n token(source.pipelineId, `${path}.source.pipelineId`); integer(source.shaderLocation, `${path}.source.shaderLocation`);\n token(input.semantic, `${path}.semantic`);\n } else {\n exact(input, [\"pipelineId\", \"moduleId\", \"entryPoint\", \"shaderLocation\", \"shaderType\", \"bufferSlot\", \"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"], path);\n token(input.pipelineId, `${path}.pipelineId`); token(input.moduleId, `${path}.moduleId`); token(input.entryPoint, `${path}.entryPoint`);\n integer(input.shaderLocation, `${path}.shaderLocation`); typeLayout(input.shaderType, `${path}.shaderType`); integer(input.bufferSlot, `${path}.bufferSlot`);\n nullableToken(input.semantic, `${path}.semantic`);\n }\n token(input.format, `${path}.format`); integer(input.offset, `${path}.offset`); integer(input.arrayStride, `${path}.arrayStride`);\n enumeration(input.stepMode, [\"vertex\", \"instance\"] as const, `${path}.stepMode`);\n return input;\n}\n\nfunction semantic(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"semantic\", \"source\"], path); token(input.semantic, `${path}.semantic`);\n const source = object(input.source, `${path}.source`);\n const kind = enumeration(source.kind, [\"record-member\", \"vertex-attribute\", \"binding\"] as const, `${path}.source.kind`);\n if (kind === \"record-member\") {\n exact(source, [\"kind\", \"recordName\", \"memberPath\"], `${path}.source`); token(source.recordName, `${path}.source.recordName`);\n tokenArray(source.memberPath, `${path}.source.memberPath`, 24);\n } else if (kind === \"vertex-attribute\") {\n exact(source, [\"kind\", \"pipelineId\", \"shaderLocation\"], `${path}.source`); token(source.pipelineId, `${path}.source.pipelineId`); integer(source.shaderLocation, `${path}.source.shaderLocation`);\n } else {\n exact(source, [\"kind\", \"moduleId\", \"group\", \"binding\"], `${path}.source`); token(source.moduleId, `${path}.source.moduleId`);\n integer(source.group, `${path}.source.group`); integer(source.binding, `${path}.source.binding`);\n }\n return input;\n}\n\nfunction interfaceRef(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"interfaceId\", \"interfaceVersion\", \"manifestUri\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"], path);\n token(input.interfaceId, `${path}.interfaceId`); token(input.interfaceVersion, `${path}.interfaceVersion`); uri(input.manifestUri, `${path}.manifestUri`);\n digest(input.manifestSha256, `${path}.manifestSha256`); digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`); digest(input.modelAbiHash, `${path}.modelAbiHash`);\n return input;\n}\n\nfunction programmable(value: unknown, path: string, moduleIds: ReadonlySet<string>): UnknownRecord {\n const input = object(value, path); exact(input, [\"moduleId\", \"entryPoint\", \"constants\"], path);\n const moduleId = token(input.moduleId, `${path}.moduleId`); if (!moduleIds.has(moduleId)) throw new TypeError(`${path}.moduleId is not in modules.`);\n token(input.entryPoint, `${path}.entryPoint`);\n const constants = object(input.constants, `${path}.constants`);\n for (const [name, value] of Object.entries(constants)) { token(name, `${path}.constants key`); if (typeof value !== \"boolean\") finite(value, `${path}.constants.${name}`); }\n return input;\n}\n\nfunction pipeline(value: unknown, path: string, moduleIds: ReadonlySet<string>): SerializableGpuPipelineDescriptor {\n const input = object(value, path); const kind = enumeration(input.kind, [\"compute\", \"render\"] as const, `${path}.kind`);\n const common = kind === \"compute\" ? [\"kind\", \"pipelineId\", \"layout\", \"compute\"] : [\"kind\", \"pipelineId\", \"layout\", \"vertex\", \"fragment\", \"vertexBuffers\", \"primitive\", \"colorTargets\", \"depthStencil\", \"multisample\"];\n exact(input, common, path); token(input.pipelineId, `${path}.pipelineId`);\n const layout = object(input.layout, `${path}.layout`); exact(layout, [\"bindGroups\"], `${path}.layout`);\n const groups = array(layout.bindGroups, `${path}.layout.bindGroups`);\n const groupIds: number[] = [];\n groups.forEach((value, groupIndex) => {\n const groupPath = `${path}.layout.bindGroups[${groupIndex}]`; const group = object(value, groupPath); exact(group, [\"group\", \"entries\"], groupPath);\n const groupId = integer(group.group, `${groupPath}.group`); groupIds.push(groupId);\n const entries = array(group.entries, `${groupPath}.entries`); const bindingIds: number[] = [];\n entries.forEach((entryValue, entryIndex) => {\n const entryPath = `${groupPath}.entries[${entryIndex}]`; const entry = object(entryValue, entryPath);\n exact(entry, [\"group\", \"binding\", \"resource\", \"visibility\"], entryPath);\n if (integer(entry.group, `${entryPath}.group`) !== groupId) throw new TypeError(`${entryPath}.group differs from its parent.`);\n bindingIds.push(integer(entry.binding, `${entryPath}.binding`)); bindingResource(entry.resource, `${entryPath}.resource`); visibility(entry.visibility, `${entryPath}.visibility`);\n });\n unique(bindingIds, String, `${groupPath}.entries`);\n });\n unique(groupIds, String, `${path}.layout.bindGroups`);\n [...groupIds].sort((a, b) => a - b).forEach((group, index) => { if (group !== index) throw new TypeError(`${path}.layout.bindGroups must be contiguous from zero.`); });\n if (kind === \"compute\") programmable(input.compute, `${path}.compute`, moduleIds);\n else {\n programmable(input.vertex, `${path}.vertex`, moduleIds); if (input.fragment !== null) programmable(input.fragment, `${path}.fragment`, moduleIds);\n array(input.vertexBuffers, `${path}.vertexBuffers`, 16).forEach((value, bufferIndex) => {\n const bufferPath = `${path}.vertexBuffers[${bufferIndex}]`; const buffer = object(value, bufferPath); exact(buffer, [\"arrayStride\", \"stepMode\", \"attributes\"], bufferPath);\n integer(buffer.arrayStride, `${bufferPath}.arrayStride`, 0, 2048); enumeration(buffer.stepMode, [\"vertex\", \"instance\"] as const, `${bufferPath}.stepMode`);\n array(buffer.attributes, `${bufferPath}.attributes`, 16).forEach((value, attributeIndex) => {\n const attributePath = `${bufferPath}.attributes[${attributeIndex}]`; const attribute = object(value, attributePath); exact(attribute, [\"format\", \"offset\", \"shaderLocation\", \"semantic\"], attributePath);\n token(attribute.format, `${attributePath}.format`); integer(attribute.offset, `${attributePath}.offset`); integer(attribute.shaderLocation, `${attributePath}.shaderLocation`); nullableToken(attribute.semantic, `${attributePath}.semantic`);\n });\n });\n const primitive = object(input.primitive, `${path}.primitive`); exact(primitive, [\"topology\", \"stripIndexFormat\", \"frontFace\", \"cullMode\", \"unclippedDepth\"], `${path}.primitive`);\n const topology = enumeration(primitive.topology, [\"point-list\", \"line-list\", \"line-strip\", \"triangle-list\", \"triangle-strip\"] as const, `${path}.primitive.topology`);\n if (primitive.stripIndexFormat !== null) enumeration(primitive.stripIndexFormat, [\"uint16\", \"uint32\"] as const, `${path}.primitive.stripIndexFormat`);\n if (primitive.stripIndexFormat !== null && topology !== \"line-strip\" && topology !== \"triangle-strip\") throw new TypeError(`${path}.primitive.stripIndexFormat is only valid for strip topologies.`);\n enumeration(primitive.frontFace, [\"ccw\", \"cw\"] as const, `${path}.primitive.frontFace`); enumeration(primitive.cullMode, [\"none\", \"front\", \"back\"] as const, `${path}.primitive.cullMode`); if (typeof primitive.unclippedDepth !== \"boolean\") throw new TypeError(`${path}.primitive.unclippedDepth must be boolean.`);\n const compare = [\"never\", \"less\", \"equal\", \"less-equal\", \"greater\", \"not-equal\", \"greater-equal\", \"always\"] as const;\n const operations = [\"keep\", \"zero\", \"replace\", \"invert\", \"increment-clamp\", \"decrement-clamp\", \"increment-wrap\", \"decrement-wrap\"] as const;\n const factors = [\"zero\", \"one\", \"src\", \"one-minus-src\", \"src-alpha\", \"one-minus-src-alpha\", \"dst\", \"one-minus-dst\", \"dst-alpha\", \"one-minus-dst-alpha\", \"src-alpha-saturated\", \"constant\", \"one-minus-constant\"] as const;\n const parseBlend = (value: unknown, label: string): void => { const component = object(value, label); exact(component, [\"operation\", \"srcFactor\", \"dstFactor\"], label); enumeration(component.operation, [\"add\", \"subtract\", \"reverse-subtract\", \"min\", \"max\"] as const, `${label}.operation`); enumeration(component.srcFactor, factors, `${label}.srcFactor`); enumeration(component.dstFactor, factors, `${label}.dstFactor`); };\n const colorTargets = array(input.colorTargets, `${path}.colorTargets`, 8); if (input.fragment === null && colorTargets.length !== 0) throw new TypeError(`${path}.colorTargets must be empty when fragment is null.`); colorTargets.forEach((value, index) => { const label = `${path}.colorTargets[${index}]`; const target = object(value, label); exact(target, [\"format\", \"blend\", \"writeMask\"], label); token(target.format, `${label}.format`); integer(target.writeMask, `${label}.writeMask`, 0, 15); if (target.blend !== null) { const blend = object(target.blend, `${label}.blend`); exact(blend, [\"color\", \"alpha\"], `${label}.blend`); parseBlend(blend.color, `${label}.blend.color`); parseBlend(blend.alpha, `${label}.blend.alpha`); } });\n const parseStencil = (value: unknown, label: string): void => { const stencil = object(value, label); exact(stencil, [\"compare\", \"failOp\", \"depthFailOp\", \"passOp\"], label); enumeration(stencil.compare, compare, `${label}.compare`); enumeration(stencil.failOp, operations, `${label}.failOp`); enumeration(stencil.depthFailOp, operations, `${label}.depthFailOp`); enumeration(stencil.passOp, operations, `${label}.passOp`); };\n if (input.depthStencil !== null) { const depth = object(input.depthStencil, `${path}.depthStencil`); exact(depth, [\"format\", \"depthWriteEnabled\", \"depthCompare\", \"stencilFront\", \"stencilBack\", \"stencilReadMask\", \"stencilWriteMask\", \"depthBias\", \"depthBiasSlopeScale\", \"depthBiasClamp\"], `${path}.depthStencil`); token(depth.format, `${path}.depthStencil.format`); if (typeof depth.depthWriteEnabled !== \"boolean\") throw new TypeError(`${path}.depthStencil.depthWriteEnabled must be boolean.`); enumeration(depth.depthCompare, compare, `${path}.depthStencil.depthCompare`); parseStencil(depth.stencilFront, `${path}.depthStencil.stencilFront`); parseStencil(depth.stencilBack, `${path}.depthStencil.stencilBack`); integer(depth.stencilReadMask, `${path}.depthStencil.stencilReadMask`); integer(depth.stencilWriteMask, `${path}.depthStencil.stencilWriteMask`); integer(depth.depthBias, `${path}.depthStencil.depthBias`, -0x8000_0000, 0x7fff_ffff); finite(depth.depthBiasSlopeScale, `${path}.depthStencil.depthBiasSlopeScale`); finite(depth.depthBiasClamp, `${path}.depthStencil.depthBiasClamp`); }\n const multisample = object(input.multisample, `${path}.multisample`); exact(multisample, [\"count\", \"mask\", \"alphaToCoverageEnabled\"], `${path}.multisample`); enumeration(multisample.count, [1, 4] as const, `${path}.multisample.count`); integer(multisample.mask, `${path}.multisample.mask`); if (typeof multisample.alphaToCoverageEnabled !== \"boolean\") throw new TypeError(`${path}.multisample.alphaToCoverageEnabled must be boolean.`); if (multisample.alphaToCoverageEnabled && multisample.count === 1) throw new TypeError(`${path}.multisample.alphaToCoverageEnabled requires multisampling.`);\n }\n return input as unknown as SerializableGpuPipelineDescriptor;\n}\n\nexport function parseSerializableGpuPipelineDescriptors(\n value: unknown,\n moduleIds: readonly string[],\n path = \"pipelines\",\n): readonly SerializableGpuPipelineDescriptor[] {\n const parsed = array(value, path).map((item, index) => pipeline(item, `${path}[${index}]`, new Set(moduleIds)));\n unique(parsed, (item) => item.pipelineId, path);\n return freeze(parsed);\n}\n\nfunction compatibleModel(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"interfaceId\", \"interfaceVersion\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"], path);\n token(input.interfaceId, `${path}.interfaceId`); token(input.interfaceVersion, `${path}.interfaceVersion`); digest(input.manifestSha256, `${path}.manifestSha256`); digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`); digest(input.modelAbiHash, `${path}.modelAbiHash`); return input;\n}\n\nfunction validationEvidenceRef(value: unknown, path: string): UnknownRecord {\n const evidence = object(value, path);\n exact(evidence, [\"evidenceId\", \"uri\", \"sha256\", \"matrixId\", \"matrixVersion\", \"matrixSha256\", \"attestationRef\"], path);\n token(evidence.evidenceId, `${path}.evidenceId`);\n uri(evidence.uri, `${path}.uri`);\n digest(evidence.sha256, `${path}.sha256`);\n token(evidence.matrixId, `${path}.matrixId`);\n token(evidence.matrixVersion, `${path}.matrixVersion`);\n digest(evidence.matrixSha256, `${path}.matrixSha256`);\n const attestation = object(evidence.attestationRef, `${path}.attestationRef`);\n exact(attestation, [\"uri\", \"sha256\"], `${path}.attestationRef`);\n uri(attestation.uri, `${path}.attestationRef.uri`);\n digest(attestation.sha256, `${path}.attestationRef.sha256`);\n if (evidence.uri === attestation.uri || evidence.sha256 === attestation.sha256) {\n throw new TypeError(`${path} evidence and attestation artifacts must have distinct URIs and digests.`);\n }\n return evidence;\n}\n\nfunction freeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n for (const child of Object.values(value as Record<string, unknown>)) freeze(child);\n return Object.freeze(value);\n}\n\nfunction reflectedRecordBindingSize(record: GpuRecordLayout): number {\n if (record.byteSize !== null) return record.byteSize;\n if (record.runtimeArrayMember === null) throw new TypeError(`Record ${record.name} has inconsistent runtime-array metadata.`);\n const member = record.members.find((candidate) => candidate.name === record.runtimeArrayMember);\n if (!member || member.type.kind !== \"array\" || member.type.count !== null) {\n throw new TypeError(`Record ${record.name} has invalid trailing runtime-array metadata.`);\n }\n const unrounded = member.offset + member.type.stride;\n return Math.ceil(unrounded / record.alignment) * record.alignment;\n}\n\n/** Strictly parses untrusted reflected interface JSON and validates all nested references. */\nexport function parseGpuInterfaceManifest(value: unknown): GpuInterfaceManifest {\n const input = object(value, \"GpuInterfaceManifest\");\n exact(input, [\"contractVersion\", \"interfaceId\", \"interfaceVersion\", \"modules\", \"records\", \"bindings\", \"entryPoints\", \"vertexInputs\", \"overrides\", \"modelAbi\", \"modelAbiHash\", \"interfaceAbiHash\", \"generatedBy\"], \"GpuInterfaceManifest\");\n if (input.contractVersion !== GPU_INTERFACE_MANIFEST_VERSION) throw new TypeError(\"Unsupported GPU interface contract version.\");\n token(input.interfaceId, \"GpuInterfaceManifest.interfaceId\"); token(input.interfaceVersion, \"GpuInterfaceManifest.interfaceVersion\");\n const moduleValues = array(input.modules, \"GpuInterfaceManifest.modules\");\n if (moduleValues.length === 0) throw new TypeError(\"GpuInterfaceManifest.modules must not be empty.\");\n const moduleIds = moduleValues.map((value, index) => { const path = `GpuInterfaceManifest.modules[${index}]`; const module = object(value, path); exact(module, [\"moduleId\", \"sha256\"], path); digest(module.sha256, `${path}.sha256`); return token(module.moduleId, `${path}.moduleId`); });\n unique(moduleIds, String, \"GpuInterfaceManifest.modules\"); const moduleSet = new Set(moduleIds);\n const recordValues = array(input.records, \"GpuInterfaceManifest.records\"); const parsedRecords = recordValues.map((item, index) => recordLayout(item, `GpuInterfaceManifest.records[${index}]`));\n unique(parsedRecords, (item) => item.name, \"GpuInterfaceManifest.records\"); const records = new Map(parsedRecords.map((item) => [item.name, item]));\n for (const record of parsedRecords) for (const member of record.members) {\n const visit = (type: GpuTypeLayout): void => { if (type.kind === \"record\") { const referenced = records.get(type.recordName); if (!referenced) throw new TypeError(`Record ${record.name} references missing ${type.recordName}.`); if (type.alignment !== referenced.alignment || type.byteSize !== referenced.byteSize) throw new TypeError(`Record reference ${record.name}.${member.name} has stale layout metadata.`); } if (type.kind === \"array\") visit(type.element); };\n visit(member.type);\n }\n const bindingValues = array(input.bindings, \"GpuInterfaceManifest.bindings\"); const bindingKeys: string[] = [];\n bindingValues.forEach((item, index) => { const path = `GpuInterfaceManifest.bindings[${index}]`; const parsed = binding(item, path); const moduleId = String(parsed.moduleId); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); bindingKeys.push(`${moduleId}:${parsed.group}:${parsed.binding}`); const resource = parsed.resource as GpuBindingResourceLayout; if (resource.kind === \"buffer\" && resource.recordName) { const record = records.get(resource.recordName); if (!record) throw new TypeError(`${path} references missing record.`); if (resource.minimumBindingSize !== reflectedRecordBindingSize(record)) throw new TypeError(`${path}.resource.minimumBindingSize differs from its reflected record.`); if (record.runtimeArrayMember !== null && resource.addressSpace !== \"storage\") throw new TypeError(`${path} exposes a runtime-sized array outside storage.`); } });\n unique(bindingKeys, String, \"GpuInterfaceManifest.bindings\"); const bindingSet = new Set(bindingKeys);\n const overrideValues = array(input.overrides, \"GpuInterfaceManifest.overrides\"); const overrideKeys: string[] = []; const overrideIds: string[] = [];\n overrideValues.forEach((item, index) => { const path = `GpuInterfaceManifest.overrides[${index}]`; const override = object(item, path); exact(override, [\"moduleId\", \"name\", \"id\", \"type\", \"defaultValue\"], path); const moduleId = token(override.moduleId, `${path}.moduleId`); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); const name = token(override.name, `${path}.name`); overrideKeys.push(`${moduleId}:${name}`); if (override.id !== null) overrideIds.push(`${moduleId}:${integer(override.id, `${path}.id`)}`); enumeration(override.type, [\"bool\", \"i32\", \"u32\", \"f32\", \"f16\"] as const, `${path}.type`); if (override.defaultValue !== null && typeof override.defaultValue !== \"boolean\") finite(override.defaultValue, `${path}.defaultValue`); });\n unique(overrideKeys, String, \"GpuInterfaceManifest.overrides\"); unique(overrideIds, String, \"GpuInterfaceManifest.overrides ids\"); const overrideSet = new Set(overrideKeys);\n const entryValues = array(input.entryPoints, \"GpuInterfaceManifest.entryPoints\"); const entryKeys: string[] = [];\n if (entryValues.length === 0) throw new TypeError(\"GpuInterfaceManifest.entryPoints must not be empty.\");\n entryValues.forEach((item, index) => { const path = `GpuInterfaceManifest.entryPoints[${index}]`; const entry = object(item, path); exact(entry, [\"moduleId\", \"name\", \"stage\", \"inputs\", \"outputs\", \"bindingKeys\", \"overrideNames\", \"workgroupSize\", \"workgroupStorageSize\"], path); const moduleId = token(entry.moduleId, `${path}.moduleId`); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); const stage = enumeration(entry.stage, stages, `${path}.stage`); entryKeys.push(`${moduleId}:${stage}:${token(entry.name, `${path}.name`)}`); for (const ioKey of [\"inputs\", \"outputs\"] as const) { const ios = array(entry[ioKey], `${path}.${ioKey}`).map((value, ioIndex) => entryIo(value, `${path}.${ioKey}[${ioIndex}]`)); unique(ios, (io) => `${io.locationKind}:${io.location}`, `${path}.${ioKey}`); } const resources = tokenArray(entry.bindingKeys, `${path}.bindingKeys`); resources.forEach((key) => { if (!bindingSet.has(key)) throw new TypeError(`${path}.bindingKeys references missing ${key}.`); }); const names = tokenArray(entry.overrideNames, `${path}.overrideNames`); names.forEach((name) => { if (!overrideSet.has(`${moduleId}:${name}`)) throw new TypeError(`${path}.overrideNames references missing ${name}.`); }); if (stage === \"compute\") { const dimensions = array(entry.workgroupSize, `${path}.workgroupSize`, 3); if (dimensions.length !== 3) throw new TypeError(`${path}.workgroupSize must have three dimensions.`); dimensions.forEach((value, dimensionIndex) => { const dimensionPath = `${path}.workgroupSize[${dimensionIndex}]`; const dimension = object(value, dimensionPath); const kind = enumeration(dimension.kind, [\"literal\", \"override\"] as const, `${dimensionPath}.kind`); if (kind === \"literal\") { exact(dimension, [\"kind\", \"value\"], dimensionPath); integer(dimension.value, `${dimensionPath}.value`, 1); } else { exact(dimension, [\"kind\", \"name\"], dimensionPath); const name = token(dimension.name, `${dimensionPath}.name`); if (!overrideSet.has(`${moduleId}:${name}`)) throw new TypeError(`${dimensionPath} references missing override.`); } }); integer(entry.workgroupStorageSize, `${path}.workgroupStorageSize`); } else if (entry.workgroupSize !== null || entry.workgroupStorageSize !== null) throw new TypeError(`${path} workgroup metadata is only valid for compute.`); });\n unique(entryKeys, String, \"GpuInterfaceManifest.entryPoints\"); const entrySet = new Set(entryKeys);\n const vertexValues = array(input.vertexInputs, \"GpuInterfaceManifest.vertexInputs\"); const vertexKeys: string[] = []; const parsedVertices: UnknownRecord[] = [];\n vertexValues.forEach((item, index) => { const path = `GpuInterfaceManifest.vertexInputs[${index}]`; const vertex = vertexInput(item, path); parsedVertices.push(vertex); if (!entrySet.has(`${vertex.moduleId}:vertex:${vertex.entryPoint}`)) throw new TypeError(`${path} references missing vertex entry point.`); vertexKeys.push(`${vertex.pipelineId}:${vertex.shaderLocation}`); }); unique(vertexKeys, String, \"GpuInterfaceManifest.vertexInputs\");\n const model = object(input.modelAbi, \"GpuInterfaceManifest.modelAbi\"); exact(model, [\"recordNames\", \"bindings\", \"vertexInputs\", \"semantics\"], \"GpuInterfaceManifest.modelAbi\");\n tokenArray(model.recordNames, \"GpuInterfaceManifest.modelAbi.recordNames\").forEach((name) => { if (!records.has(name)) throw new TypeError(`Model ABI references missing record ${name}.`); });\n const modelBindings = array(model.bindings, \"GpuInterfaceManifest.modelAbi.bindings\").map((item, index) => binding(item, `GpuInterfaceManifest.modelAbi.bindings[${index}]`, false));\n for (const [index, projected] of modelBindings.entries()) { const source = projected.source as UnknownRecord; const reflectedIndex = bindingKeys.indexOf(`${source.moduleId}:${source.group}:${source.binding}`); const reflected = reflectedIndex < 0 ? null : object(bindingValues[reflectedIndex], `GpuInterfaceManifest.bindings[${reflectedIndex}]`); if (!reflected || canonicalizeForValidation(reflected.resource) !== canonicalizeForValidation(projected.resource)) throw new TypeError(`GpuInterfaceManifest.modelAbi.bindings[${index}] differs from its reflected source.`); const resource = projected.resource as GpuBindingResourceLayout; if (resource.kind === \"buffer\" && resource.recordName === null) throw new TypeError(`GpuInterfaceManifest.modelAbi.bindings[${index}] must use a named WGSL record root.`); }\n const modelBindingSemantics = modelBindings.filter((item) => item.semantic !== null).map((item) => String(item.semantic)); unique(modelBindingSemantics, String, \"GpuInterfaceManifest.modelAbi.bindings semantics\");\n const modelVertices = array(model.vertexInputs, \"GpuInterfaceManifest.modelAbi.vertexInputs\"); const parsedModelVertices = modelVertices.map((item, index) => vertexInput(item, `GpuInterfaceManifest.modelAbi.vertexInputs[${index}]`, true)); const modelVertexSemantics = parsedModelVertices.map((item) => String(item.semantic)); unique(modelVertexSemantics, String, \"GpuInterfaceManifest.modelAbi.vertexInputs\");\n for (const [index, projected] of parsedModelVertices.entries()) { const source = projected.source as UnknownRecord; const reflected = parsedVertices.find((candidate) => candidate.pipelineId === source.pipelineId && candidate.shaderLocation === source.shaderLocation); if (!reflected || [\"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"].some((key) => reflected[key] !== projected[key])) throw new TypeError(`GpuInterfaceManifest.modelAbi.vertexInputs[${index}] differs from its reflected source.`); }\n const semantics = array(model.semantics, \"GpuInterfaceManifest.modelAbi.semantics\").map((item, index) => semantic(item, `GpuInterfaceManifest.modelAbi.semantics[${index}]`)); unique(semantics, (item) => String(item.semantic), \"GpuInterfaceManifest.modelAbi.semantics\");\n for (const projection of semantics) {\n const source = projection.source as UnknownRecord; const semanticName = String(projection.semantic);\n if (source.kind === \"record-member\") {\n let current = records.get(String(source.recordName)); if (!current) throw new TypeError(`Semantic ${semanticName} references missing record.`);\n for (const [index, memberName] of (source.memberPath as string[]).entries()) { const member = current.members.find((candidate) => candidate.name === memberName); if (!member) throw new TypeError(`Semantic ${semanticName} references missing member ${memberName}.`); if (index < (source.memberPath as string[]).length - 1) { if (member.type.kind !== \"record\") throw new TypeError(`Semantic ${semanticName} traverses a non-record member.`); current = records.get(member.type.recordName); if (!current) throw new TypeError(`Semantic ${semanticName} references missing nested record.`); } }\n } else if (source.kind === \"vertex-attribute\") {\n const vertex = parsedVertices.find((candidate) => candidate.pipelineId === source.pipelineId && candidate.shaderLocation === source.shaderLocation);\n const modelVertex = parsedModelVertices.find((candidate) => candidate.semantic === semanticName);\n const modelVertexSource = modelVertex?.source as UnknownRecord | undefined;\n if (!vertex || vertex.semantic !== semanticName || modelVertexSemantics.filter((item) => item === semanticName).length !== 1\n || !modelVertexSource || modelVertexSource.pipelineId !== source.pipelineId || modelVertexSource.shaderLocation !== source.shaderLocation) throw new TypeError(`Semantic ${semanticName} does not resolve to exactly one matching model vertex stream.`);\n } else {\n const key = `${source.moduleId}:${source.group}:${source.binding}`; if (!bindingSet.has(key)) throw new TypeError(`Semantic ${semanticName} references missing binding ${key}.`);\n const modelBinding = modelBindings.find((candidate) => candidate.semantic === semanticName);\n if (modelBindingSemantics.filter((item) => item === semanticName).length !== 1 || !modelBinding\n || canonicalizeForValidation(modelBinding.source) !== canonicalizeForValidation({ moduleId: source.moduleId, group: source.group, binding: source.binding })) throw new TypeError(`Semantic ${semanticName} does not resolve to exactly one matching model binding.`);\n }\n }\n for (const semanticName of [...modelVertexSemantics, ...modelBindingSemantics]) if (semantics.filter((item) => item.semantic === semanticName).length !== 1) throw new TypeError(`Model semantic ${semanticName} requires exactly one projection.`);\n digest(input.modelAbiHash, \"GpuInterfaceManifest.modelAbiHash\"); digest(input.interfaceAbiHash, \"GpuInterfaceManifest.interfaceAbiHash\");\n const generated = object(input.generatedBy, \"GpuInterfaceManifest.generatedBy\"); exact(generated, [\"packageVersion\", \"reflector\", \"reflectorVersion\"], \"GpuInterfaceManifest.generatedBy\"); token(generated.packageVersion, \"GpuInterfaceManifest.generatedBy.packageVersion\"); if (generated.reflector !== \"wgsl_reflect\" || generated.reflectorVersion !== \"1.5.0\") throw new TypeError(\"Unsupported reflector provenance.\");\n return freeze(input as unknown as GpuInterfaceManifest);\n}\n\n/** Strictly parses an immutable shader-version manifest. */\nexport function parseShaderVersionManifest(value: unknown): ShaderVersionManifest {\n const input = object(value, \"ShaderVersionManifest\"); exact(input, [\"contractVersion\", \"shaderId\", \"version\", \"modules\", \"gpuInterface\", \"pipelines\", \"renderRoles\", \"compatibleModelInterfaces\", \"requirements\", \"shaderAbiHash\", \"validationEvidence\", \"additionalValidationEvidence\"], \"ShaderVersionManifest\");\n if (input.contractVersion !== SHADER_VERSION_MANIFEST_VERSION) throw new TypeError(\"Unsupported shader manifest contract version.\");\n token(input.shaderId, \"ShaderVersionManifest.shaderId\"); token(input.version, \"ShaderVersionManifest.version\");\n const moduleValues = array(input.modules, \"ShaderVersionManifest.modules\"); if (moduleValues.length === 0) throw new TypeError(\"ShaderVersionManifest.modules must not be empty.\"); const moduleIds = moduleValues.map((item, index) => { const path = `ShaderVersionManifest.modules[${index}]`; const module = object(item, path); exact(module, [\"moduleId\", \"uri\", \"byteLength\", \"sha256\", \"contentType\"], path); uri(module.uri, `${path}.uri`); integer(module.byteLength, `${path}.byteLength`, 1); digest(module.sha256, `${path}.sha256`); if (module.contentType !== \"text/wgsl; charset=utf-8\") throw new TypeError(`${path}.contentType is not canonical WGSL.`); return token(module.moduleId, `${path}.moduleId`); }); unique(moduleIds, String, \"ShaderVersionManifest.modules\"); const moduleSet = new Set(moduleIds);\n const shaderInterface = interfaceRef(input.gpuInterface, \"ShaderVersionManifest.gpuInterface\");\n const pipelines = array(input.pipelines, \"ShaderVersionManifest.pipelines\").map((item, index) => pipeline(item, `ShaderVersionManifest.pipelines[${index}]`, moduleSet)); if (pipelines.length === 0) throw new TypeError(\"ShaderVersionManifest.pipelines must not be empty.\"); unique(pipelines, (item) => item.pipelineId, \"ShaderVersionManifest.pipelines\"); const pipelineIds = new Set(pipelines.map((item) => item.pipelineId));\n const roleValues = array(input.renderRoles, \"ShaderVersionManifest.renderRoles\", 5); if (roleValues.length === 0) throw new TypeError(\"ShaderVersionManifest.renderRoles must not be empty.\"); const roleNames: string[] = []; const assigned = new Set<string>(); roleValues.forEach((item, index) => { const path = `ShaderVersionManifest.renderRoles[${index}]`; const role = object(item, path); exact(role, [\"role\", \"pipelineIds\"], path); roleNames.push(enumeration(role.role, roles, `${path}.role`)); const ids = tokenArray(role.pipelineIds, `${path}.pipelineIds`); if (ids.length === 0) throw new TypeError(`${path}.pipelineIds must not be empty.`); ids.forEach((id) => { if (!pipelineIds.has(id)) throw new TypeError(`${path} references missing pipeline ${id}.`); assigned.add(id); }); }); unique(roleNames, String, \"ShaderVersionManifest.renderRoles\"); if (assigned.size !== pipelineIds.size) throw new TypeError(\"Every pipeline must belong to at least one render role.\");\n const compatible = array(input.compatibleModelInterfaces, \"ShaderVersionManifest.compatibleModelInterfaces\").map((item, index) => compatibleModel(item, `ShaderVersionManifest.compatibleModelInterfaces[${index}]`)); if (compatible.length === 0) throw new TypeError(\"ShaderVersionManifest.compatibleModelInterfaces must not be empty.\"); unique(compatible, (item) => `${item.interfaceId}:${item.interfaceVersion}:${item.manifestSha256}:${item.interfaceAbiHash}:${item.modelAbiHash}`, \"ShaderVersionManifest.compatibleModelInterfaces\"); if (compatible.some((item) => item.modelAbiHash !== shaderInterface.modelAbiHash)) throw new TypeError(\"ShaderVersionManifest compatible model ABI hashes must equal gpuInterface.modelAbiHash.\");\n const requirements = object(input.requirements, \"ShaderVersionManifest.requirements\"); exact(requirements, [\"semantics\", \"features\", \"limits\", \"formats\"], \"ShaderVersionManifest.requirements\"); tokenArray(requirements.semantics, \"ShaderVersionManifest.requirements.semantics\"); tokenArray(requirements.features, \"ShaderVersionManifest.requirements.features\"); tokenArray(requirements.formats, \"ShaderVersionManifest.requirements.formats\"); const limits = array(requirements.limits, \"ShaderVersionManifest.requirements.limits\"); const limitNames: string[] = []; limits.forEach((item, index) => { const path = `ShaderVersionManifest.requirements.limits[${index}]`; const limit = object(item, path); exact(limit, [\"name\", \"comparator\", \"value\"], path); const name = token(limit.name, `${path}.name`); limitNames.push(name); enumeration(limit.comparator, [\"at-least\", \"at-most\"] as const, `${path}.comparator`); const value = finite(limit.value, `${path}.value`); if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${path}.value must be a non-negative safe integer.`); }); unique(limitNames, String, \"ShaderVersionManifest.requirements.limits\");\n validatePipelineDerivedRequirements({\n requirements: input.requirements as unknown as ShaderVersionManifest[\"requirements\"],\n pipelines,\n });\n digest(input.shaderAbiHash, \"ShaderVersionManifest.shaderAbiHash\");\n const universalEvidence = validationEvidenceRef(input.validationEvidence, \"ShaderVersionManifest.validationEvidence\");\n if (!SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n universalEvidence.matrixId === policy.matrixId\n && universalEvidence.matrixVersion === policy.matrixVersion\n && universalEvidence.matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(\"ShaderVersionManifest.validationEvidence is not bound to a supported universal stable-WebGPU matrix policy.\");\n }\n const additionalEvidence = array(input.additionalValidationEvidence, \"ShaderVersionManifest.additionalValidationEvidence\");\n const scopedEvidence = additionalEvidence.map((item, index) => {\n const path = `ShaderVersionManifest.additionalValidationEvidence[${index}]`;\n const scoped = object(item, path);\n exact(scoped, [\"scope\", \"evidence\"], path);\n const scope = token(scoped.scope, `${path}.scope`);\n if (scope === \"universal\") throw new TypeError(`${path}.scope universal is reserved for validationEvidence.`);\n const evidence = validationEvidenceRef(scoped.evidence, `${path}.evidence`);\n if (evidence.matrixSha256 === universalEvidence.matrixSha256) {\n throw new TypeError(`${path}.evidence must use an additive matrix policy, not the universal matrix policy.`);\n }\n return { scope, evidence };\n });\n unique(scopedEvidence, (item) => item.scope, \"ShaderVersionManifest.additionalValidationEvidence scopes\");\n unique(scopedEvidence, (item) => String(item.evidence.matrixSha256), \"ShaderVersionManifest.additionalValidationEvidence matrix policies\");\n const evidenceIds = new Set([String(universalEvidence.evidenceId)]);\n const artifactUris = new Set([\n String(universalEvidence.uri),\n String((universalEvidence.attestationRef as UnknownRecord).uri),\n ]);\n const artifactDigests = new Set([\n String(universalEvidence.sha256),\n String((universalEvidence.attestationRef as UnknownRecord).sha256),\n ]);\n for (const [index, item] of scopedEvidence.entries()) {\n const path = `ShaderVersionManifest.additionalValidationEvidence[${index}].evidence`;\n if (evidenceIds.has(String(item.evidence.evidenceId))) throw new TypeError(`${path} reuses a universal or supplemental evidence ID.`);\n evidenceIds.add(String(item.evidence.evidenceId));\n const attestation = item.evidence.attestationRef as UnknownRecord;\n for (const candidate of [item.evidence.uri, attestation.uri]) {\n if (artifactUris.has(String(candidate))) throw new TypeError(`${path} reuses a universal or supplemental evidence/attestation URI.`);\n artifactUris.add(String(candidate));\n }\n for (const candidate of [item.evidence.sha256, attestation.sha256]) {\n if (artifactDigests.has(String(candidate))) throw new TypeError(`${path} reuses a universal or supplemental evidence/attestation digest.`);\n artifactDigests.add(String(candidate));\n }\n }\n for (const [index, item] of scopedEvidence.entries()) if (!SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n item.scope === policy.scope\n && item.evidence.matrixId === policy.matrixId\n && item.evidence.matrixVersion === policy.matrixVersion\n && item.evidence.matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(`ShaderVersionManifest.additionalValidationEvidence[${index}].evidence is not bound to a supported additive WebGPU matrix policy.`);\n }\n return freeze(input as unknown as ShaderVersionManifest);\n}\n\n/** Strictly parses the cycle-free shader manifest qualified before evidence attachment. */\nexport function parseShaderVersionManifestCore(value: unknown): ShaderVersionManifestCore {\n const input = object(value, \"ShaderVersionManifestCore\");\n if (\"validationEvidence\" in input || \"additionalValidationEvidence\" in input) {\n throw new TypeError(\"ShaderVersionManifestCore must not contain validationEvidence or additionalValidationEvidence.\");\n }\n const parsed = parseShaderVersionManifest({\n ...input,\n validationEvidence: {\n evidenceId: \"pending\",\n uri: \"https://catalog.invalid/evidence/pending.json\",\n sha256: \"0\".repeat(64),\n matrixId: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixId,\n matrixVersion: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixVersion,\n matrixSha256: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixSha256,\n attestationRef: {\n uri: \"https://catalog.invalid/evidence/pending.attestation-ref.json\",\n sha256: \"1\".repeat(64),\n },\n },\n additionalValidationEvidence: [],\n });\n const { validationEvidence, additionalValidationEvidence, ...core } = parsed;\n void validationEvidence;\n void additionalValidationEvidence;\n return freeze(core);\n}\n\n/** Strictly parses a rendering-style profile with exact immutable shader references. */\nexport function parseShaderStyleProfileManifest(value: unknown): ShaderStyleProfileManifest {\n const input = object(value, \"ShaderStyleProfileManifest\"); exact(input, [\"contractVersion\", \"profileId\", \"version\", \"style\", \"roles\", \"compatibleModelInterfaces\", \"requiredSemantics\", \"requiredValidationScopes\"], \"ShaderStyleProfileManifest\");\n if (input.contractVersion !== SHADER_STYLE_PROFILE_MANIFEST_VERSION) throw new TypeError(\"Unsupported style-profile contract version.\");\n token(input.profileId, \"ShaderStyleProfileManifest.profileId\"); token(input.version, \"ShaderStyleProfileManifest.version\"); token(input.style, \"ShaderStyleProfileManifest.style\");\n const roleValues = array(input.roles, \"ShaderStyleProfileManifest.roles\", 5); if (roleValues.length === 0) throw new TypeError(\"ShaderStyleProfileManifest.roles must not be empty.\"); const roleNames: string[] = []; roleValues.forEach((item, index) => { const path = `ShaderStyleProfileManifest.roles[${index}]`; const role = object(item, path); exact(role, [\"role\", \"shader\"], path); roleNames.push(enumeration(role.role, roles, `${path}.role`)); const shader = object(role.shader, `${path}.shader`); exact(shader, [\"shaderId\", \"version\", \"manifestUri\", \"manifestSha256\"], `${path}.shader`); token(shader.shaderId, `${path}.shader.shaderId`); token(shader.version, `${path}.shader.version`); uri(shader.manifestUri, `${path}.shader.manifestUri`); digest(shader.manifestSha256, `${path}.shader.manifestSha256`); }); unique(roleNames, String, \"ShaderStyleProfileManifest.roles\");\n const compatible = array(input.compatibleModelInterfaces, \"ShaderStyleProfileManifest.compatibleModelInterfaces\").map((item, index) => compatibleModel(item, `ShaderStyleProfileManifest.compatibleModelInterfaces[${index}]`)); if (compatible.length === 0) throw new TypeError(\"ShaderStyleProfileManifest.compatibleModelInterfaces must not be empty.\"); unique(compatible, (item) => `${item.interfaceId}:${item.interfaceVersion}:${item.manifestSha256}:${item.interfaceAbiHash}:${item.modelAbiHash}`, \"ShaderStyleProfileManifest.compatibleModelInterfaces\"); tokenArray(input.requiredSemantics, \"ShaderStyleProfileManifest.requiredSemantics\");\n const requiredValidationScopes = array(input.requiredValidationScopes, \"ShaderStyleProfileManifest.requiredValidationScopes\").map((item, index) => {\n const path = `ShaderStyleProfileManifest.requiredValidationScopes[${index}]`;\n const requirement = object(item, path);\n exact(requirement, [\"scope\", \"matrixId\", \"matrixVersion\", \"matrixSha256\"], path);\n const scope = token(requirement.scope, `${path}.scope`);\n if (scope === \"universal\") throw new TypeError(`${path}.scope must not use the reserved universal scope.`);\n token(requirement.matrixId, `${path}.matrixId`);\n token(requirement.matrixVersion, `${path}.matrixVersion`);\n const matrixSha256 = digest(requirement.matrixSha256, `${path}.matrixSha256`);\n if (SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) => policy.matrixSha256 === matrixSha256)) {\n throw new TypeError(`${path} must require an additive matrix policy, not the universal matrix policy.`);\n }\n if (!SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n scope === policy.scope\n && requirement.matrixId === policy.matrixId\n && requirement.matrixVersion === policy.matrixVersion\n && matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(`${path} is not a supported additive WebGPU matrix policy.`);\n }\n return requirement;\n });\n unique(requiredValidationScopes, (item) => String(item.scope), \"ShaderStyleProfileManifest.requiredValidationScopes scopes\");\n unique(requiredValidationScopes, (item) => String(item.matrixSha256), \"ShaderStyleProfileManifest.requiredValidationScopes matrix policies\");\n return freeze(input as unknown as ShaderStyleProfileManifest);\n}\n\n/** Strictly parses the model-facing GPU compatibility fields published with a model version. */\nexport function parseModelGpuCompatibilityDescriptor(value: unknown): ModelGpuCompatibilityDescriptor {\n const input = object(value, \"ModelGpuCompatibilityDescriptor\");\n exact(input, [\"modelId\", \"version\", \"gpuInterface\", \"modelAbiHash\", \"providedSemantics\", \"defaultStyleProfile\"], \"ModelGpuCompatibilityDescriptor\");\n token(input.modelId, \"ModelGpuCompatibilityDescriptor.modelId\");\n token(input.version, \"ModelGpuCompatibilityDescriptor.version\");\n const gpuInterface = interfaceRef(input.gpuInterface, \"ModelGpuCompatibilityDescriptor.gpuInterface\");\n const modelAbiHash = digest(input.modelAbiHash, \"ModelGpuCompatibilityDescriptor.modelAbiHash\");\n if (gpuInterface.modelAbiHash !== modelAbiHash) throw new TypeError(\"ModelGpuCompatibilityDescriptor.gpuInterface.modelAbiHash differs from modelAbiHash.\");\n tokenArray(input.providedSemantics, \"ModelGpuCompatibilityDescriptor.providedSemantics\");\n if (input.defaultStyleProfile !== null) { const profile = object(input.defaultStyleProfile, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile\"); exact(profile, [\"profileId\", \"version\", \"manifestUri\", \"manifestSha256\"], \"ModelGpuCompatibilityDescriptor.defaultStyleProfile\"); token(profile.profileId, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.profileId\"); token(profile.version, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.version\"); uri(profile.manifestUri, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestUri\"); digest(profile.manifestSha256, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestSha256\"); }\n return freeze(input as unknown as ModelGpuCompatibilityDescriptor);\n}\n\n/** Strictly parses a qualification fixture that binds one immutable model descriptor. */\nexport function parseShaderQualificationModelCompatibilityFixture(value: unknown): ShaderQualificationModelCompatibilityFixture {\n const input = object(value, \"ShaderQualificationModelCompatibilityFixture\");\n exact(input, [\"contractVersion\", \"fixtureId\", \"model\"], \"ShaderQualificationModelCompatibilityFixture\");\n if (input.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError(\"Unsupported model compatibility fixture version.\");\n token(input.fixtureId, \"ShaderQualificationModelCompatibilityFixture.fixtureId\");\n parseModelGpuCompatibilityDescriptor(input.model);\n return freeze(input as unknown as ShaderQualificationModelCompatibilityFixture);\n}\n\nexport function parseJsonBytes(bytes: Uint8Array, label: string): unknown {\n try { return JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes)); }\n catch (cause) { throw new TypeError(`${label} is not valid UTF-8 JSON.`, { cause }); }\n}\n","import {\n SHADER_COMPILE_UNIT_VERSION,\n type ShaderCompileUnitInventory,\n type ShaderCompileUnitManifest,\n type ShaderDiagnostic,\n type ShaderQualificationBundleManifest,\n type ShaderResult,\n} from \"../contracts.js\";\nimport { canonicalizeGpuContract } from \"../canonical-json.js\";\nimport { asSha256Hex } from \"../hash.js\";\nimport { parseSerializableGpuPipelineDescriptors } from \"../manifest-validation.js\";\n\nconst SAFE_PATH = /^(?!\\/)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)*$/u;\n\nfunction issue(code: ShaderDiagnostic[\"code\"], message: string, path?: string): ShaderDiagnostic {\n return { code, severity: \"error\", message, ...(path ? { path } : {}) };\n}\n\nfunction object(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction exactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n const expected = new Set(keys);\n return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => key in value);\n}\n\nfunction safeToken(value: unknown): value is string {\n return typeof value === \"string\" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes(\"..\");\n}\n\nfunction validSha(value: unknown): boolean {\n try {\n asSha256Hex(String(value));\n return true;\n } catch {\n return false;\n }\n}\n\n/** Identity helper that makes compile-unit declarations readonly at the call site. */\nexport function defineShaderCompileUnit<const T extends ShaderCompileUnitManifest>(unit: T): T {\n return Object.freeze(unit);\n}\n\n/** Validates that every declared WGSL fragment belongs to at least one concrete compile unit. */\nexport function validateCompileUnitInventory(\n value: unknown,\n): ShaderResult<ShaderCompileUnitInventory> {\n const envelope = object(value);\n const candidate = envelope && \"inventory\" in envelope\n ? object((value as Partial<ShaderQualificationBundleManifest>).inventory)\n : envelope;\n const diagnostics: ShaderDiagnostic[] = [];\n if (!candidate || !exactKeys(candidate, [\"contractVersion\", \"fragments\", \"compileUnits\"])) {\n return { ok: false, diagnostics: [issue(\"invalid-contract\", \"Compile-unit inventory has unknown or missing fields.\")] };\n }\n if (candidate.contractVersion !== SHADER_COMPILE_UNIT_VERSION) {\n diagnostics.push(issue(\"invalid-contract\", \"Unsupported compile-unit inventory version.\", \"contractVersion\"));\n }\n if (!Array.isArray(candidate.fragments) || !Array.isArray(candidate.compileUnits)) {\n diagnostics.push(issue(\"invalid-contract\", \"Inventory fragments and compileUnits must be arrays.\"));\n return { ok: false, diagnostics };\n }\n if (candidate.fragments.length > 10000 || candidate.compileUnits.length > 10000) {\n diagnostics.push(issue(\"invalid-contract\", \"Inventory exceeds the bounded item count.\"));\n return { ok: false, diagnostics };\n }\n const fragmentIds = new Set<string>();\n for (const [index, raw] of candidate.fragments.entries()) {\n const path = `fragments[${index}]`;\n const fragment = object(raw);\n if (!fragment || !exactKeys(fragment, [\"fragmentId\", \"path\", \"sha256\"])) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment has unknown or missing fields.\", path));\n continue;\n }\n if (!safeToken(fragment.fragmentId) || fragmentIds.has(fragment.fragmentId)) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment IDs must be unique safe tokens.\", `${path}.fragmentId`));\n } else fragmentIds.add(fragment.fragmentId);\n if (typeof fragment.path !== \"string\" || !SAFE_PATH.test(fragment.path) || !fragment.path.endsWith(\".wgsl\")) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment path must remain inside the data-only bundle.\", `${path}.path`));\n }\n if (!validSha(fragment.sha256)) diagnostics.push(issue(\"invalid-contract\", \"Fragment digest is invalid.\", `${path}.sha256`));\n }\n const covered = new Set<string>();\n const unitIds = new Set<string>();\n for (const [index, raw] of candidate.compileUnits.entries()) {\n const path = `compileUnits[${index}]`;\n const unit = object(raw);\n const keys = [\n \"contractVersion\", \"compileUnitId\", \"fragmentIds\", \"modules\", \"entryPoints\", \"pipelines\", \"interfaceRef\",\n \"overrideValues\", \"qualificationFixture\",\n ];\n if (!unit || !exactKeys(unit, keys)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit has unknown or missing fields.\", path));\n continue;\n }\n if (unit.contractVersion !== SHADER_COMPILE_UNIT_VERSION || !safeToken(unit.compileUnitId) || unitIds.has(String(unit.compileUnitId))) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit identity/version is invalid or duplicated.\", path));\n } else unitIds.add(unit.compileUnitId);\n if (!Array.isArray(unit.fragmentIds) || unit.fragmentIds.length === 0 || new Set(unit.fragmentIds).size !== unit.fragmentIds.length) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires unique fragment IDs.\", `${path}.fragmentIds`));\n } else {\n for (const id of unit.fragmentIds) {\n if (typeof id !== \"string\" || !fragmentIds.has(id)) diagnostics.push(issue(\"invalid-contract\", `Compile unit references unknown fragment ${String(id)}.`, `${path}.fragmentIds`));\n else covered.add(id);\n }\n }\n if (!Array.isArray(unit.modules) || unit.modules.length === 0 || !Array.isArray(unit.entryPoints) || unit.entryPoints.length === 0 || !Array.isArray(unit.pipelines) || unit.pipelines.length === 0) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires modules, entry points, and explicit pipelines.\", path));\n }\n const modules = Array.isArray(unit.modules) ? unit.modules : [];\n const moduleIds = new Set<string>();\n for (const [moduleIndex, moduleRaw] of modules.entries()) {\n const module = object(moduleRaw);\n if (!module || !exactKeys(module, [\"moduleId\", \"sha256\", \"assembly\"]) || !safeToken(module.moduleId) || moduleIds.has(String(module.moduleId)) || !validSha(module.sha256)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit module reference is invalid or duplicated.\", `${path}.modules[${moduleIndex}]`));\n } else {\n moduleIds.add(module.moduleId);\n const assembly = object(module.assembly);\n if (!assembly || !exactKeys(assembly, [\"kind\", \"fragmentIds\"]) || assembly.kind !== \"concat-v1\" || !Array.isArray(assembly.fragmentIds) || assembly.fragmentIds.length === 0 || new Set(assembly.fragmentIds).size !== assembly.fragmentIds.length || assembly.fragmentIds.some((id) => typeof id !== \"string\" || !fragmentIds.has(id))) {\n diagnostics.push(issue(\"invalid-contract\", \"Module requires a non-vacuous concat-v1 recipe over exact inventory fragments.\", `${path}.modules[${moduleIndex}].assembly`));\n }\n }\n }\n const recipeFragments = new Set(modules.flatMap((moduleRaw) => {\n const module = object(moduleRaw); const assembly = module ? object(module.assembly) : null;\n return Array.isArray(assembly?.fragmentIds) ? assembly.fragmentIds.filter((id): id is string => typeof id === \"string\") : [];\n }));\n if (Array.isArray(unit.fragmentIds) && ([...recipeFragments].sort().join(\"\\n\") !== [...unit.fragmentIds].sort().join(\"\\n\"))) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit fragment claims must exactly equal deterministic assembly inputs.\", `${path}.fragmentIds`));\n }\n const entryKeys = new Set<string>();\n if (Array.isArray(unit.entryPoints)) for (const [entryIndex, entryRaw] of unit.entryPoints.entries()) {\n const entry = object(entryRaw); const entryPath = `${path}.entryPoints[${entryIndex}]`;\n if (!entry || !exactKeys(entry, [\"moduleId\", \"name\", \"stage\"]) || !safeToken(entry.moduleId) || !moduleIds.has(String(entry.moduleId)) || !safeToken(entry.name) || ![\"vertex\", \"fragment\", \"compute\"].includes(String(entry.stage))) diagnostics.push(issue(\"invalid-contract\", \"Compile-unit entry point is invalid.\", entryPath));\n else { const key = `${entry.moduleId}:${entry.stage}:${entry.name}`; if (entryKeys.has(key)) diagnostics.push(issue(\"invalid-contract\", \"Compile-unit entry point is duplicated.\", entryPath)); entryKeys.add(key); }\n }\n try {\n const pipelines = parseSerializableGpuPipelineDescriptors(unit.pipelines, [...moduleIds], `${path}.pipelines`);\n const usedEntries = new Set<string>();\n for (const pipeline of pipelines) {\n if (pipeline.kind === \"compute\") usedEntries.add(`${pipeline.compute.moduleId}:compute:${pipeline.compute.entryPoint}`);\n else { usedEntries.add(`${pipeline.vertex.moduleId}:vertex:${pipeline.vertex.entryPoint}`); if (pipeline.fragment) usedEntries.add(`${pipeline.fragment.moduleId}:fragment:${pipeline.fragment.entryPoint}`); }\n }\n for (const key of usedEntries) if (!entryKeys.has(key)) diagnostics.push(issue(\"invalid-contract\", `Pipeline references undeclared compile-unit entry point ${key}.`, `${path}.pipelines`));\n for (const key of entryKeys) if (!usedEntries.has(key)) diagnostics.push(issue(\"invalid-contract\", `Compile-unit entry point ${key} is not used by a pipeline.`, `${path}.entryPoints`));\n const overrideValues = object(unit.overrideValues);\n if (!overrideValues) diagnostics.push(issue(\"invalid-contract\", \"overrideValues must be an object.\", `${path}.overrideValues`));\n else {\n for (const [name, value] of Object.entries(overrideValues)) if (!safeToken(name) || (typeof value !== \"boolean\" && (typeof value !== \"number\" || !Number.isFinite(value)))) diagnostics.push(issue(\"invalid-contract\", `Override value ${name} is invalid.`, `${path}.overrideValues`));\n const derived = new Map<string, boolean | number>();\n for (const descriptor of pipelines) {\n const stages = descriptor.kind === \"compute\" ? [descriptor.compute] : [descriptor.vertex, ...(descriptor.fragment ? [descriptor.fragment] : [])];\n for (const stage of stages) for (const [name, constant] of Object.entries(stage.constants)) {\n const previous = derived.get(name); if (previous !== undefined && !Object.is(previous, constant)) diagnostics.push(issue(\"invalid-contract\", `Override ${name} has conflicting stage values.`, `${path}.pipelines`)); else derived.set(name, constant);\n }\n }\n const exactOverrides = Object.fromEntries([...derived.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));\n if (canonicalizeGpuContract(overrideValues) !== canonicalizeGpuContract(exactOverrides)) diagnostics.push(issue(\"invalid-contract\", \"overrideValues must exactly equal the union of programmable-stage constants.\", `${path}.overrideValues`));\n }\n } catch (cause) {\n diagnostics.push(issue(\"invalid-contract\", cause instanceof Error ? cause.message : \"Compile-unit pipelines are invalid.\", `${path}.pipelines`));\n }\n const interfaceRef = object(unit.interfaceRef);\n if (!interfaceRef || !exactKeys(interfaceRef, [\"interfaceId\", \"interfaceVersion\", \"manifestUri\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"]) || !safeToken(interfaceRef.interfaceId) || !safeToken(interfaceRef.interfaceVersion) || typeof interfaceRef.manifestUri !== \"string\" || !interfaceRef.manifestUri.startsWith(\"https://\") || !validSha(interfaceRef.manifestSha256) || !validSha(interfaceRef.interfaceAbiHash) || !validSha(interfaceRef.modelAbiHash)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit interfaceRef is invalid.\", `${path}.interfaceRef`));\n }\n const fixture = object(unit.qualificationFixture);\n if (!fixture || !exactKeys(fixture, [\"fixtureId\", \"path\", \"sha256\"]) || !safeToken(fixture.fixtureId) || typeof fixture.path !== \"string\" || !SAFE_PATH.test(fixture.path) || !fixture.path.endsWith(\".json\") || !validSha(fixture.sha256)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires an exact declarative qualification fixture.\", `${path}.qualificationFixture`));\n }\n }\n for (const fragmentId of fragmentIds) {\n if (!covered.has(fragmentId)) diagnostics.push(issue(\"uncovered-fragment\", `WGSL fragment ${fragmentId} has no compile unit.`));\n }\n return diagnostics.length > 0\n ? { ok: false, diagnostics }\n : { ok: true, value: candidate as unknown as ShaderCompileUnitInventory };\n}\n","import {\n STABLE_WEBGPU_MATRIX_VERSION,\n SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES,\n type ShaderDiagnostic,\n type ShaderResult,\n type StableWebGpuMatrixManifest,\n} from \"../contracts.js\";\n\nfunction issue(message: string, path?: string): ShaderDiagnostic {\n return { code: \"invalid-contract\", severity: \"error\", message, ...(path ? { path } : {}) };\n}\n\nfunction object(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction keys(value: Record<string, unknown>, expected: readonly string[]): boolean {\n const set = new Set(expected);\n return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);\n}\n\nconst browserNames = new Set([\"chromium\", \"chrome\", \"edge\", \"firefox\", \"safari\"]);\nconst osNames = new Set([\"ubuntu\", \"windows\", \"macos\", \"chromeos\", \"android\", \"ios\", \"ipados\", \"visionos\"]);\nconst backends = new Set([\"swiftshader\", \"d3d12\", \"metal\", \"vulkan\"]);\nconst automation = new Set([\"playwright\", \"webdriver\", \"device-farm\", \"safari-webdriver\"]);\n\nconst VERSION_REQUIREMENTS = new Map<string, unknown>([\n [\"android-adreno-chrome-vulkan\", { kind: \"minimum-major\", value: 12 }],\n [\"android-mali-chrome-vulkan\", { kind: \"minimum-major\", value: 12 }],\n [\"chromeos-arm-chrome-vulkan\", { kind: \"stable-channel\", channel: \"stable\" }],\n [\"chromeos-intel-chrome-vulkan\", { kind: \"stable-channel\", channel: \"stable\" }],\n [\"ios-iphone-safari-metal\", { kind: \"major\", value: 26 }],\n [\"ipados-ipad-safari-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-chrome-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-firefox-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-safari-metal\", { kind: \"major\", value: 26 }],\n [\"swiftshader.chromium.ubuntu-x64\", { kind: \"exact\", value: \"24.04\" }],\n [\"ubuntu-intel-chrome-vulkan\", { kind: \"exact\", value: \"24.04\" }],\n [\"ubuntu-nvidia-chrome-vulkan\", { kind: \"exact\", value: \"24.04\" }],\n [\"visionos-safari-metal\", { kind: \"major\", value: 26 }],\n [\"win11-amd-firefox-d3d12\", { kind: \"major\", value: 11 }],\n [\"win11-intel-chrome-d3d12\", { kind: \"major\", value: 11 }],\n [\"win11-nvidia-edge-d3d12\", { kind: \"major\", value: 11 }],\n]);\n\nconst BASELINE = new Map<string, string>([\n [\"android-adreno-chrome-vulkan\", \"chrome|android|arm64|physical|qualcomm|adreno|vulkan|playwright|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,android-adreno,vulkan\"],\n [\"android-mali-chrome-vulkan\", \"chrome|android|arm64|physical|arm|mali|vulkan|playwright|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,android-mali,vulkan\"],\n [\"chromeos-arm-chrome-vulkan\", \"chrome|chromeos|arm64|physical|arm|qualified-arm|vulkan|webdriver|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,chromeos-arm,vulkan\"],\n [\"chromeos-intel-chrome-vulkan\", \"chrome|chromeos|x64|physical|intel|qualified-intel|vulkan|webdriver|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,chromeos-intel,vulkan\"],\n [\"ios-iphone-safari-metal\", \"safari|ios|arm64|physical|apple|iphone|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,ios-safari,metal\"],\n [\"ipados-ipad-safari-metal\", \"safari|ipados|arm64|physical|apple|ipad|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,ipados-safari,metal\"],\n [\"macos-apple-chrome-metal\", \"chrome|macos|arm64|physical|apple|apple-silicon|metal|playwright|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"macos-apple-firefox-metal\", \"firefox|macos|arm64|physical|apple|apple-silicon|metal|webdriver|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"macos-apple-safari-metal\", \"safari|macos|arm64|physical|apple|apple-silicon|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"swiftshader.chromium.ubuntu-x64\", \"chromium|ubuntu|x64|software|google|swiftshader|swiftshader|playwright|ubuntu-24.04\"],\n [\"ubuntu-intel-chrome-vulkan\", \"chrome|ubuntu|x64|physical|intel|qualified-intel|vulkan|playwright|self-hosted,Linux,X64,shader-validation,physical-gpu,gpu-intel,vulkan\"],\n [\"ubuntu-nvidia-chrome-vulkan\", \"chrome|ubuntu|x64|physical|nvidia|qualified-nvidia|vulkan|playwright|self-hosted,Linux,X64,shader-validation,physical-gpu,gpu-nvidia,vulkan\"],\n [\"visionos-safari-metal\", \"safari|visionos|arm64|physical|apple|vision-pro|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,visionos-safari,metal\"],\n [\"win11-amd-firefox-d3d12\", \"firefox|windows|x64|physical|amd|qualified-amd|d3d12|webdriver|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-amd,d3d12\"],\n [\"win11-intel-chrome-d3d12\", \"chrome|windows|x64|physical|intel|qualified-intel|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-intel,d3d12\"],\n [\"win11-nvidia-edge-d3d12\", \"edge|windows|x64|physical|nvidia|qualified-nvidia|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-nvidia,d3d12\"],\n]);\n\n/** Strictly validates the versioned 16-cell stable WebGPU support matrix. */\nexport function validateStableWebGpuMatrix(value: unknown): ShaderResult<StableWebGpuMatrixManifest> {\n const matrix = object(value);\n const diagnostics: ShaderDiagnostic[] = [];\n if (!matrix || !keys(matrix, [\"contractVersion\", \"matrixId\", \"version\", \"policy\", \"cells\"])) {\n return { ok: false, diagnostics: [issue(\"Matrix has unknown or missing top-level fields.\")] };\n }\n if (matrix.contractVersion !== STABLE_WEBGPU_MATRIX_VERSION) diagnostics.push(issue(\"Unsupported matrix contract version.\", \"contractVersion\"));\n const stablePolicy = SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0];\n if (matrix.matrixId !== stablePolicy?.matrixId || matrix.version !== stablePolicy.matrixVersion) diagnostics.push(issue(\"Matrix identity/version differs from the supported universal policy.\"));\n const policy = object(matrix.policy);\n const policyKeys = [\"coverage\", \"unavailable\", \"skipped\", \"timeout\", \"deviceLoss\", \"requiredPhysicalCellCount\", \"requiredBlockingCellCount\"];\n if (!policy || !keys(policy, policyKeys)\n || policy.coverage !== \"all-cells-required\"\n || policy.unavailable !== \"fail\"\n || policy.skipped !== \"fail\"\n || policy.timeout !== \"fail\"\n || policy.deviceLoss !== \"fail\"\n || policy.requiredPhysicalCellCount !== 15\n || policy.requiredBlockingCellCount !== 16) {\n diagnostics.push(issue(\"Matrix policy must fail closed with 15 physical and 16 blocking cells.\", \"policy\"));\n }\n if (!Array.isArray(matrix.cells) || matrix.cells.length !== 16) {\n diagnostics.push(issue(\"Stable WebGPU matrix must contain exactly 16 cells.\", \"cells\"));\n return { ok: false, diagnostics };\n }\n const ids = new Set<string>();\n let physical = 0;\n let blocking = 0;\n let software = 0;\n for (const [index, raw] of matrix.cells.entries()) {\n const path = `cells[${index}]`;\n const cell = object(raw);\n if (!cell || !keys(cell, [\n \"cellId\", \"runnerLabels\", \"browser\", \"os\", \"adapter\", \"automation\", \"timeoutMs\", \"blocking\", \"countsTowardStableCoverage\",\n ])) {\n diagnostics.push(issue(\"Matrix cell has unknown or missing fields.\", path));\n continue;\n }\n if (typeof cell.cellId !== \"string\" || !/^[a-z0-9][a-z0-9._-]+$/u.test(cell.cellId) || ids.has(cell.cellId)) diagnostics.push(issue(\"Cell ID is invalid or duplicated.\", `${path}.cellId`));\n else ids.add(cell.cellId);\n if (!Array.isArray(cell.runnerLabels) || cell.runnerLabels.length === 0 || cell.runnerLabels.some((label) => typeof label !== \"string\" || !label) || new Set(cell.runnerLabels).size !== cell.runnerLabels.length) diagnostics.push(issue(\"Runner labels must be unique non-empty strings.\", `${path}.runnerLabels`));\n const browser = object(cell.browser);\n const os = object(cell.os);\n const adapter = object(cell.adapter);\n const adapterAutomation = object(cell.automation);\n if (!browser || !keys(browser, [\"name\", \"channel\"]) || !browserNames.has(String(browser.name))) diagnostics.push(issue(\"Browser descriptor is invalid.\", `${path}.browser`));\n if (!os || !keys(os, [\"name\", \"versionRequirement\", \"architecture\"]) || !osNames.has(String(os.name)) || ![\"x64\", \"arm64\"].includes(String(os.architecture))) diagnostics.push(issue(\"OS descriptor is invalid.\", `${path}.os`));\n else {\n const requirement = object(os.versionRequirement); const kind = String(requirement?.kind);\n const validRequirement = requirement && (kind === \"exact\"\n ? keys(requirement, [\"kind\", \"value\"]) && typeof requirement.value === \"string\" && /^\\d+(?:\\.\\d+)*$/u.test(requirement.value)\n : kind === \"major\" || kind === \"minimum-major\"\n ? keys(requirement, [\"kind\", \"value\"]) && Number.isSafeInteger(requirement.value) && Number(requirement.value) > 0\n : kind === \"stable-channel\" && keys(requirement, [\"kind\", \"channel\"]) && requirement.channel === \"stable\");\n if (!validRequirement) diagnostics.push(issue(\"OS version requirement is invalid.\", `${path}.os.versionRequirement`));\n if (typeof cell.cellId === \"string\" && JSON.stringify(requirement) !== JSON.stringify(VERSION_REQUIREMENTS.get(cell.cellId))) diagnostics.push(issue(\"OS version requirement differs from the stable baseline.\", `${path}.os.versionRequirement`));\n }\n if (!adapter || !keys(adapter, [\"kind\", \"vendor\", \"family\", \"backend\"]) || ![\"software\", \"physical\"].includes(String(adapter.kind)) || !backends.has(String(adapter.backend))) diagnostics.push(issue(\"Adapter descriptor is invalid.\", `${path}.adapter`));\n if (!adapterAutomation || !keys(adapterAutomation, [\"kind\"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue(\"Automation descriptor is invalid.\", `${path}.automation`));\n const signature = `${String(browser?.name)}|${String(os?.name)}|${String(os?.architecture)}|${String(adapter?.kind)}|${String(adapter?.vendor)}|${String(adapter?.family)}|${String(adapter?.backend)}|${String(adapterAutomation?.kind)}|${Array.isArray(cell.runnerLabels) ? cell.runnerLabels.join(\",\") : \"\"}`;\n if (typeof cell.cellId === \"string\" && BASELINE.get(cell.cellId) !== signature) diagnostics.push(issue(\"Cell identity, target, automation, or runner labels differ from the stable baseline.\", path));\n if (typeof cell.cellId === \"string\" && [...BASELINE.keys()][index] !== cell.cellId) diagnostics.push(issue(\"Stable matrix cells must remain in fixed code-unit order.\", `${path}.cellId`));\n if (!Number.isSafeInteger(cell.timeoutMs) || Number(cell.timeoutMs) < 1000 || Number(cell.timeoutMs) > 3_600_000) diagnostics.push(issue(\"Cell timeout must be bounded.\", `${path}.timeoutMs`));\n if (cell.blocking !== true) diagnostics.push(issue(\"Every stable matrix cell must block delivery.\", `${path}.blocking`));\n else blocking += 1;\n if (adapter?.kind === \"physical\") {\n physical += 1;\n if (browser?.channel !== \"stable\" || cell.countsTowardStableCoverage !== true) diagnostics.push(issue(\"Physical cells must use stable browsers and count toward stable coverage.\", path));\n } else if (adapter?.kind === \"software\") {\n software += 1;\n if (adapter.backend !== \"swiftshader\" || browser?.name !== \"chromium\" || browser.channel !== \"playwright-bundled\" || cell.countsTowardStableCoverage !== false) diagnostics.push(issue(\"The sole software lane must be bundled Chromium with SwiftShader smoke coverage.\", path));\n }\n }\n if (physical !== 15 || blocking !== 16 || software !== 1 || ids.size !== BASELINE.size) diagnostics.push(issue(\"Matrix must contain the exact 15 physical baseline cells plus one SwiftShader smoke cell.\"));\n return diagnostics.length > 0\n ? { ok: false, diagnostics }\n : { ok: true, value: matrix as unknown as StableWebGpuMatrixManifest };\n}\n","import {\n SHADER_QUALIFICATION_BUNDLE_VERSION,\n SHADER_QUALIFICATION_FIXTURE_VERSION,\n type ShaderCompileUnitManifest,\n type ShaderQualificationBundleManifest,\n type ShaderQualificationFixtureManifest,\n type ShaderResult,\n} from \"../contracts.js\";\nimport { asSha256Hex } from \"../hash.js\";\nimport { validateCompileUnitInventory } from \"./inventory.js\";\n\ntype UnknownRecord = Record<string, unknown>;\ntype TextureDimension = \"1d\" | \"2d\" | \"3d\";\ntype TextureFormatAspect = \"color\" | \"depth\" | \"stencil\" | \"depth-stencil\";\n\ninterface BufferResourceInfo {\n readonly kind: \"buffer\";\n readonly byteLength: number;\n readonly usage: readonly string[];\n readonly hasInitialData: boolean;\n}\n\ninterface TextureResourceInfo {\n readonly kind: \"texture\";\n readonly usage: readonly string[];\n readonly hasInitialData: boolean;\n readonly dimension: TextureDimension;\n readonly size: readonly [number, number, number];\n readonly mipLevelCount: number;\n readonly sampleCount: number;\n readonly format: string;\n}\n\ninterface SamplerResourceInfo {\n readonly kind: \"sampler\";\n readonly usage: readonly string[];\n readonly hasInitialData: false;\n readonly descriptor: UnknownRecord;\n}\n\ntype FixtureResourceInfo = BufferResourceInfo | TextureResourceInfo | SamplerResourceInfo;\n\nconst SAFE_PATH = /^(?!\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[A-Za-z0-9._/-]+$/u;\nconst TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u;\nconst BUFFER_USAGE = new Set([\"map-read\", \"map-write\", \"copy-src\", \"copy-dst\", \"index\", \"vertex\", \"uniform\", \"storage\", \"indirect\", \"query-resolve\"]);\nconst TEXTURE_USAGE = new Set([\"copy-src\", \"copy-dst\", \"texture-binding\", \"storage-binding\", \"render-attachment\"]);\nconst UNCOMPRESSED_COLOR_BYTES = new Map<string, number>([\n [\"r8unorm\", 1], [\"r8snorm\", 1], [\"r8uint\", 1], [\"r8sint\", 1],\n [\"r16unorm\", 2], [\"r16snorm\", 2], [\"r16uint\", 2], [\"r16sint\", 2], [\"r16float\", 2],\n [\"rg8unorm\", 2], [\"rg8snorm\", 2], [\"rg8uint\", 2], [\"rg8sint\", 2],\n [\"r32uint\", 4], [\"r32sint\", 4], [\"r32float\", 4],\n [\"rg16unorm\", 4], [\"rg16snorm\", 4], [\"rg16uint\", 4], [\"rg16sint\", 4], [\"rg16float\", 4],\n [\"rgba8unorm\", 4], [\"rgba8unorm-srgb\", 4], [\"rgba8snorm\", 4], [\"rgba8uint\", 4], [\"rgba8sint\", 4],\n [\"bgra8unorm\", 4], [\"bgra8unorm-srgb\", 4], [\"rgb9e5ufloat\", 4], [\"rgb10a2uint\", 4], [\"rgb10a2unorm\", 4], [\"rg11b10ufloat\", 4],\n [\"rg32uint\", 8], [\"rg32sint\", 8], [\"rg32float\", 8],\n [\"rgba16unorm\", 8], [\"rgba16snorm\", 8], [\"rgba16uint\", 8], [\"rgba16sint\", 8], [\"rgba16float\", 8],\n [\"rgba32uint\", 16], [\"rgba32sint\", 16], [\"rgba32float\", 16],\n]);\nconst COMPRESSED_COLOR_FORMATS = new Set([\n \"bc1-rgba-unorm\", \"bc1-rgba-unorm-srgb\", \"bc2-rgba-unorm\", \"bc2-rgba-unorm-srgb\", \"bc3-rgba-unorm\", \"bc3-rgba-unorm-srgb\",\n \"bc4-r-unorm\", \"bc4-r-snorm\", \"bc5-rg-unorm\", \"bc5-rg-snorm\", \"bc6h-rgb-ufloat\", \"bc6h-rgb-float\", \"bc7-rgba-unorm\", \"bc7-rgba-unorm-srgb\",\n \"etc2-rgb8unorm\", \"etc2-rgb8unorm-srgb\", \"etc2-rgb8a1unorm\", \"etc2-rgb8a1unorm-srgb\", \"etc2-rgba8unorm\", \"etc2-rgba8unorm-srgb\",\n \"eac-r11unorm\", \"eac-r11snorm\", \"eac-rg11unorm\", \"eac-rg11snorm\",\n ...[\"4x4\", \"5x4\", \"5x5\", \"6x5\", \"6x6\", \"8x5\", \"8x6\", \"8x8\", \"10x5\", \"10x6\", \"10x8\", \"10x10\", \"12x10\", \"12x12\"]\n .flatMap((block) => [`astc-${block}-unorm`, `astc-${block}-unorm-srgb`]),\n]);\nconst DEPTH_STENCIL_FORMATS = new Map<string, TextureFormatAspect>([\n [\"stencil8\", \"stencil\"],\n [\"depth16unorm\", \"depth\"],\n [\"depth24plus\", \"depth\"],\n [\"depth24plus-stencil8\", \"depth-stencil\"],\n [\"depth32float\", \"depth\"],\n [\"depth32float-stencil8\", \"depth-stencil\"],\n]);\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const expected = new Set(keys);\n if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key in value)) throw new TypeError(`${path} has unknown or missing fields.`);\n}\n\nfunction token(value: unknown, path: string): string {\n if (typeof value !== \"string\" || !TOKEN.test(value) || value.includes(\"..\")) throw new TypeError(`${path} must be a safe token.`);\n return value;\n}\n\nfunction path(value: unknown, label: string, extensions: readonly string[]): string {\n if (typeof value !== \"string\" || !SAFE_PATH.test(value) || !extensions.some((extension) => value.endsWith(extension))) {\n throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(\", \")}).`);\n }\n return value;\n}\n\nfunction sha(value: unknown, label: string): string {\n try { return asSha256Hex(String(value)); }\n catch (cause) { throw new TypeError(`${label} must be a lowercase SHA-256 digest.`, { cause }); }\n}\n\nfunction integer(value: unknown, label: string, minimum = 0, maximum = 0xffff_ffff): number {\n if (!Number.isSafeInteger(value) || Number(value) < minimum || Number(value) > maximum) throw new TypeError(`${label} is outside its integer bound.`);\n return Number(value);\n}\n\nfunction boundedArray(value: unknown, label: string, maximum = 4096): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${label} must be a bounded array.`);\n return value;\n}\n\nfunction unique(values: readonly string[], label: string): void {\n if (new Set(values).size !== values.length) throw new TypeError(`${label} contains duplicates.`);\n}\n\nfunction orderedUniqueTokens(value: unknown, label: string): string[] {\n const result = boundedArray(value, label).map((item, index) => token(item, `${label}[${index}]`));\n unique(result, label);\n if (result.some((item, index) => index > 0 && result[index - 1]! >= item)) throw new TypeError(`${label} must use fixed code-unit order.`);\n return result;\n}\n\nfunction tuple(value: unknown, label: string, length: number, minimum = 0): number[] {\n const result = boundedArray(value, label, length);\n if (result.length !== length) throw new TypeError(`${label} must contain ${length} elements.`);\n return result.map((item, index) => integer(item, `${label}[${index}]`, minimum));\n}\n\nfunction finiteTuple(value: unknown, label: string, length: number): number[] {\n const result = boundedArray(value, label, length);\n if (result.length !== length || result.some((item) => typeof item !== \"number\" || !Number.isFinite(item))) throw new TypeError(`${label} must contain ${length} finite numbers.`);\n return result as number[];\n}\n\nfunction checkedProduct(left: number, right: number, label: string): number {\n const result = left * right;\n if (!Number.isSafeInteger(result)) throw new TypeError(`${label} exceeds the safe integer bound.`);\n return result;\n}\n\nfunction checkedSum(left: number, right: number, label: string): number {\n const result = left + right;\n if (!Number.isSafeInteger(result)) throw new TypeError(`${label} exceeds the safe integer bound.`);\n return result;\n}\n\nfunction textureFormatAspect(format: string, label: string): TextureFormatAspect {\n if (UNCOMPRESSED_COLOR_BYTES.has(format) || COMPRESSED_COLOR_FORMATS.has(format)) return \"color\";\n const aspect = DEPTH_STENCIL_FORMATS.get(format);\n if (!aspect) throw new TypeError(`${label} is not a qualification-fixture-v1 WebGPU texture format.`);\n return aspect;\n}\n\nfunction mipExtent(texture: TextureResourceInfo, mipLevel: number): readonly [number, number, number] {\n const divisor = 2 ** mipLevel;\n const width = Math.max(1, Math.floor(texture.size[0] / divisor));\n const height = texture.dimension === \"1d\" ? 1 : Math.max(1, Math.floor(texture.size[1] / divisor));\n const depthOrArrayLayers = texture.dimension === \"3d\"\n ? Math.max(1, Math.floor(texture.size[2] / divisor))\n : texture.dimension === \"2d\" ? texture.size[2] : 1;\n return [width, height, depthOrArrayLayers];\n}\n\nfunction linearTextureDataBounds(\n extent: readonly [number, number, number],\n bytesPerTexel: number,\n bytesPerRow: number,\n rowsPerImage: number,\n label: string,\n): { readonly minimum: number; readonly maximum: number } {\n const rowBytes = checkedProduct(extent[0], bytesPerTexel, `${label} row byte length`);\n if (bytesPerRow < rowBytes || bytesPerRow % bytesPerTexel !== 0) throw new TypeError(`${label}.bytesPerRow is incompatible with the copied texel row.`);\n if (rowsPerImage < extent[1]) throw new TypeError(`${label}.rowsPerImage is smaller than the copied image height.`);\n const imageStride = checkedProduct(bytesPerRow, rowsPerImage, `${label} image stride`);\n const priorImages = checkedProduct(imageStride, extent[2] - 1, `${label} prior-image byte length`);\n const priorRows = checkedProduct(bytesPerRow, extent[1] - 1, `${label} prior-row byte length`);\n const minimum = checkedSum(priorImages, checkedSum(priorRows, rowBytes, `${label} final-image byte length`), `${label} required byte length`);\n const maximum = checkedProduct(imageStride, extent[2], `${label} padded byte capacity`);\n return { minimum, maximum };\n}\n\nfunction textureView(value: unknown, label: string, texture: TextureResourceInfo): void {\n const view = object(value, label);\n exact(view, [\"format\", \"dimension\", \"aspect\", \"baseMipLevel\", \"mipLevelCount\", \"baseArrayLayer\", \"arrayLayerCount\"], label);\n const dimension = view.dimension === null ? null : String(view.dimension);\n if (dimension !== null && ![\"1d\", \"2d\", \"2d-array\", \"cube\", \"cube-array\", \"3d\"].includes(dimension)) throw new TypeError(`${label}.dimension is invalid.`);\n const aspect = String(view.aspect);\n if (![\"all\", \"depth-only\", \"stencil-only\"].includes(aspect)) throw new TypeError(`${label}.aspect is invalid.`);\n\n const resourceAspect = textureFormatAspect(texture.format, `${label} resource format`);\n const aspectIsPresent = aspect === \"all\"\n || aspect === \"depth-only\" && (resourceAspect === \"depth\" || resourceAspect === \"depth-stencil\")\n || aspect === \"stencil-only\" && (resourceAspect === \"stencil\" || resourceAspect === \"depth-stencil\");\n if (!aspectIsPresent) throw new TypeError(`${label}.aspect is not present in texture format ${texture.format}.`);\n const resolvedFormat = aspect === \"all\" ? texture.format\n : aspect === \"stencil-only\" ? \"stencil8\"\n : texture.format === \"depth24plus-stencil8\" ? \"depth24plus\"\n : texture.format === \"depth32float-stencil8\" ? \"depth32float\" : texture.format;\n if (view.format !== null && token(view.format, `${label}.format`) !== resolvedFormat) {\n throw new TypeError(`${label}.format differs from the texture aspect format ${resolvedFormat}.`);\n }\n\n const baseMipLevel = integer(view.baseMipLevel, `${label}.baseMipLevel`);\n if (baseMipLevel >= texture.mipLevelCount) throw new TypeError(`${label}.baseMipLevel is out of bounds.`);\n const mipLevelCount = view.mipLevelCount === null\n ? texture.mipLevelCount - baseMipLevel\n : integer(view.mipLevelCount, `${label}.mipLevelCount`, 1);\n if (mipLevelCount > texture.mipLevelCount - baseMipLevel) throw new TypeError(`${label}.mipLevelCount is out of bounds.`);\n\n const textureArrayLayers = texture.dimension === \"2d\" ? texture.size[2] : 1;\n const baseArrayLayer = integer(view.baseArrayLayer, `${label}.baseArrayLayer`);\n if (baseArrayLayer >= textureArrayLayers) throw new TypeError(`${label}.baseArrayLayer is out of bounds.`);\n const resolvedDimension = dimension ?? (texture.dimension === \"2d\" && textureArrayLayers > 1 ? \"2d-array\" : texture.dimension);\n const defaultArrayLayerCount = resolvedDimension === \"cube\" ? 6\n : resolvedDimension === \"2d-array\" || resolvedDimension === \"cube-array\" ? textureArrayLayers - baseArrayLayer : 1;\n const arrayLayerCount = view.arrayLayerCount === null\n ? defaultArrayLayerCount\n : integer(view.arrayLayerCount, `${label}.arrayLayerCount`, 1);\n if (arrayLayerCount > textureArrayLayers - baseArrayLayer) throw new TypeError(`${label}.arrayLayerCount is out of bounds.`);\n\n if (resolvedDimension === \"1d\" && texture.dimension !== \"1d\"\n || resolvedDimension === \"3d\" && texture.dimension !== \"3d\"\n || [\"2d\", \"2d-array\", \"cube\", \"cube-array\"].includes(resolvedDimension) && texture.dimension !== \"2d\") {\n throw new TypeError(`${label}.dimension is incompatible with the texture dimension.`);\n }\n if ([\"1d\", \"2d\", \"3d\"].includes(resolvedDimension) && arrayLayerCount !== 1) throw new TypeError(`${label}.arrayLayerCount must be one for ${resolvedDimension} views.`);\n if (resolvedDimension === \"cube\" && arrayLayerCount !== 6 || resolvedDimension === \"cube-array\" && arrayLayerCount % 6 !== 0) throw new TypeError(`${label}.arrayLayerCount is invalid for a cube view.`);\n if ((resolvedDimension === \"cube\" || resolvedDimension === \"cube-array\") && texture.size[0] !== texture.size[1]) throw new TypeError(`${label} cube views require square texture layers.`);\n if (texture.sampleCount > 1 && (resolvedDimension !== \"2d\" || mipLevelCount !== 1 || arrayLayerCount !== 1)) throw new TypeError(`${label} multisampled texture views must select one 2d subresource.`);\n}\n\nfunction dataRef(value: unknown, label: string): void {\n const ref = object(value, label); exact(ref, [\"path\", \"sha256\"], label); path(ref.path, `${label}.path`, [\".bin\"]); sha(ref.sha256, `${label}.sha256`);\n}\n\nfunction jsonValue(value: unknown, label: string, depth = 0): void {\n if (depth > 32) throw new TypeError(`${label} exceeds the structured-value nesting bound.`);\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return;\n if (typeof value === \"number\") { if (!Number.isFinite(value)) throw new TypeError(`${label} must be finite.`); return; }\n if (Array.isArray(value)) { if (value.length > 65_536) throw new TypeError(`${label} exceeds the structured-value item bound.`); value.forEach((item, index) => jsonValue(item, `${label}[${index}]`, depth + 1)); return; }\n const input = object(value, label); if (Object.keys(input).length > 4096) throw new TypeError(`${label} has too many members.`); for (const [key, item] of Object.entries(input)) { token(key, `${label} key`); jsonValue(item, `${label}.${key}`, depth + 1); }\n}\n\n/** Strictly validates the bounded, declarative (never executable) fixture DSL. */\nexport function validateQualificationFixture(\n value: unknown,\n unit?: ShaderCompileUnitManifest,\n): ShaderResult<ShaderQualificationFixtureManifest> {\n try {\n const fixture = object(value, \"fixture\"); exact(fixture, [\"contractVersion\", \"fixtureId\", \"resources\", \"bindGroups\", \"commands\", \"layoutProbes\", \"readbacks\", \"bounds\"], \"fixture\");\n if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError(\"Unsupported qualification fixture version.\");\n token(fixture.fixtureId, \"fixture.fixtureId\");\n const bounds = object(fixture.bounds, \"fixture.bounds\"); exact(bounds, [\"maxBufferBytes\", \"maxTextureTexels\", \"maxCommands\", \"timeoutMs\"], \"fixture.bounds\");\n const maxBufferBytes = integer(bounds.maxBufferBytes, \"fixture.bounds.maxBufferBytes\", 1, 67_108_864);\n const maxTextureTexels = integer(bounds.maxTextureTexels, \"fixture.bounds.maxTextureTexels\", 1, 16_777_216);\n const maxCommands = integer(bounds.maxCommands, \"fixture.bounds.maxCommands\", 1, 1000);\n integer(bounds.timeoutMs, \"fixture.bounds.timeoutMs\", 1, 300_000);\n const resources = new Map<string, FixtureResourceInfo>();\n let bufferBytes = 0; let textureTexels = 0;\n const resourceValues = boundedArray(fixture.resources, \"fixture.resources\", 256); if (resourceValues.length === 0) throw new TypeError(\"Fixture requires resources.\");\n for (const [index, value] of resourceValues.entries()) {\n const label = `fixture.resources[${index}]`; const resource = object(value, label); const kind = String(resource.kind);\n if (kind === \"buffer\") {\n exact(resource, [\"kind\", \"resourceId\", \"byteLength\", \"usage\", \"initialData\"], label);\n const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const byteLength = integer(resource.byteLength, `${label}.byteLength`, 1, maxBufferBytes); bufferBytes += byteLength;\n const usage = boundedArray(resource.usage, `${label}.usage`, BUFFER_USAGE.size).map(String); unique(usage, `${label}.usage`); if (usage.length === 0 || usage.some((item) => !BUFFER_USAGE.has(item))) throw new TypeError(`${label}.usage is invalid.`);\n if (resource.initialData !== null) dataRef(resource.initialData, `${label}.initialData`);\n resources.set(id, { kind: \"buffer\", byteLength, usage, hasInitialData: resource.initialData !== null });\n } else if (kind === \"texture\") {\n exact(resource, [\"kind\", \"resourceId\", \"dimension\", \"size\", \"mipLevelCount\", \"sampleCount\", \"format\", \"usage\", \"initialData\"], label);\n const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const dimensionValue = String(resource.dimension); if (![\"1d\", \"2d\", \"3d\"].includes(dimensionValue)) throw new TypeError(`${label}.dimension is invalid.`); const dimension = dimensionValue as TextureDimension;\n const parsedSize = tuple(resource.size, `${label}.size`, 3, 1); const size = parsedSize as [number, number, number];\n if (dimension === \"1d\" && (size[1] !== 1 || size[2] !== 1)) throw new TypeError(`${label}.size is inconsistent with dimension.`);\n const mipLevelCount = integer(resource.mipLevelCount, `${label}.mipLevelCount`, 1, 32);\n const maximumMipDimension = dimension === \"1d\" ? size[0] : dimension === \"2d\" ? Math.max(size[0], size[1]) : Math.max(...size);\n const maximumMipLevels = Math.floor(Math.log2(maximumMipDimension)) + 1;\n if (mipLevelCount > maximumMipLevels) throw new TypeError(`${label}.mipLevelCount exceeds its spatial size.`);\n const sampleCount = integer(resource.sampleCount, `${label}.sampleCount`, 1, 4); if (sampleCount !== 1 && sampleCount !== 4) throw new TypeError(`${label}.sampleCount is unsupported.`);\n if (sampleCount > 1 && (dimension !== \"2d\" || size[2] !== 1 || mipLevelCount !== 1)) throw new TypeError(`${label} multisampling requires one single-mip 2d layer.`);\n const resourceTexels = checkedProduct(checkedProduct(checkedProduct(size[0], size[1], `${label} texel count`), size[2], `${label} texel count`), sampleCount, `${label} sampled texel count`);\n textureTexels = checkedSum(textureTexels, resourceTexels, \"fixture texture texel count\");\n const format = token(resource.format, `${label}.format`); textureFormatAspect(format, `${label}.format`);\n const usage = boundedArray(resource.usage, `${label}.usage`, TEXTURE_USAGE.size).map(String); unique(usage, `${label}.usage`); if (usage.length === 0 || usage.some((item) => !TEXTURE_USAGE.has(item))) throw new TypeError(`${label}.usage is invalid.`);\n const textureInfo: TextureResourceInfo = { kind: \"texture\", usage, hasInitialData: resource.initialData !== null, dimension, size, mipLevelCount, sampleCount, format };\n if (resource.initialData !== null) {\n const initialLabel = `${label}.initialData`;\n const initial = object(resource.initialData, initialLabel); exact(initial, [\"path\", \"sha256\", \"bytesPerRow\", \"rowsPerImage\", \"mipLevel\", \"origin\", \"aspect\"], initialLabel);\n path(initial.path, `${initialLabel}.path`, [\".bin\"]); sha(initial.sha256, `${initialLabel}.sha256`);\n if (sampleCount !== 1) throw new TypeError(`${label} multisampled textures cannot have initialData.`);\n if (!usage.includes(\"copy-dst\")) throw new TypeError(`${initialLabel} requires copy-dst texture usage.`);\n const bytesPerTexel = UNCOMPRESSED_COLOR_BYTES.get(format); if (!bytesPerTexel) throw new TypeError(`${initialLabel} supports only uncompressed color formats in fixture v1.`);\n const mipLevel = integer(initial.mipLevel, `${initialLabel}.mipLevel`); if (mipLevel !== 0) throw new TypeError(`${initialLabel}.mipLevel must be zero in fixture v1.`);\n const origin = tuple(initial.origin, `${initialLabel}.origin`, 3); if (origin.some((axis) => axis !== 0)) throw new TypeError(`${initialLabel}.origin must be zero in fixture v1.`);\n if (initial.aspect !== \"all\") throw new TypeError(`${initialLabel}.aspect must be all for an uncompressed color upload.`);\n const bytesPerRow = integer(initial.bytesPerRow, `${initialLabel}.bytesPerRow`, 1);\n const rowsPerImage = integer(initial.rowsPerImage, `${initialLabel}.rowsPerImage`, 1);\n linearTextureDataBounds(mipExtent(textureInfo, 0), bytesPerTexel, bytesPerRow, rowsPerImage, initialLabel);\n }\n resources.set(id, textureInfo);\n } else if (kind === \"sampler\") {\n exact(resource, [\"kind\", \"resourceId\", \"descriptor\"], label); const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const descriptor = object(resource.descriptor, `${label}.descriptor`); const samplerKeys = new Set([\"addressModeU\", \"addressModeV\", \"addressModeW\", \"magFilter\", \"minFilter\", \"mipmapFilter\", \"lodMinClamp\", \"lodMaxClamp\", \"compare\", \"maxAnisotropy\"]); for (const key of Object.keys(descriptor)) if (!samplerKeys.has(key)) throw new TypeError(`${label}.descriptor.${key} is unsupported.`); for (const key of [\"addressModeU\", \"addressModeV\", \"addressModeW\"]) if (descriptor[key] !== undefined && ![\"clamp-to-edge\", \"repeat\", \"mirror-repeat\"].includes(String(descriptor[key]))) throw new TypeError(`${label}.descriptor.${key} is invalid.`); for (const key of [\"magFilter\", \"minFilter\", \"mipmapFilter\"]) if (descriptor[key] !== undefined && ![\"nearest\", \"linear\"].includes(String(descriptor[key]))) throw new TypeError(`${label}.descriptor.${key} is invalid.`); if (descriptor.compare !== undefined && ![\"never\", \"less\", \"equal\", \"less-equal\", \"greater\", \"not-equal\", \"greater-equal\", \"always\"].includes(String(descriptor.compare))) throw new TypeError(`${label}.descriptor.compare is invalid.`); const lodMin = descriptor.lodMinClamp === undefined ? 0 : Number(descriptor.lodMinClamp); const lodMax = descriptor.lodMaxClamp === undefined ? 32 : Number(descriptor.lodMaxClamp); if (!Number.isFinite(lodMin) || !Number.isFinite(lodMax) || lodMin < 0 || lodMax < lodMin || lodMax > 32) throw new TypeError(`${label}.descriptor LOD clamps are invalid.`); if (descriptor.maxAnisotropy !== undefined) integer(descriptor.maxAnisotropy, `${label}.descriptor.maxAnisotropy`, 1, 16);\n resources.set(id, { kind: \"sampler\", usage: [], hasInitialData: false, descriptor });\n } else throw new TypeError(`${label}.kind is unsupported.`);\n }\n if (bufferBytes > maxBufferBytes || textureTexels > maxTextureTexels) throw new TypeError(\"Fixture resources exceed declared bounds.\");\n const bindGroups = new Map<string, { group: number; entries: readonly UnknownRecord[] }>();\n for (const [index, value] of boundedArray(fixture.bindGroups, \"fixture.bindGroups\", 32).entries()) {\n const label = `fixture.bindGroups[${index}]`; const group = object(value, label); exact(group, [\"bindGroupId\", \"group\", \"entries\"], label); const id = token(group.bindGroupId, `${label}.bindGroupId`); if (bindGroups.has(id)) throw new TypeError(`Duplicate bind group ${id}.`); const groupIndex = integer(group.group, `${label}.group`); const parsedEntries: UnknownRecord[] = [];\n const bindingIds: string[] = []; for (const [entryIndex, value] of boundedArray(group.entries, `${label}.entries`, 64).entries()) { const entryLabel = `${label}.entries[${entryIndex}]`; const entry = object(value, entryLabel); parsedEntries.push(entry); exact(entry, [\"binding\", \"resource\"], entryLabel); bindingIds.push(String(integer(entry.binding, `${entryLabel}.binding`))); const ref = object(entry.resource, `${entryLabel}.resource`); const kind = String(ref.kind); if (kind === \"buffer\") { exact(ref, [\"kind\", \"resourceId\", \"offset\", \"size\"], `${entryLabel}.resource`); const source = resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`)); const offset = integer(ref.offset, `${entryLabel}.resource.offset`); const size = integer(ref.size, `${entryLabel}.resource.size`, 1); if (source?.kind !== \"buffer\" || offset + size > source.byteLength) throw new TypeError(`${entryLabel}.resource is out of bounds.`); } else if (kind === \"texture-view\") { exact(ref, [\"kind\", \"resourceId\", \"view\"], `${entryLabel}.resource`); const source = resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`)); if (source?.kind !== \"texture\") throw new TypeError(`${entryLabel}.resource is not a texture.`); textureView(ref.view, `${entryLabel}.resource.view`, source); } else if (kind === \"sampler\") { exact(ref, [\"kind\", \"resourceId\"], `${entryLabel}.resource`); if (resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`))?.kind !== \"sampler\") throw new TypeError(`${entryLabel}.resource is not a sampler.`); } else throw new TypeError(`${entryLabel}.resource.kind is unsupported.`); }\n unique(bindingIds, `${label}.entries`);\n bindGroups.set(id, { group: groupIndex, entries: parsedEntries });\n }\n const pipelines = new Map(unit?.pipelines.map((pipeline) => [pipeline.pipelineId, pipeline]) ?? []);\n const pipelineIds = new Set(pipelines.keys());\n const commandBindGroups = (value: unknown, pipelineId: string, label: string): void => {\n const ids = boundedArray(value, label, 32).map((item, index) => token(item, `${label}[${index}]`)); unique(ids, label);\n const pipeline = pipelines.get(pipelineId); if (!pipeline) { if (unit) throw new TypeError(`${label} pipeline is missing.`); return; }\n const expectedGroups = [...pipeline.layout.bindGroups].sort((left, right) => left.group - right.group);\n if (ids.length !== expectedGroups.length) throw new TypeError(`${label} must bind every pipeline group exactly once.`);\n ids.forEach((id, index) => { const actual = bindGroups.get(id); const expected = expectedGroups[index]!; if (!actual || actual.group !== expected.group) throw new TypeError(`${label}[${index}] does not match pipeline group ${expected.group}.`); const actualBindings = actual.entries.map((entry) => Number(entry.binding)).sort((left, right) => left - right); const expectedBindings = expected.entries.map((entry) => entry.binding).sort((left, right) => left - right); if (actualBindings.join(\",\") !== expectedBindings.join(\",\")) throw new TypeError(`${label}[${index}] bind-group entries differ from the pipeline layout.`); });\n };\n const commands = boundedArray(fixture.commands, \"fixture.commands\", maxCommands); if (commands.length === 0 || commands.length > maxCommands) throw new TypeError(\"Fixture requires bounded commands.\");\n let executionCommands = 0;\n for (const [index, value] of commands.entries()) {\n const label = `fixture.commands[${index}]`; const command = object(value, label); const kind = String(command.kind);\n if (kind === \"dispatch\") { executionCommands += 1; exact(command, [\"kind\", \"pipelineId\", \"bindGroupIds\", \"workgroups\"], label); const id = token(command.pipelineId, `${label}.pipelineId`); if (unit && (pipelines.get(id)?.kind !== \"compute\")) throw new TypeError(`${label} references a missing or non-compute pipeline.`); commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`); const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1); if (workgroups[0]! * workgroups[1]! * workgroups[2]! > 1_048_576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`); }\n else if (kind === \"copy-buffer\") { exact(command, [\"kind\", \"source\", \"destination\", \"byteLength\"], label); const source = resources.get(token(command.source, `${label}.source`)); const destination = resources.get(token(command.destination, `${label}.destination`)); const bytes = integer(command.byteLength, `${label}.byteLength`, 1); if (source?.kind !== \"buffer\" || destination?.kind !== \"buffer\" || bytes > (source.byteLength ?? 0) || bytes > (destination.byteLength ?? 0)) throw new TypeError(`${label} is out of bounds.`); }\n else if (kind === \"copy-texture-to-buffer\") {\n exact(command, [\"kind\", \"source\", \"destination\", \"extent\"], label);\n const source = object(command.source, `${label}.source`); exact(source, [\"resourceId\", \"mipLevel\", \"origin\", \"aspect\"], `${label}.source`);\n const sourceResource = resources.get(token(source.resourceId, `${label}.source.resourceId`));\n if (sourceResource?.kind !== \"texture\") throw new TypeError(`${label}.source is not a texture.`);\n if (!sourceResource.usage.includes(\"copy-src\")) throw new TypeError(`${label}.source requires copy-src texture usage.`);\n if (sourceResource.sampleCount !== 1) throw new TypeError(`${label}.source must not be multisampled.`);\n const bytesPerTexel = UNCOMPRESSED_COLOR_BYTES.get(sourceResource.format);\n if (!bytesPerTexel || source.aspect !== \"all\") throw new TypeError(`${label}.source format/aspect is unsupported for a fixture-v1 texture readback.`);\n const mipLevel = integer(source.mipLevel, `${label}.source.mipLevel`); if (mipLevel >= sourceResource.mipLevelCount) throw new TypeError(`${label}.source.mipLevel is out of bounds.`);\n const origin = tuple(source.origin, `${label}.source.origin`, 3); const extent = tuple(command.extent, `${label}.extent`, 3, 1) as [number, number, number]; const available = mipExtent(sourceResource, mipLevel);\n if (origin.some((axis, axisIndex) => checkedSum(axis, extent[axisIndex]!, `${label}.source copy range`) > available[axisIndex]!)) throw new TypeError(`${label}.source copy range is out of bounds.`);\n\n const destination = object(command.destination, `${label}.destination`); exact(destination, [\"resourceId\", \"offset\", \"bytesPerRow\", \"rowsPerImage\"], `${label}.destination`);\n const destinationResource = resources.get(token(destination.resourceId, `${label}.destination.resourceId`));\n if (destinationResource?.kind !== \"buffer\") throw new TypeError(`${label}.destination is not a buffer.`);\n if (!destinationResource.usage.includes(\"copy-dst\")) throw new TypeError(`${label}.destination requires copy-dst buffer usage.`);\n const offset = integer(destination.offset, `${label}.destination.offset`); if (offset % bytesPerTexel !== 0) throw new TypeError(`${label}.destination.offset must be texel-block aligned.`);\n const bytesPerRow = integer(destination.bytesPerRow, `${label}.destination.bytesPerRow`, 1); if (bytesPerRow % 256 !== 0) throw new TypeError(`${label}.destination.bytesPerRow must be 256-byte aligned.`);\n const rowsPerImage = integer(destination.rowsPerImage, `${label}.destination.rowsPerImage`, 1);\n const requiredBytes = linearTextureDataBounds(extent, bytesPerTexel, bytesPerRow, rowsPerImage, `${label}.destination`).minimum;\n if (checkedSum(offset, requiredBytes, `${label}.destination range`) > destinationResource.byteLength) throw new TypeError(`${label}.destination range is out of bounds.`);\n }\n else if (kind === \"draw\") { executionCommands += 1; exact(command, [\"kind\", \"pipelineId\", \"bindGroupIds\", \"vertexBuffers\", \"colorAttachments\", \"depthStencilAttachment\", \"vertexCount\", \"instanceCount\", \"firstVertex\", \"firstInstance\"], label); const id = token(command.pipelineId, `${label}.pipelineId`); if (unit && (pipelines.get(id)?.kind !== \"render\")) throw new TypeError(`${label} references a missing or non-render pipeline.`); commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`); boundedArray(command.vertexBuffers, `${label}.vertexBuffers`, 16).forEach((value, vertexIndex) => { const vertexLabel = `${label}.vertexBuffers[${vertexIndex}]`; const vertex = object(value, vertexLabel); exact(vertex, [\"slot\", \"resourceId\", \"offset\", \"size\"], vertexLabel); integer(vertex.slot, `${vertexLabel}.slot`); const resource = resources.get(token(vertex.resourceId, `${vertexLabel}.resourceId`)); const offset = integer(vertex.offset, `${vertexLabel}.offset`); const size = integer(vertex.size, `${vertexLabel}.size`, 1); if (resource?.kind !== \"buffer\" || !resource.usage.includes(\"vertex\") || offset + size > resource.byteLength) throw new TypeError(`${vertexLabel} is not a bounded vertex buffer.`); }); boundedArray(command.colorAttachments, `${label}.colorAttachments`, 8).forEach((value, attachmentIndex) => { const attachmentLabel = `${label}.colorAttachments[${attachmentIndex}]`; const attachment = object(value, attachmentLabel); exact(attachment, [\"resourceId\", \"view\", \"clearValue\", \"loadOp\", \"storeOp\"], attachmentLabel); const target = resources.get(token(attachment.resourceId, `${attachmentLabel}.resourceId`)); if (target?.kind !== \"texture\" || !target.usage.includes(\"render-attachment\")) throw new TypeError(`${attachmentLabel} is not a render-attachment texture.`); textureView(attachment.view, `${attachmentLabel}.view`, target); if (textureFormatAspect(target.format, `${attachmentLabel} format`) !== \"color\") throw new TypeError(`${attachmentLabel} must use a color texture format.`); finiteTuple(attachment.clearValue, `${attachmentLabel}.clearValue`, 4); if (![\"clear\", \"load\"].includes(String(attachment.loadOp)) || ![\"store\", \"discard\"].includes(String(attachment.storeOp))) throw new TypeError(`${attachmentLabel} has invalid ops.`); }); if (command.depthStencilAttachment !== null) { const attachment = object(command.depthStencilAttachment, `${label}.depthStencilAttachment`); exact(attachment, [\"resourceId\", \"view\", \"depthClearValue\", \"depthLoadOp\", \"depthStoreOp\", \"stencilClearValue\", \"stencilLoadOp\", \"stencilStoreOp\"], `${label}.depthStencilAttachment`); const target = resources.get(token(attachment.resourceId, `${label}.depthStencilAttachment.resourceId`)); if (target?.kind !== \"texture\" || !target.usage.includes(\"render-attachment\")) throw new TypeError(`${label}.depthStencilAttachment is not a render-attachment texture.`); textureView(attachment.view, `${label}.depthStencilAttachment.view`, target); if (textureFormatAspect(target.format, `${label}.depthStencilAttachment format`) === \"color\") throw new TypeError(`${label}.depthStencilAttachment must use a depth/stencil texture format.`); if (typeof attachment.depthClearValue !== \"number\" || !Number.isFinite(attachment.depthClearValue) || attachment.depthClearValue < 0 || attachment.depthClearValue > 1) throw new TypeError(`${label}.depthClearValue is invalid.`); integer(attachment.stencilClearValue, `${label}.stencilClearValue`, 0, 255); if (![\"clear\", \"load\"].includes(String(attachment.depthLoadOp)) || ![\"store\", \"discard\"].includes(String(attachment.depthStoreOp)) || attachment.stencilLoadOp !== null && ![\"clear\", \"load\"].includes(String(attachment.stencilLoadOp)) || attachment.stencilStoreOp !== null && ![\"store\", \"discard\"].includes(String(attachment.stencilStoreOp)) || (attachment.stencilLoadOp === null) !== (attachment.stencilStoreOp === null)) throw new TypeError(`${label}.depth/stencil attachment has invalid ops.`); } const vertexCount = integer(command.vertexCount, `${label}.vertexCount`, 1); const instanceCount = integer(command.instanceCount, `${label}.instanceCount`, 1); if (vertexCount * instanceCount > 16_777_216) throw new TypeError(`${label} exceeds the hard draw invocation bound.`); integer(command.firstVertex, `${label}.firstVertex`); integer(command.firstInstance, `${label}.firstInstance`); }\n else throw new TypeError(`${label}.kind is unsupported.`);\n }\n if (executionCommands === 0) throw new TypeError(\"Fixture requires a bounded dispatch or draw command.\");\n const readbacks = boundedArray(fixture.readbacks, \"fixture.readbacks\", 512); if (readbacks.length === 0) throw new TypeError(\"Fixture requires semantic readback evidence.\"); const parsedReadbacks: UnknownRecord[] = [];\n for (const [index, value] of readbacks.entries()) { const label = `fixture.readbacks[${index}]`; const readback = object(value, label); parsedReadbacks.push(readback); exact(readback, [\"resourceId\", \"byteOffset\", \"byteLength\", \"expectedSha256\"], label); const resource = resources.get(token(readback.resourceId, `${label}.resourceId`)); const offset = integer(readback.byteOffset, `${label}.byteOffset`); const size = integer(readback.byteLength, `${label}.byteLength`, 1); if (resource?.kind !== \"buffer\" || !resource.usage.includes(\"map-read\") || offset + size > (resource.byteLength ?? 0)) throw new TypeError(`${label} is not a bounded map-read buffer range.`); sha(readback.expectedSha256, `${label}.expectedSha256`); }\n const probes = boundedArray(fixture.layoutProbes, \"fixture.layoutProbes\", 512); if (probes.length === 0) throw new TypeError(\"Fixture requires at least one structured CPU-to-GPU and GPU-to-CPU layout probe.\"); const probeIds: string[] = []; const probeSources: string[] = [];\n for (const [index, value] of probes.entries()) {\n const label = `fixture.layoutProbes[${index}]`; const probe = object(value, label); probeIds.push(token(probe.probeId, `${label}.probeId`)); const commandIndex = integer(probe.commandIndex, `${label}.commandIndex`, 0, commands.length - 1); const command = object(commands[commandIndex], `${label}.command`);\n if (probe.kind === \"buffer-record\") {\n exact(probe, [\"kind\", \"probeId\", \"source\", \"pipelineId\", \"commandIndex\", \"input\", \"output\"], label);\n const source = object(probe.source, `${label}.source`); exact(source, [\"moduleId\", \"group\", \"binding\", \"recordName\"], `${label}.source`); const moduleId = token(source.moduleId, `${label}.source.moduleId`); const group = integer(source.group, `${label}.source.group`); const binding = integer(source.binding, `${label}.source.binding`); token(source.recordName, `${label}.source.recordName`); probeSources.push(`binding:${moduleId}:${group}:${binding}`);\n const pipelineId = token(probe.pipelineId, `${label}.pipelineId`); if (unit && !pipelineIds.has(pipelineId)) throw new TypeError(`${label}.pipelineId is missing.`); if (command.pipelineId !== pipelineId || command.kind !== \"dispatch\" && command.kind !== \"draw\") throw new TypeError(`${label} must target its declared executable pipeline command.`);\n const input = object(probe.input, `${label}.input`); exact(input, [\"resourceId\", \"byteOffset\", \"byteLength\", \"value\"], `${label}.input`); const inputId = token(input.resourceId, `${label}.input.resourceId`); const inputResource = resources.get(inputId); const inputOffset = integer(input.byteOffset, `${label}.input.byteOffset`); const inputLength = integer(input.byteLength, `${label}.input.byteLength`, 1); if (inputResource?.kind !== \"buffer\" || !inputResource.hasInitialData || inputOffset + inputLength > (inputResource.byteLength ?? 0)) throw new TypeError(`${label}.input must be an initialized bounded buffer range.`); jsonValue(input.value, `${label}.input.value`);\n const commandGroups = boundedArray(command.bindGroupIds, `${label}.command.bindGroupIds`).map(String); const bindsSource = commandGroups.some((id) => { const selected = bindGroups.get(id); if (selected?.group !== group) return false; const entry = selected.entries.find((candidate) => candidate.binding === binding); return entry ? object(entry.resource, `${label}.boundResource`).resourceId === inputId : false; }); if (!bindsSource) throw new TypeError(`${label}.input is not bound at the declared model source in its command.`);\n } else if (probe.kind === \"vertex-input\") {\n exact(probe, [\"kind\", \"probeId\", \"source\", \"commandIndex\", \"input\", \"output\"], label);\n const source = object(probe.source, `${label}.source`); exact(source, [\"pipelineId\", \"shaderLocation\", \"semantic\"], `${label}.source`); const pipelineId = token(source.pipelineId, `${label}.source.pipelineId`); const shaderLocation = integer(source.shaderLocation, `${label}.source.shaderLocation`); const semantic = token(source.semantic, `${label}.source.semantic`); probeSources.push(`vertex:${pipelineId}:${shaderLocation}:${semantic}`);\n if (command.kind !== \"draw\" || command.pipelineId !== pipelineId) throw new TypeError(`${label} must target its declared render pipeline draw command.`);\n const input = object(probe.input, `${label}.input`); exact(input, [\"resourceId\", \"vertexBufferSlot\", \"elementIndex\", \"value\"], `${label}.input`); const inputId = token(input.resourceId, `${label}.input.resourceId`); const inputResource = resources.get(inputId); const slot = integer(input.vertexBufferSlot, `${label}.input.vertexBufferSlot`); const elementIndex = integer(input.elementIndex, `${label}.input.elementIndex`); if (inputResource?.kind !== \"buffer\" || !inputResource.hasInitialData || !inputResource.usage.includes(\"vertex\")) throw new TypeError(`${label}.input must be an initialized vertex buffer.`); jsonValue(input.value, `${label}.input.value`);\n if (unit) { const pipeline = pipelines.get(pipelineId); if (!pipeline || pipeline.kind !== \"render\") throw new TypeError(`${label}.source.pipelineId is not a render pipeline.`); const layout = pipeline.vertexBuffers[slot]; const attribute = layout?.attributes.find((item) => item.shaderLocation === shaderLocation); if (!layout || !attribute || attribute.semantic !== semantic) throw new TypeError(`${label} does not identify an exact pipeline vertex semantic.`); const commandBuffer = boundedArray(command.vertexBuffers, `${label}.command.vertexBuffers`).map((item) => object(item, `${label}.command.vertexBuffer`)).find((item) => item.slot === slot); if (!commandBuffer || commandBuffer.resourceId !== inputId) throw new TypeError(`${label}.input is not bound to its declared vertex-buffer slot.`); const first = integer(layout.stepMode === \"vertex\" ? command.firstVertex : command.firstInstance, `${label}.command.firstElement`); const count = integer(layout.stepMode === \"vertex\" ? command.vertexCount : command.instanceCount, `${label}.command.elementCount`, 1); if (elementIndex < first || elementIndex >= first + count) throw new TypeError(`${label}.input element is not consumed by its draw command.`); }\n } else throw new TypeError(`${label}.kind is unsupported in qualification fixture v1.`);\n const output = object(probe.output, `${label}.output`); exact(output, [\"readbackIndex\", \"recordName\", \"expectedValue\"], `${label}.output`); integer(output.readbackIndex, `${label}.output.readbackIndex`, 0, parsedReadbacks.length - 1); token(output.recordName, `${label}.output.recordName`); jsonValue(output.expectedValue, `${label}.output.expectedValue`);\n }\n unique(probeIds, \"fixture.layoutProbes probe IDs\"); unique(probeSources, \"fixture.layoutProbes model sources\");\n return { ok: true, value: fixture as unknown as ShaderQualificationFixtureManifest };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid qualification fixture.\" }] };\n }\n}\n\n/** Validates the non-self-referential, data-only candidate bundle envelope. */\nexport function validateQualificationBundleManifest(value: unknown): ShaderResult<ShaderQualificationBundleManifest> {\n try {\n const bundle = object(value, \"qualification\"); exact(bundle, [\"contractVersion\", \"inventory\", \"subject\", \"shaderManifestCorePath\", \"gpuInterfaceManifest\", \"modelCompatibilityFixtures\", \"modules\", \"fixtures\"], \"qualification\");\n if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError(\"Unsupported qualification bundle version.\");\n const inventory = validateCompileUnitInventory(bundle.inventory); if (!inventory.ok) throw new TypeError(inventory.diagnostics.map((item) => item.message).join(\"; \"));\n const subject = object(bundle.subject, \"qualification.subject\"); exact(subject, [\"shaderManifestCore\", \"compileUnitInventorySha256\", \"shaderAbiHash\", \"interfaceManifestSha256\", \"modelAbiHashes\", \"modules\", \"requiredCompileUnitIds\", \"requiredCellIds\"], \"qualification.subject\");\n const candidate = object(subject.shaderManifestCore, \"qualification.subject.shaderManifestCore\"); exact(candidate, [\"shaderId\", \"version\", \"sha256\"], \"qualification.subject.shaderManifestCore\"); token(candidate.shaderId, \"qualification.subject.shaderManifestCore.shaderId\"); token(candidate.version, \"qualification.subject.shaderManifestCore.version\"); sha(candidate.sha256, \"qualification.subject.shaderManifestCore.sha256\");\n path(bundle.shaderManifestCorePath, \"qualification.shaderManifestCorePath\", [\".json\"]);\n const interfaceManifest = object(bundle.gpuInterfaceManifest, \"qualification.gpuInterfaceManifest\"); exact(interfaceManifest, [\"path\", \"sha256\"], \"qualification.gpuInterfaceManifest\"); path(interfaceManifest.path, \"qualification.gpuInterfaceManifest.path\", [\".json\"]); const interfaceSha = sha(interfaceManifest.sha256, \"qualification.gpuInterfaceManifest.sha256\"); if (interfaceSha !== subject.interfaceManifestSha256) throw new TypeError(\"GPU interface file digest differs from subject.\");\n const modelFixtures = boundedArray(bundle.modelCompatibilityFixtures, \"qualification.modelCompatibilityFixtures\").map((item, index) => { const label = `qualification.modelCompatibilityFixtures[${index}]`; const fixture = object(item, label); exact(fixture, [\"fixtureId\", \"path\", \"sha256\"], label); return { fixtureId: token(fixture.fixtureId, `${label}.fixtureId`), path: path(fixture.path, `${label}.path`, [\".json\"]), sha256: sha(fixture.sha256, `${label}.sha256`) }; }); if (modelFixtures.length === 0) throw new TypeError(\"Qualification requires at least one model compatibility fixture.\"); unique(modelFixtures.map((item) => item.fixtureId), \"qualification.modelCompatibilityFixtures\"); unique(modelFixtures.map((item) => item.path), \"qualification.modelCompatibilityFixtures paths\");\n sha(subject.compileUnitInventorySha256, \"qualification.subject.compileUnitInventorySha256\"); sha(subject.shaderAbiHash, \"qualification.subject.shaderAbiHash\"); sha(subject.interfaceManifestSha256, \"qualification.subject.interfaceManifestSha256\"); const modelHashes = boundedArray(subject.modelAbiHashes, \"qualification.subject.modelAbiHashes\").map((item, index) => sha(item, `qualification.subject.modelAbiHashes[${index}]`)); if (modelHashes.length === 0) throw new TypeError(\"Qualification requires at least one model ABI hash.\"); unique(modelHashes, \"qualification.subject.modelAbiHashes\");\n const modules = boundedArray(bundle.modules, \"qualification.modules\").map((item, index) => { const label = `qualification.modules[${index}]`; const module = object(item, label); exact(module, [\"moduleId\", \"path\", \"sha256\"], label); return { moduleId: token(module.moduleId, `${label}.moduleId`), path: path(module.path, `${label}.path`, [\".wgsl\"]), sha256: sha(module.sha256, `${label}.sha256`) }; }); if (modules.length === 0) throw new TypeError(\"Qualification requires at least one final WGSL module.\"); unique(modules.map((item) => item.moduleId), \"qualification.modules\"); unique(modules.map((item) => item.path), \"qualification.modules paths\");\n const subjectModules = boundedArray(subject.modules, \"qualification.subject.modules\").map((item, index) => { const label = `qualification.subject.modules[${index}]`; const module = object(item, label); exact(module, [\"moduleId\", \"sha256\"], label); return `${token(module.moduleId, `${label}.moduleId`)}:${sha(module.sha256, `${label}.sha256`)}`; }); unique(subjectModules, \"qualification.subject.modules\"); const moduleIdentities = modules.map((item) => `${item.moduleId}:${item.sha256}`); if ([...subjectModules].sort().join(\"\\n\") !== [...moduleIdentities].sort().join(\"\\n\")) throw new TypeError(\"Subject module set differs from bundle modules.\");\n const fixtures = boundedArray(bundle.fixtures, \"qualification.fixtures\").map((item, index) => { const label = `qualification.fixtures[${index}]`; const fixture = object(item, label); exact(fixture, [\"fixtureId\", \"path\", \"sha256\", \"kind\"], label); if (fixture.kind !== \"qualification-fixture\") throw new TypeError(`${label}.kind is invalid.`); return { fixtureId: token(fixture.fixtureId, `${label}.fixtureId`), path: path(fixture.path, `${label}.path`, [\".json\"]), sha256: sha(fixture.sha256, `${label}.sha256`) }; }); if (fixtures.length === 0) throw new TypeError(\"Qualification requires at least one semantic fixture.\"); unique(fixtures.map((item) => item.fixtureId), \"qualification.fixtures\"); unique(fixtures.map((item) => item.path), \"qualification.fixtures paths\");\n const fixtureIdentities = new Set(fixtures.map((item) => `${item.fixtureId}:${item.path}:${item.sha256}`)); for (const unit of inventory.value.compileUnits) { const ref = unit.qualificationFixture; if (!fixtureIdentities.has(`${ref.fixtureId}:${ref.path}:${ref.sha256}`)) throw new TypeError(`Compile unit ${unit.compileUnitId} fixture is absent or stale.`); }\n const unitIds = orderedUniqueTokens(subject.requiredCompileUnitIds, \"qualification.subject.requiredCompileUnitIds\"); const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort(); if (unitIds.join(\"\\n\") !== expectedUnits.join(\"\\n\")) throw new TypeError(\"Subject compile-unit IDs differ from inventory.\"); orderedUniqueTokens(subject.requiredCellIds, \"qualification.subject.requiredCellIds\");\n return { ok: true, value: bundle as unknown as ShaderQualificationBundleManifest };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid qualification bundle.\" }] };\n }\n}\n","import { canonicalizeGpuContract } from \"../canonical-json.js\";\nimport {\n SHADER_VALIDATION_EVIDENCE_VERSION,\n type GitObjectId,\n type ShaderCellEvidence,\n type ShaderDiagnostic,\n type ShaderNonQualifyingWorkflowDiagnostic,\n type ShaderQualificationBundleManifest,\n type ShaderQualificationCandidateSubject,\n type ShaderQualificationPreflightManifest,\n type ShaderQualificationExecutionProducer,\n type ShaderQualificationResult,\n type ShaderQualificationStatus,\n type ShaderResult,\n type ShaderRunnerCellPreflightEvidence,\n type ShaderTrustedWorkflowProvenance,\n type ShaderValidationCellRun,\n type ShaderValidationEvidence,\n type ShaderValidationEvidenceAttestationRef,\n type Sha256Hex,\n type StableWebGpuMatrixCell,\n type StableWebGpuMatrixManifest,\n} from \"../contracts.js\";\nimport { asSha256Hex, computeSha256 } from \"../hash.js\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nexport interface EvidenceArtifact<T> {\n readonly value: T;\n readonly bytes: Uint8Array;\n readonly sha256: Sha256Hex;\n}\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const expected = new Set(keys);\n if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key in value)) throw new TypeError(`${path} has unknown or missing fields.`);\n}\n\nfunction token(value: unknown, path: string, maximum = 512): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 0x1f)) throw new TypeError(`${path} is not a bounded string.`);\n return value;\n}\n\nfunction sha(value: unknown, path: string): Sha256Hex {\n try { return asSha256Hex(token(value, path, 64)); }\n catch (cause) { throw new TypeError(`${path} is not a SHA-256 digest.`, { cause }); }\n}\n\nfunction integer(value: unknown, path: string, minimum = 0): number {\n if (!Number.isSafeInteger(value) || Number(value) < minimum) throw new TypeError(`${path} is not a safe integer.`);\n return Number(value);\n}\n\nfunction timestamp(value: unknown, path: string): string {\n const parsed = token(value, path, 64);\n if (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(parsed) || !Number.isFinite(Date.parse(parsed))) throw new TypeError(`${path} must be an ISO UTC timestamp.`);\n return parsed;\n}\n\nfunction array(value: unknown, path: string, maximum = 100_000): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${path} must be a bounded array.`);\n return value;\n}\n\nfunction gitObject(value: unknown, path: string): GitObjectId {\n const input = object(value, path); exact(input, [\"algorithm\", \"hex\"], path);\n const algorithm = input.algorithm; if (algorithm !== \"sha1\" && algorithm !== \"sha256\") throw new TypeError(`${path}.algorithm is invalid.`);\n const hex = token(input.hex, `${path}.hex`, 64); const length = algorithm === \"sha1\" ? 40 : 64;\n if (!new RegExp(`^[a-f0-9]{${length}}$`, \"u\").test(hex)) throw new TypeError(`${path}.hex does not match its algorithm.`);\n return input as unknown as GitObjectId;\n}\n\nconst TRUSTED_WORKFLOW_PREFIX = \"Plasius-LTD/gpu-shader/.github/workflows/shader-qualification.yml@\";\n\nfunction trustedWorkflowRef(value: unknown, path: string): string {\n const result = token(value, path, 1024);\n if (result !== `${TRUSTED_WORKFLOW_PREFIX}refs/heads/main`) throw new TypeError(`${path} must bind the trusted shader-qualification workflow on protected main.`);\n return result;\n}\n\nexport function parseTrustedWorkflowProvenance(value: unknown, path = \"provenance\"): ShaderTrustedWorkflowProvenance {\n const input = object(value, path); exact(input, [\"repository\", \"commit\", \"ref\", \"workflowRef\", \"workflowSha\", \"runId\", \"runAttempt\", \"job\", \"eventName\", \"oidcAttestation\"], path);\n const repository = token(input.repository, `${path}.repository`); if (!repository.startsWith(\"Plasius-LTD/\")) throw new TypeError(`${path}.repository is outside Plasius-LTD.`); gitObject(input.commit, `${path}.commit`); token(input.ref, `${path}.ref`); gitObject(input.workflowSha, `${path}.workflowSha`); trustedWorkflowRef(input.workflowRef, `${path}.workflowRef`); token(input.runId, `${path}.runId`); integer(input.runAttempt, `${path}.runAttempt`, 1); token(input.job, `${path}.job`); token(input.eventName, `${path}.eventName`);\n const oidc = object(input.oidcAttestation, `${path}.oidcAttestation`); exact(oidc, [\"issuer\", \"subject\", \"audience\", \"verifiedClaimsSha256\", \"verifiedAt\", \"source\"], `${path}.oidcAttestation`);\n if (oidc.issuer !== \"https://token.actions.githubusercontent.com\" || oidc.source !== \"trusted-runner-preflight\") throw new TypeError(`${path}.oidcAttestation is not GitHub trusted-preflight provenance.`);\n token(oidc.subject, `${path}.oidcAttestation.subject`, 2048); token(oidc.audience, `${path}.oidcAttestation.audience`, 2048); sha(oidc.verifiedClaimsSha256, `${path}.oidcAttestation.verifiedClaimsSha256`); timestamp(oidc.verifiedAt, `${path}.oidcAttestation.verifiedAt`);\n return input as unknown as ShaderTrustedWorkflowProvenance;\n}\n\n/** Strictly parses the actual job/runner identity that produced a cell artifact. */\nexport function parseQualificationExecutionProducer(value: unknown, path = \"producer\"): ShaderQualificationExecutionProducer {\n const input = object(value, path); exact(input, [\"repository\", \"commit\", \"ref\", \"runId\", \"runAttempt\", \"job\", \"trustedWorkflowRepository\", \"trustedWorkflowRef\", \"trustedWorkflowSha\", \"runner\"], path);\n const repository = token(input.repository, `${path}.repository`); if (!repository.startsWith(\"Plasius-LTD/\")) throw new TypeError(`${path}.repository is outside Plasius-LTD.`);\n gitObject(input.commit, `${path}.commit`); token(input.ref, `${path}.ref`); token(input.runId, `${path}.runId`); integer(input.runAttempt, `${path}.runAttempt`, 1);\n if (![\"swiftshader\", \"physical\", \"physical-runner-preflight\"].includes(String(input.job))) throw new TypeError(`${path}.job is not a qualification workflow job.`);\n if (input.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\") throw new TypeError(`${path}.trustedWorkflowRepository differs.`);\n gitObject(input.trustedWorkflowSha, `${path}.trustedWorkflowSha`); trustedWorkflowRef(input.trustedWorkflowRef, `${path}.trustedWorkflowRef`);\n const runner = object(input.runner, `${path}.runner`); exact(runner, [\"name\", \"environment\", \"os\", \"architecture\"], `${path}.runner`); token(runner.name, `${path}.runner.name`); if (![\"github-hosted\", \"self-hosted\", \"device-farm\"].includes(String(runner.environment))) throw new TypeError(`${path}.runner.environment is invalid.`); token(runner.os, `${path}.runner.os`); token(runner.architecture, `${path}.runner.architecture`);\n return input as unknown as ShaderQualificationExecutionProducer;\n}\n\nfunction assertProducerMatchesPreflight(producer: ShaderQualificationExecutionProducer, provenance: ShaderTrustedWorkflowProvenance, cell: StableWebGpuMatrixCell, path: string, expectedJob: ShaderQualificationExecutionProducer[\"job\"]): void {\n if (producer.repository !== provenance.repository || !canonicalEqual(producer.commit, provenance.commit)\n || producer.ref !== provenance.ref || producer.runId !== provenance.runId || producer.runAttempt !== provenance.runAttempt\n || producer.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\" || producer.trustedWorkflowRef !== provenance.workflowRef\n || !canonicalEqual(producer.trustedWorkflowSha, provenance.workflowSha) || producer.job !== expectedJob) throw new TypeError(`${path} does not match the exact qualification workflow run or subject.`);\n if (expectedJob === \"swiftshader\" && producer.runner.environment !== \"github-hosted\") throw new TypeError(`${path} must identify the hosted SwiftShader job.`);\n if (expectedJob === \"physical\" && producer.runner.environment === \"github-hosted\") throw new TypeError(`${path} cannot use a hosted runner for a physical execution cell.`);\n if (expectedJob === \"physical-runner-preflight\" && producer.runner.environment !== \"github-hosted\") throw new TypeError(`${path} must identify its hosted orchestration job truthfully.`);\n}\n\nfunction canonicalEqual(left: unknown, right: unknown): boolean {\n return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);\n}\n\nfunction foldRunnerLabel(value: string): string {\n return value.replace(/[A-Z]/gu, (character) => character.toLowerCase());\n}\n\nexport async function computeQualificationInventorySha256(bundle: ShaderQualificationBundleManifest): Promise<Sha256Hex> {\n return computeSha256(canonicalizeGpuContract(bundle.inventory));\n}\n\nexport async function computeQualificationSubjectBinding(input: {\n readonly subject: ShaderQualificationCandidateSubject;\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n}): Promise<Sha256Hex> {\n return computeSha256(`plasius.gpu.qualification-subject/v1\\n${canonicalizeGpuContract(input)}`);\n}\n\nasync function computeValidationEvidenceId(value: unknown): Promise<string> {\n const input = object(value, \"evidence identity input\");\n const projection = Object.fromEntries(Object.entries(input).filter(([key]) => key !== \"evidenceId\"));\n return `qualification-${(await computeSha256(`plasius.gpu.validation-evidence/v1\\n${canonicalizeGpuContract(projection)}`)).slice(0, 24)}`;\n}\n\nfunction immutableBlobUri(value: string): { host: string; versionId: string; uri: string } {\n const url = new URL(value);\n if (url.protocol !== \"https:\" || url.username || url.password || url.hash || url.port\n || !/^[a-z0-9]{3,24}\\.blob\\.core\\.windows\\.net$/u.test(url.hostname)\n || !/^[A-Za-z0-9][A-Za-z0-9._/-]*\\.tar$/u.test(url.pathname.slice(1))\n || url.pathname.split(\"/\").some((segment, index) => index > 0 && (!segment || segment === \".\" || segment === \"..\"))) {\n throw new TypeError(\"Source URI must be a normalized immutable Azure Blob .tar URL.\");\n }\n const versionIds = [...url.searchParams.entries()].filter(([key]) => key.toLowerCase() === \"versionid\");\n if ([...url.searchParams.keys()].length !== 1 || versionIds.length !== 1 || !/^[A-Za-z0-9._:-]{1,128}$/u.test(versionIds[0]![1])) throw new TypeError(\"Source URI must use exactly one versionId and no other query parameters.\");\n return { host: url.host.toLowerCase(), versionId: versionIds[0]![1], uri: value };\n}\n\n/** Creates the trusted prepare artifact without persisting an OIDC token. */\nexport async function createQualificationPreflight(input: {\n readonly qualificationId: string;\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly sourceUri: string;\n readonly dataBundleSha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n readonly provenance: ShaderTrustedWorkflowProvenance;\n}): Promise<ShaderQualificationPreflightManifest> {\n token(input.qualificationId, \"qualificationId\");\n let parsedMatrix: unknown;\n try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); }\n catch (cause) { throw new TypeError(\"Selected matrix artifact is not UTF-8 JSON.\", { cause }); }\n if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Selected matrix artifact bytes differ from the supplied matrix value.\");\n const actualMatrixSha256 = await computeSha256(input.matrixBytes);\n if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError(\"Selected matrix digest is not derived from the exact matrix manifest.\");\n const inventorySha256 = await computeQualificationInventorySha256(input.bundle);\n if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError(\"Bundle subject contains a stale compile-unit inventory digest.\");\n const requiredCells = input.matrix.cells.map((cell) => cell.cellId);\n if (!canonicalEqual(input.bundle.subject.requiredCellIds, requiredCells)) throw new TypeError(\"Bundle subject cell set differs from the selected matrix.\");\n const subjectBindingSha256 = await computeQualificationSubjectBinding({\n subject: input.bundle.subject,\n dataBundleSha256: input.dataBundleSha256,\n compileUnitInventorySha256: inventorySha256,\n matrixSha256: input.matrixSha256,\n harnessSha256: input.harnessSha256,\n });\n return {\n contractVersion: SHADER_VALIDATION_EVIDENCE_VERSION,\n kind: \"shader-qualification-preflight\",\n qualificationId: input.qualificationId,\n sourceBlob: immutableBlobUri(input.sourceUri),\n dataBundleSha256: input.dataBundleSha256,\n compileUnitInventorySha256: inventorySha256,\n matrixSha256: input.matrixSha256,\n harnessSha256: input.harnessSha256,\n subjectBindingSha256,\n provenance: parseTrustedWorkflowProvenance(input.provenance, \"preflight.provenance\"),\n };\n}\n\nfunction assertDiagnostic(value: unknown, path: string): ShaderDiagnostic {\n const input = object(value, path); const allowed = new Set([\"code\", \"severity\", \"message\", \"path\", \"expected\", \"actual\"]);\n if (!Object.keys(input).every((key) => allowed.has(key)) || ![\"code\", \"severity\", \"message\"].every((key) => key in input)) throw new TypeError(`${path} has unknown or missing fields.`);\n token(input.code, `${path}.code`); if (![\"error\", \"warning\", \"info\"].includes(String(input.severity))) throw new TypeError(`${path}.severity is invalid.`); token(input.message, `${path}.message`, 4096); if (input.path !== undefined) token(input.path, `${path}.path`, 1024);\n return input as unknown as ShaderDiagnostic;\n}\n\nconst phaseNames = [\"assembly\", \"reflection-schema\", \"shader-compilation\", \"pipeline-layout\", \"pipeline-creation\", \"bind-group-creation\", \"cpu-to-gpu-layout\", \"gpu-to-cpu-layout\", \"bounded-execution\", \"semantic-readback\"] as const;\n\nfunction osVersionMatches(cell: StableWebGpuMatrixCell, version: string, channel: string | null): boolean {\n if (!/^\\d+(?:\\.\\d+)*(?:[-+][A-Za-z0-9.]+)?$/u.test(version)) return false;\n const requirement = cell.os.versionRequirement;\n if (requirement.kind === \"exact\") return channel === null && version === requirement.value;\n const major = Number.parseInt(version.split(\".\")[0]!, 10);\n if (requirement.kind === \"major\") return channel === null && major === requirement.value;\n if (requirement.kind === \"minimum-major\") return channel === null && major >= requirement.value;\n return channel === requirement.channel;\n}\n\nfunction assertResult(value: unknown, path: string, cell: StableWebGpuMatrixCell, passingRequired: boolean, timeBounds?: { readonly earliest: string; readonly latest: string }, expectedRunner?: { readonly name: string; readonly labels: readonly string[] }): ShaderQualificationResult {\n const input = object(value, path); exact(input, [\"compileUnitId\", \"cellId\", \"status\", \"startedAt\", \"completedAt\", \"observed\", \"phases\", \"diagnostics\"], path);\n token(input.compileUnitId, `${path}.compileUnitId`); if (input.cellId !== cell.cellId) throw new TypeError(`${path}.cellId differs from its cell evidence.`);\n const status = String(input.status) as ShaderQualificationStatus; if (![\"passed\", \"failed\", \"skipped\", \"timeout\", \"device-lost\", \"runner-unavailable\", \"adapter-unavailable\"].includes(status)) throw new TypeError(`${path}.status is invalid.`);\n const started = timestamp(input.startedAt, `${path}.startedAt`); const completed = timestamp(input.completedAt, `${path}.completedAt`); if (Date.parse(completed) < Date.parse(started)) throw new TypeError(`${path} has reversed timestamps.`); if (timeBounds && (Date.parse(started) < Date.parse(timeBounds.earliest) || Date.parse(completed) > Date.parse(timeBounds.latest))) throw new TypeError(`${path} timestamps fall outside trusted preflight and aggregation bounds.`);\n const observed = object(input.observed, `${path}.observed`); exact(observed, [\"runner\", \"os\", \"browser\", \"adapter\", \"features\", \"limits\"], `${path}.observed`);\n const runner = object(observed.runner, `${path}.observed.runner`); exact(runner, [\"id\", \"labels\"], `${path}.observed.runner`); const runnerId = token(runner.id, `${path}.observed.runner.id`); const labels = array(runner.labels, `${path}.observed.runner.labels`).map((item, index) => token(item, `${path}.observed.runner.labels[${index}]`)); const normalizedLabels = labels.map(foldRunnerLabel); if (new Set(normalizedLabels).size !== normalizedLabels.length || cell.runnerLabels.some((label) => !normalizedLabels.includes(foldRunnerLabel(label)))) throw new TypeError(`${path} actual runner labels do not contain the matrix route (ASCII case-insensitive).`); if (expectedRunner && (runnerId !== expectedRunner.name || !canonicalEqual(labels, expectedRunner.labels))) throw new TypeError(`${path} runner identity/labels differ from the exact runner API preflight observation.`);\n const os = object(observed.os, `${path}.observed.os`); exact(os, [\"name\", \"version\", \"channel\", \"architecture\"], `${path}.observed.os`); const osVersion = token(os.version, `${path}.observed.os.version`); const osChannel = os.channel === null ? null : token(os.channel, `${path}.observed.os.channel`); if (os.name !== cell.os.name || os.architecture !== cell.os.architecture || (status === \"passed\" && !osVersionMatches(cell, osVersion, osChannel)) || (status !== \"passed\" && osVersion !== \"unavailable\" && !osVersionMatches(cell, osVersion, osChannel))) throw new TypeError(`${path} observed the wrong OS target or failed its version requirement.`);\n const browser = object(observed.browser, `${path}.observed.browser`); exact(browser, [\"name\", \"version\", \"channel\"], `${path}.observed.browser`); if (browser.name !== cell.browser.name || browser.channel !== cell.browser.channel) throw new TypeError(`${path} observed the wrong browser target.`); const browserVersion = token(browser.version, `${path}.observed.browser.version`);\n const adapter = object(observed.adapter, `${path}.observed.adapter`); exact(adapter, [\"physical\", \"vendor\", \"family\", \"architecture\", \"device\", \"description\", \"backend\", \"driver\"], `${path}.observed.adapter`); if (adapter.physical !== (cell.adapter.kind === \"physical\") || adapter.backend !== cell.adapter.backend || String(adapter.vendor).trim().toLowerCase() !== cell.adapter.vendor || String(adapter.family).trim().toLowerCase() !== cell.adapter.family) throw new TypeError(`${path} observed the wrong adapter vendor/family/backend.`); for (const key of [\"vendor\", \"family\", \"architecture\", \"device\", \"description\", \"driver\"]) token(adapter[key], `${path}.observed.adapter.${key}`, 1024);\n const features = array(observed.features, `${path}.observed.features`).map((item, index) => token(item, `${path}.observed.features[${index}]`)); if (new Set(features).size !== features.length) throw new TypeError(`${path}.observed.features contains duplicates.`); const limits = object(observed.limits, `${path}.observed.limits`); for (const [name, limit] of Object.entries(limits)) { token(name, `${path}.observed.limits key`); if (typeof limit !== \"number\" || !Number.isFinite(limit) || limit < 0) throw new TypeError(`${path}.observed.limits.${name} is invalid.`); }\n const phases = array(input.phases, `${path}.phases`, phaseNames.length).map((phaseValue, index) => { const phasePath = `${path}.phases[${index}]`; const phase = object(phaseValue, phasePath); const name = String(phase.name); if (name === \"shader-compilation\") { exact(phase, [\"name\", \"status\", \"durationMs\", \"compilationMessagesSha256\", \"errorCount\"], phasePath); sha(phase.compilationMessagesSha256, `${phasePath}.compilationMessagesSha256`); integer(phase.errorCount, `${phasePath}.errorCount`); } else if (name === \"semantic-readback\") { exact(phase, [\"name\", \"status\", \"durationMs\", \"expectedSha256\", \"actualSha256\"], phasePath); sha(phase.expectedSha256, `${phasePath}.expectedSha256`); sha(phase.actualSha256, `${phasePath}.actualSha256`); } else { exact(phase, [\"name\", \"status\", \"durationMs\", \"evidenceSha256\"], phasePath); sha(phase.evidenceSha256, `${phasePath}.evidenceSha256`); } if (!phaseNames.includes(name as typeof phaseNames[number]) || ![\"passed\", \"failed\"].includes(String(phase.status))) throw new TypeError(`${phasePath} is invalid.`); integer(phase.durationMs, `${phasePath}.durationMs`); return phase; });\n const diagnostics = array(input.diagnostics, `${path}.diagnostics`, 256).map((item, index) => assertDiagnostic(item, `${path}.diagnostics[${index}]`));\n if (passingRequired || status === \"passed\") {\n if (status !== \"passed\" || phases.length !== phaseNames.length || !phaseNames.every((name, index) => phases[index]?.name === name && phases[index]?.status === \"passed\")) throw new TypeError(`${path} lacks all ten passed qualification phases in fixed order.`);\n if (runnerId === \"unavailable\" || browserVersion === \"unavailable\" || adapter.device === \"unavailable\" || adapter.driver === \"unavailable\") throw new TypeError(`${path} passed without concrete runner/browser/adapter/driver observations.`);\n const compilation = phases.find((phase) => phase.name === \"shader-compilation\")!; if (compilation.errorCount !== 0) throw new TypeError(`${path} contains compilation errors.`);\n const readback = phases.find((phase) => phase.name === \"semantic-readback\")!; if (readback.expectedSha256 !== readback.actualSha256) throw new TypeError(`${path} semantic readback differs.`);\n if (diagnostics.some((item) => item.severity === \"error\")) throw new TypeError(`${path} passed with an error diagnostic.`);\n }\n return input as unknown as ShaderQualificationResult;\n}\n\nfunction assertCellEvidence(value: unknown, cell: StableWebGpuMatrixCell, matrix: StableWebGpuMatrixManifest, preflight: ShaderQualificationPreflightManifest, harness: { id: string; version: string; sha256: Sha256Hex }, adapterHarness: { readonly id: string; readonly version: string; readonly sha256: Sha256Hex } | null, expectedRunner: { readonly name: string; readonly labels: readonly string[] }, expectedUnits: ReadonlySet<string>, latest: string): ShaderCellEvidence {\n const input = object(value, `cellEvidence.${cell.cellId}`); exact(input, [\"contractVersion\", \"qualificationId\", \"matrixId\", \"matrixVersion\", \"matrixSha256\", \"cellId\", \"dataBundleSha256\", \"compileUnitInventorySha256\", \"harness\", \"automation\", \"subjectBindingSha256\", \"qualificationPreflightProvenance\", \"producer\", \"results\"], `cellEvidence.${cell.cellId}`);\n if (input.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.qualificationId !== preflight.qualificationId || input.matrixId !== matrix.matrixId || input.matrixVersion !== matrix.version || input.cellId !== cell.cellId || input.matrixSha256 !== preflight.matrixSha256 || input.dataBundleSha256 !== preflight.dataBundleSha256 || input.compileUnitInventorySha256 !== preflight.compileUnitInventorySha256 || input.subjectBindingSha256 !== preflight.subjectBindingSha256) throw new TypeError(`Cell evidence ${cell.cellId} has stale subject/matrix identities.`);\n const actualHarness = object(input.harness, `cellEvidence.${cell.cellId}.harness`); exact(actualHarness, [\"id\", \"version\", \"sha256\"], `cellEvidence.${cell.cellId}.harness`); if (!canonicalEqual(actualHarness, harness)) throw new TypeError(`Cell evidence ${cell.cellId} used a different harness.`);\n const automation = object(input.automation, `cellEvidence.${cell.cellId}.automation`); exact(automation, [\"kind\", \"driver\", \"version\", \"sha256\"], `cellEvidence.${cell.cellId}.automation`); if (automation.kind !== cell.automation.kind) throw new TypeError(`Cell evidence ${cell.cellId} used the wrong automation route.`); token(automation.driver, `cellEvidence.${cell.cellId}.automation.driver`); token(automation.version, `cellEvidence.${cell.cellId}.automation.version`); sha(automation.sha256, `cellEvidence.${cell.cellId}.automation.sha256`); if (adapterHarness !== null && !canonicalEqual({ id: automation.driver, version: automation.version, sha256: automation.sha256 }, adapterHarness)) throw new TypeError(`Cell evidence ${cell.cellId} automation differs from its independently verified preflight adapter harness.`);\n if (!canonicalEqual(parseTrustedWorkflowProvenance(input.qualificationPreflightProvenance), preflight.provenance)) throw new TypeError(`Cell evidence ${cell.cellId} changed trusted prepare provenance.`);\n const producer = parseQualificationExecutionProducer(input.producer, `cellEvidence.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `cellEvidence.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\");\n const results = array(input.results, `cellEvidence.${cell.cellId}.results`); if (results.length !== expectedUnits.size) throw new TypeError(`Cell evidence ${cell.cellId} result count is incomplete.`); const ids = new Set<string>(); results.forEach((result, index) => { const parsed = assertResult(result, `cellEvidence.${cell.cellId}.results[${index}]`, cell, true, { earliest: preflight.provenance.oidcAttestation.verifiedAt, latest }, expectedRunner); if (parsed.observed.runner.id !== producer.runner.name) throw new TypeError(`Cell evidence ${cell.cellId} result runner differs from its producer.`); if (!expectedUnits.has(parsed.compileUnitId) || ids.has(parsed.compileUnitId)) throw new TypeError(`Cell evidence ${cell.cellId} has duplicate/unexpected compile unit ${parsed.compileUnitId}.`); ids.add(parsed.compileUnitId); });\n return input as unknown as ShaderCellEvidence;\n}\n\nfunction syntheticResult(unitId: string, cell: StableWebGpuMatrixCell, status: ShaderQualificationStatus, message: string, now: string): ShaderQualificationResult {\n return {\n compileUnitId: unitId, cellId: cell.cellId, status, startedAt: now, completedAt: now,\n observed: {\n runner: { id: \"unavailable\", labels: cell.runnerLabels },\n os: { name: cell.os.name, version: \"unavailable\", channel: null, architecture: cell.os.architecture },\n browser: { name: cell.browser.name, version: \"unavailable\", channel: cell.browser.channel },\n adapter: { physical: cell.adapter.kind === \"physical\", vendor: cell.adapter.vendor, family: cell.adapter.family, architecture: cell.os.architecture, device: \"unavailable\", description: \"unavailable\", backend: cell.adapter.backend, driver: \"unavailable\" },\n features: [], limits: {},\n }, phases: [], diagnostics: [{ code: status === \"timeout\" ? \"timeout\" : \"runner-unavailable\", severity: \"error\", message }],\n };\n}\n\nexport interface AggregateShaderValidationEvidenceInput {\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly preflight: EvidenceArtifact<ShaderQualificationPreflightManifest>;\n readonly cellEvidence: readonly EvidenceArtifact<ShaderCellEvidence>[];\n readonly runnerPreflights: readonly EvidenceArtifact<ShaderRunnerCellPreflightEvidence>[];\n readonly workflowDiagnostics: readonly EvidenceArtifact<ShaderNonQualifyingWorkflowDiagnostic>[];\n readonly harness: { readonly id: string; readonly version: string; readonly sha256: Sha256Hex };\n readonly packageVersion: string;\n readonly generatedAt?: string;\n}\n\n/** Aggregates exactly one immutable result for every compile-unit × matrix-cell pair. */\nexport async function aggregateShaderValidationEvidence(input: AggregateShaderValidationEvidenceInput): Promise<ShaderValidationEvidence> {\n const verifyArtifact = async <T>(artifact: EvidenceArtifact<T>, label: string): Promise<void> => {\n if (await computeSha256(artifact.bytes) !== artifact.sha256) throw new TypeError(`${label} artifact digest is not derived from its exact bytes.`);\n let parsed: unknown;\n try { parsed = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(artifact.bytes)); }\n catch (cause) { throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause }); }\n if (!canonicalEqual(parsed, artifact.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);\n };\n await verifyArtifact(input.preflight, \"Qualification preflight\");\n for (const artifact of input.cellEvidence) await verifyArtifact(artifact, \"Cell evidence\");\n for (const artifact of input.runnerPreflights) await verifyArtifact(artifact, \"Runner preflight\");\n for (const artifact of input.workflowDiagnostics) await verifyArtifact(artifact, \"Workflow diagnostic\");\n const preflight = input.preflight.value; const preflightInput = object(preflight, \"Qualification preflight\"); exact(preflightInput, [\"contractVersion\", \"kind\", \"qualificationId\", \"sourceBlob\", \"dataBundleSha256\", \"compileUnitInventorySha256\", \"matrixSha256\", \"harnessSha256\", \"subjectBindingSha256\", \"provenance\"], \"Qualification preflight\"); if (preflight.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || preflight.kind !== \"shader-qualification-preflight\") throw new TypeError(\"Missing trusted qualification preflight.\");\n token(preflight.qualificationId, \"Qualification preflight.qualificationId\"); sha(preflight.dataBundleSha256, \"Qualification preflight.dataBundleSha256\"); sha(preflight.compileUnitInventorySha256, \"Qualification preflight.compileUnitInventorySha256\"); sha(preflight.matrixSha256, \"Qualification preflight.matrixSha256\"); sha(preflight.harnessSha256, \"Qualification preflight.harnessSha256\"); sha(preflight.subjectBindingSha256, \"Qualification preflight.subjectBindingSha256\"); const preflightProvenance = parseTrustedWorkflowProvenance(preflight.provenance, \"Qualification preflight.provenance\");\n const sourceBlob = object(preflight.sourceBlob, \"Qualification preflight.sourceBlob\"); exact(sourceBlob, [\"host\", \"versionId\", \"uri\"], \"Qualification preflight.sourceBlob\"); const normalizedSource = immutableBlobUri(token(sourceBlob.uri, \"Qualification preflight.sourceBlob.uri\", 2048)); if (!canonicalEqual(sourceBlob, normalizedSource)) throw new TypeError(\"Qualification preflight source Blob claims are stale.\");\n let parsedMatrix: unknown; try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); } catch (cause) { throw new TypeError(\"Matrix artifact is not UTF-8 JSON.\", { cause }); } if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Matrix artifact bytes differ from the supplied matrix value.\"); const actualMatrixSha256 = await computeSha256(input.matrixBytes); if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError(\"Qualification preflight matrix artifact digest is stale.\");\n const actualInventorySha256 = await computeQualificationInventorySha256(input.bundle); if (preflight.compileUnitInventorySha256 !== actualInventorySha256 || input.bundle.subject.compileUnitInventorySha256 !== actualInventorySha256) throw new TypeError(\"Qualification preflight inventory digest is stale.\");\n const actualSubjectBinding = await computeQualificationSubjectBinding({ subject: input.bundle.subject, dataBundleSha256: preflight.dataBundleSha256, compileUnitInventorySha256: actualInventorySha256, matrixSha256: actualMatrixSha256, harnessSha256: input.harness.sha256 }); if (preflight.subjectBindingSha256 !== actualSubjectBinding) throw new TypeError(\"Qualification preflight subject binding is stale.\");\n const units = new Set(input.bundle.inventory.compileUnits.map((unit) => unit.compileUnitId)); const now = input.generatedAt ?? new Date().toISOString(); timestamp(now, \"generatedAt\"); if (Date.parse(now) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError(\"Aggregate timestamp predates trusted preflight verification.\");\n if (input.harness.sha256 !== preflight.harnessSha256) throw new TypeError(\"Harness digest differs from trusted preflight.\");\n const cells = new Map(input.matrix.cells.map((cell) => [cell.cellId, cell]));\n const cellArtifacts = new Map<string, EvidenceArtifact<ShaderCellEvidence>>(); for (const artifact of input.cellEvidence) { const id = artifact.value.cellId; if (!cells.has(id) || cellArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected cell evidence ${id}.`); cellArtifacts.set(id, artifact); }\n const runnerArtifacts = new Map<string, EvidenceArtifact<ShaderRunnerCellPreflightEvidence>>(); for (const artifact of input.runnerPreflights) { const id = artifact.value.cellId; if (!cells.has(id) || runnerArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected runner preflight ${id}.`); runnerArtifacts.set(id, artifact); }\n const diagnosticArtifacts = new Map<string, EvidenceArtifact<ShaderNonQualifyingWorkflowDiagnostic>>(); for (const artifact of input.workflowDiagnostics) { const id = artifact.value.cellId; if (!cells.has(id) || diagnosticArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected workflow diagnostic ${id}.`); diagnosticArtifacts.set(id, artifact); }\n const results: ShaderQualificationResult[] = []; const cellRuns: ShaderValidationCellRun[] = [];\n for (const cell of input.matrix.cells) {\n const runner = runnerArtifacts.get(cell.cellId); const diagnostic = diagnosticArtifacts.get(cell.cellId); const cellArtifact = cellArtifacts.get(cell.cellId);\n if (!runner) throw new TypeError(`Cell ${cell.cellId} lacks runner preflight evidence.`);\n if (runner) {\n const value = runner.value; const raw = object(value, `runnerPreflight.${cell.cellId}`); exact(raw, [\"contractVersion\", \"kind\", \"qualificationId\", \"cellId\", \"status\", \"matrixSha256\", \"runnerLabels\", \"matchedRunners\", \"adapterHarness\", \"qualificationPreflightProvenance\", \"producer\"], `runnerPreflight.${cell.cellId}`); const producer = parseQualificationExecutionProducer(value.producer, `runnerPreflight.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `runnerPreflight.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical-runner-preflight\"); if (value.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value.kind !== \"shader-runner-cell-preflight-evidence\" || value.qualificationId !== preflight.qualificationId || value.cellId !== cell.cellId || value.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual(value.runnerLabels, cell.runnerLabels) || !canonicalEqual(value.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Runner preflight ${cell.cellId} is stale or inconsistent.`);\n const requestedLabels = cell.runnerLabels.map(foldRunnerLabel); const matched = array(value.matchedRunners, `runnerPreflight.${cell.cellId}.matchedRunners`).map((item, index) => { const label = `runnerPreflight.${cell.cellId}.matchedRunners[${index}]`; const match = object(item, label); exact(match, [\"name\", \"labels\"], label); const labels = array(match.labels, `${label}.labels`).map((entry, labelIndex) => token(entry, `${label}.labels[${labelIndex}]`)); const normalized = labels.map(foldRunnerLabel); if (labels.length === 0 || new Set(normalized).size !== normalized.length || requestedLabels.some((required) => !normalized.includes(required))) throw new TypeError(`${label} does not preserve the actual runner API labels containing the requested matrix route.`); return { name: token(match.name, `${label}.name`), labels }; }); if (new Set(matched.map((item) => item.name)).size !== matched.length) throw new TypeError(`Runner preflight ${cell.cellId} repeats matched runners.`);\n if (value.adapterHarness !== null) { const adapterHarness = object(value.adapterHarness, `runnerPreflight.${cell.cellId}.adapterHarness`); exact(adapterHarness, [\"id\", \"version\", \"sha256\"], `runnerPreflight.${cell.cellId}.adapterHarness`); token(adapterHarness.id, `runnerPreflight.${cell.cellId}.adapterHarness.id`); token(adapterHarness.version, `runnerPreflight.${cell.cellId}.adapterHarness.version`); sha(adapterHarness.sha256, `runnerPreflight.${cell.cellId}.adapterHarness.sha256`); }\n if (value.status === \"available\" && matched.length === 0) throw new TypeError(`Available cell ${cell.cellId} has no matched runner.`);\n if (value.status === \"runner-unavailable\" && matched.length !== 0) throw new TypeError(`Unavailable cell ${cell.cellId} claims matched runners.`);\n if (value.status === \"runner-unavailable\" && value.adapterHarness !== null) throw new TypeError(`Unavailable cell ${cell.cellId} claims an executed adapter harness.`);\n if (value.status === \"available\" && cell.adapter.kind === \"software\" && value.adapterHarness === null) throw new TypeError(`Hosted SwiftShader cell ${cell.cellId} lacks its independently observable adapter harness.`);\n }\n if (diagnostic && cellArtifact) throw new TypeError(`Cell ${cell.cellId} has conflicting diagnostic and qualification evidence.`);\n if (runner?.value.status === \"runner-unavailable\") {\n if (cellArtifact || diagnostic) throw new TypeError(`Unavailable cell ${cell.cellId} has conflicting evidence.`);\n for (const unit of units) results.push(syntheticResult(unit, cell, \"runner-unavailable\", \"Required physical runner was unavailable.\", now));\n const cellResults = results.slice(-units.size); cellRuns.push({ cellId: cell.cellId, source: \"runner-preflight\", sourceArtifactSha256: runner.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: runner.value.producer, harness: input.harness, automation: null, resultCount: units.size, status: \"runner-unavailable\" });\n continue;\n }\n if (diagnostic) {\n const value = diagnostic.value; const raw = object(value, `workflowDiagnostic.${cell.cellId}`); exact(raw, [\"contractVersion\", \"kind\", \"qualificationId\", \"cellId\", \"status\", \"matrixSha256\", \"message\", \"qualificationPreflightProvenance\", \"producer\"], `workflowDiagnostic.${cell.cellId}`); const producer = parseQualificationExecutionProducer(value.producer, `workflowDiagnostic.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `workflowDiagnostic.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\"); if (!runner.value.matchedRunners.some((item) => item.name === producer.runner.name)) throw new TypeError(`Workflow diagnostic ${cell.cellId} was not produced by a runner matched in preflight.`); if (value.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value.kind !== \"non-qualifying-workflow-diagnostic\" || value.qualificationId !== preflight.qualificationId || value.cellId !== cell.cellId || value.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual(value.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Workflow diagnostic ${cell.cellId} is stale or inconsistent.`); token(value.message, `workflowDiagnostic.${cell.cellId}.message`, 4096);\n const status = value.status === \"timeout\" ? \"timeout\" : \"failed\"; for (const unit of units) results.push(syntheticResult(unit, cell, status, value.message, now));\n const cellResults = results.slice(-units.size); cellRuns.push({ cellId: cell.cellId, source: \"workflow-diagnostic\", sourceArtifactSha256: diagnostic.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: value.producer, harness: input.harness, automation: null, resultCount: units.size, status });\n continue;\n }\n if (!cellArtifact) throw new TypeError(`Cell ${cell.cellId} has no qualification evidence.`);\n const matchedRunner = runner.value.matchedRunners.find((item) => item.name === cellArtifact.value.producer.runner.name); if (!matchedRunner) throw new TypeError(`Cell evidence ${cell.cellId} producer was not matched by runner preflight.`); const value = assertCellEvidence(cellArtifact.value, cell, input.matrix, preflight, input.harness, runner.value.adapterHarness, matchedRunner, units, now); results.push(...value.results);\n cellRuns.push({ cellId: cell.cellId, source: \"cell-evidence\", sourceArtifactSha256: cellArtifact.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(value.results)), qualificationPreflightProvenance: value.qualificationPreflightProvenance, producer: value.producer, harness: value.harness, automation: value.automation, resultCount: value.results.length, status: \"passed\" });\n }\n const expectedResults = units.size * cells.size; if (results.length !== expectedResults) throw new TypeError(\"Aggregate result product is incomplete.\");\n const status: ShaderValidationEvidence[\"status\"] = results.every((result) => result.status === \"passed\") ? \"passed\" : \"failed\";\n const subject = { ...input.bundle.subject, dataBundleSha256: preflight.dataBundleSha256 };\n const draft = {\n contractVersion: SHADER_VALIDATION_EVIDENCE_VERSION,\n status, generatedAt: now, subjectBindingSha256: preflight.subjectBindingSha256, subject,\n matrixRef: { matrixId: input.matrix.matrixId, version: input.matrix.version, sha256: preflight.matrixSha256 },\n toolchain: { packageVersion: input.packageVersion, reflectorVersion: \"1.5.0\" as const, harness: input.harness },\n qualificationPreflightProvenance: preflight.provenance,\n counts: { compileUnits: units.size, cells: cells.size, expectedResults, passedResults: results.filter((result) => result.status === \"passed\").length },\n cellRuns,\n results,\n };\n return { ...draft, evidenceId: await computeValidationEvidenceId(draft) };\n}\n\n/** Validates final aggregate identities and exact Cartesian coverage. */\nexport async function validateShaderValidationEvidence(input: {\n readonly evidence: unknown;\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly dataBundleSha256?: Sha256Hex;\n readonly requirePassed?: boolean;\n}): Promise<ShaderResult<ShaderValidationEvidence>> {\n try {\n const evidence = object(input.evidence, \"evidence\"); exact(evidence, [\"contractVersion\", \"evidenceId\", \"status\", \"generatedAt\", \"subjectBindingSha256\", \"subject\", \"matrixRef\", \"toolchain\", \"qualificationPreflightProvenance\", \"counts\", \"cellRuns\", \"results\"], \"evidence\");\n if (evidence.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION) throw new TypeError(\"Unsupported evidence contract version.\");\n const evidenceId = token(evidence.evidenceId, \"evidence.evidenceId\"); const generatedAt = timestamp(evidence.generatedAt, \"evidence.generatedAt\"); const subjectBindingSha256 = sha(evidence.subjectBindingSha256, \"evidence.subjectBindingSha256\");\n if (evidence.status !== \"passed\" && evidence.status !== \"failed\") throw new TypeError(\"Evidence status is invalid.\");\n\n let parsedMatrix: unknown; try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); } catch (cause) { throw new TypeError(\"Matrix artifact is not UTF-8 JSON.\", { cause }); }\n if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Matrix artifact bytes differ from the supplied matrix value.\");\n const matrixSha256 = await computeSha256(input.matrixBytes);\n const inventorySha256 = await computeQualificationInventorySha256(input.bundle);\n if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError(\"Bundle subject inventory digest is stale.\");\n\n const subject = object(evidence.subject, \"evidence.subject\"); const expectedSubjectKeys = [...Object.keys(input.bundle.subject), \"dataBundleSha256\"]; exact(subject, expectedSubjectKeys, \"evidence.subject\");\n const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== \"dataBundleSha256\")); if (!canonicalEqual(candidateSubject, input.bundle.subject)) throw new TypeError(\"Evidence candidate subject differs from bundle.\");\n const dataBundleSha256 = sha(subject.dataBundleSha256, \"evidence.subject.dataBundleSha256\"); if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError(\"Evidence data bundle digest differs from the exact archive.\");\n if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError(\"Evidence compile-unit inventory digest is stale.\");\n\n const matrixRef = object(evidence.matrixRef, \"evidence.matrixRef\"); exact(matrixRef, [\"matrixId\", \"version\", \"sha256\"], \"evidence.matrixRef\"); if (matrixRef.matrixId !== input.matrix.matrixId || matrixRef.version !== input.matrix.version || matrixRef.sha256 !== matrixSha256) throw new TypeError(\"Evidence matrix artifact identity differs.\");\n const toolchain = object(evidence.toolchain, \"evidence.toolchain\"); exact(toolchain, [\"packageVersion\", \"reflectorVersion\", \"harness\"], \"evidence.toolchain\"); token(toolchain.packageVersion, \"evidence.toolchain.packageVersion\"); if (toolchain.reflectorVersion !== \"1.5.0\") throw new TypeError(\"Evidence reflector version differs.\"); const harness = object(toolchain.harness, \"evidence.toolchain.harness\"); exact(harness, [\"id\", \"version\", \"sha256\"], \"evidence.toolchain.harness\"); token(harness.id, \"evidence.toolchain.harness.id\"); token(harness.version, \"evidence.toolchain.harness.version\"); const harnessSha256 = sha(harness.sha256, \"evidence.toolchain.harness.sha256\");\n const preflightProvenance = parseTrustedWorkflowProvenance(evidence.qualificationPreflightProvenance, \"evidence.qualificationPreflightProvenance\"); if (Date.parse(generatedAt) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError(\"Evidence predates trusted preflight verification.\");\n const expectedBinding = await computeQualificationSubjectBinding({ subject: input.bundle.subject, dataBundleSha256, compileUnitInventorySha256: inventorySha256, matrixSha256, harnessSha256 }); if (subjectBindingSha256 !== expectedBinding) throw new TypeError(\"Evidence subject binding is stale.\");\n if (evidenceId !== await computeValidationEvidenceId(evidence)) throw new TypeError(\"Evidence identity is stale.\");\n\n const units = new Set(input.bundle.inventory.compileUnits.map((unit) => unit.compileUnitId)); const cells = new Map(input.matrix.cells.map((cell) => [cell.cellId, cell])); const expected = units.size * cells.size;\n const results = array(evidence.results, \"evidence.results\"); if (results.length !== expected) throw new TypeError(\"Evidence result product is incomplete.\"); const identities = new Set<string>(); const parsedResults: ShaderQualificationResult[] = []; let passed = 0;\n for (const [index, value] of results.entries()) { const raw = object(value, `evidence.results[${index}]`); const cell = cells.get(String(raw.cellId)); if (!cell || !units.has(String(raw.compileUnitId))) throw new TypeError(`Evidence result ${index} is unexpected.`); const result = assertResult(value, `evidence.results[${index}]`, cell, evidence.status === \"passed\", { earliest: preflightProvenance.oidcAttestation.verifiedAt, latest: generatedAt }); const key = `${result.cellId}:${result.compileUnitId}`; if (identities.has(key)) throw new TypeError(`Evidence repeats ${key}.`); identities.add(key); parsedResults.push(result); if (result.status === \"passed\") passed += 1; }\n const counts = object(evidence.counts, \"evidence.counts\"); exact(counts, [\"compileUnits\", \"cells\", \"expectedResults\", \"passedResults\"], \"evidence.counts\"); if (counts.compileUnits !== units.size || counts.cells !== cells.size || counts.expectedResults !== expected || counts.passedResults !== passed) throw new TypeError(\"Evidence counts are stale.\");\n\n const runs = array(evidence.cellRuns, \"evidence.cellRuns\"); if (runs.length !== cells.size) throw new TypeError(\"Evidence cell-run provenance is incomplete.\"); const runIds = new Set<string>();\n for (const [index, value] of runs.entries()) {\n const path = `evidence.cellRuns[${index}]`; const run = object(value, path); exact(run, [\"cellId\", \"source\", \"sourceArtifactSha256\", \"resultsSha256\", \"qualificationPreflightProvenance\", \"producer\", \"harness\", \"automation\", \"resultCount\", \"status\"], path);\n const cellId = token(run.cellId, `${path}.cellId`); const cell = cells.get(cellId); if (!cell || runIds.has(cellId)) throw new TypeError(`${path}.cellId is duplicate/unexpected.`); runIds.add(cellId);\n if (![\"cell-evidence\", \"runner-preflight\", \"workflow-diagnostic\"].includes(String(run.source))) throw new TypeError(`${path}.source is invalid.`); const sourceArtifactSha256 = sha(run.sourceArtifactSha256, `${path}.sourceArtifactSha256`); if (/^0{64}$/u.test(sourceArtifactSha256)) throw new TypeError(`${path}.sourceArtifactSha256 cannot be a placeholder.`); const resultsSha256 = sha(run.resultsSha256, `${path}.resultsSha256`);\n if (!canonicalEqual(parseTrustedWorkflowProvenance(run.qualificationPreflightProvenance, `${path}.qualificationPreflightProvenance`), preflightProvenance)) throw new TypeError(`${path} changed qualification preflight provenance.`);\n const producer = parseQualificationExecutionProducer(run.producer, `${path}.producer`); const expectedJob: ShaderQualificationExecutionProducer[\"job\"] = run.source === \"runner-preflight\" ? (cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical-runner-preflight\") : (cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\"); assertProducerMatchesPreflight(producer, preflightProvenance, cell, `${path}.producer`, expectedJob);\n if (!canonicalEqual(run.harness, harness)) throw new TypeError(`${path}.harness differs.`); if (run.source === \"cell-evidence\") { const automation = object(run.automation, `${path}.automation`); exact(automation, [\"kind\", \"driver\", \"version\", \"sha256\"], `${path}.automation`); if (automation.kind !== cell.automation.kind) throw new TypeError(`${path}.automation route differs.`); token(automation.driver, `${path}.automation.driver`); token(automation.version, `${path}.automation.version`); sha(automation.sha256, `${path}.automation.sha256`); } else if (run.automation !== null) throw new TypeError(`${path}.automation must be null when no adapter completed a cell run.`);\n const cellResults = parsedResults.filter((result) => result.cellId === cellId); if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(canonicalizeGpuContract(cellResults)) !== resultsSha256) throw new TypeError(`${path} result count/digest is stale.`);\n const resultStatuses = new Set(cellResults.map((result) => result.status)); if (resultStatuses.size !== 1 || !resultStatuses.has(String(run.status) as ShaderQualificationStatus)) throw new TypeError(`${path}.status differs from its results.`);\n if (run.source === \"cell-evidence\" && run.status !== \"passed\") throw new TypeError(`${path} cell evidence must contain passing results.`); if (run.source === \"runner-preflight\" && run.status !== \"runner-unavailable\") throw new TypeError(`${path} runner-preflight source has the wrong status.`); if (run.source === \"workflow-diagnostic\" && run.status !== \"failed\" && run.status !== \"timeout\") throw new TypeError(`${path} workflow diagnostic has the wrong status.`);\n if (run.source === \"cell-evidence\" && cellResults.some((result) => result.observed.runner.id !== producer.runner.name)) throw new TypeError(`${path} producer runner differs from its results.`);\n }\n if ((evidence.status === \"passed\") !== (passed === expected) || (input.requirePassed !== false && evidence.status !== \"passed\")) throw new TypeError(\"Evidence does not satisfy the required passed gate.\");\n return { ok: true, value: evidence as unknown as ShaderValidationEvidence };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid shader validation evidence.\" }] };\n }\n}\n\n/** Strictly parses an external attestation reference; cryptographic verification remains mandatory. */\nexport function parseShaderValidationEvidenceAttestationRef(value: unknown): ShaderValidationEvidenceAttestationRef {\n const input = object(value, \"attestationRef\"); exact(input, [\"contractVersion\", \"kind\", \"evidence\", \"attestation\", \"producer\"], \"attestationRef\"); if (input.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.kind !== \"shader-validation-evidence-attestation-ref\") throw new TypeError(\"Unsupported evidence attestation ref.\");\n const producer = object(input.producer, \"attestationRef.producer\"); exact(producer, [\"repository\", \"runId\", \"runAttempt\", \"trustedWorkflowRepository\", \"trustedWorkflowRef\", \"trustedWorkflowSha\"], \"attestationRef.producer\"); const repository = token(producer.repository, \"attestationRef.producer.repository\"); if (!/^Plasius-LTD\\/[A-Za-z0-9._-]+$/u.test(repository)) throw new TypeError(\"Attestation caller repository is outside Plasius-LTD or malformed.\"); if (producer.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\") throw new TypeError(\"Attestation trusted workflow repository differs.\"); gitObject(producer.trustedWorkflowSha, \"attestationRef.producer.trustedWorkflowSha\"); trustedWorkflowRef(producer.trustedWorkflowRef, \"attestationRef.producer.trustedWorkflowRef\"); token(producer.runId, \"attestationRef.producer.runId\"); integer(producer.runAttempt, \"attestationRef.producer.runAttempt\", 1);\n const evidence = object(input.evidence, \"attestationRef.evidence\"); exact(evidence, [\"name\", \"sha256\"], \"attestationRef.evidence\"); const evidenceName = token(evidence.name, \"attestationRef.evidence.name\"); if (!/^[A-Za-z0-9._-]+\\.json$/u.test(evidenceName)) throw new TypeError(\"Attested evidence name must be a JSON basename.\"); sha(evidence.sha256, \"attestationRef.evidence.sha256\");\n const attestation = object(input.attestation, \"attestationRef.attestation\"); exact(attestation, [\"id\", \"url\", \"bundle\"], \"attestationRef.attestation\"); token(attestation.id, \"attestationRef.attestation.id\"); const url = new URL(token(attestation.url, \"attestationRef.attestation.url\", 2048)); const expectedPrefix = `/${repository}/attestations/`; if (url.protocol !== \"https:\" || url.hostname !== \"github.com\" || url.port || url.username || url.password || url.search || url.hash || !url.pathname.startsWith(expectedPrefix) || url.pathname.length <= expectedPrefix.length) throw new TypeError(\"Attestation URL must be an exact GitHub repository attestation URL.\"); const bundle = object(attestation.bundle, \"attestationRef.attestation.bundle\"); exact(bundle, [\"name\", \"sha256\"], \"attestationRef.attestation.bundle\"); const bundleName = token(bundle.name, \"attestationRef.attestation.bundle.name\"); if (!/^[A-Za-z0-9._-]+\\.json$/u.test(bundleName)) throw new TypeError(\"Attestation bundle name must be a JSON basename.\"); sha(bundle.sha256, \"attestationRef.attestation.bundle.sha256\");\n return input as unknown as ShaderValidationEvidenceAttestationRef;\n}\n\nexport async function verifyShaderValidationEvidenceAttestation(input: {\n readonly ref: unknown;\n readonly evidenceBytes: Uint8Array;\n readonly bundleBytes: Uint8Array;\n readonly verifyCryptographicBundle: (context: { readonly ref: ShaderValidationEvidenceAttestationRef; readonly evidenceBytes: Uint8Array; readonly bundleBytes: Uint8Array }) => Promise<boolean>;\n}): Promise<ShaderResult<ShaderValidationEvidenceAttestationRef>> {\n try {\n const ref = parseShaderValidationEvidenceAttestationRef(input.ref); if (await computeSha256(input.evidenceBytes) !== ref.evidence.sha256 || await computeSha256(input.bundleBytes) !== ref.attestation.bundle.sha256) throw new TypeError(\"Attested evidence or bundle digest differs.\"); if (!await input.verifyCryptographicBundle({ ref, evidenceBytes: input.evidenceBytes, bundleBytes: input.bundleBytes })) throw new TypeError(\"External build-provenance cryptographic verification failed.\"); return { ok: true, value: ref };\n } catch (cause) { return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Evidence attestation verification failed.\" }] }; }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,IAAM,8BAA8B;AACpC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AAU,kDAAkD;AAAG,EAAAC,KAAI,OAAO,QAAQ,0CAA0C;AAC3jC,SAAO;AACT;AAEA,eAAsB,0CAA0C,OAKE;AAChE,MAAI;AACF,UAAM,MAAM,4CAA4C,MAAM,GAAG;AAAG,QAAI,MAAM,cAAc,MAAM,aAAa,MAAM,IAAI,SAAS,UAAU,MAAM,cAAc,MAAM,WAAW,MAAM,IAAI,YAAY,OAAO,OAAQ,OAAM,IAAI,UAAU,6CAA6C;AAAG,QAAI,CAAC,MAAM,MAAM,0BAA0B,EAAE,KAAK,eAAe,MAAM,eAAe,aAAa,MAAM,YAAY,CAAC,EAAG,OAAM,IAAI,UAAU,8DAA8D;AAAG,WAAO,EAAE,IAAI,MAAM,OAAO,IAAI;AAAA,EACxgB,SAAS,OAAO;AAAE,WAAO,EAAE,IAAI,OAAO,aAAa,CAAC,EAAE,MAAM,oBAAoB,UAAU,SAAS,SAAS,iBAAiB,QAAQ,MAAM,UAAU,4CAA4C,CAAC,EAAE;AAAA,EAAG;AACzM;","names":["path","keys","path","keys","path","path","path","path","value","path","object","keys","module","pipeline","value","stages","issue","path","object","SAFE_PATH","object","path","exact","keys","token","integer","unique","value","pipeline","module","object","path","exact","keys","token","sha","integer","array","automation","value","status"]}
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts","../src/contracts.ts","../src/canonical-json.ts","../src/asset-version.ts","../src/hash.ts","../src/manifest-validation.ts","../src/testing/inventory.ts","../src/testing/matrix.ts","../src/testing/qualification-bundle.ts","../src/testing/evidence.ts"],"sourcesContent":["export { defineShaderCompileUnit, validateCompileUnitInventory } from \"./testing/inventory.js\";\nexport { validateStableWebGpuMatrix } from \"./testing/matrix.js\";\nexport { validateQualificationBundleManifest, validateQualificationFixture } from \"./testing/qualification-bundle.js\";\nexport {\n aggregateShaderValidationEvidence,\n computeQualificationInventorySha256,\n computeQualificationSubjectBinding,\n createQualificationPreflight,\n parseShaderValidationEvidenceAttestationRef,\n parseTrustedWorkflowProvenance,\n validateShaderValidationEvidence,\n verifyShaderValidationEvidenceAttestation,\n} from \"./testing/evidence.js\";\nexport type { AggregateShaderValidationEvidenceInput, EvidenceArtifact } from \"./testing/evidence.js\";\n","/** Contract version shared by the first reflection-first manifest family. */\nexport const GPU_INTERFACE_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_VERSION_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_STYLE_PROFILE_MANIFEST_VERSION = \"1.0.0\" as const;\nexport const SHADER_COMPILE_UNIT_VERSION = \"1.0.0\" as const;\nexport const SHADER_VALIDATION_EVIDENCE_VERSION = \"1.0.0\" as const;\nexport const STABLE_WEBGPU_MATRIX_VERSION = \"1.0.0\" as const;\nexport const SHADER_QUALIFICATION_FIXTURE_VERSION = \"1.0.0\" as const;\nexport const SHADER_QUALIFICATION_BUNDLE_VERSION = \"1.0.0\" as const;\n/** Remotely controlled rollout gate owned by the asset service. */\nexport const GPU_SHADER_STORE_FEATURE_FLAG = \"asset.pipeline.shader-store.enabled\" as const;\n/** User-visible style discovery/selection entitlement owned by the capability service. */\nexport const GPU_SHADER_STYLE_SELECTION_CAPABILITY = \"gpu.shader.style.select\" as const;\n\n/** Lowercase hexadecimal SHA-256 value. Runtime parsers enforce its shape. */\nexport type Sha256Hex = string & { readonly __sha256Hex: unique symbol };\n\n/** Stable universal policies accepted by this contract implementation. */\nexport const SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [\n Object.freeze({\n matrixId: \"stable-webgpu\",\n matrixVersion: \"2026-07-13\",\n matrixSha256: \"4620eca44fd03004ee7650cfe9fcf42934493611a5097da5525f71578980b016\",\n }),\n] as const satisfies readonly {\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: string;\n}[];\nObject.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);\n\n/**\n * Exact additive policies accepted by this release. Empty means supplemental\n * qualification fails closed until reviewed policy bytes and lanes are added.\n */\nexport const SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES: readonly Readonly<{\n scope: string;\n matrixId: string;\n matrixVersion: string;\n matrixSha256: string;\n}>[] = Object.freeze([]);\n\nexport interface GitObjectId {\n readonly algorithm: \"sha1\" | \"sha256\";\n readonly hex: string;\n}\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue =\n | JsonPrimitive\n | readonly JsonValue[]\n | { readonly [key: string]: JsonValue };\n\nexport type ShaderDiagnosticSeverity = \"error\" | \"warning\" | \"info\";\nexport type ShaderDiagnosticCode =\n | \"invalid-contract\"\n | \"digest-mismatch\"\n | \"model-abi-mismatch\"\n | \"interface-abi-mismatch\"\n | \"shader-abi-mismatch\"\n | \"incompatible-model-interface\"\n | \"missing-semantic\"\n | \"missing-feature\"\n | \"limit-not-met\"\n | \"unsupported-format\"\n | \"unpromoted-asset\"\n | \"compilation-error\"\n | \"pipeline-error\"\n | \"device-lost\"\n | \"activation-error\"\n | \"stale-evidence\"\n | \"incomplete-matrix\"\n | \"uncovered-fragment\"\n | \"timeout\"\n | \"runner-unavailable\"\n | \"adapter-unavailable\";\n\nexport interface ShaderDiagnostic {\n readonly code: ShaderDiagnosticCode;\n readonly severity: ShaderDiagnosticSeverity;\n readonly message: string;\n readonly path?: string;\n readonly expected?: JsonValue;\n readonly actual?: JsonValue;\n}\n\nexport type ShaderResult<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly diagnostics: readonly ShaderDiagnostic[] };\n\nexport type GpuScalarKind = \"i32\" | \"u32\" | \"f32\" | \"f16\" | \"bool\";\nexport type GpuHostAddressSpace = \"uniform\" | \"storage\";\nexport type GpuAddressSpace =\n | GpuHostAddressSpace\n | \"function\"\n | \"private\"\n | \"workgroup\";\n\nexport interface GpuScalarLayout {\n readonly kind: \"scalar\";\n readonly scalar: GpuScalarKind;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuAtomicLayout {\n readonly kind: \"atomic\";\n readonly scalar: \"i32\" | \"u32\";\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuVectorLayout {\n readonly kind: \"vector\";\n readonly scalar: GpuScalarKind;\n readonly width: 2 | 3 | 4;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuMatrixLayout {\n readonly kind: \"matrix\";\n readonly scalar: \"f32\" | \"f16\";\n readonly columns: 2 | 3 | 4;\n readonly rows: 2 | 3 | 4;\n readonly columnStride: number;\n readonly alignment: number;\n readonly byteSize: number;\n}\n\nexport interface GpuArrayLayout {\n readonly kind: \"array\";\n readonly element: GpuTypeLayout;\n /** Null represents a WGSL runtime-sized array. */\n readonly count: number | null;\n readonly stride: number;\n readonly alignment: number;\n readonly byteSize: number | null;\n}\n\nexport interface GpuRecordReferenceLayout {\n readonly kind: \"record\";\n readonly recordName: string;\n readonly alignment: number;\n readonly byteSize: number | null;\n}\n\nexport type GpuTypeLayout =\n | GpuScalarLayout\n | GpuAtomicLayout\n | GpuVectorLayout\n | GpuMatrixLayout\n | GpuArrayLayout\n | GpuRecordReferenceLayout;\n\nexport interface GpuRecordMemberLayout {\n readonly name: string;\n readonly offset: number;\n /** Effective alignment after applying an optional WGSL `@align`. */\n readonly alignment: number;\n /** Logical size of the value, excluding a member-level `@size`. */\n readonly valueByteSize: number | null;\n /** Occupied member span, including a member-level `@size`. */\n readonly occupiedByteSize: number | null;\n readonly explicitAlign: number | null;\n readonly explicitSize: number | null;\n readonly type: GpuTypeLayout;\n}\n\nexport interface GpuRecordLayout {\n readonly name: string;\n readonly alignment: number;\n /** Null for records ending in a runtime-sized array. */\n readonly byteSize: number | null;\n /** Fixed prefix before any runtime-sized array. */\n readonly minimumByteSize: number;\n readonly runtimeArrayMember: string | null;\n readonly addressSpaces: readonly GpuAddressSpace[];\n /** WGSL declaration order; constructor and codec order depend on it. */\n readonly members: readonly GpuRecordMemberLayout[];\n}\n\nexport type GpuShaderStage = \"vertex\" | \"fragment\" | \"compute\";\nexport type GpuBindingAccess = \"read\" | \"write\" | \"read_write\";\n\nexport type GpuBindingResourceLayout =\n | {\n readonly kind: \"buffer\";\n readonly addressSpace: GpuHostAddressSpace;\n readonly access: GpuBindingAccess;\n readonly recordName: string | null;\n readonly minimumBindingSize: number;\n }\n | {\n readonly kind: \"sampler\";\n readonly samplerType: \"filtering\" | \"non-filtering\" | \"comparison\";\n }\n | {\n readonly kind: \"texture\";\n readonly sampleType: \"float\" | \"unfilterable-float\" | \"depth\" | \"sint\" | \"uint\";\n readonly viewDimension: \"1d\" | \"2d\" | \"2d-array\" | \"cube\" | \"cube-array\" | \"3d\";\n readonly multisampled: boolean;\n }\n | {\n readonly kind: \"storage-texture\";\n readonly access: \"write-only\" | \"read-only\" | \"read-write\";\n readonly format: string;\n readonly viewDimension: \"1d\" | \"2d\" | \"2d-array\" | \"3d\";\n }\n | { readonly kind: \"external-texture\" };\n\nexport interface GpuBindingLayout {\n readonly moduleId: string;\n readonly variableName: string;\n readonly group: number;\n readonly binding: number;\n readonly resource: GpuBindingResourceLayout;\n readonly visibility: readonly GpuShaderStage[];\n}\n\nexport interface GpuEntryPointIo {\n readonly name: string;\n readonly locationKind: \"location\" | \"builtin\";\n readonly location: number | string;\n readonly interpolation: string | null;\n readonly type: GpuTypeLayout;\n}\n\nexport type GpuWorkgroupDimension =\n | { readonly kind: \"literal\"; readonly value: number }\n | { readonly kind: \"override\"; readonly name: string };\n\nexport interface GpuEntryPointInterface {\n readonly moduleId: string;\n readonly name: string;\n readonly stage: GpuShaderStage;\n readonly inputs: readonly GpuEntryPointIo[];\n readonly outputs: readonly GpuEntryPointIo[];\n readonly bindingKeys: readonly string[];\n readonly overrideNames: readonly string[];\n readonly workgroupSize: readonly [\n GpuWorkgroupDimension,\n GpuWorkgroupDimension,\n GpuWorkgroupDimension,\n ] | null;\n /**\n * WebGPU workgroup-storage bytes statically used by a compute entry point.\n * This is null for non-compute entry points.\n */\n readonly workgroupStorageSize: number | null;\n}\n\nexport interface GpuVertexInputLayout {\n readonly pipelineId: string;\n readonly moduleId: string;\n readonly entryPoint: string;\n readonly shaderLocation: number;\n readonly shaderType: GpuTypeLayout;\n readonly bufferSlot: number;\n readonly format: string;\n readonly offset: number;\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly semantic: string | null;\n}\n\n/** Shader-independent vertex bytes consumed from a model buffer. */\nexport interface GpuModelVertexInputLayout {\n readonly source: {\n readonly pipelineId: string;\n readonly shaderLocation: number;\n };\n readonly format: string;\n readonly offset: number;\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly semantic: string;\n}\n\n/** A reflected model-facing resource projection; shader coordinates and visibility are excluded. */\nexport interface GpuModelBindingLayout {\n readonly source: {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n };\n readonly resource: GpuBindingResourceLayout;\n readonly semantic: string | null;\n}\n\nexport interface GpuOverrideLayout {\n readonly moduleId: string;\n readonly name: string;\n readonly id: number | null;\n readonly type: \"bool\" | \"i32\" | \"u32\" | \"f32\" | \"f16\";\n readonly defaultValue: boolean | number | null;\n}\n\nexport type GpuSemanticSource =\n | {\n readonly kind: \"record-member\";\n readonly recordName: string;\n readonly memberPath: readonly string[];\n }\n | {\n readonly kind: \"vertex-attribute\";\n readonly pipelineId: string;\n readonly shaderLocation: number;\n }\n | {\n readonly kind: \"binding\";\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n };\n\nexport interface GpuSemanticProjection {\n readonly semantic: string;\n readonly source: GpuSemanticSource;\n}\n\nexport interface GpuModelAbiProjection {\n readonly recordNames: readonly string[];\n readonly bindings: readonly GpuModelBindingLayout[];\n readonly vertexInputs: readonly GpuModelVertexInputLayout[];\n readonly semantics: readonly GpuSemanticProjection[];\n}\n\nexport interface GpuInterfaceManifest {\n readonly contractVersion: typeof GPU_INTERFACE_MANIFEST_VERSION;\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly modules: readonly {\n readonly moduleId: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly records: readonly GpuRecordLayout[];\n readonly bindings: readonly GpuBindingLayout[];\n readonly entryPoints: readonly GpuEntryPointInterface[];\n readonly vertexInputs: readonly GpuVertexInputLayout[];\n readonly overrides: readonly GpuOverrideLayout[];\n readonly modelAbi: GpuModelAbiProjection;\n readonly modelAbiHash: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly generatedBy: {\n readonly packageVersion: string;\n readonly reflector: \"wgsl_reflect\";\n readonly reflectorVersion: \"1.5.0\";\n };\n}\n\nexport interface GpuInterfaceRef {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n}\n\nexport interface ShaderVersionRef {\n readonly shaderId: string;\n readonly version: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n}\n\nexport interface ShaderStyleProfileRef {\n readonly profileId: string;\n readonly version: string;\n readonly manifestUri: string;\n readonly manifestSha256: Sha256Hex;\n}\n\nexport interface SerializableGpuProgrammableStage {\n readonly moduleId: string;\n readonly entryPoint: string;\n readonly constants: Readonly<Record<string, boolean | number>>;\n}\n\nexport interface SerializableGpuBindGroupLayout {\n readonly group: number;\n readonly entries: readonly Omit<GpuBindingLayout, \"moduleId\" | \"variableName\">[];\n}\n\nexport interface SerializableGpuPipelineLayout {\n readonly bindGroups: readonly SerializableGpuBindGroupLayout[];\n}\n\nexport interface SerializableGpuComputePipelineDescriptor {\n readonly kind: \"compute\";\n readonly pipelineId: string;\n readonly layout: SerializableGpuPipelineLayout;\n readonly compute: SerializableGpuProgrammableStage;\n}\n\nexport interface SerializableGpuRenderPipelineDescriptor {\n readonly kind: \"render\";\n readonly pipelineId: string;\n readonly layout: SerializableGpuPipelineLayout;\n readonly vertex: SerializableGpuProgrammableStage;\n readonly fragment: SerializableGpuProgrammableStage | null;\n readonly vertexBuffers: readonly {\n readonly arrayStride: number;\n readonly stepMode: \"vertex\" | \"instance\";\n readonly attributes: readonly {\n readonly format: string;\n readonly offset: number;\n readonly shaderLocation: number;\n readonly semantic: string | null;\n }[];\n }[];\n readonly primitive: {\n readonly topology: \"point-list\" | \"line-list\" | \"line-strip\" | \"triangle-list\" | \"triangle-strip\";\n readonly stripIndexFormat: \"uint16\" | \"uint32\" | null;\n readonly frontFace: \"ccw\" | \"cw\";\n readonly cullMode: \"none\" | \"front\" | \"back\";\n readonly unclippedDepth: boolean;\n };\n readonly colorTargets: readonly {\n readonly format: string;\n readonly blend: {\n readonly color: SerializableGpuBlendComponent;\n readonly alpha: SerializableGpuBlendComponent;\n } | null;\n readonly writeMask: number;\n }[];\n readonly depthStencil: {\n readonly format: string;\n readonly depthWriteEnabled: boolean;\n readonly depthCompare: GpuCompareFunction;\n readonly stencilFront: SerializableGpuStencilFaceState;\n readonly stencilBack: SerializableGpuStencilFaceState;\n readonly stencilReadMask: number;\n readonly stencilWriteMask: number;\n readonly depthBias: number;\n readonly depthBiasSlopeScale: number;\n readonly depthBiasClamp: number;\n } | null;\n readonly multisample: {\n readonly count: 1 | 4;\n readonly mask: number;\n readonly alphaToCoverageEnabled: boolean;\n };\n}\n\nexport type GpuCompareFunction = \"never\" | \"less\" | \"equal\" | \"less-equal\" | \"greater\" | \"not-equal\" | \"greater-equal\" | \"always\";\n\nexport interface SerializableGpuBlendComponent {\n readonly operation: \"add\" | \"subtract\" | \"reverse-subtract\" | \"min\" | \"max\";\n readonly srcFactor: \"zero\" | \"one\" | \"src\" | \"one-minus-src\" | \"src-alpha\" | \"one-minus-src-alpha\" | \"dst\" | \"one-minus-dst\" | \"dst-alpha\" | \"one-minus-dst-alpha\" | \"src-alpha-saturated\" | \"constant\" | \"one-minus-constant\";\n readonly dstFactor: \"zero\" | \"one\" | \"src\" | \"one-minus-src\" | \"src-alpha\" | \"one-minus-src-alpha\" | \"dst\" | \"one-minus-dst\" | \"dst-alpha\" | \"one-minus-dst-alpha\" | \"src-alpha-saturated\" | \"constant\" | \"one-minus-constant\";\n}\n\nexport interface SerializableGpuStencilFaceState {\n readonly compare: GpuCompareFunction;\n readonly failOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n readonly depthFailOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n readonly passOp: \"keep\" | \"zero\" | \"replace\" | \"invert\" | \"increment-clamp\" | \"decrement-clamp\" | \"increment-wrap\" | \"decrement-wrap\";\n}\n\nexport type SerializableGpuPipelineDescriptor =\n | SerializableGpuComputePipelineDescriptor\n | SerializableGpuRenderPipelineDescriptor;\n\nexport interface GpuLimitRequirement {\n readonly name: string;\n readonly comparator: \"at-least\" | \"at-most\";\n readonly value: number;\n}\n\nexport interface ShaderRequirements {\n readonly semantics: readonly string[];\n readonly features: readonly string[];\n readonly limits: readonly GpuLimitRequirement[];\n readonly formats: readonly string[];\n}\n\nexport type ShaderRenderRole =\n | \"material\"\n | \"lighting\"\n | \"outline\"\n | \"shadow\"\n | \"post-processing\";\n\nexport interface ShaderValidationEvidenceRef {\n readonly evidenceId: string;\n readonly uri: string;\n readonly sha256: Sha256Hex;\n readonly matrixId: string;\n readonly matrixVersion: string;\n /** Digest of the exact versioned matrix-policy bytes used to produce the evidence. */\n readonly matrixSha256: Sha256Hex;\n /** Exact external GitHub build-provenance reference artifact for the evidence bytes. */\n readonly attestationRef: {\n readonly uri: string;\n readonly sha256: Sha256Hex;\n };\n}\n\n/** Additional qualification required beyond the stable universal matrix. */\nexport interface ScopedShaderValidationEvidenceRef {\n /** Stable, profile-selectable scope such as `xr`; `universal` is reserved. */\n readonly scope: string;\n readonly evidence: ShaderValidationEvidenceRef;\n}\n\n/** Exact supplemental matrix policy a style profile requires for every role. */\nexport interface ShaderValidationScopeRequirement {\n /** Stable policy scope such as `xr`; `universal` is reserved. */\n readonly scope: string;\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: Sha256Hex;\n}\n\nexport interface ShaderVersionManifest {\n readonly contractVersion: typeof SHADER_VERSION_MANIFEST_VERSION;\n readonly shaderId: string;\n readonly version: string;\n readonly modules: readonly {\n readonly moduleId: string;\n readonly uri: string;\n readonly byteLength: number;\n readonly sha256: Sha256Hex;\n readonly contentType: \"text/wgsl; charset=utf-8\";\n }[];\n readonly gpuInterface: GpuInterfaceRef;\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly renderRoles: readonly {\n readonly role: ShaderRenderRole;\n readonly pipelineIds: readonly string[];\n }[];\n readonly compatibleModelInterfaces: readonly {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n }[];\n readonly requirements: ShaderRequirements;\n readonly shaderAbiHash: Sha256Hex;\n /** Passing evidence for the universal stable-WebGPU matrix. */\n readonly validationEvidence: ShaderValidationEvidenceRef;\n /** Passing evidence for additive matrices, for example XR device lanes. */\n readonly additionalValidationEvidence: readonly ScopedShaderValidationEvidenceRef[];\n}\n\n/** Immutable shader manifest fields qualified before external evidence is attached. */\nexport type ShaderVersionManifestCore = Omit<ShaderVersionManifest, \"validationEvidence\" | \"additionalValidationEvidence\">;\n\nexport interface ShaderStyleRoleBinding {\n readonly role: ShaderRenderRole;\n readonly shader: ShaderVersionRef;\n}\n\nexport interface ShaderStyleProfileManifest {\n readonly contractVersion: typeof SHADER_STYLE_PROFILE_MANIFEST_VERSION;\n readonly profileId: string;\n readonly version: string;\n readonly style: string;\n readonly roles: readonly ShaderStyleRoleBinding[];\n readonly compatibleModelInterfaces: readonly {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly manifestSha256: Sha256Hex;\n readonly interfaceAbiHash: Sha256Hex;\n readonly modelAbiHash: Sha256Hex;\n }[];\n readonly requiredSemantics: readonly string[];\n /** Exact supplemental matrix policies every referenced shader must provide. */\n readonly requiredValidationScopes: readonly ShaderValidationScopeRequirement[];\n}\n\nexport interface ModelGpuCompatibilityDescriptor {\n readonly modelId: string;\n readonly version: string;\n readonly gpuInterface: GpuInterfaceRef;\n readonly modelAbiHash: Sha256Hex;\n readonly providedSemantics: readonly string[];\n readonly defaultStyleProfile: ShaderStyleProfileRef | null;\n}\n\nexport interface GpuCapabilitySnapshot {\n readonly features: readonly string[];\n readonly limits: Readonly<Record<string, number>>;\n readonly formats: readonly string[];\n}\n\nexport interface ModelShaderCompatibility {\n readonly modelAbiHash: Sha256Hex;\n readonly shaderAbiHash: Sha256Hex;\n readonly matchedInterfaceId: string;\n}\n\nexport type GpuScalarValue = number;\nexport type GpuVectorValue = readonly number[];\nexport type GpuMatrixValue = readonly (readonly number[])[];\nexport type GpuRecordValue = Readonly<Record<string, unknown>>;\n\nexport interface GpuRecordCodec<T = GpuRecordValue> {\n readonly record: GpuRecordLayout;\n readonly minimumByteLength: number;\n byteLength(value: T): number;\n encode(value: T): ArrayBuffer;\n encodeInto(\n value: T,\n destination: ArrayBuffer | ArrayBufferView,\n byteOffset?: number,\n ): number;\n decode(\n source: ArrayBuffer | ArrayBufferView,\n options?: { readonly byteOffset?: number; readonly byteLength?: number },\n ): T;\n}\n\nexport interface PromotedShaderCatalogResolver {\n /** Must prove the URI belongs to the configured promoted catalog root and exact immutable identity. */\n isCatalogAssetUri(uri: string): boolean;\n loadProfile(\n ref: ShaderStyleProfileRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadShader(\n ref: ShaderVersionRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadInterface(\n ref: GpuInterfaceRef,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n loadModule(\n shader: ShaderVersionRef,\n moduleId: string,\n uri: string,\n signal?: AbortSignal,\n ): Promise<{ readonly bytes: Uint8Array; readonly promoted: boolean }>;\n}\n\nexport interface LoadedShaderVersion {\n readonly ref: ShaderVersionRef;\n readonly manifest: ShaderVersionManifest;\n readonly gpuInterface: GpuInterfaceManifest;\n readonly modules: ReadonlyMap<string, Uint8Array>;\n}\n\nexport interface LoadedShaderStyleProfile {\n readonly ref: ShaderStyleProfileRef;\n readonly manifest: ShaderStyleProfileManifest;\n readonly shaders: ReadonlyMap<ShaderRenderRole, LoadedShaderVersion>;\n}\n\nexport interface GpuCompilationMessageLike {\n readonly type: \"error\" | \"warning\" | \"info\";\n readonly message: string;\n readonly lineNum?: number;\n readonly linePos?: number;\n}\n\nexport interface GpuShaderModuleLike {\n getCompilationInfo(): Promise<{ readonly messages: readonly GpuCompilationMessageLike[] }>;\n}\n\nexport interface GpuDeviceLike {\n readonly features: Iterable<string>;\n readonly limits: Readonly<Record<string, number>>;\n readonly lost?: Promise<{ readonly reason?: string; readonly message?: string }>;\n createShaderModule(descriptor: { readonly label?: string; readonly code: string }): GpuShaderModuleLike;\n createBindGroupLayout(descriptor: unknown): unknown;\n createPipelineLayout(descriptor: { readonly bindGroupLayouts: readonly unknown[] }): unknown;\n createComputePipelineAsync?(descriptor: unknown): Promise<unknown>;\n createRenderPipelineAsync?(descriptor: unknown): Promise<unknown>;\n createComputePipeline?(descriptor: unknown): unknown;\n createRenderPipeline?(descriptor: unknown): unknown;\n pushErrorScope?(filter: \"validation\"): void;\n popErrorScope?(): Promise<{ readonly message?: string } | null>;\n}\n\nexport interface PreparedShaderStyleProfile {\n readonly loaded: LoadedShaderStyleProfile;\n readonly pipelines: ReadonlyMap<string, unknown>;\n readonly preparedAt: number;\n dispose(): void;\n}\n\nexport interface ActiveShaderStyleProfile {\n readonly prepared: PreparedShaderStyleProfile;\n readonly activatedAt: number;\n}\n\nexport interface FrameBoundaryScheduler {\n schedule(operation: () => void): Promise<void>;\n}\n\nexport interface ShaderStyleController {\n readonly current: ActiveShaderStyleProfile | null;\n}\n\nexport interface AssembledWgslModule {\n readonly moduleId: string;\n readonly source: string;\n}\n\nexport type GpuSemanticSelector = GpuSemanticProjection;\n\n/** Selects a reflected binding. Callers cannot supply its resource layout. */\nexport interface GpuModelBindingSelector {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n readonly semantic?: string | null;\n}\n\nexport interface ReflectGpuInterfaceInput {\n readonly interfaceId: string;\n readonly interfaceVersion: string;\n readonly modules: readonly AssembledWgslModule[];\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly modelFacingRecordNames: readonly string[];\n readonly modelFacingBindings: readonly GpuModelBindingSelector[];\n readonly semantics: readonly GpuSemanticSelector[];\n}\n\nexport interface GeneratedGpuInterfaceArtifacts {\n readonly manifestJson: string;\n readonly jsonSchemas: string;\n readonly typescriptTypes: string;\n readonly byteConstants: string;\n readonly codecs: string;\n}\n\nexport interface ShaderCompileUnitManifest {\n readonly contractVersion: typeof SHADER_COMPILE_UNIT_VERSION;\n readonly compileUnitId: string;\n readonly fragmentIds: readonly string[];\n readonly modules: readonly {\n readonly moduleId: string;\n readonly sha256: Sha256Hex;\n readonly assembly: {\n /** UTF-8 fragment bytes joined by one LF byte, with no executable transforms. */\n readonly kind: \"concat-v1\";\n readonly fragmentIds: readonly string[];\n };\n }[];\n readonly entryPoints: readonly {\n readonly moduleId: string;\n readonly name: string;\n readonly stage: GpuShaderStage;\n }[];\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly interfaceRef: GpuInterfaceRef;\n readonly overrideValues: Readonly<Record<string, boolean | number>>;\n readonly qualificationFixture: {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n };\n}\n\nexport interface ShaderCompileUnitInventory {\n readonly contractVersion: typeof SHADER_COMPILE_UNIT_VERSION;\n readonly fragments: readonly {\n readonly fragmentId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly compileUnits: readonly ShaderCompileUnitManifest[];\n}\n\nexport type ShaderMatrixBrowserName = \"chromium\" | \"chrome\" | \"edge\" | \"firefox\" | \"safari\";\nexport type ShaderMatrixOsName =\n | \"ubuntu\"\n | \"windows\"\n | \"macos\"\n | \"chromeos\"\n | \"android\"\n | \"ios\"\n | \"ipados\"\n | \"visionos\";\n\nexport interface StableWebGpuMatrixCell {\n readonly cellId: string;\n readonly runnerLabels: readonly string[];\n readonly browser: {\n readonly name: ShaderMatrixBrowserName;\n readonly channel: \"stable\" | \"playwright-bundled\";\n };\n readonly os: {\n readonly name: ShaderMatrixOsName;\n readonly versionRequirement:\n | { readonly kind: \"exact\"; readonly value: string }\n | { readonly kind: \"major\"; readonly value: number }\n | { readonly kind: \"minimum-major\"; readonly value: number }\n | { readonly kind: \"stable-channel\"; readonly channel: \"stable\" };\n readonly architecture: \"x64\" | \"arm64\";\n };\n readonly adapter: {\n readonly kind: \"software\" | \"physical\";\n readonly vendor: string;\n readonly family: string;\n readonly backend: \"swiftshader\" | \"d3d12\" | \"metal\" | \"vulkan\";\n };\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n };\n readonly timeoutMs: number;\n readonly blocking: boolean;\n readonly countsTowardStableCoverage: boolean;\n}\n\nexport interface StableWebGpuMatrixManifest {\n readonly contractVersion: typeof STABLE_WEBGPU_MATRIX_VERSION;\n readonly matrixId: string;\n readonly version: string;\n readonly policy: {\n readonly coverage: \"all-cells-required\";\n readonly unavailable: \"fail\";\n readonly skipped: \"fail\";\n readonly timeout: \"fail\";\n readonly deviceLoss: \"fail\";\n readonly requiredPhysicalCellCount: 15;\n readonly requiredBlockingCellCount: 16;\n };\n readonly cells: readonly StableWebGpuMatrixCell[];\n}\n\nexport type ShaderQualificationStatus =\n | \"passed\"\n | \"failed\"\n | \"skipped\"\n | \"timeout\"\n | \"device-lost\"\n | \"runner-unavailable\"\n | \"adapter-unavailable\";\n\nexport type ShaderQualificationPhaseName =\n | \"assembly\"\n | \"reflection-schema\"\n | \"shader-compilation\"\n | \"pipeline-layout\"\n | \"pipeline-creation\"\n | \"bind-group-creation\"\n | \"cpu-to-gpu-layout\"\n | \"gpu-to-cpu-layout\"\n | \"bounded-execution\"\n | \"semantic-readback\";\n\nexport type ShaderQualificationPhaseEvidence =\n | {\n readonly name: Exclude<ShaderQualificationPhaseName, \"shader-compilation\" | \"semantic-readback\">;\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly evidenceSha256: Sha256Hex;\n }\n | {\n readonly name: \"shader-compilation\";\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly compilationMessagesSha256: Sha256Hex;\n readonly errorCount: number;\n }\n | {\n readonly name: \"semantic-readback\";\n readonly status: \"passed\" | \"failed\";\n readonly durationMs: number;\n readonly expectedSha256: Sha256Hex;\n readonly actualSha256: Sha256Hex;\n };\n\nexport interface ShaderQualificationResult {\n readonly compileUnitId: string;\n readonly cellId: string;\n readonly status: ShaderQualificationStatus;\n readonly startedAt: string;\n readonly completedAt: string;\n readonly observed: {\n readonly runner: { readonly id: string; readonly labels: readonly string[] };\n readonly os: { readonly name: string; readonly version: string; readonly channel: string | null; readonly architecture: string };\n readonly browser: { readonly name: string; readonly version: string; readonly channel: string };\n readonly adapter: {\n readonly physical: boolean;\n readonly vendor: string;\n readonly family: string;\n readonly architecture: string;\n readonly device: string;\n readonly description: string;\n readonly backend: string;\n readonly driver: string;\n };\n readonly features: readonly string[];\n readonly limits: Readonly<Record<string, number>>;\n };\n readonly phases: readonly ShaderQualificationPhaseEvidence[];\n readonly diagnostics: readonly ShaderDiagnostic[];\n}\n\n/** Candidate claims that can be serialized inside the candidate archive without a self-digest. */\nexport interface ShaderQualificationCandidateSubject {\n /** Digest of the ShaderVersionManifest projection with validationEvidence omitted. */\n readonly shaderManifestCore: {\n readonly shaderId: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly shaderAbiHash: Sha256Hex;\n readonly interfaceManifestSha256: Sha256Hex;\n readonly modelAbiHashes: readonly Sha256Hex[];\n readonly modules: readonly { readonly moduleId: string; readonly sha256: Sha256Hex }[];\n readonly requiredCompileUnitIds: readonly string[];\n readonly requiredCellIds: readonly string[];\n}\n\nexport interface ShaderValidationEvidenceSubject extends ShaderQualificationCandidateSubject {\n /** Verified externally over the complete immutable archive; never embedded in that archive. */\n readonly dataBundleSha256: Sha256Hex;\n}\n\nexport interface ShaderTrustedWorkflowProvenance {\n readonly repository: string;\n readonly commit: GitObjectId;\n readonly ref: string;\n readonly workflowRef: string;\n readonly workflowSha: GitObjectId;\n readonly runId: string;\n readonly runAttempt: number;\n readonly job: string;\n readonly eventName: string;\n readonly oidcAttestation: {\n readonly issuer: \"https://token.actions.githubusercontent.com\";\n readonly subject: string;\n readonly audience: string;\n readonly verifiedClaimsSha256: Sha256Hex;\n readonly verifiedAt: string;\n readonly source: \"trusted-runner-preflight\";\n };\n}\n\n/** Identifies the workflow job and runner that produced a qualification-cell artifact. */\nexport interface ShaderQualificationExecutionProducer {\n readonly repository: string;\n readonly commit: GitObjectId;\n readonly ref: string;\n readonly runId: string;\n readonly runAttempt: number;\n readonly job: \"swiftshader\" | \"physical\" | \"physical-runner-preflight\";\n readonly trustedWorkflowRepository: \"Plasius-LTD/gpu-shader\";\n readonly trustedWorkflowRef: string;\n readonly trustedWorkflowSha: GitObjectId;\n readonly runner: {\n readonly name: string;\n readonly environment: \"github-hosted\" | \"self-hosted\" | \"device-farm\";\n readonly os: string;\n readonly architecture: string;\n };\n}\n\nexport interface ShaderValidationEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly evidenceId: string;\n readonly status: \"passed\" | \"failed\";\n readonly generatedAt: string;\n readonly subjectBindingSha256: Sha256Hex;\n readonly subject: ShaderValidationEvidenceSubject;\n readonly matrixRef: {\n readonly matrixId: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly toolchain: {\n readonly packageVersion: string;\n readonly reflectorVersion: \"1.5.0\";\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n };\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly counts: {\n readonly compileUnits: number;\n readonly cells: number;\n readonly expectedResults: number;\n readonly passedResults: number;\n };\n readonly cellRuns: readonly ShaderValidationCellRun[];\n readonly results: readonly ShaderQualificationResult[];\n}\n\nexport type ShaderQualificationResource =\n | {\n readonly kind: \"buffer\";\n readonly resourceId: string;\n readonly byteLength: number;\n readonly usage: readonly string[];\n readonly initialData: { readonly path: string; readonly sha256: Sha256Hex } | null;\n }\n | {\n readonly kind: \"texture\";\n readonly resourceId: string;\n readonly dimension: \"1d\" | \"2d\" | \"3d\";\n readonly size: readonly [number, number, number];\n readonly mipLevelCount: number;\n readonly sampleCount: 1 | 4;\n readonly format: string;\n readonly usage: readonly string[];\n readonly initialData: {\n readonly path: string;\n readonly sha256: Sha256Hex;\n readonly bytesPerRow: number;\n readonly rowsPerImage: number;\n readonly mipLevel: number;\n readonly origin: readonly [number, number, number];\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n } | null;\n }\n | {\n readonly kind: \"sampler\";\n readonly resourceId: string;\n readonly descriptor: Readonly<Record<string, JsonPrimitive>>;\n };\n\nexport type ShaderQualificationCommand =\n | {\n readonly kind: \"dispatch\";\n readonly pipelineId: string;\n readonly bindGroupIds: readonly string[];\n readonly workgroups: readonly [number, number, number];\n }\n | {\n readonly kind: \"draw\";\n readonly pipelineId: string;\n readonly bindGroupIds: readonly string[];\n readonly vertexBuffers: readonly {\n readonly slot: number;\n readonly resourceId: string;\n readonly offset: number;\n readonly size: number;\n }[];\n readonly colorAttachments: readonly {\n readonly resourceId: string;\n readonly view: ShaderQualificationTextureViewDescriptor;\n readonly clearValue: readonly [number, number, number, number];\n readonly loadOp: \"clear\" | \"load\";\n readonly storeOp: \"store\" | \"discard\";\n }[];\n readonly depthStencilAttachment: {\n readonly resourceId: string;\n readonly view: ShaderQualificationTextureViewDescriptor;\n readonly depthClearValue: number;\n readonly depthLoadOp: \"clear\" | \"load\";\n readonly depthStoreOp: \"store\" | \"discard\";\n readonly stencilClearValue: number;\n readonly stencilLoadOp: \"clear\" | \"load\" | null;\n readonly stencilStoreOp: \"store\" | \"discard\" | null;\n } | null;\n readonly vertexCount: number;\n readonly instanceCount: number;\n readonly firstVertex: number;\n readonly firstInstance: number;\n }\n | {\n readonly kind: \"copy-buffer\";\n readonly source: string;\n readonly destination: string;\n readonly byteLength: number;\n }\n | {\n readonly kind: \"copy-texture-to-buffer\";\n readonly source: {\n readonly resourceId: string;\n readonly mipLevel: number;\n readonly origin: readonly [number, number, number];\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n };\n readonly destination: {\n readonly resourceId: string;\n readonly offset: number;\n readonly bytesPerRow: number;\n readonly rowsPerImage: number;\n };\n readonly extent: readonly [number, number, number];\n };\n\nexport interface ShaderQualificationTextureViewDescriptor {\n readonly format: string | null;\n readonly dimension: \"1d\" | \"2d\" | \"2d-array\" | \"cube\" | \"cube-array\" | \"3d\" | null;\n readonly aspect: \"all\" | \"depth-only\" | \"stencil-only\";\n readonly baseMipLevel: number;\n readonly mipLevelCount: number | null;\n readonly baseArrayLayer: number;\n readonly arrayLayerCount: number | null;\n}\n\nexport type ShaderQualificationBindGroupResource =\n | { readonly kind: \"buffer\"; readonly resourceId: string; readonly offset: number; readonly size: number }\n | { readonly kind: \"texture-view\"; readonly resourceId: string; readonly view: ShaderQualificationTextureViewDescriptor }\n | { readonly kind: \"sampler\"; readonly resourceId: string };\n\n/** A declarative host-codec ↔ final-WGSL record-layout probe. */\nexport interface ShaderQualificationBufferRecordLayoutProbe {\n readonly kind: \"buffer-record\";\n readonly probeId: string;\n readonly source: {\n readonly moduleId: string;\n readonly group: number;\n readonly binding: number;\n readonly recordName: string;\n };\n readonly pipelineId: string;\n readonly commandIndex: number;\n readonly input: {\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteLength: number;\n /** Encoded with createGpuRecordCodec and compared byte-for-byte with admitted initialData. */\n readonly value: JsonValue;\n };\n readonly output: {\n readonly readbackIndex: number;\n readonly recordName: string;\n /** GPU output is decoded with the reflected codec and compared to this value. */\n readonly expectedValue: JsonValue;\n };\n}\n\n/** A declarative host vertex-format encoder ↔ final-WGSL vertex-fetch probe. */\nexport interface ShaderQualificationVertexInputLayoutProbe {\n readonly kind: \"vertex-input\";\n readonly probeId: string;\n readonly source: {\n readonly pipelineId: string;\n readonly shaderLocation: number;\n readonly semantic: string;\n };\n readonly commandIndex: number;\n readonly input: {\n readonly resourceId: string;\n readonly vertexBufferSlot: number;\n /** Absolute vertex or instance element selected by the draw command. */\n readonly elementIndex: number;\n /** Encoded from the reflected GPUVertexFormat and compared with admitted bytes. */\n readonly value: JsonValue;\n };\n readonly output: {\n readonly readbackIndex: number;\n readonly recordName: string;\n /** GPU-observed vertex value encoded through this reflected output record. */\n readonly expectedValue: JsonValue;\n };\n}\n\nexport type ShaderQualificationLayoutProbe =\n | ShaderQualificationBufferRecordLayoutProbe\n | ShaderQualificationVertexInputLayoutProbe;\n\nexport interface ShaderQualificationFixtureManifest {\n readonly contractVersion: typeof SHADER_QUALIFICATION_FIXTURE_VERSION;\n readonly fixtureId: string;\n readonly resources: readonly ShaderQualificationResource[];\n readonly bindGroups: readonly {\n readonly bindGroupId: string;\n readonly group: number;\n readonly entries: readonly { readonly binding: number; readonly resource: ShaderQualificationBindGroupResource }[];\n }[];\n readonly commands: readonly ShaderQualificationCommand[];\n readonly layoutProbes: readonly ShaderQualificationLayoutProbe[];\n readonly readbacks: readonly {\n readonly resourceId: string;\n readonly byteOffset: number;\n readonly byteLength: number;\n readonly expectedSha256: Sha256Hex;\n }[];\n readonly bounds: {\n readonly maxBufferBytes: number;\n readonly maxTextureTexels: number;\n readonly maxCommands: number;\n readonly timeoutMs: number;\n };\n}\n\nexport interface ShaderQualificationBundleManifest {\n readonly contractVersion: typeof SHADER_QUALIFICATION_BUNDLE_VERSION;\n readonly inventory: ShaderCompileUnitInventory;\n readonly subject: ShaderQualificationCandidateSubject;\n readonly shaderManifestCorePath: string;\n readonly gpuInterfaceManifest: { readonly path: string; readonly sha256: Sha256Hex };\n readonly modelCompatibilityFixtures: readonly {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n }[];\n readonly modules: readonly { readonly moduleId: string; readonly path: string; readonly sha256: Sha256Hex }[];\n readonly fixtures: readonly {\n readonly fixtureId: string;\n readonly path: string;\n readonly sha256: Sha256Hex;\n readonly kind: \"qualification-fixture\";\n }[];\n}\n\nexport interface ShaderQualificationModelCompatibilityFixture {\n readonly contractVersion: typeof SHADER_QUALIFICATION_FIXTURE_VERSION;\n readonly fixtureId: string;\n readonly model: ModelGpuCompatibilityDescriptor;\n}\n\nexport interface ShaderCellEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly qualificationId: string;\n readonly matrixId: string;\n readonly matrixVersion: string;\n readonly matrixSha256: Sha256Hex;\n readonly cellId: string;\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n readonly driver: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n /** `sha256(\"plasius.gpu.qualification-subject/v1\\n\" + canonical(subject,digests))`. */\n readonly subjectBindingSha256: Sha256Hex;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n readonly results: readonly ShaderQualificationResult[];\n}\n\nexport interface ShaderRunnerCellPreflightEvidence {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-runner-cell-preflight-evidence\";\n readonly qualificationId: string;\n readonly cellId: string;\n readonly status: \"available\" | \"runner-unavailable\";\n readonly matrixSha256: Sha256Hex;\n readonly runnerLabels: readonly string[];\n /** API-observed self-hosted/device labels, or hosted image labels derived from the actual OS/architecture environment. */\n readonly matchedRunners: readonly {\n readonly name: string;\n readonly labels: readonly string[];\n }[];\n /** Independently verified adapter package/code identity, or null when inventory cannot observe it. */\n readonly adapterHarness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n } | null;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n}\n\nexport interface ShaderValidationCellRun {\n readonly cellId: string;\n readonly source: \"cell-evidence\" | \"runner-preflight\" | \"workflow-diagnostic\";\n readonly sourceArtifactSha256: Sha256Hex;\n readonly resultsSha256: Sha256Hex;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n readonly harness: {\n readonly id: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n };\n /** Null when no adapter actually executed (runner-unavailable/workflow diagnostic). */\n readonly automation: {\n readonly kind: \"playwright\" | \"webdriver\" | \"device-farm\" | \"safari-webdriver\";\n readonly driver: string;\n readonly version: string;\n readonly sha256: Sha256Hex;\n } | null;\n readonly resultCount: number;\n readonly status: ShaderQualificationStatus;\n}\n\n/** Non-secret claims emitted by the trusted prepare job after Blob version and OIDC verification. */\nexport interface ShaderQualificationPreflightManifest {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-qualification-preflight\";\n readonly qualificationId: string;\n readonly sourceBlob: {\n readonly host: string;\n readonly versionId: string;\n readonly uri: string;\n };\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n readonly subjectBindingSha256: Sha256Hex;\n readonly provenance: ShaderTrustedWorkflowProvenance;\n}\n\nexport interface ShaderNonQualifyingWorkflowDiagnostic {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"non-qualifying-workflow-diagnostic\";\n readonly qualificationId: string;\n readonly cellId: string;\n readonly status: \"timeout\" | \"failed\";\n readonly matrixSha256: Sha256Hex;\n readonly message: string;\n readonly qualificationPreflightProvenance: ShaderTrustedWorkflowProvenance;\n readonly producer: ShaderQualificationExecutionProducer;\n}\n\n/** External GitHub build-provenance reference; verified outside the evidence JSON digest. */\nexport interface ShaderValidationEvidenceAttestationRef {\n readonly contractVersion: typeof SHADER_VALIDATION_EVIDENCE_VERSION;\n readonly kind: \"shader-validation-evidence-attestation-ref\";\n readonly evidence: { readonly name: string; readonly sha256: Sha256Hex };\n readonly attestation: {\n readonly id: string;\n readonly url: string;\n readonly bundle: { readonly name: string; readonly sha256: Sha256Hex };\n };\n readonly producer: {\n readonly repository: string;\n readonly runId: string;\n readonly runAttempt: number;\n readonly trustedWorkflowRepository: \"Plasius-LTD/gpu-shader\";\n readonly trustedWorkflowRef: string;\n readonly trustedWorkflowSha: GitObjectId;\n };\n}\n\nexport interface ShaderCompileFixture {\n /** Local/hosted testing only. Callback fixtures can never produce trusted physical evidence. */\n readonly qualificationEligible: false;\n readonly fixtureId: string;\n setup(context: ShaderCompileContext): Promise<void>;\n encode(context: ShaderCompileContext): Promise<void>;\n verify(context: ShaderCompileContext): Promise<void>;\n cleanup(context: ShaderCompileContext): Promise<void>;\n}\n\nexport interface ShaderCompileContext {\n readonly device: GpuDeviceLike;\n readonly unit: ShaderCompileUnitManifest;\n readonly modules: ReadonlyMap<string, GpuShaderModuleLike>;\n readonly state: Map<string, unknown>;\n}\n","import type { JsonValue } from \"./contracts.js\";\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n}\n\nfunction assertUnicodeScalarString(value: string, path: string): void {\n for (let index = 0; index < value.length; index += 1) {\n const code = value.charCodeAt(index);\n if (code >= 0xd800 && code <= 0xdbff) {\n const next = value.charCodeAt(index + 1);\n if (!(next >= 0xdc00 && next <= 0xdfff)) throw new TypeError(`${path} contains an unpaired UTF-16 surrogate.`);\n index += 1;\n } else if (code >= 0xdc00 && code <= 0xdfff) throw new TypeError(`${path} contains an unpaired UTF-16 surrogate.`);\n }\n}\n\n/**\n * Canonicalizes contract data using the JSON Canonicalization Scheme ordering\n * rules. Unsupported JavaScript values are rejected rather than silently lost.\n */\nexport function canonicalizeGpuContract(value: unknown): string {\n const ancestors = new Set<object>();\n\n const visit = (current: unknown, path: string): string => {\n if (current === null) return \"null\";\n if (typeof current === \"string\" || typeof current === \"boolean\") {\n if (typeof current === \"string\") assertUnicodeScalarString(current, path);\n return JSON.stringify(current);\n }\n if (typeof current === \"number\") {\n if (!Number.isFinite(current)) {\n throw new TypeError(`${path} contains a non-finite number.`);\n }\n return Object.is(current, -0) ? \"0\" : JSON.stringify(current);\n }\n if (typeof current !== \"object\") {\n throw new TypeError(`${path} contains a value that JSON cannot represent.`);\n }\n if (ancestors.has(current)) {\n throw new TypeError(`${path} contains a circular reference.`);\n }\n\n ancestors.add(current);\n try {\n if (Array.isArray(current)) {\n return `[${current.map((item, index) => visit(item, `${path}[${index}]`)).join(\",\")}]`;\n }\n if (!isPlainObject(current)) {\n throw new TypeError(`${path} must contain only plain JSON objects.`);\n }\n const keys = Object.keys(current).sort();\n const properties = keys.map((key) => {\n assertUnicodeScalarString(key, `${path} key`);\n const member = current[key];\n if (member === undefined) {\n throw new TypeError(`${path}.${key} is undefined.`);\n }\n return `${JSON.stringify(key)}:${visit(member, `${path}.${key}`)}`;\n });\n return `{${properties.join(\",\")}}`;\n } finally {\n ancestors.delete(current);\n }\n };\n\n return visit(value, \"$root\");\n}\n\n/** Parses and verifies exact JCS canonical JSON while preserving its JSON-only type. */\nexport function parseCanonicalJson(value: string): JsonValue {\n const parsed = JSON.parse(value) as JsonValue;\n if (canonicalizeGpuContract(parsed) !== value) throw new TypeError(\"JSON input is valid but not in canonical form.\");\n return parsed;\n}\n","const ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;\n\nconst MUTABLE_VERSION_ALIASES = new Set([\n \"latest\",\n \"current\",\n \"stable\",\n \"preview\",\n \"default\",\n \"production\",\n \"canary\",\n \"next\",\n \"head\",\n \"main\",\n]);\n\nconst X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\\.|-|$)|\\.[xX](?:\\.|-|$)/u;\nconst IMMUTABLE_VERSION_ERROR_MESSAGE =\n \"Immutable asset version must be an exact token up to 128 characters; mutable aliases, ranges, wildcards, and URLs are not allowed.\";\n\n/**\n * Validates an immutable, reproducible model, interface, shader, or profile\n * version before catalog access.\n *\n * The diagnostic is deliberately constant and never interpolates untrusted\n * input, keeping runtime and storage-boundary failures bounded.\n */\nexport function assertImmutableAssetVersion(value: unknown): string {\n if (\n typeof value !== \"string\"\n || !ASSET_VERSION_PATTERN.test(value)\n || MUTABLE_VERSION_ALIASES.has(value.toLowerCase())\n || X_WILDCARD_SEGMENT_PATTERN.test(value)\n ) {\n throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);\n }\n return value;\n}\n","import { canonicalizeGpuContract } from \"./canonical-json.js\";\nimport type {\n GpuInterfaceManifest,\n SerializableGpuPipelineDescriptor,\n Sha256Hex,\n ShaderRequirements,\n ShaderVersionManifest,\n} from \"./contracts.js\";\n\nconst SHA256_PATTERN = /^[a-f0-9]{64}$/u;\n\nexport function asSha256Hex(value: string): Sha256Hex {\n if (!SHA256_PATTERN.test(value)) {\n throw new TypeError(\"SHA-256 values must be lowercase 64-character hexadecimal strings.\");\n }\n return value as Sha256Hex;\n}\n\n/** Computes a SHA-256 digest using the browser-safe Web Crypto API. */\nexport async function computeSha256(value: Uint8Array | string): Promise<Sha256Hex> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) {\n throw new Error(\"Web Crypto SHA-256 support is required.\");\n }\n const bytes = typeof value === \"string\" ? new TextEncoder().encode(value) : value;\n const digest = await subtle.digest(\"SHA-256\", bytes as BufferSource);\n return asSha256Hex(\n Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\"),\n );\n}\n\nfunction sorted<T>(items: readonly T[], compare: (left: T, right: T) => number): T[] {\n return [...items].sort(compare);\n}\n\nfunction compareString(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction interfaceProjection(manifest: GpuInterfaceManifest): unknown {\n return {\n contractVersion: manifest.contractVersion,\n records: sorted(manifest.records, (left, right) => compareString(left.name, right.name)),\n bindings: sorted(manifest.bindings, (left, right) =>\n compareString(left.moduleId, right.moduleId) || left.group - right.group || left.binding - right.binding),\n entryPoints: sorted(manifest.entryPoints, (left, right) =>\n compareString(left.moduleId, right.moduleId)\n || compareString(left.stage, right.stage)\n || compareString(left.name, right.name)),\n vertexInputs: sorted(manifest.vertexInputs, (left, right) =>\n compareString(left.pipelineId, right.pipelineId) || left.shaderLocation - right.shaderLocation),\n overrides: sorted(manifest.overrides, (left, right) =>\n compareString(left.moduleId, right.moduleId) || compareString(left.name, right.name)),\n };\n}\n\nfunction modelProjection(manifest: GpuInterfaceManifest): unknown {\n const recordsByName = new Map(manifest.records.map((record) => [record.name, record]));\n const names = new Set<string>();\n const includeRecord = (name: string): void => {\n if (names.has(name)) return;\n const record = recordsByName.get(name);\n if (!record) throw new TypeError(`Model ABI references missing record ${name}.`);\n names.add(name);\n const visitType = (type: typeof record.members[number][\"type\"]): void => {\n if (type.kind === \"record\") includeRecord(type.recordName);\n if (type.kind === \"array\") visitType(type.element);\n };\n for (const member of record.members) visitType(member.type);\n };\n for (const name of manifest.modelAbi.recordNames) includeRecord(name);\n for (const binding of manifest.modelAbi.bindings) {\n if (binding.resource.kind === \"buffer\" && binding.resource.recordName) includeRecord(binding.resource.recordName);\n }\n for (const semantic of manifest.modelAbi.semantics) {\n if (semantic.source.kind === \"record-member\") includeRecord(semantic.source.recordName);\n }\n const semanticProjection = manifest.modelAbi.semantics.map((projection) => ({\n semantic: projection.semantic,\n source: projection.source.kind === \"record-member\"\n ? {\n kind: projection.source.kind,\n recordName: projection.source.recordName,\n memberPath: projection.source.memberPath,\n }\n : { kind: projection.source.kind },\n }));\n return {\n contractVersion: manifest.contractVersion,\n records: sorted(\n manifest.records.filter((record) => names.has(record.name)),\n (left, right) => compareString(left.name, right.name),\n ).map(({ addressSpaces: _shaderUsage, ...record }) => record),\n bindings: sorted(manifest.modelAbi.bindings, (left, right) =>\n compareString(left.semantic ?? \"\", right.semantic ?? \"\")\n || compareString(canonicalizeGpuContract(left.resource), canonicalizeGpuContract(right.resource)))\n .map(({ source: _selector, ...binding }) => binding),\n vertexInputs: sorted(manifest.modelAbi.vertexInputs, (left, right) =>\n compareString(left.semantic ?? \"\", right.semantic ?? \"\")\n || left.offset - right.offset)\n .map(({ source: _selector, ...vertex }) => vertex),\n semantics: sorted(semanticProjection, (left, right) =>\n compareString(left.semantic, right.semantic),\n ),\n };\n}\n\nexport type ComputeGpuAbiHashInput =\n | { readonly kind: \"model\"; readonly interface: GpuInterfaceManifest }\n | { readonly kind: \"interface\"; readonly interface: GpuInterfaceManifest }\n | {\n readonly kind: \"shader\";\n readonly interface: GpuInterfaceManifest;\n readonly pipelines: readonly SerializableGpuPipelineDescriptor[];\n readonly requirements: ShaderRequirements;\n };\n\n/** Computes a domain-separated ABI digest over normalized structural data. */\nexport async function computeGpuAbiHash(input: ComputeGpuAbiHashInput): Promise<Sha256Hex> {\n if (input.kind === \"model\") {\n return computeSha256(\n `plasius.gpu.model-abi/v1\\n${canonicalizeGpuContract(modelProjection(input.interface))}`,\n );\n }\n if (input.kind === \"interface\") {\n return computeSha256(\n `plasius.gpu.interface-abi/v1\\n${canonicalizeGpuContract(interfaceProjection(input.interface))}`,\n );\n }\n const pipelines = sorted(input.pipelines, (left, right) =>\n compareString(left.pipelineId, right.pipelineId),\n );\n const requirements = {\n semantics: [...input.requirements.semantics].sort(),\n features: [...input.requirements.features].sort(),\n limits: sorted(input.requirements.limits, (left, right) => compareString(left.name, right.name)),\n formats: [...input.requirements.formats].sort(),\n };\n return computeSha256(\n `plasius.gpu.shader-abi/v1\\n${canonicalizeGpuContract({\n interface: interfaceProjection(input.interface),\n pipelines,\n requirements,\n })}`,\n );\n}\n\n/** Breaks the manifest/evidence digest cycle by omitting only the evidence reference. */\nexport async function computeShaderManifestCoreSha256(\n manifest: Omit<ShaderVersionManifest, \"validationEvidence\" | \"additionalValidationEvidence\"> | ShaderVersionManifest,\n): Promise<Sha256Hex> {\n const core = Object.fromEntries(Object.entries(manifest).filter(\n ([key]) => key !== \"validationEvidence\" && key !== \"additionalValidationEvidence\",\n ));\n return computeSha256(\n `plasius.gpu.shader-manifest-core/v1\\n${canonicalizeGpuContract(core)}`,\n );\n}\n","import {\n GPU_INTERFACE_MANIFEST_VERSION,\n SHADER_QUALIFICATION_FIXTURE_VERSION,\n SHADER_STYLE_PROFILE_MANIFEST_VERSION,\n SHADER_VERSION_MANIFEST_VERSION,\n SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES,\n SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES,\n type GpuBindingResourceLayout,\n type GpuInterfaceManifest,\n type ModelGpuCompatibilityDescriptor,\n type GpuRecordLayout,\n type GpuTypeLayout,\n type SerializableGpuPipelineDescriptor,\n type ShaderStyleProfileManifest,\n type ShaderQualificationModelCompatibilityFixture,\n type ShaderVersionManifest,\n type ShaderVersionManifestCore,\n} from \"./contracts.js\";\nimport { canonicalizeGpuContract as canonicalizeForValidation } from \"./canonical-json.js\";\nimport { assertImmutableAssetVersion } from \"./asset-version.js\";\nimport { asSha256Hex } from \"./hash.js\";\nimport { validatePipelineDerivedRequirements } from \"./requirements-validation.js\";\n\ntype UnknownRecord = Record<string, unknown>;\nconst stages = [\"vertex\", \"fragment\", \"compute\"] as const;\nconst roles = [\"material\", \"lighting\", \"outline\", \"shadow\", \"post-processing\"] as const;\n\nfunction detachedJson(value: unknown, path: string): unknown {\n try {\n return JSON.parse(canonicalizeForValidation(value)) as unknown;\n } catch (cause) {\n const detail = cause instanceof Error ? cause.message : \"Contract snapshot failed.\";\n const boundedDetail = [...detail].slice(0, 512).join(\"\");\n throw new TypeError(`${path} must contain detached JSON contract data: ${boundedDetail}`, { cause });\n }\n}\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const allowed = new Set(keys);\n for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path}.${key} is not part of this contract version.`);\n for (const key of keys) if (!(key in value)) throw new TypeError(`${path}.${key} is required.`);\n}\n\nfunction text(value: unknown, path: string, maximum = 512): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 0x1f)) {\n throw new TypeError(`${path} must be a bounded non-empty string without control characters.`);\n }\n return value;\n}\n\nfunction token(value: unknown, path: string): string {\n const result = text(value, path, 160);\n if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u.test(result) || result.includes(\"..\")) throw new TypeError(`${path} must be a safe token.`);\n return result;\n}\n\nfunction immutableVersion(value: unknown, path: string): string {\n try {\n return assertImmutableAssetVersion(value);\n } catch (cause) {\n throw new TypeError(\n `${path} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,\n { cause },\n );\n }\n}\n\nfunction enumeration<T extends string | number>(value: unknown, values: readonly T[], path: string): T {\n if (!values.includes(value as T)) throw new TypeError(`${path} is invalid.`);\n return value as T;\n}\n\nfunction integer(value: unknown, path: string, minimum = 0, maximum = 0xffff_ffff): number {\n if (!Number.isSafeInteger(value) || (value as number) < minimum || (value as number) > maximum) {\n throw new TypeError(`${path} must be an integer from ${minimum} through ${maximum}.`);\n }\n return value as number;\n}\n\nfunction finite(value: unknown, path: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value)) throw new TypeError(`${path} must be finite.`);\n return value;\n}\n\nfunction array(value: unknown, path: string, maximum = 4096): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${path} must be a bounded array.`);\n return value;\n}\n\nfunction nullableInteger(value: unknown, path: string): number | null {\n return value === null ? null : integer(value, path);\n}\n\nfunction nullableToken(value: unknown, path: string): string | null {\n return value === null ? null : token(value, path);\n}\n\nfunction digest(value: unknown, path: string): string {\n try { return asSha256Hex(text(value, path, 64)); }\n catch (cause) { throw new TypeError(`${path} must be a lowercase SHA-256 digest.`, { cause }); }\n}\n\nfunction uri(value: unknown, path: string): string {\n const result = text(value, path, 2048);\n let parsed: URL;\n try { parsed = new URL(result); }\n catch (cause) { throw new TypeError(`${path} must be an absolute immutable asset URI.`, { cause }); }\n if (parsed.protocol !== \"https:\" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path} must be credential-free HTTPS without a fragment.`);\n const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());\n const forbidden = new Set([\"sig\", \"se\", \"sp\", \"sv\", \"spr\", \"st\", \"skoid\", \"sktid\", \"skt\", \"ske\", \"sks\", \"skv\"]);\n if (keys.some((key) => forbidden.has(key)) || new Set(keys).size !== keys.length) throw new TypeError(`${path} must not contain SAS credentials or duplicate query parameters.`);\n if (parsed.href !== result) throw new TypeError(`${path} must use its canonical URL serialization.`);\n return result;\n}\n\nfunction unique<T>(values: readonly T[], key: (value: T) => string, path: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n const identity = key(value);\n if (seen.has(identity)) throw new TypeError(`${path} contains duplicate ${identity}.`);\n seen.add(identity);\n }\n}\n\nfunction tokenArray(value: unknown, path: string, maximum = 4096): string[] {\n const result = array(value, path, maximum).map((item, index) => token(item, `${path}[${index}]`));\n unique(result, String, path);\n return result;\n}\n\nfunction typeLayout(value: unknown, path: string, depth = 0): GpuTypeLayout {\n if (depth > 24) throw new TypeError(`${path} exceeds the type nesting limit.`);\n const input = object(value, path);\n const kind = enumeration(input.kind, [\"scalar\", \"atomic\", \"vector\", \"matrix\", \"array\", \"record\"] as const, `${path}.kind`);\n integer(input.alignment, `${path}.alignment`, 1);\n if (kind === \"array\") {\n exact(input, [\"kind\", \"element\", \"count\", \"stride\", \"alignment\", \"byteSize\"], path);\n const element = typeLayout(input.element, `${path}.element`, depth + 1);\n const count = nullableInteger(input.count, `${path}.count`);\n const stride = integer(input.stride, `${path}.stride`, 1);\n const byteSize = nullableInteger(input.byteSize, `${path}.byteSize`);\n if (input.alignment !== element.alignment || stride % element.alignment !== 0\n || element.byteSize === null || stride < element.byteSize\n || (count === null ? byteSize !== null : byteSize !== count * stride)) {\n throw new TypeError(`${path} has inconsistent array layout algebra.`);\n }\n } else if (kind === \"record\") {\n exact(input, [\"kind\", \"recordName\", \"alignment\", \"byteSize\"], path);\n token(input.recordName, `${path}.recordName`);\n nullableInteger(input.byteSize, `${path}.byteSize`);\n } else {\n integer(input.byteSize, `${path}.byteSize`, 1);\n if (kind === \"scalar\") {\n exact(input, [\"kind\", \"scalar\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\", \"f32\", \"f16\", \"bool\"] as const, `${path}.scalar`);\n const size = input.scalar === \"f16\" ? 2 : 4;\n if (input.alignment !== size || input.byteSize !== size) throw new TypeError(`${path} has inconsistent scalar layout.`);\n } else if (kind === \"atomic\") {\n exact(input, [\"kind\", \"scalar\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\"] as const, `${path}.scalar`);\n if (input.alignment !== 4 || input.byteSize !== 4) throw new TypeError(`${path} has inconsistent atomic layout.`);\n } else if (kind === \"vector\") {\n exact(input, [\"kind\", \"scalar\", \"width\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"i32\", \"u32\", \"f32\", \"f16\", \"bool\"] as const, `${path}.scalar`);\n const width = enumeration(input.width, [2, 3, 4] as const, `${path}.width`);\n const scalarSize = input.scalar === \"f16\" ? 2 : 4;\n if (input.alignment !== (width === 2 ? 2 : 4) * scalarSize || input.byteSize !== width * scalarSize) throw new TypeError(`${path} has inconsistent vector layout.`);\n } else {\n exact(input, [\"kind\", \"scalar\", \"columns\", \"rows\", \"columnStride\", \"alignment\", \"byteSize\"], path);\n enumeration(input.scalar, [\"f32\", \"f16\"] as const, `${path}.scalar`);\n const columns = enumeration(input.columns, [2, 3, 4] as const, `${path}.columns`);\n const rows = enumeration(input.rows, [2, 3, 4] as const, `${path}.rows`);\n const stride = integer(input.columnStride, `${path}.columnStride`, 1);\n const scalarSize = input.scalar === \"f16\" ? 2 : 4;\n const alignment = (rows === 2 ? 2 : 4) * scalarSize;\n if (input.alignment !== alignment || stride !== Math.ceil((rows * scalarSize) / alignment) * alignment || input.byteSize !== columns * stride) throw new TypeError(`${path} has inconsistent matrix layout.`);\n }\n }\n return input as unknown as GpuTypeLayout;\n}\n\nfunction recordLayout(value: unknown, path: string): GpuRecordLayout {\n const input = object(value, path);\n exact(input, [\"name\", \"alignment\", \"byteSize\", \"minimumByteSize\", \"runtimeArrayMember\", \"addressSpaces\", \"members\"], path);\n token(input.name, `${path}.name`);\n integer(input.alignment, `${path}.alignment`, 1);\n nullableInteger(input.byteSize, `${path}.byteSize`);\n integer(input.minimumByteSize, `${path}.minimumByteSize`);\n nullableToken(input.runtimeArrayMember, `${path}.runtimeArrayMember`);\n const spaces = array(input.addressSpaces, `${path}.addressSpaces`, 5).map((space, index) =>\n enumeration(space, [\"uniform\", \"storage\", \"function\", \"private\", \"workgroup\"] as const, `${path}.addressSpaces[${index}]`));\n unique(spaces, String, `${path}.addressSpaces`);\n const members = array(input.members, `${path}.members`);\n let priorEnd = 0;\n const names: string[] = [];\n members.forEach((value, index) => {\n const memberPath = `${path}.members[${index}]`;\n const member = object(value, memberPath);\n exact(member, [\"name\", \"offset\", \"alignment\", \"valueByteSize\", \"occupiedByteSize\", \"explicitAlign\", \"explicitSize\", \"type\"], memberPath);\n names.push(token(member.name, `${memberPath}.name`));\n const offset = integer(member.offset, `${memberPath}.offset`);\n const alignment = integer(member.alignment, `${memberPath}.alignment`, 1);\n const valueSize = nullableInteger(member.valueByteSize, `${memberPath}.valueByteSize`);\n const occupied = nullableInteger(member.occupiedByteSize, `${memberPath}.occupiedByteSize`);\n const explicitAlign = member.explicitAlign === null ? null : integer(member.explicitAlign, `${memberPath}.explicitAlign`, 1);\n const explicitSize = member.explicitSize === null ? null : integer(member.explicitSize, `${memberPath}.explicitSize`, 1);\n const type = typeLayout(member.type, `${memberPath}.type`);\n if (explicitAlign !== null && ((explicitAlign & (explicitAlign - 1)) !== 0 || explicitAlign < type.alignment)) {\n throw new TypeError(`${memberPath}.explicitAlign must be a power of two no smaller than the natural alignment.`);\n }\n if (explicitSize !== null && (type.byteSize === null || explicitSize < type.byteSize)) {\n throw new TypeError(`${memberPath}.explicitSize must not shrink a fixed-size WGSL type.`);\n }\n if (offset < priorEnd || offset % alignment !== 0 || alignment !== (explicitAlign ?? type.alignment)\n || valueSize !== type.byteSize || occupied !== (explicitSize ?? type.byteSize)\n || (occupied !== null && valueSize !== null && occupied < valueSize)) {\n throw new TypeError(`${memberPath} has inconsistent member layout algebra.`);\n }\n if (occupied === null && index !== members.length - 1) throw new TypeError(`${memberPath} is a non-final runtime array.`);\n if (occupied !== null) priorEnd = offset + occupied;\n });\n unique(names, String, `${path}.members`);\n if ((input.byteSize === null) !== (input.runtimeArrayMember !== null)) throw new TypeError(`${path} has inconsistent runtime array metadata.`);\n const maximumAlignment = Math.max(1, ...members.map((value) => Number((value as UnknownRecord).alignment)));\n if (input.alignment !== maximumAlignment) throw new TypeError(`${path}.alignment is inconsistent with its members.`);\n const tail = members.at(-1) as UnknownRecord | undefined;\n const expectedMinimum = input.runtimeArrayMember === null\n ? Math.ceil(priorEnd / Number(input.alignment)) * Number(input.alignment)\n : Number(tail?.offset ?? 0);\n if (input.minimumByteSize !== expectedMinimum || (input.byteSize !== null && input.byteSize !== expectedMinimum)\n || (input.runtimeArrayMember !== null && tail?.name !== input.runtimeArrayMember)) {\n throw new TypeError(`${path} has inconsistent fixed/runtime size metadata.`);\n }\n if (input.runtimeArrayMember !== null) {\n const tailType = tail?.type as GpuTypeLayout | undefined;\n if (!tailType || tailType.kind !== \"array\" || tailType.count !== null) throw new TypeError(`${path}.runtimeArrayMember must name a direct trailing runtime-sized array.`);\n }\n return input as unknown as GpuRecordLayout;\n}\n\nfunction bindingResource(value: unknown, path: string): GpuBindingResourceLayout {\n const input = object(value, path);\n const kind = enumeration(input.kind, [\"buffer\", \"sampler\", \"texture\", \"storage-texture\", \"external-texture\"] as const, `${path}.kind`);\n if (kind === \"buffer\") {\n exact(input, [\"kind\", \"addressSpace\", \"access\", \"recordName\", \"minimumBindingSize\"], path);\n enumeration(input.addressSpace, [\"uniform\", \"storage\"] as const, `${path}.addressSpace`);\n enumeration(input.access, [\"read\", \"write\", \"read_write\"] as const, `${path}.access`);\n if (input.addressSpace === \"uniform\" && input.access !== \"read\") throw new TypeError(`${path}.access must be read for uniform buffers.`);\n nullableToken(input.recordName, `${path}.recordName`);\n integer(input.minimumBindingSize, `${path}.minimumBindingSize`);\n } else if (kind === \"sampler\") {\n exact(input, [\"kind\", \"samplerType\"], path);\n enumeration(input.samplerType, [\"filtering\", \"non-filtering\", \"comparison\"] as const, `${path}.samplerType`);\n } else if (kind === \"texture\") {\n exact(input, [\"kind\", \"sampleType\", \"viewDimension\", \"multisampled\"], path);\n enumeration(input.sampleType, [\"float\", \"unfilterable-float\", \"depth\", \"sint\", \"uint\"] as const, `${path}.sampleType`);\n enumeration(input.viewDimension, [\"1d\", \"2d\", \"2d-array\", \"cube\", \"cube-array\", \"3d\"] as const, `${path}.viewDimension`);\n if (typeof input.multisampled !== \"boolean\") throw new TypeError(`${path}.multisampled must be boolean.`);\n } else if (kind === \"storage-texture\") {\n exact(input, [\"kind\", \"access\", \"format\", \"viewDimension\"], path);\n enumeration(input.access, [\"write-only\", \"read-only\", \"read-write\"] as const, `${path}.access`);\n token(input.format, `${path}.format`);\n enumeration(input.viewDimension, [\"1d\", \"2d\", \"2d-array\", \"3d\"] as const, `${path}.viewDimension`);\n } else exact(input, [\"kind\"], path);\n return input as unknown as GpuBindingResourceLayout;\n}\n\nfunction visibility(value: unknown, path: string): (typeof stages)[number][] {\n const result = array(value, path, 3).map((item, index) => enumeration(item, stages, `${path}[${index}]`));\n unique(result, String, path);\n if (result.length === 0) throw new TypeError(`${path} must include at least one shader stage.`);\n return result;\n}\n\nfunction binding(value: unknown, path: string, coordinates = true): UnknownRecord {\n const input = object(value, path);\n exact(input, coordinates\n ? [\"moduleId\", \"variableName\", \"group\", \"binding\", \"resource\", \"visibility\"]\n : [\"source\", \"resource\", \"semantic\"], path);\n if (coordinates) {\n token(input.moduleId, `${path}.moduleId`); token(input.variableName, `${path}.variableName`);\n integer(input.group, `${path}.group`); integer(input.binding, `${path}.binding`);\n visibility(input.visibility, `${path}.visibility`);\n } else {\n const source = object(input.source, `${path}.source`); exact(source, [\"moduleId\", \"group\", \"binding\"], `${path}.source`);\n token(source.moduleId, `${path}.source.moduleId`); integer(source.group, `${path}.source.group`); integer(source.binding, `${path}.source.binding`);\n nullableToken(input.semantic, `${path}.semantic`);\n }\n bindingResource(input.resource, `${path}.resource`);\n return input;\n}\n\nfunction entryIo(value: unknown, path: string): UnknownRecord {\n const input = object(value, path);\n exact(input, [\"name\", \"locationKind\", \"location\", \"interpolation\", \"type\"], path);\n token(input.name, `${path}.name`);\n const kind = enumeration(input.locationKind, [\"location\", \"builtin\"] as const, `${path}.locationKind`);\n if (kind === \"location\") integer(input.location, `${path}.location`); else token(input.location, `${path}.location`);\n if (input.interpolation !== null) token(input.interpolation, `${path}.interpolation`);\n typeLayout(input.type, `${path}.type`);\n return input;\n}\n\nfunction vertexInput(value: unknown, path: string, model = false): UnknownRecord {\n const input = object(value, path);\n if (model) {\n exact(input, [\"source\", \"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"], path);\n const source = object(input.source, `${path}.source`); exact(source, [\"pipelineId\", \"shaderLocation\"], `${path}.source`);\n token(source.pipelineId, `${path}.source.pipelineId`); integer(source.shaderLocation, `${path}.source.shaderLocation`);\n token(input.semantic, `${path}.semantic`);\n } else {\n exact(input, [\"pipelineId\", \"moduleId\", \"entryPoint\", \"shaderLocation\", \"shaderType\", \"bufferSlot\", \"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"], path);\n token(input.pipelineId, `${path}.pipelineId`); token(input.moduleId, `${path}.moduleId`); token(input.entryPoint, `${path}.entryPoint`);\n integer(input.shaderLocation, `${path}.shaderLocation`); typeLayout(input.shaderType, `${path}.shaderType`); integer(input.bufferSlot, `${path}.bufferSlot`);\n nullableToken(input.semantic, `${path}.semantic`);\n }\n token(input.format, `${path}.format`); integer(input.offset, `${path}.offset`); integer(input.arrayStride, `${path}.arrayStride`);\n enumeration(input.stepMode, [\"vertex\", \"instance\"] as const, `${path}.stepMode`);\n return input;\n}\n\nfunction semantic(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"semantic\", \"source\"], path); token(input.semantic, `${path}.semantic`);\n const source = object(input.source, `${path}.source`);\n const kind = enumeration(source.kind, [\"record-member\", \"vertex-attribute\", \"binding\"] as const, `${path}.source.kind`);\n if (kind === \"record-member\") {\n exact(source, [\"kind\", \"recordName\", \"memberPath\"], `${path}.source`); token(source.recordName, `${path}.source.recordName`);\n tokenArray(source.memberPath, `${path}.source.memberPath`, 24);\n } else if (kind === \"vertex-attribute\") {\n exact(source, [\"kind\", \"pipelineId\", \"shaderLocation\"], `${path}.source`); token(source.pipelineId, `${path}.source.pipelineId`); integer(source.shaderLocation, `${path}.source.shaderLocation`);\n } else {\n exact(source, [\"kind\", \"moduleId\", \"group\", \"binding\"], `${path}.source`); token(source.moduleId, `${path}.source.moduleId`);\n integer(source.group, `${path}.source.group`); integer(source.binding, `${path}.source.binding`);\n }\n return input;\n}\n\nfunction interfaceRef(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"interfaceId\", \"interfaceVersion\", \"manifestUri\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"], path);\n token(input.interfaceId, `${path}.interfaceId`); immutableVersion(input.interfaceVersion, `${path}.interfaceVersion`); uri(input.manifestUri, `${path}.manifestUri`);\n digest(input.manifestSha256, `${path}.manifestSha256`); digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`); digest(input.modelAbiHash, `${path}.modelAbiHash`);\n return input;\n}\n\nfunction programmable(value: unknown, path: string, moduleIds: ReadonlySet<string>): UnknownRecord {\n const input = object(value, path); exact(input, [\"moduleId\", \"entryPoint\", \"constants\"], path);\n const moduleId = token(input.moduleId, `${path}.moduleId`); if (!moduleIds.has(moduleId)) throw new TypeError(`${path}.moduleId is not in modules.`);\n token(input.entryPoint, `${path}.entryPoint`);\n const constants = object(input.constants, `${path}.constants`);\n for (const [name, value] of Object.entries(constants)) { token(name, `${path}.constants key`); if (typeof value !== \"boolean\") finite(value, `${path}.constants.${name}`); }\n return input;\n}\n\nfunction pipeline(value: unknown, path: string, moduleIds: ReadonlySet<string>): SerializableGpuPipelineDescriptor {\n const input = object(value, path); const kind = enumeration(input.kind, [\"compute\", \"render\"] as const, `${path}.kind`);\n const common = kind === \"compute\" ? [\"kind\", \"pipelineId\", \"layout\", \"compute\"] : [\"kind\", \"pipelineId\", \"layout\", \"vertex\", \"fragment\", \"vertexBuffers\", \"primitive\", \"colorTargets\", \"depthStencil\", \"multisample\"];\n exact(input, common, path); token(input.pipelineId, `${path}.pipelineId`);\n const layout = object(input.layout, `${path}.layout`); exact(layout, [\"bindGroups\"], `${path}.layout`);\n const groups = array(layout.bindGroups, `${path}.layout.bindGroups`);\n const groupIds: number[] = [];\n groups.forEach((value, groupIndex) => {\n const groupPath = `${path}.layout.bindGroups[${groupIndex}]`; const group = object(value, groupPath); exact(group, [\"group\", \"entries\"], groupPath);\n const groupId = integer(group.group, `${groupPath}.group`); groupIds.push(groupId);\n const entries = array(group.entries, `${groupPath}.entries`); const bindingIds: number[] = [];\n entries.forEach((entryValue, entryIndex) => {\n const entryPath = `${groupPath}.entries[${entryIndex}]`; const entry = object(entryValue, entryPath);\n exact(entry, [\"group\", \"binding\", \"resource\", \"visibility\"], entryPath);\n if (integer(entry.group, `${entryPath}.group`) !== groupId) throw new TypeError(`${entryPath}.group differs from its parent.`);\n bindingIds.push(integer(entry.binding, `${entryPath}.binding`)); bindingResource(entry.resource, `${entryPath}.resource`); visibility(entry.visibility, `${entryPath}.visibility`);\n });\n unique(bindingIds, String, `${groupPath}.entries`);\n });\n unique(groupIds, String, `${path}.layout.bindGroups`);\n [...groupIds].sort((a, b) => a - b).forEach((group, index) => { if (group !== index) throw new TypeError(`${path}.layout.bindGroups must be contiguous from zero.`); });\n if (kind === \"compute\") programmable(input.compute, `${path}.compute`, moduleIds);\n else {\n programmable(input.vertex, `${path}.vertex`, moduleIds); if (input.fragment !== null) programmable(input.fragment, `${path}.fragment`, moduleIds);\n array(input.vertexBuffers, `${path}.vertexBuffers`, 16).forEach((value, bufferIndex) => {\n const bufferPath = `${path}.vertexBuffers[${bufferIndex}]`; const buffer = object(value, bufferPath); exact(buffer, [\"arrayStride\", \"stepMode\", \"attributes\"], bufferPath);\n integer(buffer.arrayStride, `${bufferPath}.arrayStride`, 0, 2048); enumeration(buffer.stepMode, [\"vertex\", \"instance\"] as const, `${bufferPath}.stepMode`);\n array(buffer.attributes, `${bufferPath}.attributes`, 16).forEach((value, attributeIndex) => {\n const attributePath = `${bufferPath}.attributes[${attributeIndex}]`; const attribute = object(value, attributePath); exact(attribute, [\"format\", \"offset\", \"shaderLocation\", \"semantic\"], attributePath);\n token(attribute.format, `${attributePath}.format`); integer(attribute.offset, `${attributePath}.offset`); integer(attribute.shaderLocation, `${attributePath}.shaderLocation`); nullableToken(attribute.semantic, `${attributePath}.semantic`);\n });\n });\n const primitive = object(input.primitive, `${path}.primitive`); exact(primitive, [\"topology\", \"stripIndexFormat\", \"frontFace\", \"cullMode\", \"unclippedDepth\"], `${path}.primitive`);\n const topology = enumeration(primitive.topology, [\"point-list\", \"line-list\", \"line-strip\", \"triangle-list\", \"triangle-strip\"] as const, `${path}.primitive.topology`);\n if (primitive.stripIndexFormat !== null) enumeration(primitive.stripIndexFormat, [\"uint16\", \"uint32\"] as const, `${path}.primitive.stripIndexFormat`);\n if (primitive.stripIndexFormat !== null && topology !== \"line-strip\" && topology !== \"triangle-strip\") throw new TypeError(`${path}.primitive.stripIndexFormat is only valid for strip topologies.`);\n enumeration(primitive.frontFace, [\"ccw\", \"cw\"] as const, `${path}.primitive.frontFace`); enumeration(primitive.cullMode, [\"none\", \"front\", \"back\"] as const, `${path}.primitive.cullMode`); if (typeof primitive.unclippedDepth !== \"boolean\") throw new TypeError(`${path}.primitive.unclippedDepth must be boolean.`);\n const compare = [\"never\", \"less\", \"equal\", \"less-equal\", \"greater\", \"not-equal\", \"greater-equal\", \"always\"] as const;\n const operations = [\"keep\", \"zero\", \"replace\", \"invert\", \"increment-clamp\", \"decrement-clamp\", \"increment-wrap\", \"decrement-wrap\"] as const;\n const factors = [\"zero\", \"one\", \"src\", \"one-minus-src\", \"src-alpha\", \"one-minus-src-alpha\", \"dst\", \"one-minus-dst\", \"dst-alpha\", \"one-minus-dst-alpha\", \"src-alpha-saturated\", \"constant\", \"one-minus-constant\"] as const;\n const parseBlend = (value: unknown, label: string): void => { const component = object(value, label); exact(component, [\"operation\", \"srcFactor\", \"dstFactor\"], label); enumeration(component.operation, [\"add\", \"subtract\", \"reverse-subtract\", \"min\", \"max\"] as const, `${label}.operation`); enumeration(component.srcFactor, factors, `${label}.srcFactor`); enumeration(component.dstFactor, factors, `${label}.dstFactor`); };\n const colorTargets = array(input.colorTargets, `${path}.colorTargets`, 8); if (input.fragment === null && colorTargets.length !== 0) throw new TypeError(`${path}.colorTargets must be empty when fragment is null.`); colorTargets.forEach((value, index) => { const label = `${path}.colorTargets[${index}]`; const target = object(value, label); exact(target, [\"format\", \"blend\", \"writeMask\"], label); token(target.format, `${label}.format`); integer(target.writeMask, `${label}.writeMask`, 0, 15); if (target.blend !== null) { const blend = object(target.blend, `${label}.blend`); exact(blend, [\"color\", \"alpha\"], `${label}.blend`); parseBlend(blend.color, `${label}.blend.color`); parseBlend(blend.alpha, `${label}.blend.alpha`); } });\n const parseStencil = (value: unknown, label: string): void => { const stencil = object(value, label); exact(stencil, [\"compare\", \"failOp\", \"depthFailOp\", \"passOp\"], label); enumeration(stencil.compare, compare, `${label}.compare`); enumeration(stencil.failOp, operations, `${label}.failOp`); enumeration(stencil.depthFailOp, operations, `${label}.depthFailOp`); enumeration(stencil.passOp, operations, `${label}.passOp`); };\n if (input.depthStencil !== null) { const depth = object(input.depthStencil, `${path}.depthStencil`); exact(depth, [\"format\", \"depthWriteEnabled\", \"depthCompare\", \"stencilFront\", \"stencilBack\", \"stencilReadMask\", \"stencilWriteMask\", \"depthBias\", \"depthBiasSlopeScale\", \"depthBiasClamp\"], `${path}.depthStencil`); token(depth.format, `${path}.depthStencil.format`); if (typeof depth.depthWriteEnabled !== \"boolean\") throw new TypeError(`${path}.depthStencil.depthWriteEnabled must be boolean.`); enumeration(depth.depthCompare, compare, `${path}.depthStencil.depthCompare`); parseStencil(depth.stencilFront, `${path}.depthStencil.stencilFront`); parseStencil(depth.stencilBack, `${path}.depthStencil.stencilBack`); integer(depth.stencilReadMask, `${path}.depthStencil.stencilReadMask`); integer(depth.stencilWriteMask, `${path}.depthStencil.stencilWriteMask`); integer(depth.depthBias, `${path}.depthStencil.depthBias`, -0x8000_0000, 0x7fff_ffff); finite(depth.depthBiasSlopeScale, `${path}.depthStencil.depthBiasSlopeScale`); finite(depth.depthBiasClamp, `${path}.depthStencil.depthBiasClamp`); }\n const multisample = object(input.multisample, `${path}.multisample`); exact(multisample, [\"count\", \"mask\", \"alphaToCoverageEnabled\"], `${path}.multisample`); enumeration(multisample.count, [1, 4] as const, `${path}.multisample.count`); integer(multisample.mask, `${path}.multisample.mask`); if (typeof multisample.alphaToCoverageEnabled !== \"boolean\") throw new TypeError(`${path}.multisample.alphaToCoverageEnabled must be boolean.`); if (multisample.alphaToCoverageEnabled && multisample.count === 1) throw new TypeError(`${path}.multisample.alphaToCoverageEnabled requires multisampling.`);\n }\n return input as unknown as SerializableGpuPipelineDescriptor;\n}\n\nexport function parseSerializableGpuPipelineDescriptors(\n value: unknown,\n moduleIds: readonly string[],\n path = \"pipelines\",\n): readonly SerializableGpuPipelineDescriptor[] {\n const parsed = array(detachedJson(value, path), path).map((item, index) => pipeline(item, `${path}[${index}]`, new Set(moduleIds)));\n unique(parsed, (item) => item.pipelineId, path);\n return freeze(parsed);\n}\n\nfunction compatibleModel(value: unknown, path: string): UnknownRecord {\n const input = object(value, path); exact(input, [\"interfaceId\", \"interfaceVersion\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"], path);\n token(input.interfaceId, `${path}.interfaceId`); immutableVersion(input.interfaceVersion, `${path}.interfaceVersion`); digest(input.manifestSha256, `${path}.manifestSha256`); digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`); digest(input.modelAbiHash, `${path}.modelAbiHash`); return input;\n}\n\nfunction validationEvidenceRef(value: unknown, path: string): UnknownRecord {\n const evidence = object(value, path);\n exact(evidence, [\"evidenceId\", \"uri\", \"sha256\", \"matrixId\", \"matrixVersion\", \"matrixSha256\", \"attestationRef\"], path);\n token(evidence.evidenceId, `${path}.evidenceId`);\n uri(evidence.uri, `${path}.uri`);\n digest(evidence.sha256, `${path}.sha256`);\n token(evidence.matrixId, `${path}.matrixId`);\n immutableVersion(evidence.matrixVersion, `${path}.matrixVersion`);\n digest(evidence.matrixSha256, `${path}.matrixSha256`);\n const attestation = object(evidence.attestationRef, `${path}.attestationRef`);\n exact(attestation, [\"uri\", \"sha256\"], `${path}.attestationRef`);\n uri(attestation.uri, `${path}.attestationRef.uri`);\n digest(attestation.sha256, `${path}.attestationRef.sha256`);\n if (evidence.uri === attestation.uri || evidence.sha256 === attestation.sha256) {\n throw new TypeError(`${path} evidence and attestation artifacts must have distinct URIs and digests.`);\n }\n return evidence;\n}\n\nfunction freeze<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n for (const child of Object.values(value as Record<string, unknown>)) freeze(child);\n return Object.freeze(value);\n}\n\nfunction reflectedRecordBindingSize(record: GpuRecordLayout): number {\n if (record.byteSize !== null) return record.byteSize;\n if (record.runtimeArrayMember === null) throw new TypeError(`Record ${record.name} has inconsistent runtime-array metadata.`);\n const member = record.members.find((candidate) => candidate.name === record.runtimeArrayMember);\n if (!member || member.type.kind !== \"array\" || member.type.count !== null) {\n throw new TypeError(`Record ${record.name} has invalid trailing runtime-array metadata.`);\n }\n const unrounded = member.offset + member.type.stride;\n return Math.ceil(unrounded / record.alignment) * record.alignment;\n}\n\n/** Strictly parses untrusted reflected interface JSON and validates all nested references. */\nexport function parseGpuInterfaceManifest(value: unknown): GpuInterfaceManifest {\n const input = object(detachedJson(value, \"GpuInterfaceManifest\"), \"GpuInterfaceManifest\");\n exact(input, [\"contractVersion\", \"interfaceId\", \"interfaceVersion\", \"modules\", \"records\", \"bindings\", \"entryPoints\", \"vertexInputs\", \"overrides\", \"modelAbi\", \"modelAbiHash\", \"interfaceAbiHash\", \"generatedBy\"], \"GpuInterfaceManifest\");\n if (input.contractVersion !== GPU_INTERFACE_MANIFEST_VERSION) throw new TypeError(\"Unsupported GPU interface contract version.\");\n token(input.interfaceId, \"GpuInterfaceManifest.interfaceId\"); immutableVersion(input.interfaceVersion, \"GpuInterfaceManifest.interfaceVersion\");\n const moduleValues = array(input.modules, \"GpuInterfaceManifest.modules\");\n if (moduleValues.length === 0) throw new TypeError(\"GpuInterfaceManifest.modules must not be empty.\");\n const moduleIds = moduleValues.map((value, index) => { const path = `GpuInterfaceManifest.modules[${index}]`; const module = object(value, path); exact(module, [\"moduleId\", \"sha256\"], path); digest(module.sha256, `${path}.sha256`); return token(module.moduleId, `${path}.moduleId`); });\n unique(moduleIds, String, \"GpuInterfaceManifest.modules\"); const moduleSet = new Set(moduleIds);\n const recordValues = array(input.records, \"GpuInterfaceManifest.records\"); const parsedRecords = recordValues.map((item, index) => recordLayout(item, `GpuInterfaceManifest.records[${index}]`));\n unique(parsedRecords, (item) => item.name, \"GpuInterfaceManifest.records\"); const records = new Map(parsedRecords.map((item) => [item.name, item]));\n for (const record of parsedRecords) for (const member of record.members) {\n const visit = (type: GpuTypeLayout): void => { if (type.kind === \"record\") { const referenced = records.get(type.recordName); if (!referenced) throw new TypeError(`Record ${record.name} references missing ${type.recordName}.`); if (type.alignment !== referenced.alignment || type.byteSize !== referenced.byteSize) throw new TypeError(`Record reference ${record.name}.${member.name} has stale layout metadata.`); } if (type.kind === \"array\") visit(type.element); };\n visit(member.type);\n }\n const bindingValues = array(input.bindings, \"GpuInterfaceManifest.bindings\"); const bindingKeys: string[] = [];\n bindingValues.forEach((item, index) => { const path = `GpuInterfaceManifest.bindings[${index}]`; const parsed = binding(item, path); const moduleId = String(parsed.moduleId); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); bindingKeys.push(`${moduleId}:${parsed.group}:${parsed.binding}`); const resource = parsed.resource as GpuBindingResourceLayout; if (resource.kind === \"buffer\" && resource.recordName) { const record = records.get(resource.recordName); if (!record) throw new TypeError(`${path} references missing record.`); if (resource.minimumBindingSize !== reflectedRecordBindingSize(record)) throw new TypeError(`${path}.resource.minimumBindingSize differs from its reflected record.`); if (record.runtimeArrayMember !== null && resource.addressSpace !== \"storage\") throw new TypeError(`${path} exposes a runtime-sized array outside storage.`); } });\n unique(bindingKeys, String, \"GpuInterfaceManifest.bindings\"); const bindingSet = new Set(bindingKeys);\n const overrideValues = array(input.overrides, \"GpuInterfaceManifest.overrides\"); const overrideKeys: string[] = []; const overrideIds: string[] = [];\n overrideValues.forEach((item, index) => { const path = `GpuInterfaceManifest.overrides[${index}]`; const override = object(item, path); exact(override, [\"moduleId\", \"name\", \"id\", \"type\", \"defaultValue\"], path); const moduleId = token(override.moduleId, `${path}.moduleId`); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); const name = token(override.name, `${path}.name`); overrideKeys.push(`${moduleId}:${name}`); if (override.id !== null) overrideIds.push(`${moduleId}:${integer(override.id, `${path}.id`)}`); enumeration(override.type, [\"bool\", \"i32\", \"u32\", \"f32\", \"f16\"] as const, `${path}.type`); if (override.defaultValue !== null && typeof override.defaultValue !== \"boolean\") finite(override.defaultValue, `${path}.defaultValue`); });\n unique(overrideKeys, String, \"GpuInterfaceManifest.overrides\"); unique(overrideIds, String, \"GpuInterfaceManifest.overrides ids\"); const overrideSet = new Set(overrideKeys);\n const entryValues = array(input.entryPoints, \"GpuInterfaceManifest.entryPoints\"); const entryKeys: string[] = [];\n if (entryValues.length === 0) throw new TypeError(\"GpuInterfaceManifest.entryPoints must not be empty.\");\n entryValues.forEach((item, index) => { const path = `GpuInterfaceManifest.entryPoints[${index}]`; const entry = object(item, path); exact(entry, [\"moduleId\", \"name\", \"stage\", \"inputs\", \"outputs\", \"bindingKeys\", \"overrideNames\", \"workgroupSize\", \"workgroupStorageSize\"], path); const moduleId = token(entry.moduleId, `${path}.moduleId`); if (!moduleSet.has(moduleId)) throw new TypeError(`${path}.moduleId is missing.`); const stage = enumeration(entry.stage, stages, `${path}.stage`); entryKeys.push(`${moduleId}:${stage}:${token(entry.name, `${path}.name`)}`); for (const ioKey of [\"inputs\", \"outputs\"] as const) { const ios = array(entry[ioKey], `${path}.${ioKey}`).map((value, ioIndex) => entryIo(value, `${path}.${ioKey}[${ioIndex}]`)); unique(ios, (io) => `${io.locationKind}:${io.location}`, `${path}.${ioKey}`); } const resources = tokenArray(entry.bindingKeys, `${path}.bindingKeys`); resources.forEach((key) => { if (!bindingSet.has(key)) throw new TypeError(`${path}.bindingKeys references missing ${key}.`); }); const names = tokenArray(entry.overrideNames, `${path}.overrideNames`); names.forEach((name) => { if (!overrideSet.has(`${moduleId}:${name}`)) throw new TypeError(`${path}.overrideNames references missing ${name}.`); }); if (stage === \"compute\") { const dimensions = array(entry.workgroupSize, `${path}.workgroupSize`, 3); if (dimensions.length !== 3) throw new TypeError(`${path}.workgroupSize must have three dimensions.`); dimensions.forEach((value, dimensionIndex) => { const dimensionPath = `${path}.workgroupSize[${dimensionIndex}]`; const dimension = object(value, dimensionPath); const kind = enumeration(dimension.kind, [\"literal\", \"override\"] as const, `${dimensionPath}.kind`); if (kind === \"literal\") { exact(dimension, [\"kind\", \"value\"], dimensionPath); integer(dimension.value, `${dimensionPath}.value`, 1); } else { exact(dimension, [\"kind\", \"name\"], dimensionPath); const name = token(dimension.name, `${dimensionPath}.name`); if (!overrideSet.has(`${moduleId}:${name}`)) throw new TypeError(`${dimensionPath} references missing override.`); } }); integer(entry.workgroupStorageSize, `${path}.workgroupStorageSize`); } else if (entry.workgroupSize !== null || entry.workgroupStorageSize !== null) throw new TypeError(`${path} workgroup metadata is only valid for compute.`); });\n unique(entryKeys, String, \"GpuInterfaceManifest.entryPoints\"); const entrySet = new Set(entryKeys);\n const vertexValues = array(input.vertexInputs, \"GpuInterfaceManifest.vertexInputs\"); const vertexKeys: string[] = []; const parsedVertices: UnknownRecord[] = [];\n vertexValues.forEach((item, index) => { const path = `GpuInterfaceManifest.vertexInputs[${index}]`; const vertex = vertexInput(item, path); parsedVertices.push(vertex); if (!entrySet.has(`${vertex.moduleId}:vertex:${vertex.entryPoint}`)) throw new TypeError(`${path} references missing vertex entry point.`); vertexKeys.push(`${vertex.pipelineId}:${vertex.shaderLocation}`); }); unique(vertexKeys, String, \"GpuInterfaceManifest.vertexInputs\");\n const model = object(input.modelAbi, \"GpuInterfaceManifest.modelAbi\"); exact(model, [\"recordNames\", \"bindings\", \"vertexInputs\", \"semantics\"], \"GpuInterfaceManifest.modelAbi\");\n tokenArray(model.recordNames, \"GpuInterfaceManifest.modelAbi.recordNames\").forEach((name) => { if (!records.has(name)) throw new TypeError(`Model ABI references missing record ${name}.`); });\n const modelBindings = array(model.bindings, \"GpuInterfaceManifest.modelAbi.bindings\").map((item, index) => binding(item, `GpuInterfaceManifest.modelAbi.bindings[${index}]`, false));\n for (const [index, projected] of modelBindings.entries()) { const source = projected.source as UnknownRecord; const reflectedIndex = bindingKeys.indexOf(`${source.moduleId}:${source.group}:${source.binding}`); const reflected = reflectedIndex < 0 ? null : object(bindingValues[reflectedIndex], `GpuInterfaceManifest.bindings[${reflectedIndex}]`); if (!reflected || canonicalizeForValidation(reflected.resource) !== canonicalizeForValidation(projected.resource)) throw new TypeError(`GpuInterfaceManifest.modelAbi.bindings[${index}] differs from its reflected source.`); const resource = projected.resource as GpuBindingResourceLayout; if (resource.kind === \"buffer\" && resource.recordName === null) throw new TypeError(`GpuInterfaceManifest.modelAbi.bindings[${index}] must use a named WGSL record root.`); }\n const modelBindingSemantics = modelBindings.filter((item) => item.semantic !== null).map((item) => String(item.semantic)); unique(modelBindingSemantics, String, \"GpuInterfaceManifest.modelAbi.bindings semantics\");\n const modelVertices = array(model.vertexInputs, \"GpuInterfaceManifest.modelAbi.vertexInputs\"); const parsedModelVertices = modelVertices.map((item, index) => vertexInput(item, `GpuInterfaceManifest.modelAbi.vertexInputs[${index}]`, true)); const modelVertexSemantics = parsedModelVertices.map((item) => String(item.semantic)); unique(modelVertexSemantics, String, \"GpuInterfaceManifest.modelAbi.vertexInputs\");\n for (const [index, projected] of parsedModelVertices.entries()) { const source = projected.source as UnknownRecord; const reflected = parsedVertices.find((candidate) => candidate.pipelineId === source.pipelineId && candidate.shaderLocation === source.shaderLocation); if (!reflected || [\"format\", \"offset\", \"arrayStride\", \"stepMode\", \"semantic\"].some((key) => reflected[key] !== projected[key])) throw new TypeError(`GpuInterfaceManifest.modelAbi.vertexInputs[${index}] differs from its reflected source.`); }\n const semantics = array(model.semantics, \"GpuInterfaceManifest.modelAbi.semantics\").map((item, index) => semantic(item, `GpuInterfaceManifest.modelAbi.semantics[${index}]`)); unique(semantics, (item) => String(item.semantic), \"GpuInterfaceManifest.modelAbi.semantics\");\n for (const projection of semantics) {\n const source = projection.source as UnknownRecord; const semanticName = String(projection.semantic);\n if (source.kind === \"record-member\") {\n let current = records.get(String(source.recordName)); if (!current) throw new TypeError(`Semantic ${semanticName} references missing record.`);\n for (const [index, memberName] of (source.memberPath as string[]).entries()) { const member = current.members.find((candidate) => candidate.name === memberName); if (!member) throw new TypeError(`Semantic ${semanticName} references missing member ${memberName}.`); if (index < (source.memberPath as string[]).length - 1) { if (member.type.kind !== \"record\") throw new TypeError(`Semantic ${semanticName} traverses a non-record member.`); current = records.get(member.type.recordName); if (!current) throw new TypeError(`Semantic ${semanticName} references missing nested record.`); } }\n } else if (source.kind === \"vertex-attribute\") {\n const vertex = parsedVertices.find((candidate) => candidate.pipelineId === source.pipelineId && candidate.shaderLocation === source.shaderLocation);\n const modelVertex = parsedModelVertices.find((candidate) => candidate.semantic === semanticName);\n const modelVertexSource = modelVertex?.source as UnknownRecord | undefined;\n if (!vertex || vertex.semantic !== semanticName || modelVertexSemantics.filter((item) => item === semanticName).length !== 1\n || !modelVertexSource || modelVertexSource.pipelineId !== source.pipelineId || modelVertexSource.shaderLocation !== source.shaderLocation) throw new TypeError(`Semantic ${semanticName} does not resolve to exactly one matching model vertex stream.`);\n } else {\n const key = `${source.moduleId}:${source.group}:${source.binding}`; if (!bindingSet.has(key)) throw new TypeError(`Semantic ${semanticName} references missing binding ${key}.`);\n const modelBinding = modelBindings.find((candidate) => candidate.semantic === semanticName);\n if (modelBindingSemantics.filter((item) => item === semanticName).length !== 1 || !modelBinding\n || canonicalizeForValidation(modelBinding.source) !== canonicalizeForValidation({ moduleId: source.moduleId, group: source.group, binding: source.binding })) throw new TypeError(`Semantic ${semanticName} does not resolve to exactly one matching model binding.`);\n }\n }\n for (const semanticName of [...modelVertexSemantics, ...modelBindingSemantics]) if (semantics.filter((item) => item.semantic === semanticName).length !== 1) throw new TypeError(`Model semantic ${semanticName} requires exactly one projection.`);\n digest(input.modelAbiHash, \"GpuInterfaceManifest.modelAbiHash\"); digest(input.interfaceAbiHash, \"GpuInterfaceManifest.interfaceAbiHash\");\n const generated = object(input.generatedBy, \"GpuInterfaceManifest.generatedBy\"); exact(generated, [\"packageVersion\", \"reflector\", \"reflectorVersion\"], \"GpuInterfaceManifest.generatedBy\"); token(generated.packageVersion, \"GpuInterfaceManifest.generatedBy.packageVersion\"); if (generated.reflector !== \"wgsl_reflect\" || generated.reflectorVersion !== \"1.5.0\") throw new TypeError(\"Unsupported reflector provenance.\");\n return freeze(input as unknown as GpuInterfaceManifest);\n}\n\n/** Strictly parses an immutable shader-version manifest. */\nexport function parseShaderVersionManifest(value: unknown): ShaderVersionManifest {\n const input = object(detachedJson(value, \"ShaderVersionManifest\"), \"ShaderVersionManifest\"); exact(input, [\"contractVersion\", \"shaderId\", \"version\", \"modules\", \"gpuInterface\", \"pipelines\", \"renderRoles\", \"compatibleModelInterfaces\", \"requirements\", \"shaderAbiHash\", \"validationEvidence\", \"additionalValidationEvidence\"], \"ShaderVersionManifest\");\n if (input.contractVersion !== SHADER_VERSION_MANIFEST_VERSION) throw new TypeError(\"Unsupported shader manifest contract version.\");\n token(input.shaderId, \"ShaderVersionManifest.shaderId\"); immutableVersion(input.version, \"ShaderVersionManifest.version\");\n const moduleValues = array(input.modules, \"ShaderVersionManifest.modules\"); if (moduleValues.length === 0) throw new TypeError(\"ShaderVersionManifest.modules must not be empty.\"); const moduleIds = moduleValues.map((item, index) => { const path = `ShaderVersionManifest.modules[${index}]`; const module = object(item, path); exact(module, [\"moduleId\", \"uri\", \"byteLength\", \"sha256\", \"contentType\"], path); uri(module.uri, `${path}.uri`); integer(module.byteLength, `${path}.byteLength`, 1); digest(module.sha256, `${path}.sha256`); if (module.contentType !== \"text/wgsl; charset=utf-8\") throw new TypeError(`${path}.contentType is not canonical WGSL.`); return token(module.moduleId, `${path}.moduleId`); }); unique(moduleIds, String, \"ShaderVersionManifest.modules\"); const moduleSet = new Set(moduleIds);\n const shaderInterface = interfaceRef(input.gpuInterface, \"ShaderVersionManifest.gpuInterface\");\n const pipelines = array(input.pipelines, \"ShaderVersionManifest.pipelines\").map((item, index) => pipeline(item, `ShaderVersionManifest.pipelines[${index}]`, moduleSet)); if (pipelines.length === 0) throw new TypeError(\"ShaderVersionManifest.pipelines must not be empty.\"); unique(pipelines, (item) => item.pipelineId, \"ShaderVersionManifest.pipelines\"); const pipelineIds = new Set(pipelines.map((item) => item.pipelineId));\n const roleValues = array(input.renderRoles, \"ShaderVersionManifest.renderRoles\", 5); if (roleValues.length === 0) throw new TypeError(\"ShaderVersionManifest.renderRoles must not be empty.\"); const roleNames: string[] = []; const assigned = new Set<string>(); roleValues.forEach((item, index) => { const path = `ShaderVersionManifest.renderRoles[${index}]`; const role = object(item, path); exact(role, [\"role\", \"pipelineIds\"], path); roleNames.push(enumeration(role.role, roles, `${path}.role`)); const ids = tokenArray(role.pipelineIds, `${path}.pipelineIds`); if (ids.length === 0) throw new TypeError(`${path}.pipelineIds must not be empty.`); ids.forEach((id) => { if (!pipelineIds.has(id)) throw new TypeError(`${path} references missing pipeline ${id}.`); assigned.add(id); }); }); unique(roleNames, String, \"ShaderVersionManifest.renderRoles\"); if (assigned.size !== pipelineIds.size) throw new TypeError(\"Every pipeline must belong to at least one render role.\");\n const compatible = array(input.compatibleModelInterfaces, \"ShaderVersionManifest.compatibleModelInterfaces\").map((item, index) => compatibleModel(item, `ShaderVersionManifest.compatibleModelInterfaces[${index}]`)); if (compatible.length === 0) throw new TypeError(\"ShaderVersionManifest.compatibleModelInterfaces must not be empty.\"); unique(compatible, (item) => `${item.interfaceId}:${item.interfaceVersion}:${item.manifestSha256}:${item.interfaceAbiHash}:${item.modelAbiHash}`, \"ShaderVersionManifest.compatibleModelInterfaces\"); if (compatible.some((item) => item.modelAbiHash !== shaderInterface.modelAbiHash)) throw new TypeError(\"ShaderVersionManifest compatible model ABI hashes must equal gpuInterface.modelAbiHash.\");\n const requirements = object(input.requirements, \"ShaderVersionManifest.requirements\"); exact(requirements, [\"semantics\", \"features\", \"limits\", \"formats\"], \"ShaderVersionManifest.requirements\"); tokenArray(requirements.semantics, \"ShaderVersionManifest.requirements.semantics\"); tokenArray(requirements.features, \"ShaderVersionManifest.requirements.features\"); tokenArray(requirements.formats, \"ShaderVersionManifest.requirements.formats\"); const limits = array(requirements.limits, \"ShaderVersionManifest.requirements.limits\"); const limitNames: string[] = []; limits.forEach((item, index) => { const path = `ShaderVersionManifest.requirements.limits[${index}]`; const limit = object(item, path); exact(limit, [\"name\", \"comparator\", \"value\"], path); const name = token(limit.name, `${path}.name`); limitNames.push(name); enumeration(limit.comparator, [\"at-least\", \"at-most\"] as const, `${path}.comparator`); const value = finite(limit.value, `${path}.value`); if (!Number.isSafeInteger(value) || value < 0) throw new TypeError(`${path}.value must be a non-negative safe integer.`); }); unique(limitNames, String, \"ShaderVersionManifest.requirements.limits\");\n validatePipelineDerivedRequirements({\n requirements: input.requirements as unknown as ShaderVersionManifest[\"requirements\"],\n pipelines,\n });\n digest(input.shaderAbiHash, \"ShaderVersionManifest.shaderAbiHash\");\n const universalEvidence = validationEvidenceRef(input.validationEvidence, \"ShaderVersionManifest.validationEvidence\");\n if (!SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n universalEvidence.matrixId === policy.matrixId\n && universalEvidence.matrixVersion === policy.matrixVersion\n && universalEvidence.matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(\"ShaderVersionManifest.validationEvidence is not bound to a supported universal stable-WebGPU matrix policy.\");\n }\n const additionalEvidence = array(input.additionalValidationEvidence, \"ShaderVersionManifest.additionalValidationEvidence\");\n const scopedEvidence = additionalEvidence.map((item, index) => {\n const path = `ShaderVersionManifest.additionalValidationEvidence[${index}]`;\n const scoped = object(item, path);\n exact(scoped, [\"scope\", \"evidence\"], path);\n const scope = token(scoped.scope, `${path}.scope`);\n if (scope === \"universal\") throw new TypeError(`${path}.scope universal is reserved for validationEvidence.`);\n const evidence = validationEvidenceRef(scoped.evidence, `${path}.evidence`);\n if (evidence.matrixSha256 === universalEvidence.matrixSha256) {\n throw new TypeError(`${path}.evidence must use an additive matrix policy, not the universal matrix policy.`);\n }\n return { scope, evidence };\n });\n unique(scopedEvidence, (item) => item.scope, \"ShaderVersionManifest.additionalValidationEvidence scopes\");\n unique(scopedEvidence, (item) => String(item.evidence.matrixSha256), \"ShaderVersionManifest.additionalValidationEvidence matrix policies\");\n const evidenceIds = new Set([String(universalEvidence.evidenceId)]);\n const artifactUris = new Set([\n String(universalEvidence.uri),\n String((universalEvidence.attestationRef as UnknownRecord).uri),\n ]);\n const artifactDigests = new Set([\n String(universalEvidence.sha256),\n String((universalEvidence.attestationRef as UnknownRecord).sha256),\n ]);\n for (const [index, item] of scopedEvidence.entries()) {\n const path = `ShaderVersionManifest.additionalValidationEvidence[${index}].evidence`;\n if (evidenceIds.has(String(item.evidence.evidenceId))) throw new TypeError(`${path} reuses a universal or supplemental evidence ID.`);\n evidenceIds.add(String(item.evidence.evidenceId));\n const attestation = item.evidence.attestationRef as UnknownRecord;\n for (const candidate of [item.evidence.uri, attestation.uri]) {\n if (artifactUris.has(String(candidate))) throw new TypeError(`${path} reuses a universal or supplemental evidence/attestation URI.`);\n artifactUris.add(String(candidate));\n }\n for (const candidate of [item.evidence.sha256, attestation.sha256]) {\n if (artifactDigests.has(String(candidate))) throw new TypeError(`${path} reuses a universal or supplemental evidence/attestation digest.`);\n artifactDigests.add(String(candidate));\n }\n }\n for (const [index, item] of scopedEvidence.entries()) if (!SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n item.scope === policy.scope\n && item.evidence.matrixId === policy.matrixId\n && item.evidence.matrixVersion === policy.matrixVersion\n && item.evidence.matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(`ShaderVersionManifest.additionalValidationEvidence[${index}].evidence is not bound to a supported additive WebGPU matrix policy.`);\n }\n return freeze(input as unknown as ShaderVersionManifest);\n}\n\n/** Strictly parses the cycle-free shader manifest qualified before evidence attachment. */\nexport function parseShaderVersionManifestCore(value: unknown): ShaderVersionManifestCore {\n const input = object(detachedJson(value, \"ShaderVersionManifestCore\"), \"ShaderVersionManifestCore\");\n if (\"validationEvidence\" in input || \"additionalValidationEvidence\" in input) {\n throw new TypeError(\"ShaderVersionManifestCore must not contain validationEvidence or additionalValidationEvidence.\");\n }\n const parsed = parseShaderVersionManifest({\n ...input,\n validationEvidence: {\n evidenceId: \"pending\",\n uri: \"https://catalog.invalid/evidence/pending.json\",\n sha256: \"0\".repeat(64),\n matrixId: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixId,\n matrixVersion: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixVersion,\n matrixSha256: SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0].matrixSha256,\n attestationRef: {\n uri: \"https://catalog.invalid/evidence/pending.attestation-ref.json\",\n sha256: \"1\".repeat(64),\n },\n },\n additionalValidationEvidence: [],\n });\n const { validationEvidence, additionalValidationEvidence, ...core } = parsed;\n void validationEvidence;\n void additionalValidationEvidence;\n return freeze(core);\n}\n\n/** Strictly parses a rendering-style profile with exact immutable shader references. */\nexport function parseShaderStyleProfileManifest(value: unknown): ShaderStyleProfileManifest {\n const input = object(detachedJson(value, \"ShaderStyleProfileManifest\"), \"ShaderStyleProfileManifest\"); exact(input, [\"contractVersion\", \"profileId\", \"version\", \"style\", \"roles\", \"compatibleModelInterfaces\", \"requiredSemantics\", \"requiredValidationScopes\"], \"ShaderStyleProfileManifest\");\n if (input.contractVersion !== SHADER_STYLE_PROFILE_MANIFEST_VERSION) throw new TypeError(\"Unsupported style-profile contract version.\");\n token(input.profileId, \"ShaderStyleProfileManifest.profileId\"); immutableVersion(input.version, \"ShaderStyleProfileManifest.version\"); token(input.style, \"ShaderStyleProfileManifest.style\");\n const roleValues = array(input.roles, \"ShaderStyleProfileManifest.roles\", 5); if (roleValues.length === 0) throw new TypeError(\"ShaderStyleProfileManifest.roles must not be empty.\"); const roleNames: string[] = []; roleValues.forEach((item, index) => { const path = `ShaderStyleProfileManifest.roles[${index}]`; const role = object(item, path); exact(role, [\"role\", \"shader\"], path); roleNames.push(enumeration(role.role, roles, `${path}.role`)); const shader = object(role.shader, `${path}.shader`); exact(shader, [\"shaderId\", \"version\", \"manifestUri\", \"manifestSha256\"], `${path}.shader`); token(shader.shaderId, `${path}.shader.shaderId`); immutableVersion(shader.version, `${path}.shader.version`); uri(shader.manifestUri, `${path}.shader.manifestUri`); digest(shader.manifestSha256, `${path}.shader.manifestSha256`); }); unique(roleNames, String, \"ShaderStyleProfileManifest.roles\");\n const compatible = array(input.compatibleModelInterfaces, \"ShaderStyleProfileManifest.compatibleModelInterfaces\").map((item, index) => compatibleModel(item, `ShaderStyleProfileManifest.compatibleModelInterfaces[${index}]`)); if (compatible.length === 0) throw new TypeError(\"ShaderStyleProfileManifest.compatibleModelInterfaces must not be empty.\"); unique(compatible, (item) => `${item.interfaceId}:${item.interfaceVersion}:${item.manifestSha256}:${item.interfaceAbiHash}:${item.modelAbiHash}`, \"ShaderStyleProfileManifest.compatibleModelInterfaces\"); tokenArray(input.requiredSemantics, \"ShaderStyleProfileManifest.requiredSemantics\");\n const requiredValidationScopes = array(input.requiredValidationScopes, \"ShaderStyleProfileManifest.requiredValidationScopes\").map((item, index) => {\n const path = `ShaderStyleProfileManifest.requiredValidationScopes[${index}]`;\n const requirement = object(item, path);\n exact(requirement, [\"scope\", \"matrixId\", \"matrixVersion\", \"matrixSha256\"], path);\n const scope = token(requirement.scope, `${path}.scope`);\n if (scope === \"universal\") throw new TypeError(`${path}.scope must not use the reserved universal scope.`);\n token(requirement.matrixId, `${path}.matrixId`);\n immutableVersion(requirement.matrixVersion, `${path}.matrixVersion`);\n const matrixSha256 = digest(requirement.matrixSha256, `${path}.matrixSha256`);\n if (SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) => policy.matrixSha256 === matrixSha256)) {\n throw new TypeError(`${path} must require an additive matrix policy, not the universal matrix policy.`);\n }\n if (!SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES.some((policy) =>\n scope === policy.scope\n && requirement.matrixId === policy.matrixId\n && requirement.matrixVersion === policy.matrixVersion\n && matrixSha256 === policy.matrixSha256)) {\n throw new TypeError(`${path} is not a supported additive WebGPU matrix policy.`);\n }\n return requirement;\n });\n unique(requiredValidationScopes, (item) => String(item.scope), \"ShaderStyleProfileManifest.requiredValidationScopes scopes\");\n unique(requiredValidationScopes, (item) => String(item.matrixSha256), \"ShaderStyleProfileManifest.requiredValidationScopes matrix policies\");\n return freeze(input as unknown as ShaderStyleProfileManifest);\n}\n\n/** Strictly parses the model-facing GPU compatibility fields published with a model version. */\nexport function parseModelGpuCompatibilityDescriptor(value: unknown): ModelGpuCompatibilityDescriptor {\n const input = object(detachedJson(value, \"ModelGpuCompatibilityDescriptor\"), \"ModelGpuCompatibilityDescriptor\");\n exact(input, [\"modelId\", \"version\", \"gpuInterface\", \"modelAbiHash\", \"providedSemantics\", \"defaultStyleProfile\"], \"ModelGpuCompatibilityDescriptor\");\n token(input.modelId, \"ModelGpuCompatibilityDescriptor.modelId\");\n immutableVersion(input.version, \"ModelGpuCompatibilityDescriptor.version\");\n const gpuInterface = interfaceRef(input.gpuInterface, \"ModelGpuCompatibilityDescriptor.gpuInterface\");\n const modelAbiHash = digest(input.modelAbiHash, \"ModelGpuCompatibilityDescriptor.modelAbiHash\");\n if (gpuInterface.modelAbiHash !== modelAbiHash) throw new TypeError(\"ModelGpuCompatibilityDescriptor.gpuInterface.modelAbiHash differs from modelAbiHash.\");\n tokenArray(input.providedSemantics, \"ModelGpuCompatibilityDescriptor.providedSemantics\");\n if (input.defaultStyleProfile !== null) { const profile = object(input.defaultStyleProfile, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile\"); exact(profile, [\"profileId\", \"version\", \"manifestUri\", \"manifestSha256\"], \"ModelGpuCompatibilityDescriptor.defaultStyleProfile\"); token(profile.profileId, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.profileId\"); immutableVersion(profile.version, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.version\"); uri(profile.manifestUri, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestUri\"); digest(profile.manifestSha256, \"ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestSha256\"); }\n return freeze(input as unknown as ModelGpuCompatibilityDescriptor);\n}\n\n/** Strictly parses a qualification fixture that binds one immutable model descriptor. */\nexport function parseShaderQualificationModelCompatibilityFixture(value: unknown): ShaderQualificationModelCompatibilityFixture {\n const input = object(\n detachedJson(value, \"ShaderQualificationModelCompatibilityFixture\"),\n \"ShaderQualificationModelCompatibilityFixture\",\n );\n exact(input, [\"contractVersion\", \"fixtureId\", \"model\"], \"ShaderQualificationModelCompatibilityFixture\");\n if (input.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError(\"Unsupported model compatibility fixture version.\");\n token(input.fixtureId, \"ShaderQualificationModelCompatibilityFixture.fixtureId\");\n parseModelGpuCompatibilityDescriptor(input.model);\n return freeze(input as unknown as ShaderQualificationModelCompatibilityFixture);\n}\n\nexport function parseJsonBytes(bytes: Uint8Array, label: string): unknown {\n try { return JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes)); }\n catch (cause) { throw new TypeError(`${label} is not valid UTF-8 JSON.`, { cause }); }\n}\n","import {\n SHADER_COMPILE_UNIT_VERSION,\n type ShaderCompileUnitInventory,\n type ShaderCompileUnitManifest,\n type ShaderDiagnostic,\n type ShaderQualificationBundleManifest,\n type ShaderResult,\n} from \"../contracts.js\";\nimport { canonicalizeGpuContract } from \"../canonical-json.js\";\nimport { assertImmutableAssetVersion } from \"../asset-version.js\";\nimport { asSha256Hex } from \"../hash.js\";\nimport { parseSerializableGpuPipelineDescriptors } from \"../manifest-validation.js\";\n\nconst SAFE_PATH = /^(?!\\/)(?!.*\\/\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[A-Za-z0-9._-]+(?:\\/[A-Za-z0-9._-]+)*$/u;\n\nfunction issue(code: ShaderDiagnostic[\"code\"], message: string, path?: string): ShaderDiagnostic {\n return { code, severity: \"error\", message, ...(path ? { path } : {}) };\n}\n\nfunction object(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction freezeJson<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n for (const child of Object.values(value as Record<string, unknown>)) freezeJson(child);\n return Object.freeze(value);\n}\n\nfunction exactKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n const expected = new Set(keys);\n return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => key in value);\n}\n\nfunction safeToken(value: unknown): value is string {\n return typeof value === \"string\" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes(\"..\");\n}\n\nfunction immutableVersion(value: unknown): boolean {\n try {\n assertImmutableAssetVersion(value);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction validSha(value: unknown): boolean {\n try {\n asSha256Hex(String(value));\n return true;\n } catch {\n return false;\n }\n}\n\n/** Identity helper that makes compile-unit declarations readonly at the call site. */\nexport function defineShaderCompileUnit<const T extends ShaderCompileUnitManifest>(unit: T): T {\n return Object.freeze(unit);\n}\n\n/** Validates that every declared WGSL fragment belongs to at least one concrete compile unit. */\nexport function validateCompileUnitInventory(\n value: unknown,\n): ShaderResult<ShaderCompileUnitInventory> {\n let snapshot: unknown;\n try {\n snapshot = JSON.parse(canonicalizeGpuContract(value)) as unknown;\n } catch (cause) {\n return {\n ok: false,\n diagnostics: [issue(\n \"invalid-contract\",\n cause instanceof Error ? cause.message : \"Compile-unit inventory must contain detached JSON data.\",\n )],\n };\n }\n const envelope = object(snapshot);\n const candidate = envelope && Object.hasOwn(envelope, \"inventory\")\n ? object((snapshot as Partial<ShaderQualificationBundleManifest>).inventory)\n : envelope;\n const diagnostics: ShaderDiagnostic[] = [];\n if (!candidate || !exactKeys(candidate, [\"contractVersion\", \"fragments\", \"compileUnits\"])) {\n return { ok: false, diagnostics: [issue(\"invalid-contract\", \"Compile-unit inventory has unknown or missing fields.\")] };\n }\n if (candidate.contractVersion !== SHADER_COMPILE_UNIT_VERSION) {\n diagnostics.push(issue(\"invalid-contract\", \"Unsupported compile-unit inventory version.\", \"contractVersion\"));\n }\n if (!Array.isArray(candidate.fragments) || !Array.isArray(candidate.compileUnits)) {\n diagnostics.push(issue(\"invalid-contract\", \"Inventory fragments and compileUnits must be arrays.\"));\n return { ok: false, diagnostics };\n }\n if (candidate.fragments.length > 10000 || candidate.compileUnits.length > 10000) {\n diagnostics.push(issue(\"invalid-contract\", \"Inventory exceeds the bounded item count.\"));\n return { ok: false, diagnostics };\n }\n const fragmentIds = new Set<string>();\n for (const [index, raw] of candidate.fragments.entries()) {\n const path = `fragments[${index}]`;\n const fragment = object(raw);\n if (!fragment || !exactKeys(fragment, [\"fragmentId\", \"path\", \"sha256\"])) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment has unknown or missing fields.\", path));\n continue;\n }\n if (!safeToken(fragment.fragmentId) || fragmentIds.has(fragment.fragmentId)) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment IDs must be unique safe tokens.\", `${path}.fragmentId`));\n } else fragmentIds.add(fragment.fragmentId);\n if (typeof fragment.path !== \"string\" || !SAFE_PATH.test(fragment.path) || !fragment.path.endsWith(\".wgsl\")) {\n diagnostics.push(issue(\"invalid-contract\", \"Fragment path must remain inside the data-only bundle.\", `${path}.path`));\n }\n if (!validSha(fragment.sha256)) diagnostics.push(issue(\"invalid-contract\", \"Fragment digest is invalid.\", `${path}.sha256`));\n }\n const covered = new Set<string>();\n const unitIds = new Set<string>();\n for (const [index, raw] of candidate.compileUnits.entries()) {\n const path = `compileUnits[${index}]`;\n const unit = object(raw);\n const keys = [\n \"contractVersion\", \"compileUnitId\", \"fragmentIds\", \"modules\", \"entryPoints\", \"pipelines\", \"interfaceRef\",\n \"overrideValues\", \"qualificationFixture\",\n ];\n if (!unit || !exactKeys(unit, keys)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit has unknown or missing fields.\", path));\n continue;\n }\n if (unit.contractVersion !== SHADER_COMPILE_UNIT_VERSION || !safeToken(unit.compileUnitId) || unitIds.has(String(unit.compileUnitId))) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit identity/version is invalid or duplicated.\", path));\n } else unitIds.add(unit.compileUnitId);\n if (!Array.isArray(unit.fragmentIds) || unit.fragmentIds.length === 0 || new Set(unit.fragmentIds).size !== unit.fragmentIds.length) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires unique fragment IDs.\", `${path}.fragmentIds`));\n } else {\n for (const id of unit.fragmentIds) {\n if (typeof id !== \"string\" || !fragmentIds.has(id)) diagnostics.push(issue(\"invalid-contract\", `Compile unit references unknown fragment ${String(id)}.`, `${path}.fragmentIds`));\n else covered.add(id);\n }\n }\n if (!Array.isArray(unit.modules) || unit.modules.length === 0 || !Array.isArray(unit.entryPoints) || unit.entryPoints.length === 0 || !Array.isArray(unit.pipelines) || unit.pipelines.length === 0) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires modules, entry points, and explicit pipelines.\", path));\n }\n const modules = Array.isArray(unit.modules) ? unit.modules : [];\n const moduleIds = new Set<string>();\n for (const [moduleIndex, moduleRaw] of modules.entries()) {\n const module = object(moduleRaw);\n if (!module || !exactKeys(module, [\"moduleId\", \"sha256\", \"assembly\"]) || !safeToken(module.moduleId) || moduleIds.has(String(module.moduleId)) || !validSha(module.sha256)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit module reference is invalid or duplicated.\", `${path}.modules[${moduleIndex}]`));\n } else {\n moduleIds.add(module.moduleId);\n const assembly = object(module.assembly);\n if (!assembly || !exactKeys(assembly, [\"kind\", \"fragmentIds\"]) || assembly.kind !== \"concat-v1\" || !Array.isArray(assembly.fragmentIds) || assembly.fragmentIds.length === 0 || new Set(assembly.fragmentIds).size !== assembly.fragmentIds.length || assembly.fragmentIds.some((id) => typeof id !== \"string\" || !fragmentIds.has(id))) {\n diagnostics.push(issue(\"invalid-contract\", \"Module requires a non-vacuous concat-v1 recipe over exact inventory fragments.\", `${path}.modules[${moduleIndex}].assembly`));\n }\n }\n }\n const recipeFragments = new Set(modules.flatMap((moduleRaw) => {\n const module = object(moduleRaw); const assembly = module ? object(module.assembly) : null;\n return Array.isArray(assembly?.fragmentIds) ? assembly.fragmentIds.filter((id): id is string => typeof id === \"string\") : [];\n }));\n if (Array.isArray(unit.fragmentIds) && ([...recipeFragments].sort().join(\"\\n\") !== [...unit.fragmentIds].sort().join(\"\\n\"))) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit fragment claims must exactly equal deterministic assembly inputs.\", `${path}.fragmentIds`));\n }\n const entryKeys = new Set<string>();\n if (Array.isArray(unit.entryPoints)) for (const [entryIndex, entryRaw] of unit.entryPoints.entries()) {\n const entry = object(entryRaw); const entryPath = `${path}.entryPoints[${entryIndex}]`;\n if (!entry || !exactKeys(entry, [\"moduleId\", \"name\", \"stage\"]) || !safeToken(entry.moduleId) || !moduleIds.has(String(entry.moduleId)) || !safeToken(entry.name) || ![\"vertex\", \"fragment\", \"compute\"].includes(String(entry.stage))) diagnostics.push(issue(\"invalid-contract\", \"Compile-unit entry point is invalid.\", entryPath));\n else { const key = `${entry.moduleId}:${entry.stage}:${entry.name}`; if (entryKeys.has(key)) diagnostics.push(issue(\"invalid-contract\", \"Compile-unit entry point is duplicated.\", entryPath)); entryKeys.add(key); }\n }\n try {\n const pipelines = parseSerializableGpuPipelineDescriptors(unit.pipelines, [...moduleIds], `${path}.pipelines`);\n const usedEntries = new Set<string>();\n for (const pipeline of pipelines) {\n if (pipeline.kind === \"compute\") usedEntries.add(`${pipeline.compute.moduleId}:compute:${pipeline.compute.entryPoint}`);\n else { usedEntries.add(`${pipeline.vertex.moduleId}:vertex:${pipeline.vertex.entryPoint}`); if (pipeline.fragment) usedEntries.add(`${pipeline.fragment.moduleId}:fragment:${pipeline.fragment.entryPoint}`); }\n }\n for (const key of usedEntries) if (!entryKeys.has(key)) diagnostics.push(issue(\"invalid-contract\", `Pipeline references undeclared compile-unit entry point ${key}.`, `${path}.pipelines`));\n for (const key of entryKeys) if (!usedEntries.has(key)) diagnostics.push(issue(\"invalid-contract\", `Compile-unit entry point ${key} is not used by a pipeline.`, `${path}.entryPoints`));\n const overrideValues = object(unit.overrideValues);\n if (!overrideValues) diagnostics.push(issue(\"invalid-contract\", \"overrideValues must be an object.\", `${path}.overrideValues`));\n else {\n for (const [name, value] of Object.entries(overrideValues)) if (!safeToken(name) || (typeof value !== \"boolean\" && (typeof value !== \"number\" || !Number.isFinite(value)))) diagnostics.push(issue(\"invalid-contract\", `Override value ${name} is invalid.`, `${path}.overrideValues`));\n const derived = new Map<string, boolean | number>();\n for (const descriptor of pipelines) {\n const stages = descriptor.kind === \"compute\" ? [descriptor.compute] : [descriptor.vertex, ...(descriptor.fragment ? [descriptor.fragment] : [])];\n for (const stage of stages) for (const [name, constant] of Object.entries(stage.constants)) {\n const previous = derived.get(name); if (previous !== undefined && !Object.is(previous, constant)) diagnostics.push(issue(\"invalid-contract\", `Override ${name} has conflicting stage values.`, `${path}.pipelines`)); else derived.set(name, constant);\n }\n }\n const exactOverrides = Object.fromEntries([...derived.entries()].sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));\n if (canonicalizeGpuContract(overrideValues) !== canonicalizeGpuContract(exactOverrides)) diagnostics.push(issue(\"invalid-contract\", \"overrideValues must exactly equal the union of programmable-stage constants.\", `${path}.overrideValues`));\n }\n } catch (cause) {\n diagnostics.push(issue(\"invalid-contract\", cause instanceof Error ? cause.message : \"Compile-unit pipelines are invalid.\", `${path}.pipelines`));\n }\n const interfaceRef = object(unit.interfaceRef);\n if (!interfaceRef || !exactKeys(interfaceRef, [\"interfaceId\", \"interfaceVersion\", \"manifestUri\", \"manifestSha256\", \"interfaceAbiHash\", \"modelAbiHash\"]) || !safeToken(interfaceRef.interfaceId) || !immutableVersion(interfaceRef.interfaceVersion) || typeof interfaceRef.manifestUri !== \"string\" || !interfaceRef.manifestUri.startsWith(\"https://\") || !validSha(interfaceRef.manifestSha256) || !validSha(interfaceRef.interfaceAbiHash) || !validSha(interfaceRef.modelAbiHash)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile-unit interfaceRef is invalid.\", `${path}.interfaceRef`));\n }\n const fixture = object(unit.qualificationFixture);\n if (!fixture || !exactKeys(fixture, [\"fixtureId\", \"path\", \"sha256\"]) || !safeToken(fixture.fixtureId) || typeof fixture.path !== \"string\" || !SAFE_PATH.test(fixture.path) || !fixture.path.endsWith(\".json\") || !validSha(fixture.sha256)) {\n diagnostics.push(issue(\"invalid-contract\", \"Compile unit requires an exact declarative qualification fixture.\", `${path}.qualificationFixture`));\n }\n }\n for (const fragmentId of fragmentIds) {\n if (!covered.has(fragmentId)) diagnostics.push(issue(\"uncovered-fragment\", `WGSL fragment ${fragmentId} has no compile unit.`));\n }\n return diagnostics.length > 0\n ? { ok: false, diagnostics }\n : { ok: true, value: freezeJson(candidate as unknown as ShaderCompileUnitInventory) };\n}\n","import {\n STABLE_WEBGPU_MATRIX_VERSION,\n SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES,\n type ShaderDiagnostic,\n type ShaderResult,\n type StableWebGpuMatrixManifest,\n} from \"../contracts.js\";\nimport { canonicalizeGpuContract } from \"../canonical-json.js\";\n\nfunction issue(message: string, path?: string): ShaderDiagnostic {\n return { code: \"invalid-contract\", severity: \"error\", message, ...(path ? { path } : {}) };\n}\n\nfunction object(value: unknown): Record<string, unknown> | null {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : null;\n}\n\nfunction keys(value: Record<string, unknown>, expected: readonly string[]): boolean {\n const set = new Set(expected);\n return Object.keys(value).every((key) => set.has(key)) && expected.every((key) => key in value);\n}\n\nfunction canonicalEqual(left: unknown, right: unknown): boolean {\n try {\n return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);\n } catch {\n return false;\n }\n}\n\nconst browserNames = new Set([\"chromium\", \"chrome\", \"edge\", \"firefox\", \"safari\"]);\nconst osNames = new Set([\"ubuntu\", \"windows\", \"macos\", \"chromeos\", \"android\", \"ios\", \"ipados\", \"visionos\"]);\nconst backends = new Set([\"swiftshader\", \"d3d12\", \"metal\", \"vulkan\"]);\nconst automation = new Set([\"playwright\", \"webdriver\", \"device-farm\", \"safari-webdriver\"]);\n\nconst VERSION_REQUIREMENTS = new Map<string, unknown>([\n [\"android-adreno-chrome-vulkan\", { kind: \"minimum-major\", value: 12 }],\n [\"android-mali-chrome-vulkan\", { kind: \"minimum-major\", value: 12 }],\n [\"chromeos-arm-chrome-vulkan\", { kind: \"stable-channel\", channel: \"stable\" }],\n [\"chromeos-intel-chrome-vulkan\", { kind: \"stable-channel\", channel: \"stable\" }],\n [\"ios-iphone-safari-metal\", { kind: \"major\", value: 26 }],\n [\"ipados-ipad-safari-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-chrome-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-firefox-metal\", { kind: \"major\", value: 26 }],\n [\"macos-apple-safari-metal\", { kind: \"major\", value: 26 }],\n [\"swiftshader.chromium.ubuntu-x64\", { kind: \"exact\", value: \"24.04\" }],\n [\"ubuntu-intel-chrome-vulkan\", { kind: \"exact\", value: \"24.04\" }],\n [\"ubuntu-nvidia-chrome-vulkan\", { kind: \"exact\", value: \"24.04\" }],\n [\"visionos-safari-metal\", { kind: \"major\", value: 26 }],\n [\"win11-amd-firefox-d3d12\", { kind: \"major\", value: 11 }],\n [\"win11-intel-chrome-d3d12\", { kind: \"major\", value: 11 }],\n [\"win11-nvidia-edge-d3d12\", { kind: \"major\", value: 11 }],\n]);\n\nconst BASELINE = new Map<string, string>([\n [\"android-adreno-chrome-vulkan\", \"chrome|android|arm64|physical|qualcomm|adreno|vulkan|playwright|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,android-adreno,vulkan\"],\n [\"android-mali-chrome-vulkan\", \"chrome|android|arm64|physical|arm|mali|vulkan|playwright|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,android-mali,vulkan\"],\n [\"chromeos-arm-chrome-vulkan\", \"chrome|chromeos|arm64|physical|arm|qualified-arm|vulkan|webdriver|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,chromeos-arm,vulkan\"],\n [\"chromeos-intel-chrome-vulkan\", \"chrome|chromeos|x64|physical|intel|qualified-intel|vulkan|webdriver|self-hosted,Linux,X64,shader-validation,device-controller,physical-gpu,chromeos-intel,vulkan\"],\n [\"ios-iphone-safari-metal\", \"safari|ios|arm64|physical|apple|iphone|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,ios-safari,metal\"],\n [\"ipados-ipad-safari-metal\", \"safari|ipados|arm64|physical|apple|ipad|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,ipados-safari,metal\"],\n [\"macos-apple-chrome-metal\", \"chrome|macos|arm64|physical|apple|apple-silicon|metal|playwright|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"macos-apple-firefox-metal\", \"firefox|macos|arm64|physical|apple|apple-silicon|metal|webdriver|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"macos-apple-safari-metal\", \"safari|macos|arm64|physical|apple|apple-silicon|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,physical-gpu,gpu-apple,metal\"],\n [\"swiftshader.chromium.ubuntu-x64\", \"chromium|ubuntu|x64|software|google|swiftshader|swiftshader|playwright|ubuntu-24.04\"],\n [\"ubuntu-intel-chrome-vulkan\", \"chrome|ubuntu|x64|physical|intel|qualified-intel|vulkan|playwright|self-hosted,Linux,X64,shader-validation,physical-gpu,gpu-intel,vulkan\"],\n [\"ubuntu-nvidia-chrome-vulkan\", \"chrome|ubuntu|x64|physical|nvidia|qualified-nvidia|vulkan|playwright|self-hosted,Linux,X64,shader-validation,physical-gpu,gpu-nvidia,vulkan\"],\n [\"visionos-safari-metal\", \"safari|visionos|arm64|physical|apple|vision-pro|metal|safari-webdriver|self-hosted,macOS,ARM64,shader-validation,device-controller,physical-gpu,visionos-safari,metal\"],\n [\"win11-amd-firefox-d3d12\", \"firefox|windows|x64|physical|amd|qualified-amd|d3d12|webdriver|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-amd,d3d12\"],\n [\"win11-intel-chrome-d3d12\", \"chrome|windows|x64|physical|intel|qualified-intel|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-intel,d3d12\"],\n [\"win11-nvidia-edge-d3d12\", \"edge|windows|x64|physical|nvidia|qualified-nvidia|d3d12|playwright|self-hosted,Windows,X64,shader-validation,physical-gpu,gpu-nvidia,d3d12\"],\n]);\n\n/** Strictly validates the versioned 16-cell stable WebGPU support matrix. */\nexport function validateStableWebGpuMatrix(value: unknown): ShaderResult<StableWebGpuMatrixManifest> {\n const matrix = object(value);\n const diagnostics: ShaderDiagnostic[] = [];\n if (!matrix || !keys(matrix, [\"contractVersion\", \"matrixId\", \"version\", \"policy\", \"cells\"])) {\n return { ok: false, diagnostics: [issue(\"Matrix has unknown or missing top-level fields.\")] };\n }\n if (matrix.contractVersion !== STABLE_WEBGPU_MATRIX_VERSION) diagnostics.push(issue(\"Unsupported matrix contract version.\", \"contractVersion\"));\n const stablePolicy = SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES[0];\n if (matrix.matrixId !== stablePolicy?.matrixId || matrix.version !== stablePolicy.matrixVersion) diagnostics.push(issue(\"Matrix identity/version differs from the supported universal policy.\"));\n const policy = object(matrix.policy);\n const policyKeys = [\"coverage\", \"unavailable\", \"skipped\", \"timeout\", \"deviceLoss\", \"requiredPhysicalCellCount\", \"requiredBlockingCellCount\"];\n if (!policy || !keys(policy, policyKeys)\n || policy.coverage !== \"all-cells-required\"\n || policy.unavailable !== \"fail\"\n || policy.skipped !== \"fail\"\n || policy.timeout !== \"fail\"\n || policy.deviceLoss !== \"fail\"\n || policy.requiredPhysicalCellCount !== 15\n || policy.requiredBlockingCellCount !== 16) {\n diagnostics.push(issue(\"Matrix policy must fail closed with 15 physical and 16 blocking cells.\", \"policy\"));\n }\n if (!Array.isArray(matrix.cells) || matrix.cells.length !== 16) {\n diagnostics.push(issue(\"Stable WebGPU matrix must contain exactly 16 cells.\", \"cells\"));\n return { ok: false, diagnostics };\n }\n const ids = new Set<string>();\n let physical = 0;\n let blocking = 0;\n let software = 0;\n for (const [index, raw] of matrix.cells.entries()) {\n const path = `cells[${index}]`;\n const cell = object(raw);\n if (!cell || !keys(cell, [\n \"cellId\", \"runnerLabels\", \"browser\", \"os\", \"adapter\", \"automation\", \"timeoutMs\", \"blocking\", \"countsTowardStableCoverage\",\n ])) {\n diagnostics.push(issue(\"Matrix cell has unknown or missing fields.\", path));\n continue;\n }\n if (typeof cell.cellId !== \"string\" || !/^[a-z0-9][a-z0-9._-]+$/u.test(cell.cellId) || ids.has(cell.cellId)) diagnostics.push(issue(\"Cell ID is invalid or duplicated.\", `${path}.cellId`));\n else ids.add(cell.cellId);\n if (!Array.isArray(cell.runnerLabels) || cell.runnerLabels.length === 0 || cell.runnerLabels.some((label) => typeof label !== \"string\" || !label) || new Set(cell.runnerLabels).size !== cell.runnerLabels.length) diagnostics.push(issue(\"Runner labels must be unique non-empty strings.\", `${path}.runnerLabels`));\n const browser = object(cell.browser);\n const os = object(cell.os);\n const adapter = object(cell.adapter);\n const adapterAutomation = object(cell.automation);\n if (!browser || !keys(browser, [\"name\", \"channel\"]) || !browserNames.has(String(browser.name))) diagnostics.push(issue(\"Browser descriptor is invalid.\", `${path}.browser`));\n if (!os || !keys(os, [\"name\", \"versionRequirement\", \"architecture\"]) || !osNames.has(String(os.name)) || ![\"x64\", \"arm64\"].includes(String(os.architecture))) diagnostics.push(issue(\"OS descriptor is invalid.\", `${path}.os`));\n else {\n const requirement = object(os.versionRequirement); const kind = String(requirement?.kind);\n const validRequirement = requirement && (kind === \"exact\"\n ? keys(requirement, [\"kind\", \"value\"]) && typeof requirement.value === \"string\" && /^\\d+(?:\\.\\d+)*$/u.test(requirement.value)\n : kind === \"major\" || kind === \"minimum-major\"\n ? keys(requirement, [\"kind\", \"value\"]) && Number.isSafeInteger(requirement.value) && Number(requirement.value) > 0\n : kind === \"stable-channel\" && keys(requirement, [\"kind\", \"channel\"]) && requirement.channel === \"stable\");\n if (!validRequirement) diagnostics.push(issue(\"OS version requirement is invalid.\", `${path}.os.versionRequirement`));\n if (typeof cell.cellId === \"string\"\n && !canonicalEqual(requirement, VERSION_REQUIREMENTS.get(cell.cellId))) {\n diagnostics.push(issue(\"OS version requirement differs from the stable baseline.\", `${path}.os.versionRequirement`));\n }\n }\n if (!adapter || !keys(adapter, [\"kind\", \"vendor\", \"family\", \"backend\"]) || ![\"software\", \"physical\"].includes(String(adapter.kind)) || !backends.has(String(adapter.backend))) diagnostics.push(issue(\"Adapter descriptor is invalid.\", `${path}.adapter`));\n if (!adapterAutomation || !keys(adapterAutomation, [\"kind\"]) || !automation.has(String(adapterAutomation.kind))) diagnostics.push(issue(\"Automation descriptor is invalid.\", `${path}.automation`));\n const signature = `${String(browser?.name)}|${String(os?.name)}|${String(os?.architecture)}|${String(adapter?.kind)}|${String(adapter?.vendor)}|${String(adapter?.family)}|${String(adapter?.backend)}|${String(adapterAutomation?.kind)}|${Array.isArray(cell.runnerLabels) ? cell.runnerLabels.join(\",\") : \"\"}`;\n if (typeof cell.cellId === \"string\" && BASELINE.get(cell.cellId) !== signature) diagnostics.push(issue(\"Cell identity, target, automation, or runner labels differ from the stable baseline.\", path));\n if (typeof cell.cellId === \"string\" && [...BASELINE.keys()][index] !== cell.cellId) diagnostics.push(issue(\"Stable matrix cells must remain in fixed code-unit order.\", `${path}.cellId`));\n if (!Number.isSafeInteger(cell.timeoutMs) || Number(cell.timeoutMs) < 1000 || Number(cell.timeoutMs) > 3_600_000) diagnostics.push(issue(\"Cell timeout must be bounded.\", `${path}.timeoutMs`));\n if (cell.blocking !== true) diagnostics.push(issue(\"Every stable matrix cell must block delivery.\", `${path}.blocking`));\n else blocking += 1;\n if (adapter?.kind === \"physical\") {\n physical += 1;\n if (browser?.channel !== \"stable\" || cell.countsTowardStableCoverage !== true) diagnostics.push(issue(\"Physical cells must use stable browsers and count toward stable coverage.\", path));\n } else if (adapter?.kind === \"software\") {\n software += 1;\n if (adapter.backend !== \"swiftshader\" || browser?.name !== \"chromium\" || browser.channel !== \"playwright-bundled\" || cell.countsTowardStableCoverage !== false) diagnostics.push(issue(\"The sole software lane must be bundled Chromium with SwiftShader smoke coverage.\", path));\n }\n }\n if (physical !== 15 || blocking !== 16 || software !== 1 || ids.size !== BASELINE.size) diagnostics.push(issue(\"Matrix must contain the exact 15 physical baseline cells plus one SwiftShader smoke cell.\"));\n return diagnostics.length > 0\n ? { ok: false, diagnostics }\n : { ok: true, value: matrix as unknown as StableWebGpuMatrixManifest };\n}\n","import {\n SHADER_QUALIFICATION_BUNDLE_VERSION,\n SHADER_QUALIFICATION_FIXTURE_VERSION,\n type ShaderCompileUnitManifest,\n type ShaderQualificationBundleManifest,\n type ShaderQualificationFixtureManifest,\n type ShaderResult,\n} from \"../contracts.js\";\nimport { canonicalizeGpuContract } from \"../canonical-json.js\";\nimport { assertImmutableAssetVersion } from \"../asset-version.js\";\nimport { asSha256Hex } from \"../hash.js\";\nimport { validateCompileUnitInventory } from \"./inventory.js\";\n\ntype UnknownRecord = Record<string, unknown>;\ntype TextureDimension = \"1d\" | \"2d\" | \"3d\";\ntype TextureFormatAspect = \"color\" | \"depth\" | \"stencil\" | \"depth-stencil\";\n\ninterface BufferResourceInfo {\n readonly kind: \"buffer\";\n readonly byteLength: number;\n readonly usage: readonly string[];\n readonly hasInitialData: boolean;\n}\n\ninterface TextureResourceInfo {\n readonly kind: \"texture\";\n readonly usage: readonly string[];\n readonly hasInitialData: boolean;\n readonly dimension: TextureDimension;\n readonly size: readonly [number, number, number];\n readonly mipLevelCount: number;\n readonly sampleCount: number;\n readonly format: string;\n}\n\ninterface SamplerResourceInfo {\n readonly kind: \"sampler\";\n readonly usage: readonly string[];\n readonly hasInitialData: false;\n readonly descriptor: UnknownRecord;\n}\n\ntype FixtureResourceInfo = BufferResourceInfo | TextureResourceInfo | SamplerResourceInfo;\n\nconst SAFE_PATH = /^(?!\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[A-Za-z0-9._/-]+$/u;\nconst TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u;\nconst BUFFER_USAGE = new Set([\"map-read\", \"map-write\", \"copy-src\", \"copy-dst\", \"index\", \"vertex\", \"uniform\", \"storage\", \"indirect\", \"query-resolve\"]);\nconst TEXTURE_USAGE = new Set([\"copy-src\", \"copy-dst\", \"texture-binding\", \"storage-binding\", \"render-attachment\"]);\nconst UNCOMPRESSED_COLOR_BYTES = new Map<string, number>([\n [\"r8unorm\", 1], [\"r8snorm\", 1], [\"r8uint\", 1], [\"r8sint\", 1],\n [\"r16unorm\", 2], [\"r16snorm\", 2], [\"r16uint\", 2], [\"r16sint\", 2], [\"r16float\", 2],\n [\"rg8unorm\", 2], [\"rg8snorm\", 2], [\"rg8uint\", 2], [\"rg8sint\", 2],\n [\"r32uint\", 4], [\"r32sint\", 4], [\"r32float\", 4],\n [\"rg16unorm\", 4], [\"rg16snorm\", 4], [\"rg16uint\", 4], [\"rg16sint\", 4], [\"rg16float\", 4],\n [\"rgba8unorm\", 4], [\"rgba8unorm-srgb\", 4], [\"rgba8snorm\", 4], [\"rgba8uint\", 4], [\"rgba8sint\", 4],\n [\"bgra8unorm\", 4], [\"bgra8unorm-srgb\", 4], [\"rgb9e5ufloat\", 4], [\"rgb10a2uint\", 4], [\"rgb10a2unorm\", 4], [\"rg11b10ufloat\", 4],\n [\"rg32uint\", 8], [\"rg32sint\", 8], [\"rg32float\", 8],\n [\"rgba16unorm\", 8], [\"rgba16snorm\", 8], [\"rgba16uint\", 8], [\"rgba16sint\", 8], [\"rgba16float\", 8],\n [\"rgba32uint\", 16], [\"rgba32sint\", 16], [\"rgba32float\", 16],\n]);\nconst COMPRESSED_COLOR_FORMATS = new Set([\n \"bc1-rgba-unorm\", \"bc1-rgba-unorm-srgb\", \"bc2-rgba-unorm\", \"bc2-rgba-unorm-srgb\", \"bc3-rgba-unorm\", \"bc3-rgba-unorm-srgb\",\n \"bc4-r-unorm\", \"bc4-r-snorm\", \"bc5-rg-unorm\", \"bc5-rg-snorm\", \"bc6h-rgb-ufloat\", \"bc6h-rgb-float\", \"bc7-rgba-unorm\", \"bc7-rgba-unorm-srgb\",\n \"etc2-rgb8unorm\", \"etc2-rgb8unorm-srgb\", \"etc2-rgb8a1unorm\", \"etc2-rgb8a1unorm-srgb\", \"etc2-rgba8unorm\", \"etc2-rgba8unorm-srgb\",\n \"eac-r11unorm\", \"eac-r11snorm\", \"eac-rg11unorm\", \"eac-rg11snorm\",\n ...[\"4x4\", \"5x4\", \"5x5\", \"6x5\", \"6x6\", \"8x5\", \"8x6\", \"8x8\", \"10x5\", \"10x6\", \"10x8\", \"10x10\", \"12x10\", \"12x12\"]\n .flatMap((block) => [`astc-${block}-unorm`, `astc-${block}-unorm-srgb`]),\n]);\nconst DEPTH_STENCIL_FORMATS = new Map<string, TextureFormatAspect>([\n [\"stencil8\", \"stencil\"],\n [\"depth16unorm\", \"depth\"],\n [\"depth24plus\", \"depth\"],\n [\"depth24plus-stencil8\", \"depth-stencil\"],\n [\"depth32float\", \"depth\"],\n [\"depth32float-stencil8\", \"depth-stencil\"],\n]);\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction detachedJson(value: unknown, label: string): unknown {\n try {\n return JSON.parse(canonicalizeGpuContract(value)) as unknown;\n } catch (cause) {\n throw new TypeError(`${label} must contain detached JSON contract data.`, { cause });\n }\n}\n\nfunction freezeJson<T>(value: T): T {\n if (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n for (const child of Object.values(value as Record<string, unknown>)) freezeJson(child);\n return Object.freeze(value);\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const expected = new Set(keys);\n if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key in value)) throw new TypeError(`${path} has unknown or missing fields.`);\n}\n\nfunction token(value: unknown, path: string): string {\n if (typeof value !== \"string\" || !TOKEN.test(value) || value.includes(\"..\")) throw new TypeError(`${path} must be a safe token.`);\n return value;\n}\n\nfunction immutableVersion(value: unknown, path: string): string {\n try {\n return assertImmutableAssetVersion(value);\n } catch (cause) {\n throw new TypeError(\n `${path} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,\n { cause },\n );\n }\n}\n\nfunction path(value: unknown, label: string, extensions: readonly string[]): string {\n if (typeof value !== \"string\" || !SAFE_PATH.test(value) || !extensions.some((extension) => value.endsWith(extension))) {\n throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(\", \")}).`);\n }\n return value;\n}\n\nfunction sha(value: unknown, label: string): string {\n try { return asSha256Hex(String(value)); }\n catch (cause) { throw new TypeError(`${label} must be a lowercase SHA-256 digest.`, { cause }); }\n}\n\nfunction integer(value: unknown, label: string, minimum = 0, maximum = 0xffff_ffff): number {\n if (!Number.isSafeInteger(value) || Number(value) < minimum || Number(value) > maximum) throw new TypeError(`${label} is outside its integer bound.`);\n return Number(value);\n}\n\nfunction boundedArray(value: unknown, label: string, maximum = 4096): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${label} must be a bounded array.`);\n return value;\n}\n\nfunction unique(values: readonly string[], label: string): void {\n if (new Set(values).size !== values.length) throw new TypeError(`${label} contains duplicates.`);\n}\n\nfunction orderedUniqueTokens(value: unknown, label: string): string[] {\n const result = boundedArray(value, label).map((item, index) => token(item, `${label}[${index}]`));\n unique(result, label);\n if (result.some((item, index) => index > 0 && result[index - 1]! >= item)) throw new TypeError(`${label} must use fixed code-unit order.`);\n return result;\n}\n\nfunction tuple(value: unknown, label: string, length: number, minimum = 0): number[] {\n const result = boundedArray(value, label, length);\n if (result.length !== length) throw new TypeError(`${label} must contain ${length} elements.`);\n return result.map((item, index) => integer(item, `${label}[${index}]`, minimum));\n}\n\nfunction finiteTuple(value: unknown, label: string, length: number): number[] {\n const result = boundedArray(value, label, length);\n if (result.length !== length || result.some((item) => typeof item !== \"number\" || !Number.isFinite(item))) throw new TypeError(`${label} must contain ${length} finite numbers.`);\n return result as number[];\n}\n\nfunction checkedProduct(left: number, right: number, label: string): number {\n const result = left * right;\n if (!Number.isSafeInteger(result)) throw new TypeError(`${label} exceeds the safe integer bound.`);\n return result;\n}\n\nfunction checkedSum(left: number, right: number, label: string): number {\n const result = left + right;\n if (!Number.isSafeInteger(result)) throw new TypeError(`${label} exceeds the safe integer bound.`);\n return result;\n}\n\nfunction textureFormatAspect(format: string, label: string): TextureFormatAspect {\n if (UNCOMPRESSED_COLOR_BYTES.has(format) || COMPRESSED_COLOR_FORMATS.has(format)) return \"color\";\n const aspect = DEPTH_STENCIL_FORMATS.get(format);\n if (!aspect) throw new TypeError(`${label} is not a qualification-fixture-v1 WebGPU texture format.`);\n return aspect;\n}\n\nfunction mipExtent(texture: TextureResourceInfo, mipLevel: number): readonly [number, number, number] {\n const divisor = 2 ** mipLevel;\n const width = Math.max(1, Math.floor(texture.size[0] / divisor));\n const height = texture.dimension === \"1d\" ? 1 : Math.max(1, Math.floor(texture.size[1] / divisor));\n const depthOrArrayLayers = texture.dimension === \"3d\"\n ? Math.max(1, Math.floor(texture.size[2] / divisor))\n : texture.dimension === \"2d\" ? texture.size[2] : 1;\n return [width, height, depthOrArrayLayers];\n}\n\nfunction linearTextureDataBounds(\n extent: readonly [number, number, number],\n bytesPerTexel: number,\n bytesPerRow: number,\n rowsPerImage: number,\n label: string,\n): { readonly minimum: number; readonly maximum: number } {\n const rowBytes = checkedProduct(extent[0], bytesPerTexel, `${label} row byte length`);\n if (bytesPerRow < rowBytes || bytesPerRow % bytesPerTexel !== 0) throw new TypeError(`${label}.bytesPerRow is incompatible with the copied texel row.`);\n if (rowsPerImage < extent[1]) throw new TypeError(`${label}.rowsPerImage is smaller than the copied image height.`);\n const imageStride = checkedProduct(bytesPerRow, rowsPerImage, `${label} image stride`);\n const priorImages = checkedProduct(imageStride, extent[2] - 1, `${label} prior-image byte length`);\n const priorRows = checkedProduct(bytesPerRow, extent[1] - 1, `${label} prior-row byte length`);\n const minimum = checkedSum(priorImages, checkedSum(priorRows, rowBytes, `${label} final-image byte length`), `${label} required byte length`);\n const maximum = checkedProduct(imageStride, extent[2], `${label} padded byte capacity`);\n return { minimum, maximum };\n}\n\nfunction textureView(value: unknown, label: string, texture: TextureResourceInfo): void {\n const view = object(value, label);\n exact(view, [\"format\", \"dimension\", \"aspect\", \"baseMipLevel\", \"mipLevelCount\", \"baseArrayLayer\", \"arrayLayerCount\"], label);\n const dimension = view.dimension === null ? null : String(view.dimension);\n if (dimension !== null && ![\"1d\", \"2d\", \"2d-array\", \"cube\", \"cube-array\", \"3d\"].includes(dimension)) throw new TypeError(`${label}.dimension is invalid.`);\n const aspect = String(view.aspect);\n if (![\"all\", \"depth-only\", \"stencil-only\"].includes(aspect)) throw new TypeError(`${label}.aspect is invalid.`);\n\n const resourceAspect = textureFormatAspect(texture.format, `${label} resource format`);\n const aspectIsPresent = aspect === \"all\"\n || aspect === \"depth-only\" && (resourceAspect === \"depth\" || resourceAspect === \"depth-stencil\")\n || aspect === \"stencil-only\" && (resourceAspect === \"stencil\" || resourceAspect === \"depth-stencil\");\n if (!aspectIsPresent) throw new TypeError(`${label}.aspect is not present in texture format ${texture.format}.`);\n const resolvedFormat = aspect === \"all\" ? texture.format\n : aspect === \"stencil-only\" ? \"stencil8\"\n : texture.format === \"depth24plus-stencil8\" ? \"depth24plus\"\n : texture.format === \"depth32float-stencil8\" ? \"depth32float\" : texture.format;\n if (view.format !== null && token(view.format, `${label}.format`) !== resolvedFormat) {\n throw new TypeError(`${label}.format differs from the texture aspect format ${resolvedFormat}.`);\n }\n\n const baseMipLevel = integer(view.baseMipLevel, `${label}.baseMipLevel`);\n if (baseMipLevel >= texture.mipLevelCount) throw new TypeError(`${label}.baseMipLevel is out of bounds.`);\n const mipLevelCount = view.mipLevelCount === null\n ? texture.mipLevelCount - baseMipLevel\n : integer(view.mipLevelCount, `${label}.mipLevelCount`, 1);\n if (mipLevelCount > texture.mipLevelCount - baseMipLevel) throw new TypeError(`${label}.mipLevelCount is out of bounds.`);\n\n const textureArrayLayers = texture.dimension === \"2d\" ? texture.size[2] : 1;\n const baseArrayLayer = integer(view.baseArrayLayer, `${label}.baseArrayLayer`);\n if (baseArrayLayer >= textureArrayLayers) throw new TypeError(`${label}.baseArrayLayer is out of bounds.`);\n const resolvedDimension = dimension ?? (texture.dimension === \"2d\" && textureArrayLayers > 1 ? \"2d-array\" : texture.dimension);\n const defaultArrayLayerCount = resolvedDimension === \"cube\" ? 6\n : resolvedDimension === \"2d-array\" || resolvedDimension === \"cube-array\" ? textureArrayLayers - baseArrayLayer : 1;\n const arrayLayerCount = view.arrayLayerCount === null\n ? defaultArrayLayerCount\n : integer(view.arrayLayerCount, `${label}.arrayLayerCount`, 1);\n if (arrayLayerCount > textureArrayLayers - baseArrayLayer) throw new TypeError(`${label}.arrayLayerCount is out of bounds.`);\n\n if (resolvedDimension === \"1d\" && texture.dimension !== \"1d\"\n || resolvedDimension === \"3d\" && texture.dimension !== \"3d\"\n || [\"2d\", \"2d-array\", \"cube\", \"cube-array\"].includes(resolvedDimension) && texture.dimension !== \"2d\") {\n throw new TypeError(`${label}.dimension is incompatible with the texture dimension.`);\n }\n if ([\"1d\", \"2d\", \"3d\"].includes(resolvedDimension) && arrayLayerCount !== 1) throw new TypeError(`${label}.arrayLayerCount must be one for ${resolvedDimension} views.`);\n if (resolvedDimension === \"cube\" && arrayLayerCount !== 6 || resolvedDimension === \"cube-array\" && arrayLayerCount % 6 !== 0) throw new TypeError(`${label}.arrayLayerCount is invalid for a cube view.`);\n if ((resolvedDimension === \"cube\" || resolvedDimension === \"cube-array\") && texture.size[0] !== texture.size[1]) throw new TypeError(`${label} cube views require square texture layers.`);\n if (texture.sampleCount > 1 && (resolvedDimension !== \"2d\" || mipLevelCount !== 1 || arrayLayerCount !== 1)) throw new TypeError(`${label} multisampled texture views must select one 2d subresource.`);\n}\n\nfunction dataRef(value: unknown, label: string): void {\n const ref = object(value, label); exact(ref, [\"path\", \"sha256\"], label); path(ref.path, `${label}.path`, [\".bin\"]); sha(ref.sha256, `${label}.sha256`);\n}\n\nfunction jsonValue(value: unknown, label: string, depth = 0): void {\n if (depth > 32) throw new TypeError(`${label} exceeds the structured-value nesting bound.`);\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return;\n if (typeof value === \"number\") { if (!Number.isFinite(value)) throw new TypeError(`${label} must be finite.`); return; }\n if (Array.isArray(value)) { if (value.length > 65_536) throw new TypeError(`${label} exceeds the structured-value item bound.`); value.forEach((item, index) => jsonValue(item, `${label}[${index}]`, depth + 1)); return; }\n const input = object(value, label); if (Object.keys(input).length > 4096) throw new TypeError(`${label} has too many members.`); for (const [key, item] of Object.entries(input)) { token(key, `${label} key`); jsonValue(item, `${label}.${key}`, depth + 1); }\n}\n\n/** Strictly validates the bounded, declarative (never executable) fixture DSL. */\nexport function validateQualificationFixture(\n value: unknown,\n unit?: ShaderCompileUnitManifest,\n): ShaderResult<ShaderQualificationFixtureManifest> {\n try {\n const fixture = object(detachedJson(value, \"fixture\"), \"fixture\"); exact(fixture, [\"contractVersion\", \"fixtureId\", \"resources\", \"bindGroups\", \"commands\", \"layoutProbes\", \"readbacks\", \"bounds\"], \"fixture\");\n if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError(\"Unsupported qualification fixture version.\");\n token(fixture.fixtureId, \"fixture.fixtureId\");\n const bounds = object(fixture.bounds, \"fixture.bounds\"); exact(bounds, [\"maxBufferBytes\", \"maxTextureTexels\", \"maxCommands\", \"timeoutMs\"], \"fixture.bounds\");\n const maxBufferBytes = integer(bounds.maxBufferBytes, \"fixture.bounds.maxBufferBytes\", 1, 67_108_864);\n const maxTextureTexels = integer(bounds.maxTextureTexels, \"fixture.bounds.maxTextureTexels\", 1, 16_777_216);\n const maxCommands = integer(bounds.maxCommands, \"fixture.bounds.maxCommands\", 1, 1000);\n integer(bounds.timeoutMs, \"fixture.bounds.timeoutMs\", 1, 300_000);\n const resources = new Map<string, FixtureResourceInfo>();\n let bufferBytes = 0; let textureTexels = 0;\n const resourceValues = boundedArray(fixture.resources, \"fixture.resources\", 256); if (resourceValues.length === 0) throw new TypeError(\"Fixture requires resources.\");\n for (const [index, value] of resourceValues.entries()) {\n const label = `fixture.resources[${index}]`; const resource = object(value, label); const kind = String(resource.kind);\n if (kind === \"buffer\") {\n exact(resource, [\"kind\", \"resourceId\", \"byteLength\", \"usage\", \"initialData\"], label);\n const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const byteLength = integer(resource.byteLength, `${label}.byteLength`, 1, maxBufferBytes); bufferBytes += byteLength;\n const usage = boundedArray(resource.usage, `${label}.usage`, BUFFER_USAGE.size).map(String); unique(usage, `${label}.usage`); if (usage.length === 0 || usage.some((item) => !BUFFER_USAGE.has(item))) throw new TypeError(`${label}.usage is invalid.`);\n if (resource.initialData !== null) dataRef(resource.initialData, `${label}.initialData`);\n resources.set(id, { kind: \"buffer\", byteLength, usage, hasInitialData: resource.initialData !== null });\n } else if (kind === \"texture\") {\n exact(resource, [\"kind\", \"resourceId\", \"dimension\", \"size\", \"mipLevelCount\", \"sampleCount\", \"format\", \"usage\", \"initialData\"], label);\n const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const dimensionValue = String(resource.dimension); if (![\"1d\", \"2d\", \"3d\"].includes(dimensionValue)) throw new TypeError(`${label}.dimension is invalid.`); const dimension = dimensionValue as TextureDimension;\n const parsedSize = tuple(resource.size, `${label}.size`, 3, 1); const size = parsedSize as [number, number, number];\n if (dimension === \"1d\" && (size[1] !== 1 || size[2] !== 1)) throw new TypeError(`${label}.size is inconsistent with dimension.`);\n const mipLevelCount = integer(resource.mipLevelCount, `${label}.mipLevelCount`, 1, 32);\n const maximumMipDimension = dimension === \"1d\" ? size[0] : dimension === \"2d\" ? Math.max(size[0], size[1]) : Math.max(...size);\n const maximumMipLevels = Math.floor(Math.log2(maximumMipDimension)) + 1;\n if (mipLevelCount > maximumMipLevels) throw new TypeError(`${label}.mipLevelCount exceeds its spatial size.`);\n const sampleCount = integer(resource.sampleCount, `${label}.sampleCount`, 1, 4); if (sampleCount !== 1 && sampleCount !== 4) throw new TypeError(`${label}.sampleCount is unsupported.`);\n if (sampleCount > 1 && (dimension !== \"2d\" || size[2] !== 1 || mipLevelCount !== 1)) throw new TypeError(`${label} multisampling requires one single-mip 2d layer.`);\n const resourceTexels = checkedProduct(checkedProduct(checkedProduct(size[0], size[1], `${label} texel count`), size[2], `${label} texel count`), sampleCount, `${label} sampled texel count`);\n textureTexels = checkedSum(textureTexels, resourceTexels, \"fixture texture texel count\");\n const format = token(resource.format, `${label}.format`); textureFormatAspect(format, `${label}.format`);\n const usage = boundedArray(resource.usage, `${label}.usage`, TEXTURE_USAGE.size).map(String); unique(usage, `${label}.usage`); if (usage.length === 0 || usage.some((item) => !TEXTURE_USAGE.has(item))) throw new TypeError(`${label}.usage is invalid.`);\n const textureInfo: TextureResourceInfo = { kind: \"texture\", usage, hasInitialData: resource.initialData !== null, dimension, size, mipLevelCount, sampleCount, format };\n if (resource.initialData !== null) {\n const initialLabel = `${label}.initialData`;\n const initial = object(resource.initialData, initialLabel); exact(initial, [\"path\", \"sha256\", \"bytesPerRow\", \"rowsPerImage\", \"mipLevel\", \"origin\", \"aspect\"], initialLabel);\n path(initial.path, `${initialLabel}.path`, [\".bin\"]); sha(initial.sha256, `${initialLabel}.sha256`);\n if (sampleCount !== 1) throw new TypeError(`${label} multisampled textures cannot have initialData.`);\n if (!usage.includes(\"copy-dst\")) throw new TypeError(`${initialLabel} requires copy-dst texture usage.`);\n const bytesPerTexel = UNCOMPRESSED_COLOR_BYTES.get(format); if (!bytesPerTexel) throw new TypeError(`${initialLabel} supports only uncompressed color formats in fixture v1.`);\n const mipLevel = integer(initial.mipLevel, `${initialLabel}.mipLevel`); if (mipLevel !== 0) throw new TypeError(`${initialLabel}.mipLevel must be zero in fixture v1.`);\n const origin = tuple(initial.origin, `${initialLabel}.origin`, 3); if (origin.some((axis) => axis !== 0)) throw new TypeError(`${initialLabel}.origin must be zero in fixture v1.`);\n if (initial.aspect !== \"all\") throw new TypeError(`${initialLabel}.aspect must be all for an uncompressed color upload.`);\n const bytesPerRow = integer(initial.bytesPerRow, `${initialLabel}.bytesPerRow`, 1);\n const rowsPerImage = integer(initial.rowsPerImage, `${initialLabel}.rowsPerImage`, 1);\n linearTextureDataBounds(mipExtent(textureInfo, 0), bytesPerTexel, bytesPerRow, rowsPerImage, initialLabel);\n }\n resources.set(id, textureInfo);\n } else if (kind === \"sampler\") {\n exact(resource, [\"kind\", \"resourceId\", \"descriptor\"], label); const id = token(resource.resourceId, `${label}.resourceId`); if (resources.has(id)) throw new TypeError(`Duplicate resource ${id}.`);\n const descriptor = object(resource.descriptor, `${label}.descriptor`); const samplerKeys = new Set([\"addressModeU\", \"addressModeV\", \"addressModeW\", \"magFilter\", \"minFilter\", \"mipmapFilter\", \"lodMinClamp\", \"lodMaxClamp\", \"compare\", \"maxAnisotropy\"]); for (const key of Object.keys(descriptor)) if (!samplerKeys.has(key)) throw new TypeError(`${label}.descriptor.${key} is unsupported.`); for (const key of [\"addressModeU\", \"addressModeV\", \"addressModeW\"]) if (descriptor[key] !== undefined && ![\"clamp-to-edge\", \"repeat\", \"mirror-repeat\"].includes(String(descriptor[key]))) throw new TypeError(`${label}.descriptor.${key} is invalid.`); for (const key of [\"magFilter\", \"minFilter\", \"mipmapFilter\"]) if (descriptor[key] !== undefined && ![\"nearest\", \"linear\"].includes(String(descriptor[key]))) throw new TypeError(`${label}.descriptor.${key} is invalid.`); if (descriptor.compare !== undefined && ![\"never\", \"less\", \"equal\", \"less-equal\", \"greater\", \"not-equal\", \"greater-equal\", \"always\"].includes(String(descriptor.compare))) throw new TypeError(`${label}.descriptor.compare is invalid.`); const lodMin = descriptor.lodMinClamp === undefined ? 0 : Number(descriptor.lodMinClamp); const lodMax = descriptor.lodMaxClamp === undefined ? 32 : Number(descriptor.lodMaxClamp); if (!Number.isFinite(lodMin) || !Number.isFinite(lodMax) || lodMin < 0 || lodMax < lodMin || lodMax > 32) throw new TypeError(`${label}.descriptor LOD clamps are invalid.`); if (descriptor.maxAnisotropy !== undefined) integer(descriptor.maxAnisotropy, `${label}.descriptor.maxAnisotropy`, 1, 16);\n resources.set(id, { kind: \"sampler\", usage: [], hasInitialData: false, descriptor });\n } else throw new TypeError(`${label}.kind is unsupported.`);\n }\n if (bufferBytes > maxBufferBytes || textureTexels > maxTextureTexels) throw new TypeError(\"Fixture resources exceed declared bounds.\");\n const bindGroups = new Map<string, { group: number; entries: readonly UnknownRecord[] }>();\n for (const [index, value] of boundedArray(fixture.bindGroups, \"fixture.bindGroups\", 32).entries()) {\n const label = `fixture.bindGroups[${index}]`; const group = object(value, label); exact(group, [\"bindGroupId\", \"group\", \"entries\"], label); const id = token(group.bindGroupId, `${label}.bindGroupId`); if (bindGroups.has(id)) throw new TypeError(`Duplicate bind group ${id}.`); const groupIndex = integer(group.group, `${label}.group`); const parsedEntries: UnknownRecord[] = [];\n const bindingIds: string[] = []; for (const [entryIndex, value] of boundedArray(group.entries, `${label}.entries`, 64).entries()) { const entryLabel = `${label}.entries[${entryIndex}]`; const entry = object(value, entryLabel); parsedEntries.push(entry); exact(entry, [\"binding\", \"resource\"], entryLabel); bindingIds.push(String(integer(entry.binding, `${entryLabel}.binding`))); const ref = object(entry.resource, `${entryLabel}.resource`); const kind = String(ref.kind); if (kind === \"buffer\") { exact(ref, [\"kind\", \"resourceId\", \"offset\", \"size\"], `${entryLabel}.resource`); const source = resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`)); const offset = integer(ref.offset, `${entryLabel}.resource.offset`); const size = integer(ref.size, `${entryLabel}.resource.size`, 1); if (source?.kind !== \"buffer\" || offset + size > source.byteLength) throw new TypeError(`${entryLabel}.resource is out of bounds.`); } else if (kind === \"texture-view\") { exact(ref, [\"kind\", \"resourceId\", \"view\"], `${entryLabel}.resource`); const source = resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`)); if (source?.kind !== \"texture\") throw new TypeError(`${entryLabel}.resource is not a texture.`); textureView(ref.view, `${entryLabel}.resource.view`, source); } else if (kind === \"sampler\") { exact(ref, [\"kind\", \"resourceId\"], `${entryLabel}.resource`); if (resources.get(token(ref.resourceId, `${entryLabel}.resource.resourceId`))?.kind !== \"sampler\") throw new TypeError(`${entryLabel}.resource is not a sampler.`); } else throw new TypeError(`${entryLabel}.resource.kind is unsupported.`); }\n unique(bindingIds, `${label}.entries`);\n bindGroups.set(id, { group: groupIndex, entries: parsedEntries });\n }\n const pipelines = new Map(unit?.pipelines.map((pipeline) => [pipeline.pipelineId, pipeline]) ?? []);\n const pipelineIds = new Set(pipelines.keys());\n const commandBindGroups = (value: unknown, pipelineId: string, label: string): void => {\n const ids = boundedArray(value, label, 32).map((item, index) => token(item, `${label}[${index}]`)); unique(ids, label);\n const pipeline = pipelines.get(pipelineId); if (!pipeline) { if (unit) throw new TypeError(`${label} pipeline is missing.`); return; }\n const expectedGroups = [...pipeline.layout.bindGroups].sort((left, right) => left.group - right.group);\n if (ids.length !== expectedGroups.length) throw new TypeError(`${label} must bind every pipeline group exactly once.`);\n ids.forEach((id, index) => { const actual = bindGroups.get(id); const expected = expectedGroups[index]!; if (!actual || actual.group !== expected.group) throw new TypeError(`${label}[${index}] does not match pipeline group ${expected.group}.`); const actualBindings = actual.entries.map((entry) => Number(entry.binding)).sort((left, right) => left - right); const expectedBindings = expected.entries.map((entry) => entry.binding).sort((left, right) => left - right); if (actualBindings.join(\",\") !== expectedBindings.join(\",\")) throw new TypeError(`${label}[${index}] bind-group entries differ from the pipeline layout.`); });\n };\n const commands = boundedArray(fixture.commands, \"fixture.commands\", maxCommands); if (commands.length === 0 || commands.length > maxCommands) throw new TypeError(\"Fixture requires bounded commands.\");\n let executionCommands = 0;\n for (const [index, value] of commands.entries()) {\n const label = `fixture.commands[${index}]`; const command = object(value, label); const kind = String(command.kind);\n if (kind === \"dispatch\") { executionCommands += 1; exact(command, [\"kind\", \"pipelineId\", \"bindGroupIds\", \"workgroups\"], label); const id = token(command.pipelineId, `${label}.pipelineId`); if (unit && (pipelines.get(id)?.kind !== \"compute\")) throw new TypeError(`${label} references a missing or non-compute pipeline.`); commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`); const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1); if (workgroups[0]! * workgroups[1]! * workgroups[2]! > 1_048_576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`); }\n else if (kind === \"copy-buffer\") { exact(command, [\"kind\", \"source\", \"destination\", \"byteLength\"], label); const source = resources.get(token(command.source, `${label}.source`)); const destination = resources.get(token(command.destination, `${label}.destination`)); const bytes = integer(command.byteLength, `${label}.byteLength`, 1); if (source?.kind !== \"buffer\" || destination?.kind !== \"buffer\" || bytes > (source.byteLength ?? 0) || bytes > (destination.byteLength ?? 0)) throw new TypeError(`${label} is out of bounds.`); }\n else if (kind === \"copy-texture-to-buffer\") {\n exact(command, [\"kind\", \"source\", \"destination\", \"extent\"], label);\n const source = object(command.source, `${label}.source`); exact(source, [\"resourceId\", \"mipLevel\", \"origin\", \"aspect\"], `${label}.source`);\n const sourceResource = resources.get(token(source.resourceId, `${label}.source.resourceId`));\n if (sourceResource?.kind !== \"texture\") throw new TypeError(`${label}.source is not a texture.`);\n if (!sourceResource.usage.includes(\"copy-src\")) throw new TypeError(`${label}.source requires copy-src texture usage.`);\n if (sourceResource.sampleCount !== 1) throw new TypeError(`${label}.source must not be multisampled.`);\n const bytesPerTexel = UNCOMPRESSED_COLOR_BYTES.get(sourceResource.format);\n if (!bytesPerTexel || source.aspect !== \"all\") throw new TypeError(`${label}.source format/aspect is unsupported for a fixture-v1 texture readback.`);\n const mipLevel = integer(source.mipLevel, `${label}.source.mipLevel`); if (mipLevel >= sourceResource.mipLevelCount) throw new TypeError(`${label}.source.mipLevel is out of bounds.`);\n const origin = tuple(source.origin, `${label}.source.origin`, 3); const extent = tuple(command.extent, `${label}.extent`, 3, 1) as [number, number, number]; const available = mipExtent(sourceResource, mipLevel);\n if (origin.some((axis, axisIndex) => checkedSum(axis, extent[axisIndex]!, `${label}.source copy range`) > available[axisIndex]!)) throw new TypeError(`${label}.source copy range is out of bounds.`);\n\n const destination = object(command.destination, `${label}.destination`); exact(destination, [\"resourceId\", \"offset\", \"bytesPerRow\", \"rowsPerImage\"], `${label}.destination`);\n const destinationResource = resources.get(token(destination.resourceId, `${label}.destination.resourceId`));\n if (destinationResource?.kind !== \"buffer\") throw new TypeError(`${label}.destination is not a buffer.`);\n if (!destinationResource.usage.includes(\"copy-dst\")) throw new TypeError(`${label}.destination requires copy-dst buffer usage.`);\n const offset = integer(destination.offset, `${label}.destination.offset`); if (offset % bytesPerTexel !== 0) throw new TypeError(`${label}.destination.offset must be texel-block aligned.`);\n const bytesPerRow = integer(destination.bytesPerRow, `${label}.destination.bytesPerRow`, 1); if (bytesPerRow % 256 !== 0) throw new TypeError(`${label}.destination.bytesPerRow must be 256-byte aligned.`);\n const rowsPerImage = integer(destination.rowsPerImage, `${label}.destination.rowsPerImage`, 1);\n const requiredBytes = linearTextureDataBounds(extent, bytesPerTexel, bytesPerRow, rowsPerImage, `${label}.destination`).minimum;\n if (checkedSum(offset, requiredBytes, `${label}.destination range`) > destinationResource.byteLength) throw new TypeError(`${label}.destination range is out of bounds.`);\n }\n else if (kind === \"draw\") { executionCommands += 1; exact(command, [\"kind\", \"pipelineId\", \"bindGroupIds\", \"vertexBuffers\", \"colorAttachments\", \"depthStencilAttachment\", \"vertexCount\", \"instanceCount\", \"firstVertex\", \"firstInstance\"], label); const id = token(command.pipelineId, `${label}.pipelineId`); if (unit && (pipelines.get(id)?.kind !== \"render\")) throw new TypeError(`${label} references a missing or non-render pipeline.`); commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`); boundedArray(command.vertexBuffers, `${label}.vertexBuffers`, 16).forEach((value, vertexIndex) => { const vertexLabel = `${label}.vertexBuffers[${vertexIndex}]`; const vertex = object(value, vertexLabel); exact(vertex, [\"slot\", \"resourceId\", \"offset\", \"size\"], vertexLabel); integer(vertex.slot, `${vertexLabel}.slot`); const resource = resources.get(token(vertex.resourceId, `${vertexLabel}.resourceId`)); const offset = integer(vertex.offset, `${vertexLabel}.offset`); const size = integer(vertex.size, `${vertexLabel}.size`, 1); if (resource?.kind !== \"buffer\" || !resource.usage.includes(\"vertex\") || offset + size > resource.byteLength) throw new TypeError(`${vertexLabel} is not a bounded vertex buffer.`); }); boundedArray(command.colorAttachments, `${label}.colorAttachments`, 8).forEach((value, attachmentIndex) => { const attachmentLabel = `${label}.colorAttachments[${attachmentIndex}]`; const attachment = object(value, attachmentLabel); exact(attachment, [\"resourceId\", \"view\", \"clearValue\", \"loadOp\", \"storeOp\"], attachmentLabel); const target = resources.get(token(attachment.resourceId, `${attachmentLabel}.resourceId`)); if (target?.kind !== \"texture\" || !target.usage.includes(\"render-attachment\")) throw new TypeError(`${attachmentLabel} is not a render-attachment texture.`); textureView(attachment.view, `${attachmentLabel}.view`, target); if (textureFormatAspect(target.format, `${attachmentLabel} format`) !== \"color\") throw new TypeError(`${attachmentLabel} must use a color texture format.`); finiteTuple(attachment.clearValue, `${attachmentLabel}.clearValue`, 4); if (![\"clear\", \"load\"].includes(String(attachment.loadOp)) || ![\"store\", \"discard\"].includes(String(attachment.storeOp))) throw new TypeError(`${attachmentLabel} has invalid ops.`); }); if (command.depthStencilAttachment !== null) { const attachment = object(command.depthStencilAttachment, `${label}.depthStencilAttachment`); exact(attachment, [\"resourceId\", \"view\", \"depthClearValue\", \"depthLoadOp\", \"depthStoreOp\", \"stencilClearValue\", \"stencilLoadOp\", \"stencilStoreOp\"], `${label}.depthStencilAttachment`); const target = resources.get(token(attachment.resourceId, `${label}.depthStencilAttachment.resourceId`)); if (target?.kind !== \"texture\" || !target.usage.includes(\"render-attachment\")) throw new TypeError(`${label}.depthStencilAttachment is not a render-attachment texture.`); textureView(attachment.view, `${label}.depthStencilAttachment.view`, target); if (textureFormatAspect(target.format, `${label}.depthStencilAttachment format`) === \"color\") throw new TypeError(`${label}.depthStencilAttachment must use a depth/stencil texture format.`); if (typeof attachment.depthClearValue !== \"number\" || !Number.isFinite(attachment.depthClearValue) || attachment.depthClearValue < 0 || attachment.depthClearValue > 1) throw new TypeError(`${label}.depthClearValue is invalid.`); integer(attachment.stencilClearValue, `${label}.stencilClearValue`, 0, 255); if (![\"clear\", \"load\"].includes(String(attachment.depthLoadOp)) || ![\"store\", \"discard\"].includes(String(attachment.depthStoreOp)) || attachment.stencilLoadOp !== null && ![\"clear\", \"load\"].includes(String(attachment.stencilLoadOp)) || attachment.stencilStoreOp !== null && ![\"store\", \"discard\"].includes(String(attachment.stencilStoreOp)) || (attachment.stencilLoadOp === null) !== (attachment.stencilStoreOp === null)) throw new TypeError(`${label}.depth/stencil attachment has invalid ops.`); } const vertexCount = integer(command.vertexCount, `${label}.vertexCount`, 1); const instanceCount = integer(command.instanceCount, `${label}.instanceCount`, 1); if (vertexCount * instanceCount > 16_777_216) throw new TypeError(`${label} exceeds the hard draw invocation bound.`); integer(command.firstVertex, `${label}.firstVertex`); integer(command.firstInstance, `${label}.firstInstance`); }\n else throw new TypeError(`${label}.kind is unsupported.`);\n }\n if (executionCommands === 0) throw new TypeError(\"Fixture requires a bounded dispatch or draw command.\");\n const readbacks = boundedArray(fixture.readbacks, \"fixture.readbacks\", 512); if (readbacks.length === 0) throw new TypeError(\"Fixture requires semantic readback evidence.\"); const parsedReadbacks: UnknownRecord[] = [];\n for (const [index, value] of readbacks.entries()) { const label = `fixture.readbacks[${index}]`; const readback = object(value, label); parsedReadbacks.push(readback); exact(readback, [\"resourceId\", \"byteOffset\", \"byteLength\", \"expectedSha256\"], label); const resource = resources.get(token(readback.resourceId, `${label}.resourceId`)); const offset = integer(readback.byteOffset, `${label}.byteOffset`); const size = integer(readback.byteLength, `${label}.byteLength`, 1); if (resource?.kind !== \"buffer\" || !resource.usage.includes(\"map-read\") || offset + size > (resource.byteLength ?? 0)) throw new TypeError(`${label} is not a bounded map-read buffer range.`); sha(readback.expectedSha256, `${label}.expectedSha256`); }\n const probes = boundedArray(fixture.layoutProbes, \"fixture.layoutProbes\", 512); if (probes.length === 0) throw new TypeError(\"Fixture requires at least one structured CPU-to-GPU and GPU-to-CPU layout probe.\"); const probeIds: string[] = []; const probeSources: string[] = [];\n for (const [index, value] of probes.entries()) {\n const label = `fixture.layoutProbes[${index}]`; const probe = object(value, label); probeIds.push(token(probe.probeId, `${label}.probeId`)); const commandIndex = integer(probe.commandIndex, `${label}.commandIndex`, 0, commands.length - 1); const command = object(commands[commandIndex], `${label}.command`);\n if (probe.kind === \"buffer-record\") {\n exact(probe, [\"kind\", \"probeId\", \"source\", \"pipelineId\", \"commandIndex\", \"input\", \"output\"], label);\n const source = object(probe.source, `${label}.source`); exact(source, [\"moduleId\", \"group\", \"binding\", \"recordName\"], `${label}.source`); const moduleId = token(source.moduleId, `${label}.source.moduleId`); const group = integer(source.group, `${label}.source.group`); const binding = integer(source.binding, `${label}.source.binding`); token(source.recordName, `${label}.source.recordName`); probeSources.push(`binding:${moduleId}:${group}:${binding}`);\n const pipelineId = token(probe.pipelineId, `${label}.pipelineId`); if (unit && !pipelineIds.has(pipelineId)) throw new TypeError(`${label}.pipelineId is missing.`); if (command.pipelineId !== pipelineId || command.kind !== \"dispatch\" && command.kind !== \"draw\") throw new TypeError(`${label} must target its declared executable pipeline command.`);\n const input = object(probe.input, `${label}.input`); exact(input, [\"resourceId\", \"byteOffset\", \"byteLength\", \"value\"], `${label}.input`); const inputId = token(input.resourceId, `${label}.input.resourceId`); const inputResource = resources.get(inputId); const inputOffset = integer(input.byteOffset, `${label}.input.byteOffset`); const inputLength = integer(input.byteLength, `${label}.input.byteLength`, 1); if (inputResource?.kind !== \"buffer\" || !inputResource.hasInitialData || inputOffset + inputLength > (inputResource.byteLength ?? 0)) throw new TypeError(`${label}.input must be an initialized bounded buffer range.`); jsonValue(input.value, `${label}.input.value`);\n const commandGroups = boundedArray(command.bindGroupIds, `${label}.command.bindGroupIds`).map(String); const bindsSource = commandGroups.some((id) => { const selected = bindGroups.get(id); if (selected?.group !== group) return false; const entry = selected.entries.find((candidate) => candidate.binding === binding); return entry ? object(entry.resource, `${label}.boundResource`).resourceId === inputId : false; }); if (!bindsSource) throw new TypeError(`${label}.input is not bound at the declared model source in its command.`);\n } else if (probe.kind === \"vertex-input\") {\n exact(probe, [\"kind\", \"probeId\", \"source\", \"commandIndex\", \"input\", \"output\"], label);\n const source = object(probe.source, `${label}.source`); exact(source, [\"pipelineId\", \"shaderLocation\", \"semantic\"], `${label}.source`); const pipelineId = token(source.pipelineId, `${label}.source.pipelineId`); const shaderLocation = integer(source.shaderLocation, `${label}.source.shaderLocation`); const semantic = token(source.semantic, `${label}.source.semantic`); probeSources.push(`vertex:${pipelineId}:${shaderLocation}:${semantic}`);\n if (command.kind !== \"draw\" || command.pipelineId !== pipelineId) throw new TypeError(`${label} must target its declared render pipeline draw command.`);\n const input = object(probe.input, `${label}.input`); exact(input, [\"resourceId\", \"vertexBufferSlot\", \"elementIndex\", \"value\"], `${label}.input`); const inputId = token(input.resourceId, `${label}.input.resourceId`); const inputResource = resources.get(inputId); const slot = integer(input.vertexBufferSlot, `${label}.input.vertexBufferSlot`); const elementIndex = integer(input.elementIndex, `${label}.input.elementIndex`); if (inputResource?.kind !== \"buffer\" || !inputResource.hasInitialData || !inputResource.usage.includes(\"vertex\")) throw new TypeError(`${label}.input must be an initialized vertex buffer.`); jsonValue(input.value, `${label}.input.value`);\n if (unit) { const pipeline = pipelines.get(pipelineId); if (!pipeline || pipeline.kind !== \"render\") throw new TypeError(`${label}.source.pipelineId is not a render pipeline.`); const layout = pipeline.vertexBuffers[slot]; const attribute = layout?.attributes.find((item) => item.shaderLocation === shaderLocation); if (!layout || !attribute || attribute.semantic !== semantic) throw new TypeError(`${label} does not identify an exact pipeline vertex semantic.`); const commandBuffer = boundedArray(command.vertexBuffers, `${label}.command.vertexBuffers`).map((item) => object(item, `${label}.command.vertexBuffer`)).find((item) => item.slot === slot); if (!commandBuffer || commandBuffer.resourceId !== inputId) throw new TypeError(`${label}.input is not bound to its declared vertex-buffer slot.`); const first = integer(layout.stepMode === \"vertex\" ? command.firstVertex : command.firstInstance, `${label}.command.firstElement`); const count = integer(layout.stepMode === \"vertex\" ? command.vertexCount : command.instanceCount, `${label}.command.elementCount`, 1); if (elementIndex < first || elementIndex >= first + count) throw new TypeError(`${label}.input element is not consumed by its draw command.`); }\n } else throw new TypeError(`${label}.kind is unsupported in qualification fixture v1.`);\n const output = object(probe.output, `${label}.output`); exact(output, [\"readbackIndex\", \"recordName\", \"expectedValue\"], `${label}.output`); integer(output.readbackIndex, `${label}.output.readbackIndex`, 0, parsedReadbacks.length - 1); token(output.recordName, `${label}.output.recordName`); jsonValue(output.expectedValue, `${label}.output.expectedValue`);\n }\n unique(probeIds, \"fixture.layoutProbes probe IDs\"); unique(probeSources, \"fixture.layoutProbes model sources\");\n return { ok: true, value: freezeJson(fixture as unknown as ShaderQualificationFixtureManifest) };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid qualification fixture.\" }] };\n }\n}\n\n/** Validates the non-self-referential, data-only candidate bundle envelope. */\nexport function validateQualificationBundleManifest(value: unknown): ShaderResult<ShaderQualificationBundleManifest> {\n try {\n const bundle = object(detachedJson(value, \"qualification\"), \"qualification\"); exact(bundle, [\"contractVersion\", \"inventory\", \"subject\", \"shaderManifestCorePath\", \"gpuInterfaceManifest\", \"modelCompatibilityFixtures\", \"modules\", \"fixtures\"], \"qualification\");\n if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError(\"Unsupported qualification bundle version.\");\n const inventory = validateCompileUnitInventory(bundle.inventory); if (!inventory.ok) throw new TypeError(inventory.diagnostics.map((item) => item.message).join(\"; \"));\n const subject = object(bundle.subject, \"qualification.subject\"); exact(subject, [\"shaderManifestCore\", \"compileUnitInventorySha256\", \"shaderAbiHash\", \"interfaceManifestSha256\", \"modelAbiHashes\", \"modules\", \"requiredCompileUnitIds\", \"requiredCellIds\"], \"qualification.subject\");\n const candidate = object(subject.shaderManifestCore, \"qualification.subject.shaderManifestCore\"); exact(candidate, [\"shaderId\", \"version\", \"sha256\"], \"qualification.subject.shaderManifestCore\"); token(candidate.shaderId, \"qualification.subject.shaderManifestCore.shaderId\"); immutableVersion(candidate.version, \"qualification.subject.shaderManifestCore.version\"); sha(candidate.sha256, \"qualification.subject.shaderManifestCore.sha256\");\n path(bundle.shaderManifestCorePath, \"qualification.shaderManifestCorePath\", [\".json\"]);\n const interfaceManifest = object(bundle.gpuInterfaceManifest, \"qualification.gpuInterfaceManifest\"); exact(interfaceManifest, [\"path\", \"sha256\"], \"qualification.gpuInterfaceManifest\"); path(interfaceManifest.path, \"qualification.gpuInterfaceManifest.path\", [\".json\"]); const interfaceSha = sha(interfaceManifest.sha256, \"qualification.gpuInterfaceManifest.sha256\"); if (interfaceSha !== subject.interfaceManifestSha256) throw new TypeError(\"GPU interface file digest differs from subject.\");\n const modelFixtures = boundedArray(bundle.modelCompatibilityFixtures, \"qualification.modelCompatibilityFixtures\").map((item, index) => { const label = `qualification.modelCompatibilityFixtures[${index}]`; const fixture = object(item, label); exact(fixture, [\"fixtureId\", \"path\", \"sha256\"], label); return { fixtureId: token(fixture.fixtureId, `${label}.fixtureId`), path: path(fixture.path, `${label}.path`, [\".json\"]), sha256: sha(fixture.sha256, `${label}.sha256`) }; }); if (modelFixtures.length === 0) throw new TypeError(\"Qualification requires at least one model compatibility fixture.\"); unique(modelFixtures.map((item) => item.fixtureId), \"qualification.modelCompatibilityFixtures\"); unique(modelFixtures.map((item) => item.path), \"qualification.modelCompatibilityFixtures paths\");\n sha(subject.compileUnitInventorySha256, \"qualification.subject.compileUnitInventorySha256\"); sha(subject.shaderAbiHash, \"qualification.subject.shaderAbiHash\"); sha(subject.interfaceManifestSha256, \"qualification.subject.interfaceManifestSha256\"); const modelHashes = boundedArray(subject.modelAbiHashes, \"qualification.subject.modelAbiHashes\").map((item, index) => sha(item, `qualification.subject.modelAbiHashes[${index}]`)); if (modelHashes.length === 0) throw new TypeError(\"Qualification requires at least one model ABI hash.\"); unique(modelHashes, \"qualification.subject.modelAbiHashes\");\n const modules = boundedArray(bundle.modules, \"qualification.modules\").map((item, index) => { const label = `qualification.modules[${index}]`; const module = object(item, label); exact(module, [\"moduleId\", \"path\", \"sha256\"], label); return { moduleId: token(module.moduleId, `${label}.moduleId`), path: path(module.path, `${label}.path`, [\".wgsl\"]), sha256: sha(module.sha256, `${label}.sha256`) }; }); if (modules.length === 0) throw new TypeError(\"Qualification requires at least one final WGSL module.\"); unique(modules.map((item) => item.moduleId), \"qualification.modules\"); unique(modules.map((item) => item.path), \"qualification.modules paths\");\n const subjectModules = boundedArray(subject.modules, \"qualification.subject.modules\").map((item, index) => { const label = `qualification.subject.modules[${index}]`; const module = object(item, label); exact(module, [\"moduleId\", \"sha256\"], label); return `${token(module.moduleId, `${label}.moduleId`)}:${sha(module.sha256, `${label}.sha256`)}`; }); unique(subjectModules, \"qualification.subject.modules\"); const moduleIdentities = modules.map((item) => `${item.moduleId}:${item.sha256}`); if ([...subjectModules].sort().join(\"\\n\") !== [...moduleIdentities].sort().join(\"\\n\")) throw new TypeError(\"Subject module set differs from bundle modules.\");\n const fixtures = boundedArray(bundle.fixtures, \"qualification.fixtures\").map((item, index) => { const label = `qualification.fixtures[${index}]`; const fixture = object(item, label); exact(fixture, [\"fixtureId\", \"path\", \"sha256\", \"kind\"], label); if (fixture.kind !== \"qualification-fixture\") throw new TypeError(`${label}.kind is invalid.`); return { fixtureId: token(fixture.fixtureId, `${label}.fixtureId`), path: path(fixture.path, `${label}.path`, [\".json\"]), sha256: sha(fixture.sha256, `${label}.sha256`) }; }); if (fixtures.length === 0) throw new TypeError(\"Qualification requires at least one semantic fixture.\"); unique(fixtures.map((item) => item.fixtureId), \"qualification.fixtures\"); unique(fixtures.map((item) => item.path), \"qualification.fixtures paths\");\n const fixtureIdentities = new Set(fixtures.map((item) => `${item.fixtureId}:${item.path}:${item.sha256}`)); for (const unit of inventory.value.compileUnits) { const ref = unit.qualificationFixture; if (!fixtureIdentities.has(`${ref.fixtureId}:${ref.path}:${ref.sha256}`)) throw new TypeError(`Compile unit ${unit.compileUnitId} fixture is absent or stale.`); }\n const unitIds = orderedUniqueTokens(subject.requiredCompileUnitIds, \"qualification.subject.requiredCompileUnitIds\"); const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort(); if (unitIds.join(\"\\n\") !== expectedUnits.join(\"\\n\")) throw new TypeError(\"Subject compile-unit IDs differ from inventory.\"); orderedUniqueTokens(subject.requiredCellIds, \"qualification.subject.requiredCellIds\");\n return { ok: true, value: freezeJson(bundle as unknown as ShaderQualificationBundleManifest) };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid qualification bundle.\" }] };\n }\n}\n","import { canonicalizeGpuContract } from \"../canonical-json.js\";\nimport {\n SHADER_VALIDATION_EVIDENCE_VERSION,\n type GitObjectId,\n type ShaderCellEvidence,\n type ShaderDiagnostic,\n type ShaderNonQualifyingWorkflowDiagnostic,\n type ShaderQualificationBundleManifest,\n type ShaderQualificationCandidateSubject,\n type ShaderQualificationPreflightManifest,\n type ShaderQualificationExecutionProducer,\n type ShaderQualificationResult,\n type ShaderQualificationStatus,\n type ShaderResult,\n type ShaderRunnerCellPreflightEvidence,\n type ShaderTrustedWorkflowProvenance,\n type ShaderValidationCellRun,\n type ShaderValidationEvidence,\n type ShaderValidationEvidenceAttestationRef,\n type Sha256Hex,\n type StableWebGpuMatrixCell,\n type StableWebGpuMatrixManifest,\n} from \"../contracts.js\";\nimport { asSha256Hex, computeSha256 } from \"../hash.js\";\n\ntype UnknownRecord = Record<string, unknown>;\n\nexport interface EvidenceArtifact<T> {\n readonly value: T;\n readonly bytes: Uint8Array;\n readonly sha256: Sha256Hex;\n}\n\nfunction object(value: unknown, path: string): UnknownRecord {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);\n return value as UnknownRecord;\n}\n\nfunction exact(value: UnknownRecord, keys: readonly string[], path: string): void {\n const expected = new Set(keys);\n if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key in value)) throw new TypeError(`${path} has unknown or missing fields.`);\n}\n\nfunction token(value: unknown, path: string, maximum = 512): string {\n if (typeof value !== \"string\" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 0x1f)) throw new TypeError(`${path} is not a bounded string.`);\n return value;\n}\n\nfunction sha(value: unknown, path: string): Sha256Hex {\n try { return asSha256Hex(token(value, path, 64)); }\n catch (cause) { throw new TypeError(`${path} is not a SHA-256 digest.`, { cause }); }\n}\n\nfunction integer(value: unknown, path: string, minimum = 0): number {\n if (!Number.isSafeInteger(value) || Number(value) < minimum) throw new TypeError(`${path} is not a safe integer.`);\n return Number(value);\n}\n\nfunction timestamp(value: unknown, path: string): string {\n const parsed = token(value, path, 64);\n if (!/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{3})?Z$/u.test(parsed) || !Number.isFinite(Date.parse(parsed))) throw new TypeError(`${path} must be an ISO UTC timestamp.`);\n return parsed;\n}\n\nfunction array(value: unknown, path: string, maximum = 100_000): readonly unknown[] {\n if (!Array.isArray(value) || value.length > maximum) throw new TypeError(`${path} must be a bounded array.`);\n return value;\n}\n\nfunction gitObject(value: unknown, path: string): GitObjectId {\n const input = object(value, path); exact(input, [\"algorithm\", \"hex\"], path);\n const algorithm = input.algorithm; if (algorithm !== \"sha1\" && algorithm !== \"sha256\") throw new TypeError(`${path}.algorithm is invalid.`);\n const hex = token(input.hex, `${path}.hex`, 64); const length = algorithm === \"sha1\" ? 40 : 64;\n if (!new RegExp(`^[a-f0-9]{${length}}$`, \"u\").test(hex)) throw new TypeError(`${path}.hex does not match its algorithm.`);\n return input as unknown as GitObjectId;\n}\n\nconst TRUSTED_WORKFLOW_PREFIX = \"Plasius-LTD/gpu-shader/.github/workflows/shader-qualification.yml@\";\n\nfunction trustedWorkflowRef(value: unknown, path: string): string {\n const result = token(value, path, 1024);\n if (result !== `${TRUSTED_WORKFLOW_PREFIX}refs/heads/main`) throw new TypeError(`${path} must bind the trusted shader-qualification workflow on protected main.`);\n return result;\n}\n\nexport function parseTrustedWorkflowProvenance(value: unknown, path = \"provenance\"): ShaderTrustedWorkflowProvenance {\n const input = object(value, path); exact(input, [\"repository\", \"commit\", \"ref\", \"workflowRef\", \"workflowSha\", \"runId\", \"runAttempt\", \"job\", \"eventName\", \"oidcAttestation\"], path);\n const repository = token(input.repository, `${path}.repository`); if (!repository.startsWith(\"Plasius-LTD/\")) throw new TypeError(`${path}.repository is outside Plasius-LTD.`); gitObject(input.commit, `${path}.commit`); token(input.ref, `${path}.ref`); gitObject(input.workflowSha, `${path}.workflowSha`); trustedWorkflowRef(input.workflowRef, `${path}.workflowRef`); token(input.runId, `${path}.runId`); integer(input.runAttempt, `${path}.runAttempt`, 1); token(input.job, `${path}.job`); token(input.eventName, `${path}.eventName`);\n const oidc = object(input.oidcAttestation, `${path}.oidcAttestation`); exact(oidc, [\"issuer\", \"subject\", \"audience\", \"verifiedClaimsSha256\", \"verifiedAt\", \"source\"], `${path}.oidcAttestation`);\n if (oidc.issuer !== \"https://token.actions.githubusercontent.com\" || oidc.source !== \"trusted-runner-preflight\") throw new TypeError(`${path}.oidcAttestation is not GitHub trusted-preflight provenance.`);\n token(oidc.subject, `${path}.oidcAttestation.subject`, 2048); token(oidc.audience, `${path}.oidcAttestation.audience`, 2048); sha(oidc.verifiedClaimsSha256, `${path}.oidcAttestation.verifiedClaimsSha256`); timestamp(oidc.verifiedAt, `${path}.oidcAttestation.verifiedAt`);\n return input as unknown as ShaderTrustedWorkflowProvenance;\n}\n\n/** Strictly parses the actual job/runner identity that produced a cell artifact. */\nexport function parseQualificationExecutionProducer(value: unknown, path = \"producer\"): ShaderQualificationExecutionProducer {\n const input = object(value, path); exact(input, [\"repository\", \"commit\", \"ref\", \"runId\", \"runAttempt\", \"job\", \"trustedWorkflowRepository\", \"trustedWorkflowRef\", \"trustedWorkflowSha\", \"runner\"], path);\n const repository = token(input.repository, `${path}.repository`); if (!repository.startsWith(\"Plasius-LTD/\")) throw new TypeError(`${path}.repository is outside Plasius-LTD.`);\n gitObject(input.commit, `${path}.commit`); token(input.ref, `${path}.ref`); token(input.runId, `${path}.runId`); integer(input.runAttempt, `${path}.runAttempt`, 1);\n if (![\"swiftshader\", \"physical\", \"physical-runner-preflight\"].includes(String(input.job))) throw new TypeError(`${path}.job is not a qualification workflow job.`);\n if (input.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\") throw new TypeError(`${path}.trustedWorkflowRepository differs.`);\n gitObject(input.trustedWorkflowSha, `${path}.trustedWorkflowSha`); trustedWorkflowRef(input.trustedWorkflowRef, `${path}.trustedWorkflowRef`);\n const runner = object(input.runner, `${path}.runner`); exact(runner, [\"name\", \"environment\", \"os\", \"architecture\"], `${path}.runner`); token(runner.name, `${path}.runner.name`); if (![\"github-hosted\", \"self-hosted\", \"device-farm\"].includes(String(runner.environment))) throw new TypeError(`${path}.runner.environment is invalid.`); token(runner.os, `${path}.runner.os`); token(runner.architecture, `${path}.runner.architecture`);\n return input as unknown as ShaderQualificationExecutionProducer;\n}\n\nfunction assertProducerMatchesPreflight(producer: ShaderQualificationExecutionProducer, provenance: ShaderTrustedWorkflowProvenance, cell: StableWebGpuMatrixCell, path: string, expectedJob: ShaderQualificationExecutionProducer[\"job\"]): void {\n if (producer.repository !== provenance.repository || !canonicalEqual(producer.commit, provenance.commit)\n || producer.ref !== provenance.ref || producer.runId !== provenance.runId || producer.runAttempt !== provenance.runAttempt\n || producer.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\" || producer.trustedWorkflowRef !== provenance.workflowRef\n || !canonicalEqual(producer.trustedWorkflowSha, provenance.workflowSha) || producer.job !== expectedJob) throw new TypeError(`${path} does not match the exact qualification workflow run or subject.`);\n if (expectedJob === \"swiftshader\" && producer.runner.environment !== \"github-hosted\") throw new TypeError(`${path} must identify the hosted SwiftShader job.`);\n if (expectedJob === \"physical\" && producer.runner.environment === \"github-hosted\") throw new TypeError(`${path} cannot use a hosted runner for a physical execution cell.`);\n if (expectedJob === \"physical-runner-preflight\" && producer.runner.environment !== \"github-hosted\") throw new TypeError(`${path} must identify its hosted orchestration job truthfully.`);\n}\n\nfunction canonicalEqual(left: unknown, right: unknown): boolean {\n return canonicalizeGpuContract(left) === canonicalizeGpuContract(right);\n}\n\nfunction foldRunnerLabel(value: string): string {\n return value.replace(/[A-Z]/gu, (character) => character.toLowerCase());\n}\n\nexport async function computeQualificationInventorySha256(bundle: ShaderQualificationBundleManifest): Promise<Sha256Hex> {\n return computeSha256(canonicalizeGpuContract(bundle.inventory));\n}\n\nexport async function computeQualificationSubjectBinding(input: {\n readonly subject: ShaderQualificationCandidateSubject;\n readonly dataBundleSha256: Sha256Hex;\n readonly compileUnitInventorySha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n}): Promise<Sha256Hex> {\n return computeSha256(`plasius.gpu.qualification-subject/v1\\n${canonicalizeGpuContract(input)}`);\n}\n\nasync function computeValidationEvidenceId(value: unknown): Promise<string> {\n const input = object(value, \"evidence identity input\");\n const projection = Object.fromEntries(Object.entries(input).filter(([key]) => key !== \"evidenceId\"));\n return `qualification-${(await computeSha256(`plasius.gpu.validation-evidence/v1\\n${canonicalizeGpuContract(projection)}`)).slice(0, 24)}`;\n}\n\nfunction immutableBlobUri(value: string): { host: string; versionId: string; uri: string } {\n const url = new URL(value);\n if (url.protocol !== \"https:\" || url.username || url.password || url.hash || url.port\n || !/^[a-z0-9]{3,24}\\.blob\\.core\\.windows\\.net$/u.test(url.hostname)\n || !/^[A-Za-z0-9][A-Za-z0-9._/-]*\\.tar$/u.test(url.pathname.slice(1))\n || url.pathname.split(\"/\").some((segment, index) => index > 0 && (!segment || segment === \".\" || segment === \"..\"))) {\n throw new TypeError(\"Source URI must be a normalized immutable Azure Blob .tar URL.\");\n }\n const versionIds = [...url.searchParams.entries()].filter(([key]) => key.toLowerCase() === \"versionid\");\n if ([...url.searchParams.keys()].length !== 1 || versionIds.length !== 1 || !/^[A-Za-z0-9._:-]{1,128}$/u.test(versionIds[0]![1])) throw new TypeError(\"Source URI must use exactly one versionId and no other query parameters.\");\n return { host: url.host.toLowerCase(), versionId: versionIds[0]![1], uri: value };\n}\n\n/** Creates the trusted prepare artifact without persisting an OIDC token. */\nexport async function createQualificationPreflight(input: {\n readonly qualificationId: string;\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly sourceUri: string;\n readonly dataBundleSha256: Sha256Hex;\n readonly matrixSha256: Sha256Hex;\n readonly harnessSha256: Sha256Hex;\n readonly provenance: ShaderTrustedWorkflowProvenance;\n}): Promise<ShaderQualificationPreflightManifest> {\n token(input.qualificationId, \"qualificationId\");\n let parsedMatrix: unknown;\n try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); }\n catch (cause) { throw new TypeError(\"Selected matrix artifact is not UTF-8 JSON.\", { cause }); }\n if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Selected matrix artifact bytes differ from the supplied matrix value.\");\n const actualMatrixSha256 = await computeSha256(input.matrixBytes);\n if (actualMatrixSha256 !== input.matrixSha256) throw new TypeError(\"Selected matrix digest is not derived from the exact matrix manifest.\");\n const inventorySha256 = await computeQualificationInventorySha256(input.bundle);\n if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError(\"Bundle subject contains a stale compile-unit inventory digest.\");\n const requiredCells = input.matrix.cells.map((cell) => cell.cellId);\n if (!canonicalEqual(input.bundle.subject.requiredCellIds, requiredCells)) throw new TypeError(\"Bundle subject cell set differs from the selected matrix.\");\n const subjectBindingSha256 = await computeQualificationSubjectBinding({\n subject: input.bundle.subject,\n dataBundleSha256: input.dataBundleSha256,\n compileUnitInventorySha256: inventorySha256,\n matrixSha256: input.matrixSha256,\n harnessSha256: input.harnessSha256,\n });\n return {\n contractVersion: SHADER_VALIDATION_EVIDENCE_VERSION,\n kind: \"shader-qualification-preflight\",\n qualificationId: input.qualificationId,\n sourceBlob: immutableBlobUri(input.sourceUri),\n dataBundleSha256: input.dataBundleSha256,\n compileUnitInventorySha256: inventorySha256,\n matrixSha256: input.matrixSha256,\n harnessSha256: input.harnessSha256,\n subjectBindingSha256,\n provenance: parseTrustedWorkflowProvenance(input.provenance, \"preflight.provenance\"),\n };\n}\n\nfunction assertDiagnostic(value: unknown, path: string): ShaderDiagnostic {\n const input = object(value, path); const allowed = new Set([\"code\", \"severity\", \"message\", \"path\", \"expected\", \"actual\"]);\n if (!Object.keys(input).every((key) => allowed.has(key)) || ![\"code\", \"severity\", \"message\"].every((key) => key in input)) throw new TypeError(`${path} has unknown or missing fields.`);\n token(input.code, `${path}.code`); if (![\"error\", \"warning\", \"info\"].includes(String(input.severity))) throw new TypeError(`${path}.severity is invalid.`); token(input.message, `${path}.message`, 4096); if (input.path !== undefined) token(input.path, `${path}.path`, 1024);\n return input as unknown as ShaderDiagnostic;\n}\n\nconst phaseNames = [\"assembly\", \"reflection-schema\", \"shader-compilation\", \"pipeline-layout\", \"pipeline-creation\", \"bind-group-creation\", \"cpu-to-gpu-layout\", \"gpu-to-cpu-layout\", \"bounded-execution\", \"semantic-readback\"] as const;\n\nfunction osVersionMatches(cell: StableWebGpuMatrixCell, version: string, channel: string | null): boolean {\n if (!/^\\d+(?:\\.\\d+)*(?:[-+][A-Za-z0-9.]+)?$/u.test(version)) return false;\n const requirement = cell.os.versionRequirement;\n if (requirement.kind === \"exact\") return channel === null && version === requirement.value;\n const major = Number.parseInt(version.split(\".\")[0]!, 10);\n if (requirement.kind === \"major\") return channel === null && major === requirement.value;\n if (requirement.kind === \"minimum-major\") return channel === null && major >= requirement.value;\n return channel === requirement.channel;\n}\n\nfunction assertResult(value: unknown, path: string, cell: StableWebGpuMatrixCell, passingRequired: boolean, timeBounds?: { readonly earliest: string; readonly latest: string }, expectedRunner?: { readonly name: string; readonly labels: readonly string[] }): ShaderQualificationResult {\n const input = object(value, path); exact(input, [\"compileUnitId\", \"cellId\", \"status\", \"startedAt\", \"completedAt\", \"observed\", \"phases\", \"diagnostics\"], path);\n token(input.compileUnitId, `${path}.compileUnitId`); if (input.cellId !== cell.cellId) throw new TypeError(`${path}.cellId differs from its cell evidence.`);\n const status = String(input.status) as ShaderQualificationStatus; if (![\"passed\", \"failed\", \"skipped\", \"timeout\", \"device-lost\", \"runner-unavailable\", \"adapter-unavailable\"].includes(status)) throw new TypeError(`${path}.status is invalid.`);\n const started = timestamp(input.startedAt, `${path}.startedAt`); const completed = timestamp(input.completedAt, `${path}.completedAt`); if (Date.parse(completed) < Date.parse(started)) throw new TypeError(`${path} has reversed timestamps.`); if (timeBounds && (Date.parse(started) < Date.parse(timeBounds.earliest) || Date.parse(completed) > Date.parse(timeBounds.latest))) throw new TypeError(`${path} timestamps fall outside trusted preflight and aggregation bounds.`);\n const observed = object(input.observed, `${path}.observed`); exact(observed, [\"runner\", \"os\", \"browser\", \"adapter\", \"features\", \"limits\"], `${path}.observed`);\n const runner = object(observed.runner, `${path}.observed.runner`); exact(runner, [\"id\", \"labels\"], `${path}.observed.runner`); const runnerId = token(runner.id, `${path}.observed.runner.id`); const labels = array(runner.labels, `${path}.observed.runner.labels`).map((item, index) => token(item, `${path}.observed.runner.labels[${index}]`)); const normalizedLabels = labels.map(foldRunnerLabel); if (new Set(normalizedLabels).size !== normalizedLabels.length || cell.runnerLabels.some((label) => !normalizedLabels.includes(foldRunnerLabel(label)))) throw new TypeError(`${path} actual runner labels do not contain the matrix route (ASCII case-insensitive).`); if (expectedRunner && (runnerId !== expectedRunner.name || !canonicalEqual(labels, expectedRunner.labels))) throw new TypeError(`${path} runner identity/labels differ from the exact runner API preflight observation.`);\n const os = object(observed.os, `${path}.observed.os`); exact(os, [\"name\", \"version\", \"channel\", \"architecture\"], `${path}.observed.os`); const osVersion = token(os.version, `${path}.observed.os.version`); const osChannel = os.channel === null ? null : token(os.channel, `${path}.observed.os.channel`); if (os.name !== cell.os.name || os.architecture !== cell.os.architecture || (status === \"passed\" && !osVersionMatches(cell, osVersion, osChannel)) || (status !== \"passed\" && osVersion !== \"unavailable\" && !osVersionMatches(cell, osVersion, osChannel))) throw new TypeError(`${path} observed the wrong OS target or failed its version requirement.`);\n const browser = object(observed.browser, `${path}.observed.browser`); exact(browser, [\"name\", \"version\", \"channel\"], `${path}.observed.browser`); if (browser.name !== cell.browser.name || browser.channel !== cell.browser.channel) throw new TypeError(`${path} observed the wrong browser target.`); const browserVersion = token(browser.version, `${path}.observed.browser.version`);\n const adapter = object(observed.adapter, `${path}.observed.adapter`); exact(adapter, [\"physical\", \"vendor\", \"family\", \"architecture\", \"device\", \"description\", \"backend\", \"driver\"], `${path}.observed.adapter`); if (adapter.physical !== (cell.adapter.kind === \"physical\") || adapter.backend !== cell.adapter.backend || String(adapter.vendor).trim().toLowerCase() !== cell.adapter.vendor || String(adapter.family).trim().toLowerCase() !== cell.adapter.family) throw new TypeError(`${path} observed the wrong adapter vendor/family/backend.`); for (const key of [\"vendor\", \"family\", \"architecture\", \"device\", \"description\", \"driver\"]) token(adapter[key], `${path}.observed.adapter.${key}`, 1024);\n const features = array(observed.features, `${path}.observed.features`).map((item, index) => token(item, `${path}.observed.features[${index}]`)); if (new Set(features).size !== features.length) throw new TypeError(`${path}.observed.features contains duplicates.`); const limits = object(observed.limits, `${path}.observed.limits`); for (const [name, limit] of Object.entries(limits)) { token(name, `${path}.observed.limits key`); if (typeof limit !== \"number\" || !Number.isFinite(limit) || limit < 0) throw new TypeError(`${path}.observed.limits.${name} is invalid.`); }\n const phases = array(input.phases, `${path}.phases`, phaseNames.length).map((phaseValue, index) => { const phasePath = `${path}.phases[${index}]`; const phase = object(phaseValue, phasePath); const name = String(phase.name); if (name === \"shader-compilation\") { exact(phase, [\"name\", \"status\", \"durationMs\", \"compilationMessagesSha256\", \"errorCount\"], phasePath); sha(phase.compilationMessagesSha256, `${phasePath}.compilationMessagesSha256`); integer(phase.errorCount, `${phasePath}.errorCount`); } else if (name === \"semantic-readback\") { exact(phase, [\"name\", \"status\", \"durationMs\", \"expectedSha256\", \"actualSha256\"], phasePath); sha(phase.expectedSha256, `${phasePath}.expectedSha256`); sha(phase.actualSha256, `${phasePath}.actualSha256`); } else { exact(phase, [\"name\", \"status\", \"durationMs\", \"evidenceSha256\"], phasePath); sha(phase.evidenceSha256, `${phasePath}.evidenceSha256`); } if (!phaseNames.includes(name as typeof phaseNames[number]) || ![\"passed\", \"failed\"].includes(String(phase.status))) throw new TypeError(`${phasePath} is invalid.`); integer(phase.durationMs, `${phasePath}.durationMs`); return phase; });\n const diagnostics = array(input.diagnostics, `${path}.diagnostics`, 256).map((item, index) => assertDiagnostic(item, `${path}.diagnostics[${index}]`));\n if (passingRequired || status === \"passed\") {\n if (status !== \"passed\" || phases.length !== phaseNames.length || !phaseNames.every((name, index) => phases[index]?.name === name && phases[index]?.status === \"passed\")) throw new TypeError(`${path} lacks all ten passed qualification phases in fixed order.`);\n if (runnerId === \"unavailable\" || browserVersion === \"unavailable\" || adapter.device === \"unavailable\" || adapter.driver === \"unavailable\") throw new TypeError(`${path} passed without concrete runner/browser/adapter/driver observations.`);\n const compilation = phases.find((phase) => phase.name === \"shader-compilation\")!; if (compilation.errorCount !== 0) throw new TypeError(`${path} contains compilation errors.`);\n const readback = phases.find((phase) => phase.name === \"semantic-readback\")!; if (readback.expectedSha256 !== readback.actualSha256) throw new TypeError(`${path} semantic readback differs.`);\n if (diagnostics.some((item) => item.severity === \"error\")) throw new TypeError(`${path} passed with an error diagnostic.`);\n }\n return input as unknown as ShaderQualificationResult;\n}\n\nfunction assertCellEvidence(value: unknown, cell: StableWebGpuMatrixCell, matrix: StableWebGpuMatrixManifest, preflight: ShaderQualificationPreflightManifest, harness: { id: string; version: string; sha256: Sha256Hex }, adapterHarness: { readonly id: string; readonly version: string; readonly sha256: Sha256Hex } | null, expectedRunner: { readonly name: string; readonly labels: readonly string[] }, expectedUnits: ReadonlySet<string>, latest: string): ShaderCellEvidence {\n const input = object(value, `cellEvidence.${cell.cellId}`); exact(input, [\"contractVersion\", \"qualificationId\", \"matrixId\", \"matrixVersion\", \"matrixSha256\", \"cellId\", \"dataBundleSha256\", \"compileUnitInventorySha256\", \"harness\", \"automation\", \"subjectBindingSha256\", \"qualificationPreflightProvenance\", \"producer\", \"results\"], `cellEvidence.${cell.cellId}`);\n if (input.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.qualificationId !== preflight.qualificationId || input.matrixId !== matrix.matrixId || input.matrixVersion !== matrix.version || input.cellId !== cell.cellId || input.matrixSha256 !== preflight.matrixSha256 || input.dataBundleSha256 !== preflight.dataBundleSha256 || input.compileUnitInventorySha256 !== preflight.compileUnitInventorySha256 || input.subjectBindingSha256 !== preflight.subjectBindingSha256) throw new TypeError(`Cell evidence ${cell.cellId} has stale subject/matrix identities.`);\n const actualHarness = object(input.harness, `cellEvidence.${cell.cellId}.harness`); exact(actualHarness, [\"id\", \"version\", \"sha256\"], `cellEvidence.${cell.cellId}.harness`); if (!canonicalEqual(actualHarness, harness)) throw new TypeError(`Cell evidence ${cell.cellId} used a different harness.`);\n const automation = object(input.automation, `cellEvidence.${cell.cellId}.automation`); exact(automation, [\"kind\", \"driver\", \"version\", \"sha256\"], `cellEvidence.${cell.cellId}.automation`); if (automation.kind !== cell.automation.kind) throw new TypeError(`Cell evidence ${cell.cellId} used the wrong automation route.`); token(automation.driver, `cellEvidence.${cell.cellId}.automation.driver`); token(automation.version, `cellEvidence.${cell.cellId}.automation.version`); sha(automation.sha256, `cellEvidence.${cell.cellId}.automation.sha256`); if (adapterHarness !== null && !canonicalEqual({ id: automation.driver, version: automation.version, sha256: automation.sha256 }, adapterHarness)) throw new TypeError(`Cell evidence ${cell.cellId} automation differs from its independently verified preflight adapter harness.`);\n if (!canonicalEqual(parseTrustedWorkflowProvenance(input.qualificationPreflightProvenance), preflight.provenance)) throw new TypeError(`Cell evidence ${cell.cellId} changed trusted prepare provenance.`);\n const producer = parseQualificationExecutionProducer(input.producer, `cellEvidence.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `cellEvidence.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\");\n const results = array(input.results, `cellEvidence.${cell.cellId}.results`); if (results.length !== expectedUnits.size) throw new TypeError(`Cell evidence ${cell.cellId} result count is incomplete.`); const ids = new Set<string>(); results.forEach((result, index) => { const parsed = assertResult(result, `cellEvidence.${cell.cellId}.results[${index}]`, cell, true, { earliest: preflight.provenance.oidcAttestation.verifiedAt, latest }, expectedRunner); if (parsed.observed.runner.id !== producer.runner.name) throw new TypeError(`Cell evidence ${cell.cellId} result runner differs from its producer.`); if (!expectedUnits.has(parsed.compileUnitId) || ids.has(parsed.compileUnitId)) throw new TypeError(`Cell evidence ${cell.cellId} has duplicate/unexpected compile unit ${parsed.compileUnitId}.`); ids.add(parsed.compileUnitId); });\n return input as unknown as ShaderCellEvidence;\n}\n\nfunction syntheticResult(unitId: string, cell: StableWebGpuMatrixCell, status: ShaderQualificationStatus, message: string, now: string): ShaderQualificationResult {\n return {\n compileUnitId: unitId, cellId: cell.cellId, status, startedAt: now, completedAt: now,\n observed: {\n runner: { id: \"unavailable\", labels: cell.runnerLabels },\n os: { name: cell.os.name, version: \"unavailable\", channel: null, architecture: cell.os.architecture },\n browser: { name: cell.browser.name, version: \"unavailable\", channel: cell.browser.channel },\n adapter: { physical: cell.adapter.kind === \"physical\", vendor: cell.adapter.vendor, family: cell.adapter.family, architecture: cell.os.architecture, device: \"unavailable\", description: \"unavailable\", backend: cell.adapter.backend, driver: \"unavailable\" },\n features: [], limits: {},\n }, phases: [], diagnostics: [{ code: status === \"timeout\" ? \"timeout\" : \"runner-unavailable\", severity: \"error\", message }],\n };\n}\n\nexport interface AggregateShaderValidationEvidenceInput {\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly preflight: EvidenceArtifact<ShaderQualificationPreflightManifest>;\n readonly cellEvidence: readonly EvidenceArtifact<ShaderCellEvidence>[];\n readonly runnerPreflights: readonly EvidenceArtifact<ShaderRunnerCellPreflightEvidence>[];\n readonly workflowDiagnostics: readonly EvidenceArtifact<ShaderNonQualifyingWorkflowDiagnostic>[];\n readonly harness: { readonly id: string; readonly version: string; readonly sha256: Sha256Hex };\n readonly packageVersion: string;\n readonly generatedAt?: string;\n}\n\n/** Aggregates exactly one immutable result for every compile-unit × matrix-cell pair. */\nexport async function aggregateShaderValidationEvidence(input: AggregateShaderValidationEvidenceInput): Promise<ShaderValidationEvidence> {\n const verifyArtifact = async <T>(artifact: EvidenceArtifact<T>, label: string): Promise<void> => {\n if (await computeSha256(artifact.bytes) !== artifact.sha256) throw new TypeError(`${label} artifact digest is not derived from its exact bytes.`);\n let parsed: unknown;\n try { parsed = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(artifact.bytes)); }\n catch (cause) { throw new TypeError(`${label} bytes are not UTF-8 JSON.`, { cause }); }\n if (!canonicalEqual(parsed, artifact.value)) throw new TypeError(`${label} parsed value differs from its exact bytes.`);\n };\n await verifyArtifact(input.preflight, \"Qualification preflight\");\n for (const artifact of input.cellEvidence) await verifyArtifact(artifact, \"Cell evidence\");\n for (const artifact of input.runnerPreflights) await verifyArtifact(artifact, \"Runner preflight\");\n for (const artifact of input.workflowDiagnostics) await verifyArtifact(artifact, \"Workflow diagnostic\");\n const preflight = input.preflight.value; const preflightInput = object(preflight, \"Qualification preflight\"); exact(preflightInput, [\"contractVersion\", \"kind\", \"qualificationId\", \"sourceBlob\", \"dataBundleSha256\", \"compileUnitInventorySha256\", \"matrixSha256\", \"harnessSha256\", \"subjectBindingSha256\", \"provenance\"], \"Qualification preflight\"); if (preflight.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || preflight.kind !== \"shader-qualification-preflight\") throw new TypeError(\"Missing trusted qualification preflight.\");\n token(preflight.qualificationId, \"Qualification preflight.qualificationId\"); sha(preflight.dataBundleSha256, \"Qualification preflight.dataBundleSha256\"); sha(preflight.compileUnitInventorySha256, \"Qualification preflight.compileUnitInventorySha256\"); sha(preflight.matrixSha256, \"Qualification preflight.matrixSha256\"); sha(preflight.harnessSha256, \"Qualification preflight.harnessSha256\"); sha(preflight.subjectBindingSha256, \"Qualification preflight.subjectBindingSha256\"); const preflightProvenance = parseTrustedWorkflowProvenance(preflight.provenance, \"Qualification preflight.provenance\");\n const sourceBlob = object(preflight.sourceBlob, \"Qualification preflight.sourceBlob\"); exact(sourceBlob, [\"host\", \"versionId\", \"uri\"], \"Qualification preflight.sourceBlob\"); const normalizedSource = immutableBlobUri(token(sourceBlob.uri, \"Qualification preflight.sourceBlob.uri\", 2048)); if (!canonicalEqual(sourceBlob, normalizedSource)) throw new TypeError(\"Qualification preflight source Blob claims are stale.\");\n let parsedMatrix: unknown; try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); } catch (cause) { throw new TypeError(\"Matrix artifact is not UTF-8 JSON.\", { cause }); } if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Matrix artifact bytes differ from the supplied matrix value.\"); const actualMatrixSha256 = await computeSha256(input.matrixBytes); if (preflight.matrixSha256 !== actualMatrixSha256) throw new TypeError(\"Qualification preflight matrix artifact digest is stale.\");\n const actualInventorySha256 = await computeQualificationInventorySha256(input.bundle); if (preflight.compileUnitInventorySha256 !== actualInventorySha256 || input.bundle.subject.compileUnitInventorySha256 !== actualInventorySha256) throw new TypeError(\"Qualification preflight inventory digest is stale.\");\n const actualSubjectBinding = await computeQualificationSubjectBinding({ subject: input.bundle.subject, dataBundleSha256: preflight.dataBundleSha256, compileUnitInventorySha256: actualInventorySha256, matrixSha256: actualMatrixSha256, harnessSha256: input.harness.sha256 }); if (preflight.subjectBindingSha256 !== actualSubjectBinding) throw new TypeError(\"Qualification preflight subject binding is stale.\");\n const units = new Set(input.bundle.inventory.compileUnits.map((unit) => unit.compileUnitId)); const now = input.generatedAt ?? new Date().toISOString(); timestamp(now, \"generatedAt\"); if (Date.parse(now) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError(\"Aggregate timestamp predates trusted preflight verification.\");\n if (input.harness.sha256 !== preflight.harnessSha256) throw new TypeError(\"Harness digest differs from trusted preflight.\");\n const cells = new Map(input.matrix.cells.map((cell) => [cell.cellId, cell]));\n const cellArtifacts = new Map<string, EvidenceArtifact<ShaderCellEvidence>>(); for (const artifact of input.cellEvidence) { const id = artifact.value.cellId; if (!cells.has(id) || cellArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected cell evidence ${id}.`); cellArtifacts.set(id, artifact); }\n const runnerArtifacts = new Map<string, EvidenceArtifact<ShaderRunnerCellPreflightEvidence>>(); for (const artifact of input.runnerPreflights) { const id = artifact.value.cellId; if (!cells.has(id) || runnerArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected runner preflight ${id}.`); runnerArtifacts.set(id, artifact); }\n const diagnosticArtifacts = new Map<string, EvidenceArtifact<ShaderNonQualifyingWorkflowDiagnostic>>(); for (const artifact of input.workflowDiagnostics) { const id = artifact.value.cellId; if (!cells.has(id) || diagnosticArtifacts.has(id)) throw new TypeError(`Duplicate or unexpected workflow diagnostic ${id}.`); diagnosticArtifacts.set(id, artifact); }\n const results: ShaderQualificationResult[] = []; const cellRuns: ShaderValidationCellRun[] = [];\n for (const cell of input.matrix.cells) {\n const runner = runnerArtifacts.get(cell.cellId); const diagnostic = diagnosticArtifacts.get(cell.cellId); const cellArtifact = cellArtifacts.get(cell.cellId);\n if (!runner) throw new TypeError(`Cell ${cell.cellId} lacks runner preflight evidence.`);\n if (runner) {\n const value = runner.value; const raw = object(value, `runnerPreflight.${cell.cellId}`); exact(raw, [\"contractVersion\", \"kind\", \"qualificationId\", \"cellId\", \"status\", \"matrixSha256\", \"runnerLabels\", \"matchedRunners\", \"adapterHarness\", \"qualificationPreflightProvenance\", \"producer\"], `runnerPreflight.${cell.cellId}`); const producer = parseQualificationExecutionProducer(value.producer, `runnerPreflight.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `runnerPreflight.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical-runner-preflight\"); if (value.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value.kind !== \"shader-runner-cell-preflight-evidence\" || value.qualificationId !== preflight.qualificationId || value.cellId !== cell.cellId || value.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual(value.runnerLabels, cell.runnerLabels) || !canonicalEqual(value.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Runner preflight ${cell.cellId} is stale or inconsistent.`);\n const requestedLabels = cell.runnerLabels.map(foldRunnerLabel); const matched = array(value.matchedRunners, `runnerPreflight.${cell.cellId}.matchedRunners`).map((item, index) => { const label = `runnerPreflight.${cell.cellId}.matchedRunners[${index}]`; const match = object(item, label); exact(match, [\"name\", \"labels\"], label); const labels = array(match.labels, `${label}.labels`).map((entry, labelIndex) => token(entry, `${label}.labels[${labelIndex}]`)); const normalized = labels.map(foldRunnerLabel); if (labels.length === 0 || new Set(normalized).size !== normalized.length || requestedLabels.some((required) => !normalized.includes(required))) throw new TypeError(`${label} does not preserve the actual runner API labels containing the requested matrix route.`); return { name: token(match.name, `${label}.name`), labels }; }); if (new Set(matched.map((item) => item.name)).size !== matched.length) throw new TypeError(`Runner preflight ${cell.cellId} repeats matched runners.`);\n if (value.adapterHarness !== null) { const adapterHarness = object(value.adapterHarness, `runnerPreflight.${cell.cellId}.adapterHarness`); exact(adapterHarness, [\"id\", \"version\", \"sha256\"], `runnerPreflight.${cell.cellId}.adapterHarness`); token(adapterHarness.id, `runnerPreflight.${cell.cellId}.adapterHarness.id`); token(adapterHarness.version, `runnerPreflight.${cell.cellId}.adapterHarness.version`); sha(adapterHarness.sha256, `runnerPreflight.${cell.cellId}.adapterHarness.sha256`); }\n if (value.status === \"available\" && matched.length === 0) throw new TypeError(`Available cell ${cell.cellId} has no matched runner.`);\n if (value.status === \"runner-unavailable\" && matched.length !== 0) throw new TypeError(`Unavailable cell ${cell.cellId} claims matched runners.`);\n if (value.status === \"runner-unavailable\" && value.adapterHarness !== null) throw new TypeError(`Unavailable cell ${cell.cellId} claims an executed adapter harness.`);\n if (value.status === \"available\" && cell.adapter.kind === \"software\" && value.adapterHarness === null) throw new TypeError(`Hosted SwiftShader cell ${cell.cellId} lacks its independently observable adapter harness.`);\n }\n if (diagnostic && cellArtifact) throw new TypeError(`Cell ${cell.cellId} has conflicting diagnostic and qualification evidence.`);\n if (runner?.value.status === \"runner-unavailable\") {\n if (cellArtifact || diagnostic) throw new TypeError(`Unavailable cell ${cell.cellId} has conflicting evidence.`);\n for (const unit of units) results.push(syntheticResult(unit, cell, \"runner-unavailable\", \"Required physical runner was unavailable.\", now));\n const cellResults = results.slice(-units.size); cellRuns.push({ cellId: cell.cellId, source: \"runner-preflight\", sourceArtifactSha256: runner.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: runner.value.producer, harness: input.harness, automation: null, resultCount: units.size, status: \"runner-unavailable\" });\n continue;\n }\n if (diagnostic) {\n const value = diagnostic.value; const raw = object(value, `workflowDiagnostic.${cell.cellId}`); exact(raw, [\"contractVersion\", \"kind\", \"qualificationId\", \"cellId\", \"status\", \"matrixSha256\", \"message\", \"qualificationPreflightProvenance\", \"producer\"], `workflowDiagnostic.${cell.cellId}`); const producer = parseQualificationExecutionProducer(value.producer, `workflowDiagnostic.${cell.cellId}.producer`); assertProducerMatchesPreflight(producer, preflight.provenance, cell, `workflowDiagnostic.${cell.cellId}.producer`, cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\"); if (!runner.value.matchedRunners.some((item) => item.name === producer.runner.name)) throw new TypeError(`Workflow diagnostic ${cell.cellId} was not produced by a runner matched in preflight.`); if (value.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || value.kind !== \"non-qualifying-workflow-diagnostic\" || value.qualificationId !== preflight.qualificationId || value.cellId !== cell.cellId || value.matrixSha256 !== preflight.matrixSha256 || !canonicalEqual(value.qualificationPreflightProvenance, preflight.provenance)) throw new TypeError(`Workflow diagnostic ${cell.cellId} is stale or inconsistent.`); token(value.message, `workflowDiagnostic.${cell.cellId}.message`, 4096);\n const status = value.status === \"timeout\" ? \"timeout\" : \"failed\"; for (const unit of units) results.push(syntheticResult(unit, cell, status, value.message, now));\n const cellResults = results.slice(-units.size); cellRuns.push({ cellId: cell.cellId, source: \"workflow-diagnostic\", sourceArtifactSha256: diagnostic.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(cellResults)), qualificationPreflightProvenance: preflight.provenance, producer: value.producer, harness: input.harness, automation: null, resultCount: units.size, status });\n continue;\n }\n if (!cellArtifact) throw new TypeError(`Cell ${cell.cellId} has no qualification evidence.`);\n const matchedRunner = runner.value.matchedRunners.find((item) => item.name === cellArtifact.value.producer.runner.name); if (!matchedRunner) throw new TypeError(`Cell evidence ${cell.cellId} producer was not matched by runner preflight.`); const value = assertCellEvidence(cellArtifact.value, cell, input.matrix, preflight, input.harness, runner.value.adapterHarness, matchedRunner, units, now); results.push(...value.results);\n cellRuns.push({ cellId: cell.cellId, source: \"cell-evidence\", sourceArtifactSha256: cellArtifact.sha256, resultsSha256: await computeSha256(canonicalizeGpuContract(value.results)), qualificationPreflightProvenance: value.qualificationPreflightProvenance, producer: value.producer, harness: value.harness, automation: value.automation, resultCount: value.results.length, status: \"passed\" });\n }\n const expectedResults = units.size * cells.size; if (results.length !== expectedResults) throw new TypeError(\"Aggregate result product is incomplete.\");\n const status: ShaderValidationEvidence[\"status\"] = results.every((result) => result.status === \"passed\") ? \"passed\" : \"failed\";\n const subject = { ...input.bundle.subject, dataBundleSha256: preflight.dataBundleSha256 };\n const draft = {\n contractVersion: SHADER_VALIDATION_EVIDENCE_VERSION,\n status, generatedAt: now, subjectBindingSha256: preflight.subjectBindingSha256, subject,\n matrixRef: { matrixId: input.matrix.matrixId, version: input.matrix.version, sha256: preflight.matrixSha256 },\n toolchain: { packageVersion: input.packageVersion, reflectorVersion: \"1.5.0\" as const, harness: input.harness },\n qualificationPreflightProvenance: preflight.provenance,\n counts: { compileUnits: units.size, cells: cells.size, expectedResults, passedResults: results.filter((result) => result.status === \"passed\").length },\n cellRuns,\n results,\n };\n return { ...draft, evidenceId: await computeValidationEvidenceId(draft) };\n}\n\n/** Validates final aggregate identities and exact Cartesian coverage. */\nexport async function validateShaderValidationEvidence(input: {\n readonly evidence: unknown;\n readonly bundle: ShaderQualificationBundleManifest;\n readonly matrix: StableWebGpuMatrixManifest;\n readonly matrixBytes: Uint8Array;\n readonly dataBundleSha256?: Sha256Hex;\n readonly requirePassed?: boolean;\n}): Promise<ShaderResult<ShaderValidationEvidence>> {\n try {\n const evidence = object(input.evidence, \"evidence\"); exact(evidence, [\"contractVersion\", \"evidenceId\", \"status\", \"generatedAt\", \"subjectBindingSha256\", \"subject\", \"matrixRef\", \"toolchain\", \"qualificationPreflightProvenance\", \"counts\", \"cellRuns\", \"results\"], \"evidence\");\n if (evidence.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION) throw new TypeError(\"Unsupported evidence contract version.\");\n const evidenceId = token(evidence.evidenceId, \"evidence.evidenceId\"); const generatedAt = timestamp(evidence.generatedAt, \"evidence.generatedAt\"); const subjectBindingSha256 = sha(evidence.subjectBindingSha256, \"evidence.subjectBindingSha256\");\n if (evidence.status !== \"passed\" && evidence.status !== \"failed\") throw new TypeError(\"Evidence status is invalid.\");\n\n let parsedMatrix: unknown; try { parsedMatrix = JSON.parse(new TextDecoder(\"utf-8\", { fatal: true }).decode(input.matrixBytes)); } catch (cause) { throw new TypeError(\"Matrix artifact is not UTF-8 JSON.\", { cause }); }\n if (!canonicalEqual(parsedMatrix, input.matrix)) throw new TypeError(\"Matrix artifact bytes differ from the supplied matrix value.\");\n const matrixSha256 = await computeSha256(input.matrixBytes);\n const inventorySha256 = await computeQualificationInventorySha256(input.bundle);\n if (inventorySha256 !== input.bundle.subject.compileUnitInventorySha256) throw new TypeError(\"Bundle subject inventory digest is stale.\");\n\n const subject = object(evidence.subject, \"evidence.subject\"); const expectedSubjectKeys = [...Object.keys(input.bundle.subject), \"dataBundleSha256\"]; exact(subject, expectedSubjectKeys, \"evidence.subject\");\n const candidateSubject = Object.fromEntries(Object.entries(subject).filter(([key]) => key !== \"dataBundleSha256\")); if (!canonicalEqual(candidateSubject, input.bundle.subject)) throw new TypeError(\"Evidence candidate subject differs from bundle.\");\n const dataBundleSha256 = sha(subject.dataBundleSha256, \"evidence.subject.dataBundleSha256\"); if (input.dataBundleSha256 && input.dataBundleSha256 !== dataBundleSha256) throw new TypeError(\"Evidence data bundle digest differs from the exact archive.\");\n if (subject.compileUnitInventorySha256 !== inventorySha256) throw new TypeError(\"Evidence compile-unit inventory digest is stale.\");\n\n const matrixRef = object(evidence.matrixRef, \"evidence.matrixRef\"); exact(matrixRef, [\"matrixId\", \"version\", \"sha256\"], \"evidence.matrixRef\"); if (matrixRef.matrixId !== input.matrix.matrixId || matrixRef.version !== input.matrix.version || matrixRef.sha256 !== matrixSha256) throw new TypeError(\"Evidence matrix artifact identity differs.\");\n const toolchain = object(evidence.toolchain, \"evidence.toolchain\"); exact(toolchain, [\"packageVersion\", \"reflectorVersion\", \"harness\"], \"evidence.toolchain\"); token(toolchain.packageVersion, \"evidence.toolchain.packageVersion\"); if (toolchain.reflectorVersion !== \"1.5.0\") throw new TypeError(\"Evidence reflector version differs.\"); const harness = object(toolchain.harness, \"evidence.toolchain.harness\"); exact(harness, [\"id\", \"version\", \"sha256\"], \"evidence.toolchain.harness\"); token(harness.id, \"evidence.toolchain.harness.id\"); token(harness.version, \"evidence.toolchain.harness.version\"); const harnessSha256 = sha(harness.sha256, \"evidence.toolchain.harness.sha256\");\n const preflightProvenance = parseTrustedWorkflowProvenance(evidence.qualificationPreflightProvenance, \"evidence.qualificationPreflightProvenance\"); if (Date.parse(generatedAt) < Date.parse(preflightProvenance.oidcAttestation.verifiedAt)) throw new TypeError(\"Evidence predates trusted preflight verification.\");\n const expectedBinding = await computeQualificationSubjectBinding({ subject: input.bundle.subject, dataBundleSha256, compileUnitInventorySha256: inventorySha256, matrixSha256, harnessSha256 }); if (subjectBindingSha256 !== expectedBinding) throw new TypeError(\"Evidence subject binding is stale.\");\n if (evidenceId !== await computeValidationEvidenceId(evidence)) throw new TypeError(\"Evidence identity is stale.\");\n\n const units = new Set(input.bundle.inventory.compileUnits.map((unit) => unit.compileUnitId)); const cells = new Map(input.matrix.cells.map((cell) => [cell.cellId, cell])); const expected = units.size * cells.size;\n const results = array(evidence.results, \"evidence.results\"); if (results.length !== expected) throw new TypeError(\"Evidence result product is incomplete.\"); const identities = new Set<string>(); const parsedResults: ShaderQualificationResult[] = []; let passed = 0;\n for (const [index, value] of results.entries()) { const raw = object(value, `evidence.results[${index}]`); const cell = cells.get(String(raw.cellId)); if (!cell || !units.has(String(raw.compileUnitId))) throw new TypeError(`Evidence result ${index} is unexpected.`); const result = assertResult(value, `evidence.results[${index}]`, cell, evidence.status === \"passed\", { earliest: preflightProvenance.oidcAttestation.verifiedAt, latest: generatedAt }); const key = `${result.cellId}:${result.compileUnitId}`; if (identities.has(key)) throw new TypeError(`Evidence repeats ${key}.`); identities.add(key); parsedResults.push(result); if (result.status === \"passed\") passed += 1; }\n const counts = object(evidence.counts, \"evidence.counts\"); exact(counts, [\"compileUnits\", \"cells\", \"expectedResults\", \"passedResults\"], \"evidence.counts\"); if (counts.compileUnits !== units.size || counts.cells !== cells.size || counts.expectedResults !== expected || counts.passedResults !== passed) throw new TypeError(\"Evidence counts are stale.\");\n\n const runs = array(evidence.cellRuns, \"evidence.cellRuns\"); if (runs.length !== cells.size) throw new TypeError(\"Evidence cell-run provenance is incomplete.\"); const runIds = new Set<string>();\n for (const [index, value] of runs.entries()) {\n const path = `evidence.cellRuns[${index}]`; const run = object(value, path); exact(run, [\"cellId\", \"source\", \"sourceArtifactSha256\", \"resultsSha256\", \"qualificationPreflightProvenance\", \"producer\", \"harness\", \"automation\", \"resultCount\", \"status\"], path);\n const cellId = token(run.cellId, `${path}.cellId`); const cell = cells.get(cellId); if (!cell || runIds.has(cellId)) throw new TypeError(`${path}.cellId is duplicate/unexpected.`); runIds.add(cellId);\n if (![\"cell-evidence\", \"runner-preflight\", \"workflow-diagnostic\"].includes(String(run.source))) throw new TypeError(`${path}.source is invalid.`); const sourceArtifactSha256 = sha(run.sourceArtifactSha256, `${path}.sourceArtifactSha256`); if (/^0{64}$/u.test(sourceArtifactSha256)) throw new TypeError(`${path}.sourceArtifactSha256 cannot be a placeholder.`); const resultsSha256 = sha(run.resultsSha256, `${path}.resultsSha256`);\n if (!canonicalEqual(parseTrustedWorkflowProvenance(run.qualificationPreflightProvenance, `${path}.qualificationPreflightProvenance`), preflightProvenance)) throw new TypeError(`${path} changed qualification preflight provenance.`);\n const producer = parseQualificationExecutionProducer(run.producer, `${path}.producer`); const expectedJob: ShaderQualificationExecutionProducer[\"job\"] = run.source === \"runner-preflight\" ? (cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical-runner-preflight\") : (cell.adapter.kind === \"software\" ? \"swiftshader\" : \"physical\"); assertProducerMatchesPreflight(producer, preflightProvenance, cell, `${path}.producer`, expectedJob);\n if (!canonicalEqual(run.harness, harness)) throw new TypeError(`${path}.harness differs.`); if (run.source === \"cell-evidence\") { const automation = object(run.automation, `${path}.automation`); exact(automation, [\"kind\", \"driver\", \"version\", \"sha256\"], `${path}.automation`); if (automation.kind !== cell.automation.kind) throw new TypeError(`${path}.automation route differs.`); token(automation.driver, `${path}.automation.driver`); token(automation.version, `${path}.automation.version`); sha(automation.sha256, `${path}.automation.sha256`); } else if (run.automation !== null) throw new TypeError(`${path}.automation must be null when no adapter completed a cell run.`);\n const cellResults = parsedResults.filter((result) => result.cellId === cellId); if (run.resultCount !== units.size || cellResults.length !== units.size || await computeSha256(canonicalizeGpuContract(cellResults)) !== resultsSha256) throw new TypeError(`${path} result count/digest is stale.`);\n const resultStatuses = new Set(cellResults.map((result) => result.status)); if (resultStatuses.size !== 1 || !resultStatuses.has(String(run.status) as ShaderQualificationStatus)) throw new TypeError(`${path}.status differs from its results.`);\n if (run.source === \"cell-evidence\" && run.status !== \"passed\") throw new TypeError(`${path} cell evidence must contain passing results.`); if (run.source === \"runner-preflight\" && run.status !== \"runner-unavailable\") throw new TypeError(`${path} runner-preflight source has the wrong status.`); if (run.source === \"workflow-diagnostic\" && run.status !== \"failed\" && run.status !== \"timeout\") throw new TypeError(`${path} workflow diagnostic has the wrong status.`);\n if (run.source === \"cell-evidence\" && cellResults.some((result) => result.observed.runner.id !== producer.runner.name)) throw new TypeError(`${path} producer runner differs from its results.`);\n }\n if ((evidence.status === \"passed\") !== (passed === expected) || (input.requirePassed !== false && evidence.status !== \"passed\")) throw new TypeError(\"Evidence does not satisfy the required passed gate.\");\n return { ok: true, value: evidence as unknown as ShaderValidationEvidence };\n } catch (cause) {\n return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Invalid shader validation evidence.\" }] };\n }\n}\n\n/** Strictly parses an external attestation reference; cryptographic verification remains mandatory. */\nexport function parseShaderValidationEvidenceAttestationRef(value: unknown): ShaderValidationEvidenceAttestationRef {\n const input = object(value, \"attestationRef\"); exact(input, [\"contractVersion\", \"kind\", \"evidence\", \"attestation\", \"producer\"], \"attestationRef\"); if (input.contractVersion !== SHADER_VALIDATION_EVIDENCE_VERSION || input.kind !== \"shader-validation-evidence-attestation-ref\") throw new TypeError(\"Unsupported evidence attestation ref.\");\n const producer = object(input.producer, \"attestationRef.producer\"); exact(producer, [\"repository\", \"runId\", \"runAttempt\", \"trustedWorkflowRepository\", \"trustedWorkflowRef\", \"trustedWorkflowSha\"], \"attestationRef.producer\"); const repository = token(producer.repository, \"attestationRef.producer.repository\"); if (!/^Plasius-LTD\\/[A-Za-z0-9._-]+$/u.test(repository)) throw new TypeError(\"Attestation caller repository is outside Plasius-LTD or malformed.\"); if (producer.trustedWorkflowRepository !== \"Plasius-LTD/gpu-shader\") throw new TypeError(\"Attestation trusted workflow repository differs.\"); gitObject(producer.trustedWorkflowSha, \"attestationRef.producer.trustedWorkflowSha\"); trustedWorkflowRef(producer.trustedWorkflowRef, \"attestationRef.producer.trustedWorkflowRef\"); token(producer.runId, \"attestationRef.producer.runId\"); integer(producer.runAttempt, \"attestationRef.producer.runAttempt\", 1);\n const evidence = object(input.evidence, \"attestationRef.evidence\"); exact(evidence, [\"name\", \"sha256\"], \"attestationRef.evidence\"); const evidenceName = token(evidence.name, \"attestationRef.evidence.name\"); if (!/^[A-Za-z0-9._-]+\\.json$/u.test(evidenceName)) throw new TypeError(\"Attested evidence name must be a JSON basename.\"); sha(evidence.sha256, \"attestationRef.evidence.sha256\");\n const attestation = object(input.attestation, \"attestationRef.attestation\"); exact(attestation, [\"id\", \"url\", \"bundle\"], \"attestationRef.attestation\"); token(attestation.id, \"attestationRef.attestation.id\"); const url = new URL(token(attestation.url, \"attestationRef.attestation.url\", 2048)); const expectedPrefix = `/${repository}/attestations/`; if (url.protocol !== \"https:\" || url.hostname !== \"github.com\" || url.port || url.username || url.password || url.search || url.hash || !url.pathname.startsWith(expectedPrefix) || url.pathname.length <= expectedPrefix.length) throw new TypeError(\"Attestation URL must be an exact GitHub repository attestation URL.\"); const bundle = object(attestation.bundle, \"attestationRef.attestation.bundle\"); exact(bundle, [\"name\", \"sha256\"], \"attestationRef.attestation.bundle\"); const bundleName = token(bundle.name, \"attestationRef.attestation.bundle.name\"); if (!/^[A-Za-z0-9._-]+\\.json$/u.test(bundleName)) throw new TypeError(\"Attestation bundle name must be a JSON basename.\"); sha(bundle.sha256, \"attestationRef.attestation.bundle.sha256\");\n return input as unknown as ShaderValidationEvidenceAttestationRef;\n}\n\nexport async function verifyShaderValidationEvidenceAttestation(input: {\n readonly ref: unknown;\n readonly evidenceBytes: Uint8Array;\n readonly bundleBytes: Uint8Array;\n readonly verifyCryptographicBundle: (context: { readonly ref: ShaderValidationEvidenceAttestationRef; readonly evidenceBytes: Uint8Array; readonly bundleBytes: Uint8Array }) => Promise<boolean>;\n}): Promise<ShaderResult<ShaderValidationEvidenceAttestationRef>> {\n try {\n const ref = parseShaderValidationEvidenceAttestationRef(input.ref); if (await computeSha256(input.evidenceBytes) !== ref.evidence.sha256 || await computeSha256(input.bundleBytes) !== ref.attestation.bundle.sha256) throw new TypeError(\"Attested evidence or bundle digest differs.\"); if (!await input.verifyCryptographicBundle({ ref, evidenceBytes: input.evidenceBytes, bundleBytes: input.bundleBytes })) throw new TypeError(\"External build-provenance cryptographic verification failed.\"); return { ok: true, value: ref };\n } catch (cause) { return { ok: false, diagnostics: [{ code: \"invalid-contract\", severity: \"error\", message: cause instanceof Error ? cause.message : \"Evidence attestation verification failed.\" }] }; }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC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M,IAAI,UAAU,6CAA6C;AAAG,QAAI,CAAC,MAAM,MAAM,0BAA0B,EAAE,KAAK,eAAe,MAAM,eAAe,aAAa,MAAM,YAAY,CAAC,EAAG,OAAM,IAAI,UAAU,8DAA8D;AAAG,WAAO,EAAE,IAAI,MAAM,OAAO,IAAI;AAAA,EACxgB,SAAS,OAAO;AAAE,WAAO,EAAE,IAAI,OAAO,aAAa,CAAC,EAAE,MAAM,oBAAoB,UAAU,SAAS,SAAS,iBAAiB,QAAQ,MAAM,UAAU,4CAA4C,CAAC,EAAE;AAAA,EAAG;AACzM;","names":["path","keys","path","keys","path","path","path","path","path","value","path","object","keys","module","pipeline","value","stages","issue","path","object","SAFE_PATH","object","path","detachedJson","freezeJson","exact","keys","token","immutableVersion","integer","unique","value","pipeline","module","object","path","exact","keys","token","sha","integer","array","canonicalEqual","automation","value","status"]}
|