@plasius/gpu-shader 0.1.1 → 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/dist/index.d.cts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { J as JsonValue, S as Sha256Hex, G as GpuInterfaceManifest, a as SerializableGpuPipelineDescriptor, b as ShaderRequirements, c as ShaderVersionManifest, d as GpuRecordValue, e as GpuRecordLayout, f as GpuRecordCodec, M as ModelGpuCompatibilityDescriptor, g as ShaderVersionManifestCore, h as ShaderStyleProfileManifest, i as GpuCapabilitySnapshot, j as ShaderResult, k as ModelShaderCompatibility, l as ShaderStyleProfileRef, P as PromotedShaderCatalogResolver, L as LoadedShaderStyleProfile, m as GpuDeviceLike, n as PreparedShaderStyleProfile, o as ShaderStyleController, A as ActiveShaderStyleProfile, F as FrameBoundaryScheduler } from './contracts-B49AUejk.cjs';
2
2
  export { p as AssembledWgslModule, q as GPU_INTERFACE_MANIFEST_VERSION, r as GPU_SHADER_STORE_FEATURE_FLAG, s as GPU_SHADER_STYLE_SELECTION_CAPABILITY, t as GeneratedGpuInterfaceArtifacts, u as GitObjectId, v as GpuAddressSpace, w as GpuArrayLayout, x as GpuAtomicLayout, y as GpuBindingAccess, z as GpuBindingLayout, B as GpuBindingResourceLayout, C as GpuCompareFunction, D as GpuCompilationMessageLike, E as GpuEntryPointInterface, H as GpuEntryPointIo, I as GpuHostAddressSpace, K as GpuInterfaceRef, N as GpuLimitRequirement, O as GpuMatrixLayout, Q as GpuMatrixValue, R as GpuModelAbiProjection, T as GpuModelBindingLayout, U as GpuModelBindingSelector, V as GpuModelVertexInputLayout, W as GpuOverrideLayout, X as GpuRecordMemberLayout, Y as GpuRecordReferenceLayout, Z as GpuScalarKind, _ as GpuScalarLayout, $ as GpuScalarValue, a0 as GpuSemanticProjection, a1 as GpuSemanticSelector, a2 as GpuSemanticSource, a3 as GpuShaderModuleLike, a4 as GpuShaderStage, a5 as GpuTypeLayout, a6 as GpuVectorLayout, a7 as GpuVectorValue, a8 as GpuVertexInputLayout, a9 as GpuWorkgroupDimension, aa as JsonPrimitive, ab as LoadedShaderVersion, ac as ReflectGpuInterfaceInput, ad as SHADER_COMPILE_UNIT_VERSION, ae as SHADER_QUALIFICATION_BUNDLE_VERSION, af as SHADER_QUALIFICATION_FIXTURE_VERSION, ag as SHADER_STYLE_PROFILE_MANIFEST_VERSION, ah as SHADER_VALIDATION_EVIDENCE_VERSION, ai as SHADER_VERSION_MANIFEST_VERSION, aj as STABLE_WEBGPU_MATRIX_VERSION, ak as SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES, al as SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES, am as ScopedShaderValidationEvidenceRef, an as SerializableGpuBindGroupLayout, ao as SerializableGpuBlendComponent, ap as SerializableGpuComputePipelineDescriptor, aq as SerializableGpuPipelineLayout, ar as SerializableGpuProgrammableStage, as as SerializableGpuRenderPipelineDescriptor, at as SerializableGpuStencilFaceState, au as ShaderCellEvidence, av as ShaderCompileContext, aw as ShaderCompileFixture, ax as ShaderCompileUnitInventory, ay as ShaderCompileUnitManifest, az as ShaderDiagnostic, aA as ShaderDiagnosticCode, aB as ShaderDiagnosticSeverity, aC as ShaderMatrixBrowserName, aD as ShaderMatrixOsName, aE as ShaderNonQualifyingWorkflowDiagnostic, aF as ShaderQualificationBindGroupResource, aG as ShaderQualificationBufferRecordLayoutProbe, aH as ShaderQualificationBundleManifest, aI as ShaderQualificationCandidateSubject, aJ as ShaderQualificationCommand, aK as ShaderQualificationExecutionProducer, aL as ShaderQualificationFixtureManifest, aM as ShaderQualificationLayoutProbe, aN as ShaderQualificationModelCompatibilityFixture, aO as ShaderQualificationPhaseEvidence, aP as ShaderQualificationPhaseName, aQ as ShaderQualificationPreflightManifest, aR as ShaderQualificationResource, aS as ShaderQualificationResult, aT as ShaderQualificationStatus, aU as ShaderQualificationTextureViewDescriptor, aV as ShaderQualificationVertexInputLayoutProbe, aW as ShaderRenderRole, aX as ShaderRunnerCellPreflightEvidence, aY as ShaderStyleRoleBinding, aZ as ShaderTrustedWorkflowProvenance, a_ as ShaderValidationCellRun, a$ as ShaderValidationEvidence, b0 as ShaderValidationEvidenceAttestationRef, b1 as ShaderValidationEvidenceRef, b2 as ShaderValidationEvidenceSubject, b3 as ShaderValidationScopeRequirement, b4 as ShaderVersionRef, b5 as StableWebGpuMatrixCell, b6 as StableWebGpuMatrixManifest } from './contracts-B49AUejk.cjs';
3
3
 
4
+ /**
5
+ * Validates an immutable, reproducible model, interface, shader, or profile
6
+ * version before catalog access.
7
+ *
8
+ * The diagnostic is deliberately constant and never interpolates untrusted
9
+ * input, keeping runtime and storage-boundary failures bounded.
10
+ */
11
+ declare function assertImmutableAssetVersion(value: unknown): string;
12
+
4
13
  /**
5
14
  * Canonicalizes contract data using the JSON Canonicalization Scheme ordering
6
15
  * rules. Unsupported JavaScript values are rejected rather than silently lost.
@@ -85,4 +94,4 @@ declare function activateStyleProfile(input: {
85
94
  readonly retire?: (previous: PreparedShaderStyleProfile) => void | Promise<void>;
86
95
  }): Promise<ShaderResult<ActiveShaderStyleProfile>>;
87
96
 
88
- export { ActiveShaderStyleProfile, FrameBoundaryScheduler, GpuCapabilitySnapshot, GpuDeviceLike, GpuInterfaceManifest, GpuRecordCodec, GpuRecordLayout, GpuRecordValue, JsonValue, LoadedShaderStyleProfile, ModelGpuCompatibilityDescriptor, ModelShaderCompatibility, PreparedShaderStyleProfile, PromotedShaderCatalogResolver, SerializableGpuPipelineDescriptor, Sha256Hex, ShaderRequirements, ShaderResult, ShaderStyleController, ShaderStyleProfileManifest, ShaderStyleProfileRef, ShaderVersionManifest, ShaderVersionManifestCore, activateStyleProfile, asSha256Hex, canonicalizeGpuContract, computeGpuAbiHash, computeSha256, computeShaderManifestCoreSha256, createGpuRecordCodec, createShaderStyleController, loadShaderStyleProfile, parseCanonicalJson, parseGpuInterfaceManifest, parseJsonBytes, parseModelGpuCompatibilityDescriptor, parseShaderStyleProfileManifest, parseShaderVersionManifest, parseShaderVersionManifestCore, prepareStyleProfile, validateModelShaderCompatibility };
97
+ export { ActiveShaderStyleProfile, FrameBoundaryScheduler, GpuCapabilitySnapshot, GpuDeviceLike, GpuInterfaceManifest, GpuRecordCodec, GpuRecordLayout, GpuRecordValue, JsonValue, LoadedShaderStyleProfile, ModelGpuCompatibilityDescriptor, ModelShaderCompatibility, PreparedShaderStyleProfile, PromotedShaderCatalogResolver, SerializableGpuPipelineDescriptor, Sha256Hex, ShaderRequirements, ShaderResult, ShaderStyleController, ShaderStyleProfileManifest, ShaderStyleProfileRef, ShaderVersionManifest, ShaderVersionManifestCore, activateStyleProfile, asSha256Hex, assertImmutableAssetVersion, canonicalizeGpuContract, computeGpuAbiHash, computeSha256, computeShaderManifestCoreSha256, createGpuRecordCodec, createShaderStyleController, loadShaderStyleProfile, parseCanonicalJson, parseGpuInterfaceManifest, parseJsonBytes, parseModelGpuCompatibilityDescriptor, parseShaderStyleProfileManifest, parseShaderVersionManifest, parseShaderVersionManifestCore, prepareStyleProfile, validateModelShaderCompatibility };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { J as JsonValue, S as Sha256Hex, G as GpuInterfaceManifest, a as SerializableGpuPipelineDescriptor, b as ShaderRequirements, c as ShaderVersionManifest, d as GpuRecordValue, e as GpuRecordLayout, f as GpuRecordCodec, M as ModelGpuCompatibilityDescriptor, g as ShaderVersionManifestCore, h as ShaderStyleProfileManifest, i as GpuCapabilitySnapshot, j as ShaderResult, k as ModelShaderCompatibility, l as ShaderStyleProfileRef, P as PromotedShaderCatalogResolver, L as LoadedShaderStyleProfile, m as GpuDeviceLike, n as PreparedShaderStyleProfile, o as ShaderStyleController, A as ActiveShaderStyleProfile, F as FrameBoundaryScheduler } from './contracts-B49AUejk.js';
2
2
  export { p as AssembledWgslModule, q as GPU_INTERFACE_MANIFEST_VERSION, r as GPU_SHADER_STORE_FEATURE_FLAG, s as GPU_SHADER_STYLE_SELECTION_CAPABILITY, t as GeneratedGpuInterfaceArtifacts, u as GitObjectId, v as GpuAddressSpace, w as GpuArrayLayout, x as GpuAtomicLayout, y as GpuBindingAccess, z as GpuBindingLayout, B as GpuBindingResourceLayout, C as GpuCompareFunction, D as GpuCompilationMessageLike, E as GpuEntryPointInterface, H as GpuEntryPointIo, I as GpuHostAddressSpace, K as GpuInterfaceRef, N as GpuLimitRequirement, O as GpuMatrixLayout, Q as GpuMatrixValue, R as GpuModelAbiProjection, T as GpuModelBindingLayout, U as GpuModelBindingSelector, V as GpuModelVertexInputLayout, W as GpuOverrideLayout, X as GpuRecordMemberLayout, Y as GpuRecordReferenceLayout, Z as GpuScalarKind, _ as GpuScalarLayout, $ as GpuScalarValue, a0 as GpuSemanticProjection, a1 as GpuSemanticSelector, a2 as GpuSemanticSource, a3 as GpuShaderModuleLike, a4 as GpuShaderStage, a5 as GpuTypeLayout, a6 as GpuVectorLayout, a7 as GpuVectorValue, a8 as GpuVertexInputLayout, a9 as GpuWorkgroupDimension, aa as JsonPrimitive, ab as LoadedShaderVersion, ac as ReflectGpuInterfaceInput, ad as SHADER_COMPILE_UNIT_VERSION, ae as SHADER_QUALIFICATION_BUNDLE_VERSION, af as SHADER_QUALIFICATION_FIXTURE_VERSION, ag as SHADER_STYLE_PROFILE_MANIFEST_VERSION, ah as SHADER_VALIDATION_EVIDENCE_VERSION, ai as SHADER_VERSION_MANIFEST_VERSION, aj as STABLE_WEBGPU_MATRIX_VERSION, ak as SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES, al as SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES, am as ScopedShaderValidationEvidenceRef, an as SerializableGpuBindGroupLayout, ao as SerializableGpuBlendComponent, ap as SerializableGpuComputePipelineDescriptor, aq as SerializableGpuPipelineLayout, ar as SerializableGpuProgrammableStage, as as SerializableGpuRenderPipelineDescriptor, at as SerializableGpuStencilFaceState, au as ShaderCellEvidence, av as ShaderCompileContext, aw as ShaderCompileFixture, ax as ShaderCompileUnitInventory, ay as ShaderCompileUnitManifest, az as ShaderDiagnostic, aA as ShaderDiagnosticCode, aB as ShaderDiagnosticSeverity, aC as ShaderMatrixBrowserName, aD as ShaderMatrixOsName, aE as ShaderNonQualifyingWorkflowDiagnostic, aF as ShaderQualificationBindGroupResource, aG as ShaderQualificationBufferRecordLayoutProbe, aH as ShaderQualificationBundleManifest, aI as ShaderQualificationCandidateSubject, aJ as ShaderQualificationCommand, aK as ShaderQualificationExecutionProducer, aL as ShaderQualificationFixtureManifest, aM as ShaderQualificationLayoutProbe, aN as ShaderQualificationModelCompatibilityFixture, aO as ShaderQualificationPhaseEvidence, aP as ShaderQualificationPhaseName, aQ as ShaderQualificationPreflightManifest, aR as ShaderQualificationResource, aS as ShaderQualificationResult, aT as ShaderQualificationStatus, aU as ShaderQualificationTextureViewDescriptor, aV as ShaderQualificationVertexInputLayoutProbe, aW as ShaderRenderRole, aX as ShaderRunnerCellPreflightEvidence, aY as ShaderStyleRoleBinding, aZ as ShaderTrustedWorkflowProvenance, a_ as ShaderValidationCellRun, a$ as ShaderValidationEvidence, b0 as ShaderValidationEvidenceAttestationRef, b1 as ShaderValidationEvidenceRef, b2 as ShaderValidationEvidenceSubject, b3 as ShaderValidationScopeRequirement, b4 as ShaderVersionRef, b5 as StableWebGpuMatrixCell, b6 as StableWebGpuMatrixManifest } from './contracts-B49AUejk.js';
3
3
 
4
+ /**
5
+ * Validates an immutable, reproducible model, interface, shader, or profile
6
+ * version before catalog access.
7
+ *
8
+ * The diagnostic is deliberately constant and never interpolates untrusted
9
+ * input, keeping runtime and storage-boundary failures bounded.
10
+ */
11
+ declare function assertImmutableAssetVersion(value: unknown): string;
12
+
4
13
  /**
5
14
  * Canonicalizes contract data using the JSON Canonicalization Scheme ordering
6
15
  * rules. Unsupported JavaScript values are rejected rather than silently lost.
@@ -85,4 +94,4 @@ declare function activateStyleProfile(input: {
85
94
  readonly retire?: (previous: PreparedShaderStyleProfile) => void | Promise<void>;
86
95
  }): Promise<ShaderResult<ActiveShaderStyleProfile>>;
87
96
 
88
- export { ActiveShaderStyleProfile, FrameBoundaryScheduler, GpuCapabilitySnapshot, GpuDeviceLike, GpuInterfaceManifest, GpuRecordCodec, GpuRecordLayout, GpuRecordValue, JsonValue, LoadedShaderStyleProfile, ModelGpuCompatibilityDescriptor, ModelShaderCompatibility, PreparedShaderStyleProfile, PromotedShaderCatalogResolver, SerializableGpuPipelineDescriptor, Sha256Hex, ShaderRequirements, ShaderResult, ShaderStyleController, ShaderStyleProfileManifest, ShaderStyleProfileRef, ShaderVersionManifest, ShaderVersionManifestCore, activateStyleProfile, asSha256Hex, canonicalizeGpuContract, computeGpuAbiHash, computeSha256, computeShaderManifestCoreSha256, createGpuRecordCodec, createShaderStyleController, loadShaderStyleProfile, parseCanonicalJson, parseGpuInterfaceManifest, parseJsonBytes, parseModelGpuCompatibilityDescriptor, parseShaderStyleProfileManifest, parseShaderVersionManifest, parseShaderVersionManifestCore, prepareStyleProfile, validateModelShaderCompatibility };
97
+ export { ActiveShaderStyleProfile, FrameBoundaryScheduler, GpuCapabilitySnapshot, GpuDeviceLike, GpuInterfaceManifest, GpuRecordCodec, GpuRecordLayout, GpuRecordValue, JsonValue, LoadedShaderStyleProfile, ModelGpuCompatibilityDescriptor, ModelShaderCompatibility, PreparedShaderStyleProfile, PromotedShaderCatalogResolver, SerializableGpuPipelineDescriptor, Sha256Hex, ShaderRequirements, ShaderResult, ShaderStyleController, ShaderStyleProfileManifest, ShaderStyleProfileRef, ShaderVersionManifest, ShaderVersionManifestCore, activateStyleProfile, asSha256Hex, assertImmutableAssetVersion, canonicalizeGpuContract, computeGpuAbiHash, computeSha256, computeShaderManifestCoreSha256, createGpuRecordCodec, createShaderStyleController, loadShaderStyleProfile, parseCanonicalJson, parseGpuInterfaceManifest, parseJsonBytes, parseModelGpuCompatibilityDescriptor, parseShaderStyleProfileManifest, parseShaderVersionManifest, parseShaderVersionManifestCore, prepareStyleProfile, validateModelShaderCompatibility };
package/dist/index.js CHANGED
@@ -19,6 +19,29 @@ var SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES = [
19
19
  Object.freeze(SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES);
20
20
  var SUPPORTED_ADDITIVE_WEBGPU_MATRIX_POLICIES = Object.freeze([]);
21
21
 
22
+ // src/asset-version.ts
23
+ var ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;
24
+ var MUTABLE_VERSION_ALIASES = /* @__PURE__ */ new Set([
25
+ "latest",
26
+ "current",
27
+ "stable",
28
+ "preview",
29
+ "default",
30
+ "production",
31
+ "canary",
32
+ "next",
33
+ "head",
34
+ "main"
35
+ ]);
36
+ var X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\.|-|$)|\.[xX](?:\.|-|$)/u;
37
+ var IMMUTABLE_VERSION_ERROR_MESSAGE = "Immutable asset version must be an exact token up to 128 characters; mutable aliases, ranges, wildcards, and URLs are not allowed.";
38
+ function assertImmutableAssetVersion(value) {
39
+ if (typeof value !== "string" || !ASSET_VERSION_PATTERN.test(value) || MUTABLE_VERSION_ALIASES.has(value.toLowerCase()) || X_WILDCARD_SEGMENT_PATTERN.test(value)) {
40
+ throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);
41
+ }
42
+ return value;
43
+ }
44
+
22
45
  // src/canonical-json.ts
23
46
  function isPlainObject(value) {
24
47
  const prototype = Object.getPrototypeOf(value);
@@ -827,96 +850,18 @@ function validateShaderDerivedRequirements(input) {
827
850
  for (const feature of inferWgslRequiredFeatures([...input.moduleSources.values()])) if (!features.has(feature)) throw new TypeError(`Shader requirements omit WGSL-derived feature ${feature}.`);
828
851
  }
829
852
 
830
- // src/compatibility.ts
831
- function error(code, message, path) {
832
- return { code, severity: "error", message, ...path ? { path } : {} };
833
- }
834
- function interfaceMatches(item, model) {
835
- return item.interfaceId === model.gpuInterface.interfaceId && item.interfaceVersion === model.gpuInterface.interfaceVersion && item.manifestSha256 === model.gpuInterface.manifestSha256 && item.interfaceAbiHash === model.gpuInterface.interfaceAbiHash && item.modelAbiHash === model.modelAbiHash;
836
- }
837
- function validateRequirements(shader, gpuInterface, model, capabilities, diagnostics) {
838
- const semantics = new Set(model.providedSemantics);
839
- const requiredSemantics = /* @__PURE__ */ new Set([
840
- ...shader.requirements.semantics,
841
- ...gpuInterface.modelAbi.semantics.map((projection) => projection.semantic)
842
- ]);
843
- for (const semantic2 of requiredSemantics) {
844
- if (!semantics.has(semantic2)) {
845
- diagnostics.push(error("missing-semantic", `Model does not provide required semantic ${semantic2}.`, "requirements.semantics"));
846
- }
847
- }
848
- if (!capabilities) return;
849
- const features = new Set(capabilities.features);
850
- for (const feature of shader.requirements.features) {
851
- if (!features.has(feature)) {
852
- diagnostics.push(error("missing-feature", `GPU does not provide required feature ${feature}.`, "requirements.features"));
853
- }
854
- }
855
- const formats = new Set(capabilities.formats);
856
- for (const format of shader.requirements.formats) {
857
- if (!formats.has(format)) {
858
- diagnostics.push(error("unsupported-format", `GPU runtime does not expose required format ${format}.`, "requirements.formats"));
859
- }
860
- }
861
- for (const requirement of shader.requirements.limits) {
862
- const available = capabilities.limits[requirement.name];
863
- const satisfied = available !== void 0 && (requirement.comparator === "at-least" ? available >= requirement.value : available <= requirement.value);
864
- if (!satisfied) {
865
- diagnostics.push(error(
866
- "limit-not-met",
867
- `GPU limit ${requirement.name} does not meet the ${requirement.comparator} requirement.`,
868
- "requirements.limits"
869
- ));
870
- }
871
- }
872
- }
873
- function validateModelShaderCompatibility(input) {
874
- const diagnostics = [];
875
- const { model, shader, gpuInterface, profile, capabilities } = input;
853
+ // src/manifest-validation.ts
854
+ var stages = ["vertex", "fragment", "compute"];
855
+ var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
856
+ function detachedJson(value, path) {
876
857
  try {
877
- validateShaderInterfaceRequirements({ manifest: shader, gpuInterface });
858
+ return JSON.parse(canonicalizeGpuContract(value));
878
859
  } catch (cause) {
879
- diagnostics.push(error(
880
- "invalid-contract",
881
- cause instanceof Error ? cause.message : "Shader requirements differ from the reflected GPU interface.",
882
- "requirements"
883
- ));
884
- }
885
- if (model.gpuInterface.modelAbiHash !== model.modelAbiHash) {
886
- diagnostics.push(error("model-abi-mismatch", "Model manifest and GPU interface reference disagree on modelAbiHash.", "modelAbiHash"));
887
- }
888
- if (shader.gpuInterface.modelAbiHash !== model.modelAbiHash) {
889
- diagnostics.push(error("model-abi-mismatch", "Shader GPU interface does not match the model ABI.", "gpuInterface.modelAbiHash"));
890
- }
891
- if (!shader.compatibleModelInterfaces.some((item) => interfaceMatches(item, model))) {
892
- diagnostics.push(error("incompatible-model-interface", "Shader does not declare this exact model interface as compatible."));
893
- }
894
- if (profile) {
895
- if (!profile.compatibleModelInterfaces.some((item) => interfaceMatches(item, model))) {
896
- diagnostics.push(error("incompatible-model-interface", "Style profile does not declare this exact model interface as compatible."));
897
- }
898
- const provided = new Set(model.providedSemantics);
899
- for (const semantic2 of profile.requiredSemantics) {
900
- if (!provided.has(semantic2)) {
901
- diagnostics.push(error("missing-semantic", `Model does not provide profile semantic ${semantic2}.`, "requiredSemantics"));
902
- }
903
- }
860
+ const detail = cause instanceof Error ? cause.message : "Contract snapshot failed.";
861
+ const boundedDetail = [...detail].slice(0, 512).join("");
862
+ throw new TypeError(`${path} must contain detached JSON contract data: ${boundedDetail}`, { cause });
904
863
  }
905
- validateRequirements(shader, gpuInterface, model, capabilities, diagnostics);
906
- if (diagnostics.length > 0) return { ok: false, diagnostics };
907
- return {
908
- ok: true,
909
- value: {
910
- modelAbiHash: model.modelAbiHash,
911
- shaderAbiHash: shader.shaderAbiHash,
912
- matchedInterfaceId: model.gpuInterface.interfaceId
913
- }
914
- };
915
864
  }
916
-
917
- // src/manifest-validation.ts
918
- var stages = ["vertex", "fragment", "compute"];
919
- var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
920
865
  function object(value, path) {
921
866
  if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path} must be an object.`);
922
867
  return value;
@@ -937,6 +882,16 @@ function token(value, path) {
937
882
  if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u.test(result) || result.includes("..")) throw new TypeError(`${path} must be a safe token.`);
938
883
  return result;
939
884
  }
885
+ function immutableVersion(value, path) {
886
+ try {
887
+ return assertImmutableAssetVersion(value);
888
+ } catch (cause) {
889
+ throw new TypeError(
890
+ `${path} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
891
+ { cause }
892
+ );
893
+ }
894
+ }
940
895
  function enumeration(value, values, path) {
941
896
  if (!values.includes(value)) throw new TypeError(`${path} is invalid.`);
942
897
  return value;
@@ -1210,7 +1165,7 @@ function interfaceRef(value, path) {
1210
1165
  const input = object(value, path);
1211
1166
  exact(input, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path);
1212
1167
  token(input.interfaceId, `${path}.interfaceId`);
1213
- token(input.interfaceVersion, `${path}.interfaceVersion`);
1168
+ immutableVersion(input.interfaceVersion, `${path}.interfaceVersion`);
1214
1169
  uri(input.manifestUri, `${path}.manifestUri`);
1215
1170
  digest(input.manifestSha256, `${path}.manifestSha256`);
1216
1171
  digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`);
@@ -1351,7 +1306,7 @@ function compatibleModel(value, path) {
1351
1306
  const input = object(value, path);
1352
1307
  exact(input, ["interfaceId", "interfaceVersion", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path);
1353
1308
  token(input.interfaceId, `${path}.interfaceId`);
1354
- token(input.interfaceVersion, `${path}.interfaceVersion`);
1309
+ immutableVersion(input.interfaceVersion, `${path}.interfaceVersion`);
1355
1310
  digest(input.manifestSha256, `${path}.manifestSha256`);
1356
1311
  digest(input.interfaceAbiHash, `${path}.interfaceAbiHash`);
1357
1312
  digest(input.modelAbiHash, `${path}.modelAbiHash`);
@@ -1364,7 +1319,7 @@ function validationEvidenceRef(value, path) {
1364
1319
  uri(evidence.uri, `${path}.uri`);
1365
1320
  digest(evidence.sha256, `${path}.sha256`);
1366
1321
  token(evidence.matrixId, `${path}.matrixId`);
1367
- token(evidence.matrixVersion, `${path}.matrixVersion`);
1322
+ immutableVersion(evidence.matrixVersion, `${path}.matrixVersion`);
1368
1323
  digest(evidence.matrixSha256, `${path}.matrixSha256`);
1369
1324
  const attestation = object(evidence.attestationRef, `${path}.attestationRef`);
1370
1325
  exact(attestation, ["uri", "sha256"], `${path}.attestationRef`);
@@ -1391,11 +1346,11 @@ function reflectedRecordBindingSize(record) {
1391
1346
  return Math.ceil(unrounded / record.alignment) * record.alignment;
1392
1347
  }
1393
1348
  function parseGpuInterfaceManifest(value) {
1394
- const input = object(value, "GpuInterfaceManifest");
1349
+ const input = object(detachedJson(value, "GpuInterfaceManifest"), "GpuInterfaceManifest");
1395
1350
  exact(input, ["contractVersion", "interfaceId", "interfaceVersion", "modules", "records", "bindings", "entryPoints", "vertexInputs", "overrides", "modelAbi", "modelAbiHash", "interfaceAbiHash", "generatedBy"], "GpuInterfaceManifest");
1396
1351
  if (input.contractVersion !== GPU_INTERFACE_MANIFEST_VERSION) throw new TypeError("Unsupported GPU interface contract version.");
1397
1352
  token(input.interfaceId, "GpuInterfaceManifest.interfaceId");
1398
- token(input.interfaceVersion, "GpuInterfaceManifest.interfaceVersion");
1353
+ immutableVersion(input.interfaceVersion, "GpuInterfaceManifest.interfaceVersion");
1399
1354
  const moduleValues = array(input.modules, "GpuInterfaceManifest.modules");
1400
1355
  if (moduleValues.length === 0) throw new TypeError("GpuInterfaceManifest.modules must not be empty.");
1401
1356
  const moduleIds = moduleValues.map((value2, index) => {
@@ -1577,11 +1532,11 @@ function parseGpuInterfaceManifest(value) {
1577
1532
  return freeze(input);
1578
1533
  }
1579
1534
  function parseShaderVersionManifest(value) {
1580
- const input = object(value, "ShaderVersionManifest");
1535
+ const input = object(detachedJson(value, "ShaderVersionManifest"), "ShaderVersionManifest");
1581
1536
  exact(input, ["contractVersion", "shaderId", "version", "modules", "gpuInterface", "pipelines", "renderRoles", "compatibleModelInterfaces", "requirements", "shaderAbiHash", "validationEvidence", "additionalValidationEvidence"], "ShaderVersionManifest");
1582
1537
  if (input.contractVersion !== SHADER_VERSION_MANIFEST_VERSION) throw new TypeError("Unsupported shader manifest contract version.");
1583
1538
  token(input.shaderId, "ShaderVersionManifest.shaderId");
1584
- token(input.version, "ShaderVersionManifest.version");
1539
+ immutableVersion(input.version, "ShaderVersionManifest.version");
1585
1540
  const moduleValues = array(input.modules, "ShaderVersionManifest.modules");
1586
1541
  if (moduleValues.length === 0) throw new TypeError("ShaderVersionManifest.modules must not be empty.");
1587
1542
  const moduleIds = moduleValues.map((item, index) => {
@@ -1694,7 +1649,7 @@ function parseShaderVersionManifest(value) {
1694
1649
  return freeze(input);
1695
1650
  }
1696
1651
  function parseShaderVersionManifestCore(value) {
1697
- const input = object(value, "ShaderVersionManifestCore");
1652
+ const input = object(detachedJson(value, "ShaderVersionManifestCore"), "ShaderVersionManifestCore");
1698
1653
  if ("validationEvidence" in input || "additionalValidationEvidence" in input) {
1699
1654
  throw new TypeError("ShaderVersionManifestCore must not contain validationEvidence or additionalValidationEvidence.");
1700
1655
  }
@@ -1720,11 +1675,11 @@ function parseShaderVersionManifestCore(value) {
1720
1675
  return freeze(core);
1721
1676
  }
1722
1677
  function parseShaderStyleProfileManifest(value) {
1723
- const input = object(value, "ShaderStyleProfileManifest");
1678
+ const input = object(detachedJson(value, "ShaderStyleProfileManifest"), "ShaderStyleProfileManifest");
1724
1679
  exact(input, ["contractVersion", "profileId", "version", "style", "roles", "compatibleModelInterfaces", "requiredSemantics", "requiredValidationScopes"], "ShaderStyleProfileManifest");
1725
1680
  if (input.contractVersion !== SHADER_STYLE_PROFILE_MANIFEST_VERSION) throw new TypeError("Unsupported style-profile contract version.");
1726
1681
  token(input.profileId, "ShaderStyleProfileManifest.profileId");
1727
- token(input.version, "ShaderStyleProfileManifest.version");
1682
+ immutableVersion(input.version, "ShaderStyleProfileManifest.version");
1728
1683
  token(input.style, "ShaderStyleProfileManifest.style");
1729
1684
  const roleValues = array(input.roles, "ShaderStyleProfileManifest.roles", 5);
1730
1685
  if (roleValues.length === 0) throw new TypeError("ShaderStyleProfileManifest.roles must not be empty.");
@@ -1737,7 +1692,7 @@ function parseShaderStyleProfileManifest(value) {
1737
1692
  const shader = object(role.shader, `${path}.shader`);
1738
1693
  exact(shader, ["shaderId", "version", "manifestUri", "manifestSha256"], `${path}.shader`);
1739
1694
  token(shader.shaderId, `${path}.shader.shaderId`);
1740
- token(shader.version, `${path}.shader.version`);
1695
+ immutableVersion(shader.version, `${path}.shader.version`);
1741
1696
  uri(shader.manifestUri, `${path}.shader.manifestUri`);
1742
1697
  digest(shader.manifestSha256, `${path}.shader.manifestSha256`);
1743
1698
  });
@@ -1753,7 +1708,7 @@ function parseShaderStyleProfileManifest(value) {
1753
1708
  const scope = token(requirement.scope, `${path}.scope`);
1754
1709
  if (scope === "universal") throw new TypeError(`${path}.scope must not use the reserved universal scope.`);
1755
1710
  token(requirement.matrixId, `${path}.matrixId`);
1756
- token(requirement.matrixVersion, `${path}.matrixVersion`);
1711
+ immutableVersion(requirement.matrixVersion, `${path}.matrixVersion`);
1757
1712
  const matrixSha256 = digest(requirement.matrixSha256, `${path}.matrixSha256`);
1758
1713
  if (SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES.some((policy) => policy.matrixSha256 === matrixSha256)) {
1759
1714
  throw new TypeError(`${path} must require an additive matrix policy, not the universal matrix policy.`);
@@ -1768,10 +1723,10 @@ function parseShaderStyleProfileManifest(value) {
1768
1723
  return freeze(input);
1769
1724
  }
1770
1725
  function parseModelGpuCompatibilityDescriptor(value) {
1771
- const input = object(value, "ModelGpuCompatibilityDescriptor");
1726
+ const input = object(detachedJson(value, "ModelGpuCompatibilityDescriptor"), "ModelGpuCompatibilityDescriptor");
1772
1727
  exact(input, ["modelId", "version", "gpuInterface", "modelAbiHash", "providedSemantics", "defaultStyleProfile"], "ModelGpuCompatibilityDescriptor");
1773
1728
  token(input.modelId, "ModelGpuCompatibilityDescriptor.modelId");
1774
- token(input.version, "ModelGpuCompatibilityDescriptor.version");
1729
+ immutableVersion(input.version, "ModelGpuCompatibilityDescriptor.version");
1775
1730
  const gpuInterface = interfaceRef(input.gpuInterface, "ModelGpuCompatibilityDescriptor.gpuInterface");
1776
1731
  const modelAbiHash = digest(input.modelAbiHash, "ModelGpuCompatibilityDescriptor.modelAbiHash");
1777
1732
  if (gpuInterface.modelAbiHash !== modelAbiHash) throw new TypeError("ModelGpuCompatibilityDescriptor.gpuInterface.modelAbiHash differs from modelAbiHash.");
@@ -1780,7 +1735,7 @@ function parseModelGpuCompatibilityDescriptor(value) {
1780
1735
  const profile = object(input.defaultStyleProfile, "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
1781
1736
  exact(profile, ["profileId", "version", "manifestUri", "manifestSha256"], "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
1782
1737
  token(profile.profileId, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.profileId");
1783
- token(profile.version, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.version");
1738
+ immutableVersion(profile.version, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.version");
1784
1739
  uri(profile.manifestUri, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestUri");
1785
1740
  digest(profile.manifestSha256, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestSha256");
1786
1741
  }
@@ -1794,6 +1749,135 @@ function parseJsonBytes(bytes, label) {
1794
1749
  }
1795
1750
  }
1796
1751
 
1752
+ // src/compatibility.ts
1753
+ function error(code, message, path) {
1754
+ const bounded = [...message].map((character) => {
1755
+ const codePoint = character.codePointAt(0);
1756
+ return codePoint <= 31 || codePoint === 127 ? " " : character;
1757
+ }).slice(0, 512).join("");
1758
+ return { code, severity: "error", message: bounded, ...path ? { path } : {} };
1759
+ }
1760
+ function interfaceMatches(item, model) {
1761
+ return item.interfaceId === model.gpuInterface.interfaceId && item.interfaceVersion === model.gpuInterface.interfaceVersion && item.manifestSha256 === model.gpuInterface.manifestSha256 && item.interfaceAbiHash === model.gpuInterface.interfaceAbiHash && item.modelAbiHash === model.modelAbiHash;
1762
+ }
1763
+ function detachedContract(value) {
1764
+ return JSON.parse(canonicalizeGpuContract(value));
1765
+ }
1766
+ function hasValidationEvidence(value) {
1767
+ return typeof value === "object" && value !== null && !Array.isArray(value) && (Object.hasOwn(value, "validationEvidence") || Object.hasOwn(value, "additionalValidationEvidence"));
1768
+ }
1769
+ function validateRequirements(shader, gpuInterface, model, capabilities, diagnostics) {
1770
+ const semantics = new Set(model.providedSemantics);
1771
+ const requiredSemantics = /* @__PURE__ */ new Set([
1772
+ ...shader.requirements.semantics,
1773
+ ...gpuInterface.modelAbi.semantics.map((projection) => projection.semantic)
1774
+ ]);
1775
+ for (const semantic2 of requiredSemantics) {
1776
+ if (!semantics.has(semantic2)) {
1777
+ diagnostics.push(error("missing-semantic", `Model does not provide required semantic ${semantic2}.`, "requirements.semantics"));
1778
+ }
1779
+ }
1780
+ if (!capabilities) return;
1781
+ const features = new Set(capabilities.features);
1782
+ for (const feature of shader.requirements.features) {
1783
+ if (!features.has(feature)) {
1784
+ diagnostics.push(error("missing-feature", `GPU does not provide required feature ${feature}.`, "requirements.features"));
1785
+ }
1786
+ }
1787
+ const formats = new Set(capabilities.formats);
1788
+ for (const format of shader.requirements.formats) {
1789
+ if (!formats.has(format)) {
1790
+ diagnostics.push(error("unsupported-format", `GPU runtime does not expose required format ${format}.`, "requirements.formats"));
1791
+ }
1792
+ }
1793
+ for (const requirement of shader.requirements.limits) {
1794
+ const available = capabilities.limits[requirement.name];
1795
+ const satisfied = available !== void 0 && (requirement.comparator === "at-least" ? available >= requirement.value : available <= requirement.value);
1796
+ if (!satisfied) {
1797
+ diagnostics.push(error(
1798
+ "limit-not-met",
1799
+ `GPU limit ${requirement.name} does not meet the ${requirement.comparator} requirement.`,
1800
+ "requirements.limits"
1801
+ ));
1802
+ }
1803
+ }
1804
+ }
1805
+ function validateModelShaderCompatibility(input) {
1806
+ const diagnostics = [];
1807
+ let model;
1808
+ let shader;
1809
+ let gpuInterface;
1810
+ let profile;
1811
+ let capabilities;
1812
+ try {
1813
+ const modelSnapshot = detachedContract(input.model);
1814
+ const shaderSnapshot = detachedContract(input.shader);
1815
+ const gpuInterfaceSnapshot = detachedContract(input.gpuInterface);
1816
+ const profileValue = input.profile;
1817
+ const profileSnapshot = profileValue === void 0 ? void 0 : detachedContract(profileValue);
1818
+ model = parseModelGpuCompatibilityDescriptor(modelSnapshot);
1819
+ shader = hasValidationEvidence(shaderSnapshot) ? parseShaderVersionManifest(shaderSnapshot) : parseShaderVersionManifestCore(shaderSnapshot);
1820
+ gpuInterface = parseGpuInterfaceManifest(gpuInterfaceSnapshot);
1821
+ profile = profileSnapshot === void 0 ? void 0 : parseShaderStyleProfileManifest(profileSnapshot);
1822
+ capabilities = input.capabilities;
1823
+ } catch (cause) {
1824
+ return {
1825
+ ok: false,
1826
+ diagnostics: [error(
1827
+ "invalid-contract",
1828
+ cause instanceof Error ? cause.message : "GPU compatibility contract snapshot failed."
1829
+ )]
1830
+ };
1831
+ }
1832
+ try {
1833
+ validateShaderInterfaceRequirements({ manifest: shader, gpuInterface });
1834
+ } catch (cause) {
1835
+ diagnostics.push(error(
1836
+ "invalid-contract",
1837
+ cause instanceof Error ? cause.message : "Shader requirements differ from the reflected GPU interface.",
1838
+ "requirements"
1839
+ ));
1840
+ }
1841
+ if (model.gpuInterface.modelAbiHash !== model.modelAbiHash) {
1842
+ diagnostics.push(error("model-abi-mismatch", "Model manifest and GPU interface reference disagree on modelAbiHash.", "modelAbiHash"));
1843
+ }
1844
+ if (shader.gpuInterface.modelAbiHash !== model.modelAbiHash) {
1845
+ diagnostics.push(error("model-abi-mismatch", "Shader GPU interface does not match the model ABI.", "gpuInterface.modelAbiHash"));
1846
+ }
1847
+ if (!shader.compatibleModelInterfaces.some((item) => interfaceMatches(item, model))) {
1848
+ diagnostics.push(error("incompatible-model-interface", "Shader does not declare this exact model interface as compatible."));
1849
+ }
1850
+ if (profile) {
1851
+ if (!profile.compatibleModelInterfaces.some((item) => interfaceMatches(item, model))) {
1852
+ diagnostics.push(error("incompatible-model-interface", "Style profile does not declare this exact model interface as compatible."));
1853
+ }
1854
+ const provided = new Set(model.providedSemantics);
1855
+ for (const semantic2 of profile.requiredSemantics) {
1856
+ if (!provided.has(semantic2)) {
1857
+ diagnostics.push(error("missing-semantic", `Model does not provide profile semantic ${semantic2}.`, "requiredSemantics"));
1858
+ }
1859
+ }
1860
+ }
1861
+ try {
1862
+ validateRequirements(shader, gpuInterface, model, capabilities, diagnostics);
1863
+ } catch (cause) {
1864
+ diagnostics.push(error(
1865
+ "invalid-contract",
1866
+ cause instanceof Error ? cause.message : "GPU capability snapshot validation failed.",
1867
+ "capabilities"
1868
+ ));
1869
+ }
1870
+ if (diagnostics.length > 0) return { ok: false, diagnostics };
1871
+ return {
1872
+ ok: true,
1873
+ value: {
1874
+ modelAbiHash: model.modelAbiHash,
1875
+ shaderAbiHash: shader.shaderAbiHash,
1876
+ matchedInterfaceId: model.gpuInterface.interfaceId
1877
+ }
1878
+ };
1879
+ }
1880
+
1797
1881
  // src/runtime/trusted-values.ts
1798
1882
  var ReadonlyMapView = class {
1799
1883
  #source;
@@ -1920,6 +2004,36 @@ async function verifyBytes(bytes, expected, label) {
1920
2004
  function copyBytes(bytes) {
1921
2005
  return new Uint8Array(bytes);
1922
2006
  }
2007
+ function snapshotProfileRef(ref) {
2008
+ const profileId = ref.profileId;
2009
+ const version = ref.version;
2010
+ const manifestUri = ref.manifestUri;
2011
+ const manifestSha256 = ref.manifestSha256;
2012
+ return Object.freeze({ profileId, version, manifestUri, manifestSha256 });
2013
+ }
2014
+ function snapshotShaderRef(ref) {
2015
+ const shaderId = ref.shaderId;
2016
+ const version = ref.version;
2017
+ const manifestUri = ref.manifestUri;
2018
+ const manifestSha256 = ref.manifestSha256;
2019
+ return Object.freeze({ shaderId, version, manifestUri, manifestSha256 });
2020
+ }
2021
+ function snapshotInterfaceRef(ref) {
2022
+ const interfaceId = ref.interfaceId;
2023
+ const interfaceVersion = ref.interfaceVersion;
2024
+ const manifestUri = ref.manifestUri;
2025
+ const manifestSha256 = ref.manifestSha256;
2026
+ const interfaceAbiHash = ref.interfaceAbiHash;
2027
+ const modelAbiHash = ref.modelAbiHash;
2028
+ return Object.freeze({
2029
+ interfaceId,
2030
+ interfaceVersion,
2031
+ manifestUri,
2032
+ manifestSha256,
2033
+ interfaceAbiHash,
2034
+ modelAbiHash
2035
+ });
2036
+ }
1923
2037
  function throwIfAborted(signal) {
1924
2038
  if (signal?.aborted) throw signal.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
1925
2039
  }
@@ -1983,6 +2097,7 @@ async function mapLimit(values, limit, operation, signal) {
1983
2097
  }
1984
2098
  async function loadInterface(catalog, ref, signal) {
1985
2099
  throwIfAborted(signal);
2100
+ assertImmutableAssetVersion(ref.interfaceVersion);
1986
2101
  if (!catalog.isCatalogAssetUri(ref.manifestUri)) throw new TypeError("GPU interface URI is outside the promoted catalog root.");
1987
2102
  const loaded = await catalog.loadInterface(ref, signal);
1988
2103
  const bytes = copyBytes(loaded.bytes);
@@ -2003,6 +2118,7 @@ async function loadInterface(catalog, ref, signal) {
2003
2118
  }
2004
2119
  async function loadShader(catalog, ref, signal) {
2005
2120
  throwIfAborted(signal);
2121
+ assertImmutableAssetVersion(ref.version);
2006
2122
  if (!catalog.isCatalogAssetUri(ref.manifestUri)) throw new TypeError("Shader manifest URI is outside the promoted catalog root.");
2007
2123
  const loaded = await catalog.loadShader(ref, signal);
2008
2124
  const bytes = copyBytes(loaded.bytes);
@@ -2021,7 +2137,8 @@ async function loadShader(catalog, ref, signal) {
2021
2137
  if (!catalog.isCatalogAssetUri(evidence.uri)) throw new TypeError("Shader validation evidence URI is outside the promoted catalog root.");
2022
2138
  if (!catalog.isCatalogAssetUri(evidence.attestationRef.uri)) throw new TypeError("Shader validation evidence attestation URI is outside the promoted catalog root.");
2023
2139
  }
2024
- const gpuInterface = await loadInterface(catalog, manifest.gpuInterface, signal);
2140
+ const interfaceRef2 = snapshotInterfaceRef(manifest.gpuInterface);
2141
+ const gpuInterface = await loadInterface(catalog, interfaceRef2, signal);
2025
2142
  const normalizeModules = (values) => [...values].sort((left, right) => left.moduleId < right.moduleId ? -1 : left.moduleId > right.moduleId ? 1 : 0).map(({ moduleId, sha256 }) => ({ moduleId, sha256 }));
2026
2143
  if (canonicalizeGpuContract(normalizeModules(gpuInterface.modules)) !== canonicalizeGpuContract(normalizeModules(manifest.modules))) {
2027
2144
  throw new TypeError("Shader modules differ from the exact reflected GPU interface module set.");
@@ -2052,28 +2169,32 @@ async function loadShader(catalog, ref, signal) {
2052
2169
  return { ref, manifest, gpuInterface, modules: new Map(modulePairs) };
2053
2170
  }
2054
2171
  async function loadShaderStyleProfile(input) {
2172
+ const signal = input.signal;
2055
2173
  try {
2056
- throwIfAborted(input.signal);
2057
- if (!input.catalog.isCatalogAssetUri(input.ref.manifestUri)) throw new TypeError("Style profile URI is outside the promoted catalog root.");
2058
- const loaded = await input.catalog.loadProfile(input.ref, input.signal);
2174
+ throwIfAborted(signal);
2175
+ const ref = snapshotProfileRef(input.ref);
2176
+ assertImmutableAssetVersion(ref.version);
2177
+ if (!input.catalog.isCatalogAssetUri(ref.manifestUri)) throw new TypeError("Style profile URI is outside the promoted catalog root.");
2178
+ const loaded = await input.catalog.loadProfile(ref, signal);
2059
2179
  const profileBytes = copyBytes(loaded.bytes);
2060
2180
  const promoted = loaded.promoted;
2061
- throwIfAborted(input.signal);
2181
+ throwIfAborted(signal);
2062
2182
  if (!promoted) {
2063
2183
  return { ok: false, diagnostics: [diagnostic("unpromoted-asset", "Style profile is not promoted.")] };
2064
2184
  }
2065
- await verifyBytes(profileBytes, input.ref.manifestSha256, "Style profile manifest");
2185
+ await verifyBytes(profileBytes, ref.manifestSha256, "Style profile manifest");
2066
2186
  const manifest = parseShaderStyleProfileManifest(parseJsonBytes(profileBytes, "Style profile manifest"));
2067
- if (manifest.profileId !== input.ref.profileId || manifest.version !== input.ref.version) {
2187
+ if (manifest.profileId !== ref.profileId || manifest.version !== ref.version) {
2068
2188
  return { ok: false, diagnostics: [diagnostic("invalid-contract", "Style profile identity does not match its exact reference.")] };
2069
2189
  }
2070
2190
  const cache = /* @__PURE__ */ new Map();
2071
2191
  const pairs = await mapLimit(manifest.roles, 4, async (binding2) => {
2072
- throwIfAborted(input.signal);
2073
- const cacheKey = exactShaderRefKey(binding2.shader);
2192
+ throwIfAborted(signal);
2193
+ const shaderRef = snapshotShaderRef(binding2.shader);
2194
+ const cacheKey = exactShaderRefKey(shaderRef);
2074
2195
  let shader = cache.get(cacheKey);
2075
2196
  if (!shader) {
2076
- shader = loadShader(input.catalog, binding2.shader, input.signal);
2197
+ shader = loadShader(input.catalog, shaderRef, signal);
2077
2198
  cache.set(cacheKey, shader);
2078
2199
  }
2079
2200
  const resolved = await shader;
@@ -2095,18 +2216,18 @@ async function loadShaderStyleProfile(input) {
2095
2216
  }
2096
2217
  }
2097
2218
  return [binding2.role, resolved];
2098
- }, input.signal);
2219
+ }, signal);
2099
2220
  assertDistinctEvidenceOwnership(pairs.map(([, shader]) => shader));
2100
2221
  return {
2101
2222
  ok: true,
2102
2223
  value: trustLoadedShaderStyleProfile({
2103
- ref: input.ref,
2224
+ ref,
2104
2225
  manifest,
2105
2226
  shaders: new Map(pairs)
2106
2227
  })
2107
2228
  };
2108
2229
  } catch (cause) {
2109
- if (input.signal?.aborted) throw cause;
2230
+ if (signal?.aborted) throw cause;
2110
2231
  const code = cause instanceof TypeError && /digest/u.test(cause.message) ? "digest-mismatch" : "invalid-contract";
2111
2232
  return {
2112
2233
  ok: false,
@@ -2436,6 +2557,7 @@ export {
2436
2557
  SUPPORTED_STABLE_WEBGPU_MATRIX_POLICIES,
2437
2558
  activateStyleProfile,
2438
2559
  asSha256Hex,
2560
+ assertImmutableAssetVersion,
2439
2561
  canonicalizeGpuContract,
2440
2562
  computeGpuAbiHash,
2441
2563
  computeSha256,